Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: cc/layers/layer.cc

Issue 1912893002: cc : Stop pushing properties not used by LayerImpl to LayerImpl. (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_(false), 80 force_render_surface_(false),
81 transform_is_invertible_(true), 81 transform_is_invertible_(true),
82 has_render_surface_(false), 82 has_render_surface_(false),
83 subtree_property_changed_(false), 83 subtree_property_changed_(false),
84 layer_property_changed_(false),
84 background_color_(0), 85 background_color_(0),
85 safe_opaque_background_color_(0), 86 safe_opaque_background_color_(0),
86 opacity_(1.f), 87 opacity_(1.f),
87 blend_mode_(SkXfermode::kSrcOver_Mode), 88 blend_mode_(SkXfermode::kSrcOver_Mode),
88 draw_blend_mode_(SkXfermode::kSrcOver_Mode), 89 draw_blend_mode_(SkXfermode::kSrcOver_Mode),
89 scroll_parent_(nullptr), 90 scroll_parent_(nullptr),
90 clip_parent_(nullptr), 91 clip_parent_(nullptr),
91 replica_layer_(nullptr), 92 replica_layer_(nullptr),
92 client_(nullptr), 93 client_(nullptr),
93 num_unclipped_descendants_(0) {} 94 num_unclipped_descendants_(0) {}
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 901
901 touch_event_handler_region_ = region; 902 touch_event_handler_region_ = region;
902 SetNeedsCommit(); 903 SetNeedsCommit();
903 } 904 }
904 905
905 void Layer::SetForceRenderSurface(bool force) { 906 void Layer::SetForceRenderSurface(bool force) {
906 DCHECK(IsPropertyChangeAllowed()); 907 DCHECK(IsPropertyChangeAllowed());
907 if (force_render_surface_ == force) 908 if (force_render_surface_ == force)
908 return; 909 return;
909 force_render_surface_ = force; 910 force_render_surface_ = force;
911 SetLayerPropertyChanged();
910 SetNeedsCommit(); 912 SetNeedsCommit();
911 } 913 }
912 914
913 void Layer::SetDoubleSided(bool double_sided) { 915 void Layer::SetDoubleSided(bool double_sided) {
914 DCHECK(IsPropertyChangeAllowed()); 916 DCHECK(IsPropertyChangeAllowed());
915 if (double_sided_ == double_sided) 917 if (double_sided_ == double_sided)
916 return; 918 return;
917 double_sided_ = double_sided; 919 double_sided_ = double_sided;
918 SetNeedsCommit(); 920 SetNeedsCommit();
919 SetSubtreePropertyChanged(); 921 SetSubtreePropertyChanged();
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 layer->SetDebugInfo(TakeDebugInfo()); 1132 layer->SetDebugInfo(TakeDebugInfo());
1131 #else 1133 #else
1132 layer->SetDebugInfo(TakeDebugInfo()); 1134 layer->SetDebugInfo(TakeDebugInfo());
1133 #endif 1135 #endif
1134 1136
1135 layer->SetTransformTreeIndex(transform_tree_index()); 1137 layer->SetTransformTreeIndex(transform_tree_index());
1136 layer->SetEffectTreeIndex(effect_tree_index()); 1138 layer->SetEffectTreeIndex(effect_tree_index());
1137 layer->SetClipTreeIndex(clip_tree_index()); 1139 layer->SetClipTreeIndex(clip_tree_index());
1138 layer->SetScrollTreeIndex(scroll_tree_index()); 1140 layer->SetScrollTreeIndex(scroll_tree_index());
1139 layer->set_offset_to_transform_parent(offset_to_transform_parent_); 1141 layer->set_offset_to_transform_parent(offset_to_transform_parent_);
1140 layer->SetDoubleSided(double_sided_);
1141 layer->SetDrawsContent(DrawsContent()); 1142 layer->SetDrawsContent(DrawsContent());
1142 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); 1143 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_);
1143 layer->SetHasRenderSurface(has_render_surface_); 1144 layer->SetHasRenderSurface(has_render_surface_);
1144 // subtree_property_changed_ is propagated to all descendants while building 1145 // subtree_property_changed_ is propagated to all descendants while building
1145 // property trees. So, it is enough to check it only for the current layer. 1146 // property trees. So, it is enough to check it only for the current layer.
1146 if (subtree_property_changed_) 1147 if (subtree_property_changed_ || layer_property_changed_)
1147 layer->NoteLayerPropertyChanged(); 1148 layer->NoteLayerPropertyChanged();
1148 layer->SetForceRenderSurface(force_render_surface_);
1149 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) 1149 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating())
1150 layer->SetFilters(filters_); 1150 layer->SetFilters(filters_);
1151 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); 1151 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly()));
1152 layer->SetBackgroundFilters(background_filters()); 1152 layer->SetBackgroundFilters(background_filters());
1153 layer->SetMasksToBounds(masks_to_bounds_); 1153 layer->SetMasksToBounds(masks_to_bounds_);
1154 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); 1154 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_);
1155 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); 1155 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_);
1156 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); 1156 layer->SetTouchEventHandlerRegion(touch_event_handler_region_);
1157 layer->SetContentsOpaque(contents_opaque_); 1157 layer->SetContentsOpaque(contents_opaque_);
1158 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) 1158 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating())
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 1263
1264 // If the main thread commits multiple times before the impl thread actually 1264 // If the main thread commits multiple times before the impl thread actually
1265 // draws, then damage tracking will become incorrect if we simply clobber the 1265 // draws, then damage tracking will become incorrect if we simply clobber the
1266 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. 1266 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e.
1267 // union) any update changes that have occurred on the main thread. 1267 // union) any update changes that have occurred on the main thread.
1268 update_rect_.Union(layer->update_rect()); 1268 update_rect_.Union(layer->update_rect());
1269 layer->SetUpdateRect(update_rect_); 1269 layer->SetUpdateRect(update_rect_);
1270 1270
1271 // Reset any state that should be cleared for the next update. 1271 // Reset any state that should be cleared for the next update.
1272 subtree_property_changed_ = false; 1272 subtree_property_changed_ = false;
1273 layer_property_changed_ = false;
1273 update_rect_ = gfx::Rect(); 1274 update_rect_ = gfx::Rect();
1274 1275
1275 layer_tree_host()->RemoveLayerShouldPushProperties(this); 1276 layer_tree_host()->RemoveLayerShouldPushProperties(this);
1276 } 1277 }
1277 1278
1278 void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { 1279 void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const {
1279 proto->set_type(proto::LayerNode::LAYER); 1280 proto->set_type(proto::LayerNode::LAYER);
1280 } 1281 }
1281 1282
1282 void Layer::ToLayerNodeProto(proto::LayerNode* proto) const { 1283 void Layer::ToLayerNodeProto(proto::LayerNode* proto) const {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 base->set_effect_tree_index(effect_tree_index_); 1405 base->set_effect_tree_index(effect_tree_index_);
1405 base->set_clip_tree_index(clip_tree_index_); 1406 base->set_clip_tree_index(clip_tree_index_);
1406 base->set_scroll_tree_index(scroll_tree_index_); 1407 base->set_scroll_tree_index(scroll_tree_index_);
1407 Vector2dFToProto(offset_to_transform_parent_, 1408 Vector2dFToProto(offset_to_transform_parent_,
1408 base->mutable_offset_to_transform_parent()); 1409 base->mutable_offset_to_transform_parent());
1409 base->set_double_sided(double_sided_); 1410 base->set_double_sided(double_sided_);
1410 base->set_draws_content(draws_content_); 1411 base->set_draws_content(draws_content_);
1411 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); 1412 base->set_hide_layer_and_subtree(hide_layer_and_subtree_);
1412 base->set_has_render_surface(has_render_surface_); 1413 base->set_has_render_surface(has_render_surface_);
1413 base->set_subtree_property_changed(subtree_property_changed_); 1414 base->set_subtree_property_changed(subtree_property_changed_);
1415 base->set_layer_property_changed(layer_property_changed_);
1414 1416
1415 // TODO(nyquist): Add support for serializing FilterOperations for 1417 // TODO(nyquist): Add support for serializing FilterOperations for
1416 // |filters_| and |background_filters_|. See crbug.com/541321. 1418 // |filters_| and |background_filters_|. See crbug.com/541321.
1417 1419
1418 base->set_masks_to_bounds(masks_to_bounds_); 1420 base->set_masks_to_bounds(masks_to_bounds_);
1419 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); 1421 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_);
1420 RegionToProto(non_fast_scrollable_region_, 1422 RegionToProto(non_fast_scrollable_region_,
1421 base->mutable_non_fast_scrollable_region()); 1423 base->mutable_non_fast_scrollable_region());
1422 RegionToProto(touch_event_handler_region_, 1424 RegionToProto(touch_event_handler_region_,
1423 base->mutable_touch_event_handler_region()); 1425 base->mutable_touch_event_handler_region());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 transform_tree_index_ = base.transform_free_index(); 1489 transform_tree_index_ = base.transform_free_index();
1488 effect_tree_index_ = base.effect_tree_index(); 1490 effect_tree_index_ = base.effect_tree_index();
1489 clip_tree_index_ = base.clip_tree_index(); 1491 clip_tree_index_ = base.clip_tree_index();
1490 scroll_tree_index_ = base.scroll_tree_index(); 1492 scroll_tree_index_ = base.scroll_tree_index();
1491 offset_to_transform_parent_ = 1493 offset_to_transform_parent_ =
1492 ProtoToVector2dF(base.offset_to_transform_parent()); 1494 ProtoToVector2dF(base.offset_to_transform_parent());
1493 double_sided_ = base.double_sided(); 1495 double_sided_ = base.double_sided();
1494 draws_content_ = base.draws_content(); 1496 draws_content_ = base.draws_content();
1495 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); 1497 hide_layer_and_subtree_ = base.hide_layer_and_subtree();
1496 has_render_surface_ = base.has_render_surface(); 1498 has_render_surface_ = base.has_render_surface();
1497 subtree_property_changed_ = base.subtree_property_changed(); 1499 layer_property_changed_ = base.layer_property_changed();
1498 masks_to_bounds_ = base.masks_to_bounds(); 1500 masks_to_bounds_ = base.masks_to_bounds();
1499 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); 1501 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons();
1500 non_fast_scrollable_region_ = 1502 non_fast_scrollable_region_ =
1501 RegionFromProto(base.non_fast_scrollable_region()); 1503 RegionFromProto(base.non_fast_scrollable_region());
1502 touch_event_handler_region_ = 1504 touch_event_handler_region_ =
1503 RegionFromProto(base.touch_event_handler_region()); 1505 RegionFromProto(base.touch_event_handler_region());
1504 contents_opaque_ = base.contents_opaque(); 1506 contents_opaque_ = base.contents_opaque();
1505 opacity_ = base.opacity(); 1507 opacity_ = base.opacity();
1506 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode()); 1508 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode());
1507 is_root_for_isolated_group_ = base.is_root_for_isolated_group(); 1509 is_root_for_isolated_group_ = base.is_root_for_isolated_group();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 SetNeedsPushProperties(); 1636 SetNeedsPushProperties();
1635 } 1637 }
1636 1638
1637 void Layer::SetSubtreePropertyChanged() { 1639 void Layer::SetSubtreePropertyChanged() {
1638 if (subtree_property_changed_) 1640 if (subtree_property_changed_)
1639 return; 1641 return;
1640 subtree_property_changed_ = true; 1642 subtree_property_changed_ = true;
1641 SetNeedsPushProperties(); 1643 SetNeedsPushProperties();
1642 } 1644 }
1643 1645
1646 void Layer::SetLayerPropertyChanged() {
1647 if (layer_property_changed_)
1648 return;
1649 layer_property_changed_ = true;
1650 SetNeedsPushProperties();
1651 }
1652
1644 gfx::ScrollOffset Layer::ScrollOffsetForAnimation() const { 1653 gfx::ScrollOffset Layer::ScrollOffsetForAnimation() const {
1645 return CurrentScrollOffset(); 1654 return CurrentScrollOffset();
1646 } 1655 }
1647 1656
1648 // On<Property>Animated is called due to an ongoing accelerated animation. 1657 // On<Property>Animated is called due to an ongoing accelerated animation.
1649 // Since this animation is also being run on the compositor thread, there 1658 // Since this animation is also being run on the compositor thread, there
1650 // is no need to request a commit to push this value over, so the value is 1659 // is no need to request a commit to push this value over, so the value is
1651 // set directly rather than by calling Set<Property>. 1660 // set directly rather than by calling Set<Property>.
1652 void Layer::OnFilterAnimated(const FilterOperations& filters) { 1661 void Layer::OnFilterAnimated(const FilterOperations& filters) {
1653 filters_ = filters; 1662 filters_ = filters;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 ->data.num_copy_requests_in_subtree; 1828 ->data.num_copy_requests_in_subtree;
1820 } 1829 }
1821 1830
1822 gfx::Transform Layer::screen_space_transform() const { 1831 gfx::Transform Layer::screen_space_transform() const {
1823 DCHECK_NE(transform_tree_index_, -1); 1832 DCHECK_NE(transform_tree_index_, -1);
1824 return draw_property_utils::ScreenSpaceTransform( 1833 return draw_property_utils::ScreenSpaceTransform(
1825 this, layer_tree_host_->property_trees()->transform_tree); 1834 this, layer_tree_host_->property_trees()->transform_tree);
1826 } 1835 }
1827 1836
1828 } // namespace cc 1837 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698