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