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 "cc/output/output_surface_client.h" |
9 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" | 9 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" |
10 #include "content/browser/compositor/reflector_impl.h" | 10 #include "content/browser/compositor/reflector_impl.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, | 21 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, |
22 scoped_ptr<BrowserCompositorOverlayCandidateValidator> | 22 scoped_ptr<BrowserCompositorOverlayCandidateValidator> |
23 overlay_candidate_validator) | 23 overlay_candidate_validator) |
24 : BrowserCompositorOutputSurface(context, | 24 : BrowserCompositorOutputSurface(context, |
25 worker_context, | 25 worker_context, |
26 vsync_manager, | 26 vsync_manager, |
27 overlay_candidate_validator.Pass()), | 27 overlay_candidate_validator.Pass()), |
28 #if defined(OS_MACOSX) | 28 #if defined(OS_MACOSX) |
29 should_show_frames_state_(SHOULD_SHOW_FRAMES), | 29 should_show_frames_state_(SHOULD_SHOW_FRAMES), |
30 #endif | 30 #endif |
31 swap_buffers_completion_callback_( | 31 swap_buffers_completion_callback_(base::Bind( |
32 base::Bind(&GpuBrowserCompositorOutputSurface::OnSwapBuffersCompleted, | 32 &GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted, |
33 base::Unretained(this))), | 33 base::Unretained(this))), |
34 update_vsync_parameters_callback_(base::Bind( | 34 update_vsync_parameters_callback_(base::Bind( |
35 &BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu, | 35 &BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu, |
36 base::Unretained(this))) { | 36 base::Unretained(this))) { |
37 } | 37 } |
38 | 38 |
39 GpuBrowserCompositorOutputSurface::~GpuBrowserCompositorOutputSurface() {} | 39 GpuBrowserCompositorOutputSurface::~GpuBrowserCompositorOutputSurface() {} |
40 | 40 |
41 CommandBufferProxyImpl* | 41 CommandBufferProxyImpl* |
42 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() { | 42 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() { |
43 ContextProviderCommandBuffer* provider_command_buffer = | 43 ContextProviderCommandBuffer* provider_command_buffer = |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 client_->DidSwapBuffers(); | 99 client_->DidSwapBuffers(); |
100 | 100 |
101 #if defined(OS_MACOSX) | 101 #if defined(OS_MACOSX) |
102 if (should_show_frames_state_ == | 102 if (should_show_frames_state_ == |
103 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED) { | 103 SHOULD_NOT_SHOW_FRAMES_NO_SWAP_AFTER_SUSPENDED) { |
104 should_show_frames_state_ = SHOULD_SHOW_FRAMES; | 104 should_show_frames_state_ = SHOULD_SHOW_FRAMES; |
105 } | 105 } |
106 #endif | 106 #endif |
107 } | 107 } |
108 | 108 |
109 void GpuBrowserCompositorOutputSurface::OnSwapBuffersCompleted( | 109 void GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( |
110 const std::vector<ui::LatencyInfo>& latency_info, | 110 const std::vector<ui::LatencyInfo>& latency_info, |
111 gfx::SwapResult result) { | 111 gfx::SwapResult result) { |
112 #if defined(OS_MACOSX) | |
113 // On Mac, delay acknowledging the swap to the output surface client until | |
114 // it has been drawn, see OnSurfaceDisplayed(); | |
115 NOTREACHED(); | |
116 #else | |
117 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); | 112 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); |
118 OnSwapBuffersComplete(); | 113 OnSwapBuffersComplete(); |
119 #endif | |
120 } | 114 } |
121 | 115 |
122 #if defined(OS_MACOSX) | 116 #if defined(OS_MACOSX) |
123 void GpuBrowserCompositorOutputSurface::OnSurfaceDisplayed() { | |
124 cc::OutputSurface::OnSwapBuffersComplete(); | |
125 } | |
126 | |
127 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( | 117 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( |
128 bool suspended) { | 118 bool suspended) { |
129 if (suspended) { | 119 if (suspended) { |
130 // It may be that there are frames in-flight from the GPU process back to | 120 // It may be that there are frames in-flight from the GPU process back to |
131 // the browser. Make sure that these frames are not displayed by ignoring | 121 // the browser. Make sure that these frames are not displayed by ignoring |
132 // them in GpuProcessHostUIShim, until the browser issues a SwapBuffers for | 122 // them in GpuProcessHostUIShim, until the browser issues a SwapBuffers for |
133 // the new content. | 123 // the new content. |
134 should_show_frames_state_ = SHOULD_NOT_SHOW_FRAMES_SUSPENDED; | 124 should_show_frames_state_ = SHOULD_NOT_SHOW_FRAMES_SUSPENDED; |
135 } else { | 125 } else { |
136 // Discard the backbuffer before drawing the new frame. This is necessary | 126 // Discard the backbuffer before drawing the new frame. This is necessary |
(...skipping 20 matching lines...) Expand all Loading... |
157 | 147 |
158 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const { | 148 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const { |
159 #if defined(OS_MACOSX) | 149 #if defined(OS_MACOSX) |
160 return should_show_frames_state_ == SHOULD_NOT_SHOW_FRAMES_SUSPENDED; | 150 return should_show_frames_state_ == SHOULD_NOT_SHOW_FRAMES_SUSPENDED; |
161 #else | 151 #else |
162 return false; | 152 return false; |
163 #endif | 153 #endif |
164 } | 154 } |
165 | 155 |
166 } // namespace content | 156 } // namespace content |
OLD | NEW |