Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Protected Member Functions | Private Attributes
gfxImageSurface Class Reference

#include <gfxImageSurface.h>

Inheritance diagram for gfxImageSurface:
Inheritance graph
[legend]
Collaboration diagram for gfxImageSurface:
Collaboration graph
[legend]

List of all members.

Public Types

enum  gfxImageFormat { ImageFormatARGB32, ImageFormatRGB24, ImageFormatA8, ImageFormatA1 }

Public Member Functions

 gfxImageSurface (gfxImageFormat format, long width, long height)
virtual ~gfxImageSurface ()
int Format () const
long Width () const
long Height () const
long Stride () const
unsigned char * Data ()
cairo_surface_t * CairoSurface ()

Protected Member Functions

void Init (cairo_surface_t *surface)
void Destroy ()
PRBool Destroyed ()

Private Attributes

unsigned char * mData
int mFormat
long mWidth
long mHeight

Detailed Description

Definition at line 46 of file gfxImageSurface.h.


Member Enumeration Documentation

Enumerator:
ImageFormatARGB32 
ImageFormatRGB24 
ImageFormatA8 
ImageFormatA1 

Definition at line 50 of file gfxImageSurface.h.


Constructor & Destructor Documentation

gfxImageSurface::gfxImageSurface ( gfxImageFormat  format,
long  width,
long  height 
)

Definition at line 44 of file gfxImageSurface.cpp.

                                                                               :
    mFormat(format), mWidth(width), mHeight(height)
{
    long stride = Stride();
    mData = new unsigned char[height * stride];

    //memset(mData, 0xff, height*stride);

    cairo_surface_t *surface =
        cairo_image_surface_create_for_data((unsigned char*)mData,
                                            (cairo_format_t)format,
                                            width,
                                            height,
                                            stride);
    Init(surface);
}

Here is the call graph for this function:

Definition at line 61 of file gfxImageSurface.cpp.

{
    Destroy();

    delete[] mData;
}

Here is the call graph for this function:


Member Function Documentation

cairo_surface_t* gfxASurface::CairoSurface ( ) [inline, inherited]

Definition at line 50 of file gfxASurface.h.

{ return mSurface; }

Here is the caller graph for this function:

unsigned char* gfxImageSurface::Data ( ) [inline]

Definition at line 65 of file gfxImageSurface.h.

{ return mData; } // delete this data under us and die.
void gfxASurface::Destroy ( void  ) [inline, protected, inherited]

Definition at line 58 of file gfxASurface.h.

                   {
        if (mDestroyed) {
            NS_WARNING("Calling Destroy on an already-destroyed surface!");
            return;
        }

        cairo_surface_destroy(mSurface);
        mDestroyed = PR_TRUE;
    }

Here is the caller graph for this function:

PRBool gfxASurface::Destroyed ( ) [inline, protected, inherited]

Definition at line 68 of file gfxASurface.h.

                       {
        return mDestroyed;
    }
int gfxImageSurface::Format ( ) const [inline]

Definition at line 61 of file gfxImageSurface.h.

{ return mFormat; }
long gfxImageSurface::Height ( ) const [inline]

Definition at line 63 of file gfxImageSurface.h.

{ return mHeight; }
void gfxASurface::Init ( cairo_surface_t *  surface) [inline, protected, inherited]

Definition at line 53 of file gfxASurface.h.

                                        {
        mDestroyed = PR_FALSE;
        mSurface = surface;
    }

Here is the caller graph for this function:

Definition at line 69 of file gfxImageSurface.cpp.

{
    long stride;

    if (mFormat == ImageFormatARGB32)
        stride = mWidth * 4;
    else if (mFormat == ImageFormatRGB24)
        stride = mWidth * 3;
    else if (mFormat == ImageFormatA8)
        stride = mWidth;
    else if (mFormat == ImageFormatA1) {
        stride = (mWidth + 7) / 8;
    } else {
        NS_WARNING("Unknown format specified to gfxImageSurface!");
        stride = mWidth * 4;
    }

    stride = ((stride + 3) / 4) * 4;

    return stride;
}
long gfxImageSurface::Width ( ) const [inline]

Definition at line 62 of file gfxImageSurface.h.

{ return mWidth; }

Member Data Documentation

unsigned char* gfxImageSurface::mData [private]

Definition at line 68 of file gfxImageSurface.h.

Definition at line 69 of file gfxImageSurface.h.

Definition at line 71 of file gfxImageSurface.h.

Definition at line 70 of file gfxImageSurface.h.


The documentation for this class was generated from the following files: