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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
&m_object); | 71 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
&m_object); |
72 | 72 |
73 // When rendering clip paths as masks, only geometric operations should be i
ncluded so skip | 73 // 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. | 74 // non-geometric operations such as compositing, masking, and filtering. |
75 if (paintInfo().isRenderingClipPathAsMaskImage()) { | 75 if (paintInfo().isRenderingClipPathAsMaskImage()) { |
76 if (!applyClipIfNecessary(resources)) | 76 if (!applyClipIfNecessary(resources)) |
77 return false; | 77 return false; |
78 return true; | 78 return true; |
79 } | 79 } |
80 | 80 |
81 applyCompositingIfNecessary(); | 81 bool isSVGRoot = m_object.isSVGRoot(); |
| 82 |
| 83 // Layer takes care of root opacity and blend mode. |
| 84 if (isSVGRoot) { |
| 85 DCHECK(!(m_object.isTransparent() || m_object.styleRef().hasBlendMode())
|| m_object.hasLayer()); |
| 86 } else { |
| 87 applyCompositingIfNecessary(); |
| 88 } |
82 | 89 |
83 if (!applyClipIfNecessary(resources)) | 90 if (!applyClipIfNecessary(resources)) |
84 return false; | 91 return false; |
85 | 92 |
86 if (!applyMaskIfNecessary(resources)) | 93 if (!applyMaskIfNecessary(resources)) |
87 return false; | 94 return false; |
88 | 95 |
89 if (!applyFilterIfNecessary(resources)) | 96 if (isSVGRoot) { |
| 97 DCHECK(!m_object.styleRef().hasFilter() || m_object.hasLayer()); |
| 98 } else if (!applyFilterIfNecessary(resources)) { |
90 return false; | 99 return false; |
| 100 } |
91 | 101 |
92 if (!isIsolationInstalled() && SVGLayoutSupport::isIsolationRequired(&m_obje
ct)) | 102 if (!isIsolationInstalled() && SVGLayoutSupport::isIsolationRequired(&m_obje
ct)) |
93 m_compositingRecorder = wrapUnique(new CompositingRecorder(paintInfo().c
ontext, m_object, SkXfermode::kSrcOver_Mode, 1)); | 103 m_compositingRecorder = wrapUnique(new CompositingRecorder(paintInfo().c
ontext, m_object, SkXfermode::kSrcOver_Mode, 1)); |
94 | 104 |
95 return true; | 105 return true; |
96 } | 106 } |
97 | 107 |
98 void SVGPaintContext::applyCompositingIfNecessary() | 108 void SVGPaintContext::applyCompositingIfNecessary() |
99 { | 109 { |
100 ASSERT(!paintInfo().isRenderingClipPathAsMaskImage()); | 110 ASSERT(!paintInfo().isRenderingClipPathAsMaskImage()); |
101 | 111 |
102 // Layer takes care of root opacity and blend mode. | |
103 if (m_object.isSVGRoot()) | |
104 return; | |
105 | |
106 const ComputedStyle& style = m_object.styleRef(); | 112 const ComputedStyle& style = m_object.styleRef(); |
107 float opacity = style.opacity(); | 113 float opacity = style.opacity(); |
108 WebBlendMode blendMode = style.hasBlendMode() && m_object.isBlendingAllowed(
) ? | 114 WebBlendMode blendMode = style.hasBlendMode() && m_object.isBlendingAllowed(
) ? |
109 style.blendMode() : WebBlendModeNormal; | 115 style.blendMode() : WebBlendModeNormal; |
110 if (opacity < 1 || blendMode != WebBlendModeNormal) { | 116 if (opacity < 1 || blendMode != WebBlendModeNormal) { |
111 const FloatRect compositingBounds = m_object.paintInvalidationRectInLoca
lSVGCoordinates(); | 117 const FloatRect compositingBounds = m_object.paintInvalidationRectInLoca
lSVGCoordinates(); |
112 m_compositingRecorder = wrapUnique(new CompositingRecorder(paintInfo().c
ontext, m_object, | 118 m_compositingRecorder = wrapUnique(new CompositingRecorder(paintInfo().c
ontext, m_object, |
113 WebCoreCompositeToSkiaComposite(CompositeSourceOver, blendMode), opa
city, &compositingBounds)); | 119 WebCoreCompositeToSkiaComposite(CompositeSourceOver, blendMode), opa
city, &compositingBounds)); |
114 } | 120 } |
115 } | 121 } |
(...skipping 25 matching lines...) Expand all Loading... |
141 if (!SVGMaskPainter(*masker).prepareEffect(m_object, paintInfo().context
)) | 147 if (!SVGMaskPainter(*masker).prepareEffect(m_object, paintInfo().context
)) |
142 return false; | 148 return false; |
143 m_masker = masker; | 149 m_masker = masker; |
144 } | 150 } |
145 return true; | 151 return true; |
146 } | 152 } |
147 | 153 |
148 bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources) | 154 bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources) |
149 { | 155 { |
150 if (!resources) { | 156 if (!resources) { |
151 if (m_object.style()->svgStyle().hasFilter()) | 157 if (m_object.style()->hasFilter()) |
152 return false; | 158 return false; |
153 } else if (LayoutSVGResourceFilter* filter = resources->filter()) { | 159 } else if (LayoutSVGResourceFilter* filter = resources->filter()) { |
154 m_filterRecordingContext = wrapUnique(new SVGFilterRecordingContext(pain
tInfo().context)); | 160 m_filterRecordingContext = wrapUnique(new SVGFilterRecordingContext(pain
tInfo().context)); |
155 m_filter = filter; | 161 m_filter = filter; |
156 GraphicsContext* filterContext = SVGFilterPainter(*filter).prepareEffect
(m_object, *m_filterRecordingContext); | 162 GraphicsContext* filterContext = SVGFilterPainter(*filter).prepareEffect
(m_object, *m_filterRecordingContext); |
157 if (!filterContext) | 163 if (!filterContext) |
158 return false; | 164 return false; |
159 | 165 |
160 // Because the filter needs to cache its contents we replace the context | 166 // Because the filter needs to cache its contents we replace the context |
161 // during filtering with the filter's context. | 167 // during filtering with the filter's context. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // though. | 229 // though. |
224 // Additionally, it's not really safe/guaranteed to be correct, as | 230 // Additionally, it's not really safe/guaranteed to be correct, as |
225 // something down the paint pipe may want to farther tweak the color | 231 // something down the paint pipe may want to farther tweak the color |
226 // filter, which could yield incorrect results. (Consider just using | 232 // filter, which could yield incorrect results. (Consider just using |
227 // saveLayer() w/ this color filter explicitly instead.) | 233 // saveLayer() w/ this color filter explicitly instead.) |
228 paint.setColorFilter(sk_ref_sp(paintInfo.context.colorFilter())); | 234 paint.setColorFilter(sk_ref_sp(paintInfo.context.colorFilter())); |
229 return true; | 235 return true; |
230 } | 236 } |
231 | 237 |
232 } // namespace blink | 238 } // namespace blink |
OLD | NEW |