OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" | 5 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
6 | 6 |
7 #include "cc/output/compositor_frame.h" | 7 #include "cc/output/compositor_frame.h" |
8 #include "cc/output/output_surface_client.h" | |
8 #include "content/browser/compositor/reflector_impl.h" | 9 #include "content/browser/compositor/reflector_impl.h" |
10 #include "content/browser/renderer_host/render_widget_host_impl.h" | |
9 #include "content/common/gpu/client/context_provider_command_buffer.h" | 11 #include "content/common/gpu/client/context_provider_command_buffer.h" |
12 #include "gpu/command_buffer/client/context_support.h" | |
10 #include "gpu/command_buffer/client/gles2_interface.h" | 13 #include "gpu/command_buffer/client/gles2_interface.h" |
11 | 14 |
12 namespace content { | 15 namespace content { |
13 | 16 |
14 GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface( | 17 GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface( |
15 const scoped_refptr<ContextProviderCommandBuffer>& context, | 18 const scoped_refptr<ContextProviderCommandBuffer>& context, |
16 int surface_id, | 19 int surface_id, |
17 IDMap<BrowserCompositorOutputSurface>* output_surface_map, | 20 IDMap<BrowserCompositorOutputSurface>* output_surface_map, |
18 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, | 21 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, |
19 scoped_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator) | 22 scoped_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator) |
20 : BrowserCompositorOutputSurface(context, | 23 : BrowserCompositorOutputSurface(context, |
21 surface_id, | 24 surface_id, |
22 output_surface_map, | 25 output_surface_map, |
23 vsync_manager) { | 26 vsync_manager) { |
24 overlay_candidate_validator_ = overlay_candidate_validator.Pass(); | 27 overlay_candidate_validator_ = overlay_candidate_validator.Pass(); |
25 } | 28 } |
26 | 29 |
27 GpuBrowserCompositorOutputSurface::~GpuBrowserCompositorOutputSurface() {} | 30 GpuBrowserCompositorOutputSurface::~GpuBrowserCompositorOutputSurface() {} |
28 | 31 |
29 void GpuBrowserCompositorOutputSurface::SwapBuffers( | 32 void GpuBrowserCompositorOutputSurface::SwapBuffers( |
30 cc::CompositorFrame* frame) { | 33 cc::CompositorFrame* frame) { |
31 DCHECK(frame->gl_frame_data); | 34 DCHECK(frame->gl_frame_data); |
32 | 35 |
33 ContextProviderCommandBuffer* provider_command_buffer = | 36 ContextProviderCommandBuffer* provider_command_buffer = |
34 static_cast<ContextProviderCommandBuffer*>(context_provider_.get()); | 37 static_cast<ContextProviderCommandBuffer*>(context_provider_.get()); |
35 CommandBufferProxyImpl* command_buffer_proxy = | 38 CommandBufferProxyImpl* command_buffer_proxy = |
36 provider_command_buffer->GetCommandBufferProxy(); | 39 provider_command_buffer->GetCommandBufferProxy(); |
37 DCHECK(command_buffer_proxy); | 40 DCHECK(command_buffer_proxy); |
38 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); | 41 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info, |
42 base::Bind(&GpuBrowserCompositorOutputSurface::OnSwapBuffersCompleted, | |
43 base::Unretained(this))); | |
piman
2014/10/07 02:30:39
Because ContextProvider is refcounted, it might ou
no sievers
2014/10/07 19:47:24
Done. I've used CancelableCallback (which essentia
| |
39 | 44 |
40 if (reflector_.get()) { | 45 if (reflector_.get()) { |
41 if (frame->gl_frame_data->sub_buffer_rect == | 46 if (frame->gl_frame_data->sub_buffer_rect == |
42 gfx::Rect(frame->gl_frame_data->size)) | 47 gfx::Rect(frame->gl_frame_data->size)) |
43 reflector_->OnSwapBuffers(); | 48 reflector_->OnSwapBuffers(); |
44 else | 49 else |
45 reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect); | 50 reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect); |
46 } | 51 } |
47 | 52 |
48 OutputSurface::SwapBuffers(frame); | 53 if (frame->gl_frame_data->sub_buffer_rect == |
54 gfx::Rect(frame->gl_frame_data->size)) { | |
55 context_provider_->ContextSupport()->Swap(); | |
56 } else { | |
57 context_provider_->ContextSupport()->PartialSwapBuffers( | |
58 frame->gl_frame_data->sub_buffer_rect); | |
59 } | |
60 | |
61 client_->DidSwapBuffers(); | |
62 } | |
63 | |
64 void GpuBrowserCompositorOutputSurface::OnSwapBuffersCompleted( | |
65 const std::vector<ui::LatencyInfo>& latency_info) { | |
66 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); | |
67 BrowserCompositorOutputSurface::OnSwapBuffersComplete(); | |
49 } | 68 } |
50 | 69 |
51 } // namespace content | 70 } // namespace content |
OLD | NEW |