Mozilla2:GFXSurface: Difference between revisions
Jump to navigation
Jump to search
(Update to support seperate surfaces) |
(Update to support seperate surfaces) |
(No difference)
| |
Revision as of 06:32, 14 March 2005
Class Surface
We need a surface to draw on to. There will need to be multiple surface implementations such as win32, mac, linux, image, pdf, etc.
API
class ASurface {
public:
// <insert refcount stuff here>
virtual cairo_surface_t *CairoSurface();
virtual int Format() const;
virtual long Width() const;
virtual long Height() const;
// raw access
// will convert to ARGB32 pre-multiplied data if required
virtual SurfaceData* Lock(long x, long y, long width, long height);
// when unlock() is called, the data will be written back.
// lock() must be called before calling this method.
virtual void Unlock(SurfaceData* data);
};
Class SurfaceData
I want something simple to give back a buffer for someone to modify when they call Lock() on their surface. It will always be ARGB32.
API
class SurfaceData {
private:
long width;
long height;
unsigned long stride;
long length;
unsigned char *data;
public:
SurfaceData(unsigned long _width, unsigned long _height,
unsigned long _stride, long _length,
unsigned char *_data) :
width(_width), height(_height),
stride(_stride), length(_length), data(_data) {}
long Width() const { return width; }
long Height() const { return height; }
long Stride() const { return stride; }
long Length() const { return length; }
unsigned char *Data() { return data; }
};