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

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

Issue 2269143003: cc : Add OnTransformAnimated to transform tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 render_surface_->ResetPropertyChangedFlag(); 492 render_surface_->ResetPropertyChangedFlag();
493 } 493 }
494 494
495 int LayerImpl::num_copy_requests_in_target_subtree() { 495 int LayerImpl::num_copy_requests_in_target_subtree() {
496 return layer_tree_impl() 496 return layer_tree_impl()
497 ->property_trees() 497 ->property_trees()
498 ->effect_tree.Node(effect_tree_index()) 498 ->effect_tree.Node(effect_tree_index())
499 ->num_copy_requests_in_subtree; 499 ->num_copy_requests_in_subtree;
500 } 500 }
501 501
502 void LayerImpl::UpdatePropertyTreeTransform(const gfx::Transform& transform) {
503 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
504 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
505 id())) {
506 // A LayerImpl's own current state is insufficient for determining whether
507 // it owns a TransformNode, since this depends on the state of the
508 // corresponding Layer at the time of the last commit. For example, a
509 // transform animation might have been in progress at the time the last
510 // commit started, but might have finished since then on the compositor
511 // thread.
512 TransformNode* node = property_trees->transform_tree.Node(
513 property_trees->transform_id_to_index_map[id()]);
514 if (node->local != transform) {
515 node->local = transform;
516 node->needs_local_transform_update = true;
517 node->transform_changed = true;
518 property_trees->changed = true;
519 property_trees->transform_tree.set_needs_update(true);
520 layer_tree_impl()->set_needs_update_draw_properties();
521 // TODO(ajuma): The current criteria for creating clip nodes means that
522 // property trees may need to be rebuilt when the new transform isn't
523 // axis-aligned wrt the old transform (see Layer::SetTransform). Since
524 // rebuilding property trees every frame of a transform animation is
525 // something we should try to avoid, change property tree-building so that
526 // it doesn't depend on axis aliginment.
527 }
528 }
529 }
530
531 void LayerImpl::UpdatePropertyTreeTransformIsAnimated(bool is_animated) { 502 void LayerImpl::UpdatePropertyTreeTransformIsAnimated(bool is_animated) {
532 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); 503 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
533 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 504 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
534 id())) { 505 id())) {
535 TransformNode* node = property_trees->transform_tree.Node( 506 TransformNode* node = property_trees->transform_tree.Node(
536 property_trees->transform_id_to_index_map[id()]); 507 property_trees->transform_id_to_index_map[id()]);
537 // A LayerImpl's own current state is insufficient for determining whether 508 // A LayerImpl's own current state is insufficient for determining whether
538 // it owns a TransformNode, since this depends on the state of the 509 // it owns a TransformNode, since this depends on the state of the
539 // corresponding Layer at the time of the last commit. For example, if 510 // corresponding Layer at the time of the last commit. For example, if
540 // |is_animated| is false, this might mean a transform animation just ticked 511 // |is_animated| is false, this might mean a transform animation just ticked
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 SetNeedsPushProperties(); 576 SetNeedsPushProperties();
606 layer_tree_impl()->set_needs_update_draw_properties(); 577 layer_tree_impl()->set_needs_update_draw_properties();
607 } 578 }
608 579
609 void LayerImpl::OnOpacityAnimated(float opacity) { 580 void LayerImpl::OnOpacityAnimated(float opacity) {
610 UpdatePropertyTreeOpacity(opacity); 581 UpdatePropertyTreeOpacity(opacity);
611 layer_tree_impl()->set_needs_update_draw_properties(); 582 layer_tree_impl()->set_needs_update_draw_properties();
612 layer_tree_impl()->AddToOpacityAnimationsMap(id(), opacity); 583 layer_tree_impl()->AddToOpacityAnimationsMap(id(), opacity);
613 } 584 }
614 585
615 void LayerImpl::OnTransformAnimated(const gfx::Transform& transform) {
616 UpdatePropertyTreeTransform(transform);
617 was_ever_ready_since_last_transform_animation_ = false;
618 layer_tree_impl()->AddToTransformAnimationsMap(id(), transform);
619 }
620
621 void LayerImpl::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { 586 void LayerImpl::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) {
622 // Only layers in the active tree should need to do anything here, since 587 // Only layers in the active tree should need to do anything here, since
623 // layers in the pending tree will find out about these changes as a 588 // layers in the pending tree will find out about these changes as a
624 // result of the shared SyncedProperty. 589 // result of the shared SyncedProperty.
625 if (!IsActive()) 590 if (!IsActive())
626 return; 591 return;
627 592
628 SetCurrentScrollOffset(ClampScrollOffsetToLimits(scroll_offset)); 593 SetCurrentScrollOffset(ClampScrollOffsetToLimits(scroll_offset));
629 594
630 layer_tree_impl_->DidAnimateScrollOffset(); 595 layer_tree_impl_->DidAnimateScrollOffset();
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 .layer_transforms_should_scale_layer_contents) { 1160 .layer_transforms_should_scale_layer_contents) {
1196 return default_scale; 1161 return default_scale;
1197 } 1162 }
1198 1163
1199 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1164 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1200 ScreenSpaceTransform(), default_scale); 1165 ScreenSpaceTransform(), default_scale);
1201 return std::max(transform_scales.x(), transform_scales.y()); 1166 return std::max(transform_scales.x(), transform_scales.y());
1202 } 1167 }
1203 1168
1204 } // namespace cc 1169 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698