OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #include "config.h" | 21 #include "config.h" |
22 | 22 |
23 #include "core/svg/SVGFEBlendElement.h" | 23 #include "core/svg/SVGFEBlendElement.h" |
24 | 24 |
25 #include "core/SVGNames.h" | 25 #include "core/SVGNames.h" |
| 26 #include "platform/graphics/filters/FEBlend.h" |
26 #include "platform/graphics/filters/FilterEffect.h" | 27 #include "platform/graphics/filters/FilterEffect.h" |
27 #include "core/svg/graphics/filters/SVGFilterBuilder.h" | 28 #include "core/svg/graphics/filters/SVGFilterBuilder.h" |
28 | 29 |
29 namespace blink { | 30 namespace blink { |
30 | 31 |
31 template<> const SVGEnumerationStringEntries& getStaticStringEntries<BlendModeTy
pe>() | 32 static WebBlendMode toWebBlendMode(SVGFEBlendElement::Mode mode) |
| 33 { |
| 34 switch (mode) { |
| 35 case SVGFEBlendElement::ModeNormal: |
| 36 return WebBlendModeNormal; |
| 37 case SVGFEBlendElement::ModeMultiply: |
| 38 return WebBlendModeMultiply; |
| 39 case SVGFEBlendElement::ModeScreen: |
| 40 return WebBlendModeScreen; |
| 41 case SVGFEBlendElement::ModeDarken: |
| 42 return WebBlendModeDarken; |
| 43 case SVGFEBlendElement::ModeLighten: |
| 44 return WebBlendModeLighten; |
| 45 default: |
| 46 ASSERT_NOT_REACHED(); |
| 47 return WebBlendModeNormal; |
| 48 } |
| 49 } |
| 50 |
| 51 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGFEBlendE
lement::Mode>() |
32 { | 52 { |
33 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); | 53 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); |
34 if (entries.isEmpty()) { | 54 if (entries.isEmpty()) { |
35 entries.append(std::make_pair(FEBLEND_MODE_NORMAL, "normal")); | 55 entries.append(std::make_pair(SVGFEBlendElement::ModeNormal, "normal")); |
36 entries.append(std::make_pair(FEBLEND_MODE_MULTIPLY, "multiply")); | 56 entries.append(std::make_pair(SVGFEBlendElement::ModeMultiply, "multiply
")); |
37 entries.append(std::make_pair(FEBLEND_MODE_SCREEN, "screen")); | 57 entries.append(std::make_pair(SVGFEBlendElement::ModeScreen, "screen")); |
38 entries.append(std::make_pair(FEBLEND_MODE_DARKEN, "darken")); | 58 entries.append(std::make_pair(SVGFEBlendElement::ModeDarken, "darken")); |
39 entries.append(std::make_pair(FEBLEND_MODE_LIGHTEN, "lighten")); | 59 entries.append(std::make_pair(SVGFEBlendElement::ModeLighten, "lighten")
); |
40 } | 60 } |
41 return entries; | 61 return entries; |
42 } | 62 } |
43 | 63 |
44 inline SVGFEBlendElement::SVGFEBlendElement(Document& document) | 64 inline SVGFEBlendElement::SVGFEBlendElement(Document& document) |
45 : SVGFilterPrimitiveStandardAttributes(SVGNames::feBlendTag, document) | 65 : SVGFilterPrimitiveStandardAttributes(SVGNames::feBlendTag, document) |
46 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) | 66 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) |
47 , m_in2(SVGAnimatedString::create(this, SVGNames::in2Attr, SVGString::create
())) | 67 , m_in2(SVGAnimatedString::create(this, SVGNames::in2Attr, SVGString::create
())) |
48 , m_mode(SVGAnimatedEnumeration<BlendModeType>::create(this, SVGNames::modeA
ttr, FEBLEND_MODE_NORMAL)) | 68 , m_mode(SVGAnimatedEnumeration<Mode>::create(this, SVGNames::modeAttr, SVGF
EBlendElement::ModeNormal)) |
49 { | 69 { |
50 ScriptWrappable::init(this); | 70 ScriptWrappable::init(this); |
51 addToPropertyMap(m_in1); | 71 addToPropertyMap(m_in1); |
52 addToPropertyMap(m_in2); | 72 addToPropertyMap(m_in2); |
53 addToPropertyMap(m_mode); | 73 addToPropertyMap(m_mode); |
54 } | 74 } |
55 | 75 |
56 DEFINE_NODE_FACTORY(SVGFEBlendElement) | 76 DEFINE_NODE_FACTORY(SVGFEBlendElement) |
57 | 77 |
58 bool SVGFEBlendElement::isSupportedAttribute(const QualifiedName& attrName) | 78 bool SVGFEBlendElement::isSupportedAttribute(const QualifiedName& attrName) |
(...skipping 25 matching lines...) Expand all Loading... |
84 else | 104 else |
85 ASSERT_NOT_REACHED(); | 105 ASSERT_NOT_REACHED(); |
86 | 106 |
87 reportAttributeParsingError(parseError, name, value); | 107 reportAttributeParsingError(parseError, name, value); |
88 } | 108 } |
89 | 109 |
90 bool SVGFEBlendElement::setFilterEffectAttribute(FilterEffect* effect, const Qua
lifiedName& attrName) | 110 bool SVGFEBlendElement::setFilterEffectAttribute(FilterEffect* effect, const Qua
lifiedName& attrName) |
91 { | 111 { |
92 FEBlend* blend = static_cast<FEBlend*>(effect); | 112 FEBlend* blend = static_cast<FEBlend*>(effect); |
93 if (attrName == SVGNames::modeAttr) | 113 if (attrName == SVGNames::modeAttr) |
94 return blend->setBlendMode(m_mode->currentValue()->enumValue()); | 114 return blend->setBlendMode(toWebBlendMode(m_mode->currentValue()->enumVa
lue())); |
95 | 115 |
96 ASSERT_NOT_REACHED(); | 116 ASSERT_NOT_REACHED(); |
97 return false; | 117 return false; |
98 } | 118 } |
99 | 119 |
100 void SVGFEBlendElement::svgAttributeChanged(const QualifiedName& attrName) | 120 void SVGFEBlendElement::svgAttributeChanged(const QualifiedName& attrName) |
101 { | 121 { |
102 if (!isSupportedAttribute(attrName)) { | 122 if (!isSupportedAttribute(attrName)) { |
103 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); | 123 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); |
104 return; | 124 return; |
(...skipping 15 matching lines...) Expand all Loading... |
120 } | 140 } |
121 | 141 |
122 PassRefPtr<FilterEffect> SVGFEBlendElement::build(SVGFilterBuilder* filterBuilde
r, Filter* filter) | 142 PassRefPtr<FilterEffect> SVGFEBlendElement::build(SVGFilterBuilder* filterBuilde
r, Filter* filter) |
123 { | 143 { |
124 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); | 144 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); |
125 FilterEffect* input2 = filterBuilder->getEffectById(AtomicString(m_in2->curr
entValue()->value())); | 145 FilterEffect* input2 = filterBuilder->getEffectById(AtomicString(m_in2->curr
entValue()->value())); |
126 | 146 |
127 if (!input1 || !input2) | 147 if (!input1 || !input2) |
128 return nullptr; | 148 return nullptr; |
129 | 149 |
130 RefPtr<FilterEffect> effect = FEBlend::create(filter, m_mode->currentValue()
->enumValue()); | 150 RefPtr<FilterEffect> effect = FEBlend::create(filter, toWebBlendMode(m_mode-
>currentValue()->enumValue())); |
131 FilterEffectVector& inputEffects = effect->inputEffects(); | 151 FilterEffectVector& inputEffects = effect->inputEffects(); |
132 inputEffects.reserveCapacity(2); | 152 inputEffects.reserveCapacity(2); |
133 inputEffects.append(input1); | 153 inputEffects.append(input1); |
134 inputEffects.append(input2); | 154 inputEffects.append(input2); |
135 return effect.release(); | 155 return effect.release(); |
136 } | 156 } |
137 | 157 |
138 } | 158 } |
OLD | NEW |