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

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

Issue 2203093003: Fix SVGImage::imageForCurrentFrameForContainer() sizing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated canvas-default-object-sizing ref Created 4 years, 4 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 | « third_party/WebKit/LayoutTests/svg/canvas/canvas-default-object-sizing-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 821e926b920292a78c772e4541580b97678b260e..6e9bfe2e66eab5c8f425dfd53826f6d3eca69897 100644
--- a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
+++ b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
@@ -304,12 +304,18 @@ PassRefPtr<SkImage> SVGImage::imageForCurrentFrameForContainer(const KURL& url,
if (!m_page)
return nullptr;
+ const FloatRect containerRect(FloatPoint(), containerSize);
+
SkPictureRecorder recorder;
- SkCanvas* canvas = recorder.beginRecording(width(), height());
- drawForContainer(canvas, SkPaint(), containerSize, 1, rect(), rect(), url);
+ SkCanvas* canvas = recorder.beginRecording(containerRect);
+ drawForContainer(canvas, SkPaint(), containerSize, 1, containerRect, containerRect, url);
+ const IntSize imageSize = roundedIntSize(containerSize);
+ const SkMatrix residualScale = SkMatrix::MakeScale(
+ static_cast<float>(imageSize.width()) / containerSize.width(),
+ static_cast<float>(imageSize.height()) / containerSize.height());
return fromSkSp(SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(),
- SkISize::Make(width(), height()), nullptr, nullptr));
+ SkISize::Make(imageSize.width(), imageSize.height()), &residualScale, nullptr));
}
static bool drawNeedsLayer(const SkPaint& paint)
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/canvas/canvas-default-object-sizing-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698