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

Unified Diff: Source/platform/graphics/GraphicsContext.cpp

Issue 1181963006: Removing unnecessary assert from BitmapImage::draw (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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/media/crbug496605.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/GraphicsContext.cpp
diff --git a/Source/platform/graphics/GraphicsContext.cpp b/Source/platform/graphics/GraphicsContext.cpp
index ce53c4b73bc776681c6627ebb628f3f2006ee3f3..d2f41647533837dbd573d1027bb73a862f346a9a 100644
--- a/Source/platform/graphics/GraphicsContext.cpp
+++ b/Source/platform/graphics/GraphicsContext.cpp
@@ -932,6 +932,20 @@ void GraphicsContext::drawImage(Image* image, const IntRect& r, SkXfermode::Mode
drawImage(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image->size())), op, shouldRespectImageOrientation);
}
+static FloatRect adjustRectForNegativeSize(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;
+}
+
void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const FloatRect& src, SkXfermode::Mode op, RespectImageOrientationEnum shouldRespectImageOrientation)
{
if (contextDisabled() || !image)
@@ -946,7 +960,9 @@ void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float
// regardless of whether content is pixel aligned. Is this correct?
// For now, just preserving legacy behavior.
imagePaint.setAntiAlias(shouldAntialiasImages());
- image->draw(m_canvas, imagePaint, dest, src, shouldRespectImageOrientation, Image::ClampImageToSourceRect);
chrishtr 2015/06/12 16:45:12 Why is the rect of negative width or height? Can i
+ FloatRect normDest = adjustRectForNegativeSize(dest);
+ FloatRect normSrc = adjustRectForNegativeSize(src);
+ image->draw(m_canvas, imagePaint, normDest, normSrc, shouldRespectImageOrientation, Image::ClampImageToSourceRect);
}
SkFilterQuality GraphicsContext::computeFilterQuality(Image* image, const FloatRect& dest, const FloatRect& src) const
« no previous file with comments | « LayoutTests/media/crbug496605.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698