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

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

Issue 2317753002: cc: Abstract the LayerTreeHost. (Closed)
Patch Set: Rebase Created 4 years, 3 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 | « content/renderer/gpu/render_widget_compositor.cc ('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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, &params); 205 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, &params);
206 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", 206 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor",
207 base::TimeTicks::Now() - before_create); 207 base::TimeTicks::Now() - before_create);
208 208
209 animation_timeline_ = 209 animation_timeline_ =
210 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId()); 210 cc::AnimationTimeline::Create(cc::AnimationIdProvider::NextTimelineId());
211 host_->GetLayerTree()->animation_host()->AddAnimationTimeline( 211 host_->GetLayerTree()->animation_host()->AddAnimationTimeline(
212 animation_timeline_.get()); 212 animation_timeline_.get());
213 213
214 host_->GetLayerTree()->SetRootLayer(root_web_layer_); 214 host_->GetLayerTree()->SetRootLayer(root_web_layer_);
215 host_->set_surface_client_id(surface_id_allocator_->client_id()); 215 host_->SetSurfaceClientId(surface_id_allocator_->client_id());
216 host_->SetVisible(true); 216 host_->SetVisible(true);
217 } 217 }
218 218
219 Compositor::~Compositor() { 219 Compositor::~Compositor() {
220 TRACE_EVENT0("shutdown", "Compositor::destructor"); 220 TRACE_EVENT0("shutdown", "Compositor::destructor");
221 221
222 CancelCompositorLock(); 222 CancelCompositorLock();
223 DCHECK(!compositor_lock_); 223 DCHECK(!compositor_lock_);
224 224
225 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, 225 FOR_EACH_OBSERVER(CompositorObserver, observer_list_,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 it->second, it->first); 263 it->second, it->first);
264 surface_clients_.erase(it); 264 surface_clients_.erase(it);
265 } 265 }
266 266
267 void Compositor::SetOutputSurface( 267 void Compositor::SetOutputSurface(
268 std::unique_ptr<cc::OutputSurface> output_surface) { 268 std::unique_ptr<cc::OutputSurface> output_surface) {
269 output_surface_requested_ = false; 269 output_surface_requested_ = false;
270 host_->SetOutputSurface(std::move(output_surface)); 270 host_->SetOutputSurface(std::move(output_surface));
271 // Visibility is reset when the output surface is lost, so update it to match 271 // Visibility is reset when the output surface is lost, so update it to match
272 // the Compositor's. 272 // the Compositor's.
273 context_factory_->SetDisplayVisible(this, host_->visible()); 273 context_factory_->SetDisplayVisible(this, host_->IsVisible());
274 } 274 }
275 275
276 void Compositor::ScheduleDraw() { 276 void Compositor::ScheduleDraw() {
277 host_->SetNeedsCommit(); 277 host_->SetNeedsCommit();
278 } 278 }
279 279
280 void Compositor::SetRootLayer(Layer* root_layer) { 280 void Compositor::SetRootLayer(Layer* root_layer) {
281 if (root_layer_ == root_layer) 281 if (root_layer_ == root_layer)
282 return; 282 return;
283 if (root_layer_) 283 if (root_layer_)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 349 }
350 350
351 void Compositor::SetVisible(bool visible) { 351 void Compositor::SetVisible(bool visible) {
352 host_->SetVisible(visible); 352 host_->SetVisible(visible);
353 // Visibility is reset when the output surface is lost, so this must also be 353 // Visibility is reset when the output surface is lost, so this must also be
354 // updated then. 354 // updated then.
355 context_factory_->SetDisplayVisible(this, visible); 355 context_factory_->SetDisplayVisible(this, visible);
356 } 356 }
357 357
358 bool Compositor::IsVisible() { 358 bool Compositor::IsVisible() {
359 return host_->visible(); 359 return host_->IsVisible();
360 } 360 }
361 361
362 bool Compositor::ScrollLayerTo(int layer_id, const gfx::ScrollOffset& offset) { 362 bool Compositor::ScrollLayerTo(int layer_id, const gfx::ScrollOffset& offset) {
363 return host_->GetInputHandler()->ScrollLayerTo(layer_id, offset); 363 return host_->GetInputHandler()->ScrollLayerTo(layer_id, offset);
364 } 364 }
365 365
366 bool Compositor::GetScrollOffsetForLayer(int layer_id, 366 bool Compositor::GetScrollOffsetForLayer(int layer_id,
367 gfx::ScrollOffset* offset) const { 367 gfx::ScrollOffset* offset) const {
368 return host_->GetInputHandler()->GetScrollOffsetForLayer(layer_id, offset); 368 return host_->GetInputHandler()->GetScrollOffsetForLayer(layer_id, offset);
369 } 369 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 FOR_EACH_OBSERVER(CompositorObserver, 510 FOR_EACH_OBSERVER(CompositorObserver,
511 observer_list_, 511 observer_list_,
512 OnCompositingAborted(this)); 512 OnCompositingAborted(this));
513 } 513 }
514 514
515 void Compositor::SetOutputIsSecure(bool output_is_secure) { 515 void Compositor::SetOutputIsSecure(bool output_is_secure) {
516 context_factory_->SetOutputIsSecure(this, output_is_secure); 516 context_factory_->SetOutputIsSecure(this, output_is_secure);
517 } 517 }
518 518
519 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { 519 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const {
520 return host_->debug_state(); 520 return host_->GetDebugState();
521 } 521 }
522 522
523 void Compositor::SetLayerTreeDebugState( 523 void Compositor::SetLayerTreeDebugState(
524 const cc::LayerTreeDebugState& debug_state) { 524 const cc::LayerTreeDebugState& debug_state) {
525 host_->SetDebugState(debug_state); 525 host_->SetDebugState(debug_state);
526 } 526 }
527 527
528 const cc::RendererSettings& Compositor::GetRendererSettings() const { 528 const cc::RendererSettings& Compositor::GetRendererSettings() const {
529 return host_->settings().renderer_settings; 529 return host_->GetSettings().renderer_settings;
530 } 530 }
531 531
532 scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { 532 scoped_refptr<CompositorLock> Compositor::GetCompositorLock() {
533 if (!compositor_lock_) { 533 if (!compositor_lock_) {
534 compositor_lock_ = new CompositorLock(this); 534 compositor_lock_ = new CompositorLock(this);
535 host_->SetDeferCommits(true); 535 host_->SetDeferCommits(true);
536 FOR_EACH_OBSERVER(CompositorObserver, 536 FOR_EACH_OBSERVER(CompositorObserver,
537 observer_list_, 537 observer_list_,
538 OnCompositingLockStateChanged(this)); 538 OnCompositingLockStateChanged(this));
539 } 539 }
540 return compositor_lock_; 540 return compositor_lock_;
541 } 541 }
542 542
543 void Compositor::UnlockCompositor() { 543 void Compositor::UnlockCompositor() {
544 DCHECK(compositor_lock_); 544 DCHECK(compositor_lock_);
545 compositor_lock_ = NULL; 545 compositor_lock_ = NULL;
546 host_->SetDeferCommits(false); 546 host_->SetDeferCommits(false);
547 FOR_EACH_OBSERVER(CompositorObserver, 547 FOR_EACH_OBSERVER(CompositorObserver,
548 observer_list_, 548 observer_list_,
549 OnCompositingLockStateChanged(this)); 549 OnCompositingLockStateChanged(this));
550 } 550 }
551 551
552 void Compositor::CancelCompositorLock() { 552 void Compositor::CancelCompositorLock() {
553 if (compositor_lock_) 553 if (compositor_lock_)
554 compositor_lock_->CancelLock(); 554 compositor_lock_->CancelLock();
555 } 555 }
556 556
557 } // namespace ui 557 } // namespace ui
OLDNEW
« no previous file with comments | « content/renderer/gpu/render_widget_compositor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698