Index: content/common/gpu/gpu_command_buffer_stub.cc |
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc |
index b82d71532e5a9a0879be76493202502f2bb2c20e..efd6f06c7e96ce812ed4a239fef88ccc0da612d1 100644 |
--- a/content/common/gpu/gpu_command_buffer_stub.cc |
+++ b/content/common/gpu/gpu_command_buffer_stub.cc |
@@ -205,6 +205,7 @@ GpuCommandBufferStub::GpuCommandBufferStub( |
route_id_(route_id), |
offscreen_(offscreen), |
last_flush_count_(0), |
+ last_memory_allocation_valid_(false), |
watchdog_(watchdog), |
waiting_for_sync_point_(false), |
previous_processed_num_(0), |
@@ -277,7 +278,9 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { |
message.type() != GpuCommandBufferMsg_RegisterTransferBuffer::ID && |
message.type() != GpuCommandBufferMsg_DestroyTransferBuffer::ID && |
message.type() != GpuCommandBufferMsg_RetireSyncPoint::ID && |
- message.type() != GpuCommandBufferMsg_SignalSyncPoint::ID) { |
+ message.type() != GpuCommandBufferMsg_SignalSyncPoint::ID && |
+ message.type() != |
+ GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback::ID) { |
if (!MakeCurrent()) |
return false; |
have_context = true; |
@@ -316,6 +319,9 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { |
OnSignalSyncToken) |
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery, |
OnSignalQuery) |
+ IPC_MESSAGE_HANDLER( |
+ GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback, |
+ OnSetClientHasMemoryAllocationChangedCallback) |
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateImage, OnCreateImage); |
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyImage, OnDestroyImage); |
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture, |
@@ -473,6 +479,8 @@ void GpuCommandBufferStub::Destroy() { |
} |
} |
+ memory_manager_client_state_.reset(); |
+ |
while (!sync_points_.empty()) |
OnRetireSyncPoint(sync_points_.front()); |
@@ -917,9 +925,10 @@ void GpuCommandBufferStub::OnCreateVideoEncoder( |
// self-delete during destruction of this stub. |
} |
-// TODO(sohanjg): cleanup this and the client side too. |
void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { |
TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetSurfaceVisible"); |
+ if (memory_manager_client_state_) |
+ memory_manager_client_state_->SetVisible(visible); |
} |
void GpuCommandBufferStub::InsertSyncPoint(uint32 sync_point, bool retire) { |
@@ -1107,6 +1116,22 @@ void GpuCommandBufferStub::OnWaitFenceSyncCompleted( |
scheduler_->SetScheduled(true); |
} |
+ |
+void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( |
+ bool has_callback) { |
+ TRACE_EVENT0( |
+ "gpu", |
+ "GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback"); |
+ if (has_callback) { |
+ if (!memory_manager_client_state_) { |
+ memory_manager_client_state_.reset( |
+ GetMemoryManager()->CreateClientState(this, !offscreen_, true)); |
+ } |
+ } else { |
+ memory_manager_client_state_.reset(); |
+ } |
+} |
+ |
void GpuCommandBufferStub::OnCreateImage(int32 id, |
gfx::GpuMemoryBufferHandle handle, |
gfx::Size size, |
@@ -1212,6 +1237,18 @@ gpu::gles2::MemoryTracker* GpuCommandBufferStub::GetMemoryTracker() const { |
return context_group_->memory_tracker(); |
} |
+void GpuCommandBufferStub::SetMemoryAllocation( |
+ const gpu::MemoryAllocation& allocation) { |
+ if (!last_memory_allocation_valid_ || |
+ !allocation.Equals(last_memory_allocation_)) { |
+ Send(new GpuCommandBufferMsg_SetMemoryAllocation( |
+ route_id_, allocation)); |
+ } |
+ |
+ last_memory_allocation_valid_ = true; |
+ last_memory_allocation_ = allocation; |
+} |
+ |
void GpuCommandBufferStub::SuggestHaveFrontBuffer( |
bool suggest_have_frontbuffer) { |
// This can be called outside of OnMessageReceived, so the context needs |