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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 | 221 |
221 DCHECK_NE(swap_state_, SWAP_POSTED); | 222 DCHECK_NE(swap_state_, SWAP_POSTED); |
222 swap_state_ = SWAP_NONE; | 223 swap_state_ = SWAP_NONE; |
223 | 224 |
224 waiting_on_compositing_end_ = true; | 225 waiting_on_compositing_end_ = true; |
225 last_started_frame_++; | 226 last_started_frame_++; |
226 if (!IsLocked()) { | 227 if (!IsLocked()) { |
227 // TODO(nduca): Temporary while compositor calls | 228 // TODO(nduca): Temporary while compositor calls |
228 // compositeImmediately() directly. | 229 // compositeImmediately() directly. |
229 base::TimeTicks now = gfx::FrameTime::Now(); | 230 base::TimeTicks now = gfx::FrameTime::Now(); |
230 Animate(now); | 231 cc::BeginFrameArgs args = cc::BeginFrameArgs::Create( |
232 now, base::TimeTicks(), cc::BeginFrameArgs::DefaultInterval()); | |
233 BeginMainFrame(args); | |
231 Layout(); | 234 Layout(); |
232 host_->Composite(now); | 235 host_->Composite(now); |
mithro-old
2014/08/11 07:33:34
Maybe
cc::BeginFrameArgs args = cc::BeginFrameAr
Sami
2014/08/11 17:51:27
Good idea, done.
| |
233 } | 236 } |
234 if (swap_state_ == SWAP_NONE) | 237 if (swap_state_ == SWAP_NONE) |
235 NotifyEnd(); | 238 NotifyEnd(); |
236 } | 239 } |
237 | 240 |
238 void Compositor::ScheduleFullRedraw() { | 241 void Compositor::ScheduleFullRedraw() { |
239 host_->SetNeedsRedraw(); | 242 host_->SetNeedsRedraw(); |
240 } | 243 } |
241 | 244 |
242 void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) { | 245 void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 | 299 |
297 void Compositor::RemoveAnimationObserver( | 300 void Compositor::RemoveAnimationObserver( |
298 CompositorAnimationObserver* observer) { | 301 CompositorAnimationObserver* observer) { |
299 animation_observer_list_.RemoveObserver(observer); | 302 animation_observer_list_.RemoveObserver(observer); |
300 } | 303 } |
301 | 304 |
302 bool Compositor::HasAnimationObserver(CompositorAnimationObserver* observer) { | 305 bool Compositor::HasAnimationObserver(CompositorAnimationObserver* observer) { |
303 return animation_observer_list_.HasObserver(observer); | 306 return animation_observer_list_.HasObserver(observer); |
304 } | 307 } |
305 | 308 |
306 void Compositor::Animate(base::TimeTicks frame_begin_time) { | 309 void Compositor::BeginMainFrame(const cc::BeginFrameArgs& args) { |
307 FOR_EACH_OBSERVER(CompositorAnimationObserver, | 310 FOR_EACH_OBSERVER(CompositorAnimationObserver, |
308 animation_observer_list_, | 311 animation_observer_list_, |
309 OnAnimationStep(frame_begin_time)); | 312 OnAnimationStep(args.frame_time)); |
310 if (animation_observer_list_.might_have_observers()) | 313 if (animation_observer_list_.might_have_observers()) |
311 host_->SetNeedsAnimate(); | 314 host_->SetNeedsAnimate(); |
312 } | 315 } |
313 | 316 |
314 void Compositor::Layout() { | 317 void Compositor::Layout() { |
315 // We're sending damage that will be addressed during this composite | 318 // We're sending damage that will be addressed during this composite |
316 // cycle, so we don't need to schedule another composite to address it. | 319 // cycle, so we don't need to schedule another composite to address it. |
317 disable_schedule_composite_ = true; | 320 disable_schedule_composite_ = true; |
318 if (root_layer_) | 321 if (root_layer_) |
319 root_layer_->SendDamagedRects(); | 322 root_layer_->SendDamagedRects(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 // CompositorObservers to be notified before starting another | 426 // CompositorObservers to be notified before starting another |
424 // draw cycle. | 427 // draw cycle. |
425 ScheduleDraw(); | 428 ScheduleDraw(); |
426 } | 429 } |
427 FOR_EACH_OBSERVER(CompositorObserver, | 430 FOR_EACH_OBSERVER(CompositorObserver, |
428 observer_list_, | 431 observer_list_, |
429 OnCompositingEnded(this)); | 432 OnCompositingEnded(this)); |
430 } | 433 } |
431 | 434 |
432 } // namespace ui | 435 } // namespace ui |
OLD | NEW |