| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 DCHECK(output_surface_filter_.get()); | 73 DCHECK(output_surface_filter_.get()); |
| 74 DetachFromThread(); | 74 DetachFromThread(); |
| 75 message_sender_ = RenderThreadImpl::current()->sync_message_filter(); | 75 message_sender_ = RenderThreadImpl::current()->sync_message_filter(); |
| 76 DCHECK(message_sender_.get()); | 76 DCHECK(message_sender_.get()); |
| 77 if (OutputSurface::software_device()) | 77 if (OutputSurface::software_device()) |
| 78 capabilities_.max_frames_pending = 1; | 78 capabilities_.max_frames_pending = 1; |
| 79 } | 79 } |
| 80 | 80 |
| 81 CompositorOutputSurface::~CompositorOutputSurface() { | 81 CompositorOutputSurface::~CompositorOutputSurface() { |
| 82 DCHECK(CalledOnValidThread()); | 82 DCHECK(CalledOnValidThread()); |
| 83 SetNeedsBeginImplFrame(false); | 83 SetNeedsBeginFrame(false); |
| 84 if (!HasClient()) | 84 if (!HasClient()) |
| 85 return; | 85 return; |
| 86 UpdateSmoothnessTakesPriority(false); | 86 UpdateSmoothnessTakesPriority(false); |
| 87 if (output_surface_proxy_.get()) | 87 if (output_surface_proxy_.get()) |
| 88 output_surface_proxy_->ClearOutputSurface(); | 88 output_surface_proxy_->ClearOutputSurface(); |
| 89 output_surface_filter_->RemoveRoute(routing_id_); | 89 output_surface_filter_->RemoveRoute(routing_id_); |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool CompositorOutputSurface::BindToClient( | 92 bool CompositorOutputSurface::BindToClient( |
| 93 cc::OutputSurfaceClient* client) { | 93 cc::OutputSurfaceClient* client) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 185 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 186 DCHECK(CalledOnValidThread()); | 186 DCHECK(CalledOnValidThread()); |
| 187 if (!HasClient()) | 187 if (!HasClient()) |
| 188 return; | 188 return; |
| 189 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 189 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| 190 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, | 190 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, |
| 191 OnUpdateVSyncParametersFromBrowser); | 191 OnUpdateVSyncParametersFromBrowser); |
| 192 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); | 192 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); |
| 193 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources); | 193 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources); |
| 194 #if defined(OS_ANDROID) | 194 #if defined(OS_ANDROID) |
| 195 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginImplFrame); | 195 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame); |
| 196 #endif | 196 #endif |
| 197 IPC_END_MESSAGE_MAP() | 197 IPC_END_MESSAGE_MAP() |
| 198 } | 198 } |
| 199 | 199 |
| 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::SetNeedsBeginImplFrame(bool enable) { | 208 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) { |
| 209 DCHECK(CalledOnValidThread()); | 209 DCHECK(CalledOnValidThread()); |
| 210 if (needs_begin_impl_frame_ != enable) | 210 if (needs_begin_frame_ != enable) |
| 211 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); | 211 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); |
| 212 OutputSurface::SetNeedsBeginImplFrame(enable); | 212 OutputSurface::SetNeedsBeginFrame(enable); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void CompositorOutputSurface::OnBeginImplFrame(const cc::BeginFrameArgs& args) { | 215 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) { |
| 216 DCHECK(CalledOnValidThread()); | 216 DCHECK(CalledOnValidThread()); |
| 217 BeginImplFrame(args); | 217 BeginFrame(args); |
| 218 } | 218 } |
| 219 #endif // defined(OS_ANDROID) | 219 #endif // defined(OS_ANDROID) |
| 220 | 220 |
| 221 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, | 221 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, |
| 222 const cc::CompositorFrameAck& ack) { | 222 const cc::CompositorFrameAck& ack) { |
| 223 // Ignore message if it's a stale one coming from a different output surface | 223 // Ignore message if it's a stale one coming from a different output surface |
| 224 // (e.g. after a lost context). | 224 // (e.g. after a lost context). |
| 225 if (output_surface_id != output_surface_id_) | 225 if (output_surface_id != output_surface_id_) |
| 226 return; | 226 return; |
| 227 ReclaimResources(&ack); | 227 ReclaimResources(&ack); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // If this is the last surface to stop preferring smoothness, | 277 // If this is the last surface to stop preferring smoothness, |
| 278 // Reset the main thread's priority to the default. | 278 // Reset the main thread's priority to the default. |
| 279 if (prefers_smoothness_ == true && | 279 if (prefers_smoothness_ == true && |
| 280 --g_prefer_smoothness_count == 0) { | 280 --g_prefer_smoothness_count == 0) { |
| 281 SetThreadPriorityToDefault(main_thread_handle_); | 281 SetThreadPriorityToDefault(main_thread_handle_); |
| 282 } | 282 } |
| 283 prefers_smoothness_ = prefers_smoothness; | 283 prefers_smoothness_ = prefers_smoothness; |
| 284 } | 284 } |
| 285 | 285 |
| 286 } // namespace content | 286 } // namespace content |
| OLD | NEW |