OLD | NEW |
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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 return; | 855 return; |
856 node->data.opacity = EffectiveOpacity(); | 856 node->data.opacity = EffectiveOpacity(); |
857 effect_tree.set_needs_update(true); | 857 effect_tree.set_needs_update(true); |
858 } | 858 } |
859 } | 859 } |
860 | 860 |
861 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() { | 861 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() { |
862 if (scrollable()) | 862 if (scrollable()) |
863 UpdatePropertyTreeScrollOffset(); | 863 UpdatePropertyTreeScrollOffset(); |
864 | 864 |
865 if (HasAnyAnimationTargetingProperty(Animation::OPACITY)) | 865 if (HasAnyAnimationTargetingProperty(TargetProperty::OPACITY)) |
866 UpdatePropertyTreeOpacity(); | 866 UpdatePropertyTreeOpacity(); |
867 | 867 |
868 if (HasAnyAnimationTargetingProperty(Animation::TRANSFORM)) { | 868 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) { |
869 UpdatePropertyTreeTransform(); | 869 UpdatePropertyTreeTransform(); |
870 UpdatePropertyTreeTransformIsAnimated( | 870 UpdatePropertyTreeTransformIsAnimated( |
871 HasPotentiallyRunningTransformAnimation()); | 871 HasPotentiallyRunningTransformAnimation()); |
872 } | 872 } |
873 } | 873 } |
874 | 874 |
875 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { | 875 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { |
876 return CurrentScrollOffset(); | 876 return CurrentScrollOffset(); |
877 } | 877 } |
878 | 878 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 filters_ = filters; | 1074 filters_ = filters; |
1075 NoteLayerPropertyChangedForSubtree(); | 1075 NoteLayerPropertyChangedForSubtree(); |
1076 } | 1076 } |
1077 | 1077 |
1078 bool LayerImpl::FilterIsAnimating() const { | 1078 bool LayerImpl::FilterIsAnimating() const { |
1079 LayerAnimationController::ObserverType observer_type = | 1079 LayerAnimationController::ObserverType observer_type = |
1080 IsActive() ? LayerAnimationController::ObserverType::ACTIVE | 1080 IsActive() ? LayerAnimationController::ObserverType::ACTIVE |
1081 : LayerAnimationController::ObserverType::PENDING; | 1081 : LayerAnimationController::ObserverType::PENDING; |
1082 return layer_animation_controller_ | 1082 return layer_animation_controller_ |
1083 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( | 1083 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( |
1084 Animation::FILTER, observer_type) | 1084 TargetProperty::FILTER, observer_type) |
1085 : layer_tree_impl_->IsAnimatingFilterProperty(this); | 1085 : layer_tree_impl_->IsAnimatingFilterProperty(this); |
1086 } | 1086 } |
1087 | 1087 |
1088 bool LayerImpl::HasPotentiallyRunningFilterAnimation() const { | 1088 bool LayerImpl::HasPotentiallyRunningFilterAnimation() const { |
1089 LayerAnimationController::ObserverType observer_type = | 1089 LayerAnimationController::ObserverType observer_type = |
1090 IsActive() ? LayerAnimationController::ObserverType::ACTIVE | 1090 IsActive() ? LayerAnimationController::ObserverType::ACTIVE |
1091 : LayerAnimationController::ObserverType::PENDING; | 1091 : LayerAnimationController::ObserverType::PENDING; |
1092 return layer_animation_controller_ | 1092 return layer_animation_controller_ |
1093 ? layer_animation_controller_->IsPotentiallyAnimatingProperty( | 1093 ? layer_animation_controller_->IsPotentiallyAnimatingProperty( |
1094 Animation::FILTER, observer_type) | 1094 TargetProperty::FILTER, observer_type) |
1095 : layer_tree_impl_->HasPotentiallyRunningFilterAnimation(this); | 1095 : layer_tree_impl_->HasPotentiallyRunningFilterAnimation(this); |
1096 } | 1096 } |
1097 | 1097 |
1098 bool LayerImpl::FilterIsAnimatingOnImplOnly() const { | 1098 bool LayerImpl::FilterIsAnimatingOnImplOnly() const { |
1099 if (!layer_animation_controller_) | 1099 if (!layer_animation_controller_) |
1100 return layer_tree_impl_->FilterIsAnimatingOnImplOnly(this); | 1100 return layer_tree_impl_->FilterIsAnimatingOnImplOnly(this); |
1101 | 1101 |
1102 Animation* filter_animation = | 1102 Animation* filter_animation = |
1103 layer_animation_controller_->GetAnimation(Animation::FILTER); | 1103 layer_animation_controller_->GetAnimation(TargetProperty::FILTER); |
1104 return filter_animation && filter_animation->is_impl_only(); | 1104 return filter_animation && filter_animation->is_impl_only(); |
1105 } | 1105 } |
1106 | 1106 |
1107 void LayerImpl::SetBackgroundFilters( | 1107 void LayerImpl::SetBackgroundFilters( |
1108 const FilterOperations& filters) { | 1108 const FilterOperations& filters) { |
1109 if (background_filters_ == filters) | 1109 if (background_filters_ == filters) |
1110 return; | 1110 return; |
1111 | 1111 |
1112 background_filters_ = filters; | 1112 background_filters_ = filters; |
1113 NoteLayerPropertyChanged(); | 1113 NoteLayerPropertyChanged(); |
(...skipping 24 matching lines...) Expand all Loading... |
1138 float LayerImpl::EffectiveOpacity() const { | 1138 float LayerImpl::EffectiveOpacity() const { |
1139 return hide_layer_and_subtree_ ? 0.f : opacity_; | 1139 return hide_layer_and_subtree_ ? 0.f : opacity_; |
1140 } | 1140 } |
1141 | 1141 |
1142 bool LayerImpl::OpacityIsAnimating() const { | 1142 bool LayerImpl::OpacityIsAnimating() const { |
1143 LayerAnimationController::ObserverType observer_type = | 1143 LayerAnimationController::ObserverType observer_type = |
1144 IsActive() ? LayerAnimationController::ObserverType::ACTIVE | 1144 IsActive() ? LayerAnimationController::ObserverType::ACTIVE |
1145 : LayerAnimationController::ObserverType::PENDING; | 1145 : LayerAnimationController::ObserverType::PENDING; |
1146 return layer_animation_controller_ | 1146 return layer_animation_controller_ |
1147 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( | 1147 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( |
1148 Animation::OPACITY, observer_type) | 1148 TargetProperty::OPACITY, observer_type) |
1149 : layer_tree_impl_->IsAnimatingOpacityProperty(this); | 1149 : layer_tree_impl_->IsAnimatingOpacityProperty(this); |
1150 } | 1150 } |
1151 | 1151 |
1152 bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const { | 1152 bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const { |
1153 LayerAnimationController::ObserverType observer_type = | 1153 LayerAnimationController::ObserverType observer_type = |
1154 IsActive() ? LayerAnimationController::ObserverType::ACTIVE | 1154 IsActive() ? LayerAnimationController::ObserverType::ACTIVE |
1155 : LayerAnimationController::ObserverType::PENDING; | 1155 : LayerAnimationController::ObserverType::PENDING; |
1156 return layer_animation_controller_ | 1156 return layer_animation_controller_ |
1157 ? layer_animation_controller_->IsPotentiallyAnimatingProperty( | 1157 ? layer_animation_controller_->IsPotentiallyAnimatingProperty( |
1158 Animation::OPACITY, observer_type) | 1158 TargetProperty::OPACITY, observer_type) |
1159 : layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this); | 1159 : layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this); |
1160 } | 1160 } |
1161 | 1161 |
1162 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { | 1162 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { |
1163 if (!layer_animation_controller_) | 1163 if (!layer_animation_controller_) |
1164 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this); | 1164 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this); |
1165 | 1165 |
1166 Animation* opacity_animation = | 1166 Animation* opacity_animation = |
1167 layer_animation_controller_->GetAnimation(Animation::OPACITY); | 1167 layer_animation_controller_->GetAnimation(TargetProperty::OPACITY); |
1168 return opacity_animation && opacity_animation->is_impl_only(); | 1168 return opacity_animation && opacity_animation->is_impl_only(); |
1169 } | 1169 } |
1170 | 1170 |
1171 void LayerImpl::SetElementId(uint64_t element_id) { | 1171 void LayerImpl::SetElementId(uint64_t element_id) { |
1172 if (element_id == element_id_) | 1172 if (element_id == element_id_) |
1173 return; | 1173 return; |
1174 | 1174 |
1175 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1175 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
1176 "LayerImpl::SetElementId", "id", element_id); | 1176 "LayerImpl::SetElementId", "id", element_id); |
1177 | 1177 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 transform_ = transform; | 1260 transform_ = transform; |
1261 transform_is_invertible_ = transform_is_invertible; | 1261 transform_is_invertible_ = transform_is_invertible; |
1262 } | 1262 } |
1263 | 1263 |
1264 bool LayerImpl::TransformIsAnimating() const { | 1264 bool LayerImpl::TransformIsAnimating() const { |
1265 LayerAnimationController::ObserverType observer_type = | 1265 LayerAnimationController::ObserverType observer_type = |
1266 IsActive() ? LayerAnimationController::ObserverType::ACTIVE | 1266 IsActive() ? LayerAnimationController::ObserverType::ACTIVE |
1267 : LayerAnimationController::ObserverType::PENDING; | 1267 : LayerAnimationController::ObserverType::PENDING; |
1268 return layer_animation_controller_ | 1268 return layer_animation_controller_ |
1269 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( | 1269 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( |
1270 Animation::TRANSFORM, observer_type) | 1270 TargetProperty::TRANSFORM, observer_type) |
1271 : layer_tree_impl_->IsAnimatingTransformProperty(this); | 1271 : layer_tree_impl_->IsAnimatingTransformProperty(this); |
1272 } | 1272 } |
1273 | 1273 |
1274 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const { | 1274 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const { |
1275 LayerAnimationController::ObserverType observer_type = | 1275 LayerAnimationController::ObserverType observer_type = |
1276 IsActive() ? LayerAnimationController::ObserverType::ACTIVE | 1276 IsActive() ? LayerAnimationController::ObserverType::ACTIVE |
1277 : LayerAnimationController::ObserverType::PENDING; | 1277 : LayerAnimationController::ObserverType::PENDING; |
1278 return layer_animation_controller_ | 1278 return layer_animation_controller_ |
1279 ? layer_animation_controller_->IsPotentiallyAnimatingProperty( | 1279 ? layer_animation_controller_->IsPotentiallyAnimatingProperty( |
1280 Animation::TRANSFORM, observer_type) | 1280 TargetProperty::TRANSFORM, observer_type) |
1281 : layer_tree_impl_->HasPotentiallyRunningTransformAnimation(this); | 1281 : layer_tree_impl_->HasPotentiallyRunningTransformAnimation(this); |
1282 } | 1282 } |
1283 | 1283 |
1284 bool LayerImpl::TransformIsAnimatingOnImplOnly() const { | 1284 bool LayerImpl::TransformIsAnimatingOnImplOnly() const { |
1285 if (!layer_animation_controller_) | 1285 if (!layer_animation_controller_) |
1286 return layer_tree_impl_->TransformIsAnimatingOnImplOnly(this); | 1286 return layer_tree_impl_->TransformIsAnimatingOnImplOnly(this); |
1287 | 1287 |
1288 Animation* transform_animation = | 1288 Animation* transform_animation = |
1289 layer_animation_controller_->GetAnimation(Animation::TRANSFORM); | 1289 layer_animation_controller_->GetAnimation(TargetProperty::TRANSFORM); |
1290 return transform_animation && transform_animation->is_impl_only(); | 1290 return transform_animation && transform_animation->is_impl_only(); |
1291 } | 1291 } |
1292 | 1292 |
1293 bool LayerImpl::HasOnlyTranslationTransforms() const { | 1293 bool LayerImpl::HasOnlyTranslationTransforms() const { |
1294 if (!layer_animation_controller_) | 1294 if (!layer_animation_controller_) |
1295 return layer_tree_impl_->HasOnlyTranslationTransforms(this); | 1295 return layer_tree_impl_->HasOnlyTranslationTransforms(this); |
1296 | 1296 |
1297 LayerAnimationController::ObserverType observer_type = | 1297 LayerAnimationController::ObserverType observer_type = |
1298 IsActive() ? LayerAnimationController::ObserverType::ACTIVE | 1298 IsActive() ? LayerAnimationController::ObserverType::ACTIVE |
1299 : LayerAnimationController::ObserverType::PENDING; | 1299 : LayerAnimationController::ObserverType::PENDING; |
(...skipping 23 matching lines...) Expand all Loading... |
1323 return layer_tree_impl_->AnimationStartScale(this, start_scale); | 1323 return layer_tree_impl_->AnimationStartScale(this, start_scale); |
1324 | 1324 |
1325 LayerAnimationController::ObserverType observer_type = | 1325 LayerAnimationController::ObserverType observer_type = |
1326 IsActive() ? LayerAnimationController::ObserverType::ACTIVE | 1326 IsActive() ? LayerAnimationController::ObserverType::ACTIVE |
1327 : LayerAnimationController::ObserverType::PENDING; | 1327 : LayerAnimationController::ObserverType::PENDING; |
1328 return layer_animation_controller_->AnimationStartScale(observer_type, | 1328 return layer_animation_controller_->AnimationStartScale(observer_type, |
1329 start_scale); | 1329 start_scale); |
1330 } | 1330 } |
1331 | 1331 |
1332 bool LayerImpl::HasAnyAnimationTargetingProperty( | 1332 bool LayerImpl::HasAnyAnimationTargetingProperty( |
1333 Animation::TargetProperty property) const { | 1333 TargetProperty::Type property) const { |
1334 if (!layer_animation_controller_) | 1334 if (!layer_animation_controller_) |
1335 return layer_tree_impl_->HasAnyAnimationTargetingProperty(this, property); | 1335 return layer_tree_impl_->HasAnyAnimationTargetingProperty(this, property); |
1336 | 1336 |
1337 return !!layer_animation_controller_->GetAnimation(property); | 1337 return !!layer_animation_controller_->GetAnimation(property); |
1338 } | 1338 } |
1339 | 1339 |
1340 bool LayerImpl::HasFilterAnimationThatInflatesBounds() const { | 1340 bool LayerImpl::HasFilterAnimationThatInflatesBounds() const { |
1341 if (!layer_animation_controller_) | 1341 if (!layer_animation_controller_) |
1342 return layer_tree_impl_->HasFilterAnimationThatInflatesBounds(this); | 1342 return layer_tree_impl_->HasFilterAnimationThatInflatesBounds(this); |
1343 | 1343 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } | 1684 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } |
1685 | 1685 |
1686 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1686 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
1687 benchmark->RunOnLayer(this); | 1687 benchmark->RunOnLayer(this); |
1688 } | 1688 } |
1689 | 1689 |
1690 int LayerImpl::NumDescendantsThatDrawContent() const { | 1690 int LayerImpl::NumDescendantsThatDrawContent() const { |
1691 return num_descendants_that_draw_content_; | 1691 return num_descendants_that_draw_content_; |
1692 } | 1692 } |
1693 | 1693 |
1694 void LayerImpl::NotifyAnimationFinished( | 1694 void LayerImpl::NotifyAnimationFinished(base::TimeTicks monotonic_time, |
1695 base::TimeTicks monotonic_time, | 1695 TargetProperty::Type target_property, |
1696 Animation::TargetProperty target_property, | 1696 int group) { |
1697 int group) { | 1697 if (target_property == TargetProperty::SCROLL_OFFSET) |
1698 if (target_property == Animation::SCROLL_OFFSET) | |
1699 layer_tree_impl_->InputScrollAnimationFinished(); | 1698 layer_tree_impl_->InputScrollAnimationFinished(); |
1700 } | 1699 } |
1701 | 1700 |
1702 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { | 1701 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { |
1703 if (!!render_surface() == should_have_render_surface) | 1702 if (!!render_surface() == should_have_render_surface) |
1704 return; | 1703 return; |
1705 | 1704 |
1706 SetNeedsPushProperties(); | 1705 SetNeedsPushProperties(); |
1707 if (should_have_render_surface) { | 1706 if (should_have_render_surface) { |
1708 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); | 1707 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 .layer_transforms_should_scale_layer_contents) { | 1778 .layer_transforms_should_scale_layer_contents) { |
1780 return default_scale; | 1779 return default_scale; |
1781 } | 1780 } |
1782 | 1781 |
1783 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1782 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
1784 DrawTransform(), default_scale); | 1783 DrawTransform(), default_scale); |
1785 return std::max(transform_scales.x(), transform_scales.y()); | 1784 return std::max(transform_scales.x(), transform_scales.y()); |
1786 } | 1785 } |
1787 | 1786 |
1788 } // namespace cc | 1787 } // namespace cc |
OLD | NEW |