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

Unified Diff: WebCore/platform/graphics/skia/ImageSkia.cpp

Issue 16437: Allow negative width or height values to be passed into canvas.drawImage... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/WebKit/
Patch Set: Created 12 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: WebCore/platform/graphics/skia/ImageSkia.cpp
===================================================================
--- WebCore/platform/graphics/skia/ImageSkia.cpp (revision 7375)
+++ WebCore/platform/graphics/skia/ImageSkia.cpp (working copy)
@@ -287,6 +287,21 @@
*dest_height = SkScalarToFloat((dest_points[2] - dest_points[0]).length());
}
+// A helper method for translating negative width and height values.
+FloatRect normalizeRect(const FloatRect& rect)
+{
+ FloatRect norm = rect;
+ if (norm.width() < 0) {
+ norm.setX(norm.x() + norm.width());
+ norm.setWidth(-norm.width());
+ }
+ if (norm.height() < 0) {
+ norm.setY(norm.y() + norm.height());
+ norm.setHeight(-norm.height());
+ }
+ return norm;
+}
+
} // namespace
void FrameData::clear()
@@ -424,13 +439,16 @@
if (!bm)
return; // It's too early and we don't have an image yet.
- if (srcRect.isEmpty() || dstRect.isEmpty())
+ FloatRect normDstRect = normalizeRect(dstRect);
+ FloatRect normSrcRect = normalizeRect(srcRect);
+
+ if (normSrcRect.isEmpty() || normDstRect.isEmpty())
return; // Nothing to draw.
paintSkBitmap(ctxt->platformContext(),
*bm,
- enclosingIntRect(srcRect),
- enclosingIntRect(dstRect),
+ enclosingIntRect(normSrcRect),
+ enclosingIntRect(normDstRect),
WebCoreCompositeToSkiaComposite(compositeOp));
}
@@ -439,13 +457,16 @@
const FloatRect& srcRect,
CompositeOperator compositeOp)
{
- if (srcRect.isEmpty() || dstRect.isEmpty())
+ FloatRect normDstRect = normalizeRect(dstRect);
+ FloatRect normSrcRect = normalizeRect(srcRect);
+
+ if (normSrcRect.isEmpty() || normDstRect.isEmpty())
return; // Nothing to draw.
paintSkBitmap(ctxt->platformContext(),
m_nativeImage,
- enclosingIntRect(srcRect),
- enclosingIntRect(dstRect),
+ enclosingIntRect(normSrcRect),
+ enclosingIntRect(normDstRect),
WebCoreCompositeToSkiaComposite(compositeOp));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698