| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); | 202 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); |
| 202 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", | 203 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", |
| 203 base::TimeTicks::Now() - before_create); | 204 base::TimeTicks::Now() - before_create); |
| 204 | 205 |
| 205 animation_timeline_ = | 206 animation_timeline_ = |
| 206 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); | 207 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); |
| 207 host_->GetLayerTree()->animation_host()->AddAnimationTimeline( | 208 host_->GetLayerTree()->animation_host()->AddAnimationTimeline( |
| 208 animation_timeline_.get()); | 209 animation_timeline_.get()); |
| 209 | 210 |
| 210 host_->GetLayerTree()->SetRootLayer(root_web_layer_); | 211 host_->GetLayerTree()->SetRootLayer(root_web_layer_); |
| 211 host_->SetSurfaceClientId(surface_id_allocator_->client_id()); | 212 host_->GetSurfaceSequenceGenerator()->set_surface_client_id( |
| 213 surface_id_allocator_->client_id()); |
| 212 host_->SetVisible(true); | 214 host_->SetVisible(true); |
| 213 } | 215 } |
| 214 | 216 |
| 215 Compositor::~Compositor() { | 217 Compositor::~Compositor() { |
| 216 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 218 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
| 217 | 219 |
| 218 CancelCompositorLock(); | 220 CancelCompositorLock(); |
| 219 DCHECK(!compositor_lock_); | 221 DCHECK(!compositor_lock_); |
| 220 | 222 |
| 221 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, | 223 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 host_->SetNeedsCommit(); | 311 host_->SetNeedsCommit(); |
| 310 } | 312 } |
| 311 | 313 |
| 312 void Compositor::DisableSwapUntilResize() { | 314 void Compositor::DisableSwapUntilResize() { |
| 313 context_factory_->ResizeDisplay(this, gfx::Size()); | 315 context_factory_->ResizeDisplay(this, gfx::Size()); |
| 314 } | 316 } |
| 315 | 317 |
| 316 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) { | 318 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) { |
| 317 std::unique_ptr<cc::SwapPromise> swap_promise( | 319 std::unique_ptr<cc::SwapPromise> swap_promise( |
| 318 new cc::LatencyInfoSwapPromise(latency_info)); | 320 new cc::LatencyInfoSwapPromise(latency_info)); |
| 319 host_->QueueSwapPromise(std::move(swap_promise)); | 321 host_->GetSwapPromiseManager()->QueueSwapPromise(std::move(swap_promise)); |
| 320 } | 322 } |
| 321 | 323 |
| 322 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { | 324 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { |
| 323 DCHECK_GT(scale, 0); | 325 DCHECK_GT(scale, 0); |
| 324 if (!size_in_pixel.IsEmpty()) { | 326 if (!size_in_pixel.IsEmpty()) { |
| 325 size_ = size_in_pixel; | 327 size_ = size_in_pixel; |
| 326 host_->GetLayerTree()->SetViewportSize(size_in_pixel); | 328 host_->GetLayerTree()->SetViewportSize(size_in_pixel); |
| 327 root_web_layer_->SetBounds(size_in_pixel); | 329 root_web_layer_->SetBounds(size_in_pixel); |
| 328 context_factory_->ResizeDisplay(this, size_in_pixel); | 330 context_factory_->ResizeDisplay(this, size_in_pixel); |
| 329 } | 331 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 observer_list_, | 546 observer_list_, |
| 545 OnCompositingLockStateChanged(this)); | 547 OnCompositingLockStateChanged(this)); |
| 546 } | 548 } |
| 547 | 549 |
| 548 void Compositor::CancelCompositorLock() { | 550 void Compositor::CancelCompositorLock() { |
| 549 if (compositor_lock_) | 551 if (compositor_lock_) |
| 550 compositor_lock_->CancelLock(); | 552 compositor_lock_->CancelLock(); |
| 551 } | 553 } |
| 552 | 554 |
| 553 } // namespace ui | 555 } // namespace ui |
| OLD | NEW |