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

Side by Side Diff: third_party/WebKit/Source/core/paint/SVGRootPainter.cpp

Issue 1847983002: [SVG] Compensate for container size snapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more expectations Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/custom/zoomed-background-alignment-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/SVGRootPainter.h" 5 #include "core/paint/SVGRootPainter.h"
6 6
7 #include "core/layout/svg/LayoutSVGRoot.h" 7 #include "core/layout/svg/LayoutSVGRoot.h"
8 #include "core/layout/svg/SVGResources.h" 8 #include "core/layout/svg/SVGResources.h"
9 #include "core/layout/svg/SVGResourcesCache.h" 9 #include "core/layout/svg/SVGResourcesCache.h"
10 #include "core/paint/BoxPainter.h" 10 #include "core/paint/BoxPainter.h"
11 #include "core/paint/ObjectPaintProperties.h" 11 #include "core/paint/ObjectPaintProperties.h"
12 #include "core/paint/PaintInfo.h" 12 #include "core/paint/PaintInfo.h"
13 #include "core/paint/PaintTiming.h" 13 #include "core/paint/PaintTiming.h"
14 #include "core/paint/SVGPaintContext.h" 14 #include "core/paint/SVGPaintContext.h"
15 #include "core/paint/TransformRecorder.h" 15 #include "core/paint/TransformRecorder.h"
16 #include "core/svg/SVGSVGElement.h" 16 #include "core/svg/SVGSVGElement.h"
17 #include "platform/graphics/paint/ClipRecorder.h" 17 #include "platform/graphics/paint/ClipRecorder.h"
18 #include "platform/graphics/paint/ScopedPaintChunkProperties.h" 18 #include "platform/graphics/paint/ScopedPaintChunkProperties.h"
19 #include "wtf/Optional.h" 19 #include "wtf/Optional.h"
20 20
21 namespace blink { 21 namespace blink {
22 22
23 void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset) 23 void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset)
24 { 24 {
25 // Pixel-snap to match BoxPainter's alignment.
26 const IntRect adjustedRect = pixelSnappedIntRect(paintOffset, m_layoutSVGRoo t.size());
27
25 // An empty viewport disables rendering. 28 // An empty viewport disables rendering.
26 if (m_layoutSVGRoot.pixelSnappedBorderBoxRect().isEmpty()) 29 if (adjustedRect.isEmpty())
27 return; 30 return;
28 31
29 // SVG outlines are painted during PaintPhaseForeground. 32 // SVG outlines are painted during PaintPhaseForeground.
30 if (shouldPaintSelfOutline(paintInfo.phase)) 33 if (shouldPaintSelfOutline(paintInfo.phase))
31 return; 34 return;
32 35
33 // An empty viewBox also disables rendering. 36 // An empty viewBox also disables rendering.
34 // (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute) 37 // (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute)
35 SVGSVGElement* svg = toSVGSVGElement(m_layoutSVGRoot.node()); 38 SVGSVGElement* svg = toSVGSVGElement(m_layoutSVGRoot.node());
36 ASSERT(svg); 39 ASSERT(svg);
(...skipping 26 matching lines...) Expand all
63 66
64 // Apply initial viewport clip. 67 // Apply initial viewport clip.
65 Optional<ClipRecorder> clipRecorder; 68 Optional<ClipRecorder> clipRecorder;
66 if (m_layoutSVGRoot.shouldApplyViewportClip()) { 69 if (m_layoutSVGRoot.shouldApplyViewportClip()) {
67 // TODO(pdr): Clip the paint info cull rect here. 70 // TODO(pdr): Clip the paint info cull rect here.
68 clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintInfoBeforeFiltering.displayItemTypeForClipping(), LayoutRect(pixelSnappedIn tRect(m_layoutSVGRoot.overflowClipRect(paintOffset)))); 71 clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintInfoBeforeFiltering.displayItemTypeForClipping(), LayoutRect(pixelSnappedIn tRect(m_layoutSVGRoot.overflowClipRect(paintOffset))));
69 } 72 }
70 73
71 // Convert from container offsets (html layoutObjects) to a relative transfo rm (svg layoutObjects). 74 // Convert from container offsets (html layoutObjects) to a relative transfo rm (svg layoutObjects).
72 // Transform from our paint container's coordinate system to our local coord s. 75 // Transform from our paint container's coordinate system to our local coord s.
73 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset); 76 AffineTransform paintOffsetToBorderBox =
74 AffineTransform paintOffsetToBorderBox = AffineTransform::translation(adjust edPaintOffset.x(), adjustedPaintOffset.y()) * m_layoutSVGRoot.localToBorderBoxTr ansform(); 77 AffineTransform::translation(adjustedRect.x(), adjustedRect.y());
78 // Compensate for size snapping.
79 paintOffsetToBorderBox.scale(
80 adjustedRect.width() / m_layoutSVGRoot.size().width().toFloat(),
81 adjustedRect.height() / m_layoutSVGRoot.size().height().toFloat());
82 paintOffsetToBorderBox.multiply(m_layoutSVGRoot.localToBorderBoxTransform()) ;
83
75 paintInfoBeforeFiltering.updateCullRect(paintOffsetToBorderBox); 84 paintInfoBeforeFiltering.updateCullRect(paintOffsetToBorderBox);
76 TransformRecorder transformRecorder(paintInfoBeforeFiltering.context, m_layo utSVGRoot, paintOffsetToBorderBox); 85 TransformRecorder transformRecorder(paintInfoBeforeFiltering.context, m_layo utSVGRoot, paintOffsetToBorderBox);
77 86
78 SVGPaintContext paintContext(m_layoutSVGRoot, paintInfoBeforeFiltering); 87 SVGPaintContext paintContext(m_layoutSVGRoot, paintInfoBeforeFiltering);
79 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext. applyClipMaskAndFilterIfNecessary()) 88 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext. applyClipMaskAndFilterIfNecessary())
80 return; 89 return;
81 90
82 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint()); 91 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint());
83 92
84 PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().t opDocument()); 93 PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().t opDocument());
85 timing.markFirstContentfulPaint(); 94 timing.markFirstContentfulPaint();
86 } 95 }
87 96
88 } // namespace blink 97 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/custom/zoomed-background-alignment-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698