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 {
typedef std::unique_ptr<ImageBuffer> ClipperMaskImage;
class RenderSVGResourceClipper final : public RenderSVGResourceContainer {
public:
RenderSVGResourceClipper(SVGClipPathElement&, Ref<RenderStyle>&&);
virtual ~RenderSVGResourceClipper();
SVGClipPathElement& clipPathElement() const { return downcast<SVGClipPathElement>(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 override { return ClipperResourceType; }
bool hitTestClipContent(const FloatRect&, const FloatPoint&);
SVGUnitTypes::SVGUnitType clipPathUnits() const { return clipPathElement().clipPathUnits(); }
protected:
virtual bool selfNeedsClientInvalidation() const override { return (everHadLayout() || m_clipper.size()) && selfNeedsLayout(); }
private:
void element() const = delete;
virtual const char* renderName() const override { return "RenderSVGResourceClipper"; }
bool pathOnlyClipping(GraphicsContext*, const AffineTransform&, const FloatRect&);
bool drawContentIntoMaskImage(const ClipperMaskImage&, const FloatRect& objectBoundingBox);
void calculateClipContentRepaintRect();
ClipperMaskImage& addRendererToClipper(const RenderObject&);
FloatRect m_clipBoundaries;
HashMap<const RenderObject*, ClipperMaskImage> m_clipper;
};
}
SPECIALIZE_TYPE_TRAITS_RENDER_SVG_RESOURCE(RenderSVGResourceClipper, ClipperResourceType)
#endif