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

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

Issue 2615773003: Replace LayerImpl::sorting_context_id with transform reference. (Closed)
Patch Set: Update tests. Created 3 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 <algorithm> 10 #include <algorithm>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 draws_content_(false), 68 draws_content_(false),
69 is_drawn_render_surface_layer_list_member_(false), 69 is_drawn_render_surface_layer_list_member_(false),
70 was_ever_ready_since_last_transform_animation_(true), 70 was_ever_ready_since_last_transform_animation_(true),
71 background_color_(0), 71 background_color_(0),
72 safe_opaque_background_color_(0), 72 safe_opaque_background_color_(0),
73 draw_blend_mode_(SkBlendMode::kSrcOver), 73 draw_blend_mode_(SkBlendMode::kSrcOver),
74 transform_tree_index_(TransformTree::kInvalidNodeId), 74 transform_tree_index_(TransformTree::kInvalidNodeId),
75 effect_tree_index_(EffectTree::kInvalidNodeId), 75 effect_tree_index_(EffectTree::kInvalidNodeId),
76 clip_tree_index_(ClipTree::kInvalidNodeId), 76 clip_tree_index_(ClipTree::kInvalidNodeId),
77 scroll_tree_index_(ScrollTree::kInvalidNodeId), 77 scroll_tree_index_(ScrollTree::kInvalidNodeId),
78 sorting_context_id_(0),
79 current_draw_mode_(DRAW_MODE_NONE), 78 current_draw_mode_(DRAW_MODE_NONE),
80 mutable_properties_(MutableProperty::kNone), 79 mutable_properties_(MutableProperty::kNone),
81 debug_info_(nullptr), 80 debug_info_(nullptr),
82 has_preferred_raster_bounds_(false), 81 has_preferred_raster_bounds_(false),
83 has_will_change_transform_hint_(false), 82 has_will_change_transform_hint_(false),
84 needs_push_properties_(false), 83 needs_push_properties_(false),
85 scrollbars_hidden_(false) { 84 scrollbars_hidden_(false) {
86 DCHECK_GT(layer_id_, 0); 85 DCHECK_GT(layer_id_, 0);
87 86
88 DCHECK(layer_tree_impl_); 87 DCHECK(layer_tree_impl_);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 162
164 void LayerImpl::ClearRenderSurfaceLayerList() { 163 void LayerImpl::ClearRenderSurfaceLayerList() {
165 if (render_surface_) 164 if (render_surface_)
166 render_surface_->ClearLayerLists(); 165 render_surface_->ClearLayerLists();
167 } 166 }
168 167
169 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { 168 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const {
170 state->SetAll(draw_properties_.target_space_transform, bounds(), 169 state->SetAll(draw_properties_.target_space_transform, bounds(),
171 draw_properties_.visible_layer_rect, draw_properties_.clip_rect, 170 draw_properties_.visible_layer_rect, draw_properties_.clip_rect,
172 draw_properties_.is_clipped, draw_properties_.opacity, 171 draw_properties_.is_clipped, draw_properties_.opacity,
173 draw_blend_mode_, sorting_context_id_); 172 draw_blend_mode_, GetSortingContextId());
174 } 173 }
175 174
176 void LayerImpl::PopulateScaledSharedQuadState( 175 void LayerImpl::PopulateScaledSharedQuadState(
177 SharedQuadState* state, 176 SharedQuadState* state,
178 float layer_to_content_scale_x, 177 float layer_to_content_scale_x,
179 float layer_to_content_scale_y) const { 178 float layer_to_content_scale_y) const {
180 gfx::Transform scaled_draw_transform = 179 gfx::Transform scaled_draw_transform =
181 draw_properties_.target_space_transform; 180 draw_properties_.target_space_transform;
182 scaled_draw_transform.Scale(SK_MScalar1 / layer_to_content_scale_x, 181 scaled_draw_transform.Scale(SK_MScalar1 / layer_to_content_scale_x,
183 SK_MScalar1 / layer_to_content_scale_y); 182 SK_MScalar1 / layer_to_content_scale_y);
184 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize( 183 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(
185 bounds(), layer_to_content_scale_x, layer_to_content_scale_y); 184 bounds(), layer_to_content_scale_x, layer_to_content_scale_y);
186 gfx::Rect scaled_visible_layer_rect = gfx::ScaleToEnclosingRect( 185 gfx::Rect scaled_visible_layer_rect = gfx::ScaleToEnclosingRect(
187 visible_layer_rect(), layer_to_content_scale_x, layer_to_content_scale_y); 186 visible_layer_rect(), layer_to_content_scale_x, layer_to_content_scale_y);
188 scaled_visible_layer_rect.Intersect(gfx::Rect(scaled_bounds)); 187 scaled_visible_layer_rect.Intersect(gfx::Rect(scaled_bounds));
189 188
190 state->SetAll(scaled_draw_transform, scaled_bounds, scaled_visible_layer_rect, 189 state->SetAll(scaled_draw_transform, scaled_bounds, scaled_visible_layer_rect,
191 draw_properties().clip_rect, draw_properties().is_clipped, 190 draw_properties().clip_rect, draw_properties().is_clipped,
192 draw_properties().opacity, draw_blend_mode_, 191 draw_properties().opacity, draw_blend_mode_,
193 sorting_context_id_); 192 GetSortingContextId());
194 } 193 }
195 194
196 bool LayerImpl::WillDraw(DrawMode draw_mode, 195 bool LayerImpl::WillDraw(DrawMode draw_mode,
197 ResourceProvider* resource_provider) { 196 ResourceProvider* resource_provider) {
198 // WillDraw/DidDraw must be matched. 197 // WillDraw/DidDraw must be matched.
199 DCHECK_NE(DRAW_MODE_NONE, draw_mode); 198 DCHECK_NE(DRAW_MODE_NONE, draw_mode);
200 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); 199 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_);
201 current_draw_mode_ = draw_mode; 200 current_draw_mode_ = draw_mode;
202 return true; 201 return true;
203 } 202 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 layer->non_fast_scrollable_region_ = non_fast_scrollable_region_; 345 layer->non_fast_scrollable_region_ = non_fast_scrollable_region_;
347 layer->touch_event_handler_region_ = touch_event_handler_region_; 346 layer->touch_event_handler_region_ = touch_event_handler_region_;
348 layer->background_color_ = background_color_; 347 layer->background_color_ = background_color_;
349 layer->safe_opaque_background_color_ = safe_opaque_background_color_; 348 layer->safe_opaque_background_color_ = safe_opaque_background_color_;
350 layer->draw_blend_mode_ = draw_blend_mode_; 349 layer->draw_blend_mode_ = draw_blend_mode_;
351 layer->position_ = position_; 350 layer->position_ = position_;
352 layer->transform_tree_index_ = transform_tree_index_; 351 layer->transform_tree_index_ = transform_tree_index_;
353 layer->effect_tree_index_ = effect_tree_index_; 352 layer->effect_tree_index_ = effect_tree_index_;
354 layer->clip_tree_index_ = clip_tree_index_; 353 layer->clip_tree_index_ = clip_tree_index_;
355 layer->scroll_tree_index_ = scroll_tree_index_; 354 layer->scroll_tree_index_ = scroll_tree_index_;
356 layer->sorting_context_id_ = sorting_context_id_;
357 layer->has_will_change_transform_hint_ = has_will_change_transform_hint_; 355 layer->has_will_change_transform_hint_ = has_will_change_transform_hint_;
358 layer->scrollbars_hidden_ = scrollbars_hidden_; 356 layer->scrollbars_hidden_ = scrollbars_hidden_;
359 357
360 if (layer_property_changed_) { 358 if (layer_property_changed_) {
361 layer->layer_tree_impl()->set_needs_update_draw_properties(); 359 layer->layer_tree_impl()->set_needs_update_draw_properties();
362 layer->layer_property_changed_ = true; 360 layer->layer_property_changed_ = true;
363 } 361 }
364 362
365 // If whether layer has render surface changes, we need to update draw 363 // If whether layer has render surface changes, we need to update draw
366 // properties. 364 // properties.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 441
444 list = new base::ListValue; 442 list = new base::ListValue;
445 for (size_t i = 0; i < test_properties()->children.size(); ++i) 443 for (size_t i = 0; i < test_properties()->children.size(); ++i)
446 list->Append(test_properties()->children[i]->LayerTreeAsJson()); 444 list->Append(test_properties()->children[i]->LayerTreeAsJson());
447 result->Set("Children", list); 445 result->Set("Children", list);
448 446
449 return result; 447 return result;
450 } 448 }
451 449
452 bool LayerImpl::LayerPropertyChanged() const { 450 bool LayerImpl::LayerPropertyChanged() const {
453 if (layer_property_changed_ || 451 if (layer_property_changed_ || GetPropertyTrees()->full_tree_damaged)
454 (GetPropertyTrees() && GetPropertyTrees()->full_tree_damaged))
455 return true; 452 return true;
456 if (transform_tree_index() == TransformTree::kInvalidNodeId) 453 if (transform_tree_index() == TransformTree::kInvalidNodeId)
457 return false; 454 return false;
458 TransformNode* transform_node = 455 TransformNode* transform_node =
459 GetTransformTree().Node(transform_tree_index()); 456 GetTransformTree().Node(transform_tree_index());
460 if (transform_node && transform_node->transform_changed) 457 if (transform_node && transform_node->transform_changed)
461 return true; 458 return true;
462 if (effect_tree_index() == EffectTree::kInvalidNodeId) 459 if (effect_tree_index() == EffectTree::kInvalidNodeId)
463 return false; 460 return false;
464 EffectNode* effect_node = GetEffectTree().Node(effect_tree_index()); 461 EffectNode* effect_node = GetEffectTree().Node(effect_tree_index());
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 758
762 mutable_properties_ = properties; 759 mutable_properties_ = properties;
763 // If this layer is already in the element map, update its properties. 760 // If this layer is already in the element map, update its properties.
764 layer_tree_impl_->AddToElementMap(this); 761 layer_tree_impl_->AddToElementMap(this);
765 } 762 }
766 763
767 void LayerImpl::SetPosition(const gfx::PointF& position) { 764 void LayerImpl::SetPosition(const gfx::PointF& position) {
768 position_ = position; 765 position_ = position;
769 } 766 }
770 767
771 void LayerImpl::Set3dSortingContextId(int id) {
772 sorting_context_id_ = id;
773 }
774
775 bool LayerImpl::TransformIsAnimating() const { 768 bool LayerImpl::TransformIsAnimating() const {
776 return GetMutatorHost()->IsAnimatingTransformProperty( 769 return GetMutatorHost()->IsAnimatingTransformProperty(
777 element_id(), GetElementTypeForAnimation()); 770 element_id(), GetElementTypeForAnimation());
778 } 771 }
779 772
780 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const { 773 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const {
781 return GetMutatorHost()->HasPotentiallyRunningTransformAnimation( 774 return GetMutatorHost()->HasPotentiallyRunningTransformAnimation(
782 element_id(), GetElementTypeForAnimation()); 775 element_id(), GetElementTypeForAnimation());
783 } 776 }
784 777
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 return false; 1024 return false;
1032 if (static_cast<int>(offset_to_transform_parent().x()) != 1025 if (static_cast<int>(offset_to_transform_parent().x()) !=
1033 offset_to_transform_parent().x()) 1026 offset_to_transform_parent().x())
1034 return false; 1027 return false;
1035 if (static_cast<int>(offset_to_transform_parent().y()) != 1028 if (static_cast<int>(offset_to_transform_parent().y()) !=
1036 offset_to_transform_parent().y()) 1029 offset_to_transform_parent().y())
1037 return false; 1030 return false;
1038 return true; 1031 return true;
1039 } 1032 }
1040 1033
1034 int LayerImpl::GetSortingContextId() const {
1035 return layer_tree_impl()
1036 ->property_trees()
1037 ->transform_tree.Node(transform_tree_index())
1038 ->sorting_context_id;
1039 }
1040
1041 Region LayerImpl::GetInvalidationRegionForDebugging() { 1041 Region LayerImpl::GetInvalidationRegionForDebugging() {
1042 return Region(update_rect_); 1042 return Region(update_rect_);
1043 } 1043 }
1044 1044
1045 gfx::Rect LayerImpl::GetEnclosingRectInTargetSpace() const { 1045 gfx::Rect LayerImpl::GetEnclosingRectInTargetSpace() const {
1046 return MathUtil::MapEnclosingClippedRect(DrawTransform(), 1046 return MathUtil::MapEnclosingClippedRect(DrawTransform(),
1047 gfx::Rect(bounds())); 1047 gfx::Rect(bounds()));
1048 } 1048 }
1049 1049
1050 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { 1050 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 1100
1101 ScrollTree& LayerImpl::GetScrollTree() const { 1101 ScrollTree& LayerImpl::GetScrollTree() const {
1102 return GetPropertyTrees()->scroll_tree; 1102 return GetPropertyTrees()->scroll_tree;
1103 } 1103 }
1104 1104
1105 TransformTree& LayerImpl::GetTransformTree() const { 1105 TransformTree& LayerImpl::GetTransformTree() const {
1106 return GetPropertyTrees()->transform_tree; 1106 return GetPropertyTrees()->transform_tree;
1107 } 1107 }
1108 1108
1109 } // namespace cc 1109 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698