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

Side by Side Diff: cc/trees/layer_tree_host_common.cc

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_unittest.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 // If we'll make a copy of the layer's contents. 674 // If we'll make a copy of the layer's contents.
675 if (layer->HasCopyRequest()) 675 if (layer->HasCopyRequest())
676 return true; 676 return true;
677 677
678 return false; 678 return false;
679 } 679 }
680 680
681 // This function returns a translation matrix that can be applied on a vector 681 // This function returns a translation matrix that can be applied on a vector
682 // that's in the layer's target surface coordinate, while the position offset is 682 // that's in the layer's target surface coordinate, while the position offset is
683 // specified in some ancestor layer's coordinate. 683 // specified in some ancestor layer's coordinate.
684 template <typename LayerType>
684 gfx::Transform ComputeSizeDeltaCompensation( 685 gfx::Transform ComputeSizeDeltaCompensation(
685 LayerImpl* layer, 686 LayerType* layer,
686 LayerImpl* container, 687 LayerType* container,
687 const gfx::Vector2dF& position_offset) { 688 const gfx::Vector2dF& position_offset) {
688 gfx::Transform result_transform; 689 gfx::Transform result_transform;
689 690
690 // To apply a translate in the container's layer space, 691 // To apply a translate in the container's layer space,
691 // the following steps need to be done: 692 // the following steps need to be done:
692 // Step 1a. transform from target surface space to the container's target 693 // Step 1a. transform from target surface space to the container's target
693 // surface space 694 // surface space
694 // Step 1b. transform from container's target surface space to the 695 // Step 1b. transform from container's target surface space to the
695 // container's layer space 696 // container's layer space
696 // Step 2. apply the compensation 697 // Step 2. apply the compensation
697 // Step 3. transform back to target surface space 698 // Step 3. transform back to target surface space
698 699
699 gfx::Transform target_surface_space_to_container_layer_space; 700 gfx::Transform target_surface_space_to_container_layer_space;
700 // Calculate step 1a 701 // Calculate step 1a
701 LayerImpl* container_target_surface = container->render_target(); 702 LayerType* container_target_surface = container->render_target();
702 for (LayerImpl* current_target_surface = NextTargetSurface(layer); 703 for (LayerType* current_target_surface = NextTargetSurface(layer);
703 current_target_surface && 704 current_target_surface &&
704 current_target_surface != container_target_surface; 705 current_target_surface != container_target_surface;
705 current_target_surface = NextTargetSurface(current_target_surface)) { 706 current_target_surface = NextTargetSurface(current_target_surface)) {
706 // Note: Concat is used here to convert the result coordinate space from 707 // Note: Concat is used here to convert the result coordinate space from
707 // current render surface to the next render surface. 708 // current render surface to the next render surface.
708 target_surface_space_to_container_layer_space.ConcatTransform( 709 target_surface_space_to_container_layer_space.ConcatTransform(
709 current_target_surface->render_surface()->draw_transform()); 710 current_target_surface->render_surface()->draw_transform());
710 } 711 }
711 // Calculate step 1b 712 // Calculate step 1b
712 gfx::Transform container_layer_space_to_container_target_surface_space = 713 gfx::Transform container_layer_space_to_container_target_surface_space =
(...skipping 26 matching lines...) Expand all
739 // Apply step 2 740 // Apply step 2
740 result_transform.Translate(position_offset.x(), position_offset.y()); 741 result_transform.Translate(position_offset.x(), position_offset.y());
741 742
742 // Apply step 1 743 // Apply step 1
743 result_transform.PreconcatTransform( 744 result_transform.PreconcatTransform(
744 target_surface_space_to_container_layer_space); 745 target_surface_space_to_container_layer_space);
745 746
746 return result_transform; 747 return result_transform;
747 } 748 }
748 749
750 template <typename LayerType>
749 void ApplyPositionAdjustment( 751 void ApplyPositionAdjustment(
750 Layer* layer, 752 LayerType* layer,
751 Layer* container, 753 LayerType* container,
752 const gfx::Transform& scroll_compensation,
753 gfx::Transform* combined_transform) {}
754 void ApplyPositionAdjustment(
755 LayerImpl* layer,
756 LayerImpl* container,
757 const gfx::Transform& scroll_compensation, 754 const gfx::Transform& scroll_compensation,
758 gfx::Transform* combined_transform) { 755 gfx::Transform* combined_transform) {
759 if (!layer->position_constraint().is_fixed_position()) 756 if (!layer->position_constraint().is_fixed_position())
760 return; 757 return;
761 758
762 // Special case: this layer is a composited fixed-position layer; we need to 759 // Special case: this layer is a composited fixed-position layer; we need to
763 // explicitly compensate for all ancestors' nonzero scroll_deltas to keep 760 // explicitly compensate for all ancestors' nonzero scroll_deltas to keep
764 // this layer fixed correctly. 761 // this layer fixed correctly.
765 // Note carefully: this is Concat, not Preconcat 762 // Note carefully: this is Concat, not Preconcat
766 // (current_scroll_compensation * combined_transform). 763 // (current_scroll_compensation * combined_transform).
(...skipping 10 matching lines...) Expand all
777 position_offset.set_y(fixed_to_bottom_edge ? position_offset.y() : 0); 774 position_offset.set_y(fixed_to_bottom_edge ? position_offset.y() : 0);
778 if (position_offset.IsZero()) 775 if (position_offset.IsZero())
779 return; 776 return;
780 777
781 // Note: Again, this is Concat. The compensation matrix will be applied on 778 // Note: Again, this is Concat. The compensation matrix will be applied on
782 // the vector in target surface space. 779 // the vector in target surface space.
783 combined_transform->ConcatTransform( 780 combined_transform->ConcatTransform(
784 ComputeSizeDeltaCompensation(layer, container, position_offset)); 781 ComputeSizeDeltaCompensation(layer, container, position_offset));
785 } 782 }
786 783
784 template <typename LayerType>
787 gfx::Transform ComputeScrollCompensationForThisLayer( 785 gfx::Transform ComputeScrollCompensationForThisLayer(
788 LayerImpl* scrolling_layer, 786 LayerType* scrolling_layer,
789 const gfx::Transform& parent_matrix, 787 const gfx::Transform& parent_matrix,
790 const gfx::Vector2dF& scroll_delta) { 788 const gfx::Vector2dF& scroll_delta) {
791 // For every layer that has non-zero scroll_delta, we have to compute a 789 // For every layer that has non-zero scroll_delta, we have to compute a
792 // transform that can undo the scroll_delta translation. In particular, we 790 // transform that can undo the scroll_delta translation. In particular, we
793 // want this matrix to premultiply a fixed-position layer's parent_matrix, so 791 // want this matrix to premultiply a fixed-position layer's parent_matrix, so
794 // we design this transform in three steps as follows. The steps described 792 // we design this transform in three steps as follows. The steps described
795 // here apply from right-to-left, so Step 1 would be the right-most matrix: 793 // here apply from right-to-left, so Step 1 would be the right-most matrix:
796 // 794 //
797 // Step 1. transform from target surface space to the exact space where 795 // Step 1. transform from target surface space to the exact space where
798 // scroll_delta is actually applied. 796 // scroll_delta is actually applied.
(...skipping 17 matching lines...) Expand all
816 gfx::Transform inverse_parent_matrix(gfx::Transform::kSkipInitialization); 814 gfx::Transform inverse_parent_matrix(gfx::Transform::kSkipInitialization);
817 if (!parent_matrix.GetInverse(&inverse_parent_matrix)) { 815 if (!parent_matrix.GetInverse(&inverse_parent_matrix)) {
818 // TODO(shawnsingh): Either we need to handle uninvertible transforms 816 // TODO(shawnsingh): Either we need to handle uninvertible transforms
819 // here, or DCHECK that the transform is invertible. 817 // here, or DCHECK that the transform is invertible.
820 } 818 }
821 scroll_compensation_for_this_layer.PreconcatTransform( 819 scroll_compensation_for_this_layer.PreconcatTransform(
822 inverse_parent_matrix); // Step 1 820 inverse_parent_matrix); // Step 1
823 return scroll_compensation_for_this_layer; 821 return scroll_compensation_for_this_layer;
824 } 822 }
825 823
824 template <typename LayerType>
826 gfx::Transform ComputeScrollCompensationMatrixForChildren( 825 gfx::Transform ComputeScrollCompensationMatrixForChildren(
827 Layer* current_layer, 826 LayerType* layer,
828 const gfx::Transform& current_parent_matrix,
829 const gfx::Transform& current_scroll_compensation,
830 const gfx::Vector2dF& scroll_delta) {
831 // The main thread (i.e. Layer) does not need to worry about scroll
832 // compensation. So we can just return an identity matrix here.
833 return gfx::Transform();
834 }
835
836 gfx::Transform ComputeScrollCompensationMatrixForChildren(
837 LayerImpl* layer,
838 const gfx::Transform& parent_matrix, 827 const gfx::Transform& parent_matrix,
839 const gfx::Transform& current_scroll_compensation_matrix, 828 const gfx::Transform& current_scroll_compensation_matrix,
840 const gfx::Vector2dF& scroll_delta) { 829 const gfx::Vector2dF& scroll_delta) {
841 // "Total scroll compensation" is the transform needed to cancel out all 830 // "Total scroll compensation" is the transform needed to cancel out all
842 // scroll_delta translations that occurred since the nearest container layer, 831 // scroll_delta translations that occurred since the nearest container layer,
843 // even if there are render_surfaces in-between. 832 // even if there are render_surfaces in-between.
844 // 833 //
845 // There are some edge cases to be aware of, that are not explicit in the 834 // There are some edge cases to be aware of, that are not explicit in the
846 // code: 835 // code:
847 // - A layer that is both a fixed-position and container should not be its 836 // - A layer that is both a fixed-position and container should not be its
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 inputs->current_render_surface_layer_list_id); 2557 inputs->current_render_surface_layer_list_id);
2569 2558
2570 // The dummy layer list should not have been used. 2559 // The dummy layer list should not have been used.
2571 DCHECK_EQ(0u, dummy_layer_list.size()); 2560 DCHECK_EQ(0u, dummy_layer_list.size());
2572 // A root layer render_surface should always exist after 2561 // A root layer render_surface should always exist after
2573 // CalculateDrawProperties. 2562 // CalculateDrawProperties.
2574 DCHECK(inputs->root_layer->render_surface()); 2563 DCHECK(inputs->root_layer->render_surface());
2575 } 2564 }
2576 2565
2577 } // namespace cc 2566 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698