| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 75 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
| 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 has_will_change_transform_hint_(false) { |
| 86 DCHECK_GT(layer_id_, 0); | 87 DCHECK_GT(layer_id_, 0); |
| 87 | 88 |
| 88 DCHECK(layer_tree_impl_); | 89 DCHECK(layer_tree_impl_); |
| 89 layer_tree_impl_->RegisterLayer(this); | 90 layer_tree_impl_->RegisterLayer(this); |
| 90 layer_tree_impl_->AddToElementMap(this); | 91 layer_tree_impl_->AddToElementMap(this); |
| 91 | 92 |
| 92 SetNeedsPushProperties(); | 93 SetNeedsPushProperties(); |
| 93 } | 94 } |
| 94 | 95 |
| 95 LayerImpl::~LayerImpl() { | 96 LayerImpl::~LayerImpl() { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 layer_tree_impl_->RemoveLayer(child->id()); | 139 layer_tree_impl_->RemoveLayer(child->id()); |
| 139 children_.clear(); | 140 children_.clear(); |
| 140 } | 141 } |
| 141 | 142 |
| 142 void LayerImpl::ClearLinksToOtherLayers() { | 143 void LayerImpl::ClearLinksToOtherLayers() { |
| 143 children_.clear(); | 144 children_.clear(); |
| 144 mask_layer_ = nullptr; | 145 mask_layer_ = nullptr; |
| 145 replica_layer_ = nullptr; | 146 replica_layer_ = nullptr; |
| 146 } | 147 } |
| 147 | 148 |
| 149 void LayerImpl::SetHasWillChangeTransformHint(bool has_will_change) { |
| 150 if (has_will_change_transform_hint_ == has_will_change) |
| 151 return; |
| 152 has_will_change_transform_hint_ = has_will_change; |
| 153 SetNeedsPushProperties(); |
| 154 } |
| 155 |
| 148 void LayerImpl::SetDebugInfo( | 156 void LayerImpl::SetDebugInfo( |
| 149 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info) { | 157 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info) { |
| 150 owned_debug_info_ = std::move(debug_info); | 158 owned_debug_info_ = std::move(debug_info); |
| 151 debug_info_ = owned_debug_info_.get(); | 159 debug_info_ = owned_debug_info_.get(); |
| 152 SetNeedsPushProperties(); | 160 SetNeedsPushProperties(); |
| 153 } | 161 } |
| 154 | 162 |
| 155 void LayerImpl::DistributeScroll(ScrollState* scroll_state) { | 163 void LayerImpl::DistributeScroll(ScrollState* scroll_state) { |
| 156 DCHECK(scroll_state); | 164 DCHECK(scroll_state); |
| 157 if (scroll_state->FullyConsumed()) | 165 if (scroll_state->FullyConsumed()) |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 // If the main thread commits multiple times before the impl thread actually | 493 // If the main thread commits multiple times before the impl thread actually |
| 486 // draws, then damage tracking will become incorrect if we simply clobber the | 494 // draws, then damage tracking will become incorrect if we simply clobber the |
| 487 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 495 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
| 488 // union) any update changes that have occurred on the main thread. | 496 // union) any update changes that have occurred on the main thread. |
| 489 update_rect_.Union(layer->update_rect()); | 497 update_rect_.Union(layer->update_rect()); |
| 490 layer->SetUpdateRect(update_rect_); | 498 layer->SetUpdateRect(update_rect_); |
| 491 | 499 |
| 492 if (owned_debug_info_) | 500 if (owned_debug_info_) |
| 493 layer->SetDebugInfo(std::move(owned_debug_info_)); | 501 layer->SetDebugInfo(std::move(owned_debug_info_)); |
| 494 | 502 |
| 503 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); |
| 504 |
| 495 // Reset any state that should be cleared for the next update. | 505 // Reset any state that should be cleared for the next update. |
| 496 layer_property_changed_ = false; | 506 layer_property_changed_ = false; |
| 497 update_rect_ = gfx::Rect(); | 507 update_rect_ = gfx::Rect(); |
| 498 layer_tree_impl()->RemoveLayerShouldPushProperties(this); | 508 layer_tree_impl()->RemoveLayerShouldPushProperties(this); |
| 499 } | 509 } |
| 500 | 510 |
| 501 bool LayerImpl::IsAffectedByPageScale() const { | 511 bool LayerImpl::IsAffectedByPageScale() const { |
| 502 TransformTree& transform_tree = | 512 TransformTree& transform_tree = |
| 503 layer_tree_impl()->property_trees()->transform_tree; | 513 layer_tree_impl()->property_trees()->transform_tree; |
| 504 return transform_tree.Node(transform_tree_index()) | 514 return transform_tree.Node(transform_tree_index()) |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 replica_layer_->AsValueInto(state); | 1261 replica_layer_->AsValueInto(state); |
| 1252 state->EndDictionary(); | 1262 state->EndDictionary(); |
| 1253 } | 1263 } |
| 1254 | 1264 |
| 1255 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); | 1265 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); |
| 1256 state->SetBoolean("contents_opaque", contents_opaque()); | 1266 state->SetBoolean("contents_opaque", contents_opaque()); |
| 1257 | 1267 |
| 1258 state->SetBoolean("has_animation_bounds", | 1268 state->SetBoolean("has_animation_bounds", |
| 1259 layer_tree_impl_->HasAnimationThatInflatesBounds(this)); | 1269 layer_tree_impl_->HasAnimationThatInflatesBounds(this)); |
| 1260 | 1270 |
| 1271 state->SetBoolean("has_will_change_transform_hint", |
| 1272 has_will_change_transform_hint()); |
| 1273 |
| 1261 gfx::BoxF box; | 1274 gfx::BoxF box; |
| 1262 if (LayerUtils::GetAnimationBounds(*this, &box)) | 1275 if (LayerUtils::GetAnimationBounds(*this, &box)) |
| 1263 MathUtil::AddToTracedValue("animation_bounds", box, state); | 1276 MathUtil::AddToTracedValue("animation_bounds", box, state); |
| 1264 | 1277 |
| 1265 if (debug_info_) { | 1278 if (debug_info_) { |
| 1266 std::string str; | 1279 std::string str; |
| 1267 debug_info_->AppendAsTraceFormat(&str); | 1280 debug_info_->AppendAsTraceFormat(&str); |
| 1268 base::JSONReader json_reader; | 1281 base::JSONReader json_reader; |
| 1269 std::unique_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); | 1282 std::unique_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); |
| 1270 | 1283 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 .layer_transforms_should_scale_layer_contents) { | 1411 .layer_transforms_should_scale_layer_contents) { |
| 1399 return default_scale; | 1412 return default_scale; |
| 1400 } | 1413 } |
| 1401 | 1414 |
| 1402 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1415 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1403 DrawTransform(), default_scale); | 1416 DrawTransform(), default_scale); |
| 1404 return std::max(transform_scales.x(), transform_scales.y()); | 1417 return std::max(transform_scales.x(), transform_scales.y()); |
| 1405 } | 1418 } |
| 1406 | 1419 |
| 1407 } // namespace cc | 1420 } // namespace cc |
| OLD | NEW |