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

Unified Diff: third_party/WebKit/Source/core/paint/SVGRootPainter.cpp

Issue 2128463002: Pixel snap SVG's root border box to local transform [spv2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename to transformToPixelSnappedBorderBox, improve comments 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/SVGRootPainter.h ('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/paint/SVGRootPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/SVGRootPainter.cpp b/third_party/WebKit/Source/core/paint/SVGRootPainter.cpp
index 9436a8d31924bf9055419177eb379c4a27bfb566..14781968a9586066b8e4fc87adf5483ef4b190d7 100644
--- a/third_party/WebKit/Source/core/paint/SVGRootPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/SVGRootPainter.cpp
@@ -18,13 +18,27 @@
namespace blink {
-void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+IntRect SVGRootPainter::pixelSnappedSize(const LayoutPoint& paintOffset) const
+{
+ return pixelSnappedIntRect(paintOffset, m_layoutSVGRoot.size());
+}
+
+AffineTransform SVGRootPainter::transformToPixelSnappedBorderBox(const LayoutPoint& paintOffset) const
{
- // Pixel-snap to match BoxPainter's alignment.
- const IntRect adjustedRect = pixelSnappedIntRect(paintOffset, m_layoutSVGRoot.size());
+ const IntRect snappedSize = pixelSnappedSize(paintOffset);
+ AffineTransform paintOffsetToBorderBox =
+ AffineTransform::translation(snappedSize.x(), snappedSize.y());
+ paintOffsetToBorderBox.scale(
+ snappedSize.width() / m_layoutSVGRoot.size().width().toFloat(),
+ snappedSize.height() / m_layoutSVGRoot.size().height().toFloat());
+ paintOffsetToBorderBox.multiply(m_layoutSVGRoot.localToBorderBoxTransform());
+ return paintOffsetToBorderBox;
+}
+void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
// An empty viewport disables rendering.
- if (adjustedRect.isEmpty())
+ if (pixelSnappedSize(paintOffset).isEmpty())
return;
// SVG outlines are painted during PaintPhaseForeground.
@@ -47,18 +61,9 @@ void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO
clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintInfoBeforeFiltering.displayItemTypeForClipping(), pixelSnappedIntRect(m_layoutSVGRoot.overflowClipRect(paintOffset)));
}
- // Convert from container offsets (html layoutObjects) to a relative transform (svg layoutObjects).
- // Transform from our paint container's coordinate system to our local coords.
- AffineTransform paintOffsetToBorderBox =
- AffineTransform::translation(adjustedRect.x(), adjustedRect.y());
- // Compensate for size snapping.
- paintOffsetToBorderBox.scale(
- adjustedRect.width() / m_layoutSVGRoot.size().width().toFloat(),
- adjustedRect.height() / m_layoutSVGRoot.size().height().toFloat());
- paintOffsetToBorderBox.multiply(m_layoutSVGRoot.localToBorderBoxTransform());
-
- paintInfoBeforeFiltering.updateCullRect(paintOffsetToBorderBox);
- SVGTransformContext transformContext(paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintOffsetToBorderBox);
+ AffineTransform transformToBorderBox = transformToPixelSnappedBorderBox(paintOffset);
+ paintInfoBeforeFiltering.updateCullRect(transformToBorderBox);
+ SVGTransformContext transformContext(paintInfoBeforeFiltering.context, m_layoutSVGRoot, transformToBorderBox);
SVGPaintContext paintContext(m_layoutSVGRoot, paintInfoBeforeFiltering);
if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext.applyClipMaskAndFilterIfNecessary())
« no previous file with comments | « third_party/WebKit/Source/core/paint/SVGRootPainter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698