OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_impl.h" | 5 #include "cc/layers/layer_impl.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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 } | 478 } |
479 | 479 |
480 int LayerImpl::num_copy_requests_in_target_subtree() { | 480 int LayerImpl::num_copy_requests_in_target_subtree() { |
481 return GetEffectTree() | 481 return GetEffectTree() |
482 .Node(effect_tree_index()) | 482 .Node(effect_tree_index()) |
483 ->num_copy_requests_in_subtree; | 483 ->num_copy_requests_in_subtree; |
484 } | 484 } |
485 | 485 |
486 void LayerImpl::UpdatePropertyTreeTransformIsAnimated(bool is_animated) { | 486 void LayerImpl::UpdatePropertyTreeTransformIsAnimated(bool is_animated) { |
487 if (TransformNode* node = | 487 if (TransformNode* node = |
488 GetTransformTree().FindNodeFromOwningLayerId(id())) { | 488 GetTransformTree().UpdateNodeFromOwningLayerId(id())) { |
489 // A LayerImpl's own current state is insufficient for determining whether | 489 // A LayerImpl's own current state is insufficient for determining whether |
490 // it owns a TransformNode, since this depends on the state of the | 490 // it owns a TransformNode, since this depends on the state of the |
491 // corresponding Layer at the time of the last commit. For example, if | 491 // corresponding Layer at the time of the last commit. For example, if |
492 // |is_animated| is false, this might mean a transform animation just ticked | 492 // |is_animated| is false, this might mean a transform animation just ticked |
493 // past its finish point (so the LayerImpl still owns a TransformNode) or it | 493 // past its finish point (so the LayerImpl still owns a TransformNode) or it |
494 // might mean that a transform animation was removed during commit or | 494 // might mean that a transform animation was removed during commit or |
495 // activation (and, in that case, the LayerImpl will no longer own a | 495 // activation (and, in that case, the LayerImpl will no longer own a |
496 // TransformNode, unless it has non-animation-related reasons for owning a | 496 // TransformNode, unless it has non-animation-related reasons for owning a |
497 // node). | 497 // node). |
498 if (node->has_potential_animation != is_animated) { | 498 if (node->has_potential_animation != is_animated) { |
(...skipping 21 matching lines...) Expand all Loading... |
520 } | 520 } |
521 | 521 |
522 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { | 522 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { |
523 return CurrentScrollOffset(); | 523 return CurrentScrollOffset(); |
524 } | 524 } |
525 | 525 |
526 void LayerImpl::OnIsAnimatingChanged(const PropertyAnimationState& mask, | 526 void LayerImpl::OnIsAnimatingChanged(const PropertyAnimationState& mask, |
527 const PropertyAnimationState& state) { | 527 const PropertyAnimationState& state) { |
528 DCHECK(layer_tree_impl_); | 528 DCHECK(layer_tree_impl_); |
529 | 529 |
530 TransformNode* transform_node = | |
531 GetTransformTree().FindNodeFromOwningLayerId(id()); | |
532 EffectNode* effect_node = GetEffectTree().FindNodeFromOwningLayerId(id()); | |
533 for (int property = TargetProperty::FIRST_TARGET_PROPERTY; | 530 for (int property = TargetProperty::FIRST_TARGET_PROPERTY; |
534 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) { | 531 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) { |
535 switch (property) { | 532 switch (property) { |
536 case TargetProperty::TRANSFORM: | 533 case TargetProperty::TRANSFORM: |
537 if (transform_node) { | 534 if (TransformNode* transform_node = |
| 535 GetTransformTree().UpdateNodeFromOwningLayerId(id())) { |
538 if (mask.currently_running[property]) | 536 if (mask.currently_running[property]) |
539 transform_node->is_currently_animating = | 537 transform_node->is_currently_animating = |
540 state.currently_running[property]; | 538 state.currently_running[property]; |
541 if (mask.potentially_animating[property]) { | 539 if (mask.potentially_animating[property]) { |
542 UpdatePropertyTreeTransformIsAnimated( | 540 UpdatePropertyTreeTransformIsAnimated( |
543 state.potentially_animating[property]); | 541 state.potentially_animating[property]); |
544 was_ever_ready_since_last_transform_animation_ = false; | 542 was_ever_ready_since_last_transform_animation_ = false; |
545 } | 543 } |
546 } | 544 } |
547 break; | 545 break; |
548 case TargetProperty::OPACITY: | 546 case TargetProperty::OPACITY: |
549 if (effect_node) { | 547 if (EffectNode* effect_node = |
| 548 GetEffectTree().UpdateNodeFromOwningLayerId(id())) { |
550 if (mask.currently_running[property]) | 549 if (mask.currently_running[property]) |
551 effect_node->is_currently_animating_opacity = | 550 effect_node->is_currently_animating_opacity = |
552 state.currently_running[property]; | 551 state.currently_running[property]; |
553 if (mask.potentially_animating[property]) { | 552 if (mask.potentially_animating[property]) { |
554 effect_node->has_potential_opacity_animation = | 553 effect_node->has_potential_opacity_animation = |
555 state.potentially_animating[property]; | 554 state.potentially_animating[property]; |
556 GetEffectTree().set_needs_update(true); | 555 GetEffectTree().set_needs_update(true); |
557 } | 556 } |
558 } | 557 } |
559 break; | 558 break; |
560 case TargetProperty::FILTER: | 559 case TargetProperty::FILTER: |
561 if (effect_node) { | 560 if (EffectNode* effect_node = |
| 561 GetEffectTree().UpdateNodeFromOwningLayerId(id())) { |
562 if (mask.currently_running[property]) | 562 if (mask.currently_running[property]) |
563 effect_node->is_currently_animating_filter = | 563 effect_node->is_currently_animating_filter = |
564 state.currently_running[property]; | 564 state.currently_running[property]; |
565 if (mask.potentially_animating[property]) | 565 if (mask.potentially_animating[property]) |
566 effect_node->has_potential_filter_animation = | 566 effect_node->has_potential_filter_animation = |
567 state.potentially_animating[property]; | 567 state.potentially_animating[property]; |
568 } | 568 } |
569 break; | 569 break; |
570 default: | 570 default: |
571 break; | 571 break; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 property_trees->SetInnerViewportContainerBoundsDelta(bounds_delta); | 611 property_trees->SetInnerViewportContainerBoundsDelta(bounds_delta); |
612 else if (this == layer_tree_impl()->OuterViewportContainerLayer()) | 612 else if (this == layer_tree_impl()->OuterViewportContainerLayer()) |
613 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta); | 613 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta); |
614 else if (this == layer_tree_impl()->InnerViewportScrollLayer()) | 614 else if (this == layer_tree_impl()->InnerViewportScrollLayer()) |
615 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta); | 615 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta); |
616 | 616 |
617 layer_tree_impl()->DidUpdateScrollState(id()); | 617 layer_tree_impl()->DidUpdateScrollState(id()); |
618 | 618 |
619 if (masks_to_bounds()) { | 619 if (masks_to_bounds()) { |
620 // If layer is clipping, then update the clip node using the new bounds. | 620 // If layer is clipping, then update the clip node using the new bounds. |
621 ClipNode* clip_node = property_trees->clip_tree.Node(clip_tree_index()); | 621 if (ClipNode* clip_node = |
622 if (clip_node) { | 622 property_trees->clip_tree.UpdateNodeFromOwningLayerId(id())) { |
623 DCHECK_EQ(clip_node, GetClipTree().FindNodeFromOwningLayerId(id())); | 623 DCHECK_EQ(clip_node->id, clip_tree_index()); |
624 clip_node->clip = gfx::RectF(gfx::PointF() + offset_to_transform_parent(), | 624 clip_node->clip = gfx::RectF(gfx::PointF() + offset_to_transform_parent(), |
625 gfx::SizeF(bounds())); | 625 gfx::SizeF(bounds())); |
626 property_trees->clip_tree.set_needs_update(true); | 626 property_trees->clip_tree.set_needs_update(true); |
627 } | 627 } |
628 property_trees->full_tree_damaged = true; | 628 property_trees->full_tree_damaged = true; |
629 layer_tree_impl()->set_needs_update_draw_properties(); | 629 layer_tree_impl()->set_needs_update_draw_properties(); |
630 } else { | 630 } else { |
631 NoteLayerPropertyChanged(); | 631 NoteLayerPropertyChanged(); |
632 } | 632 } |
633 } | 633 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 | 677 |
678 void LayerImpl::SetMasksToBounds(bool masks_to_bounds) { | 678 void LayerImpl::SetMasksToBounds(bool masks_to_bounds) { |
679 masks_to_bounds_ = masks_to_bounds; | 679 masks_to_bounds_ = masks_to_bounds; |
680 } | 680 } |
681 | 681 |
682 void LayerImpl::SetContentsOpaque(bool opaque) { | 682 void LayerImpl::SetContentsOpaque(bool opaque) { |
683 contents_opaque_ = opaque; | 683 contents_opaque_ = opaque; |
684 } | 684 } |
685 | 685 |
686 float LayerImpl::Opacity() const { | 686 float LayerImpl::Opacity() const { |
687 if (EffectNode* node = GetEffectTree().FindNodeFromOwningLayerId(id())) | 687 if (const EffectNode* node = GetEffectTree().FindNodeFromOwningLayerId(id())) |
688 return node->opacity; | 688 return node->opacity; |
689 else | 689 else |
690 return 1.f; | 690 return 1.f; |
691 } | 691 } |
692 | 692 |
693 const gfx::Transform& LayerImpl::Transform() const { | 693 const gfx::Transform& LayerImpl::Transform() const { |
694 DCHECK_NE(GetTransformTree().FindNodeFromOwningLayerId(id()), nullptr); | 694 DCHECK_NE(GetTransformTree().FindNodeFromOwningLayerId(id()), nullptr); |
695 return GetTransformTree().FindNodeFromOwningLayerId(id())->local; | 695 return GetTransformTree().FindNodeFromOwningLayerId(id())->local; |
696 } | 696 } |
697 | 697 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 | 1054 |
1055 ScrollTree& LayerImpl::GetScrollTree() const { | 1055 ScrollTree& LayerImpl::GetScrollTree() const { |
1056 return GetPropertyTrees()->scroll_tree; | 1056 return GetPropertyTrees()->scroll_tree; |
1057 } | 1057 } |
1058 | 1058 |
1059 TransformTree& LayerImpl::GetTransformTree() const { | 1059 TransformTree& LayerImpl::GetTransformTree() const { |
1060 return GetPropertyTrees()->transform_tree; | 1060 return GetPropertyTrees()->transform_tree; |
1061 } | 1061 } |
1062 | 1062 |
1063 } // namespace cc | 1063 } // namespace cc |
OLD | NEW |