| 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 22 matching lines...) Expand all Loading... |
| 33 //------------------------------------------------------------------------------ | 33 //------------------------------------------------------------------------------ |
| 34 | 34 |
| 35 // static | 35 // static |
| 36 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( | 36 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( |
| 37 base::TaskRunner* target_task_runner) | 37 base::TaskRunner* target_task_runner) |
| 38 { | 38 { |
| 39 uint32 messages_to_filter[] = { | 39 uint32 messages_to_filter[] = { |
| 40 ViewMsg_UpdateVSyncParameters::ID, | 40 ViewMsg_UpdateVSyncParameters::ID, |
| 41 ViewMsg_SwapCompositorFrameAck::ID, | 41 ViewMsg_SwapCompositorFrameAck::ID, |
| 42 ViewMsg_ReclaimCompositorResources::ID, | 42 ViewMsg_ReclaimCompositorResources::ID, |
| 43 #if defined(OS_ANDROID) | |
| 44 ViewMsg_BeginFrame::ID | 43 ViewMsg_BeginFrame::ID |
| 45 #endif | |
| 46 }; | 44 }; |
| 47 | 45 |
| 48 return new IPC::ForwardingMessageFilter( | 46 return new IPC::ForwardingMessageFilter( |
| 49 messages_to_filter, arraysize(messages_to_filter), | 47 messages_to_filter, arraysize(messages_to_filter), |
| 50 target_task_runner); | 48 target_task_runner); |
| 51 } | 49 } |
| 52 | 50 |
| 53 CompositorOutputSurface::CompositorOutputSurface( | 51 CompositorOutputSurface::CompositorOutputSurface( |
| 54 int32 routing_id, | 52 int32 routing_id, |
| 55 uint32 output_surface_id, | 53 uint32 output_surface_id, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 197 |
| 200 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 198 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 201 DCHECK(CalledOnValidThread()); | 199 DCHECK(CalledOnValidThread()); |
| 202 if (!HasClient()) | 200 if (!HasClient()) |
| 203 return; | 201 return; |
| 204 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 202 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| 205 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, | 203 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, |
| 206 OnUpdateVSyncParametersFromBrowser); | 204 OnUpdateVSyncParametersFromBrowser); |
| 207 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); | 205 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); |
| 208 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources); | 206 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources); |
| 209 #if defined(OS_ANDROID) | |
| 210 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame); | 207 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame); |
| 211 #endif | |
| 212 IPC_END_MESSAGE_MAP() | 208 IPC_END_MESSAGE_MAP() |
| 213 } | 209 } |
| 214 | 210 |
| 215 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( | 211 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( |
| 216 base::TimeTicks timebase, | 212 base::TimeTicks timebase, |
| 217 base::TimeDelta interval) { | 213 base::TimeDelta interval) { |
| 218 DCHECK(CalledOnValidThread()); | 214 DCHECK(CalledOnValidThread()); |
| 219 CommitVSyncParameters(timebase, interval); | 215 CommitVSyncParameters(timebase, interval); |
| 220 } | 216 } |
| 221 | 217 |
| 222 #if defined(OS_ANDROID) | |
| 223 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) { | 218 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) { |
| 224 DCHECK(CalledOnValidThread()); | 219 DCHECK(CalledOnValidThread()); |
| 225 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); | 220 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); |
| 226 } | 221 } |
| 227 | 222 |
| 228 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) { | 223 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) { |
| 229 DCHECK(CalledOnValidThread()); | 224 DCHECK(CalledOnValidThread()); |
| 230 client_->BeginFrame(args); | 225 BeginFrame(args); |
| 231 } | 226 } |
| 232 #endif // defined(OS_ANDROID) | |
| 233 | 227 |
| 234 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, | 228 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, |
| 235 const cc::CompositorFrameAck& ack) { | 229 const cc::CompositorFrameAck& ack) { |
| 236 // 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 |
| 237 // (e.g. after a lost context). | 231 // (e.g. after a lost context). |
| 238 if (output_surface_id != output_surface_id_) | 232 if (output_surface_id != output_surface_id_) |
| 239 return; | 233 return; |
| 240 ReclaimResources(&ack); | 234 ReclaimResources(&ack); |
| 241 client_->DidSwapBuffersComplete(); | 235 client_->DidSwapBuffersComplete(); |
| 242 } | 236 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // If this is the last surface to stop preferring smoothness, | 284 // If this is the last surface to stop preferring smoothness, |
| 291 // Reset the main thread's priority to the default. | 285 // Reset the main thread's priority to the default. |
| 292 if (prefers_smoothness_ == true && | 286 if (prefers_smoothness_ == true && |
| 293 --g_prefer_smoothness_count == 0) { | 287 --g_prefer_smoothness_count == 0) { |
| 294 SetThreadPriorityToDefault(main_thread_handle_); | 288 SetThreadPriorityToDefault(main_thread_handle_); |
| 295 } | 289 } |
| 296 prefers_smoothness_ = prefers_smoothness; | 290 prefers_smoothness_ = prefers_smoothness; |
| 297 } | 291 } |
| 298 | 292 |
| 299 } // namespace content | 293 } // namespace content |
| OLD | NEW |