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

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

Issue 2099743002: cc: Move background filters to the effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ' Created 4 years, 5 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
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 hide_layer_and_subtree_(false), 72 hide_layer_and_subtree_(false),
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 subtree_property_changed_(false), 81 subtree_property_changed_(false),
82 layer_property_changed_(false),
82 has_will_change_transform_hint_(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),
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 456
456 bool Layer::HasPotentiallyRunningFilterAnimation() const { 457 bool Layer::HasPotentiallyRunningFilterAnimation() const {
457 return layer_tree_host_->HasPotentiallyRunningFilterAnimation(this); 458 return layer_tree_host_->HasPotentiallyRunningFilterAnimation(this);
458 } 459 }
459 460
460 void Layer::SetBackgroundFilters(const FilterOperations& filters) { 461 void Layer::SetBackgroundFilters(const FilterOperations& filters) {
461 DCHECK(IsPropertyChangeAllowed()); 462 DCHECK(IsPropertyChangeAllowed());
462 if (background_filters_ == filters) 463 if (background_filters_ == filters)
463 return; 464 return;
464 background_filters_ = filters; 465 background_filters_ = filters;
466 SetLayerPropertyChanged();
465 SetNeedsCommit(); 467 SetNeedsCommit();
466 } 468 }
467 469
468 void Layer::SetOpacity(float opacity) { 470 void Layer::SetOpacity(float opacity) {
469 DCHECK(IsPropertyChangeAllowed()); 471 DCHECK(IsPropertyChangeAllowed());
470 DCHECK_GE(opacity, 0.f); 472 DCHECK_GE(opacity, 0.f);
471 DCHECK_LE(opacity, 1.f); 473 DCHECK_LE(opacity, 1.f);
472 474
473 if (opacity_ == opacity) 475 if (opacity_ == opacity)
474 return; 476 return;
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 #endif 1162 #endif
1161 1163
1162 layer->SetTransformTreeIndex(transform_tree_index()); 1164 layer->SetTransformTreeIndex(transform_tree_index());
1163 layer->SetEffectTreeIndex(effect_tree_index()); 1165 layer->SetEffectTreeIndex(effect_tree_index());
1164 layer->SetClipTreeIndex(clip_tree_index()); 1166 layer->SetClipTreeIndex(clip_tree_index());
1165 layer->SetScrollTreeIndex(scroll_tree_index()); 1167 layer->SetScrollTreeIndex(scroll_tree_index());
1166 layer->set_offset_to_transform_parent(offset_to_transform_parent_); 1168 layer->set_offset_to_transform_parent(offset_to_transform_parent_);
1167 layer->SetDrawsContent(DrawsContent()); 1169 layer->SetDrawsContent(DrawsContent());
1168 // subtree_property_changed_ is propagated to all descendants while building 1170 // subtree_property_changed_ is propagated to all descendants while building
1169 // property trees. So, it is enough to check it only for the current layer. 1171 // property trees. So, it is enough to check it only for the current layer.
1170 if (subtree_property_changed_) 1172 if (subtree_property_changed_ || layer_property_changed_)
1171 layer->NoteLayerPropertyChanged(); 1173 layer->NoteLayerPropertyChanged();
1172 if (!FilterIsAnimating()) 1174 if (!FilterIsAnimating())
1173 layer->SetFilters(filters_); 1175 layer->SetFilters(filters_);
1174 layer->SetBackgroundFilters(background_filters());
1175 layer->SetMasksToBounds(masks_to_bounds_); 1176 layer->SetMasksToBounds(masks_to_bounds_);
1176 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); 1177 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_);
1177 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); 1178 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_);
1178 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); 1179 layer->SetTouchEventHandlerRegion(touch_event_handler_region_);
1179 layer->SetContentsOpaque(contents_opaque_); 1180 layer->SetContentsOpaque(contents_opaque_);
1180 layer->SetBlendMode(blend_mode_); 1181 layer->SetBlendMode(blend_mode_);
1181 layer->SetPosition(position_); 1182 layer->SetPosition(position_);
1182 layer->set_should_flatten_transform_from_property_tree( 1183 layer->set_should_flatten_transform_from_property_tree(
1183 should_flatten_transform_from_property_tree_); 1184 should_flatten_transform_from_property_tree_);
1184 layer->set_draw_blend_mode(draw_blend_mode_); 1185 layer->set_draw_blend_mode(draw_blend_mode_);
(...skipping 24 matching lines...) Expand all
1209 // draws, then damage tracking will become incorrect if we simply clobber the 1210 // draws, then damage tracking will become incorrect if we simply clobber the
1210 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. 1211 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e.
1211 // union) any update changes that have occurred on the main thread. 1212 // union) any update changes that have occurred on the main thread.
1212 update_rect_.Union(layer->update_rect()); 1213 update_rect_.Union(layer->update_rect());
1213 layer->SetUpdateRect(update_rect_); 1214 layer->SetUpdateRect(update_rect_);
1214 1215
1215 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); 1216 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint());
1216 1217
1217 // Reset any state that should be cleared for the next update. 1218 // Reset any state that should be cleared for the next update.
1218 subtree_property_changed_ = false; 1219 subtree_property_changed_ = false;
1220 layer_property_changed_ = false;
1219 update_rect_ = gfx::Rect(); 1221 update_rect_ = gfx::Rect();
1220 1222
1221 layer_tree_host()->RemoveLayerShouldPushProperties(this); 1223 layer_tree_host()->RemoveLayerShouldPushProperties(this);
1222 } 1224 }
1223 1225
1224 void Layer::TakeCopyRequests( 1226 void Layer::TakeCopyRequests(
1225 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) { 1227 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) {
1226 for (auto& it : copy_requests_) { 1228 for (auto& it : copy_requests_) {
1227 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = 1229 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner =
1228 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); 1230 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 base->set_transform_free_index(transform_tree_index_); 1373 base->set_transform_free_index(transform_tree_index_);
1372 base->set_effect_tree_index(effect_tree_index_); 1374 base->set_effect_tree_index(effect_tree_index_);
1373 base->set_clip_tree_index(clip_tree_index_); 1375 base->set_clip_tree_index(clip_tree_index_);
1374 base->set_scroll_tree_index(scroll_tree_index_); 1376 base->set_scroll_tree_index(scroll_tree_index_);
1375 Vector2dFToProto(offset_to_transform_parent_, 1377 Vector2dFToProto(offset_to_transform_parent_,
1376 base->mutable_offset_to_transform_parent()); 1378 base->mutable_offset_to_transform_parent());
1377 base->set_double_sided(double_sided_); 1379 base->set_double_sided(double_sided_);
1378 base->set_draws_content(draws_content_); 1380 base->set_draws_content(draws_content_);
1379 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); 1381 base->set_hide_layer_and_subtree(hide_layer_and_subtree_);
1380 base->set_subtree_property_changed(subtree_property_changed_); 1382 base->set_subtree_property_changed(subtree_property_changed_);
1383 base->set_layer_property_changed(layer_property_changed_);
1381 1384
1382 // TODO(nyquist): Add support for serializing FilterOperations for 1385 // TODO(nyquist): Add support for serializing FilterOperations for
1383 // |filters_| and |background_filters_|. See crbug.com/541321. 1386 // |filters_| and |background_filters_|. See crbug.com/541321.
1384 1387
1385 base->set_masks_to_bounds(masks_to_bounds_); 1388 base->set_masks_to_bounds(masks_to_bounds_);
1386 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); 1389 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_);
1387 RegionToProto(non_fast_scrollable_region_, 1390 RegionToProto(non_fast_scrollable_region_,
1388 base->mutable_non_fast_scrollable_region()); 1391 base->mutable_non_fast_scrollable_region());
1389 RegionToProto(touch_event_handler_region_, 1392 RegionToProto(touch_event_handler_region_,
1390 base->mutable_touch_event_handler_region()); 1393 base->mutable_touch_event_handler_region());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 transform_tree_index_ = base.transform_free_index(); 1458 transform_tree_index_ = base.transform_free_index();
1456 effect_tree_index_ = base.effect_tree_index(); 1459 effect_tree_index_ = base.effect_tree_index();
1457 clip_tree_index_ = base.clip_tree_index(); 1460 clip_tree_index_ = base.clip_tree_index();
1458 scroll_tree_index_ = base.scroll_tree_index(); 1461 scroll_tree_index_ = base.scroll_tree_index();
1459 offset_to_transform_parent_ = 1462 offset_to_transform_parent_ =
1460 ProtoToVector2dF(base.offset_to_transform_parent()); 1463 ProtoToVector2dF(base.offset_to_transform_parent());
1461 double_sided_ = base.double_sided(); 1464 double_sided_ = base.double_sided();
1462 draws_content_ = base.draws_content(); 1465 draws_content_ = base.draws_content();
1463 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); 1466 hide_layer_and_subtree_ = base.hide_layer_and_subtree();
1464 subtree_property_changed_ = base.subtree_property_changed(); 1467 subtree_property_changed_ = base.subtree_property_changed();
1468 layer_property_changed_ = base.layer_property_changed();
1465 masks_to_bounds_ = base.masks_to_bounds(); 1469 masks_to_bounds_ = base.masks_to_bounds();
1466 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); 1470 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons();
1467 non_fast_scrollable_region_ = 1471 non_fast_scrollable_region_ =
1468 RegionFromProto(base.non_fast_scrollable_region()); 1472 RegionFromProto(base.non_fast_scrollable_region());
1469 touch_event_handler_region_ = 1473 touch_event_handler_region_ =
1470 RegionFromProto(base.touch_event_handler_region()); 1474 RegionFromProto(base.touch_event_handler_region());
1471 contents_opaque_ = base.contents_opaque(); 1475 contents_opaque_ = base.contents_opaque();
1472 opacity_ = base.opacity(); 1476 opacity_ = base.opacity();
1473 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode()); 1477 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode());
1474 is_root_for_isolated_group_ = base.is_root_for_isolated_group(); 1478 is_root_for_isolated_group_ = base.is_root_for_isolated_group();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 return nullptr; 1597 return nullptr;
1594 } 1598 }
1595 1599
1596 void Layer::SetSubtreePropertyChanged() { 1600 void Layer::SetSubtreePropertyChanged() {
1597 if (subtree_property_changed_) 1601 if (subtree_property_changed_)
1598 return; 1602 return;
1599 subtree_property_changed_ = true; 1603 subtree_property_changed_ = true;
1600 SetNeedsPushProperties(); 1604 SetNeedsPushProperties();
1601 } 1605 }
1602 1606
1607 void Layer::SetLayerPropertyChanged() {
1608 if (layer_property_changed_)
1609 return;
1610 layer_property_changed_ = true;
1611 SetNeedsPushProperties();
1612 }
1613
1603 gfx::ScrollOffset Layer::ScrollOffsetForAnimation() const { 1614 gfx::ScrollOffset Layer::ScrollOffsetForAnimation() const {
1604 return CurrentScrollOffset(); 1615 return CurrentScrollOffset();
1605 } 1616 }
1606 1617
1607 // On<Property>Animated is called due to an ongoing accelerated animation. 1618 // On<Property>Animated is called due to an ongoing accelerated animation.
1608 // Since this animation is also being run on the compositor thread, there 1619 // Since this animation is also being run on the compositor thread, there
1609 // is no need to request a commit to push this value over, so the value is 1620 // is no need to request a commit to push this value over, so the value is
1610 // set directly rather than by calling Set<Property>. 1621 // set directly rather than by calling Set<Property>.
1611 void Layer::OnFilterAnimated(const FilterOperations& filters) { 1622 void Layer::OnFilterAnimated(const FilterOperations& filters) {
1612 filters_ = filters; 1623 filters_ = filters;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 ->data.num_copy_requests_in_subtree; 1838 ->data.num_copy_requests_in_subtree;
1828 } 1839 }
1829 1840
1830 gfx::Transform Layer::screen_space_transform() const { 1841 gfx::Transform Layer::screen_space_transform() const {
1831 DCHECK_NE(transform_tree_index_, -1); 1842 DCHECK_NE(transform_tree_index_, -1);
1832 return draw_property_utils::ScreenSpaceTransform( 1843 return draw_property_utils::ScreenSpaceTransform(
1833 this, layer_tree_host_->property_trees()->transform_tree); 1844 this, layer_tree_host_->property_trees()->transform_tree);
1834 } 1845 }
1835 1846
1836 } // namespace cc 1847 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698