OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 layer_tree_host_(NULL), | 40 layer_tree_host_(NULL), |
41 scrollable_(false), | 41 scrollable_(false), |
42 should_scroll_on_main_thread_(false), | 42 should_scroll_on_main_thread_(false), |
43 have_wheel_event_handlers_(false), | 43 have_wheel_event_handlers_(false), |
44 user_scrollable_horizontal_(true), | 44 user_scrollable_horizontal_(true), |
45 user_scrollable_vertical_(true), | 45 user_scrollable_vertical_(true), |
46 anchor_point_(0.5f, 0.5f), | 46 anchor_point_(0.5f, 0.5f), |
47 background_color_(0), | 47 background_color_(0), |
48 compositing_reasons_(kCompositingReasonUnknown), | 48 compositing_reasons_(kCompositingReasonUnknown), |
49 opacity_(1.f), | 49 opacity_(1.f), |
| 50 blend_mode_(SkXfermode::kSrcOver_Mode), |
| 51 is_root_for_isolated_group_(false), |
50 anchor_point_z_(0.f), | 52 anchor_point_z_(0.f), |
51 is_container_for_fixed_position_layers_(false), | 53 is_container_for_fixed_position_layers_(false), |
52 is_drawable_(false), | 54 is_drawable_(false), |
53 hide_layer_and_subtree_(false), | 55 hide_layer_and_subtree_(false), |
54 masks_to_bounds_(false), | 56 masks_to_bounds_(false), |
55 contents_opaque_(false), | 57 contents_opaque_(false), |
56 double_sided_(true), | 58 double_sided_(true), |
57 preserves_3d_(false), | 59 preserves_3d_(false), |
58 use_parent_backface_visibility_(false), | 60 use_parent_backface_visibility_(false), |
59 draw_checkerboard_for_missing_tiles_(false), | 61 draw_checkerboard_for_missing_tiles_(false), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 if (host) { | 120 if (host) { |
119 layer_animation_controller_->SetAnimationRegistrar( | 121 layer_animation_controller_->SetAnimationRegistrar( |
120 host->animation_registrar()); | 122 host->animation_registrar()); |
121 | 123 |
122 if (host->settings().layer_transforms_should_scale_layer_contents) | 124 if (host->settings().layer_transforms_should_scale_layer_contents) |
123 reset_raster_scale_to_unknown(); | 125 reset_raster_scale_to_unknown(); |
124 } | 126 } |
125 | 127 |
126 if (host && layer_animation_controller_->has_any_animation()) | 128 if (host && layer_animation_controller_->has_any_animation()) |
127 host->SetNeedsCommit(); | 129 host->SetNeedsCommit(); |
128 if (host && (!filters_.IsEmpty() || !background_filters_.IsEmpty())) | 130 if (host && (!filters_.IsEmpty() || !background_filters_.IsEmpty() || |
| 131 !uses_default_blend_mode())) |
129 layer_tree_host_->set_needs_filter_context(); | 132 layer_tree_host_->set_needs_filter_context(); |
130 } | 133 } |
131 | 134 |
132 void Layer::SetNeedsUpdate() { | 135 void Layer::SetNeedsUpdate() { |
133 if (layer_tree_host_ && !ignore_set_needs_commit_) | 136 if (layer_tree_host_ && !ignore_set_needs_commit_) |
134 layer_tree_host_->SetNeedsUpdateLayers(); | 137 layer_tree_host_->SetNeedsUpdateLayers(); |
135 } | 138 } |
136 | 139 |
137 void Layer::SetNeedsCommit() { | 140 void Layer::SetNeedsCommit() { |
138 if (!layer_tree_host_) | 141 if (!layer_tree_host_) |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 } | 501 } |
499 | 502 |
500 bool Layer::OpacityIsAnimating() const { | 503 bool Layer::OpacityIsAnimating() const { |
501 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity); | 504 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity); |
502 } | 505 } |
503 | 506 |
504 bool Layer::OpacityCanAnimateOnImplThread() const { | 507 bool Layer::OpacityCanAnimateOnImplThread() const { |
505 return false; | 508 return false; |
506 } | 509 } |
507 | 510 |
| 511 void Layer::SetBlendMode(SkXfermode::Mode blend_mode) { |
| 512 if (blend_mode_ == blend_mode) |
| 513 return; |
| 514 blend_mode_ = blend_mode; |
| 515 SetNeedsCommit(); |
| 516 if (!uses_default_blend_mode() && layer_tree_host_) |
| 517 layer_tree_host_->set_needs_filter_context(); |
| 518 } |
| 519 |
| 520 void Layer::SetIsRootForIsolatedGroup(bool root) { |
| 521 if (is_root_for_isolated_group_ == root) |
| 522 return; |
| 523 is_root_for_isolated_group_ = root; |
| 524 SetNeedsCommit(); |
| 525 } |
| 526 |
508 void Layer::SetContentsOpaque(bool opaque) { | 527 void Layer::SetContentsOpaque(bool opaque) { |
509 DCHECK(IsPropertyChangeAllowed()); | 528 DCHECK(IsPropertyChangeAllowed()); |
510 if (contents_opaque_ == opaque) | 529 if (contents_opaque_ == opaque) |
511 return; | 530 return; |
512 contents_opaque_ = opaque; | 531 contents_opaque_ = opaque; |
513 SetNeedsCommit(); | 532 SetNeedsCommit(); |
514 } | 533 } |
515 | 534 |
516 void Layer::SetPosition(gfx::PointF position) { | 535 void Layer::SetPosition(gfx::PointF position) { |
517 DCHECK(IsPropertyChangeAllowed()); | 536 DCHECK(IsPropertyChangeAllowed()); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 layer->SetBackgroundFilters(background_filters()); | 844 layer->SetBackgroundFilters(background_filters()); |
826 layer->SetMasksToBounds(masks_to_bounds_); | 845 layer->SetMasksToBounds(masks_to_bounds_); |
827 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); | 846 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); |
828 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 847 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
829 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 848 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
830 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 849 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
831 layer->SetContentsOpaque(contents_opaque_); | 850 layer->SetContentsOpaque(contents_opaque_); |
832 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) | 851 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) |
833 layer->SetOpacity(opacity_); | 852 layer->SetOpacity(opacity_); |
834 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 853 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); |
| 854 layer->SetBlendMode(blend_mode_); |
| 855 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
835 layer->SetPosition(position_); | 856 layer->SetPosition(position_); |
836 layer->SetIsContainerForFixedPositionLayers( | 857 layer->SetIsContainerForFixedPositionLayers( |
837 IsContainerForFixedPositionLayers()); | 858 IsContainerForFixedPositionLayers()); |
838 layer->SetFixedContainerSizeDelta(gfx::Vector2dF()); | 859 layer->SetFixedContainerSizeDelta(gfx::Vector2dF()); |
839 layer->SetPositionConstraint(position_constraint_); | 860 layer->SetPositionConstraint(position_constraint_); |
840 layer->SetPreserves3d(preserves_3d()); | 861 layer->SetPreserves3d(preserves_3d()); |
841 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 862 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
842 layer->SetSublayerTransform(sublayer_transform_); | 863 layer->SetSublayerTransform(sublayer_transform_); |
843 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) | 864 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) |
844 layer->SetTransform(transform_); | 865 layer->SetTransform(transform_); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 clip_parent_->RemoveClipChild(this); | 1114 clip_parent_->RemoveClipChild(this); |
1094 | 1115 |
1095 clip_parent_ = NULL; | 1116 clip_parent_ = NULL; |
1096 } | 1117 } |
1097 | 1118 |
1098 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1119 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
1099 benchmark->RunOnLayer(this); | 1120 benchmark->RunOnLayer(this); |
1100 } | 1121 } |
1101 | 1122 |
1102 } // namespace cc | 1123 } // namespace cc |
OLD | NEW |