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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 command_buffer_proxy->SetLatencyInfo(latency_info); | 124 command_buffer_proxy->SetLatencyInfo(latency_info); |
124 OutputSurface::PostSubBuffer(rect, latency_info); | 125 OutputSurface::PostSubBuffer(rect, latency_info); |
125 } | 126 } |
126 | 127 |
127 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 128 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
128 DCHECK(CalledOnValidThread()); | 129 DCHECK(CalledOnValidThread()); |
129 if (!client_) | 130 if (!client_) |
130 return; | 131 return; |
131 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 132 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
132 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); | 133 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); |
134 IPC_MESSAGE_HANDLER(ViewMsg_DidVSync, DidVSync); | |
jam
2013/04/16 16:40:34
nit: follow conventions of message handlers always
Sami
2013/04/16 17:13:05
Done.
| |
133 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); | 135 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); |
134 IPC_END_MESSAGE_MAP() | 136 IPC_END_MESSAGE_MAP() |
135 } | 137 } |
136 | 138 |
137 void CompositorOutputSurface::OnUpdateVSyncParameters( | 139 void CompositorOutputSurface::OnUpdateVSyncParameters( |
138 base::TimeTicks timebase, base::TimeDelta interval) { | 140 base::TimeTicks timebase, base::TimeDelta interval) { |
139 DCHECK(CalledOnValidThread()); | 141 DCHECK(CalledOnValidThread()); |
140 DCHECK(client_); | |
141 client_->OnVSyncParametersChanged(timebase, interval); | 142 client_->OnVSyncParametersChanged(timebase, interval); |
142 } | 143 } |
143 | 144 |
145 void CompositorOutputSurface::EnableVSyncNotification(bool enable) { | |
jam
2013/04/16 16:40:34
can we ifdef these methods for android to make it
Sami
2013/04/16 17:13:05
Sure, I've added ifdefs here too.
| |
146 DCHECK(CalledOnValidThread()); | |
147 Send(new ViewHostMsg_SetVSyncNotificationEnabled(routing_id_, enable)); | |
148 } | |
149 | |
150 void CompositorOutputSurface::DidVSync(base::TimeTicks frame_time) { | |
151 DCHECK(CalledOnValidThread()); | |
152 client_->DidVSync(frame_time); | |
153 } | |
154 | |
144 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { | 155 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { |
145 client_->OnSendFrameToParentCompositorAck(ack); | 156 client_->OnSendFrameToParentCompositorAck(ack); |
146 } | 157 } |
147 | 158 |
148 bool CompositorOutputSurface::Send(IPC::Message* message) { | 159 bool CompositorOutputSurface::Send(IPC::Message* message) { |
149 return ChildThread::current()->sync_message_filter()->Send(message); | 160 return ChildThread::current()->sync_message_filter()->Send(message); |
150 } | 161 } |
151 | 162 |
152 namespace { | 163 namespace { |
153 #if defined(OS_ANDROID) | 164 #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, | 196 // If this is the last surface to stop preferring smoothness, |
186 // Reset the main thread's priority to the default. | 197 // Reset the main thread's priority to the default. |
187 if (prefers_smoothness_ == true && | 198 if (prefers_smoothness_ == true && |
188 --g_prefer_smoothness_count == 0) { | 199 --g_prefer_smoothness_count == 0) { |
189 SetThreadsPriorityToDefault(main_thread_id_); | 200 SetThreadsPriorityToDefault(main_thread_id_); |
190 } | 201 } |
191 prefers_smoothness_ = prefers_smoothness; | 202 prefers_smoothness_ = prefers_smoothness; |
192 } | 203 } |
193 | 204 |
194 } // namespace content | 205 } // namespace content |
OLD | NEW |