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_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 #if defined(OS_ANDROID) | |
| 46 ViewMsg_DidVSync::ID, | |
| 47 #endif | |
| 45 ViewMsg_SwapCompositorFrameAck::ID | 48 ViewMsg_SwapCompositorFrameAck::ID |
| 46 }; | 49 }; |
| 47 | 50 |
| 48 return new IPC::ForwardingMessageFilter( | 51 return new IPC::ForwardingMessageFilter( |
| 49 messages_to_filter, arraysize(messages_to_filter), | 52 messages_to_filter, arraysize(messages_to_filter), |
| 50 target_task_runner); | 53 target_task_runner); |
| 51 } | 54 } |
| 52 | 55 |
| 53 CompositorOutputSurface::CompositorOutputSurface( | 56 CompositorOutputSurface::CompositorOutputSurface( |
| 54 int32 routing_id, | 57 int32 routing_id, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 command_buffer_proxy->SetLatencyInfo(latency_info); | 126 command_buffer_proxy->SetLatencyInfo(latency_info); |
| 124 OutputSurface::PostSubBuffer(rect, latency_info); | 127 OutputSurface::PostSubBuffer(rect, latency_info); |
| 125 } | 128 } |
| 126 | 129 |
| 127 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 130 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 128 DCHECK(CalledOnValidThread()); | 131 DCHECK(CalledOnValidThread()); |
| 129 if (!client_) | 132 if (!client_) |
| 130 return; | 133 return; |
| 131 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 134 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| 132 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); | 135 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); |
| 136 #if defined(OS_ANDROID) | |
|
jam
2013/04/16 22:55:50
nit: convention is to put ifdef section at end of
| |
| 137 IPC_MESSAGE_HANDLER(ViewMsg_DidVSync, OnDidVSync); | |
| 138 #endif | |
| 133 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); | 139 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); |
| 134 IPC_END_MESSAGE_MAP() | 140 IPC_END_MESSAGE_MAP() |
| 135 } | 141 } |
| 136 | 142 |
| 137 void CompositorOutputSurface::OnUpdateVSyncParameters( | 143 void CompositorOutputSurface::OnUpdateVSyncParameters( |
| 138 base::TimeTicks timebase, base::TimeDelta interval) { | 144 base::TimeTicks timebase, base::TimeDelta interval) { |
| 139 DCHECK(CalledOnValidThread()); | 145 DCHECK(CalledOnValidThread()); |
| 140 DCHECK(client_); | |
| 141 client_->OnVSyncParametersChanged(timebase, interval); | 146 client_->OnVSyncParametersChanged(timebase, interval); |
| 142 } | 147 } |
| 143 | 148 |
| 149 #if defined(OS_ANDROID) | |
| 150 void CompositorOutputSurface::EnableVSyncNotification(bool enable) { | |
| 151 DCHECK(CalledOnValidThread()); | |
| 152 Send(new ViewHostMsg_SetVSyncNotificationEnabled(routing_id_, enable)); | |
| 153 } | |
| 154 | |
| 155 void CompositorOutputSurface::OnDidVSync(base::TimeTicks frame_time) { | |
| 156 DCHECK(CalledOnValidThread()); | |
| 157 client_->DidVSync(frame_time); | |
| 158 } | |
| 159 #endif // defined(OS_ANDROID) | |
| 160 | |
| 144 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { | 161 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { |
| 145 client_->OnSendFrameToParentCompositorAck(ack); | 162 client_->OnSendFrameToParentCompositorAck(ack); |
| 146 } | 163 } |
| 147 | 164 |
| 148 bool CompositorOutputSurface::Send(IPC::Message* message) { | 165 bool CompositorOutputSurface::Send(IPC::Message* message) { |
| 149 return ChildThread::current()->sync_message_filter()->Send(message); | 166 return ChildThread::current()->sync_message_filter()->Send(message); |
| 150 } | 167 } |
| 151 | 168 |
| 152 namespace { | 169 namespace { |
| 153 #if defined(OS_ANDROID) | 170 #if defined(OS_ANDROID) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 // If this is the last surface to stop preferring smoothness, | 202 // If this is the last surface to stop preferring smoothness, |
| 186 // Reset the main thread's priority to the default. | 203 // Reset the main thread's priority to the default. |
| 187 if (prefers_smoothness_ == true && | 204 if (prefers_smoothness_ == true && |
| 188 --g_prefer_smoothness_count == 0) { | 205 --g_prefer_smoothness_count == 0) { |
| 189 SetThreadsPriorityToDefault(main_thread_id_); | 206 SetThreadsPriorityToDefault(main_thread_id_); |
| 190 } | 207 } |
| 191 prefers_smoothness_ = prefers_smoothness; | 208 prefers_smoothness_ = prefers_smoothness; |
| 192 } | 209 } |
| 193 | 210 |
| 194 } // namespace content | 211 } // namespace content |
| OLD | NEW |