| 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/begin_frame_args.h" |
| 21 #include "cc/output/context_provider.h" | 22 #include "cc/output/context_provider.h" |
| 22 #include "cc/trees/layer_tree_host.h" | 23 #include "cc/trees/layer_tree_host.h" |
| 23 #include "third_party/skia/include/core/SkBitmap.h" | 24 #include "third_party/skia/include/core/SkBitmap.h" |
| 24 #include "ui/compositor/compositor_observer.h" | 25 #include "ui/compositor/compositor_observer.h" |
| 25 #include "ui/compositor/compositor_switches.h" | 26 #include "ui/compositor/compositor_switches.h" |
| 26 #include "ui/compositor/compositor_vsync_manager.h" | 27 #include "ui/compositor/compositor_vsync_manager.h" |
| 27 #include "ui/compositor/dip_util.h" | 28 #include "ui/compositor/dip_util.h" |
| 28 #include "ui/compositor/layer.h" | 29 #include "ui/compositor/layer.h" |
| 29 #include "ui/compositor/layer_animator_collection.h" | 30 #include "ui/compositor/layer_animator_collection.h" |
| 30 #include "ui/gfx/frame_time.h" | 31 #include "ui/gfx/frame_time.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 TRACE_EVENT_ASYNC_BEGIN0("ui", "Compositor::Draw", last_started_frame_ + 1); | 218 TRACE_EVENT_ASYNC_BEGIN0("ui", "Compositor::Draw", last_started_frame_ + 1); |
| 218 | 219 |
| 219 DCHECK_NE(swap_state_, SWAP_POSTED); | 220 DCHECK_NE(swap_state_, SWAP_POSTED); |
| 220 swap_state_ = SWAP_NONE; | 221 swap_state_ = SWAP_NONE; |
| 221 | 222 |
| 222 waiting_on_compositing_end_ = true; | 223 waiting_on_compositing_end_ = true; |
| 223 last_started_frame_++; | 224 last_started_frame_++; |
| 224 if (!IsLocked()) { | 225 if (!IsLocked()) { |
| 225 // TODO(nduca): Temporary while compositor calls | 226 // TODO(nduca): Temporary while compositor calls |
| 226 // compositeImmediately() directly. | 227 // compositeImmediately() directly. |
| 227 base::TimeTicks now = gfx::FrameTime::Now(); | 228 cc::BeginFrameArgs args = |
| 228 Animate(now); | 229 cc::BeginFrameArgs::Create(gfx::FrameTime::Now(), |
| 230 base::TimeTicks(), |
| 231 cc::BeginFrameArgs::DefaultInterval()); |
| 232 BeginMainFrame(args); |
| 229 Layout(); | 233 Layout(); |
| 230 host_->Composite(now); | 234 host_->Composite(args.frame_time); |
| 231 } | 235 } |
| 232 if (swap_state_ == SWAP_NONE) | 236 if (swap_state_ == SWAP_NONE) |
| 233 NotifyEnd(); | 237 NotifyEnd(); |
| 234 } | 238 } |
| 235 | 239 |
| 236 void Compositor::ScheduleFullRedraw() { | 240 void Compositor::ScheduleFullRedraw() { |
| 237 host_->SetNeedsRedraw(); | 241 host_->SetNeedsRedraw(); |
| 238 } | 242 } |
| 239 | 243 |
| 240 void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) { | 244 void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 313 |
| 310 void Compositor::RemoveAnimationObserver( | 314 void Compositor::RemoveAnimationObserver( |
| 311 CompositorAnimationObserver* observer) { | 315 CompositorAnimationObserver* observer) { |
| 312 animation_observer_list_.RemoveObserver(observer); | 316 animation_observer_list_.RemoveObserver(observer); |
| 313 } | 317 } |
| 314 | 318 |
| 315 bool Compositor::HasAnimationObserver(CompositorAnimationObserver* observer) { | 319 bool Compositor::HasAnimationObserver(CompositorAnimationObserver* observer) { |
| 316 return animation_observer_list_.HasObserver(observer); | 320 return animation_observer_list_.HasObserver(observer); |
| 317 } | 321 } |
| 318 | 322 |
| 319 void Compositor::Animate(base::TimeTicks frame_begin_time) { | 323 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { |
| 320 FOR_EACH_OBSERVER(CompositorAnimationObserver, | 324 FOR_EACH_OBSERVER(CompositorAnimationObserver, |
| 321 animation_observer_list_, | 325 animation_observer_list_, |
| 322 OnAnimationStep(frame_begin_time)); | 326 OnAnimationStep(args.frame_time)); |
| 323 if (animation_observer_list_.might_have_observers()) | 327 if (animation_observer_list_.might_have_observers()) |
| 324 host_->SetNeedsAnimate(); | 328 host_->SetNeedsAnimate(); |
| 325 } | 329 } |
| 326 | 330 |
| 327 void Compositor::Layout() { | 331 void Compositor::Layout() { |
| 328 // We're sending damage that will be addressed during this composite | 332 // We're sending damage that will be addressed during this composite |
| 329 // cycle, so we don't need to schedule another composite to address it. | 333 // cycle, so we don't need to schedule another composite to address it. |
| 330 disable_schedule_composite_ = true; | 334 disable_schedule_composite_ = true; |
| 331 if (root_layer_) | 335 if (root_layer_) |
| 332 root_layer_->SendDamagedRects(); | 336 root_layer_->SendDamagedRects(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // Call ScheduleDraw() instead of Draw() in order to allow other | 439 // Call ScheduleDraw() instead of Draw() in order to allow other |
| 436 // CompositorObservers to be notified before starting another | 440 // CompositorObservers to be notified before starting another |
| 437 // draw cycle. | 441 // draw cycle. |
| 438 ScheduleDraw(); | 442 ScheduleDraw(); |
| 439 } | 443 } |
| 440 FOR_EACH_OBSERVER( | 444 FOR_EACH_OBSERVER( |
| 441 CompositorObserver, observer_list_, OnCompositingEnded(this)); | 445 CompositorObserver, observer_list_, OnCompositingEnded(this)); |
| 442 } | 446 } |
| 443 | 447 |
| 444 } // namespace ui | 448 } // namespace ui |
| OLD | NEW |