SVGFEPointLightElement.cpp [plain text]
#include "config.h"
#include "SVGFEPointLightElement.h"
#include "GeometryUtilities.h"
#include "PointLightSource.h"
#include "SVGFilterBuilder.h"
#include "SVGNames.h"
#include <wtf/MathExtras.h>
namespace WebCore {
inline SVGFEPointLightElement::SVGFEPointLightElement(const QualifiedName& tagName, Document& document)
: SVGFELightElement(tagName, document)
{
ASSERT(hasTagName(SVGNames::fePointLightTag));
}
Ref<SVGFEPointLightElement> SVGFEPointLightElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new SVGFEPointLightElement(tagName, document));
}
Ref<LightSource> SVGFEPointLightElement::lightSource(SVGFilterBuilder& builder) const
{
FloatPoint3D position;
if (builder.primitiveUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
FloatRect referenceBox = builder.targetBoundingBox();
position.setX(referenceBox.x() + x() * referenceBox.width());
position.setY(referenceBox.y() + y() * referenceBox.height());
position.setZ(z() * euclidianDistance(referenceBox.minXMinYCorner(), referenceBox.maxXMaxYCorner()) / sqrtOfTwoFloat);
} else
position = FloatPoint3D(x(), y(), z());
return PointLightSource::create(position);
}
}