HTMLCanvasElement.h [plain text]
#ifndef HTMLCanvasElement_h
#define HTMLCanvasElement_h
#include "HTMLElement.h"
#include "IntSize.h"
#if PLATFORM(CG)
typedef struct CGContext* CGContextRef;
typedef struct CGImage* CGImageRef;
#elif PLATFORM(QT)
class QImage;
class QPainter;
#elif PLATFORM(CAIRO)
typedef struct _cairo_surface cairo_surface_t;
#endif
namespace WebCore {
class CanvasRenderingContext2D;
typedef CanvasRenderingContext2D CanvasRenderingContext;
class FloatRect;
class GraphicsContext;
class HTMLCanvasElement : public HTMLElement {
public:
HTMLCanvasElement(Document*);
virtual ~HTMLCanvasElement();
#if ENABLE(DASHBOARD_SUPPORT)
virtual HTMLTagStatus endTagRequirement() const;
virtual int tagPriority() const;
#endif
int width() const { return m_size.width(); }
int height() const { return m_size.height(); }
void setWidth(int);
void setHeight(int);
CanvasRenderingContext* getContext(const String&);
virtual void parseMappedAttribute(MappedAttribute*);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
IntSize size() const { return m_size; }
void willDraw(const FloatRect&);
void paint(GraphicsContext*, const IntRect&);
GraphicsContext* drawingContext() const;
#if PLATFORM(CG)
CGImageRef createPlatformImage() const;
#elif PLATFORM(QT)
QImage createPlatformImage() const;
#elif PLATFORM(CAIRO)
cairo_surface_t* createPlatformImage() const;
#endif
private:
void createDrawingContext() const;
void reset();
bool m_rendererIsCanvas;
RefPtr<CanvasRenderingContext2D> m_2DContext;
IntSize m_size;
mutable bool m_createdDrawingContext;
#if PLATFORM(CG)
mutable void* m_data;
#elif PLATFORM(QT)
mutable QImage* m_data;
mutable QPainter* m_painter;
#elif PLATFORM(CAIRO)
mutable void* m_data;
mutable cairo_surface_t* m_surface;
#else
mutable void* m_data;
#endif
mutable GraphicsContext* m_drawingContext;
};
}
#endif