OLD | NEW |
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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 | 665 |
666 return false; | 666 return false; |
667 } | 667 } |
668 | 668 |
669 // This function returns a translation matrix that can be applied on a vector | 669 // This function returns a translation matrix that can be applied on a vector |
670 // that's in the layer's target surface coordinate, while the position offset is | 670 // that's in the layer's target surface coordinate, while the position offset is |
671 // specified in some ancestor layer's coordinate. | 671 // specified in some ancestor layer's coordinate. |
672 gfx::Transform ComputeSizeDeltaCompensation( | 672 gfx::Transform ComputeSizeDeltaCompensation( |
673 LayerImpl* layer, | 673 LayerImpl* layer, |
674 LayerImpl* container, | 674 LayerImpl* container, |
675 gfx::Vector2dF position_offset) { | 675 const gfx::Vector2dF& position_offset) { |
676 gfx::Transform result_transform; | 676 gfx::Transform result_transform; |
677 | 677 |
678 // To apply a translate in the container's layer space, | 678 // To apply a translate in the container's layer space, |
679 // the following steps need to be done: | 679 // the following steps need to be done: |
680 // Step 1a. transform from target surface space to the container's target | 680 // Step 1a. transform from target surface space to the container's target |
681 // surface space | 681 // surface space |
682 // Step 1b. transform from container's target surface space to the | 682 // Step 1b. transform from container's target surface space to the |
683 // container's layer space | 683 // container's layer space |
684 // Step 2. apply the compensation | 684 // Step 2. apply the compensation |
685 // Step 3. transform back to target surface space | 685 // Step 3. transform back to target surface space |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 | 768 |
769 // Note: Again, this is Concat. The compensation matrix will be applied on | 769 // Note: Again, this is Concat. The compensation matrix will be applied on |
770 // the vector in target surface space. | 770 // the vector in target surface space. |
771 combined_transform->ConcatTransform( | 771 combined_transform->ConcatTransform( |
772 ComputeSizeDeltaCompensation(layer, container, position_offset)); | 772 ComputeSizeDeltaCompensation(layer, container, position_offset)); |
773 } | 773 } |
774 | 774 |
775 gfx::Transform ComputeScrollCompensationForThisLayer( | 775 gfx::Transform ComputeScrollCompensationForThisLayer( |
776 LayerImpl* scrolling_layer, | 776 LayerImpl* scrolling_layer, |
777 const gfx::Transform& parent_matrix, | 777 const gfx::Transform& parent_matrix, |
778 gfx::Vector2dF scroll_delta) { | 778 const gfx::Vector2dF& scroll_delta) { |
779 // For every layer that has non-zero scroll_delta, we have to compute a | 779 // For every layer that has non-zero scroll_delta, we have to compute a |
780 // transform that can undo the scroll_delta translation. In particular, we | 780 // transform that can undo the scroll_delta translation. In particular, we |
781 // want this matrix to premultiply a fixed-position layer's parent_matrix, so | 781 // want this matrix to premultiply a fixed-position layer's parent_matrix, so |
782 // we design this transform in three steps as follows. The steps described | 782 // we design this transform in three steps as follows. The steps described |
783 // here apply from right-to-left, so Step 1 would be the right-most matrix: | 783 // here apply from right-to-left, so Step 1 would be the right-most matrix: |
784 // | 784 // |
785 // Step 1. transform from target surface space to the exact space where | 785 // Step 1. transform from target surface space to the exact space where |
786 // scroll_delta is actually applied. | 786 // scroll_delta is actually applied. |
787 // -- this is inverse of parent_matrix | 787 // -- this is inverse of parent_matrix |
788 // Step 2. undo the scroll_delta | 788 // Step 2. undo the scroll_delta |
(...skipping 19 matching lines...) Expand all Loading... |
808 } | 808 } |
809 scroll_compensation_for_this_layer.PreconcatTransform( | 809 scroll_compensation_for_this_layer.PreconcatTransform( |
810 inverse_parent_matrix); // Step 1 | 810 inverse_parent_matrix); // Step 1 |
811 return scroll_compensation_for_this_layer; | 811 return scroll_compensation_for_this_layer; |
812 } | 812 } |
813 | 813 |
814 gfx::Transform ComputeScrollCompensationMatrixForChildren( | 814 gfx::Transform ComputeScrollCompensationMatrixForChildren( |
815 Layer* current_layer, | 815 Layer* current_layer, |
816 const gfx::Transform& current_parent_matrix, | 816 const gfx::Transform& current_parent_matrix, |
817 const gfx::Transform& current_scroll_compensation, | 817 const gfx::Transform& current_scroll_compensation, |
818 gfx::Vector2dF scroll_delta) { | 818 const gfx::Vector2dF& scroll_delta) { |
819 // The main thread (i.e. Layer) does not need to worry about scroll | 819 // The main thread (i.e. Layer) does not need to worry about scroll |
820 // compensation. So we can just return an identity matrix here. | 820 // compensation. So we can just return an identity matrix here. |
821 return gfx::Transform(); | 821 return gfx::Transform(); |
822 } | 822 } |
823 | 823 |
824 gfx::Transform ComputeScrollCompensationMatrixForChildren( | 824 gfx::Transform ComputeScrollCompensationMatrixForChildren( |
825 LayerImpl* layer, | 825 LayerImpl* layer, |
826 const gfx::Transform& parent_matrix, | 826 const gfx::Transform& parent_matrix, |
827 const gfx::Transform& current_scroll_compensation_matrix, | 827 const gfx::Transform& current_scroll_compensation_matrix, |
828 gfx::Vector2dF scroll_delta) { | 828 const gfx::Vector2dF& scroll_delta) { |
829 // "Total scroll compensation" is the transform needed to cancel out all | 829 // "Total scroll compensation" is the transform needed to cancel out all |
830 // scroll_delta translations that occurred since the nearest container layer, | 830 // scroll_delta translations that occurred since the nearest container layer, |
831 // even if there are render_surfaces in-between. | 831 // even if there are render_surfaces in-between. |
832 // | 832 // |
833 // There are some edge cases to be aware of, that are not explicit in the | 833 // There are some edge cases to be aware of, that are not explicit in the |
834 // code: | 834 // code: |
835 // - A layer that is both a fixed-position and container should not be its | 835 // - A layer that is both a fixed-position and container should not be its |
836 // own container, instead, that means it is fixed to an ancestor, and is a | 836 // own container, instead, that means it is fixed to an ancestor, and is a |
837 // container for any fixed-position descendants. | 837 // container for any fixed-position descendants. |
838 // - A layer that is a fixed-position container and has a render_surface | 838 // - A layer that is a fixed-position container and has a render_surface |
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 // At this point, we think the point does hit the touch event handler region | 2417 // At this point, we think the point does hit the touch event handler region |
2418 // on the layer, but we need to walk up the parents to ensure that the layer | 2418 // on the layer, but we need to walk up the parents to ensure that the layer |
2419 // was not clipped in such a way that the hit point actually should not hit | 2419 // was not clipped in such a way that the hit point actually should not hit |
2420 // the layer. | 2420 // the layer. |
2421 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 2421 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
2422 return false; | 2422 return false; |
2423 | 2423 |
2424 return true; | 2424 return true; |
2425 } | 2425 } |
2426 } // namespace cc | 2426 } // namespace cc |
OLD | NEW |