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 <algorithm> | 10 #include <algorithm> |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 background_color_(0), | 71 background_color_(0), |
72 safe_opaque_background_color_(0), | 72 safe_opaque_background_color_(0), |
73 blend_mode_(SkXfermode::kSrcOver_Mode), | 73 blend_mode_(SkXfermode::kSrcOver_Mode), |
74 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 74 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
75 transform_tree_index_(-1), | 75 transform_tree_index_(-1), |
76 effect_tree_index_(-1), | 76 effect_tree_index_(-1), |
77 clip_tree_index_(-1), | 77 clip_tree_index_(-1), |
78 scroll_tree_index_(-1), | 78 scroll_tree_index_(-1), |
79 sorting_context_id_(0), | 79 sorting_context_id_(0), |
80 current_draw_mode_(DRAW_MODE_NONE), | 80 current_draw_mode_(DRAW_MODE_NONE), |
81 element_id_(0), | |
82 mutable_properties_(MutableProperty::kNone), | 81 mutable_properties_(MutableProperty::kNone), |
83 debug_info_(nullptr), | 82 debug_info_(nullptr), |
84 scrolls_drawn_descendant_(false), | 83 scrolls_drawn_descendant_(false), |
85 has_will_change_transform_hint_(false) { | 84 has_will_change_transform_hint_(false) { |
86 DCHECK_GT(layer_id_, 0); | 85 DCHECK_GT(layer_id_, 0); |
87 | 86 |
88 DCHECK(layer_tree_impl_); | 87 DCHECK(layer_tree_impl_); |
89 layer_tree_impl_->RegisterLayer(this); | 88 layer_tree_impl_->RegisterLayer(this); |
90 layer_tree_impl_->AddToElementMap(this); | 89 layer_tree_impl_->AddToElementMap(this); |
91 | 90 |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 } | 941 } |
943 | 942 |
944 bool LayerImpl::OpacityIsAnimating() const { | 943 bool LayerImpl::OpacityIsAnimating() const { |
945 return layer_tree_impl_->IsAnimatingOpacityProperty(this); | 944 return layer_tree_impl_->IsAnimatingOpacityProperty(this); |
946 } | 945 } |
947 | 946 |
948 bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const { | 947 bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const { |
949 return layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this); | 948 return layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this); |
950 } | 949 } |
951 | 950 |
952 void LayerImpl::SetElementId(uint64_t element_id) { | 951 void LayerImpl::SetElementId(ElementId element_id) { |
953 if (element_id == element_id_) | 952 if (element_id == element_id_) |
954 return; | 953 return; |
955 | 954 |
956 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 955 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
957 "LayerImpl::SetElementId", "id", element_id); | 956 "LayerImpl::SetElementId", "element", |
| 957 element_id.AsValue().release()); |
958 | 958 |
959 layer_tree_impl_->RemoveFromElementMap(this); | 959 layer_tree_impl_->RemoveFromElementMap(this); |
960 element_id_ = element_id; | 960 element_id_ = element_id; |
961 layer_tree_impl_->AddToElementMap(this); | 961 layer_tree_impl_->AddToElementMap(this); |
| 962 |
962 SetNeedsPushProperties(); | 963 SetNeedsPushProperties(); |
963 } | 964 } |
964 | 965 |
965 void LayerImpl::SetMutableProperties(uint32_t properties) { | 966 void LayerImpl::SetMutableProperties(uint32_t properties) { |
966 if (mutable_properties_ == properties) | 967 if (mutable_properties_ == properties) |
967 return; | 968 return; |
968 | 969 |
969 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 970 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
970 "LayerImpl::SetMutableProperties", "properties", properties); | 971 "LayerImpl::SetMutableProperties", "properties", properties); |
971 | 972 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 MathUtil::AddToTracedValue("bounds", bounds_, state); | 1143 MathUtil::AddToTracedValue("bounds", bounds_, state); |
1143 | 1144 |
1144 state->SetDouble("opacity", Opacity()); | 1145 state->SetDouble("opacity", Opacity()); |
1145 | 1146 |
1146 MathUtil::AddToTracedValue("position", position_, state); | 1147 MathUtil::AddToTracedValue("position", position_, state); |
1147 | 1148 |
1148 state->SetInteger("draws_content", DrawsContent()); | 1149 state->SetInteger("draws_content", DrawsContent()); |
1149 state->SetInteger("gpu_memory_usage", | 1150 state->SetInteger("gpu_memory_usage", |
1150 base::saturated_cast<int>(GPUMemoryUsageInBytes())); | 1151 base::saturated_cast<int>(GPUMemoryUsageInBytes())); |
1151 | 1152 |
1152 if (mutable_properties_ != MutableProperty::kNone) { | 1153 if (element_id_) |
1153 state->SetInteger("element_id", base::saturated_cast<int>(element_id_)); | 1154 element_id_.AddToTracedValue(state); |
| 1155 |
| 1156 if (mutable_properties_ != MutableProperty::kNone) |
1154 state->SetInteger("mutable_properties", mutable_properties_); | 1157 state->SetInteger("mutable_properties", mutable_properties_); |
1155 } | |
1156 | 1158 |
1157 MathUtil::AddToTracedValue("scroll_offset", CurrentScrollOffset(), state); | 1159 MathUtil::AddToTracedValue("scroll_offset", CurrentScrollOffset(), state); |
1158 | 1160 |
1159 if (!transform().IsIdentity()) | 1161 if (!transform().IsIdentity()) |
1160 MathUtil::AddToTracedValue("transform", transform(), state); | 1162 MathUtil::AddToTracedValue("transform", transform(), state); |
1161 | 1163 |
1162 bool clipped; | 1164 bool clipped; |
1163 gfx::QuadF layer_quad = | 1165 gfx::QuadF layer_quad = |
1164 MathUtil::MapQuad(ScreenSpaceTransform(), | 1166 MathUtil::MapQuad(ScreenSpaceTransform(), |
1165 gfx::QuadF(gfx::RectF(gfx::Rect(bounds()))), &clipped); | 1167 gfx::QuadF(gfx::RectF(gfx::Rect(bounds()))), &clipped); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 .layer_transforms_should_scale_layer_contents) { | 1363 .layer_transforms_should_scale_layer_contents) { |
1362 return default_scale; | 1364 return default_scale; |
1363 } | 1365 } |
1364 | 1366 |
1365 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1367 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
1366 ScreenSpaceTransform(), default_scale); | 1368 ScreenSpaceTransform(), default_scale); |
1367 return std::max(transform_scales.x(), transform_scales.y()); | 1369 return std::max(transform_scales.x(), transform_scales.y()); |
1368 } | 1370 } |
1369 | 1371 |
1370 } // namespace cc | 1372 } // namespace cc |
OLD | NEW |