OLD | NEW |
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/SVGLayoutSupport.h" |
9 #include "core/layout/svg/SVGResourcesCache.h" | |
10 #include "core/paint/BoxPainter.h" | 9 #include "core/paint/BoxPainter.h" |
11 #include "core/paint/ObjectPaintProperties.h" | 10 #include "core/paint/ObjectPaintProperties.h" |
12 #include "core/paint/PaintInfo.h" | 11 #include "core/paint/PaintInfo.h" |
13 #include "core/paint/PaintTiming.h" | 12 #include "core/paint/PaintTiming.h" |
14 #include "core/paint/SVGPaintContext.h" | 13 #include "core/paint/SVGPaintContext.h" |
15 #include "core/paint/TransformRecorder.h" | 14 #include "core/paint/TransformRecorder.h" |
16 #include "core/svg/SVGSVGElement.h" | 15 #include "core/svg/SVGSVGElement.h" |
17 #include "platform/graphics/paint/ClipRecorder.h" | 16 #include "platform/graphics/paint/ClipRecorder.h" |
18 #include "platform/graphics/paint/ScopedPaintChunkProperties.h" | 17 #include "platform/graphics/paint/ScopedPaintChunkProperties.h" |
19 #include "wtf/Optional.h" | 18 #include "wtf/Optional.h" |
(...skipping 14 matching lines...) Expand all Loading... |
34 return; | 33 return; |
35 | 34 |
36 // An empty viewBox also disables rendering. | 35 // An empty viewBox also disables rendering. |
37 // (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute) | 36 // (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute) |
38 SVGSVGElement* svg = toSVGSVGElement(m_layoutSVGRoot.node()); | 37 SVGSVGElement* svg = toSVGSVGElement(m_layoutSVGRoot.node()); |
39 ASSERT(svg); | 38 ASSERT(svg); |
40 if (svg->hasEmptyViewBox()) | 39 if (svg->hasEmptyViewBox()) |
41 return; | 40 return; |
42 | 41 |
43 // Don't paint if we don't have kids, except if we have filters we should pa
int those. | 42 // Don't paint if we don't have kids, except if we have filters we should pa
int those. |
44 if (!m_layoutSVGRoot.firstChild()) { | 43 if (!m_layoutSVGRoot.firstChild() && !SVGLayoutSupport::hasFilterResource(m_
layoutSVGRoot)) |
45 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj
ect(&m_layoutSVGRoot); | 44 return; |
46 if (!resources || !resources->filter()) | |
47 return; | |
48 } | |
49 | 45 |
50 PaintInfo paintInfoBeforeFiltering(paintInfo); | 46 PaintInfo paintInfoBeforeFiltering(paintInfo); |
51 | 47 |
52 Optional<ScopedPaintChunkProperties> transformPropertyScope; | 48 Optional<ScopedPaintChunkProperties> transformPropertyScope; |
53 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 49 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
54 const auto* objectProperties = m_layoutSVGRoot.objectPaintProperties(); | 50 const auto* objectProperties = m_layoutSVGRoot.objectPaintProperties(); |
55 if (objectProperties && objectProperties->svgLocalTransform()) { | 51 if (objectProperties && objectProperties->svgLocalTransform()) { |
56 auto& paintController = paintInfoBeforeFiltering.context.getPaintCon
troller(); | 52 auto& paintController = paintInfoBeforeFiltering.context.getPaintCon
troller(); |
57 PaintChunkProperties properties(paintController.currentPaintChunkPro
perties()); | 53 PaintChunkProperties properties(paintController.currentPaintChunkPro
perties()); |
58 properties.transform = objectProperties->svgLocalTransform(); | 54 properties.transform = objectProperties->svgLocalTransform(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext.
applyClipMaskAndFilterIfNecessary()) | 90 if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext.
applyClipMaskAndFilterIfNecessary()) |
95 return; | 91 return; |
96 | 92 |
97 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint()); | 93 BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint()); |
98 | 94 |
99 PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().t
opDocument()); | 95 PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().t
opDocument()); |
100 timing.markFirstContentfulPaint(); | 96 timing.markFirstContentfulPaint(); |
101 } | 97 } |
102 | 98 |
103 } // namespace blink | 99 } // namespace blink |
OLD | NEW |