| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 bool SVGPaintContext::applyClipMaskAndFilterIfNecessary() | 58 bool SVGPaintContext::applyClipMaskAndFilterIfNecessary() |
| 59 { | 59 { |
| 60 #if ENABLE(ASSERT) | 60 #if ENABLE(ASSERT) |
| 61 ASSERT(!m_applyClipMaskAndFilterIfNecessaryCalled); | 61 ASSERT(!m_applyClipMaskAndFilterIfNecessaryCalled); |
| 62 m_applyClipMaskAndFilterIfNecessaryCalled = true; | 62 m_applyClipMaskAndFilterIfNecessaryCalled = true; |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 // When rendering clip paths as masks, only geometric operations should be i
ncluded so skip | 65 // When rendering clip paths as masks, only geometric operations should be i
ncluded so skip |
| 66 // non-geometric operations such as compositing, masking, and filtering. | 66 // non-geometric operations such as compositing, masking, and filtering. |
| 67 if (paintInfo().isRenderingClipPathAsMaskImage()) { | 67 if (paintInfo().isRenderingClipPathAsMaskImage()) { |
| 68 DCHECK(!m_object.isSVGRoot()); |
| 68 applyClipIfNecessary(); | 69 applyClipIfNecessary(); |
| 69 return true; | 70 return true; |
| 70 } | 71 } |
| 71 | 72 |
| 72 bool isSVGRoot = m_object.isSVGRoot(); | 73 bool isSVGRoot = m_object.isSVGRoot(); |
| 73 | 74 |
| 74 // Layer takes care of root opacity and blend mode. | 75 // Layer takes care of root opacity and blend mode. |
| 75 if (isSVGRoot) { | 76 if (isSVGRoot) { |
| 76 DCHECK(!(m_object.isTransparent() || m_object.styleRef().hasBlendMode())
|| m_object.hasLayer()); | 77 DCHECK(!(m_object.isTransparent() || m_object.styleRef().hasBlendMode())
|| m_object.hasLayer()); |
| 77 } else { | 78 } else { |
| 78 applyCompositingIfNecessary(); | 79 applyCompositingIfNecessary(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 applyClipIfNecessary(); | 82 if (isSVGRoot) { |
| 83 DCHECK(!m_object.styleRef().clipPath() || m_object.hasLayer()); |
| 84 } else { |
| 85 applyClipIfNecessary(); |
| 86 } |
| 82 | 87 |
| 83 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
&m_object); | 88 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
&m_object); |
| 84 | 89 |
| 85 if (!applyMaskIfNecessary(resources)) | 90 if (!applyMaskIfNecessary(resources)) |
| 86 return false; | 91 return false; |
| 87 | 92 |
| 88 if (isSVGRoot) { | 93 if (isSVGRoot) { |
| 89 DCHECK(!m_object.styleRef().hasFilter() || m_object.hasLayer()); | 94 DCHECK(!m_object.styleRef().hasFilter() || m_object.hasLayer()); |
| 90 } else if (!applyFilterIfNecessary(resources)) { | 95 } else if (!applyFilterIfNecessary(resources)) { |
| 91 return false; | 96 return false; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 107 style.blendMode() : WebBlendModeNormal; | 112 style.blendMode() : WebBlendModeNormal; |
| 108 if (opacity < 1 || blendMode != WebBlendModeNormal) { | 113 if (opacity < 1 || blendMode != WebBlendModeNormal) { |
| 109 const FloatRect compositingBounds = m_object.paintInvalidationRectInLoca
lSVGCoordinates(); | 114 const FloatRect compositingBounds = m_object.paintInvalidationRectInLoca
lSVGCoordinates(); |
| 110 m_compositingRecorder = wrapUnique(new CompositingRecorder(paintInfo().c
ontext, m_object, | 115 m_compositingRecorder = wrapUnique(new CompositingRecorder(paintInfo().c
ontext, m_object, |
| 111 WebCoreCompositeToSkiaComposite(CompositeSourceOver, blendMode), opa
city, &compositingBounds)); | 116 WebCoreCompositeToSkiaComposite(CompositeSourceOver, blendMode), opa
city, &compositingBounds)); |
| 112 } | 117 } |
| 113 } | 118 } |
| 114 | 119 |
| 115 void SVGPaintContext::applyClipIfNecessary() | 120 void SVGPaintContext::applyClipIfNecessary() |
| 116 { | 121 { |
| 117 ClipPathOperation* clipPathOperation = m_object.styleRef().svgStyle().clipPa
th(); | 122 ClipPathOperation* clipPathOperation = m_object.styleRef().clipPath(); |
| 118 // If no 'clip-path' is specified, try '-webkit-clip-path'. | |
| 119 if (!clipPathOperation) { | |
| 120 clipPathOperation = m_object.styleRef().clipPath(); | |
| 121 // We don't support URL references in '-webkit-clip-path'. | |
| 122 if (clipPathOperation && clipPathOperation->type() == ClipPathOperation:
:REFERENCE) | |
| 123 clipPathOperation = nullptr; | |
| 124 } | |
| 125 if (!clipPathOperation) | 123 if (!clipPathOperation) |
| 126 return; | 124 return; |
| 127 m_clipPathClipper.emplace(paintInfo().context, *clipPathOperation, m_object,
m_object.objectBoundingBox(), FloatPoint()); | 125 m_clipPathClipper.emplace(paintInfo().context, *clipPathOperation, m_object,
m_object.objectBoundingBox(), FloatPoint()); |
| 128 } | 126 } |
| 129 | 127 |
| 130 bool SVGPaintContext::applyMaskIfNecessary(SVGResources* resources) | 128 bool SVGPaintContext::applyMaskIfNecessary(SVGResources* resources) |
| 131 { | 129 { |
| 132 if (LayoutSVGResourceMasker* masker = resources ? resources->masker() : null
ptr) { | 130 if (LayoutSVGResourceMasker* masker = resources ? resources->masker() : null
ptr) { |
| 133 if (!SVGMaskPainter(*masker).prepareEffect(m_object, paintInfo().context
)) | 131 if (!SVGMaskPainter(*masker).prepareEffect(m_object, paintInfo().context
)) |
| 134 return false; | 132 return false; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // though. | 213 // though. |
| 216 // Additionally, it's not really safe/guaranteed to be correct, as | 214 // Additionally, it's not really safe/guaranteed to be correct, as |
| 217 // something down the paint pipe may want to farther tweak the color | 215 // something down the paint pipe may want to farther tweak the color |
| 218 // filter, which could yield incorrect results. (Consider just using | 216 // filter, which could yield incorrect results. (Consider just using |
| 219 // saveLayer() w/ this color filter explicitly instead.) | 217 // saveLayer() w/ this color filter explicitly instead.) |
| 220 paint.setColorFilter(sk_ref_sp(paintInfo.context.getColorFilter())); | 218 paint.setColorFilter(sk_ref_sp(paintInfo.context.getColorFilter())); |
| 221 return true; | 219 return true; |
| 222 } | 220 } |
| 223 | 221 |
| 224 } // namespace blink | 222 } // namespace blink |
| OLD | NEW |