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