From b2cad21092bc5f1c7fece179a5628c9904932ecd Mon Sep 17 00:00:00 2001 From: "pavlov%netscape.com" Date: Sat, 13 Jan 2001 02:59:24 +0000 Subject: [PATCH] renaming nsIImage to nsIImage2 for now... --- gfx2/public/Makefile.in | 2 +- gfx2/public/makefile.win | 2 +- gfx2/public/{nsIImage.idl => nsIImage2.idl} | 2 +- gfx2/src/windows/nsImage.cpp | 208 ++++++++++---------- gfx2/src/windows/nsImage.h | 6 +- gfx2/src/xlib/nsImage.cpp | 2 +- gfx2/src/xlib/nsImage.h | 6 +- 7 files changed, 117 insertions(+), 111 deletions(-) rename gfx2/public/{nsIImage.idl => nsIImage2.idl} (99%) diff --git a/gfx2/public/Makefile.in b/gfx2/public/Makefile.in index 6c8a9a0206b4..fea88bc664ab 100644 --- a/gfx2/public/Makefile.in +++ b/gfx2/public/Makefile.in @@ -32,7 +32,7 @@ XPIDL_MODULE = gfx2 XPIDLSRCS = \ gfxtypes.idl \ - nsIImage.idl \ + nsIImage2.idl \ $(NULL) EXPORTS = \ diff --git a/gfx2/public/makefile.win b/gfx2/public/makefile.win index f382ce6d45e5..d37f8c97cae7 100644 --- a/gfx2/public/makefile.win +++ b/gfx2/public/makefile.win @@ -29,7 +29,7 @@ XPIDL_MODULE = gfx2 XPIDLSRCS = \ .\gfxtypes.idl \ - .\nsIImage.idl \ + .\nsIImage2.idl \ $(NULL) EXPORTS = \ diff --git a/gfx2/public/nsIImage.idl b/gfx2/public/nsIImage2.idl similarity index 99% rename from gfx2/public/nsIImage.idl rename to gfx2/public/nsIImage2.idl index 97cf5df5384b..dc25dd884b7c 100644 --- a/gfx2/public/nsIImage.idl +++ b/gfx2/public/nsIImage2.idl @@ -35,7 +35,7 @@ interface nsIDrawable; * @see "gfx2" */ [scriptable, uuid(5e8405a4-1dd2-11b2-8385-bc8e3446cad3)] -interface nsIImage : nsISupports +interface nsIImage2 : nsISupports { /** * Create a new \a aWidth x \a aHeight sized image. diff --git a/gfx2/src/windows/nsImage.cpp b/gfx2/src/windows/nsImage.cpp index 583c1ddad85b..b2e7fedd47dd 100644 --- a/gfx2/src/windows/nsImage.cpp +++ b/gfx2/src/windows/nsImage.cpp @@ -25,7 +25,7 @@ #include "nsUnitConverters.h" -NS_IMPL_ISUPPORTS1(nsImage, nsIImage) +NS_IMPL_ISUPPORTS1(nsImage, nsIImage2) nsImage::nsImage() : mBits(nsnull) @@ -41,103 +41,7 @@ nsImage::~nsImage() mBits = nsnull; } -/* void init (in gfx_dimension aWidth, in gfx_dimension aHeight, in gfx_format aFormat); */ -NS_IMETHODIMP nsImage::Init(gfx_dimension aWidth, gfx_dimension aHeight, gfx_format aFormat) -{ - if (aWidth <= 0 || aHeight <= 0) { - printf("error - negative image size\n"); - return NS_ERROR_FAILURE; - } - delete[] mBits; - - mSize.SizeTo(aWidth, aHeight); - mFormat = aFormat; - - switch (aFormat) { - case nsIGFXFormat::RGB: - case nsIGFXFormat::RGB_A1: - case nsIGFXFormat::RGB_A8: - mDepth = 24; - break; - case nsIGFXFormat::RGBA: - mDepth = 32; - break; - default: - printf("unsupposed gfx_format\n"); - break; - } - - PRInt32 ceilWidth(GFXCoordToIntCeil(mSize.width)); - - mBytesPerRow = (ceilWidth * mDepth) >> 5; - - if ((ceilWidth * mDepth) & 0x1F) - mBytesPerRow++; - mBytesPerRow <<= 2; - - mBitsLength = mBytesPerRow * GFXCoordToIntCeil(mSize.height); - - mBits = new PRUint8[mBitsLength]; - - return NS_OK; -} - -/* void initFromDrawable (in nsIDrawable aDrawable, in gfx_coord aX, in gfx_coord aY, in gfx_dimension aWidth, in gfx_dimension aHeight); */ -NS_IMETHODIMP nsImage::InitFromDrawable(nsIDrawable *aDrawable, gfx_coord aX, gfx_coord aY, gfx_dimension aWidth, gfx_dimension aHeight) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* readonly attribute gfx_dimension width; */ -NS_IMETHODIMP nsImage::GetWidth(gfx_dimension *aWidth) -{ - if (!mBits) - return NS_ERROR_NOT_INITIALIZED; - - *aWidth = mSize.width; - return NS_OK; -} - -/* readonly attribute gfx_dimension height; */ -NS_IMETHODIMP nsImage::GetHeight(gfx_dimension *aHeight) -{ - if (!mBits) - return NS_ERROR_NOT_INITIALIZED; - - *aHeight = mSize.height; - return NS_OK; -} - -/* readonly attribute gfx_format format; */ -NS_IMETHODIMP nsImage::GetFormat(gfx_format *aFormat) -{ - if (!mBits) - return NS_ERROR_NOT_INITIALIZED; - - *aFormat = mFormat; - return NS_OK; -} - -/* readonly attribute unsigned long bytesPerRow; */ -NS_IMETHODIMP nsImage::GetBytesPerRow(PRUint32 *aBytesPerRow) -{ - if (!mBits) - return NS_ERROR_NOT_INITIALIZED; - - *aBytesPerRow = mBytesPerRow; - return NS_OK; -} - -/* readonly attribute unsigned long bitsLength; */ -NS_IMETHODIMP nsImage::GetBitsLength(PRUint32 *aBitsLength) -{ - if (!mBits) - return NS_ERROR_NOT_INITIALIZED; - - *aBitsLength = mBitsLength; - return NS_OK; -} #include @@ -223,14 +127,82 @@ void CreateBMPFile(HWND hwnd, LPTSTR pszFile, PBITMAPINFO pbi, } -/* void getBits([array, size_is(length)] out PRUint8 bits, out unsigned long length); */ -NS_IMETHODIMP nsImage::GetBits(PRUint8 **aBits, PRUint32 *length) + + +/* void init (in gfx_dimension aWidth, in gfx_dimension aHeight, in gfx_format aFormat); */ +NS_IMETHODIMP nsImage::Init(gfx_dimension aWidth, gfx_dimension aHeight, gfx_format aFormat) +{ + if (aWidth <= 0 || aHeight <= 0) { + printf("error - negative image size\n"); + return NS_ERROR_FAILURE; + } + + delete[] mBits; + + mSize.SizeTo(aWidth, aHeight); + mFormat = aFormat; + + switch (aFormat) { + case nsIGFXFormat::RGB: + case nsIGFXFormat::RGB_A1: + case nsIGFXFormat::RGB_A8: + mDepth = 24; + break; + case nsIGFXFormat::RGBA: + mDepth = 32; + break; + default: + printf("unsupposed gfx_format\n"); + break; + } + + PRInt32 ceilWidth(GFXCoordToIntCeil(mSize.width)); + + mBytesPerRow = (ceilWidth * mDepth) >> 5; + + if ((ceilWidth * mDepth) & 0x1F) + mBytesPerRow++; + mBytesPerRow <<= 2; + + mBitsLength = mBytesPerRow * GFXCoordToIntCeil(mSize.height); + + mBits = new PRUint8[mBitsLength]; + + return NS_OK; +} + +/* void initFromDrawable (in nsIDrawable aDrawable, in gfx_coord aX, in gfx_coord aY, in gfx_dimension aWidth, in gfx_dimension aHeight); */ +NS_IMETHODIMP nsImage::InitFromDrawable(nsIDrawable *aDrawable, gfx_coord aX, gfx_coord aY, gfx_dimension aWidth, gfx_dimension aHeight) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* readonly attribute gfx_dimension width; */ +NS_IMETHODIMP nsImage::GetWidth(gfx_dimension *aWidth) +{ + if (!mBits) + return NS_ERROR_NOT_INITIALIZED; + + *aWidth = mSize.width; + return NS_OK; +} + +/* readonly attribute gfx_dimension height; */ +NS_IMETHODIMP nsImage::GetHeight(gfx_dimension *aHeight) +{ + if (!mBits) + return NS_ERROR_NOT_INITIALIZED; + + *aHeight = mSize.height; + return NS_OK; +} + +/* readonly attribute gfx_format format; */ +NS_IMETHODIMP nsImage::GetFormat(gfx_format *aFormat) { if (!mBits) return NS_ERROR_NOT_INITIALIZED; - *aBits = mBits; - *length = mBitsLength; HWND bg = GetDesktopWindow(); @@ -268,6 +240,40 @@ NS_IMETHODIMP nsImage::GetBits(PRUint8 **aBits, PRUint32 *length) DeleteObject(memBM); + + *aFormat = mFormat; + return NS_OK; +} + +/* readonly attribute unsigned long bytesPerRow; */ +NS_IMETHODIMP nsImage::GetBytesPerRow(PRUint32 *aBytesPerRow) +{ + if (!mBits) + return NS_ERROR_NOT_INITIALIZED; + + *aBytesPerRow = mBytesPerRow; + return NS_OK; +} + +/* readonly attribute unsigned long bitsLength; */ +NS_IMETHODIMP nsImage::GetBitsLength(PRUint32 *aBitsLength) +{ + if (!mBits) + return NS_ERROR_NOT_INITIALIZED; + + *aBitsLength = mBitsLength; + return NS_OK; +} + +/* void getBits([array, size_is(length)] out PRUint8 bits, out unsigned long length); */ +NS_IMETHODIMP nsImage::GetBits(PRUint8 **aBits, PRUint32 *length) +{ + if (!mBits) + return NS_ERROR_NOT_INITIALIZED; + + *aBits = mBits; + *length = mBitsLength; + return NS_OK; } diff --git a/gfx2/src/windows/nsImage.h b/gfx2/src/windows/nsImage.h index 3ab865fcaa67..6b3ebf17ecc5 100644 --- a/gfx2/src/windows/nsImage.h +++ b/gfx2/src/windows/nsImage.h @@ -21,7 +21,7 @@ * Stuart Parmenter */ -#include "nsIImage.h" +#include "nsIImage2.h" #include "nsSize2.h" @@ -29,11 +29,11 @@ {0x73c72e6c, 0x1dd2, 0x11b2, \ { 0x98, 0xb7, 0xae, 0x59, 0x35, 0xee, 0x63, 0xf5 }} -class nsImage : public nsIImage +class nsImage : public nsIImage2 { public: NS_DECL_ISUPPORTS - NS_DECL_NSIIMAGE + NS_DECL_NSIIMAGE2 nsImage(); virtual ~nsImage(); diff --git a/gfx2/src/xlib/nsImage.cpp b/gfx2/src/xlib/nsImage.cpp index 2b9b214fd4a9..d272aa7fdcd3 100644 --- a/gfx2/src/xlib/nsImage.cpp +++ b/gfx2/src/xlib/nsImage.cpp @@ -25,7 +25,7 @@ #include "nsUnitConverters.h" -NS_IMPL_ISUPPORTS1(nsImage, nsIImage) +NS_IMPL_ISUPPORTS1(nsImage, nsIImage2) nsImage::nsImage() : mBits(nsnull) diff --git a/gfx2/src/xlib/nsImage.h b/gfx2/src/xlib/nsImage.h index 3ab865fcaa67..6b3ebf17ecc5 100644 --- a/gfx2/src/xlib/nsImage.h +++ b/gfx2/src/xlib/nsImage.h @@ -21,7 +21,7 @@ * Stuart Parmenter */ -#include "nsIImage.h" +#include "nsIImage2.h" #include "nsSize2.h" @@ -29,11 +29,11 @@ {0x73c72e6c, 0x1dd2, 0x11b2, \ { 0x98, 0xb7, 0xae, 0x59, 0x35, 0xee, 0x63, 0xf5 }} -class nsImage : public nsIImage +class nsImage : public nsIImage2 { public: NS_DECL_ISUPPORTS - NS_DECL_NSIIMAGE + NS_DECL_NSIIMAGE2 nsImage(); virtual ~nsImage();