Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1066)

Side by Side Diff: cc/layers/layer_impl.cc

Issue 2753933005: cc: Move Layer Id to Node Map to Individual Property Tree Private (Closed)
Patch Set: add virtual to desctructor of ptree Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 damage_rect_.SetRect(0, 0, 0, 0); 477 damage_rect_.SetRect(0, 0, 0, 0);
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 PropertyTrees* property_trees = GetPropertyTrees(); 487 if (TransformNode* node = GetTransformTree().FindNodeFromId(id())) {
488 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
489 id())) {
490 TransformTree& transform_tree = GetTransformTree();
491 TransformNode* node = transform_tree.Node(
492 property_trees->layer_id_to_transform_node_index[id()]);
493 // A LayerImpl's own current state is insufficient for determining whether 488 // A LayerImpl's own current state is insufficient for determining whether
494 // it owns a TransformNode, since this depends on the state of the 489 // it owns a TransformNode, since this depends on the state of the
495 // corresponding Layer at the time of the last commit. For example, if 490 // corresponding Layer at the time of the last commit. For example, if
496 // |is_animated| is false, this might mean a transform animation just ticked 491 // |is_animated| is false, this might mean a transform animation just ticked
497 // past its finish point (so the LayerImpl still owns a TransformNode) or it 492 // past its finish point (so the LayerImpl still owns a TransformNode) or it
498 // might mean that a transform animation was removed during commit or 493 // might mean that a transform animation was removed during commit or
499 // activation (and, in that case, the LayerImpl will no longer own a 494 // activation (and, in that case, the LayerImpl will no longer own a
500 // TransformNode, unless it has non-animation-related reasons for owning a 495 // TransformNode, unless it has non-animation-related reasons for owning a
501 // node). 496 // node).
502 if (node->has_potential_animation != is_animated) { 497 if (node->has_potential_animation != is_animated) {
503 node->has_potential_animation = is_animated; 498 node->has_potential_animation = is_animated;
504 if (is_animated) { 499 if (is_animated) {
505 node->has_only_translation_animations = HasOnlyTranslationTransforms(); 500 node->has_only_translation_animations = HasOnlyTranslationTransforms();
506 } else { 501 } else {
507 node->has_only_translation_animations = true; 502 node->has_only_translation_animations = true;
508 } 503 }
509 504
510 transform_tree.set_needs_update(true); 505 GetTransformTree().set_needs_update(true);
511 layer_tree_impl()->set_needs_update_draw_properties(); 506 layer_tree_impl()->set_needs_update_draw_properties();
512 } 507 }
513 } 508 }
514 } 509 }
515 510
516 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() { 511 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() {
517 if (scrollable()) 512 if (scrollable())
518 UpdatePropertyTreeScrollOffset(); 513 UpdatePropertyTreeScrollOffset();
519 514
520 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) { 515 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) {
521 UpdatePropertyTreeTransformIsAnimated( 516 UpdatePropertyTreeTransformIsAnimated(
522 HasPotentiallyRunningTransformAnimation()); 517 HasPotentiallyRunningTransformAnimation());
523 } 518 }
524 } 519 }
525 520
526 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { 521 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const {
527 return CurrentScrollOffset(); 522 return CurrentScrollOffset();
528 } 523 }
529 524
530 void LayerImpl::OnIsAnimatingChanged(const PropertyAnimationState& mask, 525 void LayerImpl::OnIsAnimatingChanged(const PropertyAnimationState& mask,
531 const PropertyAnimationState& state) { 526 const PropertyAnimationState& state) {
532 DCHECK(layer_tree_impl_); 527 DCHECK(layer_tree_impl_);
533 PropertyTrees* property_trees = GetPropertyTrees();
534 528
535 TransformNode* transform_node = nullptr; 529 TransformNode* transform_node = GetTransformTree().FindNodeFromId(id());
536 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 530 EffectNode* effect_node = GetEffectTree().FindNodeFromId(id());
537 id())) {
538 transform_node = GetTransformTree().Node(
539 property_trees->layer_id_to_transform_node_index[id()]);
540 }
541
542 EffectNode* effect_node = nullptr;
543 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) {
544 effect_node = GetEffectTree().Node(
545 property_trees->layer_id_to_effect_node_index[id()]);
546 }
547
548 for (int property = TargetProperty::FIRST_TARGET_PROPERTY; 531 for (int property = TargetProperty::FIRST_TARGET_PROPERTY;
549 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) { 532 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) {
550 switch (property) { 533 switch (property) {
551 case TargetProperty::TRANSFORM: 534 case TargetProperty::TRANSFORM:
552 if (transform_node) { 535 if (transform_node) {
553 if (mask.currently_running[property]) 536 if (mask.currently_running[property])
554 transform_node->is_currently_animating = 537 transform_node->is_currently_animating =
555 state.currently_running[property]; 538 state.currently_running[property];
556 if (mask.potentially_animating[property]) { 539 if (mask.potentially_animating[property]) {
557 UpdatePropertyTreeTransformIsAnimated( 540 UpdatePropertyTreeTransformIsAnimated(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta); 611 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta);
629 else if (this == layer_tree_impl()->InnerViewportScrollLayer()) 612 else if (this == layer_tree_impl()->InnerViewportScrollLayer())
630 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta); 613 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta);
631 614
632 layer_tree_impl()->DidUpdateScrollState(id()); 615 layer_tree_impl()->DidUpdateScrollState(id());
633 616
634 if (masks_to_bounds()) { 617 if (masks_to_bounds()) {
635 // If layer is clipping, then update the clip node using the new bounds. 618 // If layer is clipping, then update the clip node using the new bounds.
636 ClipNode* clip_node = property_trees->clip_tree.Node(clip_tree_index()); 619 ClipNode* clip_node = property_trees->clip_tree.Node(clip_tree_index());
637 if (clip_node) { 620 if (clip_node) {
638 DCHECK(property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::CLIP, 621 DCHECK_EQ(clip_node, GetClipTree().FindNodeFromId(id()));
639 id()));
640 clip_node->clip = gfx::RectF(gfx::PointF() + offset_to_transform_parent(), 622 clip_node->clip = gfx::RectF(gfx::PointF() + offset_to_transform_parent(),
641 gfx::SizeF(bounds())); 623 gfx::SizeF(bounds()));
642 property_trees->clip_tree.set_needs_update(true); 624 property_trees->clip_tree.set_needs_update(true);
643 } 625 }
644 property_trees->full_tree_damaged = true; 626 property_trees->full_tree_damaged = true;
645 layer_tree_impl()->set_needs_update_draw_properties(); 627 layer_tree_impl()->set_needs_update_draw_properties();
646 } else { 628 } else {
647 NoteLayerPropertyChanged(); 629 NoteLayerPropertyChanged();
648 } 630 }
649 } 631 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 675
694 void LayerImpl::SetMasksToBounds(bool masks_to_bounds) { 676 void LayerImpl::SetMasksToBounds(bool masks_to_bounds) {
695 masks_to_bounds_ = masks_to_bounds; 677 masks_to_bounds_ = masks_to_bounds;
696 } 678 }
697 679
698 void LayerImpl::SetContentsOpaque(bool opaque) { 680 void LayerImpl::SetContentsOpaque(bool opaque) {
699 contents_opaque_ = opaque; 681 contents_opaque_ = opaque;
700 } 682 }
701 683
702 float LayerImpl::Opacity() const { 684 float LayerImpl::Opacity() const {
703 PropertyTrees* property_trees = GetPropertyTrees(); 685 if (EffectNode* node = GetEffectTree().FindNodeFromId(id()))
704 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 686 return node->opacity;
687 else
705 return 1.f; 688 return 1.f;
706 EffectNode* node =
707 GetEffectTree().Node(property_trees->layer_id_to_effect_node_index[id()]);
708 return node->opacity;
709 } 689 }
710 690
711 const gfx::Transform& LayerImpl::Transform() const { 691 const gfx::Transform& LayerImpl::Transform() const {
712 PropertyTrees* property_trees = GetPropertyTrees(); 692 DCHECK_NE(GetTransformTree().FindNodeFromId(id()), nullptr);
713 DCHECK(property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 693 return GetTransformTree().FindNodeFromId(id())->local;
714 id()));
715 TransformNode* node = GetTransformTree().Node(
716 property_trees->layer_id_to_transform_node_index[id()]);
717 return node->local;
718 } 694 }
719 695
720 void LayerImpl::SetElementId(ElementId element_id) { 696 void LayerImpl::SetElementId(ElementId element_id) {
721 if (element_id == element_id_) 697 if (element_id == element_id_)
722 return; 698 return;
723 699
724 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 700 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
725 "LayerImpl::SetElementId", "element", 701 "LayerImpl::SetElementId", "element",
726 element_id.AsValue().release()); 702 element_id.AsValue().release());
727 703
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 1035
1060 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1036 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1061 ScreenSpaceTransform(), default_scale); 1037 ScreenSpaceTransform(), default_scale);
1062 return std::max(transform_scales.x(), transform_scales.y()); 1038 return std::max(transform_scales.x(), transform_scales.y());
1063 } 1039 }
1064 1040
1065 PropertyTrees* LayerImpl::GetPropertyTrees() const { 1041 PropertyTrees* LayerImpl::GetPropertyTrees() const {
1066 return layer_tree_impl_->property_trees(); 1042 return layer_tree_impl_->property_trees();
1067 } 1043 }
1068 1044
1045 ClipTree& LayerImpl::GetClipTree() const {
1046 return GetPropertyTrees()->clip_tree;
1047 }
1048
1069 EffectTree& LayerImpl::GetEffectTree() const { 1049 EffectTree& LayerImpl::GetEffectTree() const {
1070 return GetPropertyTrees()->effect_tree; 1050 return GetPropertyTrees()->effect_tree;
1071 } 1051 }
1072 1052
1073 ScrollTree& LayerImpl::GetScrollTree() const { 1053 ScrollTree& LayerImpl::GetScrollTree() const {
1074 return GetPropertyTrees()->scroll_tree; 1054 return GetPropertyTrees()->scroll_tree;
1075 } 1055 }
1076 1056
1077 TransformTree& LayerImpl::GetTransformTree() const { 1057 TransformTree& LayerImpl::GetTransformTree() const {
1078 return GetPropertyTrees()->transform_tree; 1058 return GetPropertyTrees()->transform_tree;
1079 } 1059 }
1080 1060
1081 } // namespace cc 1061 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698