SVGComponentTransferFunctionElement.h [plain text]
#pragma once
#include "FEComponentTransfer.h"
#include "SVGElement.h"
namespace WebCore {
template<>
struct SVGPropertyTraits<ComponentTransferType> {
static unsigned highestEnumValue() { return FECOMPONENTTRANSFER_TYPE_GAMMA; }
static String toString(ComponentTransferType type)
{
switch (type) {
case FECOMPONENTTRANSFER_TYPE_UNKNOWN:
return emptyString();
case FECOMPONENTTRANSFER_TYPE_IDENTITY:
return "identity"_s;
case FECOMPONENTTRANSFER_TYPE_TABLE:
return "table"_s;
case FECOMPONENTTRANSFER_TYPE_DISCRETE:
return "discrete"_s;
case FECOMPONENTTRANSFER_TYPE_LINEAR:
return "linear"_s;
case FECOMPONENTTRANSFER_TYPE_GAMMA:
return "gamma"_s;
}
ASSERT_NOT_REACHED();
return emptyString();
}
static ComponentTransferType fromString(const String& value)
{
if (value == "identity")
return FECOMPONENTTRANSFER_TYPE_IDENTITY;
if (value == "table")
return FECOMPONENTTRANSFER_TYPE_TABLE;
if (value == "discrete")
return FECOMPONENTTRANSFER_TYPE_DISCRETE;
if (value == "linear")
return FECOMPONENTTRANSFER_TYPE_LINEAR;
if (value == "gamma")
return FECOMPONENTTRANSFER_TYPE_GAMMA;
return FECOMPONENTTRANSFER_TYPE_UNKNOWN;
}
};
class SVGComponentTransferFunctionElement : public SVGElement {
WTF_MAKE_ISO_ALLOCATED(SVGComponentTransferFunctionElement);
public:
ComponentTransferFunction transferFunction() const;
ComponentTransferType type() const { return m_type->currentValue<ComponentTransferType>(); }
const SVGNumberList& tableValues() const { return m_tableValues->currentValue(); }
float slope() const { return m_slope->currentValue(); }
float intercept() const { return m_intercept->currentValue(); }
float amplitude() const { return m_amplitude->currentValue(); }
float exponent() const { return m_exponent->currentValue(); }
float offset() const { return m_offset->currentValue(); }
SVGAnimatedEnumeration& typeAnimated() { return m_type; }
SVGAnimatedNumberList& tableValuesAnimated() { return m_tableValues; }
SVGAnimatedNumber& slopeAnimated() { return m_slope; }
SVGAnimatedNumber& interceptAnimated() { return m_intercept; }
SVGAnimatedNumber& amplitudeAnimated() { return m_amplitude; }
SVGAnimatedNumber& exponentAnimated() { return m_exponent; }
SVGAnimatedNumber& offsetAnimated() { return m_offset; }
protected:
SVGComponentTransferFunctionElement(const QualifiedName&, Document&);
using PropertyRegistry = SVGPropertyOwnerRegistry<SVGComponentTransferFunctionElement, SVGElement>;
const SVGPropertyRegistry& propertyRegistry() const override { return m_propertyRegistry; }
void parseAttribute(const QualifiedName&, const AtomString&) override;
void svgAttributeChanged(const QualifiedName&) override;
bool rendererIsNeeded(const RenderStyle&) override { return false; }
private:
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedEnumeration> m_type { SVGAnimatedEnumeration::create(this, FECOMPONENTTRANSFER_TYPE_IDENTITY) };
Ref<SVGAnimatedNumberList> m_tableValues { SVGAnimatedNumberList::create(this) };
Ref<SVGAnimatedNumber> m_slope { SVGAnimatedNumber::create(this, 1) };
Ref<SVGAnimatedNumber> m_intercept { SVGAnimatedNumber::create(this) };
Ref<SVGAnimatedNumber> m_amplitude { SVGAnimatedNumber::create(this, 1) };
Ref<SVGAnimatedNumber> m_exponent { SVGAnimatedNumber::create(this, 1) };
Ref<SVGAnimatedNumber> m_offset { SVGAnimatedNumber::create(this) };
};
}