OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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.h" | 5 #include "cc/layers/layer.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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 scroll_clip_layer_id(INVALID_ID), | 55 scroll_clip_layer_id(INVALID_ID), |
56 user_scrollable_horizontal(true), | 56 user_scrollable_horizontal(true), |
57 user_scrollable_vertical(true), | 57 user_scrollable_vertical(true), |
58 main_thread_scrolling_reasons( | 58 main_thread_scrolling_reasons( |
59 MainThreadScrollingReason::kNotScrollingOnMain), | 59 MainThreadScrollingReason::kNotScrollingOnMain), |
60 is_container_for_fixed_position_layers(false), | 60 is_container_for_fixed_position_layers(false), |
61 mutable_properties(MutableProperty::kNone), | 61 mutable_properties(MutableProperty::kNone), |
62 scroll_parent(nullptr), | 62 scroll_parent(nullptr), |
63 clip_parent(nullptr), | 63 clip_parent(nullptr), |
64 has_will_change_transform_hint(false), | 64 has_will_change_transform_hint(false), |
65 has_preferred_raster_bounds(false), | |
66 hide_layer_and_subtree(false), | 65 hide_layer_and_subtree(false), |
67 client(nullptr) {} | 66 client(nullptr) {} |
68 | 67 |
69 Layer::Inputs::~Inputs() {} | 68 Layer::Inputs::~Inputs() {} |
70 | 69 |
71 scoped_refptr<Layer> Layer::Create() { | 70 scoped_refptr<Layer> Layer::Create() { |
72 return make_scoped_refptr(new Layer()); | 71 return make_scoped_refptr(new Layer()); |
73 } | 72 } |
74 | 73 |
75 Layer::Layer() | 74 Layer::Layer() |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->id()); | 1181 ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->id()); |
1183 | 1182 |
1184 // If the main thread commits multiple times before the impl thread actually | 1183 // If the main thread commits multiple times before the impl thread actually |
1185 // draws, then damage tracking will become incorrect if we simply clobber the | 1184 // draws, then damage tracking will become incorrect if we simply clobber the |
1186 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 1185 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
1187 // union) any update changes that have occurred on the main thread. | 1186 // union) any update changes that have occurred on the main thread. |
1188 inputs_.update_rect.Union(layer->update_rect()); | 1187 inputs_.update_rect.Union(layer->update_rect()); |
1189 layer->SetUpdateRect(inputs_.update_rect); | 1188 layer->SetUpdateRect(inputs_.update_rect); |
1190 | 1189 |
1191 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); | 1190 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); |
1192 if (has_preferred_raster_bounds()) | |
1193 layer->SetPreferredRasterBounds(preferred_raster_bounds()); | |
1194 else | |
1195 layer->ClearPreferredRasterBounds(); | |
1196 layer->SetNeedsPushProperties(); | 1191 layer->SetNeedsPushProperties(); |
1197 | 1192 |
1198 // Reset any state that should be cleared for the next update. | 1193 // Reset any state that should be cleared for the next update. |
1199 subtree_property_changed_ = false; | 1194 subtree_property_changed_ = false; |
1200 inputs_.update_rect = gfx::Rect(); | 1195 inputs_.update_rect = gfx::Rect(); |
1201 | 1196 |
1202 layer_tree_host_->RemoveLayerShouldPushProperties(this); | 1197 layer_tree_host_->RemoveLayerShouldPushProperties(this); |
1203 } | 1198 } |
1204 | 1199 |
1205 void Layer::TakeCopyRequests( | 1200 void Layer::TakeCopyRequests( |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 : false; | 1414 : false; |
1420 } | 1415 } |
1421 | 1416 |
1422 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { | 1417 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { |
1423 if (inputs_.has_will_change_transform_hint == has_will_change) | 1418 if (inputs_.has_will_change_transform_hint == has_will_change) |
1424 return; | 1419 return; |
1425 inputs_.has_will_change_transform_hint = has_will_change; | 1420 inputs_.has_will_change_transform_hint = has_will_change; |
1426 SetNeedsCommit(); | 1421 SetNeedsCommit(); |
1427 } | 1422 } |
1428 | 1423 |
1429 void Layer::SetPreferredRasterBounds(const gfx::Size& preferred_raster_bounds) { | |
1430 if (inputs_.has_preferred_raster_bounds && | |
1431 inputs_.preferred_raster_bounds == preferred_raster_bounds) | |
1432 return; | |
1433 | |
1434 inputs_.has_preferred_raster_bounds = true; | |
1435 inputs_.preferred_raster_bounds = preferred_raster_bounds; | |
1436 SetNeedsCommit(); | |
1437 } | |
1438 | |
1439 void Layer::ClearPreferredRasterBounds() { | |
1440 if (!inputs_.has_preferred_raster_bounds) | |
1441 return; | |
1442 inputs_.has_preferred_raster_bounds = false; | |
1443 inputs_.preferred_raster_bounds = gfx::Size(); | |
1444 SetNeedsCommit(); | |
1445 } | |
1446 | |
1447 MutatorHost* Layer::GetMutatorHost() const { | 1424 MutatorHost* Layer::GetMutatorHost() const { |
1448 return layer_tree_host_ ? layer_tree_host_->mutator_host() : nullptr; | 1425 return layer_tree_host_ ? layer_tree_host_->mutator_host() : nullptr; |
1449 } | 1426 } |
1450 | 1427 |
1451 ElementListType Layer::GetElementTypeForAnimation() const { | 1428 ElementListType Layer::GetElementTypeForAnimation() const { |
1452 return ElementListType::ACTIVE; | 1429 return ElementListType::ACTIVE; |
1453 } | 1430 } |
1454 | 1431 |
1455 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { | 1432 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { |
1456 return nullptr; | 1433 return nullptr; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 ->num_copy_requests_in_subtree; | 1507 ->num_copy_requests_in_subtree; |
1531 } | 1508 } |
1532 | 1509 |
1533 gfx::Transform Layer::screen_space_transform() const { | 1510 gfx::Transform Layer::screen_space_transform() const { |
1534 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1511 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
1535 return draw_property_utils::ScreenSpaceTransform( | 1512 return draw_property_utils::ScreenSpaceTransform( |
1536 this, layer_tree_host_->property_trees()->transform_tree); | 1513 this, layer_tree_host_->property_trees()->transform_tree); |
1537 } | 1514 } |
1538 | 1515 |
1539 } // namespace cc | 1516 } // namespace cc |
OLD | NEW |