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