Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: content/renderer/gpu/compositor_output_surface.cc

Issue 423773002: Unified BeginFrame scheduling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WIP in mac and android Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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) 43 #if !defined(OS_MACOSX)
44 ViewMsg_BeginFrame::ID 44 ViewMsg_BeginFrame::ID
45 #endif 45 #endif
46 }; 46 };
47 47
48 return new IPC::ForwardingMessageFilter( 48 return new IPC::ForwardingMessageFilter(
49 messages_to_filter, arraysize(messages_to_filter), 49 messages_to_filter, arraysize(messages_to_filter),
50 target_task_runner); 50 target_task_runner);
51 } 51 }
52 52
53 CompositorOutputSurface::CompositorOutputSurface( 53 CompositorOutputSurface::CompositorOutputSurface(
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { 201 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) {
202 DCHECK(CalledOnValidThread()); 202 DCHECK(CalledOnValidThread());
203 if (!HasClient()) 203 if (!HasClient())
204 return; 204 return;
205 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) 205 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message)
206 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, 206 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters,
207 OnUpdateVSyncParametersFromBrowser); 207 OnUpdateVSyncParametersFromBrowser);
208 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); 208 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck);
209 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources); 209 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources);
210 #if defined(OS_ANDROID) 210 #if !defined(OS_MACOSX)
211 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame); 211 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame);
212 #endif 212 #endif
213 IPC_END_MESSAGE_MAP() 213 IPC_END_MESSAGE_MAP()
214 } 214 }
215 215
216 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( 216 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser(
217 base::TimeTicks timebase, 217 base::TimeTicks timebase,
218 base::TimeDelta interval) { 218 base::TimeDelta interval) {
219 DCHECK(CalledOnValidThread()); 219 DCHECK(CalledOnValidThread());
220 CommitVSyncParameters(timebase, interval); 220 CommitVSyncParameters(timebase, interval);
221 } 221 }
222 222
223 #if defined(OS_ANDROID) 223 #if !defined(OS_MACOSX)
224 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) { 224 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) {
225 DCHECK(CalledOnValidThread()); 225 DCHECK(CalledOnValidThread());
226 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); 226 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable));
227 } 227 }
228 228
229 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) { 229 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) {
230 DCHECK(CalledOnValidThread()); 230 DCHECK(CalledOnValidThread());
231 client_->BeginFrame(args); 231 client_->BeginFrame(args);
232 } 232 }
233 #endif // defined(OS_ANDROID) 233 #endif
234 234
235 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, 235 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id,
236 const cc::CompositorFrameAck& ack) { 236 const cc::CompositorFrameAck& ack) {
237 // Ignore message if it's a stale one coming from a different output surface 237 // Ignore message if it's a stale one coming from a different output surface
238 // (e.g. after a lost context). 238 // (e.g. after a lost context).
239 if (output_surface_id != output_surface_id_) 239 if (output_surface_id != output_surface_id_)
240 return; 240 return;
241 ReclaimResources(&ack); 241 ReclaimResources(&ack);
242 client_->DidSwapBuffersComplete(); 242 client_->DidSwapBuffersComplete();
243 } 243 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 // If this is the last surface to stop preferring smoothness, 291 // If this is the last surface to stop preferring smoothness,
292 // Reset the main thread's priority to the default. 292 // Reset the main thread's priority to the default.
293 if (prefers_smoothness_ == true && 293 if (prefers_smoothness_ == true &&
294 --g_prefer_smoothness_count == 0) { 294 --g_prefer_smoothness_count == 0) {
295 SetThreadPriorityToDefault(main_thread_handle_); 295 SetThreadPriorityToDefault(main_thread_handle_);
296 } 296 }
297 prefers_smoothness_ = prefers_smoothness; 297 prefers_smoothness_ = prefers_smoothness;
298 } 298 }
299 299
300 } // namespace content 300 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698