Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: gpu/command_buffer/service/async_pixel_transfer_manager_idle.cc

Issue 16325018: GPU: Factory produces APTManagers instead of APTDelegates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/async_pixel_transfer_manager_idle.cc
diff --git a/gpu/command_buffer/service/async_pixel_transfer_delegate_idle.cc b/gpu/command_buffer/service/async_pixel_transfer_manager_idle.cc
similarity index 76%
rename from gpu/command_buffer/service/async_pixel_transfer_delegate_idle.cc
rename to gpu/command_buffer/service/async_pixel_transfer_manager_idle.cc
index d8bf916dbbed19b003fa075fda36414bb5dce507..43b62ff26578bb4cf7e06ca6dcdfc7f853df438d 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_delegate_idle.cc
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_idle.cc
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "gpu/command_buffer/service/async_pixel_transfer_delegate_idle.h"
+#include "gpu/command_buffer/service/async_pixel_transfer_manager_idle.h"
+
+#include <list>
#include "base/bind.h"
#include "base/debug/trace_event.h"
@@ -61,6 +63,75 @@ class AsyncPixelTransferStateImpl : public AsyncPixelTransferState {
} // namespace
+// Class which handles async pixel transfers in a platform
+// independent way.
+class AsyncPixelTransferDelegateIdle : public AsyncPixelTransferDelegate,
+ public base::SupportsWeakPtr<AsyncPixelTransferDelegateIdle> {
+ public:
+ AsyncPixelTransferDelegateIdle();
+ virtual ~AsyncPixelTransferDelegateIdle();
+
+ // implement AsyncPixelTransferDelegate:
+ virtual AsyncPixelTransferState* CreatePixelTransferState(
+ GLuint texture_id,
+ const AsyncTexImage2DParams& define_params) OVERRIDE;
+ virtual void BindCompletedAsyncTransfers() OVERRIDE;
+ virtual void AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) OVERRIDE;
+ virtual void AsyncTexImage2D(
+ AsyncPixelTransferState* transfer_state,
+ const AsyncTexImage2DParams& tex_params,
+ const AsyncMemoryParams& mem_params,
+ const base::Closure& bind_callback) OVERRIDE;
+ virtual void AsyncTexSubImage2D(
+ AsyncPixelTransferState* transfer_state,
+ const AsyncTexSubImage2DParams& tex_params,
+ const AsyncMemoryParams& mem_params) OVERRIDE;
+ virtual void WaitForTransferCompletion(
+ AsyncPixelTransferState* transfer_state) OVERRIDE;
+ virtual uint32 GetTextureUploadCount() OVERRIDE;
+ virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
+ virtual void ProcessMorePendingTransfers() OVERRIDE;
+ virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
+
+ private:
+ struct Task {
+ Task(uint64 transfer_id, const base::Closure& task);
+ ~Task();
+
+ // This is non-zero if pixel transfer task.
+ uint64 transfer_id;
+
+ base::Closure task;
+ };
+
+ void ProcessNotificationTasks();
+
+ void PerformNotifyCompletion(
+ AsyncMemoryParams mem_params,
+ ScopedSafeSharedMemory* safe_shared_memory,
+ const CompletionCallback& callback);
+ void PerformAsyncTexImage2D(
+ AsyncTexImage2DParams tex_params,
+ AsyncMemoryParams mem_params,
+ const base::Closure& bind_callback,
+ ScopedSafeSharedMemory* safe_shared_memory,
+ GLuint texture_id);
+ void PerformAsyncTexSubImage2D(
+ AsyncTexSubImage2DParams tex_params,
+ AsyncMemoryParams mem_params,
+ ScopedSafeSharedMemory* safe_shared_memory,
+ GLuint texture_id);
+
+ int texture_upload_count_;
+ base::TimeDelta total_texture_upload_time_;
+
+ std::list<Task> tasks_;
+
+ DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateIdle);
+};
+
AsyncPixelTransferDelegateIdle::Task::Task(
uint64 transfer_id, const base::Closure& task)
: transfer_id(transfer_id),
@@ -296,4 +367,14 @@ void AsyncPixelTransferDelegateIdle::PerformAsyncTexSubImage2D(
total_texture_upload_time_ += base::TimeTicks::HighResNow() - begin_time;
}
+AsyncPixelTransferManagerIdle::AsyncPixelTransferManagerIdle()
+ : delegate_(new AsyncPixelTransferDelegateIdle()) {}
+
+AsyncPixelTransferManagerIdle::~AsyncPixelTransferManagerIdle() {}
+
+AsyncPixelTransferDelegate*
+AsyncPixelTransferManagerIdle::GetAsyncPixelTransferDelegate() {
+ return delegate_.get();
+}
+
} // namespace gpu

Powered by Google App Engine
This is Rietveld 408576698