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, |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 #include "core/SVGNames.h" | 25 #include "core/SVGNames.h" |
26 #include "platform/graphics/filters/FEBlend.h" | 26 #include "platform/graphics/filters/FEBlend.h" |
27 #include "platform/graphics/filters/FilterEffect.h" | 27 #include "platform/graphics/filters/FilterEffect.h" |
28 #include "core/svg/graphics/filters/SVGFilterBuilder.h" | 28 #include "core/svg/graphics/filters/SVGFilterBuilder.h" |
29 | 29 |
30 namespace blink { | 30 namespace blink { |
31 | 31 |
32 static WebBlendMode toWebBlendMode(SVGFEBlendElement::Mode mode) | 32 static WebBlendMode toWebBlendMode(SVGFEBlendElement::Mode mode) |
33 { | 33 { |
| 34 #define MAP_BLEND_MODE(MODENAME) \ |
| 35 case SVGFEBlendElement::Mode##MODENAME: \ |
| 36 return WebBlendMode##MODENAME |
| 37 |
34 switch (mode) { | 38 switch (mode) { |
35 case SVGFEBlendElement::ModeNormal: | 39 MAP_BLEND_MODE(Normal); |
36 return WebBlendModeNormal; | 40 MAP_BLEND_MODE(Multiply); |
37 case SVGFEBlendElement::ModeMultiply: | 41 MAP_BLEND_MODE(Screen); |
38 return WebBlendModeMultiply; | 42 MAP_BLEND_MODE(Darken); |
39 case SVGFEBlendElement::ModeScreen: | 43 MAP_BLEND_MODE(Lighten); |
40 return WebBlendModeScreen; | 44 MAP_BLEND_MODE(Overlay); |
41 case SVGFEBlendElement::ModeDarken: | 45 MAP_BLEND_MODE(ColorDodge); |
42 return WebBlendModeDarken; | 46 MAP_BLEND_MODE(ColorBurn); |
43 case SVGFEBlendElement::ModeLighten: | 47 MAP_BLEND_MODE(HardLight); |
44 return WebBlendModeLighten; | 48 MAP_BLEND_MODE(SoftLight); |
| 49 MAP_BLEND_MODE(Difference); |
| 50 MAP_BLEND_MODE(Exclusion); |
| 51 MAP_BLEND_MODE(Hue); |
| 52 MAP_BLEND_MODE(Saturation); |
| 53 MAP_BLEND_MODE(Color); |
| 54 MAP_BLEND_MODE(Luminosity); |
45 default: | 55 default: |
46 ASSERT_NOT_REACHED(); | 56 ASSERT_NOT_REACHED(); |
47 return WebBlendModeNormal; | 57 return WebBlendModeNormal; |
48 } | 58 } |
| 59 #undef MAP_BLEND_MODE |
49 } | 60 } |
50 | 61 |
51 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGFEBlendE
lement::Mode>() | 62 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGFEBlendE
lement::Mode>() |
52 { | 63 { |
53 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); | 64 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); |
54 if (entries.isEmpty()) { | 65 if (entries.isEmpty()) { |
55 entries.append(std::make_pair(SVGFEBlendElement::ModeNormal, "normal")); | 66 entries.append(std::make_pair(SVGFEBlendElement::ModeNormal, "normal")); |
56 entries.append(std::make_pair(SVGFEBlendElement::ModeMultiply, "multiply
")); | 67 entries.append(std::make_pair(SVGFEBlendElement::ModeMultiply, "multiply
")); |
57 entries.append(std::make_pair(SVGFEBlendElement::ModeScreen, "screen")); | 68 entries.append(std::make_pair(SVGFEBlendElement::ModeScreen, "screen")); |
58 entries.append(std::make_pair(SVGFEBlendElement::ModeDarken, "darken")); | 69 entries.append(std::make_pair(SVGFEBlendElement::ModeDarken, "darken")); |
59 entries.append(std::make_pair(SVGFEBlendElement::ModeLighten, "lighten")
); | 70 entries.append(std::make_pair(SVGFEBlendElement::ModeLighten, "lighten")
); |
| 71 entries.append(std::make_pair(SVGFEBlendElement::ModeOverlay, "overlay")
); |
| 72 entries.append(std::make_pair(SVGFEBlendElement::ModeColorDodge, "color-
dodge")); |
| 73 entries.append(std::make_pair(SVGFEBlendElement::ModeColorBurn, "color-b
urn")); |
| 74 entries.append(std::make_pair(SVGFEBlendElement::ModeHardLight, "hard-li
ght")); |
| 75 entries.append(std::make_pair(SVGFEBlendElement::ModeSoftLight, "soft-li
ght")); |
| 76 entries.append(std::make_pair(SVGFEBlendElement::ModeDifference, "differ
ence")); |
| 77 entries.append(std::make_pair(SVGFEBlendElement::ModeExclusion, "exclusi
on")); |
| 78 entries.append(std::make_pair(SVGFEBlendElement::ModeHue, "hue")); |
| 79 entries.append(std::make_pair(SVGFEBlendElement::ModeSaturation, "satura
tion")); |
| 80 entries.append(std::make_pair(SVGFEBlendElement::ModeColor, "color")); |
| 81 entries.append(std::make_pair(SVGFEBlendElement::ModeLuminosity, "lumino
sity")); |
60 } | 82 } |
61 return entries; | 83 return entries; |
62 } | 84 } |
63 | 85 |
| 86 template<> unsigned short getMaxExposedEnumValue<SVGFEBlendElement::Mode>() |
| 87 { |
| 88 return SVGFEBlendElement::ModeLighten; |
| 89 } |
| 90 |
64 inline SVGFEBlendElement::SVGFEBlendElement(Document& document) | 91 inline SVGFEBlendElement::SVGFEBlendElement(Document& document) |
65 : SVGFilterPrimitiveStandardAttributes(SVGNames::feBlendTag, document) | 92 : SVGFilterPrimitiveStandardAttributes(SVGNames::feBlendTag, document) |
66 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) | 93 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) |
67 , m_in2(SVGAnimatedString::create(this, SVGNames::in2Attr, SVGString::create
())) | 94 , m_in2(SVGAnimatedString::create(this, SVGNames::in2Attr, SVGString::create
())) |
68 , m_mode(SVGAnimatedEnumeration<Mode>::create(this, SVGNames::modeAttr, SVGF
EBlendElement::ModeNormal)) | 95 , m_mode(SVGAnimatedEnumeration<Mode>::create(this, SVGNames::modeAttr, SVGF
EBlendElement::ModeNormal)) |
69 { | 96 { |
70 ScriptWrappable::init(this); | 97 ScriptWrappable::init(this); |
71 addToPropertyMap(m_in1); | 98 addToPropertyMap(m_in1); |
72 addToPropertyMap(m_in2); | 99 addToPropertyMap(m_in2); |
73 addToPropertyMap(m_mode); | 100 addToPropertyMap(m_mode); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 176 |
150 RefPtr<FilterEffect> effect = FEBlend::create(filter, toWebBlendMode(m_mode-
>currentValue()->enumValue())); | 177 RefPtr<FilterEffect> effect = FEBlend::create(filter, toWebBlendMode(m_mode-
>currentValue()->enumValue())); |
151 FilterEffectVector& inputEffects = effect->inputEffects(); | 178 FilterEffectVector& inputEffects = effect->inputEffects(); |
152 inputEffects.reserveCapacity(2); | 179 inputEffects.reserveCapacity(2); |
153 inputEffects.append(input1); | 180 inputEffects.append(input1); |
154 inputEffects.append(input2); | 181 inputEffects.append(input2); |
155 return effect.release(); | 182 return effect.release(); |
156 } | 183 } |
157 | 184 |
158 } | 185 } |
OLD | NEW |