RenderSVGResourceClipper.h [plain text]
#ifndef RenderSVGResourceClipper_h
#define RenderSVGResourceClipper_h
#include "GraphicsContext.h"
#include "ImageBuffer.h"
#include "IntSize.h"
#include "RenderSVGResourceContainer.h"
#include "SVGClipPathElement.h"
#include "SVGUnitTypes.h"
#include <wtf/HashMap.h>
namespace WebCore {
struct ClipperData {
WTF_MAKE_FAST_ALLOCATED;
public:
std::unique_ptr<ImageBuffer> clipMaskImage;
};
class RenderSVGResourceClipper final : public RenderSVGResourceContainer {
public:
RenderSVGResourceClipper(SVGClipPathElement&, PassRef<RenderStyle>);
virtual ~RenderSVGResourceClipper();
SVGClipPathElement& clipPathElement() const { return toSVGClipPathElement(nodeForNonAnonymous()); }
virtual void removeAllClientsFromCache(bool markForInvalidation = true) override;
virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override;
virtual bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, unsigned short resourceMode) override;
bool applyClippingToContext(RenderElement&, const FloatRect&, const FloatRect&, GraphicsContext*);
virtual FloatRect resourceBoundingBox(const RenderObject&) override;
virtual RenderSVGResourceType resourceType() const { return ClipperResourceType; }
bool hitTestClipContent(const FloatRect&, const FloatPoint&);
SVGUnitTypes::SVGUnitType clipPathUnits() const { return clipPathElement().clipPathUnits(); }
static RenderSVGResourceType s_resourceType;
private:
void element() const = delete;
virtual const char* renderName() const override { return "RenderSVGResourceClipper"; }
bool pathOnlyClipping(GraphicsContext*, const AffineTransform&, const FloatRect&);
bool drawContentIntoMaskImage(ClipperData*, const FloatRect& objectBoundingBox);
void calculateClipContentRepaintRect();
FloatRect m_clipBoundaries;
HashMap<RenderObject*, std::unique_ptr<ClipperData>> m_clipper;
};
}
#endif