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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 masks_to_bounds_(false), | 73 masks_to_bounds_(false), |
74 contents_opaque_(false), | 74 contents_opaque_(false), |
75 double_sided_(true), | 75 double_sided_(true), |
76 should_flatten_transform_(true), | 76 should_flatten_transform_(true), |
77 use_parent_backface_visibility_(false), | 77 use_parent_backface_visibility_(false), |
78 use_local_transform_for_backface_visibility_(false), | 78 use_local_transform_for_backface_visibility_(false), |
79 should_check_backface_visibility_(false), | 79 should_check_backface_visibility_(false), |
80 force_render_surface_for_testing_(false), | 80 force_render_surface_for_testing_(false), |
81 has_render_surface_(false), | 81 has_render_surface_(false), |
82 subtree_property_changed_(false), | 82 subtree_property_changed_(false), |
| 83 has_will_change_transform_hint_(false), |
83 background_color_(0), | 84 background_color_(0), |
84 safe_opaque_background_color_(0), | 85 safe_opaque_background_color_(0), |
85 opacity_(1.f), | 86 opacity_(1.f), |
86 blend_mode_(SkXfermode::kSrcOver_Mode), | 87 blend_mode_(SkXfermode::kSrcOver_Mode), |
87 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 88 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
88 scroll_parent_(nullptr), | 89 scroll_parent_(nullptr), |
89 clip_parent_(nullptr), | 90 clip_parent_(nullptr), |
90 replica_layer_(nullptr), | 91 replica_layer_(nullptr), |
91 client_(nullptr), | 92 client_(nullptr), |
92 num_unclipped_descendants_(0) {} | 93 num_unclipped_descendants_(0) {} |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 layer->PassCopyRequests(&main_thread_copy_requests); | 1203 layer->PassCopyRequests(&main_thread_copy_requests); |
1203 } | 1204 } |
1204 | 1205 |
1205 // If the main thread commits multiple times before the impl thread actually | 1206 // If the main thread commits multiple times before the impl thread actually |
1206 // draws, then damage tracking will become incorrect if we simply clobber the | 1207 // draws, then damage tracking will become incorrect if we simply clobber the |
1207 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 1208 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
1208 // union) any update changes that have occurred on the main thread. | 1209 // union) any update changes that have occurred on the main thread. |
1209 update_rect_.Union(layer->update_rect()); | 1210 update_rect_.Union(layer->update_rect()); |
1210 layer->SetUpdateRect(update_rect_); | 1211 layer->SetUpdateRect(update_rect_); |
1211 | 1212 |
| 1213 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); |
| 1214 |
1212 // Reset any state that should be cleared for the next update. | 1215 // Reset any state that should be cleared for the next update. |
1213 subtree_property_changed_ = false; | 1216 subtree_property_changed_ = false; |
1214 update_rect_ = gfx::Rect(); | 1217 update_rect_ = gfx::Rect(); |
1215 | 1218 |
1216 layer_tree_host()->RemoveLayerShouldPushProperties(this); | 1219 layer_tree_host()->RemoveLayerShouldPushProperties(this); |
1217 } | 1220 } |
1218 | 1221 |
1219 void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { | 1222 void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { |
1220 proto->set_type(proto::LayerNode::LAYER); | 1223 proto->set_type(proto::LayerNode::LAYER); |
1221 } | 1224 } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 | 1407 |
1405 // TODO(nyquist): Figure out what to do with CopyRequests. | 1408 // TODO(nyquist): Figure out what to do with CopyRequests. |
1406 // See crbug.com/570374. | 1409 // See crbug.com/570374. |
1407 | 1410 |
1408 RectToProto(update_rect_, base->mutable_update_rect()); | 1411 RectToProto(update_rect_, base->mutable_update_rect()); |
1409 | 1412 |
1410 // TODO(nyquist): Figure out what to do with ElementAnimations. | 1413 // TODO(nyquist): Figure out what to do with ElementAnimations. |
1411 // See crbug.com/570376. | 1414 // See crbug.com/570376. |
1412 | 1415 |
1413 update_rect_ = gfx::Rect(); | 1416 update_rect_ = gfx::Rect(); |
| 1417 |
| 1418 base->set_has_will_change_transform_hint(has_will_change_transform_hint_); |
1414 } | 1419 } |
1415 | 1420 |
1416 void Layer::FromLayerSpecificPropertiesProto( | 1421 void Layer::FromLayerSpecificPropertiesProto( |
1417 const proto::LayerProperties& proto) { | 1422 const proto::LayerProperties& proto) { |
1418 DCHECK(proto.has_base()); | 1423 DCHECK(proto.has_base()); |
1419 DCHECK(layer_tree_host_); | 1424 DCHECK(layer_tree_host_); |
1420 const proto::BaseLayerProperties& base = proto.base(); | 1425 const proto::BaseLayerProperties& base = proto.base(); |
1421 | 1426 |
1422 transform_origin_ = ProtoToPoint3F(base.transform_origin()); | 1427 transform_origin_ = ProtoToPoint3F(base.transform_origin()); |
1423 background_color_ = base.background_color(); | 1428 background_color_ = base.background_color(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1496 clip_children_.reset(new std::set<Layer*>); | 1501 clip_children_.reset(new std::set<Layer*>); |
1497 for (int i = 0; i < base.clip_children_ids_size(); ++i) { | 1502 for (int i = 0; i < base.clip_children_ids_size(); ++i) { |
1498 int child_id = base.clip_children_ids(i); | 1503 int child_id = base.clip_children_ids(i); |
1499 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); | 1504 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); |
1500 clip_children_->insert(child.get()); | 1505 clip_children_->insert(child.get()); |
1501 } | 1506 } |
1502 | 1507 |
1503 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset()); | 1508 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset()); |
1504 | 1509 |
1505 update_rect_.Union(ProtoToRect(base.update_rect())); | 1510 update_rect_.Union(ProtoToRect(base.update_rect())); |
| 1511 |
| 1512 has_will_change_transform_hint_ = base.has_will_change_transform_hint(); |
1506 } | 1513 } |
1507 | 1514 |
1508 std::unique_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 1515 std::unique_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
1509 return LayerImpl::Create(tree_impl, layer_id_); | 1516 return LayerImpl::Create(tree_impl, layer_id_); |
1510 } | 1517 } |
1511 | 1518 |
1512 bool Layer::DrawsContent() const { | 1519 bool Layer::DrawsContent() const { |
1513 return draws_content_; | 1520 return draws_content_; |
1514 } | 1521 } |
1515 | 1522 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 has_potential_animation || OpacityCanAnimateOnImplThread(); | 1697 has_potential_animation || OpacityCanAnimateOnImplThread(); |
1691 effect_tree.set_needs_update(true); | 1698 effect_tree.set_needs_update(true); |
1692 } | 1699 } |
1693 } | 1700 } |
1694 | 1701 |
1695 bool Layer::HasActiveAnimationForTesting() const { | 1702 bool Layer::HasActiveAnimationForTesting() const { |
1696 return layer_tree_host_ ? layer_tree_host_->HasActiveAnimationForTesting(this) | 1703 return layer_tree_host_ ? layer_tree_host_->HasActiveAnimationForTesting(this) |
1697 : false; | 1704 : false; |
1698 } | 1705 } |
1699 | 1706 |
| 1707 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { |
| 1708 if (has_will_change_transform_hint_ == has_will_change) |
| 1709 return; |
| 1710 has_will_change_transform_hint_ = has_will_change; |
| 1711 SetNeedsCommit(); |
| 1712 } |
| 1713 |
1700 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { | 1714 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { |
1701 return nullptr; | 1715 return nullptr; |
1702 } | 1716 } |
1703 | 1717 |
1704 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | 1718 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { |
1705 return layer_tree_host_->rendering_stats_instrumentation(); | 1719 return layer_tree_host_->rendering_stats_instrumentation(); |
1706 } | 1720 } |
1707 | 1721 |
1708 void Layer::RemoveFromScrollTree() { | 1722 void Layer::RemoveFromScrollTree() { |
1709 if (scroll_children_.get()) { | 1723 if (scroll_children_.get()) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1777 ->data.num_copy_requests_in_subtree; | 1791 ->data.num_copy_requests_in_subtree; |
1778 } | 1792 } |
1779 | 1793 |
1780 gfx::Transform Layer::screen_space_transform() const { | 1794 gfx::Transform Layer::screen_space_transform() const { |
1781 DCHECK_NE(transform_tree_index_, -1); | 1795 DCHECK_NE(transform_tree_index_, -1); |
1782 return draw_property_utils::ScreenSpaceTransform( | 1796 return draw_property_utils::ScreenSpaceTransform( |
1783 this, layer_tree_host_->property_trees()->transform_tree); | 1797 this, layer_tree_host_->property_trees()->transform_tree); |
1784 } | 1798 } |
1785 | 1799 |
1786 } // namespace cc | 1800 } // namespace cc |
OLD | NEW |