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

Side by Side Diff: cc/layer_tree_host_common.cc

Issue 11774005: Migrate more functions from MathUtil to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
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/layer_tree_host_common.h" 5 #include "cc/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/layer.h" 10 #include "cc/layer.h"
11 #include "cc/layer_impl.h" 11 #include "cc/layer_impl.h"
12 #include "cc/layer_iterator.h" 12 #include "cc/layer_iterator.h"
13 #include "cc/layer_sorter.h" 13 #include "cc/layer_sorter.h"
14 #include "cc/math_util.h" 14 #include "cc/math_util.h"
15 #include "cc/render_surface.h" 15 #include "cc/render_surface.h"
16 #include "cc/render_surface_impl.h" 16 #include "cc/render_surface_impl.h"
17 #include "ui/gfx/point_conversions.h" 17 #include "ui/gfx/point_conversions.h"
18 #include "ui/gfx/rect_conversions.h" 18 #include "ui/gfx/rect_conversions.h"
19 #include "ui/gfx/transform.h" 19 #include "ui/gfx/transform.h"
20 #include "ui/gfx/transform_util.h"
20 21
21 namespace cc { 22 namespace cc {
22 23
23 ScrollAndScaleSet::ScrollAndScaleSet() 24 ScrollAndScaleSet::ScrollAndScaleSet()
24 { 25 {
25 } 26 }
26 27
27 ScrollAndScaleSet::~ScrollAndScaleSet() 28 ScrollAndScaleSet::~ScrollAndScaleSet()
28 { 29 {
29 } 30 }
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 664
664 // The drawTransform that gets computed below is effectively the layer's dra wTransform, unless 665 // The drawTransform that gets computed below is effectively the layer's dra wTransform, unless
665 // the layer itself creates a renderSurface. In that case, the renderSurface re-parents the transforms. 666 // the layer itself creates a renderSurface. In that case, the renderSurface re-parents the transforms.
666 layerDrawProperties.target_space_transform = combinedTransform; 667 layerDrawProperties.target_space_transform = combinedTransform;
667 // M[draw] = M[parent] * LT * S[layer2content] 668 // M[draw] = M[parent] * LT * S[layer2content]
668 layerDrawProperties.target_space_transform.Scale(1.0 / layer->contentsScaleX (), 1.0 / layer->contentsScaleY()); 669 layerDrawProperties.target_space_transform.Scale(1.0 / layer->contentsScaleX (), 1.0 / layer->contentsScaleY());
669 670
670 // layerScreenSpaceTransform represents the transform between root layer's " screen space" and local content space. 671 // layerScreenSpaceTransform represents the transform between root layer's " screen space" and local content space.
671 layerDrawProperties.screen_space_transform = fullHierarchyMatrix; 672 layerDrawProperties.screen_space_transform = fullHierarchyMatrix;
672 if (!layer->preserves3D()) 673 if (!layer->preserves3D())
673 MathUtil::flattenTransformTo2d(layerDrawProperties.screen_space_transfor m); 674 gfx::FlattenTransformTo2d(layerDrawProperties.screen_space_transform);
674 layerDrawProperties.screen_space_transform.PreconcatTransform(layerDrawPrope rties.target_space_transform); 675 layerDrawProperties.screen_space_transform.PreconcatTransform(layerDrawPrope rties.target_space_transform);
675 676
676 // Adjusting text AA method during animation may cause repaints, which in-tu rn causes jank. 677 // Adjusting text AA method during animation may cause repaints, which in-tu rn causes jank.
677 bool adjustTextAA = !animatingOpacityToScreen && !animatingTransformToScreen ; 678 bool adjustTextAA = !animatingOpacityToScreen && !animatingTransformToScreen ;
678 // To avoid color fringing, LCD text should only be used on opaque layers wi th just integral translation. 679 // To avoid color fringing, LCD text should only be used on opaque layers wi th just integral translation.
679 bool layerCanUseLCDText = subtreeCanUseLCDText && 680 bool layerCanUseLCDText = subtreeCanUseLCDText &&
680 (accumulatedDrawOpacity == 1.0) && 681 (accumulatedDrawOpacity == 1.0) &&
681 layerDrawProperties.target_space_transform.IsIdent ityOrIntegerTranslation(); 682 layerDrawProperties.target_space_transform.IsIdent ityOrIntegerTranslation();
682 683
683 gfx::RectF contentRect(gfx::PointF(), layer->contentBounds()); 684 gfx::RectF contentRect(gfx::PointF(), layer->contentBounds());
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 subtreeShouldBeClipped = true; 818 subtreeShouldBeClipped = true;
818 if (ancestorClipsSubtree && !layer->renderSurface()) { 819 if (ancestorClipsSubtree && !layer->renderSurface()) {
819 clipRectForSubtree = clipRectFromAncestor; 820 clipRectForSubtree = clipRectFromAncestor;
820 clipRectForSubtree.Intersect(rectInTargetSpace); 821 clipRectForSubtree.Intersect(rectInTargetSpace);
821 } else 822 } else
822 clipRectForSubtree = rectInTargetSpace; 823 clipRectForSubtree = rectInTargetSpace;
823 } 824 }
824 825
825 // Flatten to 2D if the layer doesn't preserve 3D. 826 // Flatten to 2D if the layer doesn't preserve 3D.
826 if (!layer->preserves3D()) 827 if (!layer->preserves3D())
827 MathUtil::flattenTransformTo2d(sublayerMatrix); 828 gfx::FlattenTransformTo2d(sublayerMatrix);
828 829
829 // Apply the sublayer transform at the center of the layer. 830 // Apply the sublayer transform at the center of the layer.
830 if (!layer->sublayerTransform().IsIdentity()) { 831 if (!layer->sublayerTransform().IsIdentity()) {
831 sublayerMatrix.Translate(0.5 * bounds.width(), 0.5 * bounds.height()); 832 sublayerMatrix.Translate(0.5 * bounds.width(), 0.5 * bounds.height());
832 sublayerMatrix.PreconcatTransform(layer->sublayerTransform()); 833 sublayerMatrix.PreconcatTransform(layer->sublayerTransform());
833 sublayerMatrix.Translate(-0.5 * bounds.width(), -0.5 * bounds.height()); 834 sublayerMatrix.Translate(-0.5 * bounds.width(), -0.5 * bounds.height());
834 } 835 }
835 836
836 LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->l ayerList() : layerList); 837 LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->l ayerList() : layerList);
837 838
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 1154
1154 // At this point, we think the point does hit the touch event handler region o n the layer, but we need to walk up 1155 // At this point, we think the point does hit the touch event handler region o n the layer, but we need to walk up
1155 // the parents to ensure that the layer was not clipped in such a way that the 1156 // the parents to ensure that the layer was not clipped in such a way that the
1156 // hit point actually should not hit the layer. 1157 // hit point actually should not hit the layer.
1157 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) 1158 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl))
1158 return false; 1159 return false;
1159 1160
1160 return true; 1161 return true;
1161 } 1162 }
1162 } // namespace cc 1163 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698