#ifndef RenderSVGResourcePattern_h
#define RenderSVGResourcePattern_h
#include "core/rendering/svg/RenderSVGResourceContainer.h"
#include "core/svg/PatternAttributes.h"
#include "core/svg/SVGPatternElement.h"
#include "core/svg/SVGUnitTypes.h"
#include "platform/geometry/FloatRect.h"
#include "platform/graphics/ImageBuffer.h"
#include "platform/graphics/Pattern.h"
#include "platform/transforms/AffineTransform.h"
#include "wtf/HashMap.h"
#include "wtf/OwnPtr.h"
namespace WebCore {
struct PatternData {
WTF_MAKE_FAST_ALLOCATED;
public:
RefPtr<Pattern> pattern;
AffineTransform transform;
};
class RenderSVGResourcePattern FINAL : public RenderSVGResourceContainer {
public:
explicit RenderSVGResourcePattern(SVGPatternElement*);
virtual const char* renderName() const OVERRIDE { return "RenderSVGResourcePattern"; }
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 resourceMode, const Path*, const RenderSVGShape*) OVERRIDE;
virtual RenderSVGResourceType resourceType() const OVERRIDE { return s_resourceType; }
static const RenderSVGResourceType s_resourceType;
private:
bool buildTileImageTransform(RenderObject*, const PatternAttributes&, const SVGPatternElement*, FloatRect& patternBoundaries, AffineTransform& tileImageTransform) const;
PassOwnPtr<ImageBuffer> createTileImage(const PatternAttributes&, const FloatRect& tileBoundaries,
const FloatRect& absoluteTileBoundaries, const AffineTransform& tileImageTransform,
FloatRect& clampedAbsoluteTileBoundaries) const;
PatternData* buildPattern(RenderObject*, unsigned short resourceMode);
bool m_shouldCollectPatternAttributes : 1;
PatternAttributes m_attributes;
HashMap<RenderObject*, OwnPtr<PatternData> > m_patternMap;
};
}
#endif