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

Side by Side Diff: cc/layers/layer.cc

Issue 1101823002: CC Animations: Make LayerAnimationController creation optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use per-process global variable to create LAC Created 5 years, 7 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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "cc/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 16 matching lines...) Expand all
27 #include "cc/trees/layer_tree_host.h" 27 #include "cc/trees/layer_tree_host.h"
28 #include "cc/trees/layer_tree_impl.h" 28 #include "cc/trees/layer_tree_impl.h"
29 #include "third_party/skia/include/core/SkImageFilter.h" 29 #include "third_party/skia/include/core/SkImageFilter.h"
30 #include "ui/gfx/geometry/rect_conversions.h" 30 #include "ui/gfx/geometry/rect_conversions.h"
31 #include "ui/gfx/geometry/vector2d_conversions.h" 31 #include "ui/gfx/geometry/vector2d_conversions.h"
32 32
33 namespace cc { 33 namespace cc {
34 34
35 base::StaticAtomicSequenceNumber g_next_layer_id; 35 base::StaticAtomicSequenceNumber g_next_layer_id;
36 36
37 bool g_compositor_animation_timelines_enabled = false;
38
37 scoped_refptr<Layer> Layer::Create() { 39 scoped_refptr<Layer> Layer::Create() {
38 return make_scoped_refptr(new Layer()); 40 return make_scoped_refptr(new Layer());
39 } 41 }
40 42
41 Layer::Layer() 43 Layer::Layer()
42 : needs_push_properties_(false), 44 : needs_push_properties_(false),
43 num_dependents_need_push_properties_(false), 45 num_dependents_need_push_properties_(false),
44 stacking_order_changed_(false), 46 stacking_order_changed_(false),
45 // Layer IDs start from 1. 47 // Layer IDs start from 1.
46 layer_id_(g_next_layer_id.GetNext() + 1), 48 layer_id_(g_next_layer_id.GetNext() + 1),
(...skipping 29 matching lines...) Expand all
76 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE), 78 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE),
77 background_color_(0), 79 background_color_(0),
78 opacity_(1.f), 80 opacity_(1.f),
79 blend_mode_(SkXfermode::kSrcOver_Mode), 81 blend_mode_(SkXfermode::kSrcOver_Mode),
80 scroll_parent_(nullptr), 82 scroll_parent_(nullptr),
81 clip_parent_(nullptr), 83 clip_parent_(nullptr),
82 replica_layer_(nullptr), 84 replica_layer_(nullptr),
83 raster_scale_(0.f), 85 raster_scale_(0.f),
84 client_(nullptr), 86 client_(nullptr),
85 frame_timing_requests_dirty_(false) { 87 frame_timing_requests_dirty_(false) {
86 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); 88 if (!g_compositor_animation_timelines_enabled) {
87 layer_animation_controller_->AddValueObserver(this); 89 layer_animation_controller_ = LayerAnimationController::Create(layer_id_);
88 layer_animation_controller_->set_value_provider(this); 90 layer_animation_controller_->AddValueObserver(this);
91 layer_animation_controller_->set_value_provider(this);
92 }
89 } 93 }
90 94
91 Layer::~Layer() { 95 Layer::~Layer() {
92 // Our parent should be holding a reference to us so there should be no 96 // Our parent should be holding a reference to us so there should be no
93 // way for us to be destroyed while we still have a parent. 97 // way for us to be destroyed while we still have a parent.
94 DCHECK(!parent()); 98 DCHECK(!parent());
95 // Similarly we shouldn't have a layer tree host since it also keeps a 99 // Similarly we shouldn't have a layer tree host since it also keeps a
96 // reference to us. 100 // reference to us.
97 DCHECK(!layer_tree_host()); 101 DCHECK(!layer_tree_host());
98 102
99 layer_animation_controller_->RemoveValueObserver(this); 103 if (layer_animation_controller_) {
100 layer_animation_controller_->remove_value_provider(this); 104 layer_animation_controller_->RemoveValueObserver(this);
105 layer_animation_controller_->remove_value_provider(this);
106 }
101 107
102 RemoveFromScrollTree(); 108 RemoveFromScrollTree();
103 RemoveFromClipTree(); 109 RemoveFromClipTree();
104 110
105 // Remove the parent reference from all children and dependents. 111 // Remove the parent reference from all children and dependents.
106 RemoveAllChildren(); 112 RemoveAllChildren();
107 if (mask_layer_.get()) { 113 if (mask_layer_.get()) {
108 DCHECK_EQ(this, mask_layer_->parent()); 114 DCHECK_EQ(this, mask_layer_->parent());
109 mask_layer_->RemoveFromParent(); 115 mask_layer_->RemoveFromParent();
110 } 116 }
(...skipping 18 matching lines...) Expand all
129 135
130 for (size_t i = 0; i < children_.size(); ++i) 136 for (size_t i = 0; i < children_.size(); ++i)
131 children_[i]->SetLayerTreeHost(host); 137 children_[i]->SetLayerTreeHost(host);
132 138
133 if (mask_layer_.get()) 139 if (mask_layer_.get())
134 mask_layer_->SetLayerTreeHost(host); 140 mask_layer_->SetLayerTreeHost(host);
135 if (replica_layer_.get()) 141 if (replica_layer_.get())
136 replica_layer_->SetLayerTreeHost(host); 142 replica_layer_->SetLayerTreeHost(host);
137 143
138 if (host) { 144 if (host) {
139 layer_animation_controller_->SetAnimationRegistrar( 145 RegisterForAnimations(host->animation_registrar(), host->settings());
danakj 2015/05/08 18:21:40 if (layer_animation_controller_)?
loyso (OOO) 2015/05/11 06:59:42 Done in RegisterForAnimations.
140 host->animation_registrar());
141
142 if (host->settings().layer_transforms_should_scale_layer_contents) 146 if (host->settings().layer_transforms_should_scale_layer_contents)
143 reset_raster_scale_to_unknown(); 147 reset_raster_scale_to_unknown();
144 } 148 }
145 149
146 if (host && layer_animation_controller_->has_any_animation()) 150 if (host && layer_animation_controller_->has_any_animation())
147 host->SetNeedsCommit(); 151 host->SetNeedsCommit();
148 } 152 }
149 153
150 void Layer::SetNeedsUpdate() { 154 void Layer::SetNeedsUpdate() {
151 if (layer_tree_host_ && !ignore_set_needs_commit_) 155 if (layer_tree_host_ && !ignore_set_needs_commit_)
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 1346
1343 void Layer::OnAnimationWaitingForDeletion() { 1347 void Layer::OnAnimationWaitingForDeletion() {
1344 // Animations are only deleted during PushProperties. 1348 // Animations are only deleted during PushProperties.
1345 SetNeedsPushProperties(); 1349 SetNeedsPushProperties();
1346 } 1350 }
1347 1351
1348 bool Layer::IsActive() const { 1352 bool Layer::IsActive() const {
1349 return true; 1353 return true;
1350 } 1354 }
1351 1355
1356 // static
1357 void Layer::SetCompositorAnimationTimelinesEnabled(bool enabled) {
1358 g_compositor_animation_timelines_enabled = enabled;
1359 }
1360
1352 bool Layer::AddAnimation(scoped_ptr <Animation> animation) { 1361 bool Layer::AddAnimation(scoped_ptr <Animation> animation) {
1362 DCHECK(layer_animation_controller_);
1353 if (!layer_animation_controller_->animation_registrar()) 1363 if (!layer_animation_controller_->animation_registrar())
1354 return false; 1364 return false;
1355 1365
1356 if (animation->target_property() == Animation::SCROLL_OFFSET && 1366 if (animation->target_property() == Animation::SCROLL_OFFSET &&
1357 !layer_animation_controller_->animation_registrar() 1367 !layer_animation_controller_->animation_registrar()
1358 ->supports_scroll_animations()) 1368 ->supports_scroll_animations())
1359 return false; 1369 return false;
1360 1370
1361 UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer", 1371 UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer",
1362 !layer_tree_host_); 1372 !layer_tree_host_);
(...skipping 24 matching lines...) Expand all
1387 layer_animation_controller_->RemoveValueObserver(this); 1397 layer_animation_controller_->RemoveValueObserver(this);
1388 layer_animation_controller_ = controller; 1398 layer_animation_controller_ = controller;
1389 layer_animation_controller_->AddValueObserver(this); 1399 layer_animation_controller_->AddValueObserver(this);
1390 SetNeedsCommit(); 1400 SetNeedsCommit();
1391 } 1401 }
1392 1402
1393 bool Layer::HasActiveAnimation() const { 1403 bool Layer::HasActiveAnimation() const {
1394 return layer_animation_controller_->HasActiveAnimation(); 1404 return layer_animation_controller_->HasActiveAnimation();
1395 } 1405 }
1396 1406
1407 void Layer::RegisterForAnimations(AnimationRegistrar* registrar,
1408 const LayerTreeSettings& settings) {
danakj 2015/05/08 18:21:40 why are settings coming here but not being used?
loyso (OOO) 2015/05/11 06:59:43 Sorry, the CL was in inconsistent state (while pro
1409 layer_animation_controller_->SetAnimationRegistrar(registrar);
1410 }
1411
1397 void Layer::AddLayerAnimationEventObserver( 1412 void Layer::AddLayerAnimationEventObserver(
1398 LayerAnimationEventObserver* animation_observer) { 1413 LayerAnimationEventObserver* animation_observer) {
1414 DCHECK(layer_animation_controller_);
1399 layer_animation_controller_->AddEventObserver(animation_observer); 1415 layer_animation_controller_->AddEventObserver(animation_observer);
1400 } 1416 }
1401 1417
1402 void Layer::RemoveLayerAnimationEventObserver( 1418 void Layer::RemoveLayerAnimationEventObserver(
1403 LayerAnimationEventObserver* animation_observer) { 1419 LayerAnimationEventObserver* animation_observer) {
1420 DCHECK(layer_animation_controller_);
1404 layer_animation_controller_->RemoveEventObserver(animation_observer); 1421 layer_animation_controller_->RemoveEventObserver(animation_observer);
1405 } 1422 }
1406 1423
1407 SimpleEnclosedRegion Layer::VisibleContentOpaqueRegion() const { 1424 SimpleEnclosedRegion Layer::VisibleContentOpaqueRegion() const {
1408 if (contents_opaque()) 1425 if (contents_opaque())
1409 return SimpleEnclosedRegion(visible_content_rect()); 1426 return SimpleEnclosedRegion(visible_content_rect());
1410 return SimpleEnclosedRegion(); 1427 return SimpleEnclosedRegion();
1411 } 1428 }
1412 1429
1413 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { 1430 ScrollbarLayerInterface* Layer::ToScrollbarLayer() {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 1485
1469 void Layer::DidBeginTracing() { 1486 void Layer::DidBeginTracing() {
1470 // We'll be dumping layer trees as part of trace, so make sure 1487 // We'll be dumping layer trees as part of trace, so make sure
1471 // PushPropertiesTo() propagates layer debug info to the impl 1488 // PushPropertiesTo() propagates layer debug info to the impl
1472 // side -- otherwise this won't happen for the the layers that 1489 // side -- otherwise this won't happen for the the layers that
1473 // remain unchanged since tracing started. 1490 // remain unchanged since tracing started.
1474 SetNeedsPushProperties(); 1491 SetNeedsPushProperties();
1475 } 1492 }
1476 1493
1477 } // namespace cc 1494 } // namespace cc
OLDNEW
« cc/layers/layer.h ('K') | « cc/layers/layer.h ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698