mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
first of many patches to come for bug 104999 r=timeless sr=hyatt
This commit is contained in:
parent
d3f5fcc2d9
commit
80f4c45fa3
@ -60,16 +60,11 @@ 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.
|
||||
* TRUE by default. When set to FALSE, you will no longer be able to make any modifications
|
||||
* to the data of the image. Any attempts will fail.
|
||||
*/
|
||||
void drawTo(in gfxIImageFrame aDst,
|
||||
in nscoord aDX,
|
||||
in nscoord aDY,
|
||||
in nscoord aDWidth,
|
||||
in nscoord aDHeight);
|
||||
attribute boolean mutable;
|
||||
|
||||
/**
|
||||
* The x-offset of the image.
|
||||
@ -138,7 +133,6 @@ interface gfxIImageFrame : nsISupports
|
||||
|
||||
|
||||
|
||||
|
||||
/* alpha stuff.. used for _A1 and _A8 formated images */
|
||||
readonly attribute unsigned long alphaBytesPerRow;
|
||||
|
||||
@ -168,6 +162,18 @@ interface gfxIImageFrame : nsISupports
|
||||
void unlockAlphaData();
|
||||
|
||||
|
||||
|
||||
/* GIF Specific methods. These should be in a different class or interface. */
|
||||
|
||||
/**
|
||||
* Blit this frame into another frame. Used for GIF animation compositing
|
||||
*/
|
||||
void drawTo(in gfxIImageFrame aDst,
|
||||
in nscoord aDX,
|
||||
in nscoord aDY,
|
||||
in nscoord aDWidth,
|
||||
in nscoord aDHeight);
|
||||
|
||||
/**
|
||||
* Represents the number of milliseconds until the next frame should be displayed.
|
||||
* @note -1 means that this frame should be displayed forever.
|
||||
|
@ -60,16 +60,11 @@ 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.
|
||||
* TRUE by default. When set to FALSE, you will no longer be able to make any modifications
|
||||
* to the data of the image. Any attempts will fail.
|
||||
*/
|
||||
void drawTo(in gfxIImageFrame aDst,
|
||||
in nscoord aDX,
|
||||
in nscoord aDY,
|
||||
in nscoord aDWidth,
|
||||
in nscoord aDHeight);
|
||||
attribute boolean mutable;
|
||||
|
||||
/**
|
||||
* The x-offset of the image.
|
||||
@ -138,7 +133,6 @@ interface gfxIImageFrame : nsISupports
|
||||
|
||||
|
||||
|
||||
|
||||
/* alpha stuff.. used for _A1 and _A8 formated images */
|
||||
readonly attribute unsigned long alphaBytesPerRow;
|
||||
|
||||
@ -168,6 +162,18 @@ interface gfxIImageFrame : nsISupports
|
||||
void unlockAlphaData();
|
||||
|
||||
|
||||
|
||||
/* GIF Specific methods. These should be in a different class or interface. */
|
||||
|
||||
/**
|
||||
* Blit this frame into another frame. Used for GIF animation compositing
|
||||
*/
|
||||
void drawTo(in gfxIImageFrame aDst,
|
||||
in nscoord aDX,
|
||||
in nscoord aDY,
|
||||
in nscoord aDWidth,
|
||||
in nscoord aDHeight);
|
||||
|
||||
/**
|
||||
* Represents the number of milliseconds until the next frame should be displayed.
|
||||
* @note -1 means that this frame should be displayed forever.
|
||||
|
@ -28,13 +28,14 @@
|
||||
NS_IMPL_ISUPPORTS2(gfxImageFrame, gfxIImageFrame, nsIInterfaceRequestor)
|
||||
|
||||
gfxImageFrame::gfxImageFrame() :
|
||||
mTimeout(100),
|
||||
mInitalized(PR_FALSE),
|
||||
mDisposalMethod(0),
|
||||
mHasTransparentColor(PR_FALSE),
|
||||
mMutable(PR_TRUE),
|
||||
mHasBackgroundColor(PR_FALSE),
|
||||
mHasTransparentColor(PR_FALSE),
|
||||
mTimeout(100),
|
||||
mBackgroundColor(0),
|
||||
mTransparentColor(0)
|
||||
mTransparentColor(0),
|
||||
mDisposalMethod(0)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
@ -48,16 +49,14 @@ gfxImageFrame::~gfxImageFrame()
|
||||
/* void init (in nscoord aX, in nscoord aY, in nscoord aWidth, in nscoord aHeight, in gfx_format aFormat); */
|
||||
NS_IMETHODIMP gfxImageFrame::Init(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, gfx_format aFormat)
|
||||
{
|
||||
if (mInitalized)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aWidth <= 0 || aHeight <= 0) {
|
||||
NS_ASSERTION(0, "error - negative image size\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
if (mInitalized)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mInitalized = PR_TRUE;
|
||||
|
||||
mOffset.MoveTo(aX, aY);
|
||||
@ -111,14 +110,19 @@ 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<nsIImage> img(do_GetInterface(aDst));
|
||||
return mImage->DrawToImage(img, aDX, aDY, aDWidth, aDHeight);
|
||||
/* attribute boolean mutable */
|
||||
NS_IMETHODIMP gfxImageFrame::GetMutable(PRBool *aMutable)
|
||||
{
|
||||
NS_ASSERTION(mInitalized, "gfxImageFrame::GetMutable called on non-inited gfxImageFrame");
|
||||
*aMutable = mMutable;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP gfxImageFrame::SetMutable(PRBool aMutable)
|
||||
{
|
||||
mMutable = aMutable;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nscoord x; */
|
||||
@ -209,6 +213,8 @@ NS_IMETHODIMP gfxImageFrame::GetImageData(PRUint8 **aData, PRUint32 *length)
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
NS_ASSERTION(mMutable, "trying to get data on an immutable frame");
|
||||
|
||||
*aData = mImage->GetBits();
|
||||
*length = mImage->GetLineStride() * mSize.height;
|
||||
|
||||
@ -221,6 +227,10 @@ NS_IMETHODIMP gfxImageFrame::SetImageData(const PRUint8 *aData, PRUint32 aLength
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
NS_ASSERTION(mMutable, "trying to set data on an immutable frame");
|
||||
if (!mMutable)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 row_stride = mImage->GetLineStride();
|
||||
|
||||
mImage->LockImagePixels(PR_FALSE);
|
||||
@ -299,6 +309,8 @@ NS_IMETHODIMP gfxImageFrame::GetAlphaData(PRUint8 **aData, PRUint32 *length)
|
||||
if (!mInitalized || !mImage->GetHasAlphaMask())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
NS_ASSERTION(mMutable, "trying to get data on an immutable frame");
|
||||
|
||||
*aData = mImage->GetAlphaBits();
|
||||
*length = mImage->GetAlphaLineStride() * mSize.height;
|
||||
|
||||
@ -311,6 +323,10 @@ NS_IMETHODIMP gfxImageFrame::SetAlphaData(const PRUint8 *aData, PRUint32 aLength
|
||||
if (!mInitalized || !mImage->GetHasAlphaMask())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
NS_ASSERTION(mMutable, "trying to set data on an immutable frame");
|
||||
if (!mMutable)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 row_stride = mImage->GetAlphaLineStride();
|
||||
|
||||
mImage->LockImagePixels(PR_TRUE);
|
||||
@ -352,6 +368,21 @@ NS_IMETHODIMP gfxImageFrame::UnlockAlphaData()
|
||||
return mImage->UnlockImagePixels(PR_TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* void drawTo */
|
||||
NS_IMETHODIMP gfxImageFrame::DrawTo(gfxIImageFrame* aDst, nscoord aDX, nscoord aDY, nscoord aDWidth, nscoord aDHeight)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIImage> img(do_GetInterface(aDst));
|
||||
return mImage->DrawToImage(img, aDX, aDY, aDWidth, aDHeight);
|
||||
}
|
||||
|
||||
|
||||
/* attribute long timeout; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetTimeout(PRInt32 *aTimeout)
|
||||
{
|
||||
|
@ -57,17 +57,17 @@ protected:
|
||||
private:
|
||||
/* private members */
|
||||
nsCOMPtr<nsIImage> mImage;
|
||||
nsPoint mOffset;
|
||||
|
||||
PRPackedBool mInitalized;
|
||||
PRPackedBool mMutable;
|
||||
PRPackedBool mHasBackgroundColor;
|
||||
PRPackedBool mHasTransparentColor;
|
||||
gfx_format mFormat;
|
||||
|
||||
PRInt32 mTimeout; // -1 means display forever
|
||||
nsPoint mOffset;
|
||||
|
||||
PRPackedBool mInitalized; // 8 bits
|
||||
gfx_format mFormat; // 16 bits
|
||||
|
||||
PRBool mHasBackgroundColor;
|
||||
gfx_color mBackgroundColor;
|
||||
|
||||
PRBool mHasTransparentColor;
|
||||
gfx_color mTransparentColor;
|
||||
|
||||
PRInt32 mDisposalMethod;
|
||||
|
@ -60,16 +60,11 @@ 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.
|
||||
* TRUE by default. When set to FALSE, you will no longer be able to make any modifications
|
||||
* to the data of the image. Any attempts will fail.
|
||||
*/
|
||||
void drawTo(in gfxIImageFrame aDst,
|
||||
in nscoord aDX,
|
||||
in nscoord aDY,
|
||||
in nscoord aDWidth,
|
||||
in nscoord aDHeight);
|
||||
attribute boolean mutable;
|
||||
|
||||
/**
|
||||
* The x-offset of the image.
|
||||
@ -138,7 +133,6 @@ interface gfxIImageFrame : nsISupports
|
||||
|
||||
|
||||
|
||||
|
||||
/* alpha stuff.. used for _A1 and _A8 formated images */
|
||||
readonly attribute unsigned long alphaBytesPerRow;
|
||||
|
||||
@ -168,6 +162,18 @@ interface gfxIImageFrame : nsISupports
|
||||
void unlockAlphaData();
|
||||
|
||||
|
||||
|
||||
/* GIF Specific methods. These should be in a different class or interface. */
|
||||
|
||||
/**
|
||||
* Blit this frame into another frame. Used for GIF animation compositing
|
||||
*/
|
||||
void drawTo(in gfxIImageFrame aDst,
|
||||
in nscoord aDX,
|
||||
in nscoord aDY,
|
||||
in nscoord aDWidth,
|
||||
in nscoord aDHeight);
|
||||
|
||||
/**
|
||||
* Represents the number of milliseconds until the next frame should be displayed.
|
||||
* @note -1 means that this frame should be displayed forever.
|
||||
|
@ -28,13 +28,14 @@
|
||||
NS_IMPL_ISUPPORTS2(gfxImageFrame, gfxIImageFrame, nsIInterfaceRequestor)
|
||||
|
||||
gfxImageFrame::gfxImageFrame() :
|
||||
mTimeout(100),
|
||||
mInitalized(PR_FALSE),
|
||||
mDisposalMethod(0),
|
||||
mHasTransparentColor(PR_FALSE),
|
||||
mMutable(PR_TRUE),
|
||||
mHasBackgroundColor(PR_FALSE),
|
||||
mHasTransparentColor(PR_FALSE),
|
||||
mTimeout(100),
|
||||
mBackgroundColor(0),
|
||||
mTransparentColor(0)
|
||||
mTransparentColor(0),
|
||||
mDisposalMethod(0)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
@ -48,16 +49,14 @@ gfxImageFrame::~gfxImageFrame()
|
||||
/* void init (in nscoord aX, in nscoord aY, in nscoord aWidth, in nscoord aHeight, in gfx_format aFormat); */
|
||||
NS_IMETHODIMP gfxImageFrame::Init(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, gfx_format aFormat)
|
||||
{
|
||||
if (mInitalized)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aWidth <= 0 || aHeight <= 0) {
|
||||
NS_ASSERTION(0, "error - negative image size\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
if (mInitalized)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mInitalized = PR_TRUE;
|
||||
|
||||
mOffset.MoveTo(aX, aY);
|
||||
@ -111,14 +110,19 @@ 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<nsIImage> img(do_GetInterface(aDst));
|
||||
return mImage->DrawToImage(img, aDX, aDY, aDWidth, aDHeight);
|
||||
/* attribute boolean mutable */
|
||||
NS_IMETHODIMP gfxImageFrame::GetMutable(PRBool *aMutable)
|
||||
{
|
||||
NS_ASSERTION(mInitalized, "gfxImageFrame::GetMutable called on non-inited gfxImageFrame");
|
||||
*aMutable = mMutable;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP gfxImageFrame::SetMutable(PRBool aMutable)
|
||||
{
|
||||
mMutable = aMutable;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nscoord x; */
|
||||
@ -209,6 +213,8 @@ NS_IMETHODIMP gfxImageFrame::GetImageData(PRUint8 **aData, PRUint32 *length)
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
NS_ASSERTION(mMutable, "trying to get data on an immutable frame");
|
||||
|
||||
*aData = mImage->GetBits();
|
||||
*length = mImage->GetLineStride() * mSize.height;
|
||||
|
||||
@ -221,6 +227,10 @@ NS_IMETHODIMP gfxImageFrame::SetImageData(const PRUint8 *aData, PRUint32 aLength
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
NS_ASSERTION(mMutable, "trying to set data on an immutable frame");
|
||||
if (!mMutable)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 row_stride = mImage->GetLineStride();
|
||||
|
||||
mImage->LockImagePixels(PR_FALSE);
|
||||
@ -299,6 +309,8 @@ NS_IMETHODIMP gfxImageFrame::GetAlphaData(PRUint8 **aData, PRUint32 *length)
|
||||
if (!mInitalized || !mImage->GetHasAlphaMask())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
NS_ASSERTION(mMutable, "trying to get data on an immutable frame");
|
||||
|
||||
*aData = mImage->GetAlphaBits();
|
||||
*length = mImage->GetAlphaLineStride() * mSize.height;
|
||||
|
||||
@ -311,6 +323,10 @@ NS_IMETHODIMP gfxImageFrame::SetAlphaData(const PRUint8 *aData, PRUint32 aLength
|
||||
if (!mInitalized || !mImage->GetHasAlphaMask())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
NS_ASSERTION(mMutable, "trying to set data on an immutable frame");
|
||||
if (!mMutable)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 row_stride = mImage->GetAlphaLineStride();
|
||||
|
||||
mImage->LockImagePixels(PR_TRUE);
|
||||
@ -352,6 +368,21 @@ NS_IMETHODIMP gfxImageFrame::UnlockAlphaData()
|
||||
return mImage->UnlockImagePixels(PR_TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* void drawTo */
|
||||
NS_IMETHODIMP gfxImageFrame::DrawTo(gfxIImageFrame* aDst, nscoord aDX, nscoord aDY, nscoord aDWidth, nscoord aDHeight)
|
||||
{
|
||||
if (!mInitalized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIImage> img(do_GetInterface(aDst));
|
||||
return mImage->DrawToImage(img, aDX, aDY, aDWidth, aDHeight);
|
||||
}
|
||||
|
||||
|
||||
/* attribute long timeout; */
|
||||
NS_IMETHODIMP gfxImageFrame::GetTimeout(PRInt32 *aTimeout)
|
||||
{
|
||||
|
@ -57,17 +57,17 @@ protected:
|
||||
private:
|
||||
/* private members */
|
||||
nsCOMPtr<nsIImage> mImage;
|
||||
nsPoint mOffset;
|
||||
|
||||
PRPackedBool mInitalized;
|
||||
PRPackedBool mMutable;
|
||||
PRPackedBool mHasBackgroundColor;
|
||||
PRPackedBool mHasTransparentColor;
|
||||
gfx_format mFormat;
|
||||
|
||||
PRInt32 mTimeout; // -1 means display forever
|
||||
nsPoint mOffset;
|
||||
|
||||
PRPackedBool mInitalized; // 8 bits
|
||||
gfx_format mFormat; // 16 bits
|
||||
|
||||
PRBool mHasBackgroundColor;
|
||||
gfx_color mBackgroundColor;
|
||||
|
||||
PRBool mHasTransparentColor;
|
||||
gfx_color mTransparentColor;
|
||||
|
||||
PRInt32 mDisposalMethod;
|
||||
|
Loading…
Reference in New Issue
Block a user