SVGFEDisplacementMapElement.h [plain text]
#pragma once
#include "FEDisplacementMap.h"
#include "SVGAnimatedEnumeration.h"
#include "SVGAnimatedNumber.h"
#include "SVGFilterPrimitiveStandardAttributes.h"
namespace WebCore {
template<>
struct SVGPropertyTraits<ChannelSelectorType> {
static unsigned highestEnumValue() { return CHANNEL_A; }
static String toString(ChannelSelectorType type)
{
switch (type) {
case CHANNEL_UNKNOWN:
return emptyString();
case CHANNEL_R:
return "R"_s;
case CHANNEL_G:
return "G"_s;
case CHANNEL_B:
return "B"_s;
case CHANNEL_A:
return "A"_s;
}
ASSERT_NOT_REACHED();
return emptyString();
}
static ChannelSelectorType fromString(const String& value)
{
if (value == "R")
return CHANNEL_R;
if (value == "G")
return CHANNEL_G;
if (value == "B")
return CHANNEL_B;
if (value == "A")
return CHANNEL_A;
return CHANNEL_UNKNOWN;
}
};
class SVGFEDisplacementMapElement final : public SVGFilterPrimitiveStandardAttributes {
WTF_MAKE_ISO_ALLOCATED(SVGFEDisplacementMapElement);
public:
static Ref<SVGFEDisplacementMapElement> create(const QualifiedName&, Document&);
static ChannelSelectorType stringToChannel(const String&);
String in1() const { return m_in1.currentValue(attributeOwnerProxy()); }
String in2() const { return m_in2.currentValue(attributeOwnerProxy()); }
ChannelSelectorType xChannelSelector() const { return m_xChannelSelector.currentValue(attributeOwnerProxy()); }
ChannelSelectorType yChannelSelector() const { return m_yChannelSelector.currentValue(attributeOwnerProxy()); }
float scale() const { return m_scale.currentValue(attributeOwnerProxy()); }
RefPtr<SVGAnimatedString> in1Animated() { return m_in1.animatedProperty(attributeOwnerProxy()); }
RefPtr<SVGAnimatedString> in2Animated() { return m_in2.animatedProperty(attributeOwnerProxy()); }
RefPtr<SVGAnimatedEnumeration> xChannelSelectorAnimated() { return m_xChannelSelector.animatedProperty(attributeOwnerProxy()); }
RefPtr<SVGAnimatedEnumeration> yChannelSelectorAnimated() { return m_yChannelSelector.animatedProperty(attributeOwnerProxy()); }
RefPtr<SVGAnimatedNumber> scaleAnimated() { return m_scale.animatedProperty(attributeOwnerProxy()); }
private:
SVGFEDisplacementMapElement(const QualifiedName& tagName, Document&);
using AttributeOwnerProxy = SVGAttributeOwnerProxyImpl<SVGFEDisplacementMapElement, SVGFilterPrimitiveStandardAttributes>;
static AttributeOwnerProxy::AttributeRegistry& attributeRegistry() { return AttributeOwnerProxy::attributeRegistry(); }
static bool isKnownAttribute(const QualifiedName& attributeName) { return AttributeOwnerProxy::isKnownAttribute(attributeName); }
static void registerAttributes();
const SVGAttributeOwnerProxy& attributeOwnerProxy() const final { return m_attributeOwnerProxy; }
void parseAttribute(const QualifiedName&, const AtomicString&) override;
void svgAttributeChanged(const QualifiedName&) override;
bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override;
RefPtr<FilterEffect> build(SVGFilterBuilder*, Filter&) override;
AttributeOwnerProxy m_attributeOwnerProxy { *this };
SVGAnimatedStringAttribute m_in1;
SVGAnimatedStringAttribute m_in2;
SVGAnimatedEnumerationAttribute<ChannelSelectorType> m_xChannelSelector { CHANNEL_A };
SVGAnimatedEnumerationAttribute<ChannelSelectorType> m_yChannelSelector { CHANNEL_A };
SVGAnimatedNumberAttribute m_scale;
};
}