| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 198 |
| 201 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 199 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 202 DCHECK(CalledOnValidThread()); | 200 DCHECK(CalledOnValidThread()); |
| 203 if (!HasClient()) | 201 if (!HasClient()) |
| 204 return; | 202 return; |
| 205 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 203 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| 206 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, | 204 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, |
| 207 OnUpdateVSyncParametersFromBrowser); | 205 OnUpdateVSyncParametersFromBrowser); |
| 208 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); | 206 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); |
| 209 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources); | 207 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources); |
| 210 #if defined(OS_ANDROID) | |
| 211 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame); | 208 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame); |
| 212 #endif | |
| 213 IPC_END_MESSAGE_MAP() | 209 IPC_END_MESSAGE_MAP() |
| 214 } | 210 } |
| 215 | 211 |
| 216 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( | 212 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( |
| 217 base::TimeTicks timebase, | 213 base::TimeTicks timebase, |
| 218 base::TimeDelta interval) { | 214 base::TimeDelta interval) { |
| 219 DCHECK(CalledOnValidThread()); | 215 DCHECK(CalledOnValidThread()); |
| 220 CommitVSyncParameters(timebase, interval); | 216 CommitVSyncParameters(timebase, interval); |
| 221 } | 217 } |
| 222 | 218 |
| 223 #if defined(OS_ANDROID) | |
| 224 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) { | 219 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) { |
| 225 DCHECK(CalledOnValidThread()); | 220 DCHECK(CalledOnValidThread()); |
| 226 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); | 221 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); |
| 227 } | 222 } |
| 228 | 223 |
| 229 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) { | 224 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) { |
| 230 DCHECK(CalledOnValidThread()); | 225 DCHECK(CalledOnValidThread()); |
| 231 client_->BeginFrame(args); | 226 BeginFrame(args); |
| 232 } | 227 } |
| 233 #endif // defined(OS_ANDROID) | |
| 234 | 228 |
| 235 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, | 229 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, |
| 236 const cc::CompositorFrameAck& ack) { | 230 const cc::CompositorFrameAck& ack) { |
| 237 // Ignore message if it's a stale one coming from a different output surface | 231 // Ignore message if it's a stale one coming from a different output surface |
| 238 // (e.g. after a lost context). | 232 // (e.g. after a lost context). |
| 239 if (output_surface_id != output_surface_id_) | 233 if (output_surface_id != output_surface_id_) |
| 240 return; | 234 return; |
| 241 ReclaimResources(&ack); | 235 ReclaimResources(&ack); |
| 242 client_->DidSwapBuffersComplete(); | 236 client_->DidSwapBuffersComplete(); |
| 243 } | 237 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 // If this is the last surface to stop preferring smoothness, | 285 // If this is the last surface to stop preferring smoothness, |
| 292 // Reset the main thread's priority to the default. | 286 // Reset the main thread's priority to the default. |
| 293 if (prefers_smoothness_ == true && | 287 if (prefers_smoothness_ == true && |
| 294 --g_prefer_smoothness_count == 0) { | 288 --g_prefer_smoothness_count == 0) { |
| 295 SetThreadPriorityToDefault(main_thread_handle_); | 289 SetThreadPriorityToDefault(main_thread_handle_); |
| 296 } | 290 } |
| 297 prefers_smoothness_ = prefers_smoothness; | 291 prefers_smoothness_ = prefers_smoothness; |
| 298 } | 292 } |
| 299 | 293 |
| 300 } // namespace content | 294 } // namespace content |
| OLD | NEW |