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

Unified Diff: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp

Issue 2157953002: Change filter quality when scaling-down in drawImage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
Index: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
diff --git a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
index a059f7fb086270ce9aae5dc9f28daca4693c67e8..11c20616773421de119a9cd50ecd1d538b14389a 100644
--- a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
+++ b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
@@ -233,7 +233,7 @@ FloatSize SVGImage::concreteObjectSize(const FloatSize& defaultObjectSize) const
}
void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const FloatSize containerSize, float zoom, const FloatRect& dstRect,
- const FloatRect& srcRect, const KURL& url)
+ const FloatRect& srcRect, bool imageSmoothingEnabled, const KURL& url)
{
if (!m_page)
return;
@@ -256,7 +256,11 @@ void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const Fl
adjustedSrcSize.scale(roundedContainerSize.width() / containerSize.width(), roundedContainerSize.height() / containerSize.height());
scaledSrc.setSize(adjustedSrcSize);
- drawInternal(canvas, paint, dstRect, scaledSrc, DoNotRespectImageOrientation, ClampImageToSourceRect, url);
+ SkPaint adjustedPaint = paint;
+ if (!imageSmoothingEnabled && Image::isDrawScalingDown(scaledSrc, dstRect))
+ adjustedPaint.setFilterQuality(kLow_SkFilterQuality);
fs 2016/07/18 15:56:55 This should not have any effect. Ditto below, and
+
+ drawInternal(canvas, adjustedPaint, dstRect, scaledSrc, DoNotRespectImageOrientation, ClampImageToSourceRect, url);
}
PassRefPtr<SkImage> SVGImage::imageForCurrentFrame()
@@ -284,7 +288,7 @@ void SVGImage::drawPatternForContainer(GraphicsContext& context, const FloatSize
if (tile != spacedTile)
patternPicture.context().clip(tile);
SkPaint paint;
- drawForContainer(patternPicture.context().canvas(), paint, containerSize, zoom, tile, srcRect, url);
+ drawForContainer(patternPicture.context().canvas(), paint, containerSize, zoom, tile, srcRect, true, url);
}
RefPtr<SkPicture> tilePicture = patternPicture.endRecording();
@@ -306,7 +310,7 @@ PassRefPtr<SkImage> SVGImage::imageForCurrentFrameForContainer(const KURL& url,
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(width(), height());
- drawForContainer(canvas, SkPaint(), containerSize, 1, rect(), rect(), url);
+ drawForContainer(canvas, SkPaint(), containerSize, 1, rect(), rect(), true, url);
return fromSkSp(SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(),
SkISize::Make(width(), height()), nullptr, nullptr));
@@ -327,12 +331,16 @@ static bool drawNeedsLayer(const SkPaint& paint)
}
void SVGImage::draw(SkCanvas* canvas, const SkPaint& paint, const FloatRect& dstRect, const FloatRect& srcRect,
- RespectImageOrientationEnum shouldRespectImageOrientation, ImageClampingMode clampMode)
+ bool imageSmoothingEnabled, RespectImageOrientationEnum shouldRespectImageOrientation, ImageClampingMode clampMode)
{
if (!m_page)
return;
- drawInternal(canvas, paint, dstRect, srcRect, shouldRespectImageOrientation, clampMode, KURL());
+ SkPaint adjustedPaint = paint;
+ if (!imageSmoothingEnabled && Image::isDrawScalingDown(srcRect, dstRect))
+ adjustedPaint.setFilterQuality(kLow_SkFilterQuality);
+
+ drawInternal(canvas, adjustedPaint, dstRect, srcRect, shouldRespectImageOrientation, clampMode, KURL());
}
void SVGImage::drawInternal(SkCanvas* canvas, const SkPaint& paint, const FloatRect& dstRect, const FloatRect& srcRect,

Powered by Google App Engine
This is Rietveld 408576698