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

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

Issue 1130043003: [Sketch] CC Animations: Torpedo the old intrusive animation system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@implscroll
Patch Set: Delete more (headers and animation_registrar_ leftover) 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
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "base/trace_event/trace_event_argument.h" 10 #include "base/trace_event/trace_event_argument.h"
11 #include "cc/animation/animation_registrar.h"
12 #include "cc/animation/scrollbar_animation_controller.h" 11 #include "cc/animation/scrollbar_animation_controller.h"
13 #include "cc/base/math_util.h" 12 #include "cc/base/math_util.h"
14 #include "cc/base/simple_enclosed_region.h" 13 #include "cc/base/simple_enclosed_region.h"
15 #include "cc/debug/debug_colors.h" 14 #include "cc/debug/debug_colors.h"
16 #include "cc/debug/layer_tree_debug_state.h" 15 #include "cc/debug/layer_tree_debug_state.h"
17 #include "cc/debug/micro_benchmark_impl.h" 16 #include "cc/debug/micro_benchmark_impl.h"
18 #include "cc/debug/traced_value.h" 17 #include "cc/debug/traced_value.h"
19 #include "cc/layers/layer_utils.h" 18 #include "cc/layers/layer_utils.h"
20 #include "cc/layers/painted_scrollbar_layer_impl.h" 19 #include "cc/layers/painted_scrollbar_layer_impl.h"
21 #include "cc/output/copy_output_request.h" 20 #include "cc/output/copy_output_request.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 draw_depth_(0.f), 78 draw_depth_(0.f),
80 needs_push_properties_(false), 79 needs_push_properties_(false),
81 num_dependents_need_push_properties_(0), 80 num_dependents_need_push_properties_(0),
82 sorting_context_id_(0), 81 sorting_context_id_(0),
83 current_draw_mode_(DRAW_MODE_NONE), 82 current_draw_mode_(DRAW_MODE_NONE),
84 frame_timing_requests_dirty_(false) { 83 frame_timing_requests_dirty_(false) {
85 DCHECK_GT(layer_id_, 0); 84 DCHECK_GT(layer_id_, 0);
86 DCHECK(layer_tree_impl_); 85 DCHECK(layer_tree_impl_);
87 layer_tree_impl_->RegisterLayer(this); 86 layer_tree_impl_->RegisterLayer(this);
88 87
89 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) {
90 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar();
91 layer_animation_controller_ =
92 registrar->GetAnimationControllerForId(layer_id_);
93 layer_animation_controller_->AddValueObserver(this);
94 if (IsActive()) {
95 layer_animation_controller_->set_value_provider(this);
96 layer_animation_controller_->set_layer_animation_delegate(this);
97 }
98 }
99 SetNeedsPushProperties(); 88 SetNeedsPushProperties();
100 } 89 }
101 90
102 LayerImpl::~LayerImpl() { 91 LayerImpl::~LayerImpl() {
103 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); 92 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_);
104 93
105 if (layer_animation_controller_) {
106 layer_animation_controller_->RemoveValueObserver(this);
107 layer_animation_controller_->remove_value_provider(this);
108 layer_animation_controller_->remove_layer_animation_delegate(this);
109 }
110
111 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree()) 94 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree())
112 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); 95 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this);
113 layer_tree_impl_->UnregisterLayer(this); 96 layer_tree_impl_->UnregisterLayer(this);
114 97
115 TRACE_EVENT_OBJECT_DELETED_WITH_ID( 98 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
116 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); 99 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this);
117 } 100 }
118 101
119 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { 102 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) {
120 child->SetParent(this); 103 child->SetParent(this);
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 // layers in the pending tree will find out about these changes as a 800 // layers in the pending tree will find out about these changes as a
818 // result of the shared SyncedProperty. 801 // result of the shared SyncedProperty.
819 if (!IsActive()) 802 if (!IsActive())
820 return; 803 return;
821 804
822 SetCurrentScrollOffset(scroll_offset); 805 SetCurrentScrollOffset(scroll_offset);
823 806
824 layer_tree_impl_->DidAnimateScrollOffset(); 807 layer_tree_impl_->DidAnimateScrollOffset();
825 } 808 }
826 809
827 void LayerImpl::OnAnimationWaitingForDeletion() {}
828
829 bool LayerImpl::IsActive() const { 810 bool LayerImpl::IsActive() const {
830 return layer_tree_impl_->IsActiveTree(); 811 return layer_tree_impl_->IsActiveTree();
831 } 812 }
832 813
833 gfx::Size LayerImpl::bounds() const { 814 gfx::Size LayerImpl::bounds() const {
834 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_); 815 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_);
835 return gfx::Size(bounds_.width() + delta.x(), 816 return gfx::Size(bounds_.width() + delta.x(),
836 bounds_.height() + delta.y()); 817 bounds_.height() + delta.y());
837 } 818 }
838 819
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 948
968 void LayerImpl::SetFilters(const FilterOperations& filters) { 949 void LayerImpl::SetFilters(const FilterOperations& filters) {
969 if (filters_ == filters) 950 if (filters_ == filters)
970 return; 951 return;
971 952
972 filters_ = filters; 953 filters_ = filters;
973 NoteLayerPropertyChangedForSubtree(); 954 NoteLayerPropertyChangedForSubtree();
974 } 955 }
975 956
976 bool LayerImpl::FilterIsAnimating() const { 957 bool LayerImpl::FilterIsAnimating() const {
977 return layer_animation_controller_ 958 return layer_tree_impl_->IsAnimatingFilterProperty(this);
978 ? layer_animation_controller_->IsAnimatingProperty(
979 Animation::FILTER)
980 : layer_tree_impl_->IsAnimatingFilterProperty(this);
981 } 959 }
982 960
983 bool LayerImpl::FilterIsAnimatingOnImplOnly() const { 961 bool LayerImpl::FilterIsAnimatingOnImplOnly() const {
984 if (!layer_animation_controller_) 962 return layer_tree_impl_->FilterIsAnimatingOnImplOnly(this);
985 return layer_tree_impl_->FilterIsAnimatingOnImplOnly(this);
986
987 Animation* filter_animation =
988 layer_animation_controller_->GetAnimation(Animation::FILTER);
989 return filter_animation && filter_animation->is_impl_only();
990 } 963 }
991 964
992 void LayerImpl::SetBackgroundFilters( 965 void LayerImpl::SetBackgroundFilters(
993 const FilterOperations& filters) { 966 const FilterOperations& filters) {
994 if (background_filters_ == filters) 967 if (background_filters_ == filters)
995 return; 968 return;
996 969
997 background_filters_ = filters; 970 background_filters_ = filters;
998 NoteLayerPropertyChanged(); 971 NoteLayerPropertyChanged();
999 } 972 }
(...skipping 16 matching lines...) Expand all
1016 989
1017 void LayerImpl::SetOpacity(float opacity) { 990 void LayerImpl::SetOpacity(float opacity) {
1018 if (opacity_ == opacity) 991 if (opacity_ == opacity)
1019 return; 992 return;
1020 993
1021 opacity_ = opacity; 994 opacity_ = opacity;
1022 NoteLayerPropertyChangedForSubtree(); 995 NoteLayerPropertyChangedForSubtree();
1023 } 996 }
1024 997
1025 bool LayerImpl::OpacityIsAnimating() const { 998 bool LayerImpl::OpacityIsAnimating() const {
1026 return layer_animation_controller_ 999 return layer_tree_impl_->IsAnimatingOpacityProperty(this);
1027 ? layer_animation_controller_->IsAnimatingProperty(
1028 Animation::OPACITY)
1029 : layer_tree_impl_->IsAnimatingOpacityProperty(this);
1030 } 1000 }
1031 1001
1032 bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const { 1002 bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const {
1033 if (layer_animation_controller_) { 1003 return layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this);
1034 if (Animation* animation =
1035 layer_animation_controller()->GetAnimation(Animation::OPACITY)) {
1036 return !animation->is_finished();
1037 }
1038 return false;
1039 } else {
1040 return layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this);
1041 }
1042 } 1004 }
1043 1005
1044 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { 1006 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const {
1045 if (!layer_animation_controller_) 1007 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this);
1046 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this);
1047
1048 Animation* opacity_animation =
1049 layer_animation_controller_->GetAnimation(Animation::OPACITY);
1050 return opacity_animation && opacity_animation->is_impl_only();
1051 } 1008 }
1052 1009
1053 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { 1010 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) {
1054 if (blend_mode_ == blend_mode) 1011 if (blend_mode_ == blend_mode)
1055 return; 1012 return;
1056 1013
1057 blend_mode_ = blend_mode; 1014 blend_mode_ = blend_mode;
1058 NoteLayerPropertyChangedForSubtree(); 1015 NoteLayerPropertyChangedForSubtree();
1059 } 1016 }
1060 1017
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 DCHECK(transform_is_invertible_ == transform_is_invertible) 1073 DCHECK(transform_is_invertible_ == transform_is_invertible)
1117 << "Can't change invertibility if transform is unchanged"; 1074 << "Can't change invertibility if transform is unchanged";
1118 return; 1075 return;
1119 } 1076 }
1120 transform_ = transform; 1077 transform_ = transform;
1121 transform_is_invertible_ = transform_is_invertible; 1078 transform_is_invertible_ = transform_is_invertible;
1122 NoteLayerPropertyChangedForSubtree(); 1079 NoteLayerPropertyChangedForSubtree();
1123 } 1080 }
1124 1081
1125 bool LayerImpl::TransformIsAnimating() const { 1082 bool LayerImpl::TransformIsAnimating() const {
1126 return layer_animation_controller_ 1083 return layer_tree_impl_->IsAnimatingTransformProperty(this);
1127 ? layer_animation_controller_->IsAnimatingProperty(
1128 Animation::TRANSFORM)
1129 : layer_tree_impl_->IsAnimatingTransformProperty(this);
1130 } 1084 }
1131 1085
1132 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const { 1086 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const {
1133 if (layer_animation_controller_) { 1087 return layer_tree_impl_->HasPotentiallyRunningTransformAnimation(this);
1134 if (Animation* animation =
1135 layer_animation_controller()->GetAnimation(Animation::TRANSFORM)) {
1136 return !animation->is_finished();
1137 }
1138 return false;
1139 } else {
1140 return layer_tree_impl_->HasPotentiallyRunningTransformAnimation(this);
1141 }
1142 } 1088 }
1143 1089
1144 bool LayerImpl::TransformIsAnimatingOnImplOnly() const { 1090 bool LayerImpl::TransformIsAnimatingOnImplOnly() const {
1145 if (!layer_animation_controller_) 1091 return layer_tree_impl_->TransformIsAnimatingOnImplOnly(this);
1146 return layer_tree_impl_->TransformIsAnimatingOnImplOnly(this);
1147
1148 Animation* transform_animation =
1149 layer_animation_controller_->GetAnimation(Animation::TRANSFORM);
1150 return transform_animation && transform_animation->is_impl_only();
1151 } 1092 }
1152 1093
1153 bool LayerImpl::HasOnlyTranslationTransforms() const { 1094 bool LayerImpl::HasOnlyTranslationTransforms() const {
1154 if (!layer_animation_controller_) 1095 return layer_tree_impl_->HasOnlyTranslationTransforms(this);
1155 return layer_tree_impl_->HasOnlyTranslationTransforms(this);
1156
1157 return layer_animation_controller_->HasOnlyTranslationTransforms();
1158 } 1096 }
1159 1097
1160 bool LayerImpl::MaximumTargetScale(float* max_scale) const { 1098 bool LayerImpl::MaximumTargetScale(float* max_scale) const {
1161 if (!layer_animation_controller_) 1099 return layer_tree_impl_->MaximumTargetScale(this, max_scale);
1162 return layer_tree_impl_->MaximumTargetScale(this, max_scale);
1163
1164 return layer_animation_controller_->MaximumTargetScale(max_scale);
1165 } 1100 }
1166 1101
1167 bool LayerImpl::HasFilterAnimationThatInflatesBounds() const { 1102 bool LayerImpl::HasFilterAnimationThatInflatesBounds() const {
1168 if (!layer_animation_controller_) 1103 return layer_tree_impl_->HasFilterAnimationThatInflatesBounds(this);
1169 return layer_tree_impl_->HasFilterAnimationThatInflatesBounds(this);
1170
1171 return layer_animation_controller_->HasFilterAnimationThatInflatesBounds();
1172 } 1104 }
1173 1105
1174 bool LayerImpl::HasTransformAnimationThatInflatesBounds() const { 1106 bool LayerImpl::HasTransformAnimationThatInflatesBounds() const {
1175 if (!layer_animation_controller_) 1107 return layer_tree_impl_->HasTransformAnimationThatInflatesBounds(this);
1176 return layer_tree_impl_->HasTransformAnimationThatInflatesBounds(this);
1177
1178 return layer_animation_controller_->HasTransformAnimationThatInflatesBounds();
1179 } 1108 }
1180 1109
1181 bool LayerImpl::HasAnimationThatInflatesBounds() const { 1110 bool LayerImpl::HasAnimationThatInflatesBounds() const {
1182 if (!layer_animation_controller_) 1111 return layer_tree_impl_->HasAnimationThatInflatesBounds(this);
1183 return layer_tree_impl_->HasAnimationThatInflatesBounds(this);
1184
1185 return layer_animation_controller_->HasAnimationThatInflatesBounds();
1186 } 1112 }
1187 1113
1188 bool LayerImpl::FilterAnimationBoundsForBox(const gfx::BoxF& box, 1114 bool LayerImpl::FilterAnimationBoundsForBox(const gfx::BoxF& box,
1189 gfx::BoxF* bounds) const { 1115 gfx::BoxF* bounds) const {
1190 if (!layer_animation_controller_) 1116 return layer_tree_impl_->FilterAnimationBoundsForBox(this, box, bounds);
1191 return layer_tree_impl_->FilterAnimationBoundsForBox(this, box, bounds);
1192
1193 return layer_animation_controller_->FilterAnimationBoundsForBox(box, bounds);
1194 } 1117 }
1195 1118
1196 bool LayerImpl::TransformAnimationBoundsForBox(const gfx::BoxF& box, 1119 bool LayerImpl::TransformAnimationBoundsForBox(const gfx::BoxF& box,
1197 gfx::BoxF* bounds) const { 1120 gfx::BoxF* bounds) const {
1198 if (!layer_animation_controller_) 1121 return layer_tree_impl_->TransformAnimationBoundsForBox(this, box, bounds);
1199 return layer_tree_impl_->TransformAnimationBoundsForBox(this, box, bounds);
1200
1201 return layer_animation_controller_->TransformAnimationBoundsForBox(box,
1202 bounds);
1203 } 1122 }
1204 1123
1205 void LayerImpl::SetUpdateRect(const gfx::Rect& update_rect) { 1124 void LayerImpl::SetUpdateRect(const gfx::Rect& update_rect) {
1206 update_rect_ = update_rect; 1125 update_rect_ = update_rect;
1207 SetNeedsPushProperties(); 1126 SetNeedsPushProperties();
1208 } 1127 }
1209 1128
1210 void LayerImpl::AddDamageRect(const gfx::RectF& damage_rect) { 1129 void LayerImpl::AddDamageRect(const gfx::RectF& damage_rect) {
1211 damage_rect_ = gfx::UnionRects(damage_rect_, damage_rect); 1130 damage_rect_ = gfx::UnionRects(damage_rect_, damage_rect);
1212 } 1131 }
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 1556
1638 if (scroll_parent_) 1557 if (scroll_parent_)
1639 state->SetInteger("scroll_parent", scroll_parent_->id()); 1558 state->SetInteger("scroll_parent", scroll_parent_->id());
1640 1559
1641 if (clip_parent_) 1560 if (clip_parent_)
1642 state->SetInteger("clip_parent", clip_parent_->id()); 1561 state->SetInteger("clip_parent", clip_parent_->id());
1643 1562
1644 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); 1563 state->SetBoolean("can_use_lcd_text", can_use_lcd_text());
1645 state->SetBoolean("contents_opaque", contents_opaque()); 1564 state->SetBoolean("contents_opaque", contents_opaque());
1646 1565
1647 state->SetBoolean( 1566 state->SetBoolean("has_animation_bounds",
1648 "has_animation_bounds", 1567 layer_tree_impl_->HasAnimationThatInflatesBounds(this));
1649 layer_animation_controller_
1650 ? layer_animation_controller_->HasAnimationThatInflatesBounds()
1651 : layer_tree_impl_->HasAnimationThatInflatesBounds(this));
1652 1568
1653 gfx::BoxF box; 1569 gfx::BoxF box;
1654 if (LayerUtils::GetAnimationBounds(*this, &box)) 1570 if (LayerUtils::GetAnimationBounds(*this, &box))
1655 MathUtil::AddToTracedValue("animation_bounds", box, state); 1571 MathUtil::AddToTracedValue("animation_bounds", box, state);
1656 1572
1657 if (debug_info_.get()) { 1573 if (debug_info_.get()) {
1658 std::string str; 1574 std::string str;
1659 debug_info_->AppendAsTraceFormat(&str); 1575 debug_info_->AppendAsTraceFormat(&str);
1660 base::JSONReader json_reader; 1576 base::JSONReader json_reader;
1661 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); 1577 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } 1610 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
1695 1611
1696 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { 1612 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) {
1697 benchmark->RunOnLayer(this); 1613 benchmark->RunOnLayer(this);
1698 } 1614 }
1699 1615
1700 int LayerImpl::NumDescendantsThatDrawContent() const { 1616 int LayerImpl::NumDescendantsThatDrawContent() const {
1701 return num_descendants_that_draw_content_; 1617 return num_descendants_that_draw_content_;
1702 } 1618 }
1703 1619
1704 void LayerImpl::NotifyAnimationFinished(
1705 base::TimeTicks monotonic_time,
1706 Animation::TargetProperty target_property,
1707 int group) {
1708 if (target_property == Animation::SCROLL_OFFSET)
1709 layer_tree_impl_->InputScrollAnimationFinished();
1710 }
1711
1712 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { 1620 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) {
1713 if (!!render_surface() == should_have_render_surface) 1621 if (!!render_surface() == should_have_render_surface)
1714 return; 1622 return;
1715 1623
1716 SetNeedsPushProperties(); 1624 SetNeedsPushProperties();
1717 layer_tree_impl()->set_needs_update_draw_properties(); 1625 layer_tree_impl()->set_needs_update_draw_properties();
1718 if (should_have_render_surface) { 1626 if (should_have_render_surface) {
1719 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); 1627 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this));
1720 return; 1628 return;
1721 } 1629 }
(...skipping 14 matching lines...) Expand all
1736 gfx::Transform scaled_draw_transform = 1644 gfx::Transform scaled_draw_transform =
1737 draw_properties_.target_space_transform; 1645 draw_properties_.target_space_transform;
1738 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); 1646 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale);
1739 gfx::Size scaled_content_bounds = 1647 gfx::Size scaled_content_bounds =
1740 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), scale)); 1648 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), scale));
1741 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, 1649 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform,
1742 gfx::Rect(scaled_content_bounds)); 1650 gfx::Rect(scaled_content_bounds));
1743 } 1651 }
1744 1652
1745 } // namespace cc 1653 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698