OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 26 matching lines...) Expand all Loading... |
37 { | 37 { |
38 m_effectReferences.add(effect, FilterEffectSet()); | 38 m_effectReferences.add(effect, FilterEffectSet()); |
39 } | 39 } |
40 | 40 |
41 void SVGFilterGraphNodeMap::addPrimitive(LayoutObject* object, PassRefPtrWillBeR
awPtr<FilterEffect> prpEffect) | 41 void SVGFilterGraphNodeMap::addPrimitive(LayoutObject* object, PassRefPtrWillBeR
awPtr<FilterEffect> prpEffect) |
42 { | 42 { |
43 RefPtrWillBeRawPtr<FilterEffect> effect = prpEffect; | 43 RefPtrWillBeRawPtr<FilterEffect> effect = prpEffect; |
44 | 44 |
45 // The effect must be a newly created filter effect. | 45 // The effect must be a newly created filter effect. |
46 ASSERT(!m_effectReferences.contains(effect)); | 46 ASSERT(!m_effectReferences.contains(effect)); |
47 ASSERT(object && !m_effectRenderer.contains(object)); | 47 ASSERT(!object || !m_effectRenderer.contains(object)); |
48 m_effectReferences.add(effect, FilterEffectSet()); | 48 m_effectReferences.add(effect, FilterEffectSet()); |
49 | 49 |
50 unsigned numberOfInputEffects = effect->inputEffects().size(); | 50 unsigned numberOfInputEffects = effect->inputEffects().size(); |
51 | 51 |
52 // Add references from the inputs of this effect to the effect itself, to | 52 // Add references from the inputs of this effect to the effect itself, to |
53 // allow determining what effects needs to be invalidated when a certain | 53 // allow determining what effects needs to be invalidated when a certain |
54 // effect changes. | 54 // effect changes. |
55 for (unsigned i = 0; i < numberOfInputEffects; ++i) | 55 for (unsigned i = 0; i < numberOfInputEffects; ++i) |
56 effectReferences(effect->inputEffect(i)).add(effect.get()); | 56 effectReferences(effect->inputEffect(i)).add(effect.get()); |
57 | 57 |
58 m_effectRenderer.add(object, effect.get()); | 58 // If object is null, that means the element isn't attached for some |
| 59 // reason, which in turn mean that certain types of invalidation will not |
| 60 // work (the LayoutObject -> FilterEffect mapping will not be defined). |
| 61 if (object) |
| 62 m_effectRenderer.add(object, effect.get()); |
59 } | 63 } |
60 | 64 |
61 void SVGFilterGraphNodeMap::invalidateDependentEffects(FilterEffect* effect) | 65 void SVGFilterGraphNodeMap::invalidateDependentEffects(FilterEffect* effect) |
62 { | 66 { |
63 if (!effect->hasImageFilter()) | 67 if (!effect->hasImageFilter()) |
64 return; | 68 return; |
65 | 69 |
66 effect->clearResult(); | 70 effect->clearResult(); |
67 | 71 |
68 FilterEffectSet& effectReferences = this->effectReferences(effect); | 72 FilterEffectSet& effectReferences = this->effectReferences(effect); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 127 |
124 for (SVGElement* element = Traversal<SVGElement>::firstChild(filterElement);
element; element = Traversal<SVGElement>::nextSibling(*element)) { | 128 for (SVGElement* element = Traversal<SVGElement>::firstChild(filterElement);
element; element = Traversal<SVGElement>::nextSibling(*element)) { |
125 if (!element->isFilterEffect()) | 129 if (!element->isFilterEffect()) |
126 continue; | 130 continue; |
127 | 131 |
128 SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFil
terPrimitiveStandardAttributes*>(element); | 132 SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFil
terPrimitiveStandardAttributes*>(element); |
129 RefPtrWillBeRawPtr<FilterEffect> effect = effectElement->build(this, fil
ter); | 133 RefPtrWillBeRawPtr<FilterEffect> effect = effectElement->build(this, fil
ter); |
130 if (!effect) | 134 if (!effect) |
131 continue; | 135 continue; |
132 | 136 |
133 if (m_nodeMap && effectElement->layoutObject()) | 137 if (m_nodeMap) |
134 m_nodeMap->addPrimitive(effectElement->layoutObject(), effect); | 138 m_nodeMap->addPrimitive(effectElement->layoutObject(), effect); |
| 139 |
135 effectElement->setStandardAttributes(effect.get()); | 140 effectElement->setStandardAttributes(effect.get()); |
136 effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilter
PrimitiveStandardAttributes>(effectElement, filterElement.primitiveUnits()->curr
entValue()->enumValue(), referenceBox)); | 141 effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilter
PrimitiveStandardAttributes>(effectElement, filterElement.primitiveUnits()->curr
entValue()->enumValue(), referenceBox)); |
137 EColorInterpolation colorInterpolation = colorInterpolationForElement(*e
ffectElement, filterColorInterpolation); | 142 EColorInterpolation colorInterpolation = colorInterpolationForElement(*e
ffectElement, filterColorInterpolation); |
138 effect->setOperatingColorSpace(colorInterpolation == CI_LINEARRGB ? Colo
rSpaceLinearRGB : ColorSpaceDeviceRGB); | 143 effect->setOperatingColorSpace(colorInterpolation == CI_LINEARRGB ? Colo
rSpaceLinearRGB : ColorSpaceDeviceRGB); |
139 | 144 |
140 add(AtomicString(effectElement->result()->currentValue()->value()), effe
ct); | 145 add(AtomicString(effectElement->result()->currentValue()->value()), effe
ct); |
141 } | 146 } |
142 } | 147 } |
143 | 148 |
144 void SVGFilterBuilder::add(const AtomicString& id, PassRefPtrWillBeRawPtr<Filter
Effect> effect) | 149 void SVGFilterBuilder::add(const AtomicString& id, PassRefPtrWillBeRawPtr<Filter
Effect> effect) |
(...skipping 20 matching lines...) Expand all Loading... |
165 return namedEffect; | 170 return namedEffect; |
166 } | 171 } |
167 | 172 |
168 if (m_lastEffect) | 173 if (m_lastEffect) |
169 return m_lastEffect.get(); | 174 return m_lastEffect.get(); |
170 | 175 |
171 return m_builtinEffects.get(SourceGraphic::effectName()); | 176 return m_builtinEffects.get(SourceGraphic::effectName()); |
172 } | 177 } |
173 | 178 |
174 } // namespace blink | 179 } // namespace blink |
OLD | NEW |