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 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 layer->PassCopyRequests(&main_thread_copy_requests); | 1204 layer->PassCopyRequests(&main_thread_copy_requests); |
1204 } | 1205 } |
1205 | 1206 |
1206 // If the main thread commits multiple times before the impl thread actually | 1207 // If the main thread commits multiple times before the impl thread actually |
1207 // draws, then damage tracking will become incorrect if we simply clobber the | 1208 // draws, then damage tracking will become incorrect if we simply clobber the |
1208 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 1209 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
1209 // union) any update changes that have occurred on the main thread. | 1210 // union) any update changes that have occurred on the main thread. |
1210 update_rect_.Union(layer->update_rect()); | 1211 update_rect_.Union(layer->update_rect()); |
1211 layer->SetUpdateRect(update_rect_); | 1212 layer->SetUpdateRect(update_rect_); |
1212 | 1213 |
| 1214 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); |
| 1215 |
1213 // Reset any state that should be cleared for the next update. | 1216 // Reset any state that should be cleared for the next update. |
1214 subtree_property_changed_ = false; | 1217 subtree_property_changed_ = false; |
1215 update_rect_ = gfx::Rect(); | 1218 update_rect_ = gfx::Rect(); |
1216 | 1219 |
1217 layer_tree_host()->RemoveLayerShouldPushProperties(this); | 1220 layer_tree_host()->RemoveLayerShouldPushProperties(this); |
1218 } | 1221 } |
1219 | 1222 |
1220 void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { | 1223 void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { |
1221 proto->set_type(proto::LayerNode::LAYER); | 1224 proto->set_type(proto::LayerNode::LAYER); |
1222 } | 1225 } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 | 1408 |
1406 // TODO(nyquist): Figure out what to do with CopyRequests. | 1409 // TODO(nyquist): Figure out what to do with CopyRequests. |
1407 // See crbug.com/570374. | 1410 // See crbug.com/570374. |
1408 | 1411 |
1409 RectToProto(update_rect_, base->mutable_update_rect()); | 1412 RectToProto(update_rect_, base->mutable_update_rect()); |
1410 | 1413 |
1411 // TODO(nyquist): Figure out what to do with ElementAnimations. | 1414 // TODO(nyquist): Figure out what to do with ElementAnimations. |
1412 // See crbug.com/570376. | 1415 // See crbug.com/570376. |
1413 | 1416 |
1414 update_rect_ = gfx::Rect(); | 1417 update_rect_ = gfx::Rect(); |
| 1418 |
| 1419 base->set_has_will_change_transform_hint(has_will_change_transform_hint_); |
1415 } | 1420 } |
1416 | 1421 |
1417 void Layer::FromLayerSpecificPropertiesProto( | 1422 void Layer::FromLayerSpecificPropertiesProto( |
1418 const proto::LayerProperties& proto) { | 1423 const proto::LayerProperties& proto) { |
1419 DCHECK(proto.has_base()); | 1424 DCHECK(proto.has_base()); |
1420 DCHECK(layer_tree_host_); | 1425 DCHECK(layer_tree_host_); |
1421 const proto::BaseLayerProperties& base = proto.base(); | 1426 const proto::BaseLayerProperties& base = proto.base(); |
1422 | 1427 |
1423 transform_origin_ = ProtoToPoint3F(base.transform_origin()); | 1428 transform_origin_ = ProtoToPoint3F(base.transform_origin()); |
1424 background_color_ = base.background_color(); | 1429 background_color_ = base.background_color(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 clip_children_.reset(new std::set<Layer*>); | 1502 clip_children_.reset(new std::set<Layer*>); |
1498 for (int i = 0; i < base.clip_children_ids_size(); ++i) { | 1503 for (int i = 0; i < base.clip_children_ids_size(); ++i) { |
1499 int child_id = base.clip_children_ids(i); | 1504 int child_id = base.clip_children_ids(i); |
1500 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); | 1505 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); |
1501 clip_children_->insert(child.get()); | 1506 clip_children_->insert(child.get()); |
1502 } | 1507 } |
1503 | 1508 |
1504 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset()); | 1509 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset()); |
1505 | 1510 |
1506 update_rect_.Union(ProtoToRect(base.update_rect())); | 1511 update_rect_.Union(ProtoToRect(base.update_rect())); |
| 1512 |
| 1513 has_will_change_transform_hint_ = base.has_will_change_transform_hint(); |
1507 } | 1514 } |
1508 | 1515 |
1509 std::unique_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 1516 std::unique_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
1510 return LayerImpl::Create(tree_impl, layer_id_); | 1517 return LayerImpl::Create(tree_impl, layer_id_); |
1511 } | 1518 } |
1512 | 1519 |
1513 bool Layer::DrawsContent() const { | 1520 bool Layer::DrawsContent() const { |
1514 return draws_content_; | 1521 return draws_content_; |
1515 } | 1522 } |
1516 | 1523 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 } | 1673 } |
1667 transform_tree.set_needs_update(true); | 1674 transform_tree.set_needs_update(true); |
1668 } | 1675 } |
1669 } | 1676 } |
1670 | 1677 |
1671 bool Layer::HasActiveAnimationForTesting() const { | 1678 bool Layer::HasActiveAnimationForTesting() const { |
1672 return layer_tree_host_ ? layer_tree_host_->HasActiveAnimationForTesting(this) | 1679 return layer_tree_host_ ? layer_tree_host_->HasActiveAnimationForTesting(this) |
1673 : false; | 1680 : false; |
1674 } | 1681 } |
1675 | 1682 |
| 1683 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { |
| 1684 if (has_will_change_transform_hint_ == has_will_change) |
| 1685 return; |
| 1686 has_will_change_transform_hint_ = has_will_change; |
| 1687 SetNeedsCommit(); |
| 1688 } |
| 1689 |
1676 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { | 1690 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { |
1677 return nullptr; | 1691 return nullptr; |
1678 } | 1692 } |
1679 | 1693 |
1680 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | 1694 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { |
1681 return layer_tree_host_->rendering_stats_instrumentation(); | 1695 return layer_tree_host_->rendering_stats_instrumentation(); |
1682 } | 1696 } |
1683 | 1697 |
1684 void Layer::RemoveFromScrollTree() { | 1698 void Layer::RemoveFromScrollTree() { |
1685 if (scroll_children_.get()) { | 1699 if (scroll_children_.get()) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 ->data.num_copy_requests_in_subtree; | 1767 ->data.num_copy_requests_in_subtree; |
1754 } | 1768 } |
1755 | 1769 |
1756 gfx::Transform Layer::screen_space_transform() const { | 1770 gfx::Transform Layer::screen_space_transform() const { |
1757 DCHECK_NE(transform_tree_index_, -1); | 1771 DCHECK_NE(transform_tree_index_, -1); |
1758 return draw_property_utils::ScreenSpaceTransform( | 1772 return draw_property_utils::ScreenSpaceTransform( |
1759 this, layer_tree_host_->property_trees()->transform_tree); | 1773 this, layer_tree_host_->property_trees()->transform_tree); |
1760 } | 1774 } |
1761 | 1775 |
1762 } // namespace cc | 1776 } // namespace cc |
OLD | NEW |