From d714532feb19f42acf3b59405fbebd2709a4145c Mon Sep 17 00:00:00 2001 From: "pavlov%netscape.com" Date: Wed, 14 Mar 2001 00:35:27 +0000 Subject: [PATCH] minor api changes/indentation and spacing fixes, etc --- gfx/idl/gfxIImageFrame.idl | 87 ++++++++++++--------- gfx/public/gfxIImageFrame.idl | 87 ++++++++++++--------- gfx/src/shared/gfxImageFrame.cpp | 129 +++++++++++++++++++++---------- gfx2/public/gfxIImageFrame.idl | 87 ++++++++++++--------- gfx2/src/gfxImageFrame.cpp | 129 +++++++++++++++++++++---------- 5 files changed, 329 insertions(+), 190 deletions(-) diff --git a/gfx/idl/gfxIImageFrame.idl b/gfx/idl/gfxIImageFrame.idl index 0a85615923d7..027f6c80a7c0 100644 --- a/gfx/idl/gfxIImageFrame.idl +++ b/gfx/idl/gfxIImageFrame.idl @@ -59,6 +59,17 @@ interface gfxIImageFrame : nsISupports in nscoord aHeight, in gfx_format aFormat); + + /** + * Blit this frame into another frame. Used for GIF animation compositing + * @param mask If true, unlock the mask bits, else unlock image pixels. + */ + void drawTo(in gfxIImageFrame aDst, + in nscoord aDX, + in nscoord aDY, + in nscoord aDWidth, + in nscoord aDHeight); + /** * The x-offset of the image. */ @@ -90,12 +101,6 @@ interface gfxIImageFrame : nsISupports */ readonly attribute gfx_format format; - /** - * Represents the number of milliseconds until the next frame should be displayed. - * @note -1 means that this frame should be displayed forever. - */ - attribute long timeout; - /* data accessors */ readonly attribute unsigned long imageBytesPerRow; @@ -119,6 +124,19 @@ interface gfxIImageFrame : nsISupports in unsigned long length, in long offset); + /** + * Lock image pixels before addressing the data directly + */ + void lockImageData(); + + /** + * Unlock image pixels + */ + void unlockImageData(); + + + + /* alpha stuff.. used for _A1 and _A8 formated images */ readonly attribute unsigned long alphaBytesPerRow; @@ -127,6 +145,33 @@ interface gfxIImageFrame : nsISupports */ readonly attribute unsigned long alphaDataLength; + // XXX do we copy here? lets not... + void getAlphaData([array, size_is(length)] out PRUint8 bits, out unsigned long length); + + /** + * Sets \a length bytes of \a data in this object. + */ + void setAlphaData([array, size_is(length), const] in PRUint8 data, + in unsigned long length, + in long offset); + + /** + * Lock alpha pixels before addressing the data directly + */ + void lockAlphaData(); + + /** + * Unlock alpha pixels + */ + void unlockAlphaData(); + + + /** + * Represents the number of milliseconds until the next frame should be displayed. + * @note -1 means that this frame should be displayed forever. + */ + attribute long timeout; + /* frame disposal method, used only by GIFs. Should probably subclass image frame * and image container for GIFs special needs, but for simplicity it is here for the * moment @@ -137,34 +182,4 @@ interface gfxIImageFrame : nsISupports */ attribute gfx_color backgroundColor; - // XXX do we copy here? lets not... - void getAlphaData([array, size_is(length)] out PRUint8 bits, out unsigned long length); - - /** - * Sets \a length bytes of \a data in this object. - */ - void setAlphaData([array, size_is(length), const] in PRUint8 data, - in unsigned long length, - in long offset); - /** - * Lock image pixels before addressing the data directly - * @param mask If true, lock the mask bits, else lock image pixels. - */ - void lockImagePixels(in boolean mask); - - /** - * Unlock image pixels - * @param mask If true, unlock the mask bits, else unlock image pixels. - */ - void unlockImagePixels(in boolean mask); - - /** - * Blit this frame into another frame. Used for GIF animation compositing - * @param mask If true, unlock the mask bits, else unlock image pixels. - */ - void drawTo(in gfxIImageFrame aDst, - in long aDX, - in long aDY, - in long aDWidth, - in long aDHeight); }; diff --git a/gfx/public/gfxIImageFrame.idl b/gfx/public/gfxIImageFrame.idl index 0a85615923d7..027f6c80a7c0 100644 --- a/gfx/public/gfxIImageFrame.idl +++ b/gfx/public/gfxIImageFrame.idl @@ -59,6 +59,17 @@ interface gfxIImageFrame : nsISupports in nscoord aHeight, in gfx_format aFormat); + + /** + * Blit this frame into another frame. Used for GIF animation compositing + * @param mask If true, unlock the mask bits, else unlock image pixels. + */ + void drawTo(in gfxIImageFrame aDst, + in nscoord aDX, + in nscoord aDY, + in nscoord aDWidth, + in nscoord aDHeight); + /** * The x-offset of the image. */ @@ -90,12 +101,6 @@ interface gfxIImageFrame : nsISupports */ readonly attribute gfx_format format; - /** - * Represents the number of milliseconds until the next frame should be displayed. - * @note -1 means that this frame should be displayed forever. - */ - attribute long timeout; - /* data accessors */ readonly attribute unsigned long imageBytesPerRow; @@ -119,6 +124,19 @@ interface gfxIImageFrame : nsISupports in unsigned long length, in long offset); + /** + * Lock image pixels before addressing the data directly + */ + void lockImageData(); + + /** + * Unlock image pixels + */ + void unlockImageData(); + + + + /* alpha stuff.. used for _A1 and _A8 formated images */ readonly attribute unsigned long alphaBytesPerRow; @@ -127,6 +145,33 @@ interface gfxIImageFrame : nsISupports */ readonly attribute unsigned long alphaDataLength; + // XXX do we copy here? lets not... + void getAlphaData([array, size_is(length)] out PRUint8 bits, out unsigned long length); + + /** + * Sets \a length bytes of \a data in this object. + */ + void setAlphaData([array, size_is(length), const] in PRUint8 data, + in unsigned long length, + in long offset); + + /** + * Lock alpha pixels before addressing the data directly + */ + void lockAlphaData(); + + /** + * Unlock alpha pixels + */ + void unlockAlphaData(); + + + /** + * Represents the number of milliseconds until the next frame should be displayed. + * @note -1 means that this frame should be displayed forever. + */ + attribute long timeout; + /* frame disposal method, used only by GIFs. Should probably subclass image frame * and image container for GIFs special needs, but for simplicity it is here for the * moment @@ -137,34 +182,4 @@ interface gfxIImageFrame : nsISupports */ attribute gfx_color backgroundColor; - // XXX do we copy here? lets not... - void getAlphaData([array, size_is(length)] out PRUint8 bits, out unsigned long length); - - /** - * Sets \a length bytes of \a data in this object. - */ - void setAlphaData([array, size_is(length), const] in PRUint8 data, - in unsigned long length, - in long offset); - /** - * Lock image pixels before addressing the data directly - * @param mask If true, lock the mask bits, else lock image pixels. - */ - void lockImagePixels(in boolean mask); - - /** - * Unlock image pixels - * @param mask If true, unlock the mask bits, else unlock image pixels. - */ - void unlockImagePixels(in boolean mask); - - /** - * Blit this frame into another frame. Used for GIF animation compositing - * @param mask If true, unlock the mask bits, else unlock image pixels. - */ - void drawTo(in gfxIImageFrame aDst, - in long aDX, - in long aDY, - in long aDWidth, - in long aDHeight); }; diff --git a/gfx/src/shared/gfxImageFrame.cpp b/gfx/src/shared/gfxImageFrame.cpp index 7e0127538945..b6759c49b6e0 100644 --- a/gfx/src/shared/gfxImageFrame.cpp +++ b/gfx/src/shared/gfxImageFrame.cpp @@ -101,6 +101,16 @@ NS_IMETHODIMP gfxImageFrame::Init(nscoord aX, nscoord aY, nscoord aWidth, nscoor return NS_OK; } +/* void drawTo */ +NS_IMETHODIMP gfxImageFrame::DrawTo(gfxIImageFrame* aDst, nscoord aDX, nscoord aDY, nscoord aDWidth, nscoord aDHeight) +{ + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + nsCOMPtr img(do_GetInterface(aDst)); + return mImage->DrawToImage(img, aDX, aDY, aDWidth, aDHeight); +} + /* readonly attribute nscoord x; */ NS_IMETHODIMP gfxImageFrame::GetX(nscoord *aX) { @@ -163,19 +173,6 @@ NS_IMETHODIMP gfxImageFrame::GetFormat(gfx_format *aFormat) return NS_OK; } -/* attribute long timeout; */ -NS_IMETHODIMP gfxImageFrame::GetTimeout(PRInt32 *aTimeout) -{ - *aTimeout = mTimeout; - return NS_OK; -} - -NS_IMETHODIMP gfxImageFrame::SetTimeout(PRInt32 aTimeout) -{ - mTimeout = aTimeout; - return NS_OK; -} - /* readonly attribute unsigned long imageBytesPerRow; */ NS_IMETHODIMP gfxImageFrame::GetImageBytesPerRow(PRUint32 *aBytesPerRow) { @@ -245,28 +242,22 @@ NS_IMETHODIMP gfxImageFrame::SetImageData(const PRUint8 *aData, PRUint32 aLength return NS_OK; } -/* attribute long frameDisposalMethod; */ -NS_IMETHODIMP gfxImageFrame::GetFrameDisposalMethod(PRInt32 *aFrameDisposalMethod) +/* void lockImageData (); */ +NS_IMETHODIMP gfxImageFrame::LockImageData() { - *aFrameDisposalMethod = mDisposalMethod; - return NS_OK; -} -NS_IMETHODIMP gfxImageFrame::SetFrameDisposalMethod(PRInt32 aFrameDisposalMethod) -{ - mDisposalMethod = aFrameDisposalMethod; - return NS_OK; + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + return mImage->LockImagePixels(PR_FALSE); } -/* attribute gfx_color backgroundColor; */ -NS_IMETHODIMP gfxImageFrame::GetBackgroundColor(gfx_color *aBackgroundColor) +/* void unlockImageData (); */ +NS_IMETHODIMP gfxImageFrame::UnlockImageData() { - *aBackgroundColor = mBackgroundColor; - return NS_OK; -} -NS_IMETHODIMP gfxImageFrame::SetBackgroundColor(gfx_color aBackgroundColor) -{ - mBackgroundColor = aBackgroundColor; - return NS_OK; + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + return mImage->UnlockImagePixels(PR_FALSE); } /* readonly attribute unsigned long alphaBytesPerRow; */ @@ -330,25 +321,81 @@ NS_IMETHODIMP gfxImageFrame::SetAlphaData(const PRUint8 *aData, PRUint32 aLength return NS_OK; } -/* void lockImagePixels (in boolean mask); */ -NS_IMETHODIMP gfxImageFrame::LockImagePixels(PRBool mask) +/* void lockAlphaData (); */ +NS_IMETHODIMP gfxImageFrame::LockAlphaData() { - return mImage->LockImagePixels(mask); + if (!mInitalized || !mImage->GetHasAlphaMask()) + return NS_ERROR_NOT_INITIALIZED; + + return mImage->LockImagePixels(PR_TRUE); } -/* void unlockImagePixels (in boolean mask); */ -NS_IMETHODIMP gfxImageFrame::UnlockImagePixels(PRBool mask) +/* void unlockAlphaData (); */ +NS_IMETHODIMP gfxImageFrame::UnlockAlphaData() { - return mImage->UnlockImagePixels(mask); + if (!mInitalized || !mImage->GetHasAlphaMask()) + return NS_ERROR_NOT_INITIALIZED; + + return mImage->UnlockImagePixels(PR_TRUE); } -/* void drawTo */ -NS_IMETHODIMP gfxImageFrame::DrawTo(gfxIImageFrame* aDst, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) +/* attribute long timeout; */ +NS_IMETHODIMP gfxImageFrame::GetTimeout(PRInt32 *aTimeout) { - nsCOMPtr img(do_GetInterface(aDst)); - return mImage->DrawToImage(img, aDX, aDY, aDWidth, aDHeight); + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + *aTimeout = mTimeout; + return NS_OK; } +NS_IMETHODIMP gfxImageFrame::SetTimeout(PRInt32 aTimeout) +{ + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + mTimeout = aTimeout; + return NS_OK; +} + +/* attribute long frameDisposalMethod; */ +NS_IMETHODIMP gfxImageFrame::GetFrameDisposalMethod(PRInt32 *aFrameDisposalMethod) +{ + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + *aFrameDisposalMethod = mDisposalMethod; + return NS_OK; +} +NS_IMETHODIMP gfxImageFrame::SetFrameDisposalMethod(PRInt32 aFrameDisposalMethod) +{ + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + mDisposalMethod = aFrameDisposalMethod; + return NS_OK; +} + +/* attribute gfx_color backgroundColor; */ +NS_IMETHODIMP gfxImageFrame::GetBackgroundColor(gfx_color *aBackgroundColor) +{ + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + *aBackgroundColor = mBackgroundColor; + return NS_OK; +} +NS_IMETHODIMP gfxImageFrame::SetBackgroundColor(gfx_color aBackgroundColor) +{ + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + mBackgroundColor = aBackgroundColor; + return NS_OK; +} + + + NS_IMETHODIMP gfxImageFrame::GetInterface(const nsIID & aIID, void * *result) diff --git a/gfx2/public/gfxIImageFrame.idl b/gfx2/public/gfxIImageFrame.idl index 0a85615923d7..027f6c80a7c0 100644 --- a/gfx2/public/gfxIImageFrame.idl +++ b/gfx2/public/gfxIImageFrame.idl @@ -59,6 +59,17 @@ interface gfxIImageFrame : nsISupports in nscoord aHeight, in gfx_format aFormat); + + /** + * Blit this frame into another frame. Used for GIF animation compositing + * @param mask If true, unlock the mask bits, else unlock image pixels. + */ + void drawTo(in gfxIImageFrame aDst, + in nscoord aDX, + in nscoord aDY, + in nscoord aDWidth, + in nscoord aDHeight); + /** * The x-offset of the image. */ @@ -90,12 +101,6 @@ interface gfxIImageFrame : nsISupports */ readonly attribute gfx_format format; - /** - * Represents the number of milliseconds until the next frame should be displayed. - * @note -1 means that this frame should be displayed forever. - */ - attribute long timeout; - /* data accessors */ readonly attribute unsigned long imageBytesPerRow; @@ -119,6 +124,19 @@ interface gfxIImageFrame : nsISupports in unsigned long length, in long offset); + /** + * Lock image pixels before addressing the data directly + */ + void lockImageData(); + + /** + * Unlock image pixels + */ + void unlockImageData(); + + + + /* alpha stuff.. used for _A1 and _A8 formated images */ readonly attribute unsigned long alphaBytesPerRow; @@ -127,6 +145,33 @@ interface gfxIImageFrame : nsISupports */ readonly attribute unsigned long alphaDataLength; + // XXX do we copy here? lets not... + void getAlphaData([array, size_is(length)] out PRUint8 bits, out unsigned long length); + + /** + * Sets \a length bytes of \a data in this object. + */ + void setAlphaData([array, size_is(length), const] in PRUint8 data, + in unsigned long length, + in long offset); + + /** + * Lock alpha pixels before addressing the data directly + */ + void lockAlphaData(); + + /** + * Unlock alpha pixels + */ + void unlockAlphaData(); + + + /** + * Represents the number of milliseconds until the next frame should be displayed. + * @note -1 means that this frame should be displayed forever. + */ + attribute long timeout; + /* frame disposal method, used only by GIFs. Should probably subclass image frame * and image container for GIFs special needs, but for simplicity it is here for the * moment @@ -137,34 +182,4 @@ interface gfxIImageFrame : nsISupports */ attribute gfx_color backgroundColor; - // XXX do we copy here? lets not... - void getAlphaData([array, size_is(length)] out PRUint8 bits, out unsigned long length); - - /** - * Sets \a length bytes of \a data in this object. - */ - void setAlphaData([array, size_is(length), const] in PRUint8 data, - in unsigned long length, - in long offset); - /** - * Lock image pixels before addressing the data directly - * @param mask If true, lock the mask bits, else lock image pixels. - */ - void lockImagePixels(in boolean mask); - - /** - * Unlock image pixels - * @param mask If true, unlock the mask bits, else unlock image pixels. - */ - void unlockImagePixels(in boolean mask); - - /** - * Blit this frame into another frame. Used for GIF animation compositing - * @param mask If true, unlock the mask bits, else unlock image pixels. - */ - void drawTo(in gfxIImageFrame aDst, - in long aDX, - in long aDY, - in long aDWidth, - in long aDHeight); }; diff --git a/gfx2/src/gfxImageFrame.cpp b/gfx2/src/gfxImageFrame.cpp index 7e0127538945..b6759c49b6e0 100644 --- a/gfx2/src/gfxImageFrame.cpp +++ b/gfx2/src/gfxImageFrame.cpp @@ -101,6 +101,16 @@ NS_IMETHODIMP gfxImageFrame::Init(nscoord aX, nscoord aY, nscoord aWidth, nscoor return NS_OK; } +/* void drawTo */ +NS_IMETHODIMP gfxImageFrame::DrawTo(gfxIImageFrame* aDst, nscoord aDX, nscoord aDY, nscoord aDWidth, nscoord aDHeight) +{ + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + nsCOMPtr img(do_GetInterface(aDst)); + return mImage->DrawToImage(img, aDX, aDY, aDWidth, aDHeight); +} + /* readonly attribute nscoord x; */ NS_IMETHODIMP gfxImageFrame::GetX(nscoord *aX) { @@ -163,19 +173,6 @@ NS_IMETHODIMP gfxImageFrame::GetFormat(gfx_format *aFormat) return NS_OK; } -/* attribute long timeout; */ -NS_IMETHODIMP gfxImageFrame::GetTimeout(PRInt32 *aTimeout) -{ - *aTimeout = mTimeout; - return NS_OK; -} - -NS_IMETHODIMP gfxImageFrame::SetTimeout(PRInt32 aTimeout) -{ - mTimeout = aTimeout; - return NS_OK; -} - /* readonly attribute unsigned long imageBytesPerRow; */ NS_IMETHODIMP gfxImageFrame::GetImageBytesPerRow(PRUint32 *aBytesPerRow) { @@ -245,28 +242,22 @@ NS_IMETHODIMP gfxImageFrame::SetImageData(const PRUint8 *aData, PRUint32 aLength return NS_OK; } -/* attribute long frameDisposalMethod; */ -NS_IMETHODIMP gfxImageFrame::GetFrameDisposalMethod(PRInt32 *aFrameDisposalMethod) +/* void lockImageData (); */ +NS_IMETHODIMP gfxImageFrame::LockImageData() { - *aFrameDisposalMethod = mDisposalMethod; - return NS_OK; -} -NS_IMETHODIMP gfxImageFrame::SetFrameDisposalMethod(PRInt32 aFrameDisposalMethod) -{ - mDisposalMethod = aFrameDisposalMethod; - return NS_OK; + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + return mImage->LockImagePixels(PR_FALSE); } -/* attribute gfx_color backgroundColor; */ -NS_IMETHODIMP gfxImageFrame::GetBackgroundColor(gfx_color *aBackgroundColor) +/* void unlockImageData (); */ +NS_IMETHODIMP gfxImageFrame::UnlockImageData() { - *aBackgroundColor = mBackgroundColor; - return NS_OK; -} -NS_IMETHODIMP gfxImageFrame::SetBackgroundColor(gfx_color aBackgroundColor) -{ - mBackgroundColor = aBackgroundColor; - return NS_OK; + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + return mImage->UnlockImagePixels(PR_FALSE); } /* readonly attribute unsigned long alphaBytesPerRow; */ @@ -330,25 +321,81 @@ NS_IMETHODIMP gfxImageFrame::SetAlphaData(const PRUint8 *aData, PRUint32 aLength return NS_OK; } -/* void lockImagePixels (in boolean mask); */ -NS_IMETHODIMP gfxImageFrame::LockImagePixels(PRBool mask) +/* void lockAlphaData (); */ +NS_IMETHODIMP gfxImageFrame::LockAlphaData() { - return mImage->LockImagePixels(mask); + if (!mInitalized || !mImage->GetHasAlphaMask()) + return NS_ERROR_NOT_INITIALIZED; + + return mImage->LockImagePixels(PR_TRUE); } -/* void unlockImagePixels (in boolean mask); */ -NS_IMETHODIMP gfxImageFrame::UnlockImagePixels(PRBool mask) +/* void unlockAlphaData (); */ +NS_IMETHODIMP gfxImageFrame::UnlockAlphaData() { - return mImage->UnlockImagePixels(mask); + if (!mInitalized || !mImage->GetHasAlphaMask()) + return NS_ERROR_NOT_INITIALIZED; + + return mImage->UnlockImagePixels(PR_TRUE); } -/* void drawTo */ -NS_IMETHODIMP gfxImageFrame::DrawTo(gfxIImageFrame* aDst, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) +/* attribute long timeout; */ +NS_IMETHODIMP gfxImageFrame::GetTimeout(PRInt32 *aTimeout) { - nsCOMPtr img(do_GetInterface(aDst)); - return mImage->DrawToImage(img, aDX, aDY, aDWidth, aDHeight); + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + *aTimeout = mTimeout; + return NS_OK; } +NS_IMETHODIMP gfxImageFrame::SetTimeout(PRInt32 aTimeout) +{ + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + mTimeout = aTimeout; + return NS_OK; +} + +/* attribute long frameDisposalMethod; */ +NS_IMETHODIMP gfxImageFrame::GetFrameDisposalMethod(PRInt32 *aFrameDisposalMethod) +{ + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + *aFrameDisposalMethod = mDisposalMethod; + return NS_OK; +} +NS_IMETHODIMP gfxImageFrame::SetFrameDisposalMethod(PRInt32 aFrameDisposalMethod) +{ + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + mDisposalMethod = aFrameDisposalMethod; + return NS_OK; +} + +/* attribute gfx_color backgroundColor; */ +NS_IMETHODIMP gfxImageFrame::GetBackgroundColor(gfx_color *aBackgroundColor) +{ + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + *aBackgroundColor = mBackgroundColor; + return NS_OK; +} +NS_IMETHODIMP gfxImageFrame::SetBackgroundColor(gfx_color aBackgroundColor) +{ + if (!mInitalized) + return NS_ERROR_NOT_INITIALIZED; + + mBackgroundColor = aBackgroundColor; + return NS_OK; +} + + + NS_IMETHODIMP gfxImageFrame::GetInterface(const nsIID & aIID, void * *result)