Mozilla2:GFXSurface: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Class Surface ==
== Class gfxSurface ==
We need a surface to draw on to.  We need to be able to specifiy what type of surface to create -- for instance a Win32 surface or an image 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 ===
[http://lxr.mozilla.org/mozilla/source/gfx/thebes/public/gfxASurface.h gfxASurface.h]
class Surface {
public:
    Surface();
    ~Surface();
    // <insert refcount stuff here>
    // 0 = ARGB -- raw buffer.. wont be changed.. good for storing data.
    // 1 = "native" -- data will be possibily changed as you set bits
    // and will have to be converted back to ARGB
    int format;
    // raw access
    // will convert to ARGB32 pre-multiplied data if required
    SurfaceData* Lock();
    // when unlock() is called, the data will be written back.
    // lock() must be called before calling this method.
    void Unlock(SurfaceData* data);
    // state
    void Save();
    void Restore();
    // drawing
    void NewPath();
    void ClosePath();
    void Stroke();
    void Fill();
   
    void MoveTo(double x, double y);
    void LineTo(double x, double y);
    void CurveTo(double x1, double y1,
                  double x2, double y2,
                  double x3, double y3);
    void Arc(double xc, double yc,
              double radius,
              double angle1, double angle2);
    void Rectangle(double x, double y, double width, double height);
    void Polygon(const Point[] points, uint32 numPoints);
    // transform stuff
    void Translate(double x, double y);
    void Scale(double x, double y);
    void Rotate(double angle);
    void SetMatrix(Matrix* matrix);
    const Matrix& Matrix();
    // properties
    void SetColor(const RGBA& c);
    const RGBA& Color() const;
    void SetDash(double* dashes, int ndash, double offset);
    //void getDash() const;
    void SetLineWidth(double width);
    double LineWidth() const;
    // define enum for operators (clear, src, dst, etc)
    void SetOperator(int op);
    int Operator() const;
    // define line caps (butt, round, square)
    void SetLineCap(int cap);
    int LineCap() const;
    void SetMiterLimit(double limit);
    double MiterLimit() const;
    // patterns
    // fonts?
};


== Class SurfaceData ==
[http://lxr.mozilla.org/mozilla/source/gfx/thebes/public/gfxImageSurface.h gfxImageSurface.h]
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:
    unsigned long width;
    unsigned 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) {}
    unsigned long width()  const { return width; }
    unsigned long height() const { return height; }
    unsigned long stride() const { return stride; }
    long length() const { return length; }
    unsigned char *data() { return data; }
};

Latest revision as of 00:33, 15 February 2007

Class gfxSurface

We need a surface to draw on to. There will need to be multiple surface implementations such as win32, mac, linux, image, pdf, etc.

gfxASurface.h

gfxImageSurface.h