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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/SVGRootPainter.h" | 6 #include "core/paint/SVGRootPainter.h" |
7 | 7 |
8 #include "core/paint/BoxPainter.h" | 8 #include "core/paint/BoxPainter.h" |
9 #include "core/paint/TransformRecorder.h" | 9 #include "core/paint/TransformRecorder.h" |
10 #include "core/rendering/PaintInfo.h" | 10 #include "core/rendering/PaintInfo.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 // An empty viewBox also disables rendering. | 30 // An empty viewBox also disables rendering. |
31 // (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute) | 31 // (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute) |
32 SVGSVGElement* svg = toSVGSVGElement(m_renderSVGRoot.node()); | 32 SVGSVGElement* svg = toSVGSVGElement(m_renderSVGRoot.node()); |
33 ASSERT(svg); | 33 ASSERT(svg); |
34 if (svg->hasEmptyViewBox()) | 34 if (svg->hasEmptyViewBox()) |
35 return; | 35 return; |
36 | 36 |
37 // Don't paint if we don't have kids, except if we have filters we should pa
int those. | 37 // Don't paint if we don't have kids, except if we have filters we should pa
int those. |
38 if (!m_renderSVGRoot.firstChild()) { | 38 if (!m_renderSVGRoot.firstChild()) { |
39 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObj
ect(&m_renderSVGRoot); | 39 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj
ect(&m_renderSVGRoot); |
40 if (!resources || !resources->filter()) | 40 if (!resources || !resources->filter()) |
41 return; | 41 return; |
42 } | 42 } |
43 | 43 |
44 PaintInfo paintInfoBeforeFiltering(paintInfo); | 44 PaintInfo paintInfoBeforeFiltering(paintInfo); |
45 | 45 |
46 // Apply initial viewport clip. | 46 // Apply initial viewport clip. |
47 OwnPtr<ClipRecorder> clipRecorder; | 47 OwnPtr<ClipRecorder> clipRecorder; |
48 if (m_renderSVGRoot.shouldApplyViewportClip()) | 48 if (m_renderSVGRoot.shouldApplyViewportClip()) |
49 clipRecorder = adoptPtr(new ClipRecorder(m_renderSVGRoot.displayItemClie
nt(), paintInfoBeforeFiltering.context, paintInfoBeforeFiltering.displayItemType
ForClipping(), pixelSnappedIntRect(m_renderSVGRoot.overflowClipRect(paintOffset)
))); | 49 clipRecorder = adoptPtr(new ClipRecorder(m_renderSVGRoot.displayItemClie
nt(), paintInfoBeforeFiltering.context, paintInfoBeforeFiltering.displayItemType
ForClipping(), pixelSnappedIntRect(m_renderSVGRoot.overflowClipRect(paintOffset)
))); |
50 | 50 |
51 // Convert from container offsets (html renderers) to a relative transform (
svg renderers). | 51 // Convert from container offsets (html renderers) to a relative transform (
svg renderers). |
52 // Transform from our paint container's coordinate system to our local coord
s. | 52 // Transform from our paint container's coordinate system to our local coord
s. |
53 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset); | 53 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset); |
54 TransformRecorder transformRecorder(*paintInfoBeforeFiltering.context, m_ren
derSVGRoot.displayItemClient(), AffineTransform::translation(adjustedPaintOffset
.x(), adjustedPaintOffset.y()) * m_renderSVGRoot.localToBorderBoxTransform()); | 54 TransformRecorder transformRecorder(*paintInfoBeforeFiltering.context, m_ren
derSVGRoot.displayItemClient(), AffineTransform::translation(adjustedPaintOffset
.x(), adjustedPaintOffset.y()) * m_renderSVGRoot.localToBorderBoxTransform()); |
55 | 55 |
56 // SVG doesn't use paintOffset internally but we need to bake it into the pa
int rect. | 56 // SVG doesn't use paintOffset internally but we need to bake it into the pa
int rect. |
57 paintInfoBeforeFiltering.rect.move(-adjustedPaintOffset.x(), -adjustedPaintO
ffset.y()); | 57 paintInfoBeforeFiltering.rect.move(-adjustedPaintOffset.x(), -adjustedPaintO
ffset.y()); |
58 | 58 |
59 SVGRenderingContext renderingContext(m_renderSVGRoot, paintInfoBeforeFilteri
ng); | 59 SVGRenderingContext renderingContext(m_renderSVGRoot, paintInfoBeforeFilteri
ng); |
60 if (renderingContext.paintInfo().phase == PaintPhaseForeground && !rendering
Context.applyClipMaskAndFilterIfNecessary()) | 60 if (renderingContext.paintInfo().phase == PaintPhaseForeground && !rendering
Context.applyClipMaskAndFilterIfNecessary()) |
61 return; | 61 return; |
62 | 62 |
63 BoxPainter(m_renderSVGRoot).paint(renderingContext.paintInfo(), LayoutPoint(
)); | 63 BoxPainter(m_renderSVGRoot).paint(renderingContext.paintInfo(), LayoutPoint(
)); |
64 } | 64 } |
65 | 65 |
66 } // namespace blink | 66 } // namespace blink |
OLD | NEW |