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

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

Issue 2253143002: Revert of cc: Move data to LayerTree from LayerTreeHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@layer_tree_change
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/platform/testing/WebLayerTreeViewImplForTesting.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_->GetLayerTree()->SetRootLayer(root_web_layer_); 223 host_->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
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_->GetLayerTree()->set_has_transparent_background( 327 host_->set_has_transparent_background(host_has_transparent_background);
328 host_has_transparent_background);
329 } 328 }
330 329
331 void Compositor::ScheduleFullRedraw() { 330 void Compositor::ScheduleFullRedraw() {
332 // TODO(enne): Some callers (mac) call this function expecting that it 331 // TODO(enne): Some callers (mac) call this function expecting that it
333 // will also commit. This should probably just redraw the screen 332 // will also commit. This should probably just redraw the screen
334 // from damage and not commit. ScheduleDraw/ScheduleRedraw need 333 // from damage and not commit. ScheduleDraw/ScheduleRedraw need
335 // better names. 334 // better names.
336 host_->SetNeedsRedraw(); 335 host_->SetNeedsRedraw();
337 host_->SetNeedsCommit(); 336 host_->SetNeedsCommit();
338 } 337 }
(...skipping 11 matching lines...) Expand all
350 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) { 349 void Compositor::SetLatencyInfo(const ui::LatencyInfo& latency_info) {
351 std::unique_ptr<cc::SwapPromise> swap_promise( 350 std::unique_ptr<cc::SwapPromise> swap_promise(
352 new cc::LatencyInfoSwapPromise(latency_info)); 351 new cc::LatencyInfoSwapPromise(latency_info));
353 host_->QueueSwapPromise(std::move(swap_promise)); 352 host_->QueueSwapPromise(std::move(swap_promise));
354 } 353 }
355 354
356 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) { 355 void Compositor::SetScaleAndSize(float scale, const gfx::Size& size_in_pixel) {
357 DCHECK_GT(scale, 0); 356 DCHECK_GT(scale, 0);
358 if (!size_in_pixel.IsEmpty()) { 357 if (!size_in_pixel.IsEmpty()) {
359 size_ = size_in_pixel; 358 size_ = size_in_pixel;
360 host_->GetLayerTree()->SetViewportSize(size_in_pixel); 359 host_->SetViewportSize(size_in_pixel);
361 root_web_layer_->SetBounds(size_in_pixel); 360 root_web_layer_->SetBounds(size_in_pixel);
362 context_factory_->ResizeDisplay(this, size_in_pixel); 361 context_factory_->ResizeDisplay(this, size_in_pixel);
363 } 362 }
364 if (device_scale_factor_ != scale) { 363 if (device_scale_factor_ != scale) {
365 device_scale_factor_ = scale; 364 device_scale_factor_ = scale;
366 host_->GetLayerTree()->SetDeviceScaleFactor(scale); 365 host_->SetDeviceScaleFactor(scale);
367 if (root_layer_) 366 if (root_layer_)
368 root_layer_->OnDeviceScaleFactorChanged(scale); 367 root_layer_->OnDeviceScaleFactorChanged(scale);
369 } 368 }
370 } 369 }
371 370
372 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { 371 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) {
373 context_factory_->SetDisplayColorSpace(this, color_space); 372 context_factory_->SetDisplayColorSpace(this, color_space);
374 } 373 }
375 374
376 void Compositor::SetBackgroundColor(SkColor color) { 375 void Compositor::SetBackgroundColor(SkColor color) {
377 host_->GetLayerTree()->set_background_color(color); 376 host_->set_background_color(color);
378 ScheduleDraw(); 377 ScheduleDraw();
379 } 378 }
380 379
381 void Compositor::SetVisible(bool visible) { 380 void Compositor::SetVisible(bool visible) {
382 host_->SetVisible(visible); 381 host_->SetVisible(visible);
383 } 382 }
384 383
385 bool Compositor::IsVisible() { 384 bool Compositor::IsVisible() {
386 return host_->visible(); 385 return host_->visible();
387 } 386 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 observer_list_, 578 observer_list_,
580 OnCompositingLockStateChanged(this)); 579 OnCompositingLockStateChanged(this));
581 } 580 }
582 581
583 void Compositor::CancelCompositorLock() { 582 void Compositor::CancelCompositorLock() {
584 if (compositor_lock_) 583 if (compositor_lock_)
585 compositor_lock_->CancelLock(); 584 compositor_lock_->CancelLock();
586 } 585 }
587 586
588 } // namespace ui 587 } // namespace ui
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/testing/WebLayerTreeViewImplForTesting.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698