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

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

Issue 1698813002: CC Animation: Expose TargetProperty enum to be aliased in Blink Platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use custom hash in unordered_set. Created 4 years, 10 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 return; 935 return;
936 node->data.opacity = EffectiveOpacity(); 936 node->data.opacity = EffectiveOpacity();
937 effect_tree.set_needs_update(true); 937 effect_tree.set_needs_update(true);
938 } 938 }
939 } 939 }
940 940
941 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() { 941 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() {
942 if (scrollable()) 942 if (scrollable())
943 UpdatePropertyTreeScrollOffset(); 943 UpdatePropertyTreeScrollOffset();
944 944
945 if (HasAnyAnimationTargetingProperty(Animation::OPACITY)) 945 if (HasAnyAnimationTargetingProperty(AnimationTargetProperty::OPACITY))
946 UpdatePropertyTreeOpacity(); 946 UpdatePropertyTreeOpacity();
947 947
948 if (HasAnyAnimationTargetingProperty(Animation::TRANSFORM)) { 948 if (HasAnyAnimationTargetingProperty(AnimationTargetProperty::TRANSFORM)) {
949 UpdatePropertyTreeTransform(); 949 UpdatePropertyTreeTransform();
950 UpdatePropertyTreeTransformIsAnimated( 950 UpdatePropertyTreeTransformIsAnimated(
951 HasPotentiallyRunningTransformAnimation()); 951 HasPotentiallyRunningTransformAnimation());
952 } 952 }
953 } 953 }
954 954
955 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { 955 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const {
956 return CurrentScrollOffset(); 956 return CurrentScrollOffset();
957 } 957 }
958 958
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 filters_ = filters; 1157 filters_ = filters;
1158 NoteLayerPropertyChangedForSubtree(); 1158 NoteLayerPropertyChangedForSubtree();
1159 } 1159 }
1160 1160
1161 bool LayerImpl::FilterIsAnimating() const { 1161 bool LayerImpl::FilterIsAnimating() const {
1162 LayerAnimationController::ObserverType observer_type = 1162 LayerAnimationController::ObserverType observer_type =
1163 IsActive() ? LayerAnimationController::ObserverType::ACTIVE 1163 IsActive() ? LayerAnimationController::ObserverType::ACTIVE
1164 : LayerAnimationController::ObserverType::PENDING; 1164 : LayerAnimationController::ObserverType::PENDING;
1165 return layer_animation_controller_ 1165 return layer_animation_controller_
1166 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( 1166 ? layer_animation_controller_->IsCurrentlyAnimatingProperty(
1167 Animation::FILTER, observer_type) 1167 AnimationTargetProperty::FILTER, observer_type)
1168 : layer_tree_impl_->IsAnimatingFilterProperty(this); 1168 : layer_tree_impl_->IsAnimatingFilterProperty(this);
1169 } 1169 }
1170 1170
1171 bool LayerImpl::HasPotentiallyRunningFilterAnimation() const { 1171 bool LayerImpl::HasPotentiallyRunningFilterAnimation() const {
1172 LayerAnimationController::ObserverType observer_type = 1172 LayerAnimationController::ObserverType observer_type =
1173 IsActive() ? LayerAnimationController::ObserverType::ACTIVE 1173 IsActive() ? LayerAnimationController::ObserverType::ACTIVE
1174 : LayerAnimationController::ObserverType::PENDING; 1174 : LayerAnimationController::ObserverType::PENDING;
1175 return layer_animation_controller_ 1175 return layer_animation_controller_
1176 ? layer_animation_controller_->IsPotentiallyAnimatingProperty( 1176 ? layer_animation_controller_->IsPotentiallyAnimatingProperty(
1177 Animation::FILTER, observer_type) 1177 AnimationTargetProperty::FILTER, observer_type)
1178 : layer_tree_impl_->HasPotentiallyRunningFilterAnimation(this); 1178 : layer_tree_impl_->HasPotentiallyRunningFilterAnimation(this);
1179 } 1179 }
1180 1180
1181 bool LayerImpl::FilterIsAnimatingOnImplOnly() const { 1181 bool LayerImpl::FilterIsAnimatingOnImplOnly() const {
1182 if (!layer_animation_controller_) 1182 if (!layer_animation_controller_)
1183 return layer_tree_impl_->FilterIsAnimatingOnImplOnly(this); 1183 return layer_tree_impl_->FilterIsAnimatingOnImplOnly(this);
1184 1184
1185 Animation* filter_animation = 1185 Animation* filter_animation = layer_animation_controller_->GetAnimation(
1186 layer_animation_controller_->GetAnimation(Animation::FILTER); 1186 AnimationTargetProperty::FILTER);
1187 return filter_animation && filter_animation->is_impl_only(); 1187 return filter_animation && filter_animation->is_impl_only();
1188 } 1188 }
1189 1189
1190 void LayerImpl::SetBackgroundFilters( 1190 void LayerImpl::SetBackgroundFilters(
1191 const FilterOperations& filters) { 1191 const FilterOperations& filters) {
1192 if (background_filters_ == filters) 1192 if (background_filters_ == filters)
1193 return; 1193 return;
1194 1194
1195 background_filters_ = filters; 1195 background_filters_ = filters;
1196 NoteLayerPropertyChanged(); 1196 NoteLayerPropertyChanged();
(...skipping 24 matching lines...) Expand all
1221 float LayerImpl::EffectiveOpacity() const { 1221 float LayerImpl::EffectiveOpacity() const {
1222 return hide_layer_and_subtree_ ? 0.f : opacity_; 1222 return hide_layer_and_subtree_ ? 0.f : opacity_;
1223 } 1223 }
1224 1224
1225 bool LayerImpl::OpacityIsAnimating() const { 1225 bool LayerImpl::OpacityIsAnimating() const {
1226 LayerAnimationController::ObserverType observer_type = 1226 LayerAnimationController::ObserverType observer_type =
1227 IsActive() ? LayerAnimationController::ObserverType::ACTIVE 1227 IsActive() ? LayerAnimationController::ObserverType::ACTIVE
1228 : LayerAnimationController::ObserverType::PENDING; 1228 : LayerAnimationController::ObserverType::PENDING;
1229 return layer_animation_controller_ 1229 return layer_animation_controller_
1230 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( 1230 ? layer_animation_controller_->IsCurrentlyAnimatingProperty(
1231 Animation::OPACITY, observer_type) 1231 AnimationTargetProperty::OPACITY, observer_type)
1232 : layer_tree_impl_->IsAnimatingOpacityProperty(this); 1232 : layer_tree_impl_->IsAnimatingOpacityProperty(this);
1233 } 1233 }
1234 1234
1235 bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const { 1235 bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const {
1236 LayerAnimationController::ObserverType observer_type = 1236 LayerAnimationController::ObserverType observer_type =
1237 IsActive() ? LayerAnimationController::ObserverType::ACTIVE 1237 IsActive() ? LayerAnimationController::ObserverType::ACTIVE
1238 : LayerAnimationController::ObserverType::PENDING; 1238 : LayerAnimationController::ObserverType::PENDING;
1239 return layer_animation_controller_ 1239 return layer_animation_controller_
1240 ? layer_animation_controller_->IsPotentiallyAnimatingProperty( 1240 ? layer_animation_controller_->IsPotentiallyAnimatingProperty(
1241 Animation::OPACITY, observer_type) 1241 AnimationTargetProperty::OPACITY, observer_type)
1242 : layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this); 1242 : layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this);
1243 } 1243 }
1244 1244
1245 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { 1245 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const {
1246 if (!layer_animation_controller_) 1246 if (!layer_animation_controller_)
1247 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this); 1247 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this);
1248 1248
1249 Animation* opacity_animation = 1249 Animation* opacity_animation = layer_animation_controller_->GetAnimation(
1250 layer_animation_controller_->GetAnimation(Animation::OPACITY); 1250 AnimationTargetProperty::OPACITY);
1251 return opacity_animation && opacity_animation->is_impl_only(); 1251 return opacity_animation && opacity_animation->is_impl_only();
1252 } 1252 }
1253 1253
1254 void LayerImpl::SetElementId(uint64_t element_id) { 1254 void LayerImpl::SetElementId(uint64_t element_id) {
1255 if (element_id == element_id_) 1255 if (element_id == element_id_)
1256 return; 1256 return;
1257 1257
1258 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 1258 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1259 "LayerImpl::SetElementId", "id", element_id); 1259 "LayerImpl::SetElementId", "id", element_id);
1260 1260
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 transform_is_invertible_ = transform_is_invertible; 1345 transform_is_invertible_ = transform_is_invertible;
1346 NoteLayerPropertyChangedForSubtree(); 1346 NoteLayerPropertyChangedForSubtree();
1347 } 1347 }
1348 1348
1349 bool LayerImpl::TransformIsAnimating() const { 1349 bool LayerImpl::TransformIsAnimating() const {
1350 LayerAnimationController::ObserverType observer_type = 1350 LayerAnimationController::ObserverType observer_type =
1351 IsActive() ? LayerAnimationController::ObserverType::ACTIVE 1351 IsActive() ? LayerAnimationController::ObserverType::ACTIVE
1352 : LayerAnimationController::ObserverType::PENDING; 1352 : LayerAnimationController::ObserverType::PENDING;
1353 return layer_animation_controller_ 1353 return layer_animation_controller_
1354 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( 1354 ? layer_animation_controller_->IsCurrentlyAnimatingProperty(
1355 Animation::TRANSFORM, observer_type) 1355 AnimationTargetProperty::TRANSFORM, observer_type)
1356 : layer_tree_impl_->IsAnimatingTransformProperty(this); 1356 : layer_tree_impl_->IsAnimatingTransformProperty(this);
1357 } 1357 }
1358 1358
1359 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const { 1359 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const {
1360 LayerAnimationController::ObserverType observer_type = 1360 LayerAnimationController::ObserverType observer_type =
1361 IsActive() ? LayerAnimationController::ObserverType::ACTIVE 1361 IsActive() ? LayerAnimationController::ObserverType::ACTIVE
1362 : LayerAnimationController::ObserverType::PENDING; 1362 : LayerAnimationController::ObserverType::PENDING;
1363 return layer_animation_controller_ 1363 return layer_animation_controller_
1364 ? layer_animation_controller_->IsPotentiallyAnimatingProperty( 1364 ? layer_animation_controller_->IsPotentiallyAnimatingProperty(
1365 Animation::TRANSFORM, observer_type) 1365 AnimationTargetProperty::TRANSFORM, observer_type)
1366 : layer_tree_impl_->HasPotentiallyRunningTransformAnimation(this); 1366 : layer_tree_impl_->HasPotentiallyRunningTransformAnimation(this);
1367 } 1367 }
1368 1368
1369 bool LayerImpl::TransformIsAnimatingOnImplOnly() const { 1369 bool LayerImpl::TransformIsAnimatingOnImplOnly() const {
1370 if (!layer_animation_controller_) 1370 if (!layer_animation_controller_)
1371 return layer_tree_impl_->TransformIsAnimatingOnImplOnly(this); 1371 return layer_tree_impl_->TransformIsAnimatingOnImplOnly(this);
1372 1372
1373 Animation* transform_animation = 1373 Animation* transform_animation = layer_animation_controller_->GetAnimation(
1374 layer_animation_controller_->GetAnimation(Animation::TRANSFORM); 1374 AnimationTargetProperty::TRANSFORM);
1375 return transform_animation && transform_animation->is_impl_only(); 1375 return transform_animation && transform_animation->is_impl_only();
1376 } 1376 }
1377 1377
1378 bool LayerImpl::HasOnlyTranslationTransforms() const { 1378 bool LayerImpl::HasOnlyTranslationTransforms() const {
1379 if (!layer_animation_controller_) 1379 if (!layer_animation_controller_)
1380 return layer_tree_impl_->HasOnlyTranslationTransforms(this); 1380 return layer_tree_impl_->HasOnlyTranslationTransforms(this);
1381 1381
1382 LayerAnimationController::ObserverType observer_type = 1382 LayerAnimationController::ObserverType observer_type =
1383 IsActive() ? LayerAnimationController::ObserverType::ACTIVE 1383 IsActive() ? LayerAnimationController::ObserverType::ACTIVE
1384 : LayerAnimationController::ObserverType::PENDING; 1384 : LayerAnimationController::ObserverType::PENDING;
(...skipping 23 matching lines...) Expand all
1408 return layer_tree_impl_->AnimationStartScale(this, start_scale); 1408 return layer_tree_impl_->AnimationStartScale(this, start_scale);
1409 1409
1410 LayerAnimationController::ObserverType observer_type = 1410 LayerAnimationController::ObserverType observer_type =
1411 IsActive() ? LayerAnimationController::ObserverType::ACTIVE 1411 IsActive() ? LayerAnimationController::ObserverType::ACTIVE
1412 : LayerAnimationController::ObserverType::PENDING; 1412 : LayerAnimationController::ObserverType::PENDING;
1413 return layer_animation_controller_->AnimationStartScale(observer_type, 1413 return layer_animation_controller_->AnimationStartScale(observer_type,
1414 start_scale); 1414 start_scale);
1415 } 1415 }
1416 1416
1417 bool LayerImpl::HasAnyAnimationTargetingProperty( 1417 bool LayerImpl::HasAnyAnimationTargetingProperty(
1418 Animation::TargetProperty property) const { 1418 AnimationTargetProperty property) const {
1419 if (!layer_animation_controller_) 1419 if (!layer_animation_controller_)
1420 return layer_tree_impl_->HasAnyAnimationTargetingProperty(this, property); 1420 return layer_tree_impl_->HasAnyAnimationTargetingProperty(this, property);
1421 1421
1422 return !!layer_animation_controller_->GetAnimation(property); 1422 return !!layer_animation_controller_->GetAnimation(property);
1423 } 1423 }
1424 1424
1425 bool LayerImpl::HasFilterAnimationThatInflatesBounds() const { 1425 bool LayerImpl::HasFilterAnimationThatInflatesBounds() const {
1426 if (!layer_animation_controller_) 1426 if (!layer_animation_controller_)
1427 return layer_tree_impl_->HasFilterAnimationThatInflatesBounds(this); 1427 return layer_tree_impl_->HasFilterAnimationThatInflatesBounds(this);
1428 1428
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } 1769 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
1770 1770
1771 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { 1771 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) {
1772 benchmark->RunOnLayer(this); 1772 benchmark->RunOnLayer(this);
1773 } 1773 }
1774 1774
1775 int LayerImpl::NumDescendantsThatDrawContent() const { 1775 int LayerImpl::NumDescendantsThatDrawContent() const {
1776 return num_descendants_that_draw_content_; 1776 return num_descendants_that_draw_content_;
1777 } 1777 }
1778 1778
1779 void LayerImpl::NotifyAnimationFinished( 1779 void LayerImpl::NotifyAnimationFinished(base::TimeTicks monotonic_time,
1780 base::TimeTicks monotonic_time, 1780 AnimationTargetProperty target_property,
1781 Animation::TargetProperty target_property, 1781 int group) {
1782 int group) { 1782 if (target_property == AnimationTargetProperty::SCROLL_OFFSET)
1783 if (target_property == Animation::SCROLL_OFFSET)
1784 layer_tree_impl_->InputScrollAnimationFinished(); 1783 layer_tree_impl_->InputScrollAnimationFinished();
1785 } 1784 }
1786 1785
1787 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { 1786 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) {
1788 if (!!render_surface() == should_have_render_surface) 1787 if (!!render_surface() == should_have_render_surface)
1789 return; 1788 return;
1790 1789
1791 SetNeedsPushProperties(); 1790 SetNeedsPushProperties();
1792 if (should_have_render_surface) { 1791 if (should_have_render_surface) {
1793 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); 1792 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 .layer_transforms_should_scale_layer_contents) { 1871 .layer_transforms_should_scale_layer_contents) {
1873 return default_scale; 1872 return default_scale;
1874 } 1873 }
1875 1874
1876 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1875 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1877 DrawTransform(), default_scale); 1876 DrawTransform(), default_scale);
1878 return std::max(transform_scales.x(), transform_scales.y()); 1877 return std::max(transform_scales.x(), transform_scales.y());
1879 } 1878 }
1880 1879
1881 } // namespace cc 1880 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698