OLD | NEW |
---|---|
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 Loading... | |
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 | 166 |
168 void LayerImpl::ClearRenderSurfaceLayerList() { | 167 void LayerImpl::ClearRenderSurfaceLayerList() { |
169 if (render_surface_) | 168 if (render_surface_) |
170 render_surface_->ClearLayerLists(); | 169 render_surface_->ClearLayerLists(); |
171 } | 170 } |
172 | 171 |
173 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { | 172 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { |
174 state->SetAll(draw_properties_.target_space_transform, bounds(), | 173 state->SetAll(draw_properties_.target_space_transform, bounds(), |
175 draw_properties_.visible_layer_rect, draw_properties_.clip_rect, | 174 draw_properties_.visible_layer_rect, draw_properties_.clip_rect, |
176 draw_properties_.is_clipped, draw_properties_.opacity, | 175 draw_properties_.is_clipped, draw_properties_.opacity, |
177 draw_blend_mode_, sorting_context_id_); | 176 draw_blend_mode_, sorting_context_id()); |
178 } | 177 } |
179 | 178 |
180 void LayerImpl::PopulateScaledSharedQuadState( | 179 void LayerImpl::PopulateScaledSharedQuadState( |
181 SharedQuadState* state, | 180 SharedQuadState* state, |
182 float layer_to_content_scale_x, | 181 float layer_to_content_scale_x, |
183 float layer_to_content_scale_y) const { | 182 float layer_to_content_scale_y) const { |
184 gfx::Transform scaled_draw_transform = | 183 gfx::Transform scaled_draw_transform = |
185 draw_properties_.target_space_transform; | 184 draw_properties_.target_space_transform; |
186 scaled_draw_transform.Scale(SK_MScalar1 / layer_to_content_scale_x, | 185 scaled_draw_transform.Scale(SK_MScalar1 / layer_to_content_scale_x, |
187 SK_MScalar1 / layer_to_content_scale_y); | 186 SK_MScalar1 / layer_to_content_scale_y); |
188 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize( | 187 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize( |
189 bounds(), layer_to_content_scale_x, layer_to_content_scale_y); | 188 bounds(), layer_to_content_scale_x, layer_to_content_scale_y); |
190 gfx::Rect scaled_visible_layer_rect = gfx::ScaleToEnclosingRect( | 189 gfx::Rect scaled_visible_layer_rect = gfx::ScaleToEnclosingRect( |
191 visible_layer_rect(), layer_to_content_scale_x, layer_to_content_scale_y); | 190 visible_layer_rect(), layer_to_content_scale_x, layer_to_content_scale_y); |
192 scaled_visible_layer_rect.Intersect(gfx::Rect(scaled_bounds)); | 191 scaled_visible_layer_rect.Intersect(gfx::Rect(scaled_bounds)); |
193 | 192 |
194 state->SetAll(scaled_draw_transform, scaled_bounds, scaled_visible_layer_rect, | 193 state->SetAll(scaled_draw_transform, scaled_bounds, scaled_visible_layer_rect, |
195 draw_properties().clip_rect, draw_properties().is_clipped, | 194 draw_properties().clip_rect, draw_properties().is_clipped, |
196 draw_properties().opacity, draw_blend_mode_, | 195 draw_properties().opacity, draw_blend_mode_, |
197 sorting_context_id_); | 196 sorting_context_id()); |
198 } | 197 } |
199 | 198 |
200 bool LayerImpl::WillDraw(DrawMode draw_mode, | 199 bool LayerImpl::WillDraw(DrawMode draw_mode, |
201 ResourceProvider* resource_provider) { | 200 ResourceProvider* resource_provider) { |
202 // WillDraw/DidDraw must be matched. | 201 // WillDraw/DidDraw must be matched. |
203 DCHECK_NE(DRAW_MODE_NONE, draw_mode); | 202 DCHECK_NE(DRAW_MODE_NONE, draw_mode); |
204 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); | 203 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); |
205 current_draw_mode_ = draw_mode; | 204 current_draw_mode_ = draw_mode; |
206 return true; | 205 return true; |
207 } | 206 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 layer->non_fast_scrollable_region_ = non_fast_scrollable_region_; | 349 layer->non_fast_scrollable_region_ = non_fast_scrollable_region_; |
351 layer->touch_event_handler_region_ = touch_event_handler_region_; | 350 layer->touch_event_handler_region_ = touch_event_handler_region_; |
352 layer->background_color_ = background_color_; | 351 layer->background_color_ = background_color_; |
353 layer->safe_opaque_background_color_ = safe_opaque_background_color_; | 352 layer->safe_opaque_background_color_ = safe_opaque_background_color_; |
354 layer->draw_blend_mode_ = draw_blend_mode_; | 353 layer->draw_blend_mode_ = draw_blend_mode_; |
355 layer->position_ = position_; | 354 layer->position_ = position_; |
356 layer->transform_tree_index_ = transform_tree_index_; | 355 layer->transform_tree_index_ = transform_tree_index_; |
357 layer->effect_tree_index_ = effect_tree_index_; | 356 layer->effect_tree_index_ = effect_tree_index_; |
358 layer->clip_tree_index_ = clip_tree_index_; | 357 layer->clip_tree_index_ = clip_tree_index_; |
359 layer->scroll_tree_index_ = scroll_tree_index_; | 358 layer->scroll_tree_index_ = scroll_tree_index_; |
360 layer->sorting_context_id_ = sorting_context_id_; | |
361 layer->has_will_change_transform_hint_ = has_will_change_transform_hint_; | 359 layer->has_will_change_transform_hint_ = has_will_change_transform_hint_; |
362 layer->scrollbars_hidden_ = scrollbars_hidden_; | 360 layer->scrollbars_hidden_ = scrollbars_hidden_; |
363 | 361 |
364 if (layer_property_changed_) { | 362 if (layer_property_changed_) { |
365 layer->layer_tree_impl()->set_needs_update_draw_properties(); | 363 layer->layer_tree_impl()->set_needs_update_draw_properties(); |
366 layer->layer_property_changed_ = true; | 364 layer->layer_property_changed_ = true; |
367 } | 365 } |
368 | 366 |
369 // If whether layer has render surface changes, we need to update draw | 367 // If whether layer has render surface changes, we need to update draw |
370 // properties. | 368 // properties. |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
770 | 768 |
771 mutable_properties_ = properties; | 769 mutable_properties_ = properties; |
772 // If this layer is already in the element map, update its properties. | 770 // If this layer is already in the element map, update its properties. |
773 layer_tree_impl_->AddToElementMap(this); | 771 layer_tree_impl_->AddToElementMap(this); |
774 } | 772 } |
775 | 773 |
776 void LayerImpl::SetPosition(const gfx::PointF& position) { | 774 void LayerImpl::SetPosition(const gfx::PointF& position) { |
777 position_ = position; | 775 position_ = position; |
778 } | 776 } |
779 | 777 |
780 void LayerImpl::Set3dSortingContextId(int id) { | |
781 sorting_context_id_ = id; | |
782 } | |
783 | |
784 bool LayerImpl::TransformIsAnimating() const { | 778 bool LayerImpl::TransformIsAnimating() const { |
785 return GetMutatorHost()->IsAnimatingTransformProperty( | 779 return GetMutatorHost()->IsAnimatingTransformProperty( |
786 element_id(), GetElementTypeForAnimation()); | 780 element_id(), GetElementTypeForAnimation()); |
787 } | 781 } |
788 | 782 |
789 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const { | 783 bool LayerImpl::HasPotentiallyRunningTransformAnimation() const { |
790 return GetMutatorHost()->HasPotentiallyRunningTransformAnimation( | 784 return GetMutatorHost()->HasPotentiallyRunningTransformAnimation( |
791 element_id(), GetElementTypeForAnimation()); | 785 element_id(), GetElementTypeForAnimation()); |
792 } | 786 } |
793 | 787 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1050 return false; | 1044 return false; |
1051 if (static_cast<int>(offset_to_transform_parent().x()) != | 1045 if (static_cast<int>(offset_to_transform_parent().x()) != |
1052 offset_to_transform_parent().x()) | 1046 offset_to_transform_parent().x()) |
1053 return false; | 1047 return false; |
1054 if (static_cast<int>(offset_to_transform_parent().y()) != | 1048 if (static_cast<int>(offset_to_transform_parent().y()) != |
1055 offset_to_transform_parent().y()) | 1049 offset_to_transform_parent().y()) |
1056 return false; | 1050 return false; |
1057 return true; | 1051 return true; |
1058 } | 1052 } |
1059 | 1053 |
1054 int LayerImpl::sorting_context_id() const { | |
1055 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); | |
1056 return (!property_trees || | |
ajuma
2017/01/06 14:59:55
Looking at LayerTreeImpl::property_trees, I don't
wkorman
2017/01/06 22:50:02
Done.
| |
1057 transform_tree_index() == TransformTree::kInvalidNodeId) | |
ajuma
2017/01/06 14:59:55
This should never be kInvalidNodeId except in test
wkorman
2017/01/06 22:50:02
Done.
| |
1058 ? 0 | |
1059 : property_trees->transform_tree.Node(transform_tree_index()) | |
1060 ->sorting_context_id; | |
1061 } | |
1062 | |
1060 Region LayerImpl::GetInvalidationRegionForDebugging() { | 1063 Region LayerImpl::GetInvalidationRegionForDebugging() { |
1061 return Region(update_rect_); | 1064 return Region(update_rect_); |
1062 } | 1065 } |
1063 | 1066 |
1064 gfx::Rect LayerImpl::GetEnclosingRectInTargetSpace() const { | 1067 gfx::Rect LayerImpl::GetEnclosingRectInTargetSpace() const { |
1065 return MathUtil::MapEnclosingClippedRect(DrawTransform(), | 1068 return MathUtil::MapEnclosingClippedRect(DrawTransform(), |
1066 gfx::Rect(bounds())); | 1069 gfx::Rect(bounds())); |
1067 } | 1070 } |
1068 | 1071 |
1069 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { | 1072 gfx::Rect LayerImpl::GetScaledEnclosingRectInTargetSpace(float scale) const { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1103 .layer_transforms_should_scale_layer_contents) { | 1106 .layer_transforms_should_scale_layer_contents) { |
1104 return default_scale; | 1107 return default_scale; |
1105 } | 1108 } |
1106 | 1109 |
1107 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1110 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
1108 ScreenSpaceTransform(), default_scale); | 1111 ScreenSpaceTransform(), default_scale); |
1109 return std::max(transform_scales.x(), transform_scales.y()); | 1112 return std::max(transform_scales.x(), transform_scales.y()); |
1110 } | 1113 } |
1111 | 1114 |
1112 } // namespace cc | 1115 } // namespace cc |
OLD | NEW |