summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-05 08:34:48 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-05 08:34:48 +0000
commitb68b100758909332722402ea428c83af7053fc55 (patch)
tree5b8840cd8a9695e685dc04c8536c9f6d250d2dc1 /gpu
parente6a66079b908538c6c9c3f8fb6a0626f8c8f706a (diff)
downloadchromium_src-b68b100758909332722402ea428c83af7053fc55.zip
chromium_src-b68b100758909332722402ea428c83af7053fc55.tar.gz
chromium_src-b68b100758909332722402ea428c83af7053fc55.tar.bz2
GPU: Proxy calls from Manager to Delegate.
This is part of a larger refactoring to hollow out Delegate to the point where it can take the place of State (stored per TextureRef). Where necessary we proxy calls from the Manager to the Delegate (EGL, ShareGroup, and Idle). No functional change. BUG=240504 Review URL: https://chromiumcodereview.appspot.com/16154032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204210 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_delegate.h20
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h8
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager.h22
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_egl.cc125
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_egl.h14
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_idle.cc51
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_idle.h8
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_mock.cc15
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_mock.h34
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_share_group.cc108
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_share_group.h14
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_stub.cc44
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_stub.h8
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_sync.cc50
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_sync.h8
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_test.cc23
-rw-r--r--gpu/command_buffer/service/async_pixel_transfer_manager_test.h34
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc12
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc24
-rw-r--r--gpu/command_buffer/service/query_manager.cc4
-rw-r--r--gpu/gpu.gyp4
21 files changed, 341 insertions, 289 deletions
diff --git a/gpu/command_buffer/service/async_pixel_transfer_delegate.h b/gpu/command_buffer/service/async_pixel_transfer_delegate.h
index c8e9ded..b8e33a6 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_delegate.h
+++ b/gpu/command_buffer/service/async_pixel_transfer_delegate.h
@@ -94,21 +94,12 @@ class GPU_EXPORT AsyncPixelTransferState
class GPU_EXPORT AsyncPixelTransferDelegate {
public:
- typedef base::Callback<void(const AsyncMemoryParams&)> CompletionCallback;
-
virtual ~AsyncPixelTransferDelegate();
virtual AsyncPixelTransferState* CreatePixelTransferState(
GLuint texture_id,
const AsyncTexImage2DParams& define_params) = 0;
- virtual void BindCompletedAsyncTransfers() = 0;
-
- // There's no guarantee that callback will run on the caller thread.
- virtual void AsyncNotifyCompletion(
- const AsyncMemoryParams& mem_params,
- const CompletionCallback& callback) = 0;
-
// The callback occurs on the caller thread, once the texture is
// safe/ready to be used.
virtual void AsyncTexImage2D(
@@ -126,17 +117,6 @@ class GPU_EXPORT AsyncPixelTransferDelegate {
virtual void WaitForTransferCompletion(
AsyncPixelTransferState* state) = 0;
- virtual uint32 GetTextureUploadCount() = 0;
- virtual base::TimeDelta GetTotalTextureUploadTime() = 0;
-
- // ProcessMorePendingTransfers() will be called at a good time
- // to process a small amount of pending transfer work while
- // NeedsProcessMorePendingTransfers() returns true. Implementations
- // that can't dispatch work to separate threads should use
- // this to avoid blocking the caller thread inappropriately.
- virtual void ProcessMorePendingTransfers() = 0;
- virtual bool NeedsProcessMorePendingTransfers() = 0;
-
// Gets the address of the data from shared memory.
static void* GetAddress(const AsyncMemoryParams& mem_params);
diff --git a/gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h b/gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h
index f16934c..55f43e8 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h
+++ b/gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h
@@ -36,10 +36,6 @@ class MockAsyncPixelTransferDelegate : public AsyncPixelTransferDelegate {
MOCK_METHOD2(CreatePixelTransferState,
AsyncPixelTransferState*(
GLuint service_id, const AsyncTexImage2DParams& define_params));
- MOCK_METHOD0(BindCompletedAsyncTransfers, void());
- MOCK_METHOD2(AsyncNotifyCompletion,
- void(const AsyncMemoryParams& mem_params,
- const CompletionCallback& callback));
MOCK_METHOD4(AsyncTexImage2D,
void(AsyncPixelTransferState*,
const AsyncTexImage2DParams& tex_params,
@@ -50,10 +46,6 @@ class MockAsyncPixelTransferDelegate : public AsyncPixelTransferDelegate {
const AsyncTexSubImage2DParams& tex_params,
const AsyncMemoryParams& mem_params));
MOCK_METHOD1(WaitForTransferCompletion, void(AsyncPixelTransferState*));
- MOCK_METHOD0(GetTextureUploadCount, uint32());
- MOCK_METHOD0(GetTotalTextureUploadTime, base::TimeDelta());
- MOCK_METHOD0(ProcessMorePendingTransfers, void());
- MOCK_METHOD0(NeedsProcessMorePendingTransfers, bool());
private:
DISALLOW_COPY_AND_ASSIGN(MockAsyncPixelTransferDelegate);
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager.h b/gpu/command_buffer/service/async_pixel_transfer_manager.h
index 21f3980..6ae71ef 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_manager.h
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager.h
@@ -8,6 +8,7 @@
#include <set>
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/hash_tables.h"
#include "base/memory/ref_counted.h"
#include "gpu/command_buffer/service/texture_manager.h"
@@ -31,17 +32,38 @@ class GLContext;
namespace gpu {
class AsyncPixelTransferDelegate;
class AsyncPixelTransferState;
+struct AsyncMemoryParams;
struct AsyncTexImage2DParams;
class GPU_EXPORT AsyncPixelTransferManager
: public gles2::TextureManager::DestructionObserver {
public:
+ typedef base::Callback<void(const AsyncMemoryParams&)> CompletionCallback;
+
static AsyncPixelTransferManager* Create(gfx::GLContext* context);
virtual ~AsyncPixelTransferManager();
void Initialize(gles2::TextureManager* texture_manager);
+ virtual void BindCompletedAsyncTransfers() = 0;
+
+ // There's no guarantee that callback will run on the caller thread.
+ virtual void AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) = 0;
+
+ virtual uint32 GetTextureUploadCount() = 0;
+ virtual base::TimeDelta GetTotalTextureUploadTime() = 0;
+
+ // ProcessMorePendingTransfers() will be called at a good time
+ // to process a small amount of pending transfer work while
+ // NeedsProcessMorePendingTransfers() returns true. Implementations
+ // that can't dispatch work to separate threads should use
+ // this to avoid blocking the caller thread inappropriately.
+ virtual void ProcessMorePendingTransfers() = 0;
+ virtual bool NeedsProcessMorePendingTransfers() = 0;
+
virtual AsyncPixelTransferDelegate* GetAsyncPixelTransferDelegate() = 0;
AsyncPixelTransferState* CreatePixelTransferState(
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_egl.cc b/gpu/command_buffer/service/async_pixel_transfer_manager_egl.cc
index 1a7b301..5082f9a 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_manager_egl.cc
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_egl.cc
@@ -78,6 +78,16 @@ void SetGlParametersForEglImageTexture() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
+void PerformNotifyCompletion(
+ AsyncMemoryParams mem_params,
+ ScopedSafeSharedMemory* safe_shared_memory,
+ const AsyncPixelTransferManager::CompletionCallback& callback) {
+ TRACE_EVENT0("gpu", "PerformNotifyCompletion");
+ AsyncMemoryParams safe_mem_params = mem_params;
+ safe_mem_params.shared_memory = safe_shared_memory->shared_memory();
+ callback.Run(safe_mem_params);
+}
+
class TransferThread : public base::Thread {
public:
TransferThread() : base::Thread(kAsyncTransferThreadName) {
@@ -417,17 +427,15 @@ class AsyncPixelTransferDelegateEGL
: public AsyncPixelTransferDelegate,
public base::SupportsWeakPtr<AsyncPixelTransferDelegateEGL> {
public:
- AsyncPixelTransferDelegateEGL();
+ explicit AsyncPixelTransferDelegateEGL(AsyncPixelTransferUploadStats* stats);
virtual ~AsyncPixelTransferDelegateEGL();
+ void BindCompletedAsyncTransfers();
+
// 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* state,
const AsyncTexImage2DParams& tex_params,
@@ -439,17 +447,8 @@ class AsyncPixelTransferDelegateEGL
const AsyncMemoryParams& mem_params) OVERRIDE;
virtual void WaitForTransferCompletion(
AsyncPixelTransferState* state) OVERRIDE;
- virtual uint32 GetTextureUploadCount() OVERRIDE;
- virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
- virtual void ProcessMorePendingTransfers() OVERRIDE;
- virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
private:
- static void PerformNotifyCompletion(
- AsyncMemoryParams mem_params,
- ScopedSafeSharedMemory* safe_shared_memory,
- const CompletionCallback& callback);
-
// Returns true if a work-around was used.
bool WorkAroundAsyncTexImage2D(
AsyncPixelTransferState* state,
@@ -471,13 +470,13 @@ class AsyncPixelTransferDelegateEGL
DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateEGL);
};
-AsyncPixelTransferDelegateEGL::AsyncPixelTransferDelegateEGL() {
+AsyncPixelTransferDelegateEGL::AsyncPixelTransferDelegateEGL(
+ AsyncPixelTransferUploadStats* stats)
+ : texture_upload_stats_(stats) {
std::string vendor;
vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
is_imagination_ = vendor.find("Imagination") != std::string::npos;
is_qualcomm_ = vendor.find("Qualcomm") != std::string::npos;
- // TODO(reveman): Skip this if --enable-gpu-benchmarking is not present.
- texture_upload_stats_ = make_scoped_refptr(new AsyncPixelTransferUploadStats);
}
AsyncPixelTransferDelegateEGL::~AsyncPixelTransferDelegateEGL() {}
@@ -533,25 +532,6 @@ void AsyncPixelTransferDelegateEGL::BindCompletedAsyncTransfers() {
}
}
-void AsyncPixelTransferDelegateEGL::AsyncNotifyCompletion(
- const AsyncMemoryParams& mem_params,
- const CompletionCallback& callback) {
- DCHECK(mem_params.shared_memory);
- DCHECK_LE(mem_params.shm_data_offset + mem_params.shm_data_size,
- mem_params.shm_size);
- // Post a PerformNotifyCompletion task to the upload thread. This task
- // will run after all async transfers are complete.
- transfer_message_loop_proxy()->PostTask(
- FROM_HERE,
- base::Bind(&AsyncPixelTransferDelegateEGL::PerformNotifyCompletion,
- mem_params,
- base::Owned(
- new ScopedSafeSharedMemory(safe_shared_memory_pool(),
- mem_params.shared_memory,
- mem_params.shm_size)),
- callback));
-}
-
void AsyncPixelTransferDelegateEGL::WaitForTransferCompletion(
AsyncPixelTransferState* transfer_state) {
scoped_refptr<TransferStateInternal> state =
@@ -661,35 +641,6 @@ void AsyncPixelTransferDelegateEGL::AsyncTexSubImage2D(
DCHECK(CHECK_GL());
}
-uint32 AsyncPixelTransferDelegateEGL::GetTextureUploadCount() {
- CHECK(texture_upload_stats_.get());
- return texture_upload_stats_->GetStats(NULL);
-}
-
-base::TimeDelta AsyncPixelTransferDelegateEGL::GetTotalTextureUploadTime() {
- CHECK(texture_upload_stats_.get());
- base::TimeDelta total_texture_upload_time;
- texture_upload_stats_->GetStats(&total_texture_upload_time);
- return total_texture_upload_time;
-}
-
-void AsyncPixelTransferDelegateEGL::ProcessMorePendingTransfers() {
-}
-
-bool AsyncPixelTransferDelegateEGL::NeedsProcessMorePendingTransfers() {
- return false;
-}
-
-void AsyncPixelTransferDelegateEGL::PerformNotifyCompletion(
- AsyncMemoryParams mem_params,
- ScopedSafeSharedMemory* safe_shared_memory,
- const CompletionCallback& callback) {
- TRACE_EVENT0("gpu", "PerformNotifyCompletion");
- AsyncMemoryParams safe_mem_params = mem_params;
- safe_mem_params.shared_memory = safe_shared_memory->shared_memory();
- callback.Run(safe_mem_params);
-}
-
namespace {
bool IsPowerOfTwo (unsigned int x) {
return ((x != 0) && !(x & (x - 1)));
@@ -810,10 +761,52 @@ bool AsyncPixelTransferDelegateEGL::WorkAroundAsyncTexSubImage2D(
}
AsyncPixelTransferManagerEGL::AsyncPixelTransferManagerEGL()
- : delegate_(new AsyncPixelTransferDelegateEGL()) {}
+ // TODO(reveman): Skip this if --enable-gpu-benchmarking is not present.
+ : texture_upload_stats_(new AsyncPixelTransferUploadStats),
+ delegate_(new AsyncPixelTransferDelegateEGL(texture_upload_stats_)) {}
AsyncPixelTransferManagerEGL::~AsyncPixelTransferManagerEGL() {}
+void AsyncPixelTransferManagerEGL::BindCompletedAsyncTransfers() {
+ delegate_->BindCompletedAsyncTransfers();
+}
+
+void AsyncPixelTransferManagerEGL::AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) {
+ DCHECK(mem_params.shared_memory);
+ DCHECK_LE(mem_params.shm_data_offset + mem_params.shm_data_size,
+ mem_params.shm_size);
+ // Post a PerformNotifyCompletion task to the upload thread. This task
+ // will run after all async transfers are complete.
+ transfer_message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(&PerformNotifyCompletion,
+ mem_params,
+ base::Owned(
+ new ScopedSafeSharedMemory(safe_shared_memory_pool(),
+ mem_params.shared_memory,
+ mem_params.shm_size)),
+ callback));
+}
+
+uint32 AsyncPixelTransferManagerEGL::GetTextureUploadCount() {
+ return texture_upload_stats_->GetStats(NULL);
+}
+
+base::TimeDelta AsyncPixelTransferManagerEGL::GetTotalTextureUploadTime() {
+ base::TimeDelta total_texture_upload_time;
+ texture_upload_stats_->GetStats(&total_texture_upload_time);
+ return total_texture_upload_time;
+}
+
+void AsyncPixelTransferManagerEGL::ProcessMorePendingTransfers() {
+}
+
+bool AsyncPixelTransferManagerEGL::NeedsProcessMorePendingTransfers() {
+ return false;
+}
+
AsyncPixelTransferDelegate*
AsyncPixelTransferManagerEGL::GetAsyncPixelTransferDelegate() {
return delegate_.get();
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_egl.h b/gpu/command_buffer/service/async_pixel_transfer_manager_egl.h
index c76ee90..a41a1747 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_manager_egl.h
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_egl.h
@@ -7,9 +7,12 @@
#include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
-namespace gpu {
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+namespace gpu {
class AsyncPixelTransferDelegateEGL;
+class AsyncPixelTransferUploadStats;
class AsyncPixelTransferManagerEGL : public AsyncPixelTransferManager {
public:
@@ -17,9 +20,18 @@ class AsyncPixelTransferManagerEGL : public AsyncPixelTransferManager {
virtual ~AsyncPixelTransferManagerEGL();
// AsyncPixelTransferManager implementation:
+ virtual void BindCompletedAsyncTransfers() OVERRIDE;
+ virtual void AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) OVERRIDE;
+ virtual uint32 GetTextureUploadCount() OVERRIDE;
+ virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
+ virtual void ProcessMorePendingTransfers() OVERRIDE;
+ virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
virtual AsyncPixelTransferDelegate* GetAsyncPixelTransferDelegate() OVERRIDE;
private:
+ scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats_;
scoped_ptr<AsyncPixelTransferDelegateEGL> delegate_;
DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferManagerEGL);
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_idle.cc b/gpu/command_buffer/service/async_pixel_transfer_manager_idle.cc
index 66ff879..c283b81 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_manager_idle.cc
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_idle.cc
@@ -71,14 +71,19 @@ class AsyncPixelTransferDelegateIdle : public AsyncPixelTransferDelegate,
AsyncPixelTransferDelegateIdle();
virtual ~AsyncPixelTransferDelegateIdle();
- // implement AsyncPixelTransferDelegate:
+ void BindCompletedAsyncTransfers();
+ void AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const AsyncPixelTransferManager::CompletionCallback& callback);
+ uint32 GetTextureUploadCount();
+ base::TimeDelta GetTotalTextureUploadTime();
+ void ProcessMorePendingTransfers();
+ bool NeedsProcessMorePendingTransfers();
+
+ // 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,
@@ -90,10 +95,6 @@ class AsyncPixelTransferDelegateIdle : public AsyncPixelTransferDelegate,
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 {
@@ -111,7 +112,7 @@ class AsyncPixelTransferDelegateIdle : public AsyncPixelTransferDelegate,
void PerformNotifyCompletion(
AsyncMemoryParams mem_params,
ScopedSafeSharedMemory* safe_shared_memory,
- const CompletionCallback& callback);
+ const AsyncPixelTransferManager::CompletionCallback& callback);
void PerformAsyncTexImage2D(
AsyncTexImage2DParams tex_params,
AsyncMemoryParams mem_params,
@@ -158,7 +159,7 @@ void AsyncPixelTransferDelegateIdle::BindCompletedAsyncTransfers() {
void AsyncPixelTransferDelegateIdle::AsyncNotifyCompletion(
const AsyncMemoryParams& mem_params,
- const CompletionCallback& callback) {
+ const AsyncPixelTransferManager::CompletionCallback& callback) {
if (tasks_.empty()) {
callback.Run(mem_params);
return;
@@ -296,7 +297,7 @@ void AsyncPixelTransferDelegateIdle::ProcessNotificationTasks() {
void AsyncPixelTransferDelegateIdle::PerformNotifyCompletion(
AsyncMemoryParams mem_params,
ScopedSafeSharedMemory* safe_shared_memory,
- const CompletionCallback& callback) {
+ const AsyncPixelTransferManager::CompletionCallback& callback) {
TRACE_EVENT0("gpu", "PerformNotifyCompletion");
AsyncMemoryParams safe_mem_params = mem_params;
safe_mem_params.shared_memory = safe_shared_memory->shared_memory();
@@ -372,6 +373,32 @@ AsyncPixelTransferManagerIdle::AsyncPixelTransferManagerIdle()
AsyncPixelTransferManagerIdle::~AsyncPixelTransferManagerIdle() {}
+void AsyncPixelTransferManagerIdle::BindCompletedAsyncTransfers() {
+ delegate_->BindCompletedAsyncTransfers();
+}
+
+void AsyncPixelTransferManagerIdle::AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) {
+ delegate_->AsyncNotifyCompletion(mem_params, callback);
+}
+
+uint32 AsyncPixelTransferManagerIdle::GetTextureUploadCount() {
+ return delegate_->GetTextureUploadCount();
+}
+
+base::TimeDelta AsyncPixelTransferManagerIdle::GetTotalTextureUploadTime() {
+ return delegate_->GetTotalTextureUploadTime();
+}
+
+void AsyncPixelTransferManagerIdle::ProcessMorePendingTransfers() {
+ delegate_->ProcessMorePendingTransfers();
+}
+
+bool AsyncPixelTransferManagerIdle::NeedsProcessMorePendingTransfers() {
+ return delegate_->NeedsProcessMorePendingTransfers();
+}
+
AsyncPixelTransferDelegate*
AsyncPixelTransferManagerIdle::GetAsyncPixelTransferDelegate() {
return delegate_.get();
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_idle.h b/gpu/command_buffer/service/async_pixel_transfer_manager_idle.h
index 1821dca..62c8bc6 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_manager_idle.h
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_idle.h
@@ -16,6 +16,14 @@ class AsyncPixelTransferManagerIdle : public AsyncPixelTransferManager {
virtual ~AsyncPixelTransferManagerIdle();
// AsyncPixelTransferManager implementation:
+ virtual void BindCompletedAsyncTransfers() OVERRIDE;
+ virtual void AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) OVERRIDE;
+ virtual uint32 GetTextureUploadCount() OVERRIDE;
+ virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
+ virtual void ProcessMorePendingTransfers() OVERRIDE;
+ virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
virtual AsyncPixelTransferDelegate* GetAsyncPixelTransferDelegate() OVERRIDE;
private:
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_mock.cc b/gpu/command_buffer/service/async_pixel_transfer_manager_mock.cc
new file mode 100644
index 0000000..84e95e3
--- /dev/null
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_mock.cc
@@ -0,0 +1,15 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// 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_manager_mock.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace gpu {
+
+MockAsyncPixelTransferManager::MockAsyncPixelTransferManager() {}
+
+MockAsyncPixelTransferManager::~MockAsyncPixelTransferManager() {}
+
+} // namespace gpu
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_mock.h b/gpu/command_buffer/service/async_pixel_transfer_manager_mock.h
new file mode 100644
index 0000000..5f50a31
--- /dev/null
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_mock.h
@@ -0,0 +1,34 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_TEST_H_
+#define GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_TEST_H_
+
+#include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace gpu {
+
+class MockAsyncPixelTransferManager : public AsyncPixelTransferManager {
+ public:
+ MockAsyncPixelTransferManager();
+ virtual ~MockAsyncPixelTransferManager();
+
+ // AsyncPixelTransferManager implementation:
+ MOCK_METHOD0(BindCompletedAsyncTransfers, void());
+ MOCK_METHOD2(AsyncNotifyCompletion,
+ void(const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback));
+ MOCK_METHOD0(GetTextureUploadCount, uint32());
+ MOCK_METHOD0(GetTotalTextureUploadTime, base::TimeDelta());
+ MOCK_METHOD0(ProcessMorePendingTransfers, void());
+ MOCK_METHOD0(NeedsProcessMorePendingTransfers, bool());
+ MOCK_METHOD0(GetAsyncPixelTransferDelegate, AsyncPixelTransferDelegate*());
+
+ DISALLOW_COPY_AND_ASSIGN(MockAsyncPixelTransferManager);
+};
+
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_TEST_H_
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_share_group.cc b/gpu/command_buffer/service/async_pixel_transfer_manager_share_group.cc
index d2e3fad..d86f420 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_manager_share_group.cc
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_share_group.cc
@@ -30,6 +30,16 @@ namespace {
const char kAsyncTransferThreadName[] = "AsyncTransferThread";
+void PerformNotifyCompletion(
+ AsyncMemoryParams mem_params,
+ ScopedSafeSharedMemory* safe_shared_memory,
+ const AsyncPixelTransferManager::CompletionCallback& callback) {
+ TRACE_EVENT0("gpu", "PerformNotifyCompletion");
+ AsyncMemoryParams safe_mem_params = mem_params;
+ safe_mem_params.shared_memory = safe_shared_memory->shared_memory();
+ callback.Run(safe_mem_params);
+}
+
// TODO(backer): Factor out common thread scheduling logic from the EGL and
// ShareGroup implementations. http://crbug.com/239889
class TransferThread : public base::Thread {
@@ -289,16 +299,6 @@ class TransferStateInternal
base::Closure bind_callback_;
};
-void PerformNotifyCompletion(
- AsyncMemoryParams mem_params,
- ScopedSafeSharedMemory* safe_shared_memory,
- const AsyncPixelTransferDelegate::CompletionCallback& callback) {
- TRACE_EVENT0("gpu", "PerformNotifyCompletion");
- AsyncMemoryParams safe_mem_params = mem_params;
- safe_mem_params.shared_memory = safe_shared_memory->shared_memory();
- callback.Run(safe_mem_params);
-}
-
} // namespace
// ShareGroup needs thread-safe ref-counting, so this just wraps
@@ -327,17 +327,16 @@ class AsyncTransferStateImpl : public AsyncPixelTransferState {
class AsyncPixelTransferDelegateShareGroup : public AsyncPixelTransferDelegate {
public:
- explicit AsyncPixelTransferDelegateShareGroup(gfx::GLContext* context);
+ AsyncPixelTransferDelegateShareGroup(gfx::GLContext* context,
+ AsyncPixelTransferUploadStats* stats);
virtual ~AsyncPixelTransferDelegateShareGroup();
+ void BindCompletedAsyncTransfers();
+
// 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* state,
const AsyncTexImage2DParams& tex_params,
@@ -349,10 +348,6 @@ class AsyncPixelTransferDelegateShareGroup : public AsyncPixelTransferDelegate {
const AsyncMemoryParams& mem_params) OVERRIDE;
virtual void WaitForTransferCompletion(
AsyncPixelTransferState* state) OVERRIDE;
- virtual uint32 GetTextureUploadCount() OVERRIDE;
- virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
- virtual void ProcessMorePendingTransfers() OVERRIDE;
- virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
private:
typedef std::list<base::WeakPtr<AsyncPixelTransferState> > TransferQueue;
@@ -364,11 +359,10 @@ class AsyncPixelTransferDelegateShareGroup : public AsyncPixelTransferDelegate {
};
AsyncPixelTransferDelegateShareGroup::AsyncPixelTransferDelegateShareGroup(
- gfx::GLContext* context) {
+ gfx::GLContext* context,
+ AsyncPixelTransferUploadStats* stats)
+ : texture_upload_stats_(stats) {
g_transfer_thread.Pointer()->InitializeOnMainThread(context);
-
- // TODO(reveman): Skip this if --enable-gpu-benchmarking is not present.
- texture_upload_stats_ = make_scoped_refptr(new AsyncPixelTransferUploadStats);
}
AsyncPixelTransferDelegateShareGroup::~AsyncPixelTransferDelegateShareGroup() {
@@ -409,25 +403,6 @@ void AsyncPixelTransferDelegateShareGroup::BindCompletedAsyncTransfers() {
}
}
-void AsyncPixelTransferDelegateShareGroup::AsyncNotifyCompletion(
- const AsyncMemoryParams& mem_params,
- const CompletionCallback& callback) {
- DCHECK(mem_params.shared_memory);
- DCHECK_LE(mem_params.shm_data_offset + mem_params.shm_data_size,
- mem_params.shm_size);
- // Post a PerformNotifyCompletion task to the upload thread. This task
- // will run after all async transfers are complete.
- transfer_message_loop_proxy()->PostTask(
- FROM_HERE,
- base::Bind(&PerformNotifyCompletion,
- mem_params,
- base::Owned(
- new ScopedSafeSharedMemory(safe_shared_memory_pool(),
- mem_params.shared_memory,
- mem_params.shm_size)),
- callback));
-}
-
void AsyncPixelTransferDelegateShareGroup::WaitForTransferCompletion(
AsyncPixelTransferState* transfer_state) {
scoped_refptr<TransferStateInternal> state =
@@ -523,32 +498,57 @@ void AsyncPixelTransferDelegateShareGroup::AsyncTexSubImage2D(
texture_upload_stats_));
}
-uint32 AsyncPixelTransferDelegateShareGroup::GetTextureUploadCount() {
- DCHECK(texture_upload_stats_.get());
+AsyncPixelTransferManagerShareGroup::AsyncPixelTransferManagerShareGroup(
+ gfx::GLContext* context)
+ // TODO(reveman): Skip this if --enable-gpu-benchmarking is not present.
+ : texture_upload_stats_(new AsyncPixelTransferUploadStats),
+ delegate_(
+ new AsyncPixelTransferDelegateShareGroup(context,
+ texture_upload_stats_)) {}
+
+AsyncPixelTransferManagerShareGroup::~AsyncPixelTransferManagerShareGroup() {}
+
+void AsyncPixelTransferManagerShareGroup::BindCompletedAsyncTransfers() {
+ delegate_->BindCompletedAsyncTransfers();
+}
+
+void AsyncPixelTransferManagerShareGroup::AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) {
+ DCHECK(mem_params.shared_memory);
+ DCHECK_LE(mem_params.shm_data_offset + mem_params.shm_data_size,
+ mem_params.shm_size);
+ // Post a PerformNotifyCompletion task to the upload thread. This task
+ // will run after all async transfers are complete.
+ transfer_message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(&PerformNotifyCompletion,
+ mem_params,
+ base::Owned(
+ new ScopedSafeSharedMemory(safe_shared_memory_pool(),
+ mem_params.shared_memory,
+ mem_params.shm_size)),
+ callback));
+}
+
+uint32 AsyncPixelTransferManagerShareGroup::GetTextureUploadCount() {
return texture_upload_stats_->GetStats(NULL);
}
base::TimeDelta
- AsyncPixelTransferDelegateShareGroup::GetTotalTextureUploadTime() {
- DCHECK(texture_upload_stats_.get());
+AsyncPixelTransferManagerShareGroup::GetTotalTextureUploadTime() {
base::TimeDelta total_texture_upload_time;
texture_upload_stats_->GetStats(&total_texture_upload_time);
return total_texture_upload_time;
}
-void AsyncPixelTransferDelegateShareGroup::ProcessMorePendingTransfers() {
+void AsyncPixelTransferManagerShareGroup::ProcessMorePendingTransfers() {
}
-bool AsyncPixelTransferDelegateShareGroup::NeedsProcessMorePendingTransfers() {
+bool AsyncPixelTransferManagerShareGroup::NeedsProcessMorePendingTransfers() {
return false;
}
-AsyncPixelTransferManagerShareGroup::AsyncPixelTransferManagerShareGroup(
- gfx::GLContext* context)
- : delegate_(new AsyncPixelTransferDelegateShareGroup(context)) {}
-
-AsyncPixelTransferManagerShareGroup::~AsyncPixelTransferManagerShareGroup() {}
-
AsyncPixelTransferDelegate*
AsyncPixelTransferManagerShareGroup::GetAsyncPixelTransferDelegate() {
return delegate_.get();
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_share_group.h b/gpu/command_buffer/service/async_pixel_transfer_manager_share_group.h
index 32db74f..9f7bf1b 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_manager_share_group.h
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_share_group.h
@@ -7,13 +7,16 @@
#include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+
namespace gfx {
class GLContext;
}
namespace gpu {
-
class AsyncPixelTransferDelegateShareGroup;
+class AsyncPixelTransferUploadStats;
class AsyncPixelTransferManagerShareGroup : public AsyncPixelTransferManager {
public:
@@ -21,9 +24,18 @@ class AsyncPixelTransferManagerShareGroup : public AsyncPixelTransferManager {
virtual ~AsyncPixelTransferManagerShareGroup();
// AsyncPixelTransferManager implementation:
+ virtual void BindCompletedAsyncTransfers() OVERRIDE;
+ virtual void AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) OVERRIDE;
+ virtual uint32 GetTextureUploadCount() OVERRIDE;
+ virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
+ virtual void ProcessMorePendingTransfers() OVERRIDE;
+ virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
virtual AsyncPixelTransferDelegate* GetAsyncPixelTransferDelegate() OVERRIDE;
private:
+ scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats_;
scoped_ptr<AsyncPixelTransferDelegateShareGroup> delegate_;
DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferManagerShareGroup);
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_stub.cc b/gpu/command_buffer/service/async_pixel_transfer_manager_stub.cc
index 48af037..71338fb 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_manager_stub.cc
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_stub.cc
@@ -34,10 +34,6 @@ class AsyncPixelTransferDelegateStub : public 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* state,
const AsyncTexImage2DParams& tex_params,
@@ -49,10 +45,6 @@ class AsyncPixelTransferDelegateStub : public AsyncPixelTransferDelegate {
const AsyncMemoryParams& mem_params) OVERRIDE;
virtual void WaitForTransferCompletion(
AsyncPixelTransferState* state) OVERRIDE;
- virtual uint32 GetTextureUploadCount() OVERRIDE;
- virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
- virtual void ProcessMorePendingTransfers() OVERRIDE;
- virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateStub);
@@ -68,15 +60,6 @@ AsyncPixelTransferState* AsyncPixelTransferDelegateStub::
return new AsyncPixelTransferStateImpl;
}
-void AsyncPixelTransferDelegateStub::BindCompletedAsyncTransfers() {
-}
-
-void AsyncPixelTransferDelegateStub::AsyncNotifyCompletion(
- const AsyncMemoryParams& mem_params,
- const CompletionCallback& callback) {
- callback.Run(mem_params);
-}
-
void AsyncPixelTransferDelegateStub::AsyncTexImage2D(
AsyncPixelTransferState* transfer_state,
const AsyncTexImage2DParams& tex_params,
@@ -95,26 +78,35 @@ void AsyncPixelTransferDelegateStub::WaitForTransferCompletion(
AsyncPixelTransferState* state) {
}
-uint32 AsyncPixelTransferDelegateStub::GetTextureUploadCount() {
+AsyncPixelTransferManagerStub::AsyncPixelTransferManagerStub()
+ : delegate_(new AsyncPixelTransferDelegateStub()) {}
+
+AsyncPixelTransferManagerStub::~AsyncPixelTransferManagerStub() {}
+
+void AsyncPixelTransferManagerStub::BindCompletedAsyncTransfers() {
+}
+
+void AsyncPixelTransferManagerStub::AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) {
+ callback.Run(mem_params);
+}
+
+uint32 AsyncPixelTransferManagerStub::GetTextureUploadCount() {
return 0;
}
-base::TimeDelta AsyncPixelTransferDelegateStub::GetTotalTextureUploadTime() {
+base::TimeDelta AsyncPixelTransferManagerStub::GetTotalTextureUploadTime() {
return base::TimeDelta();
}
-void AsyncPixelTransferDelegateStub::ProcessMorePendingTransfers() {
+void AsyncPixelTransferManagerStub::ProcessMorePendingTransfers() {
}
-bool AsyncPixelTransferDelegateStub::NeedsProcessMorePendingTransfers() {
+bool AsyncPixelTransferManagerStub::NeedsProcessMorePendingTransfers() {
return false;
}
-AsyncPixelTransferManagerStub::AsyncPixelTransferManagerStub()
- : delegate_(new AsyncPixelTransferDelegateStub()) {}
-
-AsyncPixelTransferManagerStub::~AsyncPixelTransferManagerStub() {}
-
AsyncPixelTransferDelegate*
AsyncPixelTransferManagerStub::GetAsyncPixelTransferDelegate() {
return delegate_.get();
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_stub.h b/gpu/command_buffer/service/async_pixel_transfer_manager_stub.h
index c9294922..544c818 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_manager_stub.h
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_stub.h
@@ -17,6 +17,14 @@ class AsyncPixelTransferManagerStub : public AsyncPixelTransferManager {
virtual ~AsyncPixelTransferManagerStub();
// AsyncPixelTransferManager implementation:
+ virtual void BindCompletedAsyncTransfers() OVERRIDE;
+ virtual void AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) OVERRIDE;
+ virtual uint32 GetTextureUploadCount() OVERRIDE;
+ virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
+ virtual void ProcessMorePendingTransfers() OVERRIDE;
+ virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
virtual AsyncPixelTransferDelegate* GetAsyncPixelTransferDelegate() OVERRIDE;
private:
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_sync.cc b/gpu/command_buffer/service/async_pixel_transfer_manager_sync.cc
index ffd0549..4d4885b 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_manager_sync.cc
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_sync.cc
@@ -35,10 +35,6 @@ class AsyncPixelTransferDelegateSync : public 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* state,
const AsyncTexImage2DParams& tex_params,
@@ -50,10 +46,8 @@ class AsyncPixelTransferDelegateSync : public AsyncPixelTransferDelegate {
const AsyncMemoryParams& mem_params) OVERRIDE;
virtual void WaitForTransferCompletion(
AsyncPixelTransferState* state) OVERRIDE;
- virtual uint32 GetTextureUploadCount() OVERRIDE;
- virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
- virtual void ProcessMorePendingTransfers() OVERRIDE;
- virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
+ uint32 GetTextureUploadCount();
+ base::TimeDelta GetTotalTextureUploadTime();
private:
int texture_upload_count_;
@@ -74,16 +68,6 @@ AsyncPixelTransferState* AsyncPixelTransferDelegateSync::
return new AsyncPixelTransferStateImpl;
}
-void AsyncPixelTransferDelegateSync::BindCompletedAsyncTransfers() {
- // Everything is already bound.
-}
-
-void AsyncPixelTransferDelegateSync::AsyncNotifyCompletion(
- const AsyncMemoryParams& mem_params,
- const CompletionCallback& callback) {
- callback.Run(mem_params);
-}
-
void AsyncPixelTransferDelegateSync::AsyncTexImage2D(
AsyncPixelTransferState* transfer_state,
const AsyncTexImage2DParams& tex_params,
@@ -141,17 +125,35 @@ base::TimeDelta AsyncPixelTransferDelegateSync::GetTotalTextureUploadTime() {
return total_texture_upload_time_;
}
-void AsyncPixelTransferDelegateSync::ProcessMorePendingTransfers() {
+AsyncPixelTransferManagerSync::AsyncPixelTransferManagerSync()
+ : delegate_(new AsyncPixelTransferDelegateSync()) {}
+
+AsyncPixelTransferManagerSync::~AsyncPixelTransferManagerSync() {}
+
+void AsyncPixelTransferManagerSync::BindCompletedAsyncTransfers() {
+ // Everything is already bound.
}
-bool AsyncPixelTransferDelegateSync::NeedsProcessMorePendingTransfers() {
- return false;
+void AsyncPixelTransferManagerSync::AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) {
+ callback.Run(mem_params);
}
-AsyncPixelTransferManagerSync::AsyncPixelTransferManagerSync()
- : delegate_(new AsyncPixelTransferDelegateSync()) {}
+uint32 AsyncPixelTransferManagerSync::GetTextureUploadCount() {
+ return delegate_->GetTextureUploadCount();
+}
-AsyncPixelTransferManagerSync::~AsyncPixelTransferManagerSync() {}
+base::TimeDelta AsyncPixelTransferManagerSync::GetTotalTextureUploadTime() {
+ return delegate_->GetTotalTextureUploadTime();
+}
+
+void AsyncPixelTransferManagerSync::ProcessMorePendingTransfers() {
+}
+
+bool AsyncPixelTransferManagerSync::NeedsProcessMorePendingTransfers() {
+ return false;
+}
AsyncPixelTransferDelegate*
AsyncPixelTransferManagerSync::GetAsyncPixelTransferDelegate() {
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_sync.h b/gpu/command_buffer/service/async_pixel_transfer_manager_sync.h
index 3638647..12bac96 100644
--- a/gpu/command_buffer/service/async_pixel_transfer_manager_sync.h
+++ b/gpu/command_buffer/service/async_pixel_transfer_manager_sync.h
@@ -16,6 +16,14 @@ class AsyncPixelTransferManagerSync : public AsyncPixelTransferManager {
virtual ~AsyncPixelTransferManagerSync();
// AsyncPixelTransferManager implementation:
+ virtual void BindCompletedAsyncTransfers() OVERRIDE;
+ virtual void AsyncNotifyCompletion(
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) OVERRIDE;
+ virtual uint32 GetTextureUploadCount() OVERRIDE;
+ virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
+ virtual void ProcessMorePendingTransfers() OVERRIDE;
+ virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
virtual AsyncPixelTransferDelegate* GetAsyncPixelTransferDelegate() OVERRIDE;
private:
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_test.cc b/gpu/command_buffer/service/async_pixel_transfer_manager_test.cc
deleted file mode 100644
index d07b01f..0000000
--- a/gpu/command_buffer/service/async_pixel_transfer_manager_test.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// 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_manager_test.h"
-
-#include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace gpu {
-
-AsyncPixelTransferManagerTest::AsyncPixelTransferManagerTest()
- : delegate_(
- new ::testing::StrictMock<gpu::MockAsyncPixelTransferDelegate>) {}
-
-AsyncPixelTransferManagerTest::~AsyncPixelTransferManagerTest() {}
-
-AsyncPixelTransferDelegate*
-AsyncPixelTransferManagerTest::GetAsyncPixelTransferDelegate() {
- return delegate_.get();
-}
-
-} // namespace gpu
diff --git a/gpu/command_buffer/service/async_pixel_transfer_manager_test.h b/gpu/command_buffer/service/async_pixel_transfer_manager_test.h
deleted file mode 100644
index f0b1455..0000000
--- a/gpu/command_buffer/service/async_pixel_transfer_manager_test.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_TEST_H_
-#define GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_TEST_H_
-
-#include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
-
-#include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h"
-
-namespace gpu {
-
-class AsyncPixelTransferManagerTest : public AsyncPixelTransferManager {
- public:
- AsyncPixelTransferManagerTest();
- virtual ~AsyncPixelTransferManagerTest();
-
- // AsyncPixelTransferManager implementation:
- virtual AsyncPixelTransferDelegate* GetAsyncPixelTransferDelegate() OVERRIDE;
-
- ::testing::StrictMock<MockAsyncPixelTransferDelegate>* GetMockDelegate() {
- return delegate_.get();
- }
-
- private:
- scoped_ptr< ::testing::StrictMock<MockAsyncPixelTransferDelegate> > delegate_;
-
- DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferManagerTest);
-};
-
-} // namespace gpu
-
-#endif // GPU_COMMAND_BUFFER_SERVICE_ASYNC_PIXEL_TRANSFER_MANAGER_TEST_H_
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 3bd165e..4a801b5 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -2788,7 +2788,7 @@ void GLES2DecoderImpl::ProcessFinishedAsyncTransfers() {
// from the client, as the client may have recieved an async
// completion while issuing those commands.
// "DidFlushStart" would be ideal if we had such a callback.
- GetAsyncPixelTransferDelegate()->BindCompletedAsyncTransfers();
+ async_pixel_transfer_manager_->BindCompletedAsyncTransfers();
}
void GLES2DecoderImpl::ReleaseCurrent() {
@@ -3075,12 +3075,12 @@ bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id,
uint32 GLES2DecoderImpl::GetTextureUploadCount() {
return texture_upload_count_ +
- GetAsyncPixelTransferDelegate()->GetTextureUploadCount();
+ async_pixel_transfer_manager_->GetTextureUploadCount();
}
base::TimeDelta GLES2DecoderImpl::GetTotalTextureUploadTime() {
return total_texture_upload_time_ +
- GetAsyncPixelTransferDelegate()->GetTotalTextureUploadTime();
+ async_pixel_transfer_manager_->GetTotalTextureUploadTime();
}
base::TimeDelta GLES2DecoderImpl::GetTotalProcessingCommandsTime() {
@@ -9053,13 +9053,13 @@ bool GLES2DecoderImpl::ProcessPendingQueries() {
}
bool GLES2DecoderImpl::HasMoreIdleWork() {
- return GetAsyncPixelTransferDelegate()->NeedsProcessMorePendingTransfers();
+ return async_pixel_transfer_manager_->NeedsProcessMorePendingTransfers();
}
void GLES2DecoderImpl::PerformIdleWork() {
- if (!GetAsyncPixelTransferDelegate()->NeedsProcessMorePendingTransfers())
+ if (!async_pixel_transfer_manager_->NeedsProcessMorePendingTransfers())
return;
- GetAsyncPixelTransferDelegate()->ProcessMorePendingTransfers();
+ async_pixel_transfer_manager_->ProcessMorePendingTransfers();
ProcessFinishedAsyncTransfers();
}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index e7c8417..8382233 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -10,7 +10,7 @@
#include "gpu/command_buffer/common/id_allocator.h"
#include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h"
#include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
-#include "gpu/command_buffer/service/async_pixel_transfer_manager_test.h"
+#include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/gl_surface_mock.h"
@@ -8082,12 +8082,14 @@ TEST_F(GLES2DecoderManualInitTest, AsyncPixelTransfers) {
Texture* texture = texture_ref->texture();
// Set a mock Async delegate
- gpu::AsyncPixelTransferManagerTest* manager =
- new gpu::AsyncPixelTransferManagerTest;
+ StrictMock<gpu::MockAsyncPixelTransferManager>* manager =
+ new StrictMock<gpu::MockAsyncPixelTransferManager>;
manager->Initialize(group().texture_manager());
decoder_->SetAsyncPixelTransferManagerForTest(manager);
- StrictMock<gpu::MockAsyncPixelTransferDelegate>* delegate =
- manager->GetMockDelegate();
+ scoped_ptr<StrictMock<gpu::MockAsyncPixelTransferDelegate> > delegate(
+ new StrictMock<gpu::MockAsyncPixelTransferDelegate>);
+ EXPECT_CALL(*manager, GetAsyncPixelTransferDelegate())
+ .WillRepeatedly(Return(delegate.get()));
StrictMock<gpu::MockAsyncPixelTransferState>* state = NULL;
// Tex(Sub)Image2D upload commands.
@@ -8244,7 +8246,7 @@ TEST_F(GLES2DecoderManualInitTest, AsyncPixelTransfers) {
EXPECT_TRUE(texture->IsImmutable());
// Wait for completion.
EXPECT_CALL(*delegate, WaitForTransferCompletion(state));
- EXPECT_CALL(*delegate, BindCompletedAsyncTransfers());
+ EXPECT_CALL(*manager, BindCompletedAsyncTransfers());
EXPECT_EQ(error::kNoError, ExecuteCmd(wait_cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
@@ -8262,12 +8264,14 @@ TEST_F(GLES2DecoderManualInitTest, AsyncPixelTransferManager) {
TextureRef* texture_ref = GetTexture(client_texture_id_);
// Set a mock Async delegate.
- gpu::AsyncPixelTransferManagerTest* manager =
- new gpu::AsyncPixelTransferManagerTest;
+ StrictMock<gpu::MockAsyncPixelTransferManager>* manager =
+ new StrictMock<gpu::MockAsyncPixelTransferManager>;
manager->Initialize(group().texture_manager());
decoder_->SetAsyncPixelTransferManagerForTest(manager);
- StrictMock<gpu::MockAsyncPixelTransferDelegate>* delegate =
- manager->GetMockDelegate();
+ scoped_ptr<StrictMock<gpu::MockAsyncPixelTransferDelegate> > delegate(
+ new StrictMock<gpu::MockAsyncPixelTransferDelegate>);
+ EXPECT_CALL(*manager, GetAsyncPixelTransferDelegate())
+ .WillRepeatedly(Return(delegate.get()));
StrictMock<gpu::MockAsyncPixelTransferState>* state = NULL;
AsyncTexImage2DCHROMIUM teximage_cmd;
diff --git a/gpu/command_buffer/service/query_manager.cc b/gpu/command_buffer/service/query_manager.cc
index a176661..3f81f64 100644
--- a/gpu/command_buffer/service/query_manager.cc
+++ b/gpu/command_buffer/service/query_manager.cc
@@ -10,7 +10,7 @@
#include "base/shared_memory.h"
#include "base/time.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
-#include "gpu/command_buffer/service/async_pixel_transfer_delegate.h"
+#include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
#include "gpu/command_buffer/service/error_state.h"
#include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
@@ -221,7 +221,7 @@ bool AsyncPixelTransfersCompletedQuery::End(uint32 submit_count) {
// Ask AsyncPixelTransferDelegate to run completion callback after all
// previous async transfers are done. No guarantee that callback is run
// on the current thread.
- manager()->decoder()->GetAsyncPixelTransferDelegate()->AsyncNotifyCompletion(
+ manager()->decoder()->GetAsyncPixelTransferManager()->AsyncNotifyCompletion(
mem_params,
base::Bind(AsyncPixelTransfersCompletedQuery::MarkAsCompletedThreadSafe,
submit_count));
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index d806667..c054e5d 100644
--- a/gpu/gpu.gyp
+++ b/gpu/gpu.gyp
@@ -165,8 +165,8 @@
'command_buffer/common/unittest_main.cc',
'command_buffer/service/async_pixel_transfer_delegate_mock.h',
'command_buffer/service/async_pixel_transfer_delegate_mock.cc',
- 'command_buffer/service/async_pixel_transfer_manager_test.h',
- 'command_buffer/service/async_pixel_transfer_manager_test.cc',
+ 'command_buffer/service/async_pixel_transfer_manager_mock.h',
+ 'command_buffer/service/async_pixel_transfer_manager_mock.cc',
'command_buffer/service/buffer_manager_unittest.cc',
'command_buffer/service/cmd_parser_test.cc',
'command_buffer/service/command_buffer_service_unittest.cc',