OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/gpu/compositor_output_surface.h" | 5 #include "content/renderer/gpu/compositor_output_surface.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
10 #include "cc/output/compositor_frame_ack.h" | 10 #include "cc/output/compositor_frame_ack.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 base::Passed(&frame->software_frame_data)); | 150 base::Passed(&frame->software_frame_data)); |
151 | 151 |
152 if (context_provider_) { | 152 if (context_provider_) { |
153 gpu::gles2::GLES2Interface* context = context_provider_->ContextGL(); | 153 gpu::gles2::GLES2Interface* context = context_provider_->ContextGL(); |
154 context->Flush(); | 154 context->Flush(); |
155 uint32 sync_point = context->InsertSyncPointCHROMIUM(); | 155 uint32 sync_point = context->InsertSyncPointCHROMIUM(); |
156 context_provider_->ContextSupport()->SignalSyncPoint(sync_point, closure); | 156 context_provider_->ContextSupport()->SignalSyncPoint(sync_point, closure); |
157 } else { | 157 } else { |
158 base::MessageLoopProxy::current()->PostTask(FROM_HERE, closure); | 158 base::MessageLoopProxy::current()->PostTask(FROM_HERE, closure); |
159 } | 159 } |
160 DidSwapBuffers(); | 160 client_->DidSwapBuffers(); |
161 return; | 161 return; |
162 } | 162 } |
163 | 163 |
164 if (use_swap_compositor_frame_message_) { | 164 if (use_swap_compositor_frame_message_) { |
165 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, | 165 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, |
166 output_surface_id_, | 166 output_surface_id_, |
167 *frame)); | 167 *frame)); |
168 DidSwapBuffers(); | 168 client_->DidSwapBuffers(); |
169 return; | 169 return; |
170 } | 170 } |
171 | 171 |
172 if (frame->gl_frame_data) { | 172 if (frame->gl_frame_data) { |
173 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); | 173 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); |
174 ContextProviderCommandBuffer* provider_command_buffer = | 174 ContextProviderCommandBuffer* provider_command_buffer = |
175 static_cast<ContextProviderCommandBuffer*>(context_provider_.get()); | 175 static_cast<ContextProviderCommandBuffer*>(context_provider_.get()); |
176 CommandBufferProxyImpl* command_buffer_proxy = | 176 CommandBufferProxyImpl* command_buffer_proxy = |
177 provider_command_buffer->GetCommandBufferProxy(); | 177 provider_command_buffer->GetCommandBufferProxy(); |
178 DCHECK(command_buffer_proxy); | 178 DCHECK(command_buffer_proxy); |
(...skipping 21 matching lines...) Expand all Loading... |
200 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( | 200 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( |
201 base::TimeTicks timebase, | 201 base::TimeTicks timebase, |
202 base::TimeDelta interval) { | 202 base::TimeDelta interval) { |
203 DCHECK(CalledOnValidThread()); | 203 DCHECK(CalledOnValidThread()); |
204 CommitVSyncParameters(timebase, interval); | 204 CommitVSyncParameters(timebase, interval); |
205 } | 205 } |
206 | 206 |
207 #if defined(OS_ANDROID) | 207 #if defined(OS_ANDROID) |
208 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) { | 208 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) { |
209 DCHECK(CalledOnValidThread()); | 209 DCHECK(CalledOnValidThread()); |
210 if (needs_begin_frame_ != enable) | 210 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); |
211 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); | |
212 OutputSurface::SetNeedsBeginFrame(enable); | |
213 } | 211 } |
214 | 212 |
215 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) { | 213 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) { |
216 DCHECK(CalledOnValidThread()); | 214 DCHECK(CalledOnValidThread()); |
217 BeginFrame(args); | 215 client_->BeginFrame(args); |
218 } | 216 } |
219 #endif // defined(OS_ANDROID) | 217 #endif // defined(OS_ANDROID) |
220 | 218 |
221 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, | 219 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, |
222 const cc::CompositorFrameAck& ack) { | 220 const cc::CompositorFrameAck& ack) { |
223 // Ignore message if it's a stale one coming from a different output surface | 221 // Ignore message if it's a stale one coming from a different output surface |
224 // (e.g. after a lost context). | 222 // (e.g. after a lost context). |
225 if (output_surface_id != output_surface_id_) | 223 if (output_surface_id != output_surface_id_) |
226 return; | 224 return; |
227 ReclaimResources(&ack); | 225 ReclaimResources(&ack); |
228 OnSwapBuffersComplete(); | 226 client_->DidSwapBuffersComplete(); |
229 } | 227 } |
230 | 228 |
231 void CompositorOutputSurface::OnReclaimResources( | 229 void CompositorOutputSurface::OnReclaimResources( |
232 uint32 output_surface_id, | 230 uint32 output_surface_id, |
233 const cc::CompositorFrameAck& ack) { | 231 const cc::CompositorFrameAck& ack) { |
234 // Ignore message if it's a stale one coming from a different output surface | 232 // Ignore message if it's a stale one coming from a different output surface |
235 // (e.g. after a lost context). | 233 // (e.g. after a lost context). |
236 if (output_surface_id != output_surface_id_) | 234 if (output_surface_id != output_surface_id_) |
237 return; | 235 return; |
238 ReclaimResources(&ack); | 236 ReclaimResources(&ack); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // If this is the last surface to stop preferring smoothness, | 275 // If this is the last surface to stop preferring smoothness, |
278 // Reset the main thread's priority to the default. | 276 // Reset the main thread's priority to the default. |
279 if (prefers_smoothness_ == true && | 277 if (prefers_smoothness_ == true && |
280 --g_prefer_smoothness_count == 0) { | 278 --g_prefer_smoothness_count == 0) { |
281 SetThreadPriorityToDefault(main_thread_handle_); | 279 SetThreadPriorityToDefault(main_thread_handle_); |
282 } | 280 } |
283 prefers_smoothness_ = prefers_smoothness; | 281 prefers_smoothness_ = prefers_smoothness; |
284 } | 282 } |
285 | 283 |
286 } // namespace content | 284 } // namespace content |
OLD | NEW |