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

Unified Diff: Source/platform/graphics/skia/NativeImageSkia.cpp

Issue 223673003: Improve computation of ctmScale{X,Y} in NativeImageSkia::drawPattern (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/transforms/mirror-transform-tiled-scaled-background-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/skia/NativeImageSkia.cpp
diff --git a/Source/platform/graphics/skia/NativeImageSkia.cpp b/Source/platform/graphics/skia/NativeImageSkia.cpp
index f7e70af0ad4d05d15b9903954a24f59e89866f85..386c507249f22d6798866fa899be3ec50691a0ac 100644
--- a/Source/platform/graphics/skia/NativeImageSkia.cpp
+++ b/Source/platform/graphics/skia/NativeImageSkia.cpp
@@ -412,6 +412,15 @@ static SkBitmap createBitmapWithSpace(const SkBitmap& bitmap, int spaceWidth, in
return result;
}
+static SkVector computeScaleVector(const SkMatrix& matrix)
+{
+ SkScalar scaleX = matrix.getScaleX();
+ SkScalar scaleY = matrix.getScaleY();
+ SkScalar skewX = matrix.getSkewX();
+ SkScalar skewY = matrix.getSkewY();
+ return SkVector::Make(sqrt(scaleX * scaleX + skewY * skewY), sqrt(scaleY * scaleY + skewX * skewX));
Stephen White 2014/04/03 12:25:04 This looks a lot like AffineTransform::xScale() an
fs 2014/04/03 14:01:31 That was the intention...
+}
+
void NativeImageSkia::drawPattern(
GraphicsContext* context,
const FloatRect& floatSrcRect,
@@ -428,8 +437,9 @@ void NativeImageSkia::drawPattern(
return; // nothing to draw
SkMatrix totalMatrix = context->getTotalMatrix();
- SkScalar ctmScaleX = totalMatrix.getScaleX();
- SkScalar ctmScaleY = totalMatrix.getScaleY();
+ SkVector ctmScale = computeScaleVector(totalMatrix);
Stephen White 2014/04/03 12:25:04 Could this be AffineTransform ctm = context->getC
fs 2014/04/03 14:01:31 ...because I failed to find this one. Changed to u
+ SkScalar ctmScaleX = ctmScale.x();
+ SkScalar ctmScaleY = ctmScale.y();
totalMatrix.preScale(scale.width(), scale.height());
// Figure out what size the bitmap will be in the destination. The
« no previous file with comments | « LayoutTests/fast/transforms/mirror-transform-tiled-scaled-background-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698