OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> |
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2009 Google, Inc. All rights reserved. | 5 * Copyright (C) 2009 Google, Inc. All rights reserved. |
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 // Reset the paint info after the filter effect has been completed. | 47 // Reset the paint info after the filter effect has been completed. |
48 m_filterPaintInfo = nullptr; | 48 m_filterPaintInfo = nullptr; |
49 } | 49 } |
50 | 50 |
51 if (m_masker) { | 51 if (m_masker) { |
52 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(&m_object)); | 52 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(&m_object)); |
53 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(&m_object)->mas
ker() == m_masker); | 53 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(&m_object)->mas
ker() == m_masker); |
54 SVGMaskPainter(*m_masker).finishEffect(m_object, paintInfo().context); | 54 SVGMaskPainter(*m_masker).finishEffect(m_object, paintInfo().context); |
55 } | 55 } |
56 | |
57 if (m_clipper) { | |
58 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(&m_object)); | |
59 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(&m_object)->cli
pper() == m_clipper); | |
60 SVGClipPainter(*m_clipper).finishEffect(m_object, paintInfo().context, m
_clipperState); | |
61 } | |
62 } | 56 } |
63 | 57 |
64 bool SVGPaintContext::applyClipMaskAndFilterIfNecessary() | 58 bool SVGPaintContext::applyClipMaskAndFilterIfNecessary() |
65 { | 59 { |
66 #if ENABLE(ASSERT) | 60 #if ENABLE(ASSERT) |
67 ASSERT(!m_applyClipMaskAndFilterIfNecessaryCalled); | 61 ASSERT(!m_applyClipMaskAndFilterIfNecessaryCalled); |
68 m_applyClipMaskAndFilterIfNecessaryCalled = true; | 62 m_applyClipMaskAndFilterIfNecessaryCalled = true; |
69 #endif | 63 #endif |
70 | 64 |
71 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
&m_object); | 65 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
&m_object); |
72 | 66 |
73 // When rendering clip paths as masks, only geometric operations should be i
ncluded so skip | 67 // When rendering clip paths as masks, only geometric operations should be i
ncluded so skip |
74 // non-geometric operations such as compositing, masking, and filtering. | 68 // non-geometric operations such as compositing, masking, and filtering. |
75 if (paintInfo().isRenderingClipPathAsMaskImage()) { | 69 if (paintInfo().isRenderingClipPathAsMaskImage()) { |
76 if (!applyClipIfNecessary(resources)) | 70 DCHECK(!m_object.isSVGRoot()); |
77 return false; | 71 applyClipIfNecessary(resources); |
78 return true; | 72 return true; |
79 } | 73 } |
80 | 74 |
81 bool isSVGRoot = m_object.isSVGRoot(); | 75 bool isSVGRoot = m_object.isSVGRoot(); |
82 | 76 |
83 // Layer takes care of root opacity and blend mode. | 77 // Layer takes care of root opacity and blend mode. |
84 if (isSVGRoot) { | 78 if (isSVGRoot) { |
85 DCHECK(!(m_object.isTransparent() || m_object.styleRef().hasBlendMode())
|| m_object.hasLayer()); | 79 DCHECK(!(m_object.isTransparent() || m_object.styleRef().hasBlendMode())
|| m_object.hasLayer()); |
86 } else { | 80 } else { |
87 applyCompositingIfNecessary(); | 81 applyCompositingIfNecessary(); |
88 } | 82 } |
89 | 83 |
90 if (!applyClipIfNecessary(resources)) | 84 if (isSVGRoot) { |
91 return false; | 85 DCHECK(!m_object.styleRef().clipPath() || m_object.hasLayer()); |
| 86 } else { |
| 87 applyClipIfNecessary(resources); |
| 88 } |
92 | 89 |
93 if (!applyMaskIfNecessary(resources)) | 90 if (!applyMaskIfNecessary(resources)) |
94 return false; | 91 return false; |
95 | 92 |
96 if (isSVGRoot) { | 93 if (isSVGRoot) { |
97 DCHECK(!m_object.styleRef().hasFilter() || m_object.hasLayer()); | 94 DCHECK(!m_object.styleRef().hasFilter() || m_object.hasLayer()); |
98 } else if (!applyFilterIfNecessary(resources)) { | 95 } else if (!applyFilterIfNecessary(resources)) { |
99 return false; | 96 return false; |
100 } | 97 } |
101 | 98 |
(...skipping 11 matching lines...) Expand all Loading... |
113 float opacity = style.opacity(); | 110 float opacity = style.opacity(); |
114 WebBlendMode blendMode = style.hasBlendMode() && m_object.isBlendingAllowed(
) ? | 111 WebBlendMode blendMode = style.hasBlendMode() && m_object.isBlendingAllowed(
) ? |
115 style.blendMode() : WebBlendModeNormal; | 112 style.blendMode() : WebBlendModeNormal; |
116 if (opacity < 1 || blendMode != WebBlendModeNormal) { | 113 if (opacity < 1 || blendMode != WebBlendModeNormal) { |
117 const FloatRect compositingBounds = m_object.paintInvalidationRectInLoca
lSVGCoordinates(); | 114 const FloatRect compositingBounds = m_object.paintInvalidationRectInLoca
lSVGCoordinates(); |
118 m_compositingRecorder = wrapUnique(new CompositingRecorder(paintInfo().c
ontext, m_object, | 115 m_compositingRecorder = wrapUnique(new CompositingRecorder(paintInfo().c
ontext, m_object, |
119 WebCoreCompositeToSkiaComposite(CompositeSourceOver, blendMode), opa
city, &compositingBounds)); | 116 WebCoreCompositeToSkiaComposite(CompositeSourceOver, blendMode), opa
city, &compositingBounds)); |
120 } | 117 } |
121 } | 118 } |
122 | 119 |
123 bool SVGPaintContext::applyClipIfNecessary(SVGResources* resources) | 120 void SVGPaintContext::applyClipIfNecessary(SVGResources* resources) |
124 { | 121 { |
125 // resources->clipper() corresponds to the non-prefixed 'clip-path' whereas | 122 if (!m_object.styleRef().clipPath()) |
126 // m_object.style()->clipPath() corresponds to '-webkit-clip-path'. | 123 return; |
127 // FIXME: We should unify the clip-path and -webkit-clip-path codepaths. | 124 m_clipPathClipper.emplace(paintInfo().context, m_object, m_object.objectBoun
dingBox(), FloatPoint()); |
128 if (LayoutSVGResourceClipper* clipper = resources ? resources->clipper() : n
ullptr) { | |
129 if (!SVGClipPainter(*clipper).prepareEffect(m_object, m_object.objectBou
ndingBox(), | |
130 m_object.paintInvalidationRectInLocalSVGCoordinates(), FloatPoint(),
paintInfo().context, m_clipperState)) | |
131 return false; | |
132 m_clipper = clipper; | |
133 } else { | |
134 ClipPathOperation* clipPathOperation = m_object.style()->clipPath(); | |
135 if (clipPathOperation && clipPathOperation->type() == ClipPathOperation:
:SHAPE) { | |
136 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(clipPath
Operation); | |
137 if (!clipPath->isValid()) | |
138 return false; | |
139 m_clipPathRecorder = wrapUnique(new ClipPathRecorder(paintInfo().con
text, m_object, clipPath->path(m_object.objectBoundingBox()))); | |
140 } | |
141 } | |
142 return true; | |
143 } | 125 } |
144 | 126 |
145 bool SVGPaintContext::applyMaskIfNecessary(SVGResources* resources) | 127 bool SVGPaintContext::applyMaskIfNecessary(SVGResources* resources) |
146 { | 128 { |
147 if (LayoutSVGResourceMasker* masker = resources ? resources->masker() : null
ptr) { | 129 if (LayoutSVGResourceMasker* masker = resources ? resources->masker() : null
ptr) { |
148 if (!SVGMaskPainter(*masker).prepareEffect(m_object, paintInfo().context
)) | 130 if (!SVGMaskPainter(*masker).prepareEffect(m_object, paintInfo().context
)) |
149 return false; | 131 return false; |
150 m_masker = masker; | 132 m_masker = masker; |
151 } | 133 } |
152 return true; | 134 return true; |
(...skipping 22 matching lines...) Expand all Loading... |
175 } | 157 } |
176 return true; | 158 return true; |
177 } | 159 } |
178 | 160 |
179 bool SVGPaintContext::isIsolationInstalled() const | 161 bool SVGPaintContext::isIsolationInstalled() const |
180 { | 162 { |
181 if (m_compositingRecorder) | 163 if (m_compositingRecorder) |
182 return true; | 164 return true; |
183 if (m_masker || m_filter) | 165 if (m_masker || m_filter) |
184 return true; | 166 return true; |
185 if (m_clipper && m_clipperState == SVGClipPainter::ClipperAppliedMask) | 167 if (m_clipPathClipper && m_clipPathClipper->usingMask()) |
186 return true; | 168 return true; |
187 return false; | 169 return false; |
188 } | 170 } |
189 | 171 |
190 void SVGPaintContext::paintSubtree(GraphicsContext& context, const LayoutObject*
item) | 172 void SVGPaintContext::paintSubtree(GraphicsContext& context, const LayoutObject*
item) |
191 { | 173 { |
192 ASSERT(item); | 174 ASSERT(item); |
193 ASSERT(!item->needsLayout()); | 175 ASSERT(!item->needsLayout()); |
194 | 176 |
195 PaintInfo info(context, LayoutRect::infiniteIntRect(), PaintPhaseForeground,
GlobalPaintNormalPhase, PaintLayerNoFlag); | 177 PaintInfo info(context, LayoutRect::infiniteIntRect(), PaintPhaseForeground,
GlobalPaintNormalPhase, PaintLayerNoFlag); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // though. | 212 // though. |
231 // Additionally, it's not really safe/guaranteed to be correct, as | 213 // Additionally, it's not really safe/guaranteed to be correct, as |
232 // something down the paint pipe may want to farther tweak the color | 214 // something down the paint pipe may want to farther tweak the color |
233 // filter, which could yield incorrect results. (Consider just using | 215 // filter, which could yield incorrect results. (Consider just using |
234 // saveLayer() w/ this color filter explicitly instead.) | 216 // saveLayer() w/ this color filter explicitly instead.) |
235 paint.setColorFilter(sk_ref_sp(paintInfo.context.getColorFilter())); | 217 paint.setColorFilter(sk_ref_sp(paintInfo.context.getColorFilter())); |
236 return true; | 218 return true; |
237 } | 219 } |
238 | 220 |
239 } // namespace blink | 221 } // namespace blink |
OLD | NEW |