Chromium implementation of discardBackbuffer WebGraphicsContext3D extension.
Webkit side patch: https://bugs.webkit.org/show_bug.cgi?id=81383
BUG=116049
TEST=Manual
Review URL: http://codereview.chromium.org/9699125
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128501 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 f476529..844b515 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -123,6 +123,10 @@
OnDestroyVideoDecoder)
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetSurfaceVisible,
OnSetSurfaceVisible)
+ IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DiscardBackbuffer,
+ OnDiscardBackbuffer)
+ IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EnsureBackbuffer,
+ OnEnsureBackbuffer)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -564,15 +568,31 @@
}
void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) {
- if (visible)
- surface_->SetBufferAllocation(
- gfx::GLSurface::BUFFER_ALLOCATION_FRONT_AND_BACK);
DCHECK(surface_state_.get());
surface_state_->visible = visible;
surface_state_->last_used_time = base::TimeTicks::Now();
channel_->gpu_channel_manager()->gpu_memory_manager()->ScheduleManage();
}
+void GpuCommandBufferStub::OnDiscardBackbuffer() {
+ if (!surface_)
+ return;
+ if (allocation_.suggest_have_frontbuffer)
+ surface_->SetBufferAllocation(
+ gfx::GLSurface::BUFFER_ALLOCATION_FRONT_ONLY);
+ else
+ surface_->SetBufferAllocation(
+ gfx::GLSurface::BUFFER_ALLOCATION_NONE);
+}
+
+void GpuCommandBufferStub::OnEnsureBackbuffer() {
+ if (!surface_)
+ return;
+ // TODO(mmocny): Support backbuffer without frontbuffer.
+ surface_->SetBufferAllocation(
+ gfx::GLSurface::BUFFER_ALLOCATION_FRONT_AND_BACK);
+}
+
void GpuCommandBufferStub::SendConsoleMessage(
int32 id,
const std::string& message) {
@@ -623,18 +643,6 @@
allocation_ = allocation;
SendMemoryAllocationToProxy(allocation);
-
- if (!surface_)
- return;
- if (allocation.suggest_have_frontbuffer && allocation.suggest_have_backbuffer)
- surface_->SetBufferAllocation(
- gfx::GLSurface::BUFFER_ALLOCATION_FRONT_AND_BACK);
- else if (allocation.suggest_have_frontbuffer)
- surface_->SetBufferAllocation(
- gfx::GLSurface::BUFFER_ALLOCATION_FRONT_ONLY);
- else
- surface_->SetBufferAllocation(
- gfx::GLSurface::BUFFER_ALLOCATION_NONE);
}
#endif // defined(ENABLE_GPU)