Chromium Code Reviews| 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()); | |
|
danakj
2016/05/10 22:05:30
move this up with other simple setters. line 477?
vmpstr
2016/05/13 00:13:34
Done.
| |
| 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 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1245 replica_layer_->AsValueInto(state); | 1255 replica_layer_->AsValueInto(state); |
| 1246 state->EndDictionary(); | 1256 state->EndDictionary(); |
| 1247 } | 1257 } |
| 1248 | 1258 |
| 1249 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); | 1259 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); |
| 1250 state->SetBoolean("contents_opaque", contents_opaque()); | 1260 state->SetBoolean("contents_opaque", contents_opaque()); |
| 1251 | 1261 |
| 1252 state->SetBoolean("has_animation_bounds", | 1262 state->SetBoolean("has_animation_bounds", |
| 1253 layer_tree_impl_->HasAnimationThatInflatesBounds(this)); | 1263 layer_tree_impl_->HasAnimationThatInflatesBounds(this)); |
| 1254 | 1264 |
| 1265 state->SetBoolean("has_will_change_transform_hint", | |
| 1266 has_will_change_transform_hint()); | |
| 1267 | |
| 1255 gfx::BoxF box; | 1268 gfx::BoxF box; |
| 1256 if (LayerUtils::GetAnimationBounds(*this, &box)) | 1269 if (LayerUtils::GetAnimationBounds(*this, &box)) |
| 1257 MathUtil::AddToTracedValue("animation_bounds", box, state); | 1270 MathUtil::AddToTracedValue("animation_bounds", box, state); |
| 1258 | 1271 |
| 1259 if (debug_info_) { | 1272 if (debug_info_) { |
| 1260 std::string str; | 1273 std::string str; |
| 1261 debug_info_->AppendAsTraceFormat(&str); | 1274 debug_info_->AppendAsTraceFormat(&str); |
| 1262 base::JSONReader json_reader; | 1275 base::JSONReader json_reader; |
| 1263 std::unique_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); | 1276 std::unique_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); |
| 1264 | 1277 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1392 .layer_transforms_should_scale_layer_contents) { | 1405 .layer_transforms_should_scale_layer_contents) { |
| 1393 return default_scale; | 1406 return default_scale; |
| 1394 } | 1407 } |
| 1395 | 1408 |
| 1396 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1409 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1397 DrawTransform(), default_scale); | 1410 DrawTransform(), default_scale); |
| 1398 return std::max(transform_scales.x(), transform_scales.y()); | 1411 return std::max(transform_scales.x(), transform_scales.y()); |
| 1399 } | 1412 } |
| 1400 | 1413 |
| 1401 } // namespace cc | 1414 } // namespace cc |
| OLD | NEW |