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