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

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

Issue 1588093004: Compute if a layer is drawn without LayerTree hierarchy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 stacking_order_changed_(false), 66 stacking_order_changed_(false),
67 double_sided_(true), 67 double_sided_(true),
68 should_flatten_transform_(true), 68 should_flatten_transform_(true),
69 should_flatten_transform_from_property_tree_(false), 69 should_flatten_transform_from_property_tree_(false),
70 layer_property_changed_(false), 70 layer_property_changed_(false),
71 masks_to_bounds_(false), 71 masks_to_bounds_(false),
72 contents_opaque_(false), 72 contents_opaque_(false),
73 is_root_for_isolated_group_(false), 73 is_root_for_isolated_group_(false),
74 use_parent_backface_visibility_(false), 74 use_parent_backface_visibility_(false),
75 draws_content_(false), 75 draws_content_(false),
76 hide_layer_and_subtree_(false),
77 transform_is_invertible_(true), 76 transform_is_invertible_(true),
78 is_container_for_fixed_position_layers_(false), 77 is_container_for_fixed_position_layers_(false),
79 is_affected_by_page_scale_(true), 78 is_affected_by_page_scale_(true),
80 was_ever_ready_since_last_transform_animation_(true), 79 was_ever_ready_since_last_transform_animation_(true),
81 background_color_(0), 80 background_color_(0),
82 opacity_(1.0), 81 opacity_(1.0),
83 blend_mode_(SkXfermode::kSrcOver_Mode), 82 blend_mode_(SkXfermode::kSrcOver_Mode),
84 draw_blend_mode_(SkXfermode::kSrcOver_Mode), 83 draw_blend_mode_(SkXfermode::kSrcOver_Mode),
85 num_descendants_that_draw_content_(0), 84 num_descendants_that_draw_content_(0),
86 transform_tree_index_(-1), 85 transform_tree_index_(-1),
87 effect_tree_index_(-1), 86 effect_tree_index_(-1),
88 clip_tree_index_(-1), 87 clip_tree_index_(-1),
89 draw_depth_(0.f), 88 draw_depth_(0.f),
90 needs_push_properties_(false), 89 needs_push_properties_(false),
91 num_dependents_need_push_properties_(0), 90 num_dependents_need_push_properties_(0),
92 sorting_context_id_(0), 91 sorting_context_id_(0),
93 current_draw_mode_(DRAW_MODE_NONE), 92 current_draw_mode_(DRAW_MODE_NONE),
94 element_id_(0), 93 element_id_(0),
95 mutable_properties_(kMutablePropertyNone), 94 mutable_properties_(kMutablePropertyNone),
96 force_render_surface_(false), 95 force_render_surface_(false),
97 frame_timing_requests_dirty_(false), 96 frame_timing_requests_dirty_(false),
98 visited_(false), 97 visited_(false),
99 layer_or_descendant_is_drawn_(false), 98 layer_or_descendant_is_drawn_(false),
100 layer_or_descendant_has_input_handler_(false), 99 layer_or_descendant_has_input_handler_(false),
101 sorted_for_recursion_(false), 100 sorted_for_recursion_(false) {
102 is_hidden_from_property_trees_(false) {
103 DCHECK_GT(layer_id_, 0); 101 DCHECK_GT(layer_id_, 0);
104 DCHECK(layer_tree_impl_); 102 DCHECK(layer_tree_impl_);
105 layer_tree_impl_->RegisterLayer(this); 103 layer_tree_impl_->RegisterLayer(this);
106 104
107 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { 105 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) {
108 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); 106 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar();
109 layer_animation_controller_ = 107 layer_animation_controller_ =
110 registrar->GetAnimationControllerForId(layer_id_); 108 registrar->GetAnimationControllerForId(layer_id_);
111 layer_animation_controller_->AddValueObserver(this); 109 layer_animation_controller_->AddValueObserver(this);
112 if (IsActive()) { 110 if (IsActive()) {
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) { 594 scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) {
597 return LayerImpl::Create(tree_impl, layer_id_, scroll_offset_); 595 return LayerImpl::Create(tree_impl, layer_id_, scroll_offset_);
598 } 596 }
599 597
600 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { 598 void LayerImpl::PushPropertiesTo(LayerImpl* layer) {
601 layer->SetTransformOrigin(transform_origin_); 599 layer->SetTransformOrigin(transform_origin_);
602 layer->SetBackgroundColor(background_color_); 600 layer->SetBackgroundColor(background_color_);
603 layer->SetBounds(bounds_); 601 layer->SetBounds(bounds_);
604 layer->SetDoubleSided(double_sided_); 602 layer->SetDoubleSided(double_sided_);
605 layer->SetDrawsContent(DrawsContent()); 603 layer->SetDrawsContent(DrawsContent());
606 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_);
607 // If whether layer has render surface changes, we need to update draw 604 // If whether layer has render surface changes, we need to update draw
608 // properties. 605 // properties.
609 // TODO(weiliangc): Should be safely removed after impl side is able to 606 // TODO(weiliangc): Should be safely removed after impl side is able to
610 // update render surfaces without rebuilding property trees. 607 // update render surfaces without rebuilding property trees.
611 if (layer->has_render_surface() != has_render_surface()) 608 if (layer->has_render_surface() != has_render_surface())
612 layer->layer_tree_impl()->set_needs_update_draw_properties(); 609 layer->layer_tree_impl()->set_needs_update_draw_properties();
613 layer->SetHasRenderSurface(!!render_surface()); 610 layer->SetHasRenderSurface(!!render_surface());
614 layer->SetForceRenderSurface(force_render_surface_); 611 layer->SetForceRenderSurface(force_render_surface_);
615 layer->SetFilters(filters()); 612 layer->SetFilters(filters());
616 layer->SetBackgroundFilters(background_filters()); 613 layer->SetBackgroundFilters(background_filters());
(...skipping 29 matching lines...) Expand all
646 643
647 layer->PushScrollOffset(nullptr); 644 layer->PushScrollOffset(nullptr);
648 645
649 layer->Set3dSortingContextId(sorting_context_id_); 646 layer->Set3dSortingContextId(sorting_context_id_);
650 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); 647 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_);
651 648
652 layer->SetTransformTreeIndex(transform_tree_index_); 649 layer->SetTransformTreeIndex(transform_tree_index_);
653 layer->SetClipTreeIndex(clip_tree_index_); 650 layer->SetClipTreeIndex(clip_tree_index_);
654 layer->SetEffectTreeIndex(effect_tree_index_); 651 layer->SetEffectTreeIndex(effect_tree_index_);
655 layer->set_offset_to_transform_parent(offset_to_transform_parent_); 652 layer->set_offset_to_transform_parent(offset_to_transform_parent_);
656 layer->set_is_hidden_from_property_trees(is_hidden_from_property_trees_);
657 653
658 LayerImpl* scroll_parent = nullptr; 654 LayerImpl* scroll_parent = nullptr;
659 if (scroll_parent_) { 655 if (scroll_parent_) {
660 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); 656 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id());
661 DCHECK(scroll_parent); 657 DCHECK(scroll_parent);
662 } 658 }
663 659
664 layer->SetScrollParent(scroll_parent); 660 layer->SetScrollParent(scroll_parent);
665 if (scroll_children_) { 661 if (scroll_children_) {
666 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; 662 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>;
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 } 1119 }
1124 1120
1125 void LayerImpl::SetDrawsContent(bool draws_content) { 1121 void LayerImpl::SetDrawsContent(bool draws_content) {
1126 if (draws_content_ == draws_content) 1122 if (draws_content_ == draws_content)
1127 return; 1123 return;
1128 1124
1129 draws_content_ = draws_content; 1125 draws_content_ = draws_content;
1130 NoteLayerPropertyChanged(); 1126 NoteLayerPropertyChanged();
1131 } 1127 }
1132 1128
1133 void LayerImpl::SetHideLayerAndSubtree(bool hide) {
1134 if (hide_layer_and_subtree_ == hide)
1135 return;
1136
1137 hide_layer_and_subtree_ = hide;
1138 NoteLayerPropertyChangedForSubtree();
1139 }
1140
1141 void LayerImpl::SetTransformOrigin(const gfx::Point3F& transform_origin) { 1129 void LayerImpl::SetTransformOrigin(const gfx::Point3F& transform_origin) {
1142 if (transform_origin_ == transform_origin) 1130 if (transform_origin_ == transform_origin)
1143 return; 1131 return;
1144 transform_origin_ = transform_origin; 1132 transform_origin_ = transform_origin;
1145 NoteLayerPropertyChangedForSubtree(); 1133 NoteLayerPropertyChangedForSubtree();
1146 } 1134 }
1147 1135
1148 void LayerImpl::SetBackgroundColor(SkColor background_color) { 1136 void LayerImpl::SetBackgroundColor(SkColor background_color) {
1149 if (background_color_ == background_color) 1137 if (background_color_ == background_color)
1150 return; 1138 return;
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 } 1898 }
1911 1899
1912 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { 1900 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const {
1913 gfx::Transform scaled_draw_transform = DrawTransform(); 1901 gfx::Transform scaled_draw_transform = DrawTransform();
1914 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); 1902 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale);
1915 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(bounds(), scale); 1903 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(bounds(), scale);
1916 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, 1904 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform,
1917 gfx::Rect(scaled_bounds)); 1905 gfx::Rect(scaled_bounds));
1918 } 1906 }
1919 1907
1920 bool LayerImpl::LayerIsHidden() const { 1908 bool LayerImpl::IsHidden() const {
1921 if (layer_tree_impl()->settings().use_property_trees) { 1909 if (layer_tree_impl()->settings().use_property_trees) {
1922 return is_hidden_from_property_trees_; 1910 EffectTree& effect_tree = layer_tree_impl_->property_trees()->effect_tree;
1911 EffectNode* node = effect_tree.Node(effect_tree_index_);
1912 return node->data.screen_space_opacity == 0.f;
1923 } else { 1913 } else {
1924 return hide_layer_and_subtree_ || (parent() && parent()->LayerIsHidden()); 1914 return opacity_ == 0.f || (parent() && parent()->IsHidden());
1925 } 1915 }
1926 } 1916 }
1927 1917
1928 float LayerImpl::GetIdealContentsScale() const { 1918 float LayerImpl::GetIdealContentsScale() const {
1929 float page_scale = IsAffectedByPageScale() 1919 float page_scale = IsAffectedByPageScale()
1930 ? layer_tree_impl()->current_page_scale_factor() 1920 ? layer_tree_impl()->current_page_scale_factor()
1931 : 1.f; 1921 : 1.f;
1932 float device_scale = layer_tree_impl()->device_scale_factor(); 1922 float device_scale = layer_tree_impl()->device_scale_factor();
1933 1923
1934 float default_scale = page_scale * device_scale; 1924 float default_scale = page_scale * device_scale;
1935 if (!layer_tree_impl() 1925 if (!layer_tree_impl()
1936 ->settings() 1926 ->settings()
1937 .layer_transforms_should_scale_layer_contents) { 1927 .layer_transforms_should_scale_layer_contents) {
1938 return default_scale; 1928 return default_scale;
1939 } 1929 }
1940 1930
1941 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1931 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1942 DrawTransform(), default_scale); 1932 DrawTransform(), default_scale);
1943 return std::max(transform_scales.x(), transform_scales.y()); 1933 return std::max(transform_scales.x(), transform_scales.y());
1944 } 1934 }
1945 1935
1946 } // namespace cc 1936 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698