#ifndef Pattern_h
#define Pattern_h
#include "AffineTransform.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#if USE(CG)
typedef struct CGPattern* CGPatternRef;
typedef CGPatternRef PlatformPatternPtr;
#elif USE(DIRECT2D)
interface ID2D1BitmapBrush;
typedef ID2D1BitmapBrush* PlatformPatternPtr;
#elif USE(CAIRO)
#include <cairo.h>
typedef cairo_pattern_t* PlatformPatternPtr;
#elif USE(WINGDI)
typedef void* PlatformPatternPtr;
#endif
namespace WebCore {
class AffineTransform;
class GraphicsContext;
class Image;
class Pattern final : public RefCounted<Pattern> {
public:
static Ref<Pattern> create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY);
~Pattern();
Image* tileImage() const { return m_tileImage.get(); }
void platformDestroy();
#if !USE(DIRECT2D)
PlatformPatternPtr createPlatformPattern(const AffineTransform& userSpaceTransformation) const;
#else
PlatformPatternPtr createPlatformPattern(const GraphicsContext&, float alpha, const AffineTransform& userSpaceTransformation) const;
#endif
void setPatternSpaceTransform(const AffineTransform& patternSpaceTransformation);
const AffineTransform& getPatternSpaceTransform() { return m_patternSpaceTransformation; };
void setPlatformPatternSpaceTransform();
bool repeatX() const { return m_repeatX; }
bool repeatY() const { return m_repeatY; }
private:
Pattern(PassRefPtr<Image>, bool repeatX, bool repeatY);
RefPtr<Image> m_tileImage;
bool m_repeatX;
bool m_repeatY;
AffineTransform m_patternSpaceTransformation;
PlatformPatternPtr m_pattern;
};
}
#endif