Back to index

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

#include <nsDrawingSurfaceQt.h>

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

List of all members.

Public Member Functions

 nsDrawingSurfaceQt ()
virtual ~nsDrawingSurfaceQt ()
NS_DECL_ISUPPORTS NS_IMETHOD Lock (PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight, void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes, PRUint32 aFlags)
 Lock a rect of a drawing surface and return a pointer to the upper left hand corner of the bitmap.
NS_IMETHOD Unlock (void)
 Unlock a rect of a drawing surface.
NS_IMETHOD GetDimensions (PRUint32 *aWidth, PRUint32 *aHeight)
 Get the dimensions of a drawing surface.
NS_IMETHOD IsOffscreen (PRBool *aOffScreen)
 Get the offscreen status of the drawing surface.
NS_IMETHOD IsPixelAddressable (PRBool *aAddressable)
 Get the pixel addressability status of the drawing surface.
NS_IMETHOD GetPixelFormat (nsPixelFormat *aFormat)
 Get the pixel format of a drawing surface.
NS_IMETHOD Init (QPaintDevice *aPaintDevice, QPainter *aGC)
 Initialize a drawing surface using a QPainter and QPaintDevice.
NS_IMETHOD Init (QPainter *aGC, PRUint32 aWidth, PRUint32 aHeight, PRUint32 aFlags)
 Initialize an offscreen drawing surface using a QPainter.
PRInt32 GetDepth ()
virtual QPainter * GetGC (void)
virtual QPaintDevice * GetPaintDevice (void)

Protected Member Functions

NS_IMETHOD CommonInit ()

Private Attributes

QPaintDevice * mPaintDevice
QPixmap mPixmap
QPainter * mGC
int mDepth
nsPixelFormat mPixFormat
PRUint32 mWidth
PRUint32 mHeight
PRUint32 mFlags
PRBool mIsOffscreen
QImage mImage
PRInt32 mLockX
PRInt32 mLockY
PRUint32 mLockWidth
PRUint32 mLockHeight
PRUint32 mLockFlags
PRBool mLocked

Detailed Description

Definition at line 51 of file nsDrawingSurfaceQt.h.


Constructor & Destructor Documentation

Definition at line 49 of file nsDrawingSurfaceQt.cpp.

{
    mPaintDevice = nsnull;
    mGC          = nsnull;
    mDepth       = -1;
    mWidth       = 0;
    mHeight      = 0;
    mFlags       = 0;
    mLockWidth   = 0;
    mLockHeight  = 0;
    mLockFlags   = 0;
    mLocked      = PR_FALSE;

    // I have no idea how to compute these values.
    // FIXME
    mPixFormat.mRedMask = 0;
    mPixFormat.mGreenMask = 0;
    mPixFormat.mBlueMask = 0;
    mPixFormat.mAlphaMask = 0;

    mPixFormat.mRedShift = 0;
    mPixFormat.mGreenShift = 0;
    mPixFormat.mBlueShift = 0;
    mPixFormat.mAlphaShift = 0;
}

Definition at line 75 of file nsDrawingSurfaceQt.cpp.

{
    if (mGC && mGC->isActive()) {
        mGC->end();
    }

    delete mGC;
    mGC = nsnull;

    if (mPaintDevice) {
        if (mIsOffscreen && !mPaintDevice->paintingActive() && mPaintDevice != &mPixmap)
            delete mPaintDevice;
        mPaintDevice = nsnull;
    }
}

Member Function Documentation

Definition at line 214 of file nsDrawingSurfaceQt.cpp.

{
    PR_LOG(gQtLogModule, QT_BASIC, ("[%p] nsDrawingSurface::CommonInit\n", this));
    if (nsnull  == mGC || nsnull == mPaintDevice) {
        return NS_ERROR_FAILURE;
    }
    if (mGC->isActive()) {
        mGC->end();
    }
    mGC->begin(mPaintDevice);
    return NS_OK;
}

Here is the caller graph for this function:

Definition at line 97 of file nsDrawingSurfaceQt.h.

{ return mDepth; }

Here is the caller graph for this function:

NS_IMETHODIMP nsDrawingSurfaceQt::GetDimensions ( PRUint32 aWidth,
PRUint32 aHeight 
) [virtual]

Get the dimensions of a drawing surface.

Parameters:
aWidthout parameter for width of drawing surface
aHeightout parameter for height of drawing surface
Returns:
error status

Implements nsIDrawingSurface.

Definition at line 140 of file nsDrawingSurfaceQt.cpp.

{
    *aWidth = mWidth;
    *aHeight = mHeight;

    return NS_OK;
}

Here is the caller graph for this function:

QPainter * nsDrawingSurfaceQt::GetGC ( void  ) [virtual]

Definition at line 227 of file nsDrawingSurfaceQt.cpp.

{
    return mGC;
}

Here is the caller graph for this function:

QPaintDevice * nsDrawingSurfaceQt::GetPaintDevice ( void  ) [virtual]

Definition at line 232 of file nsDrawingSurfaceQt.cpp.

{
    PR_LOG(gQtLogModule, QT_BASIC, ("[%p] nsDrawingSurfaceQt::GetPaintDevice\n", this));
    NS_ASSERTION(mPaintDevice, "No paint device! Something will probably crash soon.");
    return mPaintDevice;
}

Here is the caller graph for this function:

Get the pixel format of a drawing surface.

Parameters:
aOffscreenout parameter filled in with pixel format information.
Returns:
error status

Implements nsIDrawingSurface.

Definition at line 161 of file nsDrawingSurfaceQt.cpp.

{
    *aFormat = mPixFormat;

    return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceQt::Init ( QPaintDevice *  aPaintDevice,
QPainter *  aGC 
)

Initialize a drawing surface using a QPainter and QPaintDevice.

these are "owned" by the drawing surface until the drawing surface is destroyed.

Parameters:
aGCQPainter to initialize drawing surface with
aPaintDeviceQPixmap to initialize drawing surface with
Returns:
error status

Definition at line 168 of file nsDrawingSurfaceQt.cpp.

{
    PR_LOG(gQtLogModule, QT_BASIC, ("[%p] nsDrawingSurface::Init\n", this));
    NS_ASSERTION(aPaintDevice, "need paint dev.");
    QPaintDeviceMetrics qMetrics(aPaintDevice);
    mGC = aGC;

    mPaintDevice = aPaintDevice;

    mWidth = qMetrics.width();
    mHeight = qMetrics.height();
    mDepth = qMetrics.depth();

    mIsOffscreen = PR_FALSE;

    mImage.reset();

    return CommonInit();
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDrawingSurfaceQt::Init ( QPainter *  aGC,
PRUint32  aWidth,
PRUint32  aHeight,
PRUint32  aFlags 
)

Initialize an offscreen drawing surface using a QPainter.

aGC is not "owned" by this drawing surface, instead it is used to create a drawing surface compatible with aGC. if width or height are less than zero, aGC will be created with no offscreen bitmap installed.

Parameters:
aGCQPainter to initialize drawing surface with
aWidthwidth of drawing surface
aHeightheight of drawing surface
aFlagsflags used to control type of drawing surface created
Returns:
error status

Definition at line 189 of file nsDrawingSurfaceQt.cpp.

{
    PR_LOG(gQtLogModule, QT_BASIC, ("[%p] nsDrawingSurface::Init\n", this));
    if (nsnull == aGC || aWidth <= 0 || aHeight <= 0) {
        return NS_ERROR_FAILURE;
    }
    mGC     = aGC;
    mWidth  = aWidth;
    mHeight = aHeight;
    mFlags  = aFlags;

    mPixmap = QPixmap(mWidth, mHeight, mDepth);
    mPaintDevice = &mPixmap;
    NS_ASSERTION(mPaintDevice, "this better not fail");

    mIsOffscreen = PR_TRUE;

    mImage.reset();

    return CommonInit();
}

Here is the call graph for this function:

Get the offscreen status of the drawing surface.

Parameters:
aOffscreenout parameter for offscreen status of drawing surface. if PR_TRUE, then modifying the drawing surface does not immediately reflect the changes on the output device
Returns:
error status

Implements nsIDrawingSurface.

Definition at line 149 of file nsDrawingSurfaceQt.cpp.

{
    *aOffScreen = mIsOffscreen;
    return NS_OK;
}

Get the pixel addressability status of the drawing surface.

Parameters:
aAddressableout parameter for pixel addressability status of drawing surface. if PR_TRUE, then the drawing surface is optimized for pixel addressability (i.e. the Lock() method has very low overhead). All drawing surfaces support Lock()ing, but doing so on drawing surfaces that do not return PR_TRUE here may impose significant overhead.
Returns:
error status

Implements nsIDrawingSurface.

Definition at line 155 of file nsDrawingSurfaceQt.cpp.

{
    *aAddressable = PR_FALSE;
    return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceQt::Lock ( PRInt32  aX,
PRInt32  aY,
PRUint32  aWidth,
PRUint32  aHeight,
void **  aBits,
PRInt32 aStride,
PRInt32 aWidthBytes,
PRUint32  aFlags 
) [virtual]

Lock a rect of a drawing surface and return a pointer to the upper left hand corner of the bitmap.

Parameters:
aXx position of subrect of bitmap
aYy position of subrect of bitmap
aWidthwidth of subrect of bitmap
aHeightheight of subrect of bitmap
aBitsout parameter for upper left hand corner of bitmap
aStrideout parameter for number of bytes to add to aBits to go from scanline to scanline
aWidthBytesout parameter for number of bytes per line in aBits to process aWidth pixels
Returns:
error status

Implements nsIDrawingSurface.

Definition at line 91 of file nsDrawingSurfaceQt.cpp.

{
    if (mLocked) {
        NS_ASSERTION(0, "nested lock attempt");
        return NS_ERROR_FAILURE;
    }
    if (mPixmap.isNull()) {
        NS_ASSERTION(0, "NULL pixmap in lock attempt");
        return NS_ERROR_FAILURE;
    }
    mLocked     = PR_TRUE;
    mLockX      = aX;
    mLockY      = aY;
    mLockWidth  = aWidth;
    mLockHeight = aHeight;
    mLockFlags  = aFlags;

    if (mImage.isNull())
        mImage = mPixmap.convertToImage();

    *aBits = mImage.bits();
    *aStride = mImage.bytesPerLine();
    *aWidthBytes = mImage.bytesPerLine();

    return NS_OK;
}

Here is the caller graph for this function:

Unlock a rect of a drawing surface.

must be preceded by a call to Lock(). Lock()/Unlock() pairs do not nest.

Returns:
error status

Implements nsIDrawingSurface.

Definition at line 121 of file nsDrawingSurfaceQt.cpp.

{
    if (!mLocked) {
        NS_ASSERTION(0,"attempting to unlock an DrawingSurface that isn't locked");
        return NS_ERROR_FAILURE;
    }
    if (mPixmap.isNull()) {
        NS_ASSERTION(0, "NULL pixmap in unlock attempt");
        return NS_ERROR_FAILURE;
    }
    if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY)) {
        qDebug("nsDrawingSurfaceQt::Unlock: w/h=%d/%d", mPixmap.width(), mPixmap.height());
        mGC->drawPixmap(0, 0, mPixmap, mLockY, mLockY, mLockWidth, mLockHeight);
    }
    mLocked = PR_FALSE;

    return NS_OK;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 111 of file nsDrawingSurfaceQt.h.

Definition at line 115 of file nsDrawingSurfaceQt.h.

QPainter* nsDrawingSurfaceQt::mGC [private]

Definition at line 110 of file nsDrawingSurfaceQt.h.

Definition at line 114 of file nsDrawingSurfaceQt.h.

QImage nsDrawingSurfaceQt::mImage [private]

Definition at line 119 of file nsDrawingSurfaceQt.h.

Definition at line 116 of file nsDrawingSurfaceQt.h.

Definition at line 125 of file nsDrawingSurfaceQt.h.

Definition at line 124 of file nsDrawingSurfaceQt.h.

Definition at line 123 of file nsDrawingSurfaceQt.h.

Definition at line 122 of file nsDrawingSurfaceQt.h.

Definition at line 120 of file nsDrawingSurfaceQt.h.

Definition at line 121 of file nsDrawingSurfaceQt.h.

QPaintDevice* nsDrawingSurfaceQt::mPaintDevice [private]

Definition at line 108 of file nsDrawingSurfaceQt.h.

Definition at line 112 of file nsDrawingSurfaceQt.h.

QPixmap nsDrawingSurfaceQt::mPixmap [private]

Definition at line 109 of file nsDrawingSurfaceQt.h.

Definition at line 113 of file nsDrawingSurfaceQt.h.


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