PerspectiveTransformOperation.h [plain text]
#pragma once
#include "Length.h"
#include "LengthFunctions.h"
#include "TransformOperation.h"
#include <wtf/Ref.h>
namespace WebCore {
class PerspectiveTransformOperation final : public TransformOperation {
public:
static Ref<PerspectiveTransformOperation> create(const Length& p)
{
return adoptRef(*new PerspectiveTransformOperation(p));
}
Ref<TransformOperation> clone() const override
{
return adoptRef(*new PerspectiveTransformOperation(m_p));
}
Length perspective() const { return m_p; }
private:
bool isIdentity() const override { return !floatValueForLength(m_p, 1); }
bool isAffectedByTransformOrigin() const override { return !isIdentity(); }
bool operator==(const TransformOperation&) const override;
bool apply(TransformationMatrix& transform, const FloatSize&) const override
{
transform.applyPerspective(floatValueForLength(m_p, 1));
return false;
}
Ref<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) override;
void dump(WTF::TextStream&) const final;
PerspectiveTransformOperation(const Length& p)
: TransformOperation(PERSPECTIVE)
, m_p(p)
{
ASSERT(p.isFixed());
}
Length m_p;
};
}
SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::PerspectiveTransformOperation, type() == WebCore::TransformOperation::PERSPECTIVE)