Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: ui/compositor/compositor.cc

Issue 2251143002: cc: Reland Move data to LayerTree from LayerTreeHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better fix? Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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, &params); 215 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, &params);
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 if (root_layer_) 320 if (root_layer_)
321 root_layer_->SetCompositor(this, root_web_layer_); 321 root_layer_->SetCompositor(this, root_web_layer_);
322 } 322 }
323 323
324 cc::AnimationTimeline* Compositor::GetAnimationTimeline() const { 324 cc::AnimationTimeline* Compositor::GetAnimationTimeline() const {
325 return animation_timeline_.get(); 325 return animation_timeline_.get();
326 } 326 }
327 327
328 void Compositor::SetHostHasTransparentBackground( 328 void Compositor::SetHostHasTransparentBackground(
329 bool host_has_transparent_background) { 329 bool host_has_transparent_background) {
330 host_->set_has_transparent_background(host_has_transparent_background); 330 host_->GetLayerTree()->set_has_transparent_background(
331 host_has_transparent_background);
331 } 332 }
332 333
333 void Compositor::ScheduleFullRedraw() { 334 void Compositor::ScheduleFullRedraw() {
334 // TODO(enne): Some callers (mac) call this function expecting that it 335 // TODO(enne): Some callers (mac) call this function expecting that it
335 // will also commit. This should probably just redraw the screen 336 // will also commit. This should probably just redraw the screen
336 // from damage and not commit. ScheduleDraw/ScheduleRedraw need 337 // from damage and not commit. ScheduleDraw/ScheduleRedraw need
337 // better names. 338 // better names.
338 host_->SetNeedsRedraw(); 339 host_->SetNeedsRedraw();
339 host_->SetNeedsCommit(); 340 host_->SetNeedsCommit();
340 } 341 }
(...skipping 11 matching lines...) Expand all
352 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) { 353 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) {
353 std::unique_ptr<cc::SwapPromise> swap_promise( 354 std::unique_ptr<cc::SwapPromise> swap_promise(
354 new cc::LatencyInfoSwapPromise(latency_info)); 355 new cc::LatencyInfoSwapPromise(latency_info));
355 host_->QueueSwapPromise(std::move(swap_promise)); 356 host_->QueueSwapPromise(std::move(swap_promise));
356 } 357 }
357 358
358 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { 359 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) {
359 DCHECK_GT(scale, 0); 360 DCHECK_GT(scale, 0);
360 if (!size_in_pixel.IsEmpty()) { 361 if (!size_in_pixel.IsEmpty()) {
361 size_ = size_in_pixel; 362 size_ = size_in_pixel;
362 host_->SetViewportSize(size_in_pixel); 363 host_->GetLayerTree()->SetViewportSize(size_in_pixel);
363 root_web_layer_->SetBounds(size_in_pixel); 364 root_web_layer_->SetBounds(size_in_pixel);
364 context_factory_->ResizeDisplay(this, size_in_pixel); 365 context_factory_->ResizeDisplay(this, size_in_pixel);
365 } 366 }
366 if (device_scale_factor_ != scale) { 367 if (device_scale_factor_ != scale) {
367 device_scale_factor_ = scale; 368 device_scale_factor_ = scale;
368 host_->SetDeviceScaleFactor(scale); 369 host_->GetLayerTree()->SetDeviceScaleFactor(scale);
369 if (root_layer_) 370 if (root_layer_)
370 root_layer_->OnDeviceScaleFactorChanged(scale); 371 root_layer_->OnDeviceScaleFactorChanged(scale);
371 } 372 }
372 } 373 }
373 374
374 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { 375 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) {
375 context_factory_->SetDisplayColorSpace(this, color_space); 376 context_factory_->SetDisplayColorSpace(this, color_space);
376 } 377 }
377 378
378 void Compositor::SetBackgroundColor(SkColor color) { 379 void Compositor::SetBackgroundColor(SkColor color) {
379 host_->set_background_color(color); 380 host_->GetLayerTree()->set_background_color(color);
380 ScheduleDraw(); 381 ScheduleDraw();
381 } 382 }
382 383
383 void Compositor::SetVisible(bool visible) { 384 void Compositor::SetVisible(bool visible) {
384 host_->SetVisible(visible); 385 host_->SetVisible(visible);
385 // Visibility is reset when the output surface is lost, so this must also be 386 // Visibility is reset when the output surface is lost, so this must also be
386 // updated then. 387 // updated then.
387 context_factory_->SetDisplayVisible(this, visible); 388 context_factory_->SetDisplayVisible(this, visible);
388 } 389 }
389 390
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 observer_list_, 586 observer_list_,
586 OnCompositingLockStateChanged(this)); 587 OnCompositingLockStateChanged(this));
587 } 588 }
588 589
589 void Compositor::CancelCompositorLock() { 590 void Compositor::CancelCompositorLock() {
590 if (compositor_lock_) 591 if (compositor_lock_)
591 compositor_lock_->CancelLock(); 592 compositor_lock_->CancelLock();
592 } 593 }
593 594
594 } // namespace ui 595 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698