Chromium Code Reviews| 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); |
| 179 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); | 179 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); |
| 180 } | 180 } |
| 181 | |
| 182 OutputSurface::SwapBuffers(frame); | |
|
brianderson
2014/04/22 22:41:22
I shouldn't have removed this. Will add it back.
| |
| 183 } | 181 } |
| 184 | 182 |
| 185 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 183 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 186 DCHECK(CalledOnValidThread()); | 184 DCHECK(CalledOnValidThread()); |
| 187 if (!HasClient()) | 185 if (!HasClient()) |
| 188 return; | 186 return; |
| 189 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 187 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| 190 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, | 188 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, |
| 191 OnUpdateVSyncParametersFromBrowser); | 189 OnUpdateVSyncParametersFromBrowser); |
| 192 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); | 190 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); |
| 193 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources); | 191 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources); |
| 194 #if defined(OS_ANDROID) | 192 #if defined(OS_ANDROID) |
| 195 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame); | 193 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame); |
| 196 #endif | 194 #endif |
| 197 IPC_END_MESSAGE_MAP() | 195 IPC_END_MESSAGE_MAP() |
| 198 } | 196 } |
| 199 | 197 |
| 200 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( | 198 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( |
| 201 base::TimeTicks timebase, | 199 base::TimeTicks timebase, |
| 202 base::TimeDelta interval) { | 200 base::TimeDelta interval) { |
| 203 DCHECK(CalledOnValidThread()); | 201 DCHECK(CalledOnValidThread()); |
| 204 CommitVSyncParameters(timebase, interval); | 202 CommitVSyncParameters(timebase, interval); |
| 205 } | 203 } |
| 206 | 204 |
| 207 #if defined(OS_ANDROID) | 205 #if defined(OS_ANDROID) |
| 208 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) { | 206 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) { |
| 209 DCHECK(CalledOnValidThread()); | 207 DCHECK(CalledOnValidThread()); |
| 210 if (needs_begin_frame_ != enable) | 208 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); |
| 211 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); | |
| 212 OutputSurface::SetNeedsBeginFrame(enable); | |
| 213 } | 209 } |
| 214 | 210 |
| 215 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) { | 211 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) { |
| 216 DCHECK(CalledOnValidThread()); | 212 DCHECK(CalledOnValidThread()); |
| 217 BeginFrame(args); | 213 client_->BeginFrame(args); |
| 218 } | 214 } |
| 219 #endif // defined(OS_ANDROID) | 215 #endif // defined(OS_ANDROID) |
| 220 | 216 |
| 221 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, | 217 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, |
| 222 const cc::CompositorFrameAck& ack) { | 218 const cc::CompositorFrameAck& ack) { |
| 223 // Ignore message if it's a stale one coming from a different output surface | 219 // Ignore message if it's a stale one coming from a different output surface |
| 224 // (e.g. after a lost context). | 220 // (e.g. after a lost context). |
| 225 if (output_surface_id != output_surface_id_) | 221 if (output_surface_id != output_surface_id_) |
| 226 return; | 222 return; |
| 227 ReclaimResources(&ack); | 223 ReclaimResources(&ack); |
| 228 OnSwapBuffersComplete(); | 224 client_->DidSwapBuffersComplete(); |
| 229 } | 225 } |
| 230 | 226 |
| 231 void CompositorOutputSurface::OnReclaimResources( | 227 void CompositorOutputSurface::OnReclaimResources( |
| 232 uint32 output_surface_id, | 228 uint32 output_surface_id, |
| 233 const cc::CompositorFrameAck& ack) { | 229 const cc::CompositorFrameAck& ack) { |
| 234 // Ignore message if it's a stale one coming from a different output surface | 230 // Ignore message if it's a stale one coming from a different output surface |
| 235 // (e.g. after a lost context). | 231 // (e.g. after a lost context). |
| 236 if (output_surface_id != output_surface_id_) | 232 if (output_surface_id != output_surface_id_) |
| 237 return; | 233 return; |
| 238 ReclaimResources(&ack); | 234 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, | 273 // If this is the last surface to stop preferring smoothness, |
| 278 // Reset the main thread's priority to the default. | 274 // Reset the main thread's priority to the default. |
| 279 if (prefers_smoothness_ == true && | 275 if (prefers_smoothness_ == true && |
| 280 --g_prefer_smoothness_count == 0) { | 276 --g_prefer_smoothness_count == 0) { |
| 281 SetThreadPriorityToDefault(main_thread_handle_); | 277 SetThreadPriorityToDefault(main_thread_handle_); |
| 282 } | 278 } |
| 283 prefers_smoothness_ = prefers_smoothness; | 279 prefers_smoothness_ = prefers_smoothness; |
| 284 } | 280 } |
| 285 | 281 |
| 286 } // namespace content | 282 } // namespace content |
| OLD | NEW |