Chromium Code Reviews| 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 |