| Index: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
|
| diff --git a/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp b/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
|
| index 2029de6d7d7f812aa189ca4529e5031003f1e253..30600821d88783261f8a4bc9f636118276f37c6b 100644
|
| --- a/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
|
| +++ b/third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp
|
| @@ -941,6 +941,12 @@ bool BaseRenderingContext2D::shouldDrawImageAntialiased(const FloatRect& destRec
|
| return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fabs(heightExpansion) < 1;
|
| }
|
|
|
| +static bool isDrawScalingDown(const FloatRect& srcRect, const FloatRect& dstRect, float xScaleSquared, float yScaleSquared)
|
| +{
|
| + return dstRect.width() * dstRect.width() * xScaleSquared < srcRect.width() * srcRect.width()
|
| + && dstRect.height() * dstRect.height() * yScaleSquared < srcRect.height() * srcRect.height();
|
| +}
|
| +
|
| void BaseRenderingContext2D::drawImageInternal(SkCanvas* c, CanvasImageSource* imageSource, Image* image, const FloatRect& srcRect, const FloatRect& dstRect, const SkPaint* paint)
|
| {
|
| trackDrawCall(DrawImage);
|
| @@ -972,6 +978,9 @@ void BaseRenderingContext2D::drawImageInternal(SkCanvas* c, CanvasImageSource* i
|
| imagePaint.setImageFilter(nullptr);
|
| }
|
|
|
| + if (!imageSmoothingEnabled() && isDrawScalingDown(srcRect, dstRect, state().transform().xScaleSquared(), state().transform().yScaleSquared()))
|
| + imagePaint.setFilterQuality(kLow_SkFilterQuality);
|
| +
|
| if (!imageSource->isVideoElement()) {
|
| imagePaint.setAntiAlias(shouldDrawImageAntialiased(dstRect));
|
| image->draw(c, imagePaint, dstRect, srcRect, DoNotRespectImageOrientation, Image::DoNotClampImageToSourceRect);
|
|
|