| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 params.main_task_runner = task_runner_; | 213 params.main_task_runner = task_runner_; |
| 214 params.animation_host = cc::AnimationHost::CreateMainInstance(); | 214 params.animation_host = cc::AnimationHost::CreateMainInstance(); |
| 215 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); | 215 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); |
| 216 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", | 216 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", |
| 217 base::TimeTicks::Now() - before_create); | 217 base::TimeTicks::Now() - before_create); |
| 218 | 218 |
| 219 animation_timeline_ = | 219 animation_timeline_ = |
| 220 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); | 220 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); |
| 221 host_->animation_host()->AddAnimationTimeline(animation_timeline_.get()); | 221 host_->animation_host()->AddAnimationTimeline(animation_timeline_.get()); |
| 222 | 222 |
| 223 host_->SetRootLayer(root_web_layer_); | 223 host_->GetLayerTree()->SetRootLayer(root_web_layer_); |
| 224 host_->set_surface_client_id(surface_id_allocator_->client_id()); | 224 host_->set_surface_client_id(surface_id_allocator_->client_id()); |
| 225 host_->SetVisible(true); | 225 host_->SetVisible(true); |
| 226 } | 226 } |
| 227 | 227 |
| 228 Compositor::~Compositor() { | 228 Compositor::~Compositor() { |
| 229 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 229 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
| 230 | 230 |
| 231 CancelCompositorLock(); | 231 CancelCompositorLock(); |
| 232 DCHECK(!compositor_lock_); | 232 DCHECK(!compositor_lock_); |
| 233 | 233 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 if (root_layer_) | 317 if (root_layer_) |
| 318 root_layer_->SetCompositor(this, root_web_layer_); | 318 root_layer_->SetCompositor(this, root_web_layer_); |
| 319 } | 319 } |
| 320 | 320 |
| 321 cc::AnimationTimeline* Compositor::GetAnimationTimeline() const { | 321 cc::AnimationTimeline* Compositor::GetAnimationTimeline() const { |
| 322 return animation_timeline_.get(); | 322 return animation_timeline_.get(); |
| 323 } | 323 } |
| 324 | 324 |
| 325 void Compositor::SetHostHasTransparentBackground( | 325 void Compositor::SetHostHasTransparentBackground( |
| 326 bool host_has_transparent_background) { | 326 bool host_has_transparent_background) { |
| 327 host_->set_has_transparent_background(host_has_transparent_background); | 327 host_->GetLayerTree()->set_has_transparent_background( |
| 328 host_has_transparent_background); |
| 328 } | 329 } |
| 329 | 330 |
| 330 void Compositor::ScheduleFullRedraw() { | 331 void Compositor::ScheduleFullRedraw() { |
| 331 // TODO(enne): Some callers (mac) call this function expecting that it | 332 // TODO(enne): Some callers (mac) call this function expecting that it |
| 332 // will also commit. This should probably just redraw the screen | 333 // will also commit. This should probably just redraw the screen |
| 333 // from damage and not commit. ScheduleDraw/ScheduleRedraw need | 334 // from damage and not commit. ScheduleDraw/ScheduleRedraw need |
| 334 // better names. | 335 // better names. |
| 335 host_->SetNeedsRedraw(); | 336 host_->SetNeedsRedraw(); |
| 336 host_->SetNeedsCommit(); | 337 host_->SetNeedsCommit(); |
| 337 } | 338 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 354 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) { | 355 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) { |
| 355 std::unique_ptr<cc::SwapPromise> swap_promise( | 356 std::unique_ptr<cc::SwapPromise> swap_promise( |
| 356 new cc::LatencyInfoSwapPromise(latency_info)); | 357 new cc::LatencyInfoSwapPromise(latency_info)); |
| 357 host_->QueueSwapPromise(std::move(swap_promise)); | 358 host_->QueueSwapPromise(std::move(swap_promise)); |
| 358 } | 359 } |
| 359 | 360 |
| 360 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { | 361 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { |
| 361 DCHECK_GT(scale, 0); | 362 DCHECK_GT(scale, 0); |
| 362 if (!size_in_pixel.IsEmpty()) { | 363 if (!size_in_pixel.IsEmpty()) { |
| 363 size_ = size_in_pixel; | 364 size_ = size_in_pixel; |
| 364 host_->SetViewportSize(size_in_pixel); | 365 host_->GetLayerTree()->SetViewportSize(size_in_pixel); |
| 365 root_web_layer_->SetBounds(size_in_pixel); | 366 root_web_layer_->SetBounds(size_in_pixel); |
| 366 context_factory_->ResizeDisplay(this, size_in_pixel); | 367 context_factory_->ResizeDisplay(this, size_in_pixel); |
| 367 } | 368 } |
| 368 if (device_scale_factor_ != scale) { | 369 if (device_scale_factor_ != scale) { |
| 369 device_scale_factor_ = scale; | 370 device_scale_factor_ = scale; |
| 370 host_->SetDeviceScaleFactor(scale); | 371 host_->GetLayerTree()->SetDeviceScaleFactor(scale); |
| 371 if (root_layer_) | 372 if (root_layer_) |
| 372 root_layer_->OnDeviceScaleFactorChanged(scale); | 373 root_layer_->OnDeviceScaleFactorChanged(scale); |
| 373 } | 374 } |
| 374 } | 375 } |
| 375 | 376 |
| 376 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { | 377 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { |
| 377 context_factory_->SetDisplayColorSpace(this, color_space); | 378 context_factory_->SetDisplayColorSpace(this, color_space); |
| 378 } | 379 } |
| 379 | 380 |
| 380 void Compositor::SetBackgroundColor(SkColor color) { | 381 void Compositor::SetBackgroundColor(SkColor color) { |
| 381 host_->set_background_color(color); | 382 host_->GetLayerTree()->set_background_color(color); |
| 382 ScheduleDraw(); | 383 ScheduleDraw(); |
| 383 } | 384 } |
| 384 | 385 |
| 385 void Compositor::SetVisible(bool visible) { | 386 void Compositor::SetVisible(bool visible) { |
| 386 host_->SetVisible(visible); | 387 host_->SetVisible(visible); |
| 387 } | 388 } |
| 388 | 389 |
| 389 bool Compositor::IsVisible() { | 390 bool Compositor::IsVisible() { |
| 390 return host_->visible(); | 391 return host_->visible(); |
| 391 } | 392 } |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 observer_list_, | 575 observer_list_, |
| 575 OnCompositingLockStateChanged(this)); | 576 OnCompositingLockStateChanged(this)); |
| 576 } | 577 } |
| 577 | 578 |
| 578 void Compositor::CancelCompositorLock() { | 579 void Compositor::CancelCompositorLock() { |
| 579 if (compositor_lock_) | 580 if (compositor_lock_) |
| 580 compositor_lock_->CancelLock(); | 581 compositor_lock_->CancelLock(); |
| 581 } | 582 } |
| 582 | 583 |
| 583 } // namespace ui | 584 } // namespace ui |
| OLD | NEW |