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

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

Issue 11833009: Provide a vsync notification to the renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 10 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
« no previous file with comments | « content/renderer/gpu/compositor_output_surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "cc/compositor_frame.h" 8 #include "cc/compositor_frame.h"
9 #include "cc/output_surface_client.h" 9 #include "cc/output_surface_client.h"
10 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
(...skipping 19 matching lines...) Expand all
30 } // namespace 30 } // namespace
31 31
32 namespace content { 32 namespace content {
33 33
34 //------------------------------------------------------------------------------ 34 //------------------------------------------------------------------------------
35 35
36 // static 36 // static
37 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( 37 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter(
38 base::TaskRunner* target_task_runner) 38 base::TaskRunner* target_task_runner)
39 { 39 {
40 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; 40 uint32 messages_to_filter[] = {
41 ViewMsg_UpdateVSyncParameters::ID, ViewMsg_DidVSync::ID
42 };
41 return new IPC::ForwardingMessageFilter( 43 return new IPC::ForwardingMessageFilter(
42 messages_to_filter, arraysize(messages_to_filter), 44 messages_to_filter, arraysize(messages_to_filter),
43 target_task_runner); 45 target_task_runner);
44 } 46 }
45 47
46 CompositorOutputSurface::CompositorOutputSurface( 48 CompositorOutputSurface::CompositorOutputSurface(
47 int32 routing_id, 49 int32 routing_id,
48 WebGraphicsContext3D* context3D, 50 WebGraphicsContext3D* context3D,
49 cc::SoftwareOutputDevice* software_device) 51 cc::SoftwareOutputDevice* software_device)
50 : output_surface_filter_( 52 : output_surface_filter_(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 DCHECK(CalledOnValidThread()); 111 DCHECK(CalledOnValidThread());
110 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); 112 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame));
111 } 113 }
112 114
113 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { 115 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) {
114 DCHECK(CalledOnValidThread()); 116 DCHECK(CalledOnValidThread());
115 if (!client_) 117 if (!client_)
116 return; 118 return;
117 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) 119 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message)
118 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); 120 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters);
121 IPC_MESSAGE_HANDLER(ViewMsg_DidVSync, DidVSync);
119 IPC_END_MESSAGE_MAP() 122 IPC_END_MESSAGE_MAP()
120 } 123 }
121 124
122 void CompositorOutputSurface::OnUpdateVSyncParameters( 125 void CompositorOutputSurface::OnUpdateVSyncParameters(
123 base::TimeTicks timebase, base::TimeDelta interval) { 126 base::TimeTicks timebase, base::TimeDelta interval) {
124 DCHECK(CalledOnValidThread()); 127 DCHECK(CalledOnValidThread());
125 DCHECK(client_); 128 DCHECK(client_);
126 client_->OnVSyncParametersChanged(timebase, interval); 129 client_->OnVSyncParametersChanged(timebase, interval);
127 } 130 }
128 131
132 void CompositorOutputSurface::EnableVSyncNotification(bool enable) {
133 DCHECK(CalledOnValidThread());
134 DCHECK(client_);
135 Send(new ViewHostMsg_EnableVSyncNotification(routing_id_, enable));
136 }
137
138 void CompositorOutputSurface::DidVSync(base::TimeTicks frame_time) {
139 DCHECK(CalledOnValidThread());
140 DCHECK(client_);
141 client_->DidVSync(frame_time);
142 }
143
129 bool CompositorOutputSurface::Send(IPC::Message* message) { 144 bool CompositorOutputSurface::Send(IPC::Message* message) {
130 return ChildThread::current()->sync_message_filter()->Send(message); 145 return ChildThread::current()->sync_message_filter()->Send(message);
131 } 146 }
132 147
133 namespace { 148 namespace {
134 #if defined(OS_ANDROID) 149 #if defined(OS_ANDROID)
135 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) 150 // TODO(epenner): Move thread priorities to base. (crbug.com/170549)
136 void SetThreadsPriorityToIdle(base::PlatformThreadId id) { 151 void SetThreadsPriorityToIdle(base::PlatformThreadId id) {
137 int nice_value = 10; // Idle priority. 152 int nice_value = 10; // Idle priority.
138 setpriority(PRIO_PROCESS, id, nice_value); 153 setpriority(PRIO_PROCESS, id, nice_value);
(...skipping 27 matching lines...) Expand all
166 // If this is the last surface to stop preferring smoothness, 181 // If this is the last surface to stop preferring smoothness,
167 // Reset the main thread's priority to the default. 182 // Reset the main thread's priority to the default.
168 if (prefers_smoothness_ == true && 183 if (prefers_smoothness_ == true &&
169 --g_prefer_smoothness_count == 0) { 184 --g_prefer_smoothness_count == 0) {
170 SetThreadsPriorityToDefault(main_thread_id_); 185 SetThreadsPriorityToDefault(main_thread_id_);
171 } 186 }
172 prefers_smoothness_ = prefers_smoothness; 187 prefers_smoothness_ = prefers_smoothness;
173 } 188 }
174 189
175 } // namespace content 190 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/compositor_output_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698