| 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_proxy.h" | 8 #include "base/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 24 matching lines...) Expand all Loading... |
| 35 namespace content { | 35 namespace content { |
| 36 | 36 |
| 37 //------------------------------------------------------------------------------ | 37 //------------------------------------------------------------------------------ |
| 38 | 38 |
| 39 // static | 39 // static |
| 40 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( | 40 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( |
| 41 base::TaskRunner* target_task_runner) | 41 base::TaskRunner* target_task_runner) |
| 42 { | 42 { |
| 43 uint32 messages_to_filter[] = { | 43 uint32 messages_to_filter[] = { |
| 44 ViewMsg_UpdateVSyncParameters::ID, | 44 ViewMsg_UpdateVSyncParameters::ID, |
| 45 ViewMsg_DidVSync::ID, |
| 45 ViewMsg_SwapCompositorFrameAck::ID | 46 ViewMsg_SwapCompositorFrameAck::ID |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 return new IPC::ForwardingMessageFilter( | 49 return new IPC::ForwardingMessageFilter( |
| 49 messages_to_filter, arraysize(messages_to_filter), | 50 messages_to_filter, arraysize(messages_to_filter), |
| 50 target_task_runner); | 51 target_task_runner); |
| 51 } | 52 } |
| 52 | 53 |
| 53 CompositorOutputSurface::CompositorOutputSurface( | 54 CompositorOutputSurface::CompositorOutputSurface( |
| 54 int32 routing_id, | 55 int32 routing_id, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 DCHECK(CalledOnValidThread()); | 100 DCHECK(CalledOnValidThread()); |
| 100 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); | 101 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 104 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 104 DCHECK(CalledOnValidThread()); | 105 DCHECK(CalledOnValidThread()); |
| 105 if (!client_) | 106 if (!client_) |
| 106 return; | 107 return; |
| 107 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 108 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| 108 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); | 109 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); |
| 110 IPC_MESSAGE_HANDLER(ViewMsg_DidVSync, DidVSync); |
| 109 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); | 111 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); |
| 110 IPC_END_MESSAGE_MAP() | 112 IPC_END_MESSAGE_MAP() |
| 111 } | 113 } |
| 112 | 114 |
| 113 void CompositorOutputSurface::OnUpdateVSyncParameters( | 115 void CompositorOutputSurface::OnUpdateVSyncParameters( |
| 114 base::TimeTicks timebase, base::TimeDelta interval) { | 116 base::TimeTicks timebase, base::TimeDelta interval) { |
| 115 DCHECK(CalledOnValidThread()); | 117 DCHECK(CalledOnValidThread()); |
| 116 DCHECK(client_); | 118 DCHECK(client_); |
| 117 client_->OnVSyncParametersChanged(timebase, interval); | 119 client_->OnVSyncParametersChanged(timebase, interval); |
| 118 } | 120 } |
| 119 | 121 |
| 122 void CompositorOutputSurface::EnableVSyncNotification(bool enable) { |
| 123 DCHECK(CalledOnValidThread()); |
| 124 DCHECK(client_); |
| 125 Send(new ViewHostMsg_EnableVSyncNotification(routing_id_, enable)); |
| 126 } |
| 127 |
| 128 void CompositorOutputSurface::DidVSync(base::TimeTicks frame_time) { |
| 129 DCHECK(CalledOnValidThread()); |
| 130 DCHECK(client_); |
| 131 client_->DidVSync(frame_time); |
| 132 } |
| 133 |
| 120 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { | 134 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { |
| 121 client_->OnSendFrameToParentCompositorAck(ack); | 135 client_->OnSendFrameToParentCompositorAck(ack); |
| 122 } | 136 } |
| 123 | 137 |
| 124 bool CompositorOutputSurface::Send(IPC::Message* message) { | 138 bool CompositorOutputSurface::Send(IPC::Message* message) { |
| 125 return ChildThread::current()->sync_message_filter()->Send(message); | 139 return ChildThread::current()->sync_message_filter()->Send(message); |
| 126 } | 140 } |
| 127 | 141 |
| 128 namespace { | 142 namespace { |
| 129 #if defined(OS_ANDROID) | 143 #if defined(OS_ANDROID) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // If this is the last surface to stop preferring smoothness, | 175 // If this is the last surface to stop preferring smoothness, |
| 162 // Reset the main thread's priority to the default. | 176 // Reset the main thread's priority to the default. |
| 163 if (prefers_smoothness_ == true && | 177 if (prefers_smoothness_ == true && |
| 164 --g_prefer_smoothness_count == 0) { | 178 --g_prefer_smoothness_count == 0) { |
| 165 SetThreadsPriorityToDefault(main_thread_id_); | 179 SetThreadsPriorityToDefault(main_thread_id_); |
| 166 } | 180 } |
| 167 prefers_smoothness_ = prefers_smoothness; | 181 prefers_smoothness_ = prefers_smoothness; |
| 168 } | 182 } |
| 169 | 183 |
| 170 } // namespace content | 184 } // namespace content |
| OLD | NEW |