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 11 matching lines...) Expand all Loading... |
349 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) { | 350 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) { |
350 std::unique_ptr<cc::SwapPromise> swap_promise( | 351 std::unique_ptr<cc::SwapPromise> swap_promise( |
351 new cc::LatencyInfoSwapPromise(latency_info)); | 352 new cc::LatencyInfoSwapPromise(latency_info)); |
352 host_->QueueSwapPromise(std::move(swap_promise)); | 353 host_->QueueSwapPromise(std::move(swap_promise)); |
353 } | 354 } |
354 | 355 |
355 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { | 356 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { |
356 DCHECK_GT(scale, 0); | 357 DCHECK_GT(scale, 0); |
357 if (!size_in_pixel.IsEmpty()) { | 358 if (!size_in_pixel.IsEmpty()) { |
358 size_ = size_in_pixel; | 359 size_ = size_in_pixel; |
359 host_->SetViewportSize(size_in_pixel); | 360 host_->GetLayerTree()->SetViewportSize(size_in_pixel); |
360 root_web_layer_->SetBounds(size_in_pixel); | 361 root_web_layer_->SetBounds(size_in_pixel); |
361 context_factory_->ResizeDisplay(this, size_in_pixel); | 362 context_factory_->ResizeDisplay(this, size_in_pixel); |
362 } | 363 } |
363 if (device_scale_factor_ != scale) { | 364 if (device_scale_factor_ != scale) { |
364 device_scale_factor_ = scale; | 365 device_scale_factor_ = scale; |
365 host_->SetDeviceScaleFactor(scale); | 366 host_->GetLayerTree()->SetDeviceScaleFactor(scale); |
366 if (root_layer_) | 367 if (root_layer_) |
367 root_layer_->OnDeviceScaleFactorChanged(scale); | 368 root_layer_->OnDeviceScaleFactorChanged(scale); |
368 } | 369 } |
369 } | 370 } |
370 | 371 |
371 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { | 372 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { |
372 context_factory_->SetDisplayColorSpace(this, color_space); | 373 context_factory_->SetDisplayColorSpace(this, color_space); |
373 } | 374 } |
374 | 375 |
375 void Compositor::SetBackgroundColor(SkColor color) { | 376 void Compositor::SetBackgroundColor(SkColor color) { |
376 host_->set_background_color(color); | 377 host_->GetLayerTree()->set_background_color(color); |
377 ScheduleDraw(); | 378 ScheduleDraw(); |
378 } | 379 } |
379 | 380 |
380 void Compositor::SetVisible(bool visible) { | 381 void Compositor::SetVisible(bool visible) { |
381 host_->SetVisible(visible); | 382 host_->SetVisible(visible); |
382 } | 383 } |
383 | 384 |
384 bool Compositor::IsVisible() { | 385 bool Compositor::IsVisible() { |
385 return host_->visible(); | 386 return host_->visible(); |
386 } | 387 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 observer_list_, | 579 observer_list_, |
579 OnCompositingLockStateChanged(this)); | 580 OnCompositingLockStateChanged(this)); |
580 } | 581 } |
581 | 582 |
582 void Compositor::CancelCompositorLock() { | 583 void Compositor::CancelCompositorLock() { |
583 if (compositor_lock_) | 584 if (compositor_lock_) |
584 compositor_lock_->CancelLock(); | 585 compositor_lock_->CancelLock(); |
585 } | 586 } |
586 | 587 |
587 } // namespace ui | 588 } // namespace ui |
OLD | NEW |