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

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: Created 5 years, 8 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE), 76 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE),
77 background_color_(0), 77 background_color_(0),
78 opacity_(1.f), 78 opacity_(1.f),
79 blend_mode_(SkXfermode::kSrcOver_Mode), 79 blend_mode_(SkXfermode::kSrcOver_Mode),
80 scroll_parent_(nullptr), 80 scroll_parent_(nullptr),
81 clip_parent_(nullptr), 81 clip_parent_(nullptr),
82 replica_layer_(nullptr), 82 replica_layer_(nullptr),
83 raster_scale_(0.f), 83 raster_scale_(0.f),
84 client_(nullptr), 84 client_(nullptr),
85 frame_timing_requests_dirty_(false) { 85 frame_timing_requests_dirty_(false) {
86 layer_animation_controller_ = LayerAnimationController::Create(layer_id_);
87 layer_animation_controller_->AddValueObserver(this);
88 layer_animation_controller_->set_value_provider(this);
89 } 86 }
90 87
91 Layer::~Layer() { 88 Layer::~Layer() {
92 // Our parent should be holding a reference to us so there should be no 89 // 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. 90 // way for us to be destroyed while we still have a parent.
94 DCHECK(!parent()); 91 DCHECK(!parent());
95 // Similarly we shouldn't have a layer tree host since it also keeps a 92 // Similarly we shouldn't have a layer tree host since it also keeps a
96 // reference to us. 93 // reference to us.
97 DCHECK(!layer_tree_host()); 94 DCHECK(!layer_tree_host());
98 95
99 layer_animation_controller_->RemoveValueObserver(this); 96 if (layer_animation_controller_) {
100 layer_animation_controller_->remove_value_provider(this); 97 layer_animation_controller_->RemoveValueObserver(this);
98 layer_animation_controller_->remove_value_provider(this);
99 }
101 100
102 RemoveFromScrollTree(); 101 RemoveFromScrollTree();
103 RemoveFromClipTree(); 102 RemoveFromClipTree();
104 103
105 // Remove the parent reference from all children and dependents. 104 // Remove the parent reference from all children and dependents.
106 RemoveAllChildren(); 105 RemoveAllChildren();
107 if (mask_layer_.get()) { 106 if (mask_layer_.get()) {
108 DCHECK_EQ(this, mask_layer_->parent()); 107 DCHECK_EQ(this, mask_layer_->parent());
109 mask_layer_->RemoveFromParent(); 108 mask_layer_->RemoveFromParent();
110 } 109 }
(...skipping 15 matching lines...) Expand all
126 125
127 for (size_t i = 0; i < children_.size(); ++i) 126 for (size_t i = 0; i < children_.size(); ++i)
128 children_[i]->SetLayerTreeHost(host); 127 children_[i]->SetLayerTreeHost(host);
129 128
130 if (mask_layer_.get()) 129 if (mask_layer_.get())
131 mask_layer_->SetLayerTreeHost(host); 130 mask_layer_->SetLayerTreeHost(host);
132 if (replica_layer_.get()) 131 if (replica_layer_.get())
133 replica_layer_->SetLayerTreeHost(host); 132 replica_layer_->SetLayerTreeHost(host);
134 133
135 if (host) { 134 if (host) {
136 layer_animation_controller_->SetAnimationRegistrar( 135 RegisterForAnimations(host->animation_registrar(), host->settings());
137 host->animation_registrar());
138
139 if (host->settings().layer_transforms_should_scale_layer_contents) 136 if (host->settings().layer_transforms_should_scale_layer_contents)
140 reset_raster_scale_to_unknown(); 137 reset_raster_scale_to_unknown();
141 } 138 }
142 139
143 if (host && layer_animation_controller_->has_any_animation()) 140 if (host && layer_animation_controller_->has_any_animation())
144 host->SetNeedsCommit(); 141 host->SetNeedsCommit();
145 } 142 }
146 143
147 void Layer::SetNeedsUpdate() { 144 void Layer::SetNeedsUpdate() {
148 if (layer_tree_host_ && !ignore_set_needs_commit_) 145 if (layer_tree_host_ && !ignore_set_needs_commit_)
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 void Layer::OnAnimationWaitingForDeletion() { 1172 void Layer::OnAnimationWaitingForDeletion() {
1176 // Animations are only deleted during PushProperties. 1173 // Animations are only deleted during PushProperties.
1177 SetNeedsPushProperties(); 1174 SetNeedsPushProperties();
1178 } 1175 }
1179 1176
1180 bool Layer::IsActive() const { 1177 bool Layer::IsActive() const {
1181 return true; 1178 return true;
1182 } 1179 }
1183 1180
1184 bool Layer::AddAnimation(scoped_ptr <Animation> animation) { 1181 bool Layer::AddAnimation(scoped_ptr <Animation> animation) {
1185 if (!layer_animation_controller_->animation_registrar()) 1182 if (!layer_animation_controller_ ||
1183 !layer_animation_controller_->animation_registrar())
1186 return false; 1184 return false;
1187 1185
1188 if (animation->target_property() == Animation::SCROLL_OFFSET && 1186 if (animation->target_property() == Animation::SCROLL_OFFSET &&
1189 !layer_animation_controller_->animation_registrar() 1187 !layer_animation_controller_->animation_registrar()
1190 ->supports_scroll_animations()) 1188 ->supports_scroll_animations())
1191 return false; 1189 return false;
1192 1190
1193 UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer", 1191 UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer",
1194 !layer_tree_host_); 1192 !layer_tree_host_);
1195 layer_animation_controller_->AddAnimation(animation.Pass()); 1193 layer_animation_controller_->AddAnimation(animation.Pass());
(...skipping 23 matching lines...) Expand all
1219 layer_animation_controller_->RemoveValueObserver(this); 1217 layer_animation_controller_->RemoveValueObserver(this);
1220 layer_animation_controller_ = controller; 1218 layer_animation_controller_ = controller;
1221 layer_animation_controller_->AddValueObserver(this); 1219 layer_animation_controller_->AddValueObserver(this);
1222 SetNeedsCommit(); 1220 SetNeedsCommit();
1223 } 1221 }
1224 1222
1225 bool Layer::HasActiveAnimation() const { 1223 bool Layer::HasActiveAnimation() const {
1226 return layer_animation_controller_->HasActiveAnimation(); 1224 return layer_animation_controller_->HasActiveAnimation();
1227 } 1225 }
1228 1226
1227 void Layer::RegisterForAnimations(AnimationRegistrar* registrar,
1228 const LayerTreeSettings& settings) {
1229 if (!layer_animation_controller_) {
1230 layer_animation_controller_ = LayerAnimationController::Create(layer_id_);
1231 layer_animation_controller_->AddValueObserver(this);
1232 layer_animation_controller_->set_value_provider(this);
1233 }
1234
1235 layer_animation_controller_->SetAnimationRegistrar(registrar);
1236 }
1237
1229 void Layer::AddLayerAnimationEventObserver( 1238 void Layer::AddLayerAnimationEventObserver(
1230 LayerAnimationEventObserver* animation_observer) { 1239 LayerAnimationEventObserver* animation_observer) {
1240 DCHECK(layer_animation_controller_);
loyso (OOO) 2015/04/23 08:26:33 webkit_unit_tests are failing. I'm considering to
ajuma 2015/04/23 15:09:15 Hmm, these failures suggest that WebViewImpl::regi
loyso (OOO) 2015/04/24 03:44:52 Well, not really. We had a bunch of problems here:
1231 layer_animation_controller_->AddEventObserver(animation_observer); 1241 layer_animation_controller_->AddEventObserver(animation_observer);
1232 } 1242 }
1233 1243
1234 void Layer::RemoveLayerAnimationEventObserver( 1244 void Layer::RemoveLayerAnimationEventObserver(
1235 LayerAnimationEventObserver* animation_observer) { 1245 LayerAnimationEventObserver* animation_observer) {
1246 DCHECK(layer_animation_controller_);
1236 layer_animation_controller_->RemoveEventObserver(animation_observer); 1247 layer_animation_controller_->RemoveEventObserver(animation_observer);
1237 } 1248 }
1238 1249
1239 SimpleEnclosedRegion Layer::VisibleContentOpaqueRegion() const { 1250 SimpleEnclosedRegion Layer::VisibleContentOpaqueRegion() const {
1240 if (contents_opaque()) 1251 if (contents_opaque())
1241 return SimpleEnclosedRegion(visible_content_rect()); 1252 return SimpleEnclosedRegion(visible_content_rect());
1242 return SimpleEnclosedRegion(); 1253 return SimpleEnclosedRegion();
1243 } 1254 }
1244 1255
1245 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { 1256 ScrollbarLayerInterface* Layer::ToScrollbarLayer() {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 1386
1376 void Layer::DidBeginTracing() { 1387 void Layer::DidBeginTracing() {
1377 // We'll be dumping layer trees as part of trace, so make sure 1388 // We'll be dumping layer trees as part of trace, so make sure
1378 // PushPropertiesTo() propagates layer debug info to the impl 1389 // PushPropertiesTo() propagates layer debug info to the impl
1379 // side -- otherwise this won't happen for the the layers that 1390 // side -- otherwise this won't happen for the the layers that
1380 // remain unchanged since tracing started. 1391 // remain unchanged since tracing started.
1381 SetNeedsPushProperties(); 1392 SetNeedsPushProperties();
1382 } 1393 }
1383 1394
1384 } // namespace cc 1395 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_unittest.cc » ('j') | ui/compositor/layer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698