diff --git a/gfx/public/nsIImage.h b/gfx/public/nsIImage.h index d1241938d587..f782ac19085d 100644 --- a/gfx/public/nsIImage.h +++ b/gfx/public/nsIImage.h @@ -109,6 +109,11 @@ public: virtual PRInt32 GetDecodedX2() = 0; virtual PRInt32 GetDecodedY2() = 0; + NS_IMETHOD SetNaturalWidth(PRInt32) = 0; + NS_IMETHOD SetNaturalHeight(PRInt32) = 0; + virtual PRInt32 GetNaturalWidth() = 0; + virtual PRInt32 GetNaturalHeight() = 0; + /** * Get a pointer to the bits for the pixelmap, only if it is not optimized * @update - dwc 2/1/99 diff --git a/gfx/src/beos/nsImageBeOS.cpp b/gfx/src/beos/nsImageBeOS.cpp index 09be6bf56eca..284a084a57b5 100644 --- a/gfx/src/beos/nsImageBeOS.cpp +++ b/gfx/src/beos/nsImageBeOS.cpp @@ -42,6 +42,9 @@ nsImageBeOS::nsImageBeOS() mAlphaBits = nsnull; mAlphaPixmap = nsnull; mImage = nsnull; + mNaturalWidth = 0; + mNaturalHeight = 0; + } //------------------------------------------------------------ @@ -93,6 +96,8 @@ nsresult } SetDecodedRect(0,0,0,0); //init + SetNaturalWidth(0); + SetNaturalHeight(0); mWidth = aWidth; mHeight = aHeight; diff --git a/gfx/src/beos/nsImageBeOS.h b/gfx/src/beos/nsImageBeOS.h index a4adce656a8f..fa9c03b61209 100644 --- a/gfx/src/beos/nsImageBeOS.h +++ b/gfx/src/beos/nsImageBeOS.h @@ -55,6 +55,12 @@ public: virtual PRInt32 GetDecodedX2() { return mDecodedX2;} virtual PRInt32 GetDecodedY2() { return mDecodedY2;} + NS_IMETHOD SetNaturalWidth(PRInt32 naturalwidth) { mNaturalWidth= naturalwidth; return NS_OK;} + NS_IMETHOD SetNaturalHeight(PRInt32 naturalheight) { mNaturalHeight= naturalheight; return NS_OK;} + virtual PRInt32 GetNaturalWidth() {return mNaturalWidth; } + virtual PRInt32 GetNaturalHeight() {return mNaturalHeight; } + + NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, @@ -119,6 +125,9 @@ private: PRInt32 mDecodedX2; PRInt32 mDecodedY2; + PRInt32 mNaturalWidth; + PRInt32 mNaturalHeight; + // alpha layer members PRUint8 *mAlphaBits; BBitmap *mAlphaPixmap; diff --git a/gfx/src/gtk/nsImageGTK.cpp b/gfx/src/gtk/nsImageGTK.cpp index fa4c3e4da771..9d5dba4840ce 100644 --- a/gfx/src/gtk/nsImageGTK.cpp +++ b/gfx/src/gtk/nsImageGTK.cpp @@ -70,6 +70,9 @@ nsImageGTK::nsImageGTK() mAlphaWidth = 0; mConvertedBits = nsnull; mGC = nsnull; + mNaturalWidth = 0; + mNaturalHeight = 0; + #ifdef TRACE_IMAGE_ALLOCATION printf("nsImageGTK::nsImageGTK(this=%p)\n", this); @@ -131,7 +134,8 @@ nsresult nsImageGTK::Init(PRInt32 aWidth, PRInt32 aHeight, } SetDecodedRect(0,0,0,0); //init - + SetNaturalWidth(0); + SetNaturalHeight(0); // mImagePixmap gets created once per unique image bits in Draw() // ImageUpdated(nsImageUpdateFlags_kBitsChanged) can cause the diff --git a/gfx/src/gtk/nsImageGTK.h b/gfx/src/gtk/nsImageGTK.h index d4e65d80b29c..51a6ee7210d9 100644 --- a/gfx/src/gtk/nsImageGTK.h +++ b/gfx/src/gtk/nsImageGTK.h @@ -50,6 +50,11 @@ public: virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; } virtual PRInt32 GetLineStride(); + NS_IMETHOD SetNaturalWidth(PRInt32 naturalwidth) { mNaturalWidth= naturalwidth; return NS_OK;} + NS_IMETHOD SetNaturalHeight(PRInt32 naturalheight) { mNaturalHeight= naturalheight; return NS_OK;} + virtual PRInt32 GetNaturalWidth() {return mNaturalWidth; } + virtual PRInt32 GetNaturalHeight() {return mNaturalHeight; } + NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2); virtual PRInt32 GetDecodedX1() { return mDecodedX1;} virtual PRInt32 GetDecodedY1() { return mDecodedY1;} @@ -158,6 +163,9 @@ private: PRInt8 mNumBytesPixel; + PRInt32 mNaturalWidth; + PRInt32 mNaturalHeight; + PRInt32 mDecodedX1; //Keeps track of what part of image PRInt32 mDecodedY1; // has been decoded. PRInt32 mDecodedX2; diff --git a/gfx/src/mac/nsImageMac.cpp b/gfx/src/mac/nsImageMac.cpp index 1466b9d4818f..632bd6fbd0a9 100644 --- a/gfx/src/mac/nsImageMac.cpp +++ b/gfx/src/mac/nsImageMac.cpp @@ -52,6 +52,9 @@ nsImageMac::nsImageMac() , mARowBytes(0) , mIsTopToBottom(PR_TRUE) , mPixelDataSize(0) +, mNaturalWidth(0) +, mNaturalHeight(0) + { NS_INIT_REFCNT(); } @@ -145,7 +148,9 @@ nsImageMac::Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirem mWidth = aWidth; mHeight = aHeight; SetDecodedRect(0,0,0,0); //init - + SetNaturalWidth(0); + SetNaturalHeight(0); + PRInt16 bufferdepth; switch(aDepth) diff --git a/gfx/src/mac/nsImageMac.h b/gfx/src/mac/nsImageMac.h index 8c428eb65bc5..7d7966e03d82 100644 --- a/gfx/src/mac/nsImageMac.h +++ b/gfx/src/mac/nsImageMac.h @@ -48,6 +48,11 @@ public: virtual PRInt32 GetLineStride() { return mRowBytes; } virtual PRBool GetHasAlphaMask() { return mAlphaGWorld != nsnull; } + NS_IMETHOD SetNaturalWidth(PRInt32 naturalwidth) { mNaturalWidth= naturalwidth; return NS_OK;} + NS_IMETHOD SetNaturalHeight(PRInt32 naturalheight) { mNaturalHeight= naturalheight; return NS_OK;} + virtual PRInt32 GetNaturalWidth() {return mNaturalWidth; } + virtual PRInt32 GetNaturalHeight() {return mNaturalHeight; } + NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2); virtual PRInt32 GetDecodedX1() { return mDecodedX1;} virtual PRInt32 GetDecodedY1() { return mDecodedY1;} @@ -103,6 +108,9 @@ private: PRInt16 mAlphaHeight; // alpha layer height PRInt32 mARowBytes; // alpha row bytes + PRInt32 mNaturalWidth; + PRInt32 mNaturalHeight; + PRInt32 mDecodedX1; //Keeps track of what part of image PRInt32 mDecodedY1; // has been decoded. PRInt32 mDecodedX2; diff --git a/gfx/src/motif/nsImageMotif.cpp b/gfx/src/motif/nsImageMotif.cpp index 3ac3c69391db..e67bdb9c4c34 100644 --- a/gfx/src/motif/nsImageMotif.cpp +++ b/gfx/src/motif/nsImageMotif.cpp @@ -47,6 +47,9 @@ nsImageMotif :: nsImageMotif() mColorMap = nsnull; mAlphaBits = nsnull; mStaticImage = PR_FALSE; + mNaturalWidth = 0; + mNaturalHeight = 0; + } //------------------------------------------------------------ @@ -101,6 +104,8 @@ nsresult nsImageMotif :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,ns mConverted = PR_FALSE; SetDecodedRect(0,0,0,0); //init + SetNaturalWidth(0); + SetNaturalHeight(0); ComputePaletteSize(aDepth); diff --git a/gfx/src/motif/nsImageMotif.h b/gfx/src/motif/nsImageMotif.h index c471db62fd8b..7beb39cd6d12 100644 --- a/gfx/src/motif/nsImageMotif.h +++ b/gfx/src/motif/nsImageMotif.h @@ -57,6 +57,11 @@ public: virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; } virtual PRInt32 GetLineStride() {return mRowBytes; } + NS_IMETHOD SetNaturalWidth(PRInt32 naturalwidth) { mNaturalWidth= naturalwidth; return NS_OK;} + NS_IMETHOD SetNaturalHeight(PRInt32 naturalheight) { mNaturalHeight= naturalheight; return NS_OK;} + virtual PRInt32 GetNaturalWidth() {return mNaturalWidth; } + virtual PRInt32 GetNaturalHeight() {return mNaturalHeight; } + NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2); virtual PRInt32 GetDecodedX1() { return mDecodedX1;} virtual PRInt32 GetDecodedY1() { return mDecodedY1;} @@ -141,6 +146,9 @@ private: PRInt16 mNumPalleteColors; PRInt8 mNumBytesPixel; + PRInt32 mNaturalWidth; + PRInt32 mNaturalHeight; + PRInt32 mDecodedX1; //Keeps track of what part of image PRInt32 mDecodedY1; // has been decoded. PRInt32 mDecodedX2; diff --git a/gfx/src/nsImageRenderer.cpp b/gfx/src/nsImageRenderer.cpp index 32353d197055..772876bee3ce 100644 --- a/gfx/src/nsImageRenderer.cpp +++ b/gfx/src/nsImageRenderer.cpp @@ -65,6 +65,9 @@ public: PRInt32 *aWidthPtr, PRInt32 *aHeightPtr, PRUint32 aIconNumber); + NS_IMETHOD SetImageNaturalDimensions(IL_Pixmap* aImage, PRInt32 naturalwidth, PRInt32 naturalheight); + + NS_IMETHOD SetDecodedRect(IL_Pixmap* aImage, PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2); @@ -72,6 +75,20 @@ public: }; +NS_IMETHODIMP +ImageRendererImpl::SetImageNaturalDimensions( + IL_Pixmap* aImage, + PRInt32 naturalwidth, + PRInt32 naturalheight){ + + nsIImage *img = (nsIImage *)aImage->client_data; + + if(img){ + nsresult rv = img->SetNaturalWidth(naturalwidth); + rv = img->SetNaturalHeight(naturalheight); + } + return NS_OK; +} ImageRendererImpl::ImageRendererImpl() { NS_INIT_REFCNT(); diff --git a/gfx/src/os2/nsImageOS2.cpp b/gfx/src/os2/nsImageOS2.cpp index 3ee3824bb750..b932720fd73a 100644 --- a/gfx/src/os2/nsImageOS2.cpp +++ b/gfx/src/os2/nsImageOS2.cpp @@ -59,6 +59,9 @@ nsImageOS2::nsImageOS2() mIsTopToBottom = PR_FALSE; mDeviceDepth = 0; + mNaturalWidth = 0; + mNaturalHeight = 0; + } nsImageOS2::~nsImageOS2() @@ -87,6 +90,8 @@ nsresult nsImageOS2::Init( PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, // mRowBytes = (mRowBytes + 3) & ~0x3; SetDecodedRect(0,0,0,0); //init + SetNaturalWidth(0); + SetNaturalHeight(0); mImageBits = new PRUint8 [ aHeight * mRowBytes ]; diff --git a/gfx/src/os2/nsImageOS2.h b/gfx/src/os2/nsImageOS2.h index 3aebbfe72d67..0eedf38dbc36 100644 --- a/gfx/src/os2/nsImageOS2.h +++ b/gfx/src/os2/nsImageOS2.h @@ -49,6 +49,11 @@ public: virtual PRUint8* GetBits() { return mImageBits; } virtual PRInt32 GetLineStride() { return mRowBytes; } + NS_IMETHOD SetNaturalWidth(PRInt32 naturalwidth) { mNaturalWidth= naturalwidth; return NS_OK;} + NS_IMETHOD SetNaturalHeight(PRInt32 naturalheight) { mNaturalHeight= naturalheight; return NS_OK;} + virtual PRInt32 GetNaturalWidth() {return mNaturalWidth; } + virtual PRInt32 GetNaturalHeight() {return mNaturalHeight; } + NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2); virtual PRInt32 GetDecodedX1() { return mDecodedX1;} virtual PRInt32 GetDecodedY1() { return mDecodedY1;} @@ -188,6 +193,9 @@ public: PRBool mIsOptimized; // Did we convert our DIB to a HBITMAP nsColorMap* mColorMap; // Redundant with mColorTable, but necessary + PRInt32 mNaturalWidth; + PRInt32 mNaturalHeight; + PRInt32 mDecodedX1; //Keeps track of what part of image PRInt32 mDecodedY1; // has been decoded. PRInt32 mDecodedX2; diff --git a/gfx/src/photon/nsImagePh.cpp b/gfx/src/photon/nsImagePh.cpp index 7133a7e7798c..0c744023b647 100644 --- a/gfx/src/photon/nsImagePh.cpp +++ b/gfx/src/photon/nsImagePh.cpp @@ -66,6 +66,9 @@ nsImagePh :: nsImagePh() mAlphaLevel = 0; mImage.palette = nsnull; mImage.image = nsnull; + mNaturalWidth = 0; + mNaturalHeight = 0; + } // ---------------------------------------------------------------- @@ -127,6 +130,8 @@ nsresult nsImagePh :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMas } SetDecodedRect(0,0,0,0); //init + SetNaturalWidth(0); + SetNaturalHeight(0); if (24 == aDepth) { diff --git a/gfx/src/photon/nsImagePh.h b/gfx/src/photon/nsImagePh.h index da0d6c0d8aac..0aba3e89732e 100644 --- a/gfx/src/photon/nsImagePh.h +++ b/gfx/src/photon/nsImagePh.h @@ -44,6 +44,11 @@ public: virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; } virtual PRInt32 GetLineStride(); + NS_IMETHOD SetNaturalWidth(PRInt32 naturalwidth) { mNaturalWidth= naturalwidth; return NS_OK;} + NS_IMETHOD SetNaturalHeight(PRInt32 naturalheight) { mNaturalHeight= naturalheight; return NS_OK;} + virtual PRInt32 GetNaturalWidth() {return mNaturalWidth; } + virtual PRInt32 GetNaturalHeight() {return mNaturalHeight; } + NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2); virtual PRInt32 GetDecodedX1() { return mDecodedX1;} virtual PRInt32 GetDecodedY1() { return mDecodedY1;} @@ -110,6 +115,8 @@ private: // PRBool mIsOptimized; // Have we turned our DIB into a GDI? // nsColorMap* mColorMap; // Redundant with mColorTable, but necessary + PRInt32 mNaturalWidth; + PRInt32 mNaturalHeight; PRInt32 mDecodedX1; //Keeps track of what part of image PRInt32 mDecodedY1; // has been decoded. diff --git a/gfx/src/qt/nsImageQT.cpp b/gfx/src/qt/nsImageQT.cpp index 8a3ac21017be..ad355c90365e 100644 --- a/gfx/src/qt/nsImageQT.cpp +++ b/gfx/src/qt/nsImageQT.cpp @@ -47,6 +47,9 @@ nsImageQT::nsImageQT() mAlphaBits = nsnull; mAlphaPixmap = nsnull; mImagePixmap = nsnull; + mNaturalWidth = 0; + mNaturalHeight = 0; + } //------------------------------------------------------------ @@ -96,6 +99,8 @@ nsresult nsImageQT::Init(PRInt32 aWidth, } SetDecodedRect(0,0,0,0); //init + SetNaturalWidth(0); + SetNaturalHeight(0); if (nsnull != mImageBits) { diff --git a/gfx/src/qt/nsImageQT.h b/gfx/src/qt/nsImageQT.h index b0cadb905454..d9d71f4e13af 100644 --- a/gfx/src/qt/nsImageQT.h +++ b/gfx/src/qt/nsImageQT.h @@ -47,6 +47,11 @@ public: virtual PRUint8* GetBits(); virtual void* GetBitInfo(); virtual PRInt32 GetLineStride(); + + NS_IMETHOD SetNaturalWidth(PRInt32 naturalwidth) { mNaturalWidth= naturalwidth; return NS_OK;} + NS_IMETHOD SetNaturalHeight(PRInt32 naturalheight) { mNaturalHeight= naturalheight; return NS_OK;} + virtual PRInt32 GetNaturalWidth() {return mNaturalWidth; } + virtual PRInt32 GetNaturalHeight() {return mNaturalHeight; } NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2); virtual PRInt32 GetDecodedX1() { return mDecodedX1;} @@ -117,6 +122,9 @@ private: PRInt8 mNumBytesPixel; + PRInt32 mNaturalWidth; + PRInt32 mNaturalHeight; + PRInt32 mDecodedX1; //Keeps track of what part of image PRInt32 mDecodedY1; // has been decoded. PRInt32 mDecodedX2; diff --git a/gfx/src/windows/nsImageWin.cpp b/gfx/src/windows/nsImageWin.cpp index 2329f3827a4c..9baa6f70ac10 100644 --- a/gfx/src/windows/nsImageWin.cpp +++ b/gfx/src/windows/nsImageWin.cpp @@ -58,6 +58,9 @@ nsImageWin :: nsImageWin() mColorMap = nsnull; mBHead = nsnull; + mNaturalWidth = 0; + mNaturalHeight = 0; + //CleanUp(PR_TRUE); CleanUpDDB(); CleanUpDIB(); @@ -98,6 +101,9 @@ nsresult nsImageWin :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMa } else { NS_ASSERTION(PR_FALSE, "unexpected image depth"); return NS_ERROR_UNEXPECTED; + + SetNaturalWidth(0); + SetNaturalHeight(0); } SetDecodedRect(0,0,0,0); //init diff --git a/gfx/src/windows/nsImageWin.h b/gfx/src/windows/nsImageWin.h index 763aee141a45..5396c2316fcf 100644 --- a/gfx/src/windows/nsImageWin.h +++ b/gfx/src/windows/nsImageWin.h @@ -69,6 +69,12 @@ public: virtual PRInt32 GetWidth() { return mBHead->biWidth; } virtual PRUint8* GetBits() { return mImageBits; } virtual PRInt32 GetLineStride() { return mRowBytes; } + + NS_IMETHOD SetNaturalWidth(PRInt32 naturalwidth) { mNaturalWidth= naturalwidth; return NS_OK;} + NS_IMETHOD SetNaturalHeight(PRInt32 naturalheight) { mNaturalHeight= naturalheight; return NS_OK;} + virtual PRInt32 GetNaturalWidth() {return mNaturalWidth; } + virtual PRInt32 GetNaturalHeight() {return mNaturalHeight; } + NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2); virtual PRInt32 GetDecodedX1() { return mDecodedX1;} @@ -244,6 +250,9 @@ private: PRInt32 mDecodedY1; // has been decoded. PRInt32 mDecodedX2; PRInt32 mDecodedY2; + + PRInt32 mNaturalWidth; + PRInt32 mNaturalHeight; // alpha layer members PRUint8 *mAlphaBits; // alpha layer if we made one diff --git a/gfx/src/xlib/nsImageXlib.cpp b/gfx/src/xlib/nsImageXlib.cpp index 338dddbbd1d3..83c051ea54c9 100644 --- a/gfx/src/xlib/nsImageXlib.cpp +++ b/gfx/src/xlib/nsImageXlib.cpp @@ -54,6 +54,9 @@ nsImageXlib::nsImageXlib() mLocation.y = 0; mDisplay = nsnull; mConvertedBits = nsnull; + mNaturalWidth = 0; + mNaturalHeight = 0; + } nsImageXlib::~nsImageXlib() @@ -114,6 +117,8 @@ nsresult nsImageXlib::Init(PRInt32 aWidth, PRInt32 aHeight, } SetDecodedRect(0,0,0,0); + SetNaturalWidth(0); + SetNaturalHeight(0); if (nsnull != mImagePixmap) { XFreePixmap(mDisplay, mImagePixmap); diff --git a/gfx/src/xlib/nsImageXlib.h b/gfx/src/xlib/nsImageXlib.h index 4c72c7d6cf1e..c4e484d49e05 100644 --- a/gfx/src/xlib/nsImageXlib.h +++ b/gfx/src/xlib/nsImageXlib.h @@ -45,6 +45,11 @@ public: virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; } virtual PRInt32 GetLineStride(); + NS_IMETHOD SetNaturalWidth(PRInt32 naturalwidth) { mNaturalWidth= naturalwidth; return NS_OK;} + NS_IMETHOD SetNaturalHeight(PRInt32 naturalheight) { mNaturalHeight= naturalheight; return NS_OK;} + virtual PRInt32 GetNaturalWidth() {return mNaturalWidth; } + virtual PRInt32 GetNaturalHeight() {return mNaturalHeight; } + NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2); virtual PRInt32 GetDecodedX1() { return mDecodedX1;} virtual PRInt32 GetDecodedY1() { return mDecodedY1;} @@ -157,6 +162,9 @@ private: PRInt8 mNumBytesPixel; + PRInt32 mNaturalWidth; + PRInt32 mNaturalHeight; + PRInt32 mDecodedX1; //Keeps track of what part of image PRInt32 mDecodedY1; // has been decoded. PRInt32 mDecodedX2;