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

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: add three more test expectation changes (added since earlier) 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
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 906
907 TransformationMatrix DeprecatedPaintLayer::perspectiveTransform() const 907 TransformationMatrix DeprecatedPaintLayer::perspectiveTransform() const
908 { 908 {
909 if (!layoutObject()->hasTransformRelatedProperty()) 909 if (!layoutObject()->hasTransformRelatedProperty())
910 return TransformationMatrix(); 910 return TransformationMatrix();
911 911
912 const ComputedStyle& style = layoutObject()->styleRef(); 912 const ComputedStyle& style = layoutObject()->styleRef();
913 if (!style.hasPerspective()) 913 if (!style.hasPerspective())
914 return TransformationMatrix(); 914 return TransformationMatrix();
915 915
916 // Maybe fetch the perspective from the backing?
917 const IntRect borderBox = toLayoutBox(layoutObject())->pixelSnappedBorderBox Rect();
918 const float boxWidth = borderBox.width();
919 const float boxHeight = borderBox.height();
920
921 float perspectiveOriginX = floatValueForLength(style.perspectiveOriginX(), b oxWidth);
922 float perspectiveOriginY = floatValueForLength(style.perspectiveOriginY(), b oxHeight);
923
924 // A perspective origin of 0,0 makes the vanishing point in the center of th e element.
925 // We want it to be in the top-left, so subtract half the height and width.
926 perspectiveOriginX -= boxWidth / 2.0f;
927 perspectiveOriginY -= boxHeight / 2.0f;
928
929 TransformationMatrix t; 916 TransformationMatrix t;
930 t.translate(perspectiveOriginX, perspectiveOriginY);
931 t.applyPerspective(style.perspective()); 917 t.applyPerspective(style.perspective());
932 t.translate(-perspectiveOriginX, -perspectiveOriginY);
933
934 return t; 918 return t;
935 } 919 }
936 920
937 FloatPoint DeprecatedPaintLayer::perspectiveOrigin() const 921 FloatPoint DeprecatedPaintLayer::perspectiveOrigin() const
938 { 922 {
939 if (!layoutObject()->hasTransformRelatedProperty()) 923 if (!layoutObject()->hasTransformRelatedProperty())
940 return FloatPoint(); 924 return FloatPoint();
941 925
942 const LayoutRect borderBox = toLayoutBox(layoutObject())->borderBoxRect(); 926 const LayoutRect borderBox = toLayoutBox(layoutObject())->borderBoxRect();
943 const ComputedStyle& style = layoutObject()->styleRef(); 927 const ComputedStyle& style = layoutObject()->styleRef();
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 } 2963 }
2980 } 2964 }
2981 2965
2982 void showLayerTree(const blink::LayoutObject* renderer) 2966 void showLayerTree(const blink::LayoutObject* renderer)
2983 { 2967 {
2984 if (!renderer) 2968 if (!renderer)
2985 return; 2969 return;
2986 showLayerTree(renderer->enclosingLayer()); 2970 showLayerTree(renderer->enclosingLayer());
2987 } 2971 }
2988 #endif 2972 #endif
OLDNEW
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698