GpuMemoryManager suggests values for renderer Contents Texture Managers' preferred memory limit.


BUG=123382
TEST=Manual


Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=134428

Review URL: http://codereview.chromium.org/10083056

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134801 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index aa5b331..41fa5e5a 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -59,7 +59,9 @@
       route_id_(route_id),
       software_(software),
       last_flush_count_(0),
-      allocation_(GpuMemoryAllocation::INVALID_RESOURCE_SIZE, true, true),
+      allocation_(GpuMemoryAllocation::INVALID_RESOURCE_SIZE,
+                  GpuMemoryAllocation::kHasFrontbuffer |
+                  GpuMemoryAllocation::kHasBackbuffer),
       parent_stub_for_initialization_(),
       parent_texture_for_initialization_(0),
       watchdog_(watchdog) {
@@ -131,6 +133,9 @@
                         OnDiscardBackbuffer)
     IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EnsureBackbuffer,
                         OnEnsureBackbuffer)
+    IPC_MESSAGE_HANDLER(
+        GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback,
+        OnSetClientHasMemoryAllocationChangedCallback)
     IPC_MESSAGE_UNHANDLED(handled = false)
   IPC_END_MESSAGE_MAP()
 
@@ -589,6 +594,12 @@
       gfx::GLSurface::BUFFER_ALLOCATION_FRONT_AND_BACK);
 }
 
+void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback(
+    bool has_callback) {
+  client_has_memory_allocation_changed_callback_ = has_callback;
+  channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage();
+}
+
 void GpuCommandBufferStub::SendConsoleMessage(
     int32 id,
     const std::string& message) {
@@ -617,6 +628,11 @@
       static_cast<const GpuCommandBufferStub&>(other).context_group_;
 }
 
+bool GpuCommandBufferStub::
+    client_has_memory_allocation_changed_callback() const {
+  return client_has_memory_allocation_changed_callback_;
+}
+
 bool GpuCommandBufferStub::has_surface_state() const {
   return surface_state_ != NULL;
 }