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

Side by Side Diff: ui/compositor/compositor.cc

Issue 427103002: compositor: Add rAF-like functionality for the UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 | « ui/compositor/compositor.h ('k') | ui/compositor/compositor.gyp » ('j') | 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 "ui/compositor/compositor.h" 5 #include "ui/compositor/compositor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 282 }
283 283
284 void Compositor::RemoveObserver(CompositorObserver* observer) { 284 void Compositor::RemoveObserver(CompositorObserver* observer) {
285 observer_list_.RemoveObserver(observer); 285 observer_list_.RemoveObserver(observer);
286 } 286 }
287 287
288 bool Compositor::HasObserver(CompositorObserver* observer) { 288 bool Compositor::HasObserver(CompositorObserver* observer) {
289 return observer_list_.HasObserver(observer); 289 return observer_list_.HasObserver(observer);
290 } 290 }
291 291
292 void Compositor::AddAnimationObserver(CompositorAnimationObserver* observer) {
293 animation_observer_list_.AddObserver(observer);
294 host_->SetNeedsAnimate();
295 }
296
297 void Compositor::RemoveAnimationObserver(
298 CompositorAnimationObserver* observer) {
299 animation_observer_list_.RemoveObserver(observer);
300 }
301
302 bool Compositor::HasAnimationObserver(CompositorAnimationObserver* observer) {
303 return animation_observer_list_.HasObserver(observer);
304 }
305
292 void Compositor::Animate(base::TimeTicks frame_begin_time) { 306 void Compositor::Animate(base::TimeTicks frame_begin_time) {
293 layer_animator_collection_.Progress(frame_begin_time); 307 FOR_EACH_OBSERVER(CompositorAnimationObserver,
294 if (layer_animator_collection_.HasActiveAnimators()) 308 animation_observer_list_,
309 OnAnimationStep(frame_begin_time));
310 if (animation_observer_list_.might_have_observers())
295 host_->SetNeedsAnimate(); 311 host_->SetNeedsAnimate();
296 } 312 }
297 313
298 void Compositor::Layout() { 314 void Compositor::Layout() {
299 // We're sending damage that will be addressed during this composite 315 // We're sending damage that will be addressed during this composite
300 // cycle, so we don't need to schedule another composite to address it. 316 // cycle, so we don't need to schedule another composite to address it.
301 disable_schedule_composite_ = true; 317 disable_schedule_composite_ = true;
302 if (root_layer_) 318 if (root_layer_)
303 root_layer_->SendDamagedRects(); 319 root_layer_->SendDamagedRects();
304 disable_schedule_composite_ = false; 320 disable_schedule_composite_ = false;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 NotifyEnd(); 369 NotifyEnd();
354 swap_state_ = SWAP_COMPLETED; 370 swap_state_ = SWAP_COMPLETED;
355 } 371 }
356 } 372 }
357 373
358 FOR_EACH_OBSERVER(CompositorObserver, 374 FOR_EACH_OBSERVER(CompositorObserver,
359 observer_list_, 375 observer_list_,
360 OnCompositingAborted(this)); 376 OnCompositingAborted(this));
361 } 377 }
362 378
363 void Compositor::ScheduleAnimationForLayerCollection() {
364 host_->SetNeedsAnimate();
365 }
366
367 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { 379 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const {
368 return host_->debug_state(); 380 return host_->debug_state();
369 } 381 }
370 382
371 void Compositor::SetLayerTreeDebugState( 383 void Compositor::SetLayerTreeDebugState(
372 const cc::LayerTreeDebugState& debug_state) { 384 const cc::LayerTreeDebugState& debug_state) {
373 host_->SetDebugState(debug_state); 385 host_->SetDebugState(debug_state);
374 } 386 }
375 387
376 scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { 388 scoped_refptr<CompositorLock> Compositor::GetCompositorLock() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 // CompositorObservers to be notified before starting another 423 // CompositorObservers to be notified before starting another
412 // draw cycle. 424 // draw cycle.
413 ScheduleDraw(); 425 ScheduleDraw();
414 } 426 }
415 FOR_EACH_OBSERVER(CompositorObserver, 427 FOR_EACH_OBSERVER(CompositorObserver,
416 observer_list_, 428 observer_list_,
417 OnCompositingEnded(this)); 429 OnCompositingEnded(this));
418 } 430 }
419 431
420 } // namespace ui 432 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698