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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <deque> | 10 #include <deque> |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "cc/surfaces/surface_manager.h" | 32 #include "cc/surfaces/surface_manager.h" |
33 #include "cc/trees/layer_tree_host_in_process.h" | 33 #include "cc/trees/layer_tree_host_in_process.h" |
34 #include "cc/trees/layer_tree_settings.h" | 34 #include "cc/trees/layer_tree_settings.h" |
35 #include "third_party/skia/include/core/SkBitmap.h" | 35 #include "third_party/skia/include/core/SkBitmap.h" |
36 #include "ui/compositor/compositor_observer.h" | 36 #include "ui/compositor/compositor_observer.h" |
37 #include "ui/compositor/compositor_switches.h" | 37 #include "ui/compositor/compositor_switches.h" |
38 #include "ui/compositor/compositor_vsync_manager.h" | 38 #include "ui/compositor/compositor_vsync_manager.h" |
39 #include "ui/compositor/dip_util.h" | 39 #include "ui/compositor/dip_util.h" |
40 #include "ui/compositor/layer.h" | 40 #include "ui/compositor/layer.h" |
41 #include "ui/compositor/layer_animator_collection.h" | 41 #include "ui/compositor/layer_animator_collection.h" |
| 42 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
42 #include "ui/gl/gl_switches.h" | 43 #include "ui/gl/gl_switches.h" |
43 | 44 |
44 namespace { | 45 namespace { |
45 | 46 |
46 const double kDefaultRefreshRate = 60.0; | 47 const double kDefaultRefreshRate = 60.0; |
47 const double kTestRefreshRate = 200.0; | 48 const double kTestRefreshRate = 200.0; |
48 | 49 |
49 // TODO(mfomitchev, fsamuel): Look at removing this when transition from | 50 // TODO(mfomitchev, fsamuel): Look at removing this when transition from |
50 // SurfaceSequence to SurfaceReference is fully complete. | 51 // SurfaceSequence to SurfaceReference is fully complete. |
51 // Used when ui::Compositor is created with null ContextFactoryPrivate. | 52 // Used when ui::Compositor is created with null ContextFactoryPrivate. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", | 212 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", |
212 base::TimeTicks::Now() - before_create); | 213 base::TimeTicks::Now() - before_create); |
213 | 214 |
214 animation_timeline_ = | 215 animation_timeline_ = |
215 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); | 216 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); |
216 animation_host_->AddAnimationTimeline(animation_timeline_.get()); | 217 animation_host_->AddAnimationTimeline(animation_timeline_.get()); |
217 | 218 |
218 host_->GetLayerTree()->SetRootLayer(root_web_layer_); | 219 host_->GetLayerTree()->SetRootLayer(root_web_layer_); |
219 host_->SetFrameSinkId(frame_sink_id_); | 220 host_->SetFrameSinkId(frame_sink_id_); |
220 host_->SetVisible(true); | 221 host_->SetVisible(true); |
| 222 |
| 223 if (command_line->HasSwitch(switches::kUISlowAnimations)) { |
| 224 slow_animations_ = base::MakeUnique<ScopedAnimationDurationScaleMode>( |
| 225 ScopedAnimationDurationScaleMode::SLOW_DURATION); |
| 226 } |
221 } | 227 } |
222 | 228 |
223 Compositor::~Compositor() { | 229 Compositor::~Compositor() { |
224 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 230 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
225 | 231 |
226 CancelCompositorLock(); | 232 CancelCompositorLock(); |
227 DCHECK(!compositor_lock_); | 233 DCHECK(!compositor_lock_); |
228 | 234 |
229 for (auto& observer : observer_list_) | 235 for (auto& observer : observer_list_) |
230 observer.OnCompositingShuttingDown(this); | 236 observer.OnCompositingShuttingDown(this); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 for (auto& observer : observer_list_) | 570 for (auto& observer : observer_list_) |
565 observer.OnCompositingLockStateChanged(this); | 571 observer.OnCompositingLockStateChanged(this); |
566 } | 572 } |
567 | 573 |
568 void Compositor::CancelCompositorLock() { | 574 void Compositor::CancelCompositorLock() { |
569 if (compositor_lock_) | 575 if (compositor_lock_) |
570 compositor_lock_->CancelLock(); | 576 compositor_lock_->CancelLock(); |
571 } | 577 } |
572 | 578 |
573 } // namespace ui | 579 } // namespace ui |
OLD | NEW |