RenderSVGResourceClipper.h [plain text]
#pragma once
#include "RenderSVGResourceContainer.h"
#include "SVGClipPathElement.h"
#include "SVGUnitTypes.h"
#include <wtf/HashMap.h>
namespace WebCore {
class GraphicsContext;
class ImageBuffer;
typedef std::unique_ptr<ImageBuffer> ClipperMaskImage;
class RenderSVGResourceClipper final : public RenderSVGResourceContainer {
public:
RenderSVGResourceClipper(SVGClipPathElement&, RenderStyle&&);
virtual ~RenderSVGResourceClipper();
SVGClipPathElement& clipPathElement() const { return downcast<SVGClipPathElement>(nodeForNonAnonymous()); }
void removeAllClientsFromCache(bool markForInvalidation = true) override;
void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override;
bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, OptionSet<RenderSVGResourceMode>) override;
bool applyClippingToContext(RenderElement&, const FloatRect&, const FloatRect&, GraphicsContext&);
FloatRect resourceBoundingBox(const RenderObject&) override;
RenderSVGResourceType resourceType() const override { return ClipperResourceType; }
bool hitTestClipContent(const FloatRect&, const FloatPoint&);
SVGUnitTypes::SVGUnitType clipPathUnits() const { return clipPathElement().clipPathUnits(); }
protected:
bool selfNeedsClientInvalidation() const override { return (everHadLayout() || m_clipper.size()) && selfNeedsLayout(); }
private:
void element() const = delete;
const char* renderName() const override { return "RenderSVGResourceClipper"; }
bool isSVGResourceClipper() const override { return true; }
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_BEGIN(WebCore::RenderSVGResourceClipper)
static bool isType(const WebCore::RenderObject& renderer) { return renderer.isSVGResourceClipper(); }
static bool isType(const WebCore::RenderSVGResource& resource) { return resource.resourceType() == WebCore::ClipperResourceType; }
SPECIALIZE_TYPE_TRAITS_END()