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_); | |
danakj
2016/05/10 22:05:30
move this up with the other calls to base->setfoo.
vmpstr
2016/05/13 00:13:34
Done.
| |
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(); | |
danakj
2016/05/10 22:05:30
ditto move this up with other like things. line 14
vmpstr
2016/05/13 00:13:34
Done.
| |
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1665 } | 1672 } |
1666 transform_tree.set_needs_update(true); | 1673 transform_tree.set_needs_update(true); |
1667 } | 1674 } |
1668 } | 1675 } |
1669 | 1676 |
1670 bool Layer::HasActiveAnimationForTesting() const { | 1677 bool Layer::HasActiveAnimationForTesting() const { |
1671 return layer_tree_host_ ? layer_tree_host_->HasActiveAnimationForTesting(this) | 1678 return layer_tree_host_ ? layer_tree_host_->HasActiveAnimationForTesting(this) |
1672 : false; | 1679 : false; |
1673 } | 1680 } |
1674 | 1681 |
1682 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { | |
1683 if (has_will_change_transform_hint_ == has_will_change) | |
1684 return; | |
1685 has_will_change_transform_hint_ = has_will_change; | |
1686 SetNeedsCommit(); | |
1687 } | |
1688 | |
1675 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { | 1689 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { |
1676 return nullptr; | 1690 return nullptr; |
1677 } | 1691 } |
1678 | 1692 |
1679 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | 1693 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { |
1680 return layer_tree_host_->rendering_stats_instrumentation(); | 1694 return layer_tree_host_->rendering_stats_instrumentation(); |
1681 } | 1695 } |
1682 | 1696 |
1683 void Layer::RemoveFromScrollTree() { | 1697 void Layer::RemoveFromScrollTree() { |
1684 if (scroll_children_.get()) { | 1698 if (scroll_children_.get()) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1752 ->data.num_copy_requests_in_subtree; | 1766 ->data.num_copy_requests_in_subtree; |
1753 } | 1767 } |
1754 | 1768 |
1755 gfx::Transform Layer::screen_space_transform() const { | 1769 gfx::Transform Layer::screen_space_transform() const { |
1756 DCHECK_NE(transform_tree_index_, -1); | 1770 DCHECK_NE(transform_tree_index_, -1); |
1757 return draw_property_utils::ScreenSpaceTransform( | 1771 return draw_property_utils::ScreenSpaceTransform( |
1758 this, layer_tree_host_->property_trees()->transform_tree); | 1772 this, layer_tree_host_->property_trees()->transform_tree); |
1759 } | 1773 } |
1760 | 1774 |
1761 } // namespace cc | 1775 } // namespace cc |
OLD | NEW |