| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 if (filters_ == filters) | 500 if (filters_ == filters) |
| 501 return; | 501 return; |
| 502 filters_ = filters; | 502 filters_ = filters; |
| 503 SetNeedsCommit(); | 503 SetNeedsCommit(); |
| 504 } | 504 } |
| 505 | 505 |
| 506 bool Layer::FilterIsAnimating() const { | 506 bool Layer::FilterIsAnimating() const { |
| 507 DCHECK(layer_tree_host_); | 507 DCHECK(layer_tree_host_); |
| 508 return layer_animation_controller_ | 508 return layer_animation_controller_ |
| 509 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( | 509 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( |
| 510 Animation::FILTER, | 510 TargetProperty::FILTER, |
| 511 LayerAnimationController::ObserverType::ACTIVE) | 511 LayerAnimationController::ObserverType::ACTIVE) |
| 512 : layer_tree_host_->IsAnimatingFilterProperty(this); | 512 : layer_tree_host_->IsAnimatingFilterProperty(this); |
| 513 } | 513 } |
| 514 | 514 |
| 515 bool Layer::HasPotentiallyRunningFilterAnimation() const { | 515 bool Layer::HasPotentiallyRunningFilterAnimation() const { |
| 516 if (layer_animation_controller_) { | 516 if (layer_animation_controller_) { |
| 517 return layer_animation_controller_->IsPotentiallyAnimatingProperty( | 517 return layer_animation_controller_->IsPotentiallyAnimatingProperty( |
| 518 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE); | 518 TargetProperty::FILTER, LayerAnimationController::ObserverType::ACTIVE); |
| 519 } | 519 } |
| 520 return layer_tree_host_->HasPotentiallyRunningFilterAnimation(this); | 520 return layer_tree_host_->HasPotentiallyRunningFilterAnimation(this); |
| 521 } | 521 } |
| 522 | 522 |
| 523 void Layer::SetBackgroundFilters(const FilterOperations& filters) { | 523 void Layer::SetBackgroundFilters(const FilterOperations& filters) { |
| 524 DCHECK(IsPropertyChangeAllowed()); | 524 DCHECK(IsPropertyChangeAllowed()); |
| 525 if (background_filters_ == filters) | 525 if (background_filters_ == filters) |
| 526 return; | 526 return; |
| 527 background_filters_ = filters; | 527 background_filters_ = filters; |
| 528 SetNeedsCommit(); | 528 SetNeedsCommit(); |
| 529 } | 529 } |
| 530 | 530 |
| 531 void Layer::SetOpacity(float opacity) { | 531 void Layer::SetOpacity(float opacity) { |
| 532 DCHECK(IsPropertyChangeAllowed()); | 532 DCHECK(IsPropertyChangeAllowed()); |
| 533 if (opacity_ == opacity) | 533 if (opacity_ == opacity) |
| 534 return; | 534 return; |
| 535 opacity_ = opacity; | 535 opacity_ = opacity; |
| 536 SetNeedsCommit(); | 536 SetNeedsCommit(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 float Layer::EffectiveOpacity() const { | 539 float Layer::EffectiveOpacity() const { |
| 540 return hide_layer_and_subtree_ ? 0.f : opacity_; | 540 return hide_layer_and_subtree_ ? 0.f : opacity_; |
| 541 } | 541 } |
| 542 | 542 |
| 543 bool Layer::OpacityIsAnimating() const { | 543 bool Layer::OpacityIsAnimating() const { |
| 544 DCHECK(layer_tree_host_); | 544 DCHECK(layer_tree_host_); |
| 545 return layer_animation_controller_ | 545 return layer_animation_controller_ |
| 546 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( | 546 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( |
| 547 Animation::OPACITY, | 547 TargetProperty::OPACITY, |
| 548 LayerAnimationController::ObserverType::ACTIVE) | 548 LayerAnimationController::ObserverType::ACTIVE) |
| 549 : layer_tree_host_->IsAnimatingOpacityProperty(this); | 549 : layer_tree_host_->IsAnimatingOpacityProperty(this); |
| 550 } | 550 } |
| 551 | 551 |
| 552 bool Layer::HasPotentiallyRunningOpacityAnimation() const { | 552 bool Layer::HasPotentiallyRunningOpacityAnimation() const { |
| 553 if (layer_animation_controller_) { | 553 if (layer_animation_controller_) { |
| 554 return layer_animation_controller_->IsPotentiallyAnimatingProperty( | 554 return layer_animation_controller_->IsPotentiallyAnimatingProperty( |
| 555 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE); | 555 TargetProperty::OPACITY, |
| 556 LayerAnimationController::ObserverType::ACTIVE); |
| 556 } | 557 } |
| 557 return layer_tree_host_->HasPotentiallyRunningOpacityAnimation(this); | 558 return layer_tree_host_->HasPotentiallyRunningOpacityAnimation(this); |
| 558 } | 559 } |
| 559 | 560 |
| 560 bool Layer::OpacityCanAnimateOnImplThread() const { | 561 bool Layer::OpacityCanAnimateOnImplThread() const { |
| 561 return false; | 562 return false; |
| 562 } | 563 } |
| 563 | 564 |
| 564 void Layer::SetBlendMode(SkXfermode::Mode blend_mode) { | 565 void Layer::SetBlendMode(SkXfermode::Mode blend_mode) { |
| 565 DCHECK(IsPropertyChangeAllowed()); | 566 DCHECK(IsPropertyChangeAllowed()); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 DCHECK(layer_tree_host_); | 750 DCHECK(layer_tree_host_); |
| 750 return layer_animation_controller_ | 751 return layer_animation_controller_ |
| 751 ? layer_animation_controller_->AnimationsPreserveAxisAlignment() | 752 ? layer_animation_controller_->AnimationsPreserveAxisAlignment() |
| 752 : layer_tree_host_->AnimationsPreserveAxisAlignment(this); | 753 : layer_tree_host_->AnimationsPreserveAxisAlignment(this); |
| 753 } | 754 } |
| 754 | 755 |
| 755 bool Layer::TransformIsAnimating() const { | 756 bool Layer::TransformIsAnimating() const { |
| 756 DCHECK(layer_tree_host_); | 757 DCHECK(layer_tree_host_); |
| 757 return layer_animation_controller_ | 758 return layer_animation_controller_ |
| 758 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( | 759 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( |
| 759 Animation::TRANSFORM, | 760 TargetProperty::TRANSFORM, |
| 760 LayerAnimationController::ObserverType::ACTIVE) | 761 LayerAnimationController::ObserverType::ACTIVE) |
| 761 : layer_tree_host_->IsAnimatingTransformProperty(this); | 762 : layer_tree_host_->IsAnimatingTransformProperty(this); |
| 762 } | 763 } |
| 763 | 764 |
| 764 bool Layer::HasPotentiallyRunningTransformAnimation() const { | 765 bool Layer::HasPotentiallyRunningTransformAnimation() const { |
| 765 if (layer_animation_controller_) { | 766 if (layer_animation_controller_) { |
| 766 return layer_animation_controller_->IsPotentiallyAnimatingProperty( | 767 return layer_animation_controller_->IsPotentiallyAnimatingProperty( |
| 767 Animation::TRANSFORM, LayerAnimationController::ObserverType::ACTIVE); | 768 TargetProperty::TRANSFORM, |
| 769 LayerAnimationController::ObserverType::ACTIVE); |
| 768 } | 770 } |
| 769 return layer_tree_host_->HasPotentiallyRunningTransformAnimation(this); | 771 return layer_tree_host_->HasPotentiallyRunningTransformAnimation(this); |
| 770 } | 772 } |
| 771 | 773 |
| 772 bool Layer::HasOnlyTranslationTransforms() const { | 774 bool Layer::HasOnlyTranslationTransforms() const { |
| 773 if (layer_animation_controller_) { | 775 if (layer_animation_controller_) { |
| 774 return layer_animation_controller_->HasOnlyTranslationTransforms( | 776 return layer_animation_controller_->HasOnlyTranslationTransforms( |
| 775 LayerAnimationController::ObserverType::ACTIVE); | 777 LayerAnimationController::ObserverType::ACTIVE); |
| 776 } | 778 } |
| 777 return layer_tree_host_->HasOnlyTranslationTransforms(this); | 779 return layer_tree_host_->HasOnlyTranslationTransforms(this); |
| 778 } | 780 } |
| 779 | 781 |
| 780 bool Layer::MaximumTargetScale(float* max_scale) const { | 782 bool Layer::MaximumTargetScale(float* max_scale) const { |
| 781 if (layer_animation_controller_) { | 783 if (layer_animation_controller_) { |
| 782 return layer_animation_controller_->MaximumTargetScale( | 784 return layer_animation_controller_->MaximumTargetScale( |
| 783 LayerAnimationController::ObserverType::ACTIVE, max_scale); | 785 LayerAnimationController::ObserverType::ACTIVE, max_scale); |
| 784 } | 786 } |
| 785 return layer_tree_host_->MaximumTargetScale(this, max_scale); | 787 return layer_tree_host_->MaximumTargetScale(this, max_scale); |
| 786 } | 788 } |
| 787 | 789 |
| 788 bool Layer::AnimationStartScale(float* start_scale) const { | 790 bool Layer::AnimationStartScale(float* start_scale) const { |
| 789 if (layer_animation_controller_) { | 791 if (layer_animation_controller_) { |
| 790 return layer_animation_controller_->AnimationStartScale( | 792 return layer_animation_controller_->AnimationStartScale( |
| 791 LayerAnimationController::ObserverType::ACTIVE, start_scale); | 793 LayerAnimationController::ObserverType::ACTIVE, start_scale); |
| 792 } | 794 } |
| 793 return layer_tree_host_->AnimationStartScale(this, start_scale); | 795 return layer_tree_host_->AnimationStartScale(this, start_scale); |
| 794 } | 796 } |
| 795 | 797 |
| 796 bool Layer::HasAnyAnimationTargetingProperty( | 798 bool Layer::HasAnyAnimationTargetingProperty( |
| 797 Animation::TargetProperty property) const { | 799 TargetProperty::Type property) const { |
| 798 if (layer_animation_controller_) | 800 if (layer_animation_controller_) |
| 799 return !!layer_animation_controller_->GetAnimation(property); | 801 return !!layer_animation_controller_->GetAnimation(property); |
| 800 | 802 |
| 801 return layer_tree_host_->HasAnyAnimationTargetingProperty(this, property); | 803 return layer_tree_host_->HasAnyAnimationTargetingProperty(this, property); |
| 802 } | 804 } |
| 803 | 805 |
| 804 bool Layer::ScrollOffsetAnimationWasInterrupted() const { | 806 bool Layer::ScrollOffsetAnimationWasInterrupted() const { |
| 805 DCHECK(layer_tree_host_); | 807 DCHECK(layer_tree_host_); |
| 806 return layer_animation_controller_ | 808 return layer_animation_controller_ |
| 807 ? layer_animation_controller_ | 809 ? layer_animation_controller_ |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 | 1869 |
| 1868 bool Layer::IsActive() const { | 1870 bool Layer::IsActive() const { |
| 1869 return true; | 1871 return true; |
| 1870 } | 1872 } |
| 1871 | 1873 |
| 1872 bool Layer::AddAnimation(scoped_ptr <Animation> animation) { | 1874 bool Layer::AddAnimation(scoped_ptr <Animation> animation) { |
| 1873 DCHECK(layer_animation_controller_); | 1875 DCHECK(layer_animation_controller_); |
| 1874 if (!layer_animation_controller_->animation_registrar()) | 1876 if (!layer_animation_controller_->animation_registrar()) |
| 1875 return false; | 1877 return false; |
| 1876 | 1878 |
| 1877 if (animation->target_property() == Animation::SCROLL_OFFSET && | 1879 if (animation->target_property() == TargetProperty::SCROLL_OFFSET && |
| 1878 !layer_animation_controller_->animation_registrar() | 1880 !layer_animation_controller_->animation_registrar() |
| 1879 ->supports_scroll_animations()) | 1881 ->supports_scroll_animations()) |
| 1880 return false; | 1882 return false; |
| 1881 | 1883 |
| 1882 UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer", | 1884 UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer", |
| 1883 !layer_tree_host_); | 1885 !layer_tree_host_); |
| 1884 layer_animation_controller_->AddAnimation(std::move(animation)); | 1886 layer_animation_controller_->AddAnimation(std::move(animation)); |
| 1885 SetNeedsCommit(); | 1887 SetNeedsCommit(); |
| 1886 return true; | 1888 return true; |
| 1887 } | 1889 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2069 this, layer_tree_host_->property_trees()->transform_tree); | 2071 this, layer_tree_host_->property_trees()->transform_tree); |
| 2070 } | 2072 } |
| 2071 | 2073 |
| 2072 gfx::Transform Layer::screen_space_transform() const { | 2074 gfx::Transform Layer::screen_space_transform() const { |
| 2073 DCHECK_NE(transform_tree_index_, -1); | 2075 DCHECK_NE(transform_tree_index_, -1); |
| 2074 return ScreenSpaceTransformFromPropertyTrees( | 2076 return ScreenSpaceTransformFromPropertyTrees( |
| 2075 this, layer_tree_host_->property_trees()->transform_tree); | 2077 this, layer_tree_host_->property_trees()->transform_tree); |
| 2076 } | 2078 } |
| 2077 | 2079 |
| 2078 } // namespace cc | 2080 } // namespace cc |
| OLD | NEW |