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 13 matching lines...) Expand all Loading... |
24 #include "cc/base/switches.h" | 24 #include "cc/base/switches.h" |
25 #include "cc/input/input_handler.h" | 25 #include "cc/input/input_handler.h" |
26 #include "cc/layers/layer.h" | 26 #include "cc/layers/layer.h" |
27 #include "cc/output/begin_frame_args.h" | 27 #include "cc/output/begin_frame_args.h" |
28 #include "cc/output/context_provider.h" | 28 #include "cc/output/context_provider.h" |
29 #include "cc/output/latency_info_swap_promise.h" | 29 #include "cc/output/latency_info_swap_promise.h" |
30 #include "cc/scheduler/begin_frame_source.h" | 30 #include "cc/scheduler/begin_frame_source.h" |
31 #include "cc/surfaces/surface_id_allocator.h" | 31 #include "cc/surfaces/surface_id_allocator.h" |
32 #include "cc/surfaces/surface_manager.h" | 32 #include "cc/surfaces/surface_manager.h" |
33 #include "cc/trees/layer_tree_host.h" | 33 #include "cc/trees/layer_tree_host.h" |
| 34 #include "cc/trees/swap_promise_manager.h" |
34 #include "third_party/skia/include/core/SkBitmap.h" | 35 #include "third_party/skia/include/core/SkBitmap.h" |
35 #include "ui/compositor/compositor_observer.h" | 36 #include "ui/compositor/compositor_observer.h" |
36 #include "ui/compositor/compositor_switches.h" | 37 #include "ui/compositor/compositor_switches.h" |
37 #include "ui/compositor/compositor_vsync_manager.h" | 38 #include "ui/compositor/compositor_vsync_manager.h" |
38 #include "ui/compositor/dip_util.h" | 39 #include "ui/compositor/dip_util.h" |
39 #include "ui/compositor/layer.h" | 40 #include "ui/compositor/layer.h" |
40 #include "ui/compositor/layer_animator_collection.h" | 41 #include "ui/compositor/layer_animator_collection.h" |
41 #include "ui/gl/gl_switches.h" | 42 #include "ui/gl/gl_switches.h" |
42 | 43 |
43 namespace { | 44 namespace { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); | 206 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); |
206 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", | 207 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", |
207 base::TimeTicks::Now() - before_create); | 208 base::TimeTicks::Now() - before_create); |
208 | 209 |
209 animation_timeline_ = | 210 animation_timeline_ = |
210 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); | 211 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); |
211 host_->GetLayerTree()->animation_host()->AddAnimationTimeline( | 212 host_->GetLayerTree()->animation_host()->AddAnimationTimeline( |
212 animation_timeline_.get()); | 213 animation_timeline_.get()); |
213 | 214 |
214 host_->GetLayerTree()->SetRootLayer(root_web_layer_); | 215 host_->GetLayerTree()->SetRootLayer(root_web_layer_); |
215 host_->SetSurfaceClientId(surface_id_allocator_->client_id()); | 216 host_->GetSurfaceSequenceGenerator()->set_surface_client_id( |
| 217 surface_id_allocator_->client_id()); |
216 host_->SetVisible(true); | 218 host_->SetVisible(true); |
217 } | 219 } |
218 | 220 |
219 Compositor::~Compositor() { | 221 Compositor::~Compositor() { |
220 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 222 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
221 | 223 |
222 CancelCompositorLock(); | 224 CancelCompositorLock(); |
223 DCHECK(!compositor_lock_); | 225 DCHECK(!compositor_lock_); |
224 | 226 |
225 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, | 227 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 host_->SetNeedsCommit(); | 315 host_->SetNeedsCommit(); |
314 } | 316 } |
315 | 317 |
316 void Compositor::DisableSwapUntilResize() { | 318 void Compositor::DisableSwapUntilResize() { |
317 context_factory_->ResizeDisplay(this, gfx::Size()); | 319 context_factory_->ResizeDisplay(this, gfx::Size()); |
318 } | 320 } |
319 | 321 |
320 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) { | 322 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) { |
321 std::unique_ptr<cc::SwapPromise> swap_promise( | 323 std::unique_ptr<cc::SwapPromise> swap_promise( |
322 new cc::LatencyInfoSwapPromise(latency_info)); | 324 new cc::LatencyInfoSwapPromise(latency_info)); |
323 host_->QueueSwapPromise(std::move(swap_promise)); | 325 host_->GetSwapPromiseManager()->QueueSwapPromise(std::move(swap_promise)); |
324 } | 326 } |
325 | 327 |
326 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { | 328 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { |
327 DCHECK_GT(scale, 0); | 329 DCHECK_GT(scale, 0); |
328 if (!size_in_pixel.IsEmpty()) { | 330 if (!size_in_pixel.IsEmpty()) { |
329 size_ = size_in_pixel; | 331 size_ = size_in_pixel; |
330 host_->GetLayerTree()->SetViewportSize(size_in_pixel); | 332 host_->GetLayerTree()->SetViewportSize(size_in_pixel); |
331 root_web_layer_->SetBounds(size_in_pixel); | 333 root_web_layer_->SetBounds(size_in_pixel); |
332 context_factory_->ResizeDisplay(this, size_in_pixel); | 334 context_factory_->ResizeDisplay(this, size_in_pixel); |
333 } | 335 } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 observer_list_, | 550 observer_list_, |
549 OnCompositingLockStateChanged(this)); | 551 OnCompositingLockStateChanged(this)); |
550 } | 552 } |
551 | 553 |
552 void Compositor::CancelCompositorLock() { | 554 void Compositor::CancelCompositorLock() { |
553 if (compositor_lock_) | 555 if (compositor_lock_) |
554 compositor_lock_->CancelLock(); | 556 compositor_lock_->CancelLock(); |
555 } | 557 } |
556 | 558 |
557 } // namespace ui | 559 } // namespace ui |
OLD | NEW |