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

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

Issue 2758343002: cc: Use Element Id to Record Animation Changes (Closed)
Patch Set: 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 update_rect_.SetRect(0, 0, 0, 0); 476 update_rect_.SetRect(0, 0, 0, 0);
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) {
487 if (TransformNode* node =
488 GetTransformTree().UpdateNodeFromOwningLayerId(id())) {
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
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
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
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
497 // node).
498 if (node->has_potential_animation != is_animated) {
499 node->has_potential_animation = is_animated;
500 if (is_animated) {
501 node->has_only_translation_animations = HasOnlyTranslationTransforms();
502 } else {
503 node->has_only_translation_animations = true;
504 }
505
506 GetTransformTree().set_needs_update(true);
507 layer_tree_impl()->set_needs_update_draw_properties();
508 }
509 }
510 }
511
512 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() { 486 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() {
513 if (scrollable()) 487 if (scrollable())
514 UpdatePropertyTreeScrollOffset(); 488 UpdatePropertyTreeScrollOffset();
515 489
516 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) { 490 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) {
517 UpdatePropertyTreeTransformIsAnimated( 491 if (TransformNode* node =
518 HasPotentiallyRunningTransformAnimation()); 492 GetTransformTree().FindNodeFromElementId(element_id())) {
493 bool has_potential_animation = HasPotentiallyRunningTransformAnimation();
494 if (node->has_potential_animation != has_potential_animation) {
495 node->has_potential_animation = has_potential_animation;
496 node->has_only_translation_animations = HasOnlyTranslationTransforms();
497 GetTransformTree().set_needs_update(true);
498 layer_tree_impl()->set_needs_update_draw_properties();
499 }
500 }
519 } 501 }
520 } 502 }
521 503
522 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { 504 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const {
523 return CurrentScrollOffset(); 505 return CurrentScrollOffset();
524 } 506 }
525 507
526 void LayerImpl::OnIsAnimatingChanged(const PropertyAnimationState& mask,
527 const PropertyAnimationState& state) {
528 DCHECK(layer_tree_impl_);
529
530 for (int property = TargetProperty::FIRST_TARGET_PROPERTY;
531 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) {
532 if (!mask.currently_running[property] &&
533 !mask.potentially_animating[property])
534 continue;
535
536 switch (property) {
537 case TargetProperty::TRANSFORM:
538 if (TransformNode* transform_node =
539 GetTransformTree().UpdateNodeFromOwningLayerId(id())) {
540 if (mask.currently_running[property])
541 transform_node->is_currently_animating =
542 state.currently_running[property];
543 if (mask.potentially_animating[property]) {
544 UpdatePropertyTreeTransformIsAnimated(
545 state.potentially_animating[property]);
546 was_ever_ready_since_last_transform_animation_ = false;
547 }
548 }
549 break;
550 case TargetProperty::OPACITY:
551 if (EffectNode* effect_node =
552 GetEffectTree().UpdateNodeFromOwningLayerId(id())) {
553 if (mask.currently_running[property])
554 effect_node->is_currently_animating_opacity =
555 state.currently_running[property];
556 if (mask.potentially_animating[property]) {
557 effect_node->has_potential_opacity_animation =
558 state.potentially_animating[property];
559 GetEffectTree().set_needs_update(true);
560 }
561 }
562 break;
563 case TargetProperty::FILTER:
564 if (EffectNode* effect_node =
565 GetEffectTree().UpdateNodeFromOwningLayerId(id())) {
566 if (mask.currently_running[property])
567 effect_node->is_currently_animating_filter =
568 state.currently_running[property];
569 if (mask.potentially_animating[property])
570 effect_node->has_potential_filter_animation =
571 state.potentially_animating[property];
572 }
573 break;
574 default:
575 break;
576 }
577 }
578 }
579
580 bool LayerImpl::IsActive() const { 508 bool LayerImpl::IsActive() const {
581 return layer_tree_impl_->IsActiveTree(); 509 return layer_tree_impl_->IsActiveTree();
582 } 510 }
583 511
584 gfx::Size LayerImpl::bounds() const { 512 gfx::Size LayerImpl::bounds() const {
585 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_); 513 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_);
586 return gfx::Size(bounds_.width() + delta.x(), 514 return gfx::Size(bounds_.width() + delta.x(),
587 bounds_.height() + delta.y()); 515 bounds_.height() + delta.y());
588 } 516 }
589 517
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 986
1059 ScrollTree& LayerImpl::GetScrollTree() const { 987 ScrollTree& LayerImpl::GetScrollTree() const {
1060 return GetPropertyTrees()->scroll_tree; 988 return GetPropertyTrees()->scroll_tree;
1061 } 989 }
1062 990
1063 TransformTree& LayerImpl::GetTransformTree() const { 991 TransformTree& LayerImpl::GetTransformTree() const {
1064 return GetPropertyTrees()->transform_tree; 992 return GetPropertyTrees()->transform_tree;
1065 } 993 }
1066 994
1067 } // namespace cc 995 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/test/layer_tree_test.cc » ('j') | cc/trees/layer_tree_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698