diff options
16 files changed, 118 insertions, 20 deletions
diff --git a/content/common/gpu/client/command_buffer_proxy.cc b/content/common/gpu/client/command_buffer_proxy.cc index 4f6caa5..a59fdb7 100644 --- a/content/common/gpu/client/command_buffer_proxy.cc +++ b/content/common/gpu/client/command_buffer_proxy.cc @@ -367,6 +367,20 @@ bool CommandBufferProxy::SetSurfaceVisible(bool visible) { return Send(new GpuCommandBufferMsg_SetSurfaceVisible(route_id_, visible)); } +bool CommandBufferProxy::DiscardBackbuffer() { + if (last_state_.error != gpu::error::kNoError) + return false; + + return Send(new GpuCommandBufferMsg_DiscardBackbuffer(route_id_)); +} + +bool CommandBufferProxy::EnsureBackbuffer() { + if (last_state_.error != gpu::error::kNoError) + return false; + + return Send(new GpuCommandBufferMsg_EnsureBackbuffer(route_id_)); +} + bool CommandBufferProxy::SetParent(CommandBufferProxy* parent_command_buffer, uint32 parent_texture_id) { if (last_state_.error != gpu::error::kNoError) diff --git a/content/common/gpu/client/command_buffer_proxy.h b/content/common/gpu/client/command_buffer_proxy.h index 206eb87..d9874e0 100644 --- a/content/common/gpu/client/command_buffer_proxy.h +++ b/content/common/gpu/client/command_buffer_proxy.h @@ -74,6 +74,9 @@ class CommandBufferProxy : public gpu::CommandBuffer, // Sends an IPC message with the new state of surface visibility. bool SetSurfaceVisible(bool visible); + bool DiscardBackbuffer(); + bool EnsureBackbuffer(); + // Register a callback to invoke whenever we recieve a new memory allocation. void SetMemoryAllocationChangedCallback( const base::Callback<void(const GpuMemoryAllocationForRenderer&)>& diff --git a/content/common/gpu/client/content_gl_context.cc b/content/common/gpu/client/content_gl_context.cc index 9e09076..3ee10af 100644 --- a/content/common/gpu/client/content_gl_context.cc +++ b/content/common/gpu/client/content_gl_context.cc @@ -279,6 +279,14 @@ bool ContentGLContext::SetSurfaceVisible(bool visible) { return GetCommandBufferProxy()->SetSurfaceVisible(visible); } +bool ContentGLContext::DiscardBackbuffer() { + return GetCommandBufferProxy()->DiscardBackbuffer(); +} + +bool ContentGLContext::EnsureBackbuffer() { + return GetCommandBufferProxy()->EnsureBackbuffer(); +} + void ContentGLContext::SetMemoryAllocationChangedCallback( const base::Callback<void(const GpuMemoryAllocationForRenderer&)>& callback) { diff --git a/content/common/gpu/client/content_gl_context.h b/content/common/gpu/client/content_gl_context.h index 87f4b07..d410a1d 100644 --- a/content/common/gpu/client/content_gl_context.h +++ b/content/common/gpu/client/content_gl_context.h @@ -164,6 +164,9 @@ class ContentGLContext : public base::SupportsWeakPtr<ContentGLContext>, // Sends an IPC message with the new state of surface visibility bool SetSurfaceVisible(bool visibility); + bool DiscardBackbuffer(); + bool EnsureBackbuffer(); + // Register a callback to invoke whenever we recieve a new memory allocation. void SetMemoryAllocationChangedCallback( const base::Callback<void(const GpuMemoryAllocationForRenderer&)>& diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc index 863f07c..9fa7afc 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc @@ -458,6 +458,17 @@ void WebGraphicsContext3DCommandBufferImpl::setVisibilityCHROMIUM( gl_->FreeEverything(); } +void WebGraphicsContext3DCommandBufferImpl::discardFramebufferEXT( + WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) { + gl_->Flush(); + context_->DiscardBackbuffer(); +} + +void WebGraphicsContext3DCommandBufferImpl::ensureFramebufferCHROMIUM() { + gl_->Flush(); + context_->EnsureBackbuffer(); +} + void WebGraphicsContext3DCommandBufferImpl:: setMemoryAllocationChangedCallbackCHROMIUM( WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h index 2508bd7..9bad2f4 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h @@ -443,6 +443,11 @@ class WebGraphicsContext3DCommandBufferImpl virtual void setVisibilityCHROMIUM(bool visible); + virtual void discardFramebufferEXT(WGC3Denum target, + WGC3Dsizei numAttachments, + const WGC3Denum* attachments); + virtual void ensureFramebufferCHROMIUM(); + virtual void setMemoryAllocationChangedCallbackCHROMIUM( WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback); 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 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { 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::OnDestroyVideoDecoder(int decoder_route_id) { } 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 @@ void GpuCommandBufferStub::SetMemoryAllocation( 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) diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index b0eadac..b9ed99e 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -195,6 +195,9 @@ class GpuCommandBufferStub void OnSetSurfaceVisible(bool visible); + void OnDiscardBackbuffer(); + void OnEnsureBackbuffer(); + void OnReschedule(); void OnCommandProcessed(); diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h index 1d38ef9..09d1c74 100644 --- a/content/common/gpu/gpu_messages.h +++ b/content/common/gpu/gpu_messages.h @@ -445,6 +445,9 @@ IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_EchoAck) // Send to stub on surface visibility change. IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetSurfaceVisible, bool /* visible */) +IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_DiscardBackbuffer) +IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_EnsureBackbuffer) + // Sent to proxy when the gpu memory manager changes its memory allocation. IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetMemoryAllocation, GpuMemoryAllocationForRenderer /* allocation */) diff --git a/content/common/gpu/texture_image_transport_surface.cc b/content/common/gpu/texture_image_transport_surface.cc index 6a62977..e9649f5 100644 --- a/content/common/gpu/texture_image_transport_surface.cc +++ b/content/common/gpu/texture_image_transport_surface.cc @@ -157,9 +157,7 @@ void TextureImageTransportSurface::SetBufferAllocation( break; case BUFFER_ALLOCATION_FRONT_ONLY: case BUFFER_ALLOCATION_NONE: - // TODO(piman): Re-enable this (or something else) when we fix the - // renderer so it doesn't try to draw/swap on deleted back buffers. - // ReleaseBackTexture(); + ReleaseBackTexture(); break; }; } @@ -195,6 +193,8 @@ bool TextureImageTransportSurface::SwapBuffers() { front_ = back(); previous_damage_rect_ = gfx::Rect(textures_[front_].size); + DCHECK(textures_[front_].client_id != 0); + GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; params.surface_handle = textures_[front_].client_id; helper_->SendAcceleratedSurfaceBuffersSwapped(params); diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc index 606636c..9e83d97 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -118,6 +118,7 @@ void FeatureInfo::AddFeatures(const char* desired_features) { AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context"); AddExtensionString("GL_CHROMIUM_set_visibility"); AddExtensionString("GL_CHROMIUM_gpu_memory_manager"); + AddExtensionString("GL_CHROMIUM_discard_framebuffer"); AddExtensionString("GL_CHROMIUM_command_buffer_query"); AddExtensionString("GL_ANGLE_translated_shader_source"); diff --git a/ui/gfx/compositor/test_web_graphics_context_3d.h b/ui/gfx/compositor/test_web_graphics_context_3d.h index 796df04..0d44d98 100644 --- a/ui/gfx/compositor/test_web_graphics_context_3d.h +++ b/ui/gfx/compositor/test_web_graphics_context_3d.h @@ -57,6 +57,10 @@ class TestWebGraphicsContext3D : public WebKit::WebGraphicsContext3D { WebKit::WGC3Denum access); virtual void unmapTexSubImage2DCHROMIUM(const void* data) {} virtual void setVisibilityCHROMIUM(bool visible) {} + virtual void discardFramebufferEXT(WebKit::WGC3Denum target, + WebKit::WGC3Dsizei numAttachments, + const WebKit::WGC3Denum* attachments) {} + virtual void ensureFramebufferCHROMIUM() {} virtual void setMemoryAllocationChangedCallbackCHROMIUM( WebGraphicsMemoryAllocationChangedCallbackCHROMIUM*) { } virtual WebKit::WebString getRequestableExtensionsCHROMIUM(); diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc index f729b92..7d9c0a2 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -810,6 +810,19 @@ void WebGraphicsContext3DInProcessCommandBufferImpl::setVisibilityCHROMIUM( } void WebGraphicsContext3DInProcessCommandBufferImpl:: + setMemoryAllocationChangedCallbackCHROMIUM( + WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { +} + +void WebGraphicsContext3DInProcessCommandBufferImpl::discardFramebufferEXT( + WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) { +} + +void WebGraphicsContext3DInProcessCommandBufferImpl:: + ensureFramebufferCHROMIUM() { +} + +void WebGraphicsContext3DInProcessCommandBufferImpl:: copyTextureToParentTextureCHROMIUM(WebGLId texture, WebGLId parentTexture) { NOTIMPLEMENTED(); } diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h index ea69865..947b6d9 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h @@ -424,7 +424,12 @@ class WebGraphicsContext3DInProcessCommandBufferImpl virtual void setVisibilityCHROMIUM(bool visible); virtual void setMemoryAllocationChangedCallbackCHROMIUM( - WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { } + WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback); + + virtual void discardFramebufferEXT(WGC3Denum target, + WGC3Dsizei numAttachments, + const WGC3Denum* attachments); + virtual void ensureFramebufferCHROMIUM(); virtual void copyTextureToParentTextureCHROMIUM( WebGLId texture, WebGLId parentTexture); diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc index 0a331f4..6fefa74 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc +++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc @@ -729,6 +729,18 @@ void WebGraphicsContext3DInProcessImpl::unmapTexSubImage2DCHROMIUM( void WebGraphicsContext3DInProcessImpl::setVisibilityCHROMIUM(bool visible) { } +void WebGraphicsContext3DInProcessImpl:: + setMemoryAllocationChangedCallbackCHROMIUM( + WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { +} + +void WebGraphicsContext3DInProcessImpl::discardFramebufferEXT( + WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) { +} + +void WebGraphicsContext3DInProcessImpl::ensureFramebufferCHROMIUM() { +} + void WebGraphicsContext3DInProcessImpl::copyTextureToParentTextureCHROMIUM( WebGLId id, WebGLId id2) { NOTIMPLEMENTED(); diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.h b/webkit/gpu/webgraphicscontext3d_in_process_impl.h index a26a6ba..8c13ed0 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_impl.h +++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.h @@ -108,7 +108,12 @@ class WebGraphicsContext3DInProcessImpl : public WebGraphicsContext3D { virtual void setVisibilityCHROMIUM(bool visible); virtual void setMemoryAllocationChangedCallbackCHROMIUM( - WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { } + WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback); + + virtual void discardFramebufferEXT(WGC3Denum target, + WGC3Dsizei numAttachments, + const WGC3Denum* attachments); + virtual void ensureFramebufferCHROMIUM(); virtual void copyTextureToParentTextureCHROMIUM( WebGLId texture, WebGLId parentTexture); |