Index: content/browser/compositor/gpu_browser_compositor_output_surface.cc |
diff --git a/content/browser/compositor/gpu_browser_compositor_output_surface.cc b/content/browser/compositor/gpu_browser_compositor_output_surface.cc |
index 5f647626b27bae299a8a61158a096ed07579c17d..ca63bc23d8faabdc562db908caaf776be3aaf5a4 100644 |
--- a/content/browser/compositor/gpu_browser_compositor_output_surface.cc |
+++ b/content/browser/compositor/gpu_browser_compositor_output_surface.cc |
@@ -5,8 +5,12 @@ |
#include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
#include "cc/output/compositor_frame.h" |
+#include "cc/output/output_surface_client.h" |
#include "content/browser/compositor/reflector_impl.h" |
+#include "content/browser/renderer_host/render_widget_host_impl.h" |
#include "content/common/gpu/client/context_provider_command_buffer.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "gpu/command_buffer/client/context_support.h" |
#include "gpu/command_buffer/client/gles2_interface.h" |
namespace content { |
@@ -20,22 +24,41 @@ GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface( |
: BrowserCompositorOutputSurface(context, |
surface_id, |
output_surface_map, |
- vsync_manager) { |
+ vsync_manager), |
+ swap_buffers_completion_callback_( |
+ base::Bind(&GpuBrowserCompositorOutputSurface::OnSwapBuffersCompleted, |
+ base::Unretained(this))) { |
overlay_candidate_validator_ = overlay_candidate_validator.Pass(); |
} |
GpuBrowserCompositorOutputSurface::~GpuBrowserCompositorOutputSurface() {} |
-void GpuBrowserCompositorOutputSurface::SwapBuffers( |
- cc::CompositorFrame* frame) { |
- DCHECK(frame->gl_frame_data); |
- |
+CommandBufferProxyImpl* |
+GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() { |
ContextProviderCommandBuffer* provider_command_buffer = |
- static_cast<ContextProviderCommandBuffer*>(context_provider_.get()); |
+ static_cast<content::ContextProviderCommandBuffer*>( |
+ context_provider_.get()); |
CommandBufferProxyImpl* command_buffer_proxy = |
provider_command_buffer->GetCommandBufferProxy(); |
DCHECK(command_buffer_proxy); |
- command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); |
+ return command_buffer_proxy; |
+} |
+ |
+bool GpuBrowserCompositorOutputSurface::BindToClient( |
+ cc::OutputSurfaceClient* client) { |
+ if (!BrowserCompositorOutputSurface::BindToClient(client)) |
+ return false; |
+ |
+ GetCommandBufferProxy()->SetSwapBuffersCompletionCallback( |
+ swap_buffers_completion_callback_.callback()); |
+ return true; |
+} |
+ |
+void GpuBrowserCompositorOutputSurface::SwapBuffers( |
+ cc::CompositorFrame* frame) { |
+ DCHECK(frame->gl_frame_data); |
+ |
+ GetCommandBufferProxy()->SetLatencyInfo(frame->metadata.latency_info); |
if (reflector_.get()) { |
if (frame->gl_frame_data->sub_buffer_rect == |
@@ -45,13 +68,32 @@ void GpuBrowserCompositorOutputSurface::SwapBuffers( |
reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect); |
} |
- OutputSurface::SwapBuffers(frame); |
+ if (frame->gl_frame_data->sub_buffer_rect == |
+ gfx::Rect(frame->gl_frame_data->size)) { |
+ context_provider_->ContextSupport()->Swap(); |
+ } else { |
+ context_provider_->ContextSupport()->PartialSwapBuffers( |
+ frame->gl_frame_data->sub_buffer_rect); |
+ } |
+ |
+ client_->DidSwapBuffers(); |
} |
-void GpuBrowserCompositorOutputSurface::OnSwapBuffersComplete() { |
+void GpuBrowserCompositorOutputSurface::OnSwapBuffersCompleted( |
+ const std::vector<ui::LatencyInfo>& latency_info) { |
+#if defined(OS_MACOSX) |
// On Mac, delay acknowledging the swap to the output surface client until |
- // it has been drawn. |
-#if !defined(OS_MACOSX) |
+ // it has been drawn, see OnSurfaceDisplayed(); |
+ NOTREACHED(); |
+#else |
+ if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
+ RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); |
+ } else { |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&RenderWidgetHostImpl::CompositorFrameDrawn, latency_info)); |
+ } |
cc::OutputSurface::OnSwapBuffersComplete(); |
#endif |
} |