Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: content/browser/compositor/gpu_browser_compositor_output_surface.cc

Issue 628703005: Remove GpuHostMsg_FrameDrawn and replace with client channel swap ack (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, fix cros/threaded Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/public/browser/browser_thread.h"
13 #include "gpu/command_buffer/client/context_support.h"
10 #include "gpu/command_buffer/client/gles2_interface.h" 14 #include "gpu/command_buffer/client/gles2_interface.h"
11 15
12 namespace content { 16 namespace content {
13 17
14 GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface( 18 GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface(
15 const scoped_refptr<ContextProviderCommandBuffer>& context, 19 const scoped_refptr<ContextProviderCommandBuffer>& context,
16 int surface_id, 20 int surface_id,
17 IDMap<BrowserCompositorOutputSurface>* output_surface_map, 21 IDMap<BrowserCompositorOutputSurface>* output_surface_map,
18 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, 22 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
19 scoped_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator) 23 scoped_ptr<cc::OverlayCandidateValidator> overlay_candidate_validator)
20 : BrowserCompositorOutputSurface(context, 24 : BrowserCompositorOutputSurface(context,
21 surface_id, 25 surface_id,
22 output_surface_map, 26 output_surface_map,
23 vsync_manager) { 27 vsync_manager),
28 swap_buffers_completion_callback_(
29 base::Bind(&GpuBrowserCompositorOutputSurface::OnSwapBuffersCompleted,
30 base::Unretained(this))) {
24 overlay_candidate_validator_ = overlay_candidate_validator.Pass(); 31 overlay_candidate_validator_ = overlay_candidate_validator.Pass();
25 } 32 }
26 33
27 GpuBrowserCompositorOutputSurface::~GpuBrowserCompositorOutputSurface() {} 34 GpuBrowserCompositorOutputSurface::~GpuBrowserCompositorOutputSurface() {}
28 35
36 CommandBufferProxyImpl*
37 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() {
38 ContextProviderCommandBuffer* provider_command_buffer =
39 static_cast<content::ContextProviderCommandBuffer*>(
40 context_provider_.get());
41 CommandBufferProxyImpl* command_buffer_proxy =
42 provider_command_buffer->GetCommandBufferProxy();
43 DCHECK(command_buffer_proxy);
44 return command_buffer_proxy;
45 }
46
47 bool GpuBrowserCompositorOutputSurface::BindToClient(
48 cc::OutputSurfaceClient* client) {
49 if (!BrowserCompositorOutputSurface::BindToClient(client))
50 return false;
51
52 GetCommandBufferProxy()->SetSwapBuffersCompletionCallback(
53 swap_buffers_completion_callback_.callback());
54 return true;
55 }
56
29 void GpuBrowserCompositorOutputSurface::SwapBuffers( 57 void GpuBrowserCompositorOutputSurface::SwapBuffers(
30 cc::CompositorFrame* frame) { 58 cc::CompositorFrame* frame) {
31 DCHECK(frame->gl_frame_data); 59 DCHECK(frame->gl_frame_data);
32 60
33 ContextProviderCommandBuffer* provider_command_buffer = 61 GetCommandBufferProxy()->SetLatencyInfo(frame->metadata.latency_info);
34 static_cast<ContextProviderCommandBuffer*>(context_provider_.get());
35 CommandBufferProxyImpl* command_buffer_proxy =
36 provider_command_buffer->GetCommandBufferProxy();
37 DCHECK(command_buffer_proxy);
38 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info);
39 62
40 if (reflector_.get()) { 63 if (reflector_.get()) {
41 if (frame->gl_frame_data->sub_buffer_rect == 64 if (frame->gl_frame_data->sub_buffer_rect ==
42 gfx::Rect(frame->gl_frame_data->size)) 65 gfx::Rect(frame->gl_frame_data->size))
43 reflector_->OnSwapBuffers(); 66 reflector_->OnSwapBuffers();
44 else 67 else
45 reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect); 68 reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect);
46 } 69 }
47 70
48 OutputSurface::SwapBuffers(frame); 71 if (frame->gl_frame_data->sub_buffer_rect ==
72 gfx::Rect(frame->gl_frame_data->size)) {
73 context_provider_->ContextSupport()->Swap();
74 } else {
75 context_provider_->ContextSupport()->PartialSwapBuffers(
76 frame->gl_frame_data->sub_buffer_rect);
77 }
78
79 client_->DidSwapBuffers();
49 } 80 }
50 81
51 void GpuBrowserCompositorOutputSurface::OnSwapBuffersComplete() { 82 void GpuBrowserCompositorOutputSurface::OnSwapBuffersCompleted(
83 const std::vector<ui::LatencyInfo>& latency_info) {
84 #if defined(OS_MACOSX)
52 // On Mac, delay acknowledging the swap to the output surface client until 85 // On Mac, delay acknowledging the swap to the output surface client until
53 // it has been drawn. 86 // it has been drawn, see OnSurfaceDisplayed();
54 #if !defined(OS_MACOSX) 87 NOTREACHED();
88 #else
89 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
90 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info);
91 } else {
92 BrowserThread::PostTask(
93 BrowserThread::UI,
94 FROM_HERE,
95 base::Bind(&RenderWidgetHostImpl::CompositorFrameDrawn, latency_info));
96 }
55 cc::OutputSurface::OnSwapBuffersComplete(); 97 cc::OutputSurface::OnSwapBuffersComplete();
56 #endif 98 #endif
57 } 99 }
58 100
59 #if defined(OS_MACOSX) 101 #if defined(OS_MACOSX)
60 void GpuBrowserCompositorOutputSurface::OnSurfaceDisplayed() { 102 void GpuBrowserCompositorOutputSurface::OnSurfaceDisplayed() {
61 cc::OutputSurface::OnSwapBuffersComplete(); 103 cc::OutputSurface::OnSwapBuffersComplete();
62 } 104 }
63 #endif 105 #endif
64 106
65 } // namespace content 107 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/gpu_browser_compositor_output_surface.h ('k') | content/browser/gpu/gpu_process_host_ui_shim.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698