darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 1 | /* |
zimmermann@webkit.org | 711245f | 2010-08-03 19:39:01 +0000 | [diff] [blame] | 2 | * Copyright (C) 2006 Oliver Hunt <oliver@nerget.com> |
commit-queue@webkit.org | fcb4bb1 | 2019-03-18 23:33:10 +0000 | [diff] [blame] | 3 | * Copyright (C) 2018-2019 Apple Inc. All rights reserved. |
zimmermann@webkit.org | 711245f | 2010-08-03 19:39:01 +0000 | [diff] [blame] | 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Library General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Library General Public License for more details. |
| 14 | * |
| 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 |
| 17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | * Boston, MA 02110-1301, USA. |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
commit-queue@webkit.org | 46c0f52 | 2016-11-13 10:05:43 +0000 | [diff] [blame] | 21 | #pragma once |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 22 | |
krit@webkit.org | a64eca0 | 2010-09-22 07:42:12 +0000 | [diff] [blame] | 23 | #include "FEDisplacementMap.h" |
rwlbuis | 7998312 | 2006-10-09 07:40:41 +0000 | [diff] [blame] | 24 | #include "SVGFilterPrimitiveStandardAttributes.h" |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 25 | |
darin | d18e72a | 2006-03-21 01:15:36 +0000 | [diff] [blame] | 26 | namespace WebCore { |
zimmermann@webkit.org | e1c7c58 | 2011-07-07 14:18:01 +0000 | [diff] [blame] | 27 | |
zimmermann@webkit.org | 94630af | 2011-05-18 15:35:36 +0000 | [diff] [blame] | 28 | template<> |
| 29 | struct SVGPropertyTraits<ChannelSelectorType> { |
zimmermann@webkit.org | f941d3c | 2012-04-03 11:26:50 +0000 | [diff] [blame] | 30 | static unsigned highestEnumValue() { return CHANNEL_A; } |
zimmermann@webkit.org | 94630af | 2011-05-18 15:35:36 +0000 | [diff] [blame] | 31 | |
| 32 | static String toString(ChannelSelectorType type) |
| 33 | { |
| 34 | switch (type) { |
| 35 | case CHANNEL_UNKNOWN: |
| 36 | return emptyString(); |
| 37 | case CHANNEL_R: |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 38 | return "R"_s; |
zimmermann@webkit.org | 94630af | 2011-05-18 15:35:36 +0000 | [diff] [blame] | 39 | case CHANNEL_G: |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 40 | return "G"_s; |
zimmermann@webkit.org | 94630af | 2011-05-18 15:35:36 +0000 | [diff] [blame] | 41 | case CHANNEL_B: |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 42 | return "B"_s; |
zimmermann@webkit.org | 94630af | 2011-05-18 15:35:36 +0000 | [diff] [blame] | 43 | case CHANNEL_A: |
utatane.tea@gmail.com | 8407763 | 2018-06-23 08:39:34 +0000 | [diff] [blame] | 44 | return "A"_s; |
zimmermann@webkit.org | 94630af | 2011-05-18 15:35:36 +0000 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | ASSERT_NOT_REACHED(); |
| 48 | return emptyString(); |
| 49 | } |
| 50 | |
| 51 | static ChannelSelectorType fromString(const String& value) |
| 52 | { |
| 53 | if (value == "R") |
| 54 | return CHANNEL_R; |
| 55 | if (value == "G") |
| 56 | return CHANNEL_G; |
| 57 | if (value == "B") |
| 58 | return CHANNEL_B; |
| 59 | if (value == "A") |
| 60 | return CHANNEL_A; |
| 61 | return CHANNEL_UNKNOWN; |
| 62 | } |
| 63 | }; |
| 64 | |
andersca@apple.com | 16d2dd4 | 2014-01-16 23:08:24 +0000 | [diff] [blame] | 65 | class SVGFEDisplacementMapElement final : public SVGFilterPrimitiveStandardAttributes { |
fpizlo@apple.com | 197cd32 | 2018-03-17 06:11:00 +0000 | [diff] [blame] | 66 | WTF_MAKE_ISO_ALLOCATED(SVGFEDisplacementMapElement); |
zimmermann@webkit.org | e1c7c58 | 2011-07-07 14:18:01 +0000 | [diff] [blame] | 67 | public: |
weinig@apple.com | 1092357 | 2015-01-07 20:56:24 +0000 | [diff] [blame] | 68 | static Ref<SVGFEDisplacementMapElement> create(const QualifiedName&, Document&); |
zimmermann@webkit.org | e1c7c58 | 2011-07-07 14:18:01 +0000 | [diff] [blame] | 69 | |
| 70 | static ChannelSelectorType stringToChannel(const String&); |
commit-queue@webkit.org | ea3eb58 | 2018-08-06 21:08:53 +0000 | [diff] [blame] | 71 | |
said@apple.com | 7f84324 | 2019-03-21 21:46:39 +0000 | [diff] [blame] | 72 | String in1() const { return m_in1->currentValue(); } |
| 73 | String in2() const { return m_in2->currentValue(); } |
commit-queue@webkit.org | 30faed4 | 2019-03-26 01:26:11 +0000 | [diff] [blame] | 74 | ChannelSelectorType xChannelSelector() const { return m_xChannelSelector->currentValue<ChannelSelectorType>(); } |
| 75 | ChannelSelectorType yChannelSelector() const { return m_yChannelSelector->currentValue<ChannelSelectorType>(); } |
said@apple.com | f9426b3 | 2019-03-21 00:35:50 +0000 | [diff] [blame] | 76 | float scale() const { return m_scale->currentValue(); } |
commit-queue@webkit.org | ea3eb58 | 2018-08-06 21:08:53 +0000 | [diff] [blame] | 77 | |
said@apple.com | 7f84324 | 2019-03-21 21:46:39 +0000 | [diff] [blame] | 78 | SVGAnimatedString& in1Animated() { return m_in1; } |
| 79 | SVGAnimatedString& in2Animated() { return m_in2; } |
commit-queue@webkit.org | 30faed4 | 2019-03-26 01:26:11 +0000 | [diff] [blame] | 80 | SVGAnimatedEnumeration& xChannelSelectorAnimated() { return m_xChannelSelector; } |
| 81 | SVGAnimatedEnumeration& yChannelSelectorAnimated() { return m_yChannelSelector; } |
said@apple.com | f9426b3 | 2019-03-21 00:35:50 +0000 | [diff] [blame] | 82 | SVGAnimatedNumber& scaleAnimated() { return m_scale; } |
commit-queue@webkit.org | ea3eb58 | 2018-08-06 21:08:53 +0000 | [diff] [blame] | 83 | |
zimmermann@webkit.org | e1c7c58 | 2011-07-07 14:18:01 +0000 | [diff] [blame] | 84 | private: |
weinig@apple.com | 52e786e | 2013-09-15 18:06:06 +0000 | [diff] [blame] | 85 | SVGFEDisplacementMapElement(const QualifiedName& tagName, Document&); |
commit-queue@webkit.org | ea3eb58 | 2018-08-06 21:08:53 +0000 | [diff] [blame] | 86 | |
commit-queue@webkit.org | fcb4bb1 | 2019-03-18 23:33:10 +0000 | [diff] [blame] | 87 | using PropertyRegistry = SVGPropertyOwnerRegistry<SVGFEDisplacementMapElement, SVGFilterPrimitiveStandardAttributes>; |
| 88 | const SVGPropertyRegistry& propertyRegistry() const final { return m_propertyRegistry; } |
| 89 | |
darin@apple.com | 0ce67df | 2019-06-17 01:48:13 +0000 | [diff] [blame] | 90 | void parseAttribute(const QualifiedName&, const AtomString&) override; |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 91 | void svgAttributeChanged(const QualifiedName&) override; |
commit-queue@webkit.org | ea3eb58 | 2018-08-06 21:08:53 +0000 | [diff] [blame] | 92 | |
| 93 | bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override; |
commit-queue@webkit.org | a43a6e8 | 2019-03-20 01:49:29 +0000 | [diff] [blame] | 94 | RefPtr<FilterEffect> build(SVGFilterBuilder*, Filter&) const override; |
zimmermann@webkit.org | e1c7c58 | 2011-07-07 14:18:01 +0000 | [diff] [blame] | 95 | |
commit-queue@webkit.org | fcb4bb1 | 2019-03-18 23:33:10 +0000 | [diff] [blame] | 96 | PropertyRegistry m_propertyRegistry { *this }; |
said@apple.com | 7f84324 | 2019-03-21 21:46:39 +0000 | [diff] [blame] | 97 | Ref<SVGAnimatedString> m_in1 { SVGAnimatedString::create(this) }; |
| 98 | Ref<SVGAnimatedString> m_in2 { SVGAnimatedString::create(this) }; |
commit-queue@webkit.org | 30faed4 | 2019-03-26 01:26:11 +0000 | [diff] [blame] | 99 | Ref<SVGAnimatedEnumeration> m_xChannelSelector { SVGAnimatedEnumeration::create(this, CHANNEL_A) }; |
| 100 | Ref<SVGAnimatedEnumeration> m_yChannelSelector { SVGAnimatedEnumeration::create(this, CHANNEL_A) }; |
said@apple.com | f9426b3 | 2019-03-21 00:35:50 +0000 | [diff] [blame] | 101 | Ref<SVGAnimatedNumber> m_scale { SVGAnimatedNumber::create(this) }; |
zimmermann@webkit.org | e1c7c58 | 2011-07-07 14:18:01 +0000 | [diff] [blame] | 102 | }; |
| 103 | |
weinig | ab5f09e | 2006-07-29 23:15:25 +0000 | [diff] [blame] | 104 | } // namespace WebCore |