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

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

Issue 1655553002: Update svg's root paint offset property during paint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only update SVG paint offset property Created 4 years, 10 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/virtual/spv2/svg/README.txt ('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/PaintInfo.h" 12 #include "core/paint/PaintInfo.h"
12 #include "core/paint/PaintTiming.h" 13 #include "core/paint/PaintTiming.h"
13 #include "core/paint/SVGPaintContext.h" 14 #include "core/paint/SVGPaintContext.h"
14 #include "core/paint/TransformRecorder.h" 15 #include "core/paint/TransformRecorder.h"
15 #include "core/svg/SVGSVGElement.h" 16 #include "core/svg/SVGSVGElement.h"
16 #include "platform/graphics/paint/ClipRecorder.h" 17 #include "platform/graphics/paint/ClipRecorder.h"
18 #include "platform/graphics/paint/ScopedPaintChunkProperties.h"
17 #include "wtf/Optional.h" 19 #include "wtf/Optional.h"
18 20
19 namespace blink { 21 namespace blink {
20 22
21 void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset) 23 void SVGRootPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintO ffset)
22 { 24 {
23 // An empty viewport disables rendering. 25 // An empty viewport disables rendering.
24 if (m_layoutSVGRoot.pixelSnappedBorderBoxRect().isEmpty()) 26 if (m_layoutSVGRoot.pixelSnappedBorderBoxRect().isEmpty())
25 return; 27 return;
26 28
(...skipping 10 matching lines...) Expand all
37 39
38 // Don't paint if we don't have kids, except if we have filters we should pa int those. 40 // Don't paint if we don't have kids, except if we have filters we should pa int those.
39 if (!m_layoutSVGRoot.firstChild()) { 41 if (!m_layoutSVGRoot.firstChild()) {
40 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj ect(&m_layoutSVGRoot); 42 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj ect(&m_layoutSVGRoot);
41 if (!resources || !resources->filter()) 43 if (!resources || !resources->filter())
42 return; 44 return;
43 } 45 }
44 46
45 PaintInfo paintInfoBeforeFiltering(paintInfo); 47 PaintInfo paintInfoBeforeFiltering(paintInfo);
46 48
49 // At the HTML->SVG boundary, SVGRoot will have a paint offset transform
50 // paint property but may not have a PaintLayer, so we need to update the
51 // paint properties here since they will not be updated by PaintLayer
52 // (See: PaintPropertyTreeBuilder::createPaintOffsetTranslationIfNeeded).
53 Optional<ScopedPaintChunkProperties> paintOffsetTranslationPropertyScope;
54 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && !m_layoutSVGRoot.has Layer()) {
55 const auto* objectProperties = m_layoutSVGRoot.objectPaintProperties();
56 if (objectProperties && objectProperties->paintOffsetTranslation()) {
57 auto& paintController = paintInfoBeforeFiltering.context.paintContro ller();
58 PaintChunkProperties properties(paintController.currentPaintChunkPro perties());
59 properties.transform = objectProperties->paintOffsetTranslation();
60 paintOffsetTranslationPropertyScope.emplace(paintController, propert ies);
61 }
62 }
63
47 // Apply initial viewport clip. 64 // Apply initial viewport clip.
48 Optional<ClipRecorder> clipRecorder; 65 Optional<ClipRecorder> clipRecorder;
49 if (m_layoutSVGRoot.shouldApplyViewportClip()) { 66 if (m_layoutSVGRoot.shouldApplyViewportClip()) {
50 // TODO(pdr): Clip the paint info cull rect here. 67 // TODO(pdr): Clip the paint info cull rect here.
51 clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintInfoBeforeFiltering.displayItemTypeForClipping(), LayoutRect(pixelSnappedIn tRect(m_layoutSVGRoot.overflowClipRect(paintOffset)))); 68 clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGRoot, paintInfoBeforeFiltering.displayItemTypeForClipping(), LayoutRect(pixelSnappedIn tRect(m_layoutSVGRoot.overflowClipRect(paintOffset))));
52 } 69 }
53 70
54 // Convert from container offsets (html layoutObjects) to a relative transfo rm (svg layoutObjects). 71 // Convert from container offsets (html layoutObjects) to a relative transfo rm (svg layoutObjects).
55 // Transform from our paint container's coordinate system to our local coord s. 72 // Transform from our paint container's coordinate system to our local coord s.
56 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset); 73 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset);
57 AffineTransform paintOffsetToBorderBox = AffineTransform::translation(adjust edPaintOffset.x(), adjustedPaintOffset.y()) * m_layoutSVGRoot.localToBorderBoxTr ansform(); 74 AffineTransform paintOffsetToBorderBox = AffineTransform::translation(adjust edPaintOffset.x(), adjustedPaintOffset.y()) * m_layoutSVGRoot.localToBorderBoxTr ansform();
58 paintInfoBeforeFiltering.updateCullRect(paintOffsetToBorderBox); 75 paintInfoBeforeFiltering.updateCullRect(paintOffsetToBorderBox);
59 TransformRecorder transformRecorder(paintInfoBeforeFiltering.context, m_layo utSVGRoot, paintOffsetToBorderBox); 76 TransformRecorder transformRecorder(paintInfoBeforeFiltering.context, m_layo utSVGRoot, paintOffsetToBorderBox);
60 77
61 SVGPaintContext paintContext(m_layoutSVGRoot, paintInfoBeforeFiltering); 78 SVGPaintContext paintContext(m_layoutSVGRoot, paintInfoBeforeFiltering);
62 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext. applyClipMaskAndFilterIfNecessary()) 79 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext. applyClipMaskAndFilterIfNecessary())
63 return; 80 return;
64 81
65 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint()); 82 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint());
66 83
67 PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().t opDocument()); 84 PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().t opDocument());
68 timing.markFirstContentfulPaint(); 85 timing.markFirstContentfulPaint();
69 } 86 }
70 87
71 } // namespace blink 88 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/virtual/spv2/svg/README.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698