Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 } | 311 } |
| 311 | 312 |
| 312 void Compositor::RemoveObserver(CompositorObserver* observer) { | 313 void Compositor::RemoveObserver(CompositorObserver* observer) { |
| 313 observer_list_.RemoveObserver(observer); | 314 observer_list_.RemoveObserver(observer); |
| 314 } | 315 } |
| 315 | 316 |
| 316 bool Compositor::HasObserver(CompositorObserver* observer) { | 317 bool Compositor::HasObserver(CompositorObserver* observer) { |
| 317 return observer_list_.HasObserver(observer); | 318 return observer_list_.HasObserver(observer); |
| 318 } | 319 } |
| 319 | 320 |
| 321 void Compositor::Animate(base::TimeTicks frame_begin_time) { | |
| 322 LayerAnimatorCollection::GetInstance()->Progress(frame_begin_time); | |
| 323 } | |
| 324 | |
| 320 void Compositor::Layout() { | 325 void Compositor::Layout() { |
| 321 // We're sending damage that will be addressed during this composite | 326 // 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. | 327 // cycle, so we don't need to schedule another composite to address it. |
| 323 disable_schedule_composite_ = true; | 328 disable_schedule_composite_ = true; |
| 324 if (root_layer_) | 329 if (root_layer_) |
| 325 root_layer_->SendDamagedRects(); | 330 root_layer_->SendDamagedRects(); |
| 326 disable_schedule_composite_ = false; | 331 disable_schedule_composite_ = false; |
| 327 } | 332 } |
| 328 | 333 |
| 329 scoped_ptr<cc::OutputSurface> Compositor::CreateOutputSurface(bool fallback) { | 334 scoped_ptr<cc::OutputSurface> Compositor::CreateOutputSurface(bool fallback) { |
| 330 return context_factory_->CreateOutputSurface(this, fallback); | 335 return context_factory_->CreateOutputSurface(this, fallback); |
| 331 } | 336 } |
| 332 | 337 |
| 333 void Compositor::DidCommit() { | 338 void Compositor::DidCommit() { |
| 334 DCHECK(!IsLocked()); | 339 DCHECK(!IsLocked()); |
| 335 FOR_EACH_OBSERVER(CompositorObserver, | 340 FOR_EACH_OBSERVER(CompositorObserver, |
| 336 observer_list_, | 341 observer_list_, |
| 337 OnCompositingDidCommit(this)); | 342 OnCompositingDidCommit(this)); |
| 343 if (LayerAnimatorCollection::GetInstance()->HasActiveAnimators()) | |
| 344 host_->SetNeedsAnimate(); | |
|
ajuma
2014/05/23 17:10:00
This should be moved to the end of ::Animate above
sadrul
2014/05/23 18:02:42
Done.
| |
| 338 } | 345 } |
| 339 | 346 |
| 340 void Compositor::DidCommitAndDrawFrame() { | 347 void Compositor::DidCommitAndDrawFrame() { |
| 341 base::TimeTicks start_time = gfx::FrameTime::Now(); | 348 base::TimeTicks start_time = gfx::FrameTime::Now(); |
| 342 FOR_EACH_OBSERVER(CompositorObserver, | 349 FOR_EACH_OBSERVER(CompositorObserver, |
| 343 observer_list_, | 350 observer_list_, |
| 344 OnCompositingStarted(this, start_time)); | 351 OnCompositingStarted(this, start_time)); |
| 345 } | 352 } |
| 346 | 353 |
| 347 void Compositor::DidCompleteSwapBuffers() { | 354 void Compositor::DidCompleteSwapBuffers() { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 // CompositorObservers to be notified before starting another | 436 // CompositorObservers to be notified before starting another |
| 430 // draw cycle. | 437 // draw cycle. |
| 431 ScheduleDraw(); | 438 ScheduleDraw(); |
| 432 } | 439 } |
| 433 FOR_EACH_OBSERVER(CompositorObserver, | 440 FOR_EACH_OBSERVER(CompositorObserver, |
| 434 observer_list_, | 441 observer_list_, |
| 435 OnCompositingEnded(this)); | 442 OnCompositingEnded(this)); |
| 436 } | 443 } |
| 437 | 444 |
| 438 } // namespace ui | 445 } // namespace ui |
| OLD | NEW |