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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 if (node->filters == filters) | 551 if (node->filters == filters) |
581 return; | 552 return; |
582 node->filters = filters; | 553 node->filters = filters; |
583 node->effect_changed = true; | 554 node->effect_changed = true; |
584 property_trees->changed = true; | 555 property_trees->changed = true; |
585 property_trees->effect_tree.set_needs_update(true); | 556 property_trees->effect_tree.set_needs_update(true); |
586 SetNeedsPushProperties(); | 557 SetNeedsPushProperties(); |
587 layer_tree_impl()->set_needs_update_draw_properties(); | 558 layer_tree_impl()->set_needs_update_draw_properties(); |
588 } | 559 } |
589 | 560 |
590 void LayerImpl::OnTransformAnimated(const gfx::Transform& transform) { | |
591 UpdatePropertyTreeTransform(transform); | |
592 was_ever_ready_since_last_transform_animation_ = false; | |
593 layer_tree_impl()->AddToTransformAnimationsMap(id(), transform); | |
594 } | |
595 | |
596 void LayerImpl::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { | 561 void LayerImpl::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { |
597 // Only layers in the active tree should need to do anything here, since | 562 // Only layers in the active tree should need to do anything here, since |
598 // layers in the pending tree will find out about these changes as a | 563 // layers in the pending tree will find out about these changes as a |
599 // result of the shared SyncedProperty. | 564 // result of the shared SyncedProperty. |
600 if (!IsActive()) | 565 if (!IsActive()) |
601 return; | 566 return; |
602 | 567 |
603 SetCurrentScrollOffset(ClampScrollOffsetToLimits(scroll_offset)); | 568 SetCurrentScrollOffset(ClampScrollOffsetToLimits(scroll_offset)); |
604 | 569 |
605 layer_tree_impl_->DidAnimateScrollOffset(); | 570 layer_tree_impl_->DidAnimateScrollOffset(); |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 .layer_transforms_should_scale_layer_contents) { | 1135 .layer_transforms_should_scale_layer_contents) { |
1171 return default_scale; | 1136 return default_scale; |
1172 } | 1137 } |
1173 | 1138 |
1174 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1139 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
1175 ScreenSpaceTransform(), default_scale); | 1140 ScreenSpaceTransform(), default_scale); |
1176 return std::max(transform_scales.x(), transform_scales.y()); | 1141 return std::max(transform_scales.x(), transform_scales.y()); |
1177 } | 1142 } |
1178 | 1143 |
1179 } // namespace cc | 1144 } // namespace cc |
OLD | NEW |