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

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

Issue 2758343002: cc: Use Element Id to Record Animation Changes (Closed)
Patch Set: fix for test 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
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/test/layer_tree_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 update_rect_.SetRect(0, 0, 0, 0); 468 update_rect_.SetRect(0, 0, 0, 0);
469 damage_rect_.SetRect(0, 0, 0, 0); 469 damage_rect_.SetRect(0, 0, 0, 0);
470 } 470 }
471 471
472 int LayerImpl::num_copy_requests_in_target_subtree() { 472 int LayerImpl::num_copy_requests_in_target_subtree() {
473 return GetEffectTree() 473 return GetEffectTree()
474 .Node(effect_tree_index()) 474 .Node(effect_tree_index())
475 ->num_copy_requests_in_subtree; 475 ->num_copy_requests_in_subtree;
476 } 476 }
477 477
478 void LayerImpl::UpdatePropertyTreeTransformIsAnimated(bool is_animated) {
479 if (TransformNode* node =
480 GetTransformTree().UpdateNodeFromOwningLayerId(id())) {
481 // A LayerImpl's own current state is insufficient for determining whether
482 // it owns a TransformNode, since this depends on the state of the
483 // corresponding Layer at the time of the last commit. For example, if
484 // |is_animated| is false, this might mean a transform animation just ticked
485 // past its finish point (so the LayerImpl still owns a TransformNode) or it
486 // might mean that a transform animation was removed during commit or
487 // activation (and, in that case, the LayerImpl will no longer own a
488 // TransformNode, unless it has non-animation-related reasons for owning a
489 // node).
490 if (node->has_potential_animation != is_animated) {
491 node->has_potential_animation = is_animated;
492 if (is_animated) {
493 node->has_only_translation_animations = HasOnlyTranslationTransforms();
494 } else {
495 node->has_only_translation_animations = true;
496 }
497
498 GetTransformTree().set_needs_update(true);
499 layer_tree_impl()->set_needs_update_draw_properties();
500 }
501 }
502 }
503
504 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() { 478 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() {
505 if (scrollable()) 479 if (scrollable())
506 UpdatePropertyTreeScrollOffset(); 480 UpdatePropertyTreeScrollOffset();
507 481
508 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) { 482 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) {
509 UpdatePropertyTreeTransformIsAnimated( 483 if (TransformNode* node =
510 HasPotentiallyRunningTransformAnimation()); 484 GetTransformTree().FindNodeFromElementId(element_id())) {
485 bool has_potential_animation = HasPotentiallyRunningTransformAnimation();
486 if (node->has_potential_animation != has_potential_animation) {
487 node->has_potential_animation = has_potential_animation;
488 node->has_only_translation_animations = HasOnlyTranslationTransforms();
489 GetTransformTree().set_needs_update(true);
490 layer_tree_impl()->set_needs_update_draw_properties();
491 }
492 }
511 } 493 }
512 } 494 }
513 495
514 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { 496 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const {
515 return CurrentScrollOffset(); 497 return CurrentScrollOffset();
516 } 498 }
517 499
518 void LayerImpl::OnIsAnimatingChanged(const PropertyAnimationState& mask,
519 const PropertyAnimationState& state) {
520 DCHECK(layer_tree_impl_);
521
522 for (int property = TargetProperty::FIRST_TARGET_PROPERTY;
523 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) {
524 if (!mask.currently_running[property] &&
525 !mask.potentially_animating[property])
526 continue;
527
528 switch (property) {
529 case TargetProperty::TRANSFORM:
530 if (TransformNode* transform_node =
531 GetTransformTree().UpdateNodeFromOwningLayerId(id())) {
532 if (mask.currently_running[property])
533 transform_node->is_currently_animating =
534 state.currently_running[property];
535 if (mask.potentially_animating[property]) {
536 UpdatePropertyTreeTransformIsAnimated(
537 state.potentially_animating[property]);
538 was_ever_ready_since_last_transform_animation_ = false;
539 }
540 }
541 break;
542 case TargetProperty::OPACITY:
543 if (EffectNode* effect_node =
544 GetEffectTree().UpdateNodeFromOwningLayerId(id())) {
545 if (mask.currently_running[property])
546 effect_node->is_currently_animating_opacity =
547 state.currently_running[property];
548 if (mask.potentially_animating[property]) {
549 effect_node->has_potential_opacity_animation =
550 state.potentially_animating[property];
551 GetEffectTree().set_needs_update(true);
552 }
553 }
554 break;
555 case TargetProperty::FILTER:
556 if (EffectNode* effect_node =
557 GetEffectTree().UpdateNodeFromOwningLayerId(id())) {
558 if (mask.currently_running[property])
559 effect_node->is_currently_animating_filter =
560 state.currently_running[property];
561 if (mask.potentially_animating[property])
562 effect_node->has_potential_filter_animation =
563 state.potentially_animating[property];
564 }
565 break;
566 default:
567 break;
568 }
569 }
570 }
571
572 bool LayerImpl::IsActive() const { 500 bool LayerImpl::IsActive() const {
573 return layer_tree_impl_->IsActiveTree(); 501 return layer_tree_impl_->IsActiveTree();
574 } 502 }
575 503
576 gfx::Size LayerImpl::bounds() const { 504 gfx::Size LayerImpl::bounds() const {
577 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_); 505 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_);
578 return gfx::Size(bounds_.width() + delta.x(), 506 return gfx::Size(bounds_.width() + delta.x(),
579 bounds_.height() + delta.y()); 507 bounds_.height() + delta.y());
580 } 508 }
581 509
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 978
1051 ScrollTree& LayerImpl::GetScrollTree() const { 979 ScrollTree& LayerImpl::GetScrollTree() const {
1052 return GetPropertyTrees()->scroll_tree; 980 return GetPropertyTrees()->scroll_tree;
1053 } 981 }
1054 982
1055 TransformTree& LayerImpl::GetTransformTree() const { 983 TransformTree& LayerImpl::GetTransformTree() const {
1056 return GetPropertyTrees()->transform_tree; 984 return GetPropertyTrees()->transform_tree;
1057 } 985 }
1058 986
1059 } // namespace cc 987 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/test/layer_tree_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698