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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 transform_tree_index_(-1), | 76 transform_tree_index_(-1), |
77 effect_tree_index_(-1), | 77 effect_tree_index_(-1), |
78 clip_tree_index_(-1), | 78 clip_tree_index_(-1), |
79 scroll_tree_index_(-1), | 79 scroll_tree_index_(-1), |
80 sorting_context_id_(0), | 80 sorting_context_id_(0), |
81 current_draw_mode_(DRAW_MODE_NONE), | 81 current_draw_mode_(DRAW_MODE_NONE), |
82 element_id_(0), | 82 element_id_(0), |
83 mutable_properties_(MutableProperty::kNone), | 83 mutable_properties_(MutableProperty::kNone), |
84 debug_info_(nullptr), | 84 debug_info_(nullptr), |
85 scrolls_drawn_descendant_(false), | 85 scrolls_drawn_descendant_(false), |
86 layer_or_descendant_has_touch_handler_(false) { | 86 layer_or_descendant_has_touch_handler_(false), |
| 87 has_will_change_transform_hint_(false) { |
87 DCHECK_GT(layer_id_, 0); | 88 DCHECK_GT(layer_id_, 0); |
88 | 89 |
89 DCHECK(layer_tree_impl_); | 90 DCHECK(layer_tree_impl_); |
90 layer_tree_impl_->RegisterLayer(this); | 91 layer_tree_impl_->RegisterLayer(this); |
91 layer_tree_impl_->AddToElementMap(this); | 92 layer_tree_impl_->AddToElementMap(this); |
92 | 93 |
93 SetNeedsPushProperties(); | 94 SetNeedsPushProperties(); |
94 } | 95 } |
95 | 96 |
96 LayerImpl::~LayerImpl() { | 97 LayerImpl::~LayerImpl() { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 layer_tree_impl_->RemoveLayer(child->id()); | 140 layer_tree_impl_->RemoveLayer(child->id()); |
140 children_.clear(); | 141 children_.clear(); |
141 } | 142 } |
142 | 143 |
143 void LayerImpl::ClearLinksToOtherLayers() { | 144 void LayerImpl::ClearLinksToOtherLayers() { |
144 children_.clear(); | 145 children_.clear(); |
145 mask_layer_ = nullptr; | 146 mask_layer_ = nullptr; |
146 replica_layer_ = nullptr; | 147 replica_layer_ = nullptr; |
147 } | 148 } |
148 | 149 |
| 150 void LayerImpl::SetHasWillChangeTransformHint(bool has_will_change) { |
| 151 if (has_will_change_transform_hint_ == has_will_change) |
| 152 return; |
| 153 has_will_change_transform_hint_ = has_will_change; |
| 154 SetNeedsPushProperties(); |
| 155 } |
| 156 |
149 void LayerImpl::SetDebugInfo( | 157 void LayerImpl::SetDebugInfo( |
150 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info) { | 158 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info) { |
151 owned_debug_info_ = std::move(debug_info); | 159 owned_debug_info_ = std::move(debug_info); |
152 debug_info_ = owned_debug_info_.get(); | 160 debug_info_ = owned_debug_info_.get(); |
153 SetNeedsPushProperties(); | 161 SetNeedsPushProperties(); |
154 } | 162 } |
155 | 163 |
156 void LayerImpl::DistributeScroll(ScrollState* scroll_state) { | 164 void LayerImpl::DistributeScroll(ScrollState* scroll_state) { |
157 DCHECK(scroll_state); | 165 DCHECK(scroll_state); |
158 if (scroll_state->FullyConsumed()) | 166 if (scroll_state->FullyConsumed()) |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 // If the main thread commits multiple times before the impl thread actually | 494 // If the main thread commits multiple times before the impl thread actually |
487 // draws, then damage tracking will become incorrect if we simply clobber the | 495 // draws, then damage tracking will become incorrect if we simply clobber the |
488 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 496 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
489 // union) any update changes that have occurred on the main thread. | 497 // union) any update changes that have occurred on the main thread. |
490 update_rect_.Union(layer->update_rect()); | 498 update_rect_.Union(layer->update_rect()); |
491 layer->SetUpdateRect(update_rect_); | 499 layer->SetUpdateRect(update_rect_); |
492 | 500 |
493 if (owned_debug_info_) | 501 if (owned_debug_info_) |
494 layer->SetDebugInfo(std::move(owned_debug_info_)); | 502 layer->SetDebugInfo(std::move(owned_debug_info_)); |
495 | 503 |
| 504 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); |
| 505 |
496 // Reset any state that should be cleared for the next update. | 506 // Reset any state that should be cleared for the next update. |
497 layer_property_changed_ = false; | 507 layer_property_changed_ = false; |
498 update_rect_ = gfx::Rect(); | 508 update_rect_ = gfx::Rect(); |
499 layer_tree_impl()->RemoveLayerShouldPushProperties(this); | 509 layer_tree_impl()->RemoveLayerShouldPushProperties(this); |
500 } | 510 } |
501 | 511 |
502 bool LayerImpl::IsAffectedByPageScale() const { | 512 bool LayerImpl::IsAffectedByPageScale() const { |
503 TransformTree& transform_tree = | 513 TransformTree& transform_tree = |
504 layer_tree_impl()->property_trees()->transform_tree; | 514 layer_tree_impl()->property_trees()->transform_tree; |
505 return transform_tree.Node(transform_tree_index()) | 515 return transform_tree.Node(transform_tree_index()) |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 replica_layer_->AsValueInto(state); | 1274 replica_layer_->AsValueInto(state); |
1265 state->EndDictionary(); | 1275 state->EndDictionary(); |
1266 } | 1276 } |
1267 | 1277 |
1268 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); | 1278 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); |
1269 state->SetBoolean("contents_opaque", contents_opaque()); | 1279 state->SetBoolean("contents_opaque", contents_opaque()); |
1270 | 1280 |
1271 state->SetBoolean("has_animation_bounds", | 1281 state->SetBoolean("has_animation_bounds", |
1272 layer_tree_impl_->HasAnimationThatInflatesBounds(this)); | 1282 layer_tree_impl_->HasAnimationThatInflatesBounds(this)); |
1273 | 1283 |
| 1284 state->SetBoolean("has_will_change_transform_hint", |
| 1285 has_will_change_transform_hint()); |
| 1286 |
1274 gfx::BoxF box; | 1287 gfx::BoxF box; |
1275 if (LayerUtils::GetAnimationBounds(*this, &box)) | 1288 if (LayerUtils::GetAnimationBounds(*this, &box)) |
1276 MathUtil::AddToTracedValue("animation_bounds", box, state); | 1289 MathUtil::AddToTracedValue("animation_bounds", box, state); |
1277 | 1290 |
1278 if (debug_info_) { | 1291 if (debug_info_) { |
1279 std::string str; | 1292 std::string str; |
1280 debug_info_->AppendAsTraceFormat(&str); | 1293 debug_info_->AppendAsTraceFormat(&str); |
1281 base::JSONReader json_reader; | 1294 base::JSONReader json_reader; |
1282 std::unique_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); | 1295 std::unique_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); |
1283 | 1296 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 .layer_transforms_should_scale_layer_contents) { | 1424 .layer_transforms_should_scale_layer_contents) { |
1412 return default_scale; | 1425 return default_scale; |
1413 } | 1426 } |
1414 | 1427 |
1415 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1428 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
1416 DrawTransform(), default_scale); | 1429 DrawTransform(), default_scale); |
1417 return std::max(transform_scales.x(), transform_scales.y()); | 1430 return std::max(transform_scales.x(), transform_scales.y()); |
1418 } | 1431 } |
1419 | 1432 |
1420 } // namespace cc | 1433 } // namespace cc |
OLD | NEW |