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

Side by Side Diff: content/browser/android/in_process/synchronous_compositor_output_surface.cc

Issue 218633010: cc: Handle retroactive BeginFrames in the Scheduler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@compositorVsyncDisable
Patch Set: rebase Created 6 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/android/in_process/synchronous_compositor_output_surfa ce.h" 5 #include "content/browser/android/in_process/synchronous_compositor_output_surfa ce.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "cc/output/begin_frame_args.h" 9 #include "cc/output/begin_frame_args.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 delegate->DidBindOutputSurface(this); 116 delegate->DidBindOutputSurface(this);
117 117
118 return true; 118 return true;
119 } 119 }
120 120
121 void SynchronousCompositorOutputSurface::Reshape( 121 void SynchronousCompositorOutputSurface::Reshape(
122 const gfx::Size& size, float scale_factor) { 122 const gfx::Size& size, float scale_factor) {
123 // Intentional no-op: surface size is controlled by the embedder. 123 // Intentional no-op: surface size is controlled by the embedder.
124 } 124 }
125 125
126 void SynchronousCompositorOutputSurface::SetNeedsBeginImplFrame( 126 void SynchronousCompositorOutputSurface::SetNeedsBeginFrame(bool enable) {
127 bool enable) {
128 DCHECK(CalledOnValidThread()); 127 DCHECK(CalledOnValidThread());
129 needs_begin_impl_frame_ = enable; 128 needs_begin_frame_ = enable;
130 client_ready_for_begin_impl_frame_ = true;
131 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); 129 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate();
132 if (delegate && !invoking_composite_) 130 if (delegate && !invoking_composite_)
133 delegate->SetContinuousInvalidate(needs_begin_impl_frame_); 131 delegate->SetContinuousInvalidate(needs_begin_frame_);
134 } 132 }
135 133
136 void SynchronousCompositorOutputSurface::SwapBuffers( 134 void SynchronousCompositorOutputSurface::SwapBuffers(
137 cc::CompositorFrame* frame) { 135 cc::CompositorFrame* frame) {
138 DCHECK(CalledOnValidThread()); 136 DCHECK(CalledOnValidThread());
139 if (!ForcedDrawToSoftwareDevice()) { 137 if (!ForcedDrawToSoftwareDevice()) {
140 DCHECK(context_provider_); 138 DCHECK(context_provider_);
141 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); 139 context_provider_->ContextGL()->ShallowFlushCHROMIUM();
142 } 140 }
143 UpdateFrameMetaData(frame->metadata); 141 UpdateFrameMetaData(frame->metadata);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 bool valid_for_tile_management) { 230 bool valid_for_tile_management) {
233 DCHECK(!invoking_composite_); 231 DCHECK(!invoking_composite_);
234 base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true); 232 base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true);
235 did_swap_buffer_ = false; 233 did_swap_buffer_ = false;
236 234
237 gfx::Transform adjusted_transform = transform; 235 gfx::Transform adjusted_transform = transform;
238 AdjustTransform(&adjusted_transform, viewport); 236 AdjustTransform(&adjusted_transform, viewport);
239 SetExternalDrawConstraints( 237 SetExternalDrawConstraints(
240 adjusted_transform, viewport, clip, valid_for_tile_management); 238 adjusted_transform, viewport, clip, valid_for_tile_management);
241 SetNeedsRedrawRect(gfx::Rect(viewport.size())); 239 SetNeedsRedrawRect(gfx::Rect(viewport.size()));
242 BeginImplFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor()); 240 BeginFrame(cc::BeginFrameArgs::CreateForSynchronousCompositor());
243 241
244 // After software draws (which might move the viewport arbitrarily), restore 242 // After software draws (which might move the viewport arbitrarily), restore
245 // the previous hardware viewport to allow CC's tile manager to prioritize 243 // the previous hardware viewport to allow CC's tile manager to prioritize
246 // properly. 244 // properly.
247 if (valid_for_tile_management) { 245 if (valid_for_tile_management) {
248 cached_hw_transform_ = adjusted_transform; 246 cached_hw_transform_ = adjusted_transform;
249 cached_hw_viewport_ = viewport; 247 cached_hw_viewport_ = viewport;
250 cached_hw_clip_ = clip; 248 cached_hw_clip_ = clip;
251 } else { 249 } else {
252 SetExternalDrawConstraints( 250 SetExternalDrawConstraints(
253 cached_hw_transform_, cached_hw_viewport_, cached_hw_clip_, true); 251 cached_hw_transform_, cached_hw_viewport_, cached_hw_clip_, true);
254 } 252 }
255 253
256 if (did_swap_buffer_) 254 if (did_swap_buffer_)
257 OnSwapBuffersComplete(); 255 OnSwapBuffersComplete();
258 256
259 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate(); 257 SynchronousCompositorOutputSurfaceDelegate* delegate = GetDelegate();
260 if (delegate) 258 if (delegate)
261 delegate->SetContinuousInvalidate(needs_begin_impl_frame_); 259 delegate->SetContinuousInvalidate(needs_begin_frame_);
262 } 260 }
263 261
264 void 262 void SynchronousCompositorOutputSurface::PostCheckForRetroactiveBeginFrame() {
265 SynchronousCompositorOutputSurface::PostCheckForRetroactiveBeginImplFrame() { 263 // Synchronous compositor cannot perform retroactive BeginFrames, so
266 // Synchronous compositor cannot perform retroactive BeginImplFrames, so
267 // intentionally no-op here. 264 // intentionally no-op here.
268 } 265 }
269 266
270 void SynchronousCompositorOutputSurface::SetMemoryPolicy( 267 void SynchronousCompositorOutputSurface::SetMemoryPolicy(
271 const SynchronousCompositorMemoryPolicy& policy) { 268 const SynchronousCompositorMemoryPolicy& policy) {
272 DCHECK(CalledOnValidThread()); 269 DCHECK(CalledOnValidThread());
273 memory_policy_.bytes_limit_when_visible = policy.bytes_limit; 270 memory_policy_.bytes_limit_when_visible = policy.bytes_limit;
274 memory_policy_.num_resources_limit = policy.num_resources_limit; 271 memory_policy_.num_resources_limit = policy.num_resources_limit;
275 272
276 if (output_surface_client_) 273 if (output_surface_client_)
277 output_surface_client_->SetMemoryPolicy(memory_policy_); 274 output_surface_client_->SetMemoryPolicy(memory_policy_);
278 } 275 }
279 276
280 // Not using base::NonThreadSafe as we want to enforce a more exacting threading 277 // Not using base::NonThreadSafe as we want to enforce a more exacting threading
281 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI 278 // requirement: SynchronousCompositorOutputSurface() must only be used on the UI
282 // thread. 279 // thread.
283 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 280 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
284 return BrowserThread::CurrentlyOn(BrowserThread::UI); 281 return BrowserThread::CurrentlyOn(BrowserThread::UI);
285 } 282 }
286 283
287 SynchronousCompositorOutputSurfaceDelegate* 284 SynchronousCompositorOutputSurfaceDelegate*
288 SynchronousCompositorOutputSurface::GetDelegate() { 285 SynchronousCompositorOutputSurface::GetDelegate() {
289 return SynchronousCompositorImpl::FromRoutingID(routing_id_); 286 return SynchronousCompositorImpl::FromRoutingID(routing_id_);
290 } 287 }
291 288
292 } // namespace content 289 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698