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" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 posted_swaps_(new PostedSwapQueue()), | 187 posted_swaps_(new PostedSwapQueue()), |
| 188 device_scale_factor_(0.0f), | 188 device_scale_factor_(0.0f), |
| 189 last_started_frame_(0), | 189 last_started_frame_(0), |
| 190 last_ended_frame_(0), | 190 last_ended_frame_(0), |
| 191 next_draw_is_resize_(false), | 191 next_draw_is_resize_(false), |
| 192 disable_schedule_composite_(false), | 192 disable_schedule_composite_(false), |
| 193 compositor_lock_(NULL), | 193 compositor_lock_(NULL), |
| 194 defer_draw_scheduling_(false), | 194 defer_draw_scheduling_(false), |
| 195 waiting_on_compositing_end_(false), | 195 waiting_on_compositing_end_(false), |
| 196 draw_on_compositing_end_(false), | 196 draw_on_compositing_end_(false), |
| 197 schedule_draw_factory_(this) { | 197 schedule_draw_factory_(this) { |
|
oshima
2014/01/29 19:00:35
initialize authoritative_vsync_interval_
sheu
2014/01/29 22:43:36
The default constructor initializes to a 0 interna
oshima
2014/01/29 22:45:32
Ah, it's TimeDelta. nvm.
| |
| 198 DCHECK(g_compositor_initialized) | 198 DCHECK(g_compositor_initialized) |
| 199 << "Compositor::Initialize must be called before creating a Compositor."; | 199 << "Compositor::Initialize must be called before creating a Compositor."; |
| 200 | 200 |
| 201 root_web_layer_ = cc::Layer::Create(); | 201 root_web_layer_ = cc::Layer::Create(); |
| 202 root_web_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); | 202 root_web_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); |
| 203 | 203 |
| 204 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 204 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 205 | 205 |
| 206 cc::LayerTreeSettings settings; | 206 cc::LayerTreeSettings settings; |
| 207 settings.refresh_rate = | 207 settings.refresh_rate = |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 | 439 |
| 440 void Compositor::RemoveObserver(CompositorObserver* observer) { | 440 void Compositor::RemoveObserver(CompositorObserver* observer) { |
| 441 observer_list_.RemoveObserver(observer); | 441 observer_list_.RemoveObserver(observer); |
| 442 } | 442 } |
| 443 | 443 |
| 444 bool Compositor::HasObserver(CompositorObserver* observer) { | 444 bool Compositor::HasObserver(CompositorObserver* observer) { |
| 445 return observer_list_.HasObserver(observer); | 445 return observer_list_.HasObserver(observer); |
| 446 } | 446 } |
| 447 | 447 |
| 448 void Compositor::OnUpdateVSyncParameters(base::TimeTicks timebase, | 448 void Compositor::OnUpdateVSyncParameters(base::TimeTicks timebase, |
| 449 base::TimeDelta interval) { | 449 base::TimeDelta interval, |
| 450 FOR_EACH_OBSERVER(CompositorObserver, | 450 bool interval_is_authoritative) { |
| 451 observer_list_, | 451 if (interval_is_authoritative) { |
| 452 OnUpdateVSyncParameters(this, timebase, interval)); | 452 authoritative_vsync_interval_ = interval; |
| 453 } else { | |
| 454 if (authoritative_vsync_interval_ != base::TimeDelta()) | |
| 455 interval = authoritative_vsync_interval_; | |
| 456 } | |
| 457 | |
| 458 if (!timebase.is_null()) { | |
| 459 FOR_EACH_OBSERVER(CompositorObserver, | |
| 460 observer_list_, | |
| 461 OnUpdateVSyncParameters(this, timebase, interval)); | |
| 462 } | |
| 453 } | 463 } |
| 454 | 464 |
| 455 void Compositor::Layout() { | 465 void Compositor::Layout() { |
| 456 // We're sending damage that will be addressed during this composite | 466 // We're sending damage that will be addressed during this composite |
| 457 // cycle, so we don't need to schedule another composite to address it. | 467 // cycle, so we don't need to schedule another composite to address it. |
| 458 disable_schedule_composite_ = true; | 468 disable_schedule_composite_ = true; |
| 459 if (root_layer_) | 469 if (root_layer_) |
| 460 root_layer_->SendDamagedRects(); | 470 root_layer_->SendDamagedRects(); |
| 461 disable_schedule_composite_ = false; | 471 disable_schedule_composite_ = false; |
| 462 } | 472 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 573 // CompositorObservers to be notified before starting another | 583 // CompositorObservers to be notified before starting another |
| 574 // draw cycle. | 584 // draw cycle. |
| 575 ScheduleDraw(); | 585 ScheduleDraw(); |
| 576 } | 586 } |
| 577 FOR_EACH_OBSERVER(CompositorObserver, | 587 FOR_EACH_OBSERVER(CompositorObserver, |
| 578 observer_list_, | 588 observer_list_, |
| 579 OnCompositingEnded(this)); | 589 OnCompositingEnded(this)); |
| 580 } | 590 } |
| 581 | 591 |
| 582 } // namespace ui | 592 } // namespace ui |
| OLD | NEW |