| 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 switch (blend_mode) { |
| 524 case SkXfermode::kSrcOver_Mode: |
| 525 case SkXfermode::kScreen_Mode: |
| 526 case SkXfermode::kOverlay_Mode: |
| 527 case SkXfermode::kDarken_Mode: |
| 528 case SkXfermode::kLighten_Mode: |
| 529 case SkXfermode::kColorDodge_Mode: |
| 530 case SkXfermode::kColorBurn_Mode: |
| 531 case SkXfermode::kHardLight_Mode: |
| 532 case SkXfermode::kSoftLight_Mode: |
| 533 case SkXfermode::kDifference_Mode: |
| 534 case SkXfermode::kExclusion_Mode: |
| 535 case SkXfermode::kMultiply_Mode: |
| 536 case SkXfermode::kHue_Mode: |
| 537 case SkXfermode::kSaturation_Mode: |
| 538 case SkXfermode::kColor_Mode: |
| 539 case SkXfermode::kLuminosity_Mode: |
| 540 // supported blend modes |
| 541 break; |
| 542 case SkXfermode::kClear_Mode: |
| 543 case SkXfermode::kSrc_Mode: |
| 544 case SkXfermode::kDst_Mode: |
| 545 case SkXfermode::kDstOver_Mode: |
| 546 case SkXfermode::kSrcIn_Mode: |
| 547 case SkXfermode::kDstIn_Mode: |
| 548 case SkXfermode::kSrcOut_Mode: |
| 549 case SkXfermode::kDstOut_Mode: |
| 550 case SkXfermode::kSrcATop_Mode: |
| 551 case SkXfermode::kDstATop_Mode: |
| 552 case SkXfermode::kXor_Mode: |
| 553 case SkXfermode::kPlus_Mode: |
| 554 case SkXfermode::kModulate_Mode: |
| 555 // Porter Duff Compositing Operators are not yet supported |
| 556 // http://dev.w3.org/fxtf/compositing-1/#porterduffcompositingoperators |
| 557 NOTREACHED(); |
| 558 return; |
| 559 } |
| 560 |
| 561 blend_mode_ = blend_mode; |
| 562 SetNeedsCommit(); |
| 563 SetNeedsFilterContextIfNeeded(); |
| 564 } |
| 565 |
| 566 void Layer::SetIsRootForIsolatedGroup(bool root) { |
| 567 DCHECK(IsPropertyChangeAllowed()); |
| 568 if (is_root_for_isolated_group_ == root) |
| 569 return; |
| 570 is_root_for_isolated_group_ = root; |
| 571 SetNeedsCommit(); |
| 572 } |
| 573 |
| 508 void Layer::SetContentsOpaque(bool opaque) { | 574 void Layer::SetContentsOpaque(bool opaque) { |
| 509 DCHECK(IsPropertyChangeAllowed()); | 575 DCHECK(IsPropertyChangeAllowed()); |
| 510 if (contents_opaque_ == opaque) | 576 if (contents_opaque_ == opaque) |
| 511 return; | 577 return; |
| 512 contents_opaque_ = opaque; | 578 contents_opaque_ = opaque; |
| 513 SetNeedsCommit(); | 579 SetNeedsCommit(); |
| 514 } | 580 } |
| 515 | 581 |
| 516 void Layer::SetPosition(gfx::PointF position) { | 582 void Layer::SetPosition(gfx::PointF position) { |
| 517 DCHECK(IsPropertyChangeAllowed()); | 583 DCHECK(IsPropertyChangeAllowed()); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 layer->SetBackgroundFilters(background_filters()); | 891 layer->SetBackgroundFilters(background_filters()); |
| 826 layer->SetMasksToBounds(masks_to_bounds_); | 892 layer->SetMasksToBounds(masks_to_bounds_); |
| 827 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); | 893 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); |
| 828 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 894 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
| 829 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 895 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
| 830 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 896 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
| 831 layer->SetContentsOpaque(contents_opaque_); | 897 layer->SetContentsOpaque(contents_opaque_); |
| 832 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) | 898 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) |
| 833 layer->SetOpacity(opacity_); | 899 layer->SetOpacity(opacity_); |
| 834 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 900 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); |
| 901 layer->SetBlendMode(blend_mode_); |
| 902 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
| 835 layer->SetPosition(position_); | 903 layer->SetPosition(position_); |
| 836 layer->SetIsContainerForFixedPositionLayers( | 904 layer->SetIsContainerForFixedPositionLayers( |
| 837 IsContainerForFixedPositionLayers()); | 905 IsContainerForFixedPositionLayers()); |
| 838 layer->SetFixedContainerSizeDelta(gfx::Vector2dF()); | 906 layer->SetFixedContainerSizeDelta(gfx::Vector2dF()); |
| 839 layer->SetPositionConstraint(position_constraint_); | 907 layer->SetPositionConstraint(position_constraint_); |
| 840 layer->SetPreserves3d(preserves_3d()); | 908 layer->SetPreserves3d(preserves_3d()); |
| 841 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 909 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
| 842 layer->SetSublayerTransform(sublayer_transform_); | 910 layer->SetSublayerTransform(sublayer_transform_); |
| 843 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) | 911 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) |
| 844 layer->SetTransform(transform_); | 912 layer->SetTransform(transform_); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 clip_parent_->RemoveClipChild(this); | 1158 clip_parent_->RemoveClipChild(this); |
| 1091 | 1159 |
| 1092 clip_parent_ = NULL; | 1160 clip_parent_ = NULL; |
| 1093 } | 1161 } |
| 1094 | 1162 |
| 1095 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1163 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 1096 benchmark->RunOnLayer(this); | 1164 benchmark->RunOnLayer(this); |
| 1097 } | 1165 } |
| 1098 | 1166 |
| 1099 } // namespace cc | 1167 } // namespace cc |
| OLD | NEW |