#ifndef RenderSVGResourceClipper_h
#define RenderSVGResourceClipper_h
#include "core/rendering/svg/RenderSVGResourceContainer.h"
#include "core/svg/SVGClipPathElement.h"
namespace WebCore {
class DisplayList;
struct ClipperContext {
WTF_MAKE_FAST_ALLOCATED;
public:
enum ClipperState { NotAppliedState, AppliedPathState, AppliedMaskState };
ClipperContext()
: state(NotAppliedState)
{
}
ClipperState state;
};
class RenderSVGResourceClipper FINAL : public RenderSVGResourceContainer {
public:
explicit RenderSVGResourceClipper(SVGClipPathElement*);
virtual ~RenderSVGResourceClipper();
virtual const char* renderName() const OVERRIDE { return "RenderSVGResourceClipper"; }
virtual void removeAllClientsFromCache(bool markForInvalidation = true) OVERRIDE;
virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true) OVERRIDE;
virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode) OVERRIDE;
virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short, const Path*, const RenderSVGShape*) OVERRIDE;
bool applyStatefulResource(RenderObject*, GraphicsContext*&, ClipperContext&);
void postApplyStatefulResource(RenderObject*, GraphicsContext*&, ClipperContext&);
bool applyClippingToContext(RenderObject*, const FloatRect&, const FloatRect&, GraphicsContext*, ClipperContext&);
FloatRect resourceBoundingBox(const RenderObject*);
virtual RenderSVGResourceType resourceType() const OVERRIDE { return s_resourceType; }
bool hitTestClipContent(const FloatRect&, const FloatPoint&);
SVGUnitTypes::SVGUnitType clipPathUnits() const { return toSVGClipPathElement(element())->clipPathUnits()->currentValue()->enumValue(); }
static const RenderSVGResourceType s_resourceType;
private:
bool tryPathOnlyClipping(GraphicsContext*, const AffineTransform&, const FloatRect&);
void drawClipMaskContent(GraphicsContext*, const FloatRect& targetBoundingBox);
PassRefPtr<DisplayList> asDisplayList(GraphicsContext*, const AffineTransform&);
void calculateClipContentRepaintRect();
RefPtr<DisplayList> m_clipContentDisplayList;
FloatRect m_clipBoundaries;
bool m_inClipExpansion;
};
DEFINE_RENDER_SVG_RESOURCE_TYPE_CASTS(RenderSVGResourceClipper, ClipperResourceType);
}
#endif