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

Side by Side Diff: Source/core/paint/DeprecatedPaintLayer.cpp

Issue 1030323005: Simplify application of perspective origin. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: with new TestExpectations Created 5 years, 8 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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 901
902 TransformationMatrix DeprecatedPaintLayer::perspectiveTransform() const 902 TransformationMatrix DeprecatedPaintLayer::perspectiveTransform() const
903 { 903 {
904 if (!layoutObject()->hasTransformRelatedProperty()) 904 if (!layoutObject()->hasTransformRelatedProperty())
905 return TransformationMatrix(); 905 return TransformationMatrix();
906 906
907 const ComputedStyle& style = layoutObject()->styleRef(); 907 const ComputedStyle& style = layoutObject()->styleRef();
908 if (!style.hasPerspective()) 908 if (!style.hasPerspective())
909 return TransformationMatrix(); 909 return TransformationMatrix();
910 910
911 // Maybe fetch the perspective from the backing?
912 const IntRect borderBox = toLayoutBox(layoutObject())->pixelSnappedBorderBox Rect();
913 const float boxWidth = borderBox.width();
914 const float boxHeight = borderBox.height();
915
916 float perspectiveOriginX = floatValueForLength(style.perspectiveOriginX(), b oxWidth);
917 float perspectiveOriginY = floatValueForLength(style.perspectiveOriginY(), b oxHeight);
918
919 // A perspective origin of 0,0 makes the vanishing point in the center of th e element.
920 // We want it to be in the top-left, so subtract half the height and width.
921 perspectiveOriginX -= boxWidth / 2.0f;
922 perspectiveOriginY -= boxHeight / 2.0f;
923
924 TransformationMatrix t; 911 TransformationMatrix t;
925 t.translate(perspectiveOriginX, perspectiveOriginY);
926 t.applyPerspective(style.perspective()); 912 t.applyPerspective(style.perspective());
927 t.translate(-perspectiveOriginX, -perspectiveOriginY);
928
929 return t; 913 return t;
930 } 914 }
931 915
932 FloatPoint DeprecatedPaintLayer::perspectiveOrigin() const 916 FloatPoint DeprecatedPaintLayer::perspectiveOrigin() const
933 { 917 {
934 if (!layoutObject()->hasTransformRelatedProperty()) 918 if (!layoutObject()->hasTransformRelatedProperty())
935 return FloatPoint(); 919 return FloatPoint();
936 920
937 const LayoutRect borderBox = toLayoutBox(layoutObject())->borderBoxRect(); 921 const LayoutRect borderBox = toLayoutBox(layoutObject())->borderBoxRect();
938 const ComputedStyle& style = layoutObject()->styleRef(); 922 const ComputedStyle& style = layoutObject()->styleRef();
(...skipping 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 } 2952 }
2969 } 2953 }
2970 2954
2971 void showLayerTree(const blink::LayoutObject* renderer) 2955 void showLayerTree(const blink::LayoutObject* renderer)
2972 { 2956 {
2973 if (!renderer) 2957 if (!renderer)
2974 return; 2958 return;
2975 showLayerTree(renderer->enclosingLayer()); 2959 showLayerTree(renderer->enclosingLayer());
2976 } 2960 }
2977 #endif 2961 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698