Chromium Code Reviews| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 masks_to_bounds_(false), | 63 masks_to_bounds_(false), |
| 64 contents_opaque_(false), | 64 contents_opaque_(false), |
| 65 use_parent_backface_visibility_(false), | 65 use_parent_backface_visibility_(false), |
| 66 use_local_transform_for_backface_visibility_(false), | 66 use_local_transform_for_backface_visibility_(false), |
| 67 should_check_backface_visibility_(false), | 67 should_check_backface_visibility_(false), |
| 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), | |
| 74 transform_tree_index_(TransformTree::kInvalidNodeId), | 73 transform_tree_index_(TransformTree::kInvalidNodeId), |
| 75 effect_tree_index_(EffectTree::kInvalidNodeId), | 74 effect_tree_index_(EffectTree::kInvalidNodeId), |
| 76 clip_tree_index_(ClipTree::kInvalidNodeId), | 75 clip_tree_index_(ClipTree::kInvalidNodeId), |
| 77 scroll_tree_index_(ScrollTree::kInvalidNodeId), | 76 scroll_tree_index_(ScrollTree::kInvalidNodeId), |
| 78 current_draw_mode_(DRAW_MODE_NONE), | 77 current_draw_mode_(DRAW_MODE_NONE), |
| 79 mutable_properties_(MutableProperty::kNone), | 78 mutable_properties_(MutableProperty::kNone), |
| 80 debug_info_(nullptr), | 79 debug_info_(nullptr), |
| 81 has_will_change_transform_hint_(false), | 80 has_will_change_transform_hint_(false), |
| 82 needs_push_properties_(false), | 81 needs_push_properties_(false), |
| 83 scrollbars_hidden_(false), | 82 scrollbars_hidden_(false), |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 } | 143 } |
| 145 | 144 |
| 146 void LayerImpl::SetScrollTreeIndex(int index) { | 145 void LayerImpl::SetScrollTreeIndex(int index) { |
| 147 scroll_tree_index_ = index; | 146 scroll_tree_index_ = index; |
| 148 } | 147 } |
| 149 | 148 |
| 150 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { | 149 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { |
| 151 state->SetAll(draw_properties_.target_space_transform, bounds(), | 150 state->SetAll(draw_properties_.target_space_transform, bounds(), |
| 152 draw_properties_.visible_layer_rect, draw_properties_.clip_rect, | 151 draw_properties_.visible_layer_rect, draw_properties_.clip_rect, |
| 153 draw_properties_.is_clipped, draw_properties_.opacity, | 152 draw_properties_.is_clipped, draw_properties_.opacity, |
| 154 draw_blend_mode_, GetSortingContextId()); | 153 SkBlendMode::kSrcOver, GetSortingContextId()); |
| 155 } | 154 } |
| 156 | 155 |
| 157 void LayerImpl::PopulateScaledSharedQuadState( | 156 void LayerImpl::PopulateScaledSharedQuadState( |
| 158 SharedQuadState* state, | 157 SharedQuadState* state, |
| 159 float layer_to_content_scale_x, | 158 float layer_to_content_scale_x, |
| 160 float layer_to_content_scale_y) const { | 159 float layer_to_content_scale_y) const { |
| 161 gfx::Transform scaled_draw_transform = | 160 gfx::Transform scaled_draw_transform = |
| 162 draw_properties_.target_space_transform; | 161 draw_properties_.target_space_transform; |
| 163 scaled_draw_transform.Scale(SK_MScalar1 / layer_to_content_scale_x, | 162 scaled_draw_transform.Scale(SK_MScalar1 / layer_to_content_scale_x, |
| 164 SK_MScalar1 / layer_to_content_scale_y); | 163 SK_MScalar1 / layer_to_content_scale_y); |
| 165 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize( | 164 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize( |
| 166 bounds(), layer_to_content_scale_x, layer_to_content_scale_y); | 165 bounds(), layer_to_content_scale_x, layer_to_content_scale_y); |
| 167 gfx::Rect scaled_visible_layer_rect = gfx::ScaleToEnclosingRect( | 166 gfx::Rect scaled_visible_layer_rect = gfx::ScaleToEnclosingRect( |
| 168 visible_layer_rect(), layer_to_content_scale_x, layer_to_content_scale_y); | 167 visible_layer_rect(), layer_to_content_scale_x, layer_to_content_scale_y); |
| 169 scaled_visible_layer_rect.Intersect(gfx::Rect(scaled_bounds)); | 168 scaled_visible_layer_rect.Intersect(gfx::Rect(scaled_bounds)); |
| 170 | 169 |
| 171 state->SetAll(scaled_draw_transform, scaled_bounds, scaled_visible_layer_rect, | 170 state->SetAll(scaled_draw_transform, scaled_bounds, scaled_visible_layer_rect, |
| 172 draw_properties().clip_rect, draw_properties().is_clipped, | 171 draw_properties().clip_rect, draw_properties().is_clipped, |
| 173 draw_properties().opacity, draw_blend_mode_, | 172 draw_properties().opacity, SkBlendMode::kSrcOver, |
|
weiliangc
2017/04/10 15:42:20
Do we ever set SharedQuadState's blend mode to any
jaydasika
2017/04/10 16:29:33
We can set it to something other than kSrcOver whe
| |
| 174 GetSortingContextId()); | 173 GetSortingContextId()); |
| 175 } | 174 } |
| 176 | 175 |
| 177 bool LayerImpl::WillDraw(DrawMode draw_mode, | 176 bool LayerImpl::WillDraw(DrawMode draw_mode, |
| 178 ResourceProvider* resource_provider) { | 177 ResourceProvider* resource_provider) { |
| 179 // WillDraw/DidDraw must be matched. | 178 // WillDraw/DidDraw must be matched. |
| 180 DCHECK_NE(DRAW_MODE_NONE, draw_mode); | 179 DCHECK_NE(DRAW_MODE_NONE, draw_mode); |
| 181 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); | 180 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); |
| 182 current_draw_mode_ = draw_mode; | 181 current_draw_mode_ = draw_mode; |
| 183 return true; | 182 return true; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 layer->may_contain_video_ = may_contain_video_; | 323 layer->may_contain_video_ = may_contain_video_; |
| 325 layer->use_parent_backface_visibility_ = use_parent_backface_visibility_; | 324 layer->use_parent_backface_visibility_ = use_parent_backface_visibility_; |
| 326 layer->use_local_transform_for_backface_visibility_ = | 325 layer->use_local_transform_for_backface_visibility_ = |
| 327 use_local_transform_for_backface_visibility_; | 326 use_local_transform_for_backface_visibility_; |
| 328 layer->should_check_backface_visibility_ = should_check_backface_visibility_; | 327 layer->should_check_backface_visibility_ = should_check_backface_visibility_; |
| 329 layer->draws_content_ = draws_content_; | 328 layer->draws_content_ = draws_content_; |
| 330 layer->non_fast_scrollable_region_ = non_fast_scrollable_region_; | 329 layer->non_fast_scrollable_region_ = non_fast_scrollable_region_; |
| 331 layer->touch_event_handler_region_ = touch_event_handler_region_; | 330 layer->touch_event_handler_region_ = touch_event_handler_region_; |
| 332 layer->background_color_ = background_color_; | 331 layer->background_color_ = background_color_; |
| 333 layer->safe_opaque_background_color_ = safe_opaque_background_color_; | 332 layer->safe_opaque_background_color_ = safe_opaque_background_color_; |
| 334 layer->draw_blend_mode_ = draw_blend_mode_; | |
| 335 layer->position_ = position_; | 333 layer->position_ = position_; |
| 336 layer->transform_tree_index_ = transform_tree_index_; | 334 layer->transform_tree_index_ = transform_tree_index_; |
| 337 layer->effect_tree_index_ = effect_tree_index_; | 335 layer->effect_tree_index_ = effect_tree_index_; |
| 338 layer->clip_tree_index_ = clip_tree_index_; | 336 layer->clip_tree_index_ = clip_tree_index_; |
| 339 layer->scroll_tree_index_ = scroll_tree_index_; | 337 layer->scroll_tree_index_ = scroll_tree_index_; |
| 340 layer->has_will_change_transform_hint_ = has_will_change_transform_hint_; | 338 layer->has_will_change_transform_hint_ = has_will_change_transform_hint_; |
| 341 layer->scrollbars_hidden_ = scrollbars_hidden_; | 339 layer->scrollbars_hidden_ = scrollbars_hidden_; |
| 342 layer->needs_show_scrollbars_ = needs_show_scrollbars_; | 340 layer->needs_show_scrollbars_ = needs_show_scrollbars_; |
| 343 | 341 |
| 344 if (layer_property_changed_) { | 342 if (layer_property_changed_) { |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 | 974 |
| 977 ScrollTree& LayerImpl::GetScrollTree() const { | 975 ScrollTree& LayerImpl::GetScrollTree() const { |
| 978 return GetPropertyTrees()->scroll_tree; | 976 return GetPropertyTrees()->scroll_tree; |
| 979 } | 977 } |
| 980 | 978 |
| 981 TransformTree& LayerImpl::GetTransformTree() const { | 979 TransformTree& LayerImpl::GetTransformTree() const { |
| 982 return GetPropertyTrees()->transform_tree; | 980 return GetPropertyTrees()->transform_tree; |
| 983 } | 981 } |
| 984 | 982 |
| 985 } // namespace cc | 983 } // namespace cc |
| OLD | NEW |