summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-25 01:38:06 +0000
committerccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-25 01:38:06 +0000
commite6e1fc29a59fcffde631d6acd2853e2c7a24cea7 (patch)
treea9d83b3fb2dd60dd520abe478f2ca16c8887c911
parent1301919b1e48ced7d6d83c0307650c1eed57fdfd (diff)
downloadchromium_src-e6e1fc29a59fcffde631d6acd2853e2c7a24cea7.zip
chromium_src-e6e1fc29a59fcffde631d6acd2853e2c7a24cea7.tar.gz
chromium_src-e6e1fc29a59fcffde631d6acd2853e2c7a24cea7.tar.bz2
Elide unnecessary IPCs and MakeCurrents from GpuMemoryManager
Sending a new memory policy is not free -- it will invoke a MakeCurrent if changing the surface allocation, and it will invoke an IPC to send the policy to the renderer. Don't do these if there is no change being sent. BUG= Review URL: https://chromiumcodereview.appspot.com/12038075 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178723 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc28
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.h4
2 files changed, 24 insertions, 8 deletions
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index a0a79bc..a8bb1c5 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -119,6 +119,7 @@ GpuCommandBufferStub::GpuCommandBufferStub(
surface_id_(surface_id),
software_(software),
last_flush_count_(0),
+ last_memory_allocation_valid_(false),
parent_stub_for_initialization_(),
parent_texture_for_initialization_(0),
watchdog_(watchdog),
@@ -865,14 +866,25 @@ gpu::gles2::MemoryTracker* GpuCommandBufferStub::GetMemoryTracker() const {
void GpuCommandBufferStub::SetMemoryAllocation(
const GpuMemoryAllocation& allocation) {
- Send(new GpuCommandBufferMsg_SetMemoryAllocation(
- route_id_, allocation.renderer_allocation));
- // This can be called outside of OnMessageReceived, so the context needs to be
- // made current before calling methods on the surface.
- if (!surface_ || !MakeCurrent())
- return;
- surface_->SetFrontbufferAllocation(
- allocation.browser_allocation.suggest_have_frontbuffer);
+ if (!last_memory_allocation_valid_ ||
+ !allocation.renderer_allocation.Equals(
+ last_memory_allocation_.renderer_allocation)) {
+ Send(new GpuCommandBufferMsg_SetMemoryAllocation(
+ route_id_, allocation.renderer_allocation));
+ }
+
+ if (!last_memory_allocation_valid_ ||
+ !allocation.browser_allocation.Equals(
+ last_memory_allocation_.browser_allocation)) {
+ // This can be called outside of OnMessageReceived, so the context needs
+ // to be made current before calling methods on the surface.
+ if (surface_ && MakeCurrent())
+ surface_->SetFrontbufferAllocation(
+ allocation.browser_allocation.suggest_have_frontbuffer);
+ }
+
+ last_memory_allocation_valid_ = true;
+ last_memory_allocation_ = allocation;
}
} // namespace content
diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h
index c133ecc..eff5511c 100644
--- a/content/common/gpu/gpu_command_buffer_stub.h
+++ b/content/common/gpu/gpu_command_buffer_stub.h
@@ -220,6 +220,10 @@ class GpuCommandBufferStub
scoped_refptr<gfx::GLSurface> surface_;
scoped_ptr<GpuMemoryManagerClientState> memory_manager_client_state_;
+ // The last memory allocation received from the GpuMemoryManager (used to
+ // elide redundant work).
+ bool last_memory_allocation_valid_;
+ GpuMemoryAllocation last_memory_allocation_;
// SetParent may be called before Initialize, in which case we need to keep
// around the parent stub, so that Initialize can set the parent correctly.