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

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

Issue 15836005: cc: Emulate BeginFrame in OutputSurfaces that don't support it natively (Closed) Base URL: http://git.chromium.org/chromium/src.git@nofrc
Patch Set: Created 7 years, 6 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
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_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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 RenderThreadImpl::current()->compositor_output_surface_filter()), 57 RenderThreadImpl::current()->compositor_output_surface_filter()),
58 routing_id_(routing_id), 58 routing_id_(routing_id),
59 prefers_smoothness_(false), 59 prefers_smoothness_(false),
60 main_thread_handle_(base::PlatformThread::CurrentHandle()) { 60 main_thread_handle_(base::PlatformThread::CurrentHandle()) {
61 DCHECK(output_surface_filter_); 61 DCHECK(output_surface_filter_);
62 CommandLine* command_line = CommandLine::ForCurrentProcess(); 62 CommandLine* command_line = CommandLine::ForCurrentProcess();
63 capabilities_.has_parent_compositor = command_line->HasSwitch( 63 capabilities_.has_parent_compositor = command_line->HasSwitch(
64 switches::kEnableDelegatedRenderer); 64 switches::kEnableDelegatedRenderer);
65 DetachFromThread(); 65 DetachFromThread();
66 message_sender_ = RenderThreadImpl::current()->sync_message_filter(); 66 message_sender_ = RenderThreadImpl::current()->sync_message_filter();
67
67 DCHECK(message_sender_); 68 DCHECK(message_sender_);
68 } 69 }
69 70
70 CompositorOutputSurface::~CompositorOutputSurface() { 71 CompositorOutputSurface::~CompositorOutputSurface() {
71 DCHECK(CalledOnValidThread()); 72 DCHECK(CalledOnValidThread());
72 if (!client_) 73 if (!hasClient())
brianderson 2013/06/01 04:30:29 client_ is a private member of the base class, whi
73 return; 74 return;
74 UpdateSmoothnessTakesPriority(false); 75 UpdateSmoothnessTakesPriority(false);
75 if (output_surface_proxy_) 76 if (output_surface_proxy_)
76 output_surface_proxy_->ClearOutputSurface(); 77 output_surface_proxy_->ClearOutputSurface();
77 output_surface_filter_->RemoveRoute(routing_id_); 78 output_surface_filter_->RemoveRoute(routing_id_);
78 } 79 }
79 80
80 bool CompositorOutputSurface::BindToClient( 81 bool CompositorOutputSurface::BindToClient(
81 cc::OutputSurfaceClient* client) { 82 cc::OutputSurfaceClient* client) {
82 DCHECK(CalledOnValidThread()); 83 DCHECK(CalledOnValidThread());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 CommandBufferProxyImpl* command_buffer_proxy = 119 CommandBufferProxyImpl* command_buffer_proxy =
119 command_buffer->GetCommandBufferProxy(); 120 command_buffer->GetCommandBufferProxy();
120 DCHECK(command_buffer_proxy); 121 DCHECK(command_buffer_proxy);
121 context3d()->shallowFlushCHROMIUM(); 122 context3d()->shallowFlushCHROMIUM();
122 command_buffer_proxy->SetLatencyInfo(latency_info); 123 command_buffer_proxy->SetLatencyInfo(latency_info);
123 OutputSurface::PostSubBuffer(rect, latency_info); 124 OutputSurface::PostSubBuffer(rect, latency_info);
124 } 125 }
125 126
126 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { 127 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) {
127 DCHECK(CalledOnValidThread()); 128 DCHECK(CalledOnValidThread());
128 if (!client_) 129 if (!hasClient())
129 return; 130 return;
130 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) 131 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message)
131 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); 132 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters);
132 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); 133 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck);
133 #if defined(OS_ANDROID) 134 #if defined(OS_ANDROID)
134 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame); 135 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame);
135 #endif 136 #endif
136 IPC_END_MESSAGE_MAP() 137 IPC_END_MESSAGE_MAP()
137 } 138 }
138 139
139 void CompositorOutputSurface::OnUpdateVSyncParameters( 140 void CompositorOutputSurface::OnUpdateVSyncParameters(
140 base::TimeTicks timebase, base::TimeDelta interval) { 141 base::TimeTicks timebase, base::TimeDelta interval) {
141 DCHECK(CalledOnValidThread()); 142 DCHECK(CalledOnValidThread());
142 client_->OnVSyncParametersChanged(timebase, interval); 143 OnVSyncParametersChanged(timebase, interval);
143 } 144 }
144 145
145 #if defined(OS_ANDROID) 146 #if defined(OS_ANDROID)
146 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) { 147 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) {
147 DCHECK(CalledOnValidThread()); 148 DCHECK(CalledOnValidThread());
148 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); 149 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable));
149 } 150 }
150 151
151 void CompositorOutputSurface::OnBeginFrame(base::TimeTicks frame_time) { 152 void CompositorOutputSurface::OnBeginFrame(base::TimeTicks frame_time) {
152 DCHECK(CalledOnValidThread()); 153 DCHECK(CalledOnValidThread());
153 client_->BeginFrame(frame_time); 154 BeginFrame(frame_time);
154 } 155 }
155 #endif // defined(OS_ANDROID) 156 #endif // defined(OS_ANDROID)
156 157
157 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { 158 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) {
158 client_->OnSendFrameToParentCompositorAck(ack); 159 OnSendFrameToParentCompositorAck(ack);
159 } 160 }
160 161
161 bool CompositorOutputSurface::Send(IPC::Message* message) { 162 bool CompositorOutputSurface::Send(IPC::Message* message) {
162 return message_sender_->Send(message); 163 return message_sender_->Send(message);
163 } 164 }
164 165
165 namespace { 166 namespace {
166 #if defined(OS_ANDROID) 167 #if defined(OS_ANDROID)
167 void SetThreadPriorityToIdle(base::PlatformThreadHandle handle) { 168 void SetThreadPriorityToIdle(base::PlatformThreadHandle handle) {
168 base::PlatformThread::SetThreadPriority( 169 base::PlatformThread::SetThreadPriority(
(...skipping 28 matching lines...) Expand all
197 // If this is the last surface to stop preferring smoothness, 198 // If this is the last surface to stop preferring smoothness,
198 // Reset the main thread's priority to the default. 199 // Reset the main thread's priority to the default.
199 if (prefers_smoothness_ == true && 200 if (prefers_smoothness_ == true &&
200 --g_prefer_smoothness_count == 0) { 201 --g_prefer_smoothness_count == 0) {
201 SetThreadPriorityToDefault(main_thread_handle_); 202 SetThreadPriorityToDefault(main_thread_handle_);
202 } 203 }
203 prefers_smoothness_ = prefers_smoothness; 204 prefers_smoothness_ = prefers_smoothness;
204 } 205 }
205 206
206 } // namespace content 207 } // namespace content
OLDNEW
« cc/trees/thread_proxy.cc ('K') | « content/renderer/android/synchronous_compositor_output_surface.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698