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

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

Issue 291843012: compositor: Tick the UI animations from cc, instead of from timer callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/sys_info.h" 16 #include "base/sys_info.h"
17 #include "cc/base/latency_info_swap_promise.h" 17 #include "cc/base/latency_info_swap_promise.h"
18 #include "cc/base/switches.h" 18 #include "cc/base/switches.h"
19 #include "cc/input/input_handler.h" 19 #include "cc/input/input_handler.h"
20 #include "cc/layers/layer.h" 20 #include "cc/layers/layer.h"
21 #include "cc/output/context_provider.h" 21 #include "cc/output/context_provider.h"
22 #include "cc/trees/layer_tree_host.h" 22 #include "cc/trees/layer_tree_host.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 23 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "ui/compositor/compositor_observer.h" 24 #include "ui/compositor/compositor_observer.h"
25 #include "ui/compositor/compositor_switches.h" 25 #include "ui/compositor/compositor_switches.h"
26 #include "ui/compositor/compositor_vsync_manager.h" 26 #include "ui/compositor/compositor_vsync_manager.h"
27 #include "ui/compositor/dip_util.h" 27 #include "ui/compositor/dip_util.h"
28 #include "ui/compositor/layer.h" 28 #include "ui/compositor/layer.h"
29 #include "ui/compositor/layer_animator_collection.h"
29 #include "ui/gfx/frame_time.h" 30 #include "ui/gfx/frame_time.h"
30 #include "ui/gl/gl_context.h" 31 #include "ui/gl/gl_context.h"
31 #include "ui/gl/gl_switches.h" 32 #include "ui/gl/gl_switches.h"
32 33
33 namespace { 34 namespace {
34 35
35 const double kDefaultRefreshRate = 60.0; 36 const double kDefaultRefreshRate = 60.0;
36 const double kTestRefreshRate = 200.0; 37 const double kTestRefreshRate = 200.0;
37 38
38 ui::ContextFactory* g_context_factory = NULL; 39 ui::ContextFactory* g_context_factory = NULL;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 return; 251 return;
251 252
252 DCHECK_NE(swap_state_, SWAP_POSTED); 253 DCHECK_NE(swap_state_, SWAP_POSTED);
253 swap_state_ = SWAP_NONE; 254 swap_state_ = SWAP_NONE;
254 255
255 last_started_frame_++; 256 last_started_frame_++;
256 if (!IsLocked()) { 257 if (!IsLocked()) {
257 // TODO(nduca): Temporary while compositor calls 258 // TODO(nduca): Temporary while compositor calls
258 // compositeImmediately() directly. 259 // compositeImmediately() directly.
259 Layout(); 260 Layout();
260 host_->Composite(gfx::FrameTime::Now()); 261 base::TimeTicks now = gfx::FrameTime::Now();
262 Animate(now);
piman 2014/05/23 18:20:06 I'm not sure I understand what in the animation co
sadrul 2014/05/23 18:32:28 I am not sure if there is anything to ensure this
ajuma 2014/05/23 19:15:14 There doesn't seem to be anything to ensure this.
263 host_->Composite(now);
261 } 264 }
262 if (swap_state_ == SWAP_NONE) 265 if (swap_state_ == SWAP_NONE)
263 NotifyEnd(); 266 NotifyEnd();
264 } 267 }
265 268
266 void Compositor::ScheduleFullRedraw() { 269 void Compositor::ScheduleFullRedraw() {
267 host_->SetNeedsRedraw(); 270 host_->SetNeedsRedraw();
268 } 271 }
269 272
270 void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) { 273 void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 313 }
311 314
312 void Compositor::RemoveObserver(CompositorObserver* observer) { 315 void Compositor::RemoveObserver(CompositorObserver* observer) {
313 observer_list_.RemoveObserver(observer); 316 observer_list_.RemoveObserver(observer);
314 } 317 }
315 318
316 bool Compositor::HasObserver(CompositorObserver* observer) { 319 bool Compositor::HasObserver(CompositorObserver* observer) {
317 return observer_list_.HasObserver(observer); 320 return observer_list_.HasObserver(observer);
318 } 321 }
319 322
323 void Compositor::Animate(base::TimeTicks frame_begin_time) {
324 LayerAnimatorCollection::GetInstance()->Progress(frame_begin_time);
piman 2014/05/23 18:20:06 We have one compositor per root window, which are
sadrul 2014/05/23 18:32:28 Ah, good point. Right now, the LayerAnimator does
ajuma 2014/05/23 19:15:14 Maybe LayerAnimationDelegate::GetCollection(), whe
325 if (LayerAnimatorCollection::GetInstance()->HasActiveAnimators())
326 host_->SetNeedsAnimate();
327 }
328
320 void Compositor::Layout() { 329 void Compositor::Layout() {
321 // We're sending damage that will be addressed during this composite 330 // We're sending damage that will be addressed during this composite
322 // cycle, so we don't need to schedule another composite to address it. 331 // cycle, so we don't need to schedule another composite to address it.
323 disable_schedule_composite_ = true; 332 disable_schedule_composite_ = true;
324 if (root_layer_) 333 if (root_layer_)
325 root_layer_->SendDamagedRects(); 334 root_layer_->SendDamagedRects();
326 disable_schedule_composite_ = false; 335 disable_schedule_composite_ = false;
327 } 336 }
328 337
329 scoped_ptr<cc::OutputSurface> Compositor::CreateOutputSurface(bool fallback) { 338 scoped_ptr<cc::OutputSurface> Compositor::CreateOutputSurface(bool fallback) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 // CompositorObservers to be notified before starting another 438 // CompositorObservers to be notified before starting another
430 // draw cycle. 439 // draw cycle.
431 ScheduleDraw(); 440 ScheduleDraw();
432 } 441 }
433 FOR_EACH_OBSERVER(CompositorObserver, 442 FOR_EACH_OBSERVER(CompositorObserver,
434 observer_list_, 443 observer_list_,
435 OnCompositingEnded(this)); 444 OnCompositingEnded(this));
436 } 445 }
437 446
438 } // namespace ui 447 } // 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