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

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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) { 573 scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) {
576 return LayerImpl::Create(tree_impl, layer_id_, scroll_offset_); 574 return LayerImpl::Create(tree_impl, layer_id_, scroll_offset_);
577 } 575 }
578 576
579 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { 577 void LayerImpl::PushPropertiesTo(LayerImpl* layer) {
580 layer->SetTransformOrigin(transform_origin_); 578 layer->SetTransformOrigin(transform_origin_);
581 layer->SetBackgroundColor(background_color_); 579 layer->SetBackgroundColor(background_color_);
582 layer->SetBounds(bounds_); 580 layer->SetBounds(bounds_);
583 layer->SetDoubleSided(double_sided_); 581 layer->SetDoubleSided(double_sided_);
584 layer->SetDrawsContent(DrawsContent()); 582 layer->SetDrawsContent(DrawsContent());
585 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_);
586 // If whether layer has render surface changes, we need to update draw 583 // If whether layer has render surface changes, we need to update draw
587 // properties. 584 // properties.
588 // TODO(weiliangc): Should be safely removed after impl side is able to 585 // TODO(weiliangc): Should be safely removed after impl side is able to
589 // update render surfaces without rebuilding property trees. 586 // update render surfaces without rebuilding property trees.
590 if (layer->has_render_surface() != has_render_surface()) 587 if (layer->has_render_surface() != has_render_surface())
591 layer->layer_tree_impl()->set_needs_update_draw_properties(); 588 layer->layer_tree_impl()->set_needs_update_draw_properties();
592 layer->SetHasRenderSurface(!!render_surface()); 589 layer->SetHasRenderSurface(!!render_surface());
593 layer->SetForceRenderSurface(force_render_surface_); 590 layer->SetForceRenderSurface(force_render_surface_);
594 layer->SetFilters(filters()); 591 layer->SetFilters(filters());
595 layer->SetBackgroundFilters(background_filters()); 592 layer->SetBackgroundFilters(background_filters());
(...skipping 29 matching lines...) Expand all
625 622
626 layer->PushScrollOffset(nullptr); 623 layer->PushScrollOffset(nullptr);
627 624
628 layer->Set3dSortingContextId(sorting_context_id_); 625 layer->Set3dSortingContextId(sorting_context_id_);
629 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); 626 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_);
630 627
631 layer->SetTransformTreeIndex(transform_tree_index_); 628 layer->SetTransformTreeIndex(transform_tree_index_);
632 layer->SetClipTreeIndex(clip_tree_index_); 629 layer->SetClipTreeIndex(clip_tree_index_);
633 layer->SetEffectTreeIndex(effect_tree_index_); 630 layer->SetEffectTreeIndex(effect_tree_index_);
634 layer->set_offset_to_transform_parent(offset_to_transform_parent_); 631 layer->set_offset_to_transform_parent(offset_to_transform_parent_);
635 layer->set_is_hidden_from_property_trees(is_hidden_from_property_trees_);
636 632
637 LayerImpl* scroll_parent = nullptr; 633 LayerImpl* scroll_parent = nullptr;
638 if (scroll_parent_) { 634 if (scroll_parent_) {
639 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); 635 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id());
640 DCHECK(scroll_parent); 636 DCHECK(scroll_parent);
641 } 637 }
642 638
643 layer->SetScrollParent(scroll_parent); 639 layer->SetScrollParent(scroll_parent);
644 if (scroll_children_) { 640 if (scroll_children_) {
645 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; 641 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>;
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 } 1098 }
1103 1099
1104 void LayerImpl::SetDrawsContent(bool draws_content) { 1100 void LayerImpl::SetDrawsContent(bool draws_content) {
1105 if (draws_content_ == draws_content) 1101 if (draws_content_ == draws_content)
1106 return; 1102 return;
1107 1103
1108 draws_content_ = draws_content; 1104 draws_content_ = draws_content;
1109 NoteLayerPropertyChanged(); 1105 NoteLayerPropertyChanged();
1110 } 1106 }
1111 1107
1112 void LayerImpl::SetHideLayerAndSubtree(bool hide) {
1113 if (hide_layer_and_subtree_ == hide)
1114 return;
1115
1116 hide_layer_and_subtree_ = hide;
1117 NoteLayerPropertyChangedForSubtree();
1118 }
1119
1120 void LayerImpl::SetTransformOrigin(const gfx::Point3F& transform_origin) { 1108 void LayerImpl::SetTransformOrigin(const gfx::Point3F& transform_origin) {
1121 if (transform_origin_ == transform_origin) 1109 if (transform_origin_ == transform_origin)
1122 return; 1110 return;
1123 transform_origin_ = transform_origin; 1111 transform_origin_ = transform_origin;
1124 NoteLayerPropertyChangedForSubtree(); 1112 NoteLayerPropertyChangedForSubtree();
1125 } 1113 }
1126 1114
1127 void LayerImpl::SetBackgroundColor(SkColor background_color) { 1115 void LayerImpl::SetBackgroundColor(SkColor background_color) {
1128 if (background_color_ == background_color) 1116 if (background_color_ == background_color)
1129 return; 1117 return;
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 } 1877 }
1890 1878
1891 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { 1879 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const {
1892 gfx::Transform scaled_draw_transform = DrawTransform(); 1880 gfx::Transform scaled_draw_transform = DrawTransform();
1893 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); 1881 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale);
1894 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(bounds(), scale); 1882 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(bounds(), scale);
1895 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, 1883 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform,
1896 gfx::Rect(scaled_bounds)); 1884 gfx::Rect(scaled_bounds));
1897 } 1885 }
1898 1886
1899 bool LayerImpl::LayerIsHidden() const { 1887 bool LayerImpl::IsHidden() const {
1900 if (layer_tree_impl()->settings().use_property_trees) { 1888 if (layer_tree_impl()->settings().use_property_trees) {
1901 return is_hidden_from_property_trees_; 1889 EffectTree& effect_tree = layer_tree_impl_->property_trees()->effect_tree;
1890 EffectNode* node = effect_tree.Node(effect_tree_index_);
1891 return node->data.screen_space_opacity == 0.f;
1902 } else { 1892 } else {
1903 return hide_layer_and_subtree_ || (parent() && parent()->LayerIsHidden()); 1893 return opacity_ == 0.f || (parent() && parent()->IsHidden());
1904 } 1894 }
1905 } 1895 }
1906 1896
1897 bool LayerImpl::IsDrawnFromPropertyTrees() const {
1898 // Layers that have screen space opacity are hidden. So they are not drawn.
ajuma 2016/01/15 15:02:46 "screen space opacity 0"
jaydasika 2016/01/19 20:02:49 Done.
1899 // Exceptions:
1900 // 1) Layers that contribute to copy requests, whether hidden or not, must be
1901 // drawn.
1902 // 2) Layers that have a background filter or an animating opacity.
1903 if (HasPotentiallyRunningOpacityAnimation() ||
ajuma 2016/01/15 15:02:46 Do we need the animation check on the compositor s
jaydasika 2016/01/15 18:23:05 Won't we need it to handle animating opacity on th
ajuma 2016/01/15 18:48:16 Ah, good point.
1904 !background_filters().IsEmpty())
1905 return true;
1906 EffectTree& effect_tree = layer_tree_impl_->property_trees()->effect_tree;
1907 EffectNode* node = effect_tree.Node(effect_tree_index_);
1908 return node->data.screen_space_opacity != 0.f ||
1909 node->data.contributes_to_copy_request;
1910 }
1911
1907 float LayerImpl::GetIdealContentsScale() const { 1912 float LayerImpl::GetIdealContentsScale() const {
1908 float page_scale = IsAffectedByPageScale() 1913 float page_scale = IsAffectedByPageScale()
1909 ? layer_tree_impl()->current_page_scale_factor() 1914 ? layer_tree_impl()->current_page_scale_factor()
1910 : 1.f; 1915 : 1.f;
1911 float device_scale = layer_tree_impl()->device_scale_factor(); 1916 float device_scale = layer_tree_impl()->device_scale_factor();
1912 1917
1913 float default_scale = page_scale * device_scale; 1918 float default_scale = page_scale * device_scale;
1914 if (!layer_tree_impl() 1919 if (!layer_tree_impl()
1915 ->settings() 1920 ->settings()
1916 .layer_transforms_should_scale_layer_contents) { 1921 .layer_transforms_should_scale_layer_contents) {
1917 return default_scale; 1922 return default_scale;
1918 } 1923 }
1919 1924
1920 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1925 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1921 DrawTransform(), default_scale); 1926 DrawTransform(), default_scale);
1922 return std::max(transform_scales.x(), transform_scales.y()); 1927 return std::max(transform_scales.x(), transform_scales.y());
1923 } 1928 }
1924 1929
1925 } // namespace cc 1930 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698