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 SetNeedsFilterContextIfNeeded(); |
129 layer_tree_host_->set_needs_filter_context(); | |
130 } | 131 } |
131 | 132 |
132 void Layer::SetNeedsUpdate() { | 133 void Layer::SetNeedsUpdate() { |
133 if (layer_tree_host_ && !ignore_set_needs_commit_) | 134 if (layer_tree_host_ && !ignore_set_needs_commit_) |
134 layer_tree_host_->SetNeedsUpdateLayers(); | 135 layer_tree_host_->SetNeedsUpdateLayers(); |
135 } | 136 } |
136 | 137 |
137 void Layer::SetNeedsCommit() { | 138 void Layer::SetNeedsCommit() { |
138 if (!layer_tree_host_) | 139 if (!layer_tree_host_) |
139 return; | 140 return; |
(...skipping 13 matching lines...) Expand all Loading... | |
153 layer_tree_host_->SetNeedsFullTreeSync(); | 154 layer_tree_host_->SetNeedsFullTreeSync(); |
154 } | 155 } |
155 | 156 |
156 void Layer::SetNextCommitWaitsForActivation() { | 157 void Layer::SetNextCommitWaitsForActivation() { |
157 if (!layer_tree_host_) | 158 if (!layer_tree_host_) |
158 return; | 159 return; |
159 | 160 |
160 layer_tree_host_->SetNextCommitWaitsForActivation(); | 161 layer_tree_host_->SetNextCommitWaitsForActivation(); |
161 } | 162 } |
162 | 163 |
164 void Layer::SetNeedsFilterContextIfNeeded() { | |
165 if (!layer_tree_host_) | |
166 return; | |
167 | |
168 if (!filters_.IsEmpty() || !background_filters_.IsEmpty() || | |
169 !uses_default_blend_mode()) | |
170 layer_tree_host_->set_needs_filter_context(); | |
171 } | |
172 | |
163 void Layer::SetNeedsPushProperties() { | 173 void Layer::SetNeedsPushProperties() { |
164 if (needs_push_properties_) | 174 if (needs_push_properties_) |
165 return; | 175 return; |
166 if (!parent_should_know_need_push_properties() && parent_) | 176 if (!parent_should_know_need_push_properties() && parent_) |
167 parent_->AddDependentNeedsPushProperties(); | 177 parent_->AddDependentNeedsPushProperties(); |
168 needs_push_properties_ = true; | 178 needs_push_properties_ = true; |
169 } | 179 } |
170 | 180 |
171 void Layer::AddDependentNeedsPushProperties() { | 181 void Layer::AddDependentNeedsPushProperties() { |
172 DCHECK_GE(num_dependents_need_push_properties_, 0); | 182 DCHECK_GE(num_dependents_need_push_properties_, 0); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 } | 474 } |
465 SetNeedsFullTreeSync(); | 475 SetNeedsFullTreeSync(); |
466 } | 476 } |
467 | 477 |
468 void Layer::SetFilters(const FilterOperations& filters) { | 478 void Layer::SetFilters(const FilterOperations& filters) { |
469 DCHECK(IsPropertyChangeAllowed()); | 479 DCHECK(IsPropertyChangeAllowed()); |
470 if (filters_ == filters) | 480 if (filters_ == filters) |
471 return; | 481 return; |
472 filters_ = filters; | 482 filters_ = filters; |
473 SetNeedsCommit(); | 483 SetNeedsCommit(); |
474 if (!filters.IsEmpty() && layer_tree_host_) | 484 SetNeedsFilterContextIfNeeded(); |
475 layer_tree_host_->set_needs_filter_context(); | |
476 } | 485 } |
477 | 486 |
478 bool Layer::FilterIsAnimating() const { | 487 bool Layer::FilterIsAnimating() const { |
479 return layer_animation_controller_->IsAnimatingProperty(Animation::Filter); | 488 return layer_animation_controller_->IsAnimatingProperty(Animation::Filter); |
480 } | 489 } |
481 | 490 |
482 void Layer::SetBackgroundFilters(const FilterOperations& filters) { | 491 void Layer::SetBackgroundFilters(const FilterOperations& filters) { |
483 DCHECK(IsPropertyChangeAllowed()); | 492 DCHECK(IsPropertyChangeAllowed()); |
484 if (background_filters_ == filters) | 493 if (background_filters_ == filters) |
485 return; | 494 return; |
486 background_filters_ = filters; | 495 background_filters_ = filters; |
487 SetNeedsCommit(); | 496 SetNeedsCommit(); |
488 if (!filters.IsEmpty() && layer_tree_host_) | 497 SetNeedsFilterContextIfNeeded(); |
489 layer_tree_host_->set_needs_filter_context(); | |
490 } | 498 } |
491 | 499 |
492 void Layer::SetOpacity(float opacity) { | 500 void Layer::SetOpacity(float opacity) { |
493 DCHECK(IsPropertyChangeAllowed()); | 501 DCHECK(IsPropertyChangeAllowed()); |
494 if (opacity_ == opacity) | 502 if (opacity_ == opacity) |
495 return; | 503 return; |
496 opacity_ = opacity; | 504 opacity_ = opacity; |
497 SetNeedsCommit(); | 505 SetNeedsCommit(); |
498 } | 506 } |
499 | 507 |
500 bool Layer::OpacityIsAnimating() const { | 508 bool Layer::OpacityIsAnimating() const { |
501 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity); | 509 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity); |
502 } | 510 } |
503 | 511 |
504 bool Layer::OpacityCanAnimateOnImplThread() const { | 512 bool Layer::OpacityCanAnimateOnImplThread() const { |
505 return false; | 513 return false; |
506 } | 514 } |
507 | 515 |
516 void Layer::SetBlendMode(SkXfermode::Mode blend_mode) { | |
517 DCHECK(IsPropertyChangeAllowed()); | |
518 if (blend_mode_ == blend_mode) | |
519 return; | |
520 | |
521 // Allowing only blend modes that are defined in the CSS Compositing standard: | |
522 // http://dev.w3.org/fxtf/compositing-1/#blending | |
523 bool is_blend_mode = (blend_mode == SkXfermode::kSrcOver_Mode || | |
enne (OOO)
2013/11/04 22:38:16
naming: is_blend_mode => supported_blend_mode or e
rosca
2013/11/05 19:14:09
We call the other modes "Compositing operators", b
| |
524 (blend_mode >= SkXfermode::kScreen_Mode && | |
525 blend_mode <= SkXfermode::kLastMode)); | |
enne (OOO)
2013/11/04 22:38:16
This doesn't seem very futureproof. Could you jus
rosca
2013/11/05 19:14:09
Done.
| |
526 DCHECK(is_blend_mode); | |
527 if (!is_blend_mode) | |
528 return; | |
529 | |
530 blend_mode_ = blend_mode; | |
531 SetNeedsCommit(); | |
532 SetNeedsFilterContextIfNeeded(); | |
533 } | |
534 | |
535 void Layer::SetIsRootForIsolatedGroup(bool root) { | |
536 DCHECK(IsPropertyChangeAllowed()); | |
537 if (is_root_for_isolated_group_ == root) | |
538 return; | |
539 is_root_for_isolated_group_ = root; | |
540 SetNeedsCommit(); | |
541 } | |
542 | |
508 void Layer::SetContentsOpaque(bool opaque) { | 543 void Layer::SetContentsOpaque(bool opaque) { |
509 DCHECK(IsPropertyChangeAllowed()); | 544 DCHECK(IsPropertyChangeAllowed()); |
510 if (contents_opaque_ == opaque) | 545 if (contents_opaque_ == opaque) |
511 return; | 546 return; |
512 contents_opaque_ = opaque; | 547 contents_opaque_ = opaque; |
513 SetNeedsCommit(); | 548 SetNeedsCommit(); |
514 } | 549 } |
515 | 550 |
516 void Layer::SetPosition(gfx::PointF position) { | 551 void Layer::SetPosition(gfx::PointF position) { |
517 DCHECK(IsPropertyChangeAllowed()); | 552 DCHECK(IsPropertyChangeAllowed()); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
825 layer->SetBackgroundFilters(background_filters()); | 860 layer->SetBackgroundFilters(background_filters()); |
826 layer->SetMasksToBounds(masks_to_bounds_); | 861 layer->SetMasksToBounds(masks_to_bounds_); |
827 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); | 862 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); |
828 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 863 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
829 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 864 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
830 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 865 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
831 layer->SetContentsOpaque(contents_opaque_); | 866 layer->SetContentsOpaque(contents_opaque_); |
832 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) | 867 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) |
833 layer->SetOpacity(opacity_); | 868 layer->SetOpacity(opacity_); |
834 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 869 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); |
870 layer->SetBlendMode(blend_mode_); | |
871 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | |
835 layer->SetPosition(position_); | 872 layer->SetPosition(position_); |
836 layer->SetIsContainerForFixedPositionLayers( | 873 layer->SetIsContainerForFixedPositionLayers( |
837 IsContainerForFixedPositionLayers()); | 874 IsContainerForFixedPositionLayers()); |
838 layer->SetFixedContainerSizeDelta(gfx::Vector2dF()); | 875 layer->SetFixedContainerSizeDelta(gfx::Vector2dF()); |
839 layer->SetPositionConstraint(position_constraint_); | 876 layer->SetPositionConstraint(position_constraint_); |
840 layer->SetPreserves3d(preserves_3d()); | 877 layer->SetPreserves3d(preserves_3d()); |
841 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 878 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
842 layer->SetSublayerTransform(sublayer_transform_); | 879 layer->SetSublayerTransform(sublayer_transform_); |
843 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) | 880 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) |
844 layer->SetTransform(transform_); | 881 layer->SetTransform(transform_); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1088 clip_parent_->RemoveClipChild(this); | 1125 clip_parent_->RemoveClipChild(this); |
1089 | 1126 |
1090 clip_parent_ = NULL; | 1127 clip_parent_ = NULL; |
1091 } | 1128 } |
1092 | 1129 |
1093 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1130 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
1094 benchmark->RunOnLayer(this); | 1131 benchmark->RunOnLayer(this); |
1095 } | 1132 } |
1096 | 1133 |
1097 } // namespace cc | 1134 } // namespace cc |
OLD | NEW |