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

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

Issue 1010663002: CC Animations: Redirect all compositor animation requests to AnimationHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@introduce
Patch Set: Add ported unittests. 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 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"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 num_descendants_that_draw_content_(0), 74 num_descendants_that_draw_content_(0),
75 draw_depth_(0.f), 75 draw_depth_(0.f),
76 needs_push_properties_(false), 76 needs_push_properties_(false),
77 num_dependents_need_push_properties_(0), 77 num_dependents_need_push_properties_(0),
78 sorting_context_id_(0), 78 sorting_context_id_(0),
79 current_draw_mode_(DRAW_MODE_NONE), 79 current_draw_mode_(DRAW_MODE_NONE),
80 frame_timing_requests_dirty_(false) { 80 frame_timing_requests_dirty_(false) {
81 DCHECK_GT(layer_id_, 0); 81 DCHECK_GT(layer_id_, 0);
82 DCHECK(layer_tree_impl_); 82 DCHECK(layer_tree_impl_);
83 layer_tree_impl_->RegisterLayer(this); 83 layer_tree_impl_->RegisterLayer(this);
84 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); 84
85 layer_animation_controller_ = 85 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) {
86 registrar->GetAnimationControllerForId(layer_id_); 86 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar();
87 layer_animation_controller_->AddValueObserver(this); 87 layer_animation_controller_ =
88 if (IsActive()) { 88 registrar->GetAnimationControllerForId(layer_id_);
89 layer_animation_controller_->set_value_provider(this); 89 layer_animation_controller_->AddValueObserver(this);
90 layer_animation_controller_->set_layer_animation_delegate(this); 90 if (IsActive()) {
91 layer_animation_controller_->set_value_provider(this);
92 layer_animation_controller_->set_layer_animation_delegate(this);
93 }
91 } 94 }
92 SetNeedsPushProperties(); 95 SetNeedsPushProperties();
93 } 96 }
94 97
95 LayerImpl::~LayerImpl() { 98 LayerImpl::~LayerImpl() {
96 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); 99 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_);
97 100
98 layer_animation_controller_->RemoveValueObserver(this); 101 if (layer_animation_controller_) {
99 layer_animation_controller_->remove_value_provider(this); 102 layer_animation_controller_->RemoveValueObserver(this);
100 layer_animation_controller_->remove_layer_animation_delegate(this); 103 layer_animation_controller_->remove_value_provider(this);
104 layer_animation_controller_->remove_layer_animation_delegate(this);
105 }
101 106
102 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree()) 107 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree())
103 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); 108 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this);
104 layer_tree_impl_->UnregisterLayer(this); 109 layer_tree_impl_->UnregisterLayer(this);
105 110
106 TRACE_EVENT_OBJECT_DELETED_WITH_ID( 111 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
107 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); 112 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this);
108 } 113 }
109 114
110 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { 115 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) {
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 937
933 void LayerImpl::SetFilters(const FilterOperations& filters) { 938 void LayerImpl::SetFilters(const FilterOperations& filters) {
934 if (filters_ == filters) 939 if (filters_ == filters)
935 return; 940 return;
936 941
937 filters_ = filters; 942 filters_ = filters;
938 NoteLayerPropertyChangedForSubtree(); 943 NoteLayerPropertyChangedForSubtree();
939 } 944 }
940 945
941 bool LayerImpl::FilterIsAnimating() const { 946 bool LayerImpl::FilterIsAnimating() const {
942 return layer_animation_controller_->IsAnimatingProperty(Animation::FILTER); 947 return layer_animation_controller_
948 ? layer_animation_controller_->IsAnimatingProperty(
949 Animation::FILTER)
950 : layer_tree_impl_->IsAnimatingFilterProperty(this);
943 } 951 }
944 952
945 bool LayerImpl::FilterIsAnimatingOnImplOnly() const { 953 bool LayerImpl::FilterIsAnimatingOnImplOnly() const {
954 if (!layer_animation_controller_)
955 return layer_tree_impl_->FilterIsAnimatingOnImplOnly(this);
956
946 Animation* filter_animation = 957 Animation* filter_animation =
947 layer_animation_controller_->GetAnimation(Animation::FILTER); 958 layer_animation_controller_->GetAnimation(Animation::FILTER);
948 return filter_animation && filter_animation->is_impl_only(); 959 return filter_animation && filter_animation->is_impl_only();
949 } 960 }
950 961
951 void LayerImpl::SetBackgroundFilters( 962 void LayerImpl::SetBackgroundFilters(
952 const FilterOperations& filters) { 963 const FilterOperations& filters) {
953 if (background_filters_ == filters) 964 if (background_filters_ == filters)
954 return; 965 return;
955 966
(...skipping 19 matching lines...) Expand all
975 986
976 void LayerImpl::SetOpacity(float opacity) { 987 void LayerImpl::SetOpacity(float opacity) {
977 if (opacity_ == opacity) 988 if (opacity_ == opacity)
978 return; 989 return;
979 990
980 opacity_ = opacity; 991 opacity_ = opacity;
981 NoteLayerPropertyChangedForSubtree(); 992 NoteLayerPropertyChangedForSubtree();
982 } 993 }
983 994
984 bool LayerImpl::OpacityIsAnimating() const { 995 bool LayerImpl::OpacityIsAnimating() const {
985 return layer_animation_controller_->IsAnimatingProperty(Animation::OPACITY); 996 return layer_animation_controller_
997 ? layer_animation_controller_->IsAnimatingProperty(
998 Animation::OPACITY)
999 : layer_tree_impl_->IsAnimatingOpacityProperty(this);
986 } 1000 }
987 1001
988 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { 1002 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const {
1003 if (!layer_animation_controller_)
1004 return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this);
1005
989 Animation* opacity_animation = 1006 Animation* opacity_animation =
990 layer_animation_controller_->GetAnimation(Animation::OPACITY); 1007 layer_animation_controller_->GetAnimation(Animation::OPACITY);
991 return opacity_animation && opacity_animation->is_impl_only(); 1008 return opacity_animation && opacity_animation->is_impl_only();
992 } 1009 }
993 1010
994 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { 1011 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) {
995 if (blend_mode_ == blend_mode) 1012 if (blend_mode_ == blend_mode)
996 return; 1013 return;
997 1014
998 blend_mode_ = blend_mode; 1015 blend_mode_ = blend_mode;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 DCHECK(transform_is_invertible_ == transform_is_invertible) 1074 DCHECK(transform_is_invertible_ == transform_is_invertible)
1058 << "Can't change invertibility if transform is unchanged"; 1075 << "Can't change invertibility if transform is unchanged";
1059 return; 1076 return;
1060 } 1077 }
1061 transform_ = transform; 1078 transform_ = transform;
1062 transform_is_invertible_ = transform_is_invertible; 1079 transform_is_invertible_ = transform_is_invertible;
1063 NoteLayerPropertyChangedForSubtree(); 1080 NoteLayerPropertyChangedForSubtree();
1064 } 1081 }
1065 1082
1066 bool LayerImpl::TransformIsAnimating() const { 1083 bool LayerImpl::TransformIsAnimating() const {
1067 return layer_animation_controller_->IsAnimatingProperty(Animation::TRANSFORM); 1084 return layer_animation_controller_
1085 ? layer_animation_controller_->IsAnimatingProperty(
1086 Animation::TRANSFORM)
1087 : layer_tree_impl_->IsAnimatingTransformProperty(this);
1068 } 1088 }
1069 1089
1070 bool LayerImpl::TransformIsAnimatingOnImplOnly() const { 1090 bool LayerImpl::TransformIsAnimatingOnImplOnly() const {
1091 if (!layer_animation_controller_)
1092 return layer_tree_impl_->TransformIsAnimatingOnImplOnly(this);
1093
1071 Animation* transform_animation = 1094 Animation* transform_animation =
1072 layer_animation_controller_->GetAnimation(Animation::TRANSFORM); 1095 layer_animation_controller_->GetAnimation(Animation::TRANSFORM);
1073 return transform_animation && transform_animation->is_impl_only(); 1096 return transform_animation && transform_animation->is_impl_only();
1074 } 1097 }
1075 1098
1099 bool LayerImpl::HasOnlyTranslationTransforms() const {
1100 if (!layer_animation_controller_)
1101 return layer_tree_impl_->HasOnlyTranslationTransforms(this);
1102
1103 return layer_animation_controller_->HasOnlyTranslationTransforms();
1104 }
1105
1106 bool LayerImpl::MaximumTargetScale(float* max_scale) const {
1107 if (!layer_animation_controller_)
1108 return layer_tree_impl_->MaximumTargetScale(this, max_scale);
1109
1110 return layer_animation_controller_->MaximumTargetScale(max_scale);
1111 }
1112
1113 bool LayerImpl::HasFilterAnimationThatInflatesBounds() const {
1114 if (!layer_animation_controller_)
1115 return layer_tree_impl_->HasFilterAnimationThatInflatesBounds(this);
1116
1117 return layer_animation_controller_->HasFilterAnimationThatInflatesBounds();
1118 }
1119
1120 bool LayerImpl::HasTransformAnimationThatInflatesBounds() const {
1121 if (!layer_animation_controller_)
1122 return layer_tree_impl_->HasTransformAnimationThatInflatesBounds(this);
1123
1124 return layer_animation_controller_->HasTransformAnimationThatInflatesBounds();
1125 }
1126
1127 bool LayerImpl::HasAnimationThatInflatesBounds() const {
1128 if (!layer_animation_controller_)
1129 return layer_tree_impl_->HasAnimationThatInflatesBounds(this);
1130
1131 return layer_animation_controller_->HasAnimationThatInflatesBounds();
1132 }
1133
1134 bool LayerImpl::FilterAnimationBoundsForBox(const gfx::BoxF& box,
1135 gfx::BoxF* bounds) const {
1136 if (!layer_animation_controller_)
1137 return layer_tree_impl_->FilterAnimationBoundsForBox(this, box, bounds);
1138
1139 return layer_animation_controller_->FilterAnimationBoundsForBox(box, bounds);
1140 }
1141
1142 bool LayerImpl::TransformAnimationBoundsForBox(const gfx::BoxF& box,
1143 gfx::BoxF* bounds) const {
1144 if (!layer_animation_controller_)
1145 return layer_tree_impl_->TransformAnimationBoundsForBox(this, box, bounds);
1146
1147 return layer_animation_controller_->TransformAnimationBoundsForBox(box,
1148 bounds);
1149 }
1150
1076 void LayerImpl::SetUpdateRect(const gfx::Rect& update_rect) { 1151 void LayerImpl::SetUpdateRect(const gfx::Rect& update_rect) {
1077 update_rect_ = update_rect; 1152 update_rect_ = update_rect;
1078 SetNeedsPushProperties(); 1153 SetNeedsPushProperties();
1079 } 1154 }
1080 1155
1081 void LayerImpl::AddDamageRect(const gfx::RectF& damage_rect) { 1156 void LayerImpl::AddDamageRect(const gfx::RectF& damage_rect) {
1082 damage_rect_ = gfx::UnionRects(damage_rect_, damage_rect); 1157 damage_rect_ = gfx::UnionRects(damage_rect_, damage_rect);
1083 } 1158 }
1084 1159
1085 void LayerImpl::SetContentBounds(const gfx::Size& content_bounds) { 1160 void LayerImpl::SetContentBounds(const gfx::Size& content_bounds) {
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 state->SetInteger("scroll_parent", scroll_parent_->id()); 1585 state->SetInteger("scroll_parent", scroll_parent_->id());
1511 1586
1512 if (clip_parent_) 1587 if (clip_parent_)
1513 state->SetInteger("clip_parent", clip_parent_->id()); 1588 state->SetInteger("clip_parent", clip_parent_->id());
1514 1589
1515 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); 1590 state->SetBoolean("can_use_lcd_text", can_use_lcd_text());
1516 state->SetBoolean("contents_opaque", contents_opaque()); 1591 state->SetBoolean("contents_opaque", contents_opaque());
1517 1592
1518 state->SetBoolean( 1593 state->SetBoolean(
1519 "has_animation_bounds", 1594 "has_animation_bounds",
1520 layer_animation_controller()->HasAnimationThatInflatesBounds()); 1595 layer_animation_controller_
1596 ? layer_animation_controller_->HasAnimationThatInflatesBounds()
1597 : layer_tree_impl_->HasAnimationThatInflatesBounds(this));
1521 1598
1522 gfx::BoxF box; 1599 gfx::BoxF box;
1523 if (LayerUtils::GetAnimationBounds(*this, &box)) 1600 if (LayerUtils::GetAnimationBounds(*this, &box))
1524 MathUtil::AddToTracedValue("animation_bounds", box, state); 1601 MathUtil::AddToTracedValue("animation_bounds", box, state);
1525 1602
1526 if (debug_info_.get()) { 1603 if (debug_info_.get()) {
1527 std::string str; 1604 std::string str;
1528 debug_info_->AppendAsTraceFormat(&str); 1605 debug_info_->AppendAsTraceFormat(&str);
1529 base::JSONReader json_reader; 1606 base::JSONReader json_reader;
1530 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); 1607 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 gfx::Transform scaled_draw_transform = 1682 gfx::Transform scaled_draw_transform =
1606 draw_properties_.target_space_transform; 1683 draw_properties_.target_space_transform;
1607 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); 1684 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale);
1608 gfx::Size scaled_content_bounds = 1685 gfx::Size scaled_content_bounds =
1609 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), scale)); 1686 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), scale));
1610 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, 1687 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform,
1611 gfx::Rect(scaled_content_bounds)); 1688 gfx::Rect(scaled_content_bounds));
1612 } 1689 }
1613 1690
1614 } // namespace cc 1691 } // namespace cc
OLDNEW
« cc/layers/layer.cc ('K') | « cc/layers/layer_impl.h ('k') | cc/layers/layer_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698