XPCOM Review of imglib.

This commit is contained in:
dp%netscape.com 1999-08-10 22:41:26 +00:00
parent 904d45e5ea
commit a3a94b4e23
24 changed files with 264 additions and 331 deletions

View File

@ -58,16 +58,14 @@ mailing address.
*/
#include "if_struct.h"
#include "nsIImgDecoder.h"
#include "il.h"
#include "prmem.h"
#include "merrors.h"
#include "dllcompat.h"
#include "gif.h"
#include "nsGIFDecoder.h"
#include "nsGIFCallback.h"
#include "nsIImgDecoder.h"
#include "nsIImgDCallbk.h"
#include "ilISystemServices.h"

View File

@ -16,15 +16,14 @@
* Reserved.
*/
#if 0 // OBSOLETE
/* -*- Mode: C; tab-width: 4 -*-
* nsGIFDecoder.cpp --- interface to gif decoder
*/
#include "nsGIFCallback.h"
NS_DEFINE_IID(kGIFCallbkIID, NS_GIFCALLBK_IID);
NS_DEFINE_CID(kGIFCallbkCID, NS_GIFCALLBK_CID);
/* callbks: */
/*-------------class----------*/
@ -38,10 +37,12 @@ NS_IMETHODIMP GIFCallbk::QueryInterface(const nsIID& aIID, void** aResult)
return NS_ERROR_NULL_POINTER;
}
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIImgDCallbkIID, NS_IIMGDCALLBK_IID);
static NS_DEFINE_IID(kGIFCallbkIID, NS_GIFCALLBK_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if ( aIID.Equals(kGIFCallbkIID) ||
aIID.Equals(kImgDCallbkIID)||
aIID.Equals(kIImgDCallbkIID)||
aIID.Equals(kISupportsIID)) {
*aResult = (void*) this;
NS_INIT_REFCNT();
@ -55,3 +56,4 @@ NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
/*-----------------------------*/
#endif /* 0 */

View File

@ -16,14 +16,16 @@
* Reserved.
*/
#if 0 // OBSOLETE
/* -*- Mode: C; tab-width: 4 -*-
* nsGIFDecoder.cpp --- interface to gif decoder
*/
#ifndef _nsGIFCallbk_h
#define _nsGIFCallbk_h
#include "nsIImgDecoder.h"
#include "nsIImgDCallbk.h"
#include "nsGIFDecoder.h"
/* new gif call back stuff: */
@ -54,3 +56,4 @@ private:
};
#endif
#endif /* 0 */

View File

@ -16,36 +16,32 @@
* Reserved.
*/
/* -*- Mode: C; tab-width: 4 -*-
/*
* nsGIFDecoder.cpp --- interface to gif decoder
*/
#include "if_struct.h"
#include "prmem.h"
#include "merrors.h"
#include "dllcompat.h"
#include "gif.h"
#include "nsIImgDecoder.h" // include if_struct.h Needs to be included first
#include "nsGIFDecoder.h"
#include "nsImgDecCID.h"
#include "nsIImgDecoder.h" /* interface class */
#include "nsImgDecoder.h" /* factory */
#include "nscore.h"
#include "gif.h"
/*--- needed for autoregistry ---*/
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsIGenericFactory.h"
PR_BEGIN_EXTERN_C
extern int MK_OUT_OF_MEMORY;
PR_END_EXTERN_C
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
static NS_DEFINE_CID(kGIFDecoderCID, NS_GIFDECODER_CID);
static NS_DEFINE_IID(kIImgDecoderIID, NS_IIMGDECODER_IID);
//////////////////////////////////////////////////////////////////////
// GIF Decoder Definition
/*-----------class----------------*/
class GIFDecoder : public nsIImgDecoder
{
public:
@ -62,14 +58,18 @@ public:
NS_IMETHOD ImgDComplete();
NS_IMETHOD ImgDAbort();
il_container *SetContainer(il_container *ic){ilContainer = ic; return ic;}
il_container *GetContainer() {return ilContainer;}
NS_IMETHOD_(il_container *) SetContainer(il_container *ic){ilContainer = ic; return ic;}
NS_IMETHOD_(il_container *) GetContainer() {return ilContainer;}
private:
il_container* ilContainer;
};
/*-------------------------------------------------*/
//////////////////////////////////////////////////////////////////////
// GIF Decoder Implementation
NS_IMPL_ISUPPORTS(GIFDecoder, kIImgDecoderIID)
GIFDecoder::GIFDecoder(il_container* aContainer)
{
@ -77,183 +77,11 @@ GIFDecoder::GIFDecoder(il_container* aContainer)
ilContainer = aContainer;
};
GIFDecoder::~GIFDecoder(void)
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
};
NS_IMPL_ADDREF(GIFDecoder)
NS_IMPL_RELEASE(GIFDecoder)
NS_IMETHODIMP
GIFDecoder::QueryInterface(const nsIID& aIID, void** aInstPtr)
{
if (NULL == aInstPtr) {
return NS_ERROR_NULL_POINTER;
}
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kGIFDecoderIID) ||
aIID.Equals(kImgDecoderIID) ||
aIID.Equals(kISupportsIID)) {
*aInstPtr = (void*) this;
NS_INIT_REFCNT();
return NS_OK;
}
return NS_NOINTERFACE;
}
/*-----------class----------------*/
class nsGIFDecFactory : public nsIFactory
{
public:
NS_DECL_ISUPPORTS
nsGIFDecFactory(const nsCID &aClass);
virtual ~nsGIFDecFactory();
NS_IMETHOD CreateInstance(nsISupports *aOuter,
REFNSIID aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
protected:
private:
nsCID mClassID;
il_container *ilContainer;
};
/*-----------------------------------------*/
nsGIFDecFactory* gFactory = NULL;
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
NS_IMPL_ISUPPORTS(nsGIFDecFactory, kIFactoryIID)
nsGIFDecFactory::nsGIFDecFactory(const nsCID &aClass)
{
NS_INIT_REFCNT();
mClassID = aClass;
}
nsGIFDecFactory::~nsGIFDecFactory(void)
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
/*----------------------------------for autoregistration ----*/
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
extern "C" NS_EXPORT nsresult
NSRegisterSelf(nsISupports* aServMgr, const char *path)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
if ((rv = nsRepository::RegisterComponent(kGIFDecoderCID,
"Netscape GIFDec",
"component://netscape/image/decoder&type=image/gif", path, PR_TRUE, PR_TRUE)
) != NS_OK) {
return rv;
}
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char *path)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
rv = compMgr->UnregisterComponent(kGIFDecoderCID, path);
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}
/*--------------------*/
NS_IMETHODIMP
nsGIFDecFactory::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **ppv)
{
GIFDecoder *gifdec = NULL;
*ppv = NULL;
il_container* ic = NULL;
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aOuter && !aIID.Equals(kISupportsIID))
return NS_NOINTERFACE;
ic = new il_container();
gifdec = new GIFDecoder(ic);
nsresult res = gifdec->QueryInterface(aIID,(void**)ppv);
//interface is other than nsISupports and gifdecoder
if (NS_FAILED(res)) {
*ppv = NULL;
delete gifdec;
}
delete ic; /* is a place holder */
return res;
}
NS_METHOD
nsGIFDecFactory::LockFactory(PRBool aLock)
{
return NS_OK;
}
extern "C" NS_EXPORT nsresult
NSGetFactory(nsISupports* serviceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if( !aClass.Equals(kGIFDecoderCID))
return NS_ERROR_FACTORY_NOT_REGISTERED;
if( gFactory == NULL){
gFactory = new nsGIFDecFactory(aClass);
if( gFactory == NULL)
return NS_ERROR_OUT_OF_MEMORY;
gFactory->AddRef(); //for global
}
gFactory->AddRef(); //for client
*aFactory = gFactory;
return NS_OK;
}
/*----------------------------------------------------*/
// api functions
/*------------------------------------------------------*/
NS_IMETHODIMP
GIFDecoder::ImgDInit()
{
@ -301,5 +129,110 @@ GIFDecoder::ImgDAbort()
}
return 0;
}
//////////////////////////////////////////////////////////////////////
// GIF Decoder Factory using nsIGenericFactory
static NS_IMETHODIMP
nsGIFDecoderCreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
GIFDecoder *gifdec = NULL;
*aResult = NULL;
il_container* ic = NULL;
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aOuter && !aIID.Equals(kISupportsIID))
return NS_NOINTERFACE;
ic = new il_container();
if (!ic)
{
return NS_ERROR_OUT_OF_MEMORY;
}
gifdec = new GIFDecoder(ic);
if (!gifdec)
{
delete ic;
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult res = gifdec->QueryInterface(aIID, aResult);
if (NS_FAILED(res))
{
*aResult = NULL;
delete gifdec;
}
delete ic; /* is a place holder */
return res;
}
//////////////////////////////////////////////////////////////////////
// Module Object Creation Entry points
extern "C" NS_EXPORT nsresult
NSGetFactory(nsISupports* serviceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if( !aClass.Equals(kGIFDecoderCID))
return NS_ERROR_FACTORY_NOT_REGISTERED;
nsCOMPtr<nsIGenericFactory> fact;
nsresult rv = NS_NewGenericFactory(getter_AddRefs(fact), nsGIFDecoderCreateInstance);
if (NS_FAILED(rv)) return rv;
rv = fact->QueryInterface(kIFactoryIID, (void **)aFactory);
return rv;
}
//////////////////////////////////////////////////////////////////////
// Module Registration Entrypoints
extern "C" NS_EXPORT nsresult
NSRegisterSelf(nsISupports* aServMgr, const char *path)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
if ((rv = compMgr->RegisterComponent(kGIFDecoderCID,
"Netscape GIFDec",
"component://netscape/image/decoder&type=image/gif", path, PR_TRUE, PR_TRUE)
) != NS_OK) {
return rv;
}
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char *path)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
rv = compMgr->UnregisterComponent(kGIFDecoderCID, path);
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
}

View File

@ -22,7 +22,6 @@
#ifndef _nsGIFDec_h
#define _nsGIFDec_h
#define NS_GIFDECODER_CID \
{ 0x0d471b70, 0xbaf5, 0x11d2, \
{ 0x80, 0x2c, 0x00, 0x60, 0x08, 0x8f, 0x91, 0xa3 } }
@ -32,9 +31,4 @@
{ 0x402b190, 0xbbd0, 0x11d2, \
{ 0x80, 0x2c, 0x00, 0x60, 0x08, 0x8f, 0x91, 0xa3 } }
static NS_DEFINE_IID(kGIFDecoderIID, NS_GIFDECODER_IID);
static NS_DEFINE_CID(kGIFDecoderCID, NS_GIFDECODER_CID);
#endif

View File

@ -18,19 +18,15 @@
/*
* jpeg.c --- Glue code to Independent JPEG Group decoder library
* $Id: jpeg.cpp,v 1.4 1999/07/07 19:22:00 pnunn%netscape.com Exp $
* $Id: jpeg.cpp,v 1.5 1999/08/10 22:39:49 dp%netscape.com Exp $
*/
#include "if_struct.h"
#include "nsIImgDecoder.h" // include if_struct.h Needs to be first
#include "nsIImgDCallbk.h"
#include "dllcompat.h"
#include "nsIImgDecoder.h"
#include "nsImgDecCID.h"
#include "nsJPGDecoder.h"
#include "nsJPGCallback.h"
#include "jpeg.h"
#include "merrors.h"
#include "il.h"

View File

@ -21,7 +21,7 @@
*/
#if 0 // OBSOLETE
#include "nsJPGCallback.h"
@ -32,3 +32,4 @@ NS_IMPL_ISUPPORTS(JPGCallbk, kImgDCallbkIID)
/*-----------------------------*/
#endif /* 0 */

View File

@ -16,13 +16,15 @@
* Reserved.
*/
#if 0 // OBSOLETE
/* -*- Mode: C; tab-width: 4 -*-
* nsJPGDecoder.cpp --- interface to jpg decoder
*/
#ifndef _nsJPGCallbk_h
#define _nsJPGCallbk_h
#include "nsIImgDCallbk.h"
#include "nsIImgDecoder.h"
#include "nsJPGDecoder.h"
@ -54,3 +56,5 @@ private:
};
#endif
#endif /* 0 */

View File

@ -21,7 +21,7 @@
*/
#include "if_struct.h"
#include "nsIImgDecoder.h" // include if_struct.h Needs to be first
#include "jpeg.h"
#include "prmem.h"
#include "merrors.h"
@ -29,9 +29,6 @@
#include "dllcompat.h"
#include "nsJPGDecoder.h"
#include "nsImgDecCID.h"
#include "nsIImgDecoder.h" /* interface class */
#include "nsImgDecoder.h" /* factory */
#include "nscore.h"
/*--- needed for autoregistry ---*/
@ -62,8 +59,8 @@ public:
NS_IMETHOD ImgDComplete();
NS_IMETHOD ImgDAbort();
il_container *SetContainer(il_container *ic){ilContainer = ic; return ic;}
il_container *GetContainer() {return ilContainer;}
NS_IMETHOD_(il_container *) SetContainer(il_container *ic){ilContainer = ic; return ic;}
NS_IMETHOD_(il_container *) GetContainer() {return ilContainer;}
private:
@ -94,10 +91,11 @@ JPGDecoder::QueryInterface(const nsIID& aIID, void** aInstPtr)
return NS_ERROR_NULL_POINTER;
}
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
NS_DEFINE_IID(kIImgDecoderIID, NS_IIMGDECODER_IID);
if (aIID.Equals(kJPGDecoderIID) ||
aIID.Equals(kImgDecoderIID) ||
aIID.Equals(kIImgDecoderIID) ||
aIID.Equals(kISupportsIID)) {
*aInstPtr = (void*) this;
NS_INIT_REFCNT();
@ -124,7 +122,7 @@ NSRegisterSelf(nsISupports* aServMgr, const char *path)
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
if ((rv = nsRepository::RegisterComponent(kJPGDecoderCID, "Netscape JPGDec", "component://netscape/image/decoder&type=image/jpeg", path, PR_TRUE, PR_TRUE)
if ((rv = compMgr->RegisterComponent(kJPGDecoderCID, "Netscape JPGDec", "component://netscape/image/decoder&type=image/jpeg", path, PR_TRUE, PR_TRUE)
) != NS_OK) {
return rv;
}

View File

@ -17,17 +17,16 @@
*/
#include "png.h"
#include "nsIImgDecoder.h" // include if_struct.h Needs to be first
#include "if_struct.h"
#include "ipng.h"
#include "dllcompat.h"
#include "pngdec.h"
#include "nsIImgDecoder.h"
#include "nsPNGDecoder.h"
#include "nsPNGCallback.h"
#include "nsIImgDCallbk.h"
#include "ilISystemServices.h"
#define OK 1

View File

@ -16,6 +16,8 @@
* Reserved.
*/
#if 0 // OBSOLETE
/* -*- Mode: C; tab-width: 4 -*-
* nsPNGDecoder.cpp --- interface to png decoder
*/
@ -32,3 +34,4 @@ NS_IMPL_ISUPPORTS(PNGCallbk, kImgDCallbkIID)
/*-----------------------------*/
#endif /* 0 */

View File

@ -16,6 +16,8 @@
* Reserved.
*/
#if 0 // OBSOLETE
/* -*- Mode: C; tab-width: 4 -*-
* nsPNGDecoder.cpp --- interface to png decoder
*/
@ -54,3 +56,4 @@ private:
};
#endif
#endif /* 0 */

View File

@ -21,7 +21,7 @@
*/
#include "if_struct.h"
#include "nsIImgDecoder.h" // include if_struct.h Needs to be first
#include "prmem.h"
#include "merrors.h"
@ -29,9 +29,6 @@
#include "dllcompat.h"
#include "pngdec.h"
#include "nsPNGDecoder.h"
#include "nsImgDecCID.h"
#include "nsIImgDecoder.h" /* interface class */
#include "nsImgDecoder.h" /* factory */
#include "nscore.h"
/*--- needed for autoregistry ---*/
@ -62,8 +59,8 @@ public:
NS_IMETHOD ImgDComplete();
NS_IMETHOD ImgDAbort();
il_container *SetContainer(il_container *ic){ilContainer = ic; return ic;}
il_container *GetContainer() {return ilContainer;}
NS_IMETHOD_(il_container *) SetContainer(il_container *ic){ilContainer = ic; return ic;}
NS_IMETHOD_(il_container *) GetContainer() {return ilContainer;}
private:
@ -91,10 +88,11 @@ PNGDecoder::QueryInterface(const nsIID& aIID, void** aInstPtr)
return NS_ERROR_NULL_POINTER;
}
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
NS_DEFINE_IID(kIImgDecoderIID, NS_IIMGDECODER_IID);
if (aIID.Equals(kPNGDecoderIID) ||
aIID.Equals(kImgDecoderIID) ||
aIID.Equals(kIImgDecoderIID) ||
aIID.Equals(kISupportsIID)) {
*aInstPtr = (void*) this;
NS_INIT_REFCNT();
@ -163,7 +161,7 @@ NSRegisterSelf(nsISupports* aServMgr, const char *path)
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
if ((rv = nsRepository::RegisterComponent(kPNGDecoderCID,
if ((rv = compMgr->RegisterComponent(kPNGDecoderCID,
"Netscape PNGDec",
"component://netscape/image/decoder&type=image/png", path, PR_TRUE, PR_TRUE)
) != NS_OK) {

View File

@ -19,12 +19,11 @@
/* png_png.c - modified from example.c code */
#include "png.h"
#include "if_struct.h"
#include "nsIImgDecoder.h" // include if_struct.h Needs to be first
#include "ipng.h"
#include "nsIImgDecoder.h"
#include "nsPNGDecoder.h"
#include "nsPNGCallback.h"
#include "nsIImgDCallbk.h"
#define OK 1
#define ERROR -1

View File

@ -8,5 +8,4 @@ il.h
il_utilp.h
nsIImgDecoder.h
nsImgDCallbk.h
nsImgDecCID.h
nsImgDecoder.h
nsIImgDCallbk.h

View File

@ -30,10 +30,11 @@ include $(DEPTH)/config/autoconf.mk
MODULE = img
EXPORTS = il.h dllcompat.h if_struct.h il_utilp.h \
nsIImgDecoder.h nsImgDecCID.h nsImgDecoder.h \
nsImgDCallbk.h \
$(NULL)
# XXX nsImgDCallbk.h should go into libimg/src instead of being here
EXPORTS = il.h dllcompat.h if_struct.h il_utilp.h \
nsIImgDecoder.h nsIImgDCallbk.h \
nsImgDCallbk.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

View File

@ -40,7 +40,7 @@ LCFLAGS = $(LCFLAGS) /TP
MODULE=img
DEPTH=..\..\..
EXPORTS= if_struct.h dllcompat.h il.h il_utilp.h \
nsIImgDecoder.h nsImgDCallbk.h nsImgDecCID.h nsImgDecoder.h
nsIImgDecoder.h nsIImgDCallbk.h nsImgDCallbk.h
include <$(DEPTH)/config/rules.mak>

View File

@ -0,0 +1,57 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "dllcompat.h" // for TimeoutCallbackFunction
#include "nsISupports.h"
/* d34a2f20-cd9f-11d2-802c-0060088f91a3 */
#define NS_IIMGDCALLBK_IID \
{ 0xd34a2f20, 0xcd9f, 0x11d2, \
{ 0x80, 0x2c, 0x00, 0x60, 0x08, 0x8f, 0x91, 0xa3 } }
class nsIImgDCallbk : public nsISupports
{
public:
NS_IMETHOD ImgDCBFlushImage()=0;
NS_IMETHOD ImgDCBImageSize()=0;
NS_IMETHOD ImgDCBResetPalette()=0;
NS_IMETHOD ImgDCBInitTransparentPixel()=0;
NS_IMETHOD ImgDCBDestroyTransparentPixel()=0;
NS_IMETHOD ImgDCBSetupColorspaceConverter()=0;
NS_IMETHOD_(NI_ColorSpace *) ImgDCBCreateGreyScaleColorSpace()=0;
NS_IMETHOD_(void*) ImgDCBSetTimeout(TimeoutCallbackFunction func, void* closure, uint32 msecs)=0;
NS_IMETHOD ImgDCBClearTimeout(void *timer_id)=0;
NS_IMETHOD ImgDCBHaveHdr(int destwidth, int destheight )=0;
NS_IMETHOD ImgDCBHaveRow(uint8 *rowbuf, uint8* rgbrow, int x_offset, int len,
int row, int dup_rowcnt, uint8 draw_mode,
int pass )=0;
NS_IMETHOD ImgDCBHaveImageFrame()=0;
NS_IMETHOD ImgDCBHaveImageAll()=0;
NS_IMETHOD ImgDCBError()=0;
private:
void *ilContainer;
};

View File

@ -19,12 +19,16 @@
#ifndef _nsIImgDecoder_h
#define _nsIImgDecoder_h
#include "if_struct.h"
#include "if_struct.h" // for il_container
#include "ni_pixmp.h"
#include "nsISupports.h"
#include "nsImgDecCID.h"
/* f00c22b0-bbd2-11d2-802c-0060088f91a3 */
#define NS_IIMGDECODER_IID \
{ 0xf00c22b0, 0xbbd2, 0x11d2, \
{ 0x80, 0x2c, 0x00, 0x60, 0x08, 0x8f, 0x91, 0xa3 } }
#define NS_IIMGDECODER_BASE_PROGID "component://netscape/image/decoder&type="
class nsIImgDecoder : public nsISupports
{
@ -37,43 +41,9 @@ public:
NS_IMETHOD ImgDComplete()=0;
NS_IMETHOD ImgDAbort()=0;
private:
void *ilContainer;
};
NS_DEFINE_IID(kImgDCallbkIID, NS_IMGDCALLBK_IID);
NS_DEFINE_CID(kImgDCallbkCID, NS_IMGDCALLBK_CID);
class nsIImgDCallbk : public nsISupports
{
public:
NS_IMETHOD ImgDCBFlushImage()=0;
NS_IMETHOD ImgDCBImageSize()=0;
NS_IMETHOD ImgDCBResetPalette()=0;
NS_IMETHOD ImgDCBInitTransparentPixel()=0;
NS_IMETHOD ImgDCBDestroyTransparentPixel()=0;
NS_IMETHOD ImgDCBSetupColorspaceConverter()=0;
NS_IMETHOD_(NI_ColorSpace *) ImgDCBCreateGreyScaleColorSpace()=0;
NS_IMETHOD_(void*) ImgDCBSetTimeout(TimeoutCallbackFunction func, void* closure, uint32 msecs)=0;
NS_IMETHOD ImgDCBClearTimeout(void *timer_id)=0;
NS_IMETHOD ImgDCBHaveHdr(int destwidth, int destheight )=0;
NS_IMETHOD ImgDCBHaveRow(uint8 *rowbuf, uint8* rgbrow, int x_offset, int len,
int row, int dup_rowcnt, uint8 draw_mode,
int pass )=0;
NS_IMETHOD ImgDCBHaveImageFrame()=0;
NS_IMETHOD ImgDCBHaveImageAll()=0;
NS_IMETHOD ImgDCBError()=0;
private:
void *ilContainer;
// XXX Need to fix this to make sure return type is nsresult
NS_IMETHOD_(il_container *) SetContainer(il_container *ic) = 0;
NS_IMETHOD_(il_container *) GetContainer() = 0;
};

View File

@ -20,8 +20,9 @@
*
*/
// XXX This file needs to move to libimg/src - dp
#include "nsIImgDecoder.h"
#include "nsIImgDCallbk.h"
/*---------------------------------------------*/
/*-----------------class-----------------------*/

View File

@ -16,6 +16,8 @@
* Reserved.
*/
#if 0 // OBSOLETE
#ifndef nsImgDecCIID_h__
#define nsImgDecCIID_h__
@ -54,8 +56,5 @@ NS_DEFINE_IID(kImgDecoderCID, NS_IMGDECODER_CID);
{ 0xd34a2f20, 0xcd9f, 0x11d2, \
{ 0x80, 0x2c, 0x00, 0x60, 0x08, 0x8f, 0x91, 0xa3 } }
#endif
#endif /* 0 */

View File

@ -16,6 +16,7 @@
* Reserved.
*/
#if 0 // OBSOLETE
#ifndef nsImgDec_h___
#define nsImgDec_h___
@ -24,3 +25,4 @@
#include "nsIFactory.h"
#endif
#endif /* 0 */

View File

@ -26,9 +26,9 @@
#include "nsIImgDecoder.h"
#include "nsImgDCallbk.h"
#include "nsIComponentManager.h"
#include "xpcompat.h"
#include "nsImgDecCID.h"
#include "prtypes.h"
#include "il_strm.h"
@ -52,33 +52,6 @@ int il_debug=0;
/* Global list of image group contexts. */
static IL_GroupContext *il_global_img_cx_list = NULL;
/*-------------------------------------------------*/
class ImgDecoder : public nsIImgDecoder {
public:
NS_DECL_ISUPPORTS
il_container *GetContainer() {return ilContainer;};
il_container *SetContainer(il_container *ic) {ilContainer=ic; return ic;};
ImgDecoder(il_container *aContainer){ NS_INIT_ISUPPORTS(); ilContainer=aContainer;};
virtual ~ImgDecoder();
private:
il_container* ilContainer;
};
NS_IMPL_ISUPPORTS(ImgDecoder, kImgDecoderIID)
ImgDecoder:: ~ImgDecoder()
{
if(ilContainer)
delete ilContainer;
return;
}
/*-----------------------------------------*/
/*-----------------------------------------*/
NS_IMETHODIMP ImgDCallbk::ImgDCBSetupColorspaceConverter()
{
@ -212,8 +185,6 @@ ImgDCallbk :: ImgDCBClearTimeout(void *timer_id)
return 0;
}
/*-------------------------------------------------*/
ImgDecoder *imgdec;
/*********************** Image Observer Notification. *************************
*
* These functions are used to send messages to registered observers of an
@ -1045,7 +1016,7 @@ IL_StreamFirstWrite(il_container *ic, const unsigned char *str, int32 len)
ic->expires = ic->url->GetExpires();
ImgDecoder *imgdec;
nsIImgDecoder *imgdec;
char imgtype[150];
char imgtypestr[200];
@ -1061,18 +1032,18 @@ IL_StreamFirstWrite(il_container *ic, const unsigned char *str, int32 len)
sprintf(imgtypestr, "component://netscape/image/decoder&type=image/%s"
, imgtype );
result = nsRepository::CreateInstance(imgtypestr,
NULL,
kImgDecoderIID,
(void **)&imgdec);
static NS_DEFINE_IID(kIImgDecoderIID, NS_IIMGDECODER_IID);
result = nsComponentManager::CreateInstance(imgtypestr, NULL,
kIImgDecoderIID, // XXX was previously kImgDecoderIID
(void **)&imgdec);
if (NS_FAILED(result))
return MK_IMAGE_LOSSAGE;
NS_ADDREF(imgdec);
imgdec->SetContainer(ic);
// NS_ADDREF(imgdec); Dont need this as we aren't releasing the addref from CreateInstance
ic->imgdec = imgdec;
ret = imgdec->ImgDInit();

View File

@ -20,7 +20,7 @@
* ilclient.c --- Management of imagelib client data structures,
* including image cache.
*
* $Id: ilclient.cpp,v 3.10 1999/06/09 20:19:29 pnunn%netscape.com Exp $
* $Id: ilclient.cpp,v 3.11 1999/08/10 22:41:26 dp%netscape.com Exp $
*/
@ -29,6 +29,7 @@
#include "nsIImgDecoder.h"
#include "nsImgDCallbk.h"
#include "ilISystemServices.h"
#include "nsIFactory.h"
/* for XP_GetString() */
#include "xpgetstr.h"
@ -80,8 +81,9 @@ struct il_cache_struct il_cache;
/*-------------------------------*/
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
NS_DEFINE_IID(kIImgDCallbkIID, NS_IIMGDCALLBK_IID);
NS_IMPL_ISUPPORTS(ImgDCallbk, kImgDCallbkIID)
NS_IMPL_ISUPPORTS(ImgDCallbk, kIImgDCallbkIID)
NS_IMETHODIMP
ImgDCallbk::CreateInstance(const nsCID &aClass,
@ -567,7 +569,7 @@ il_get_container(IL_GroupContext *img_cx,
NS_ADDREF(imgdcb);
nsresult res = imgdcb->QueryInterface(kImgDCallbkIID, (void**)&imgdcb);
nsresult res = imgdcb->QueryInterface(kIImgDCallbkIID, (void**)&imgdcb);
if (NS_FAILED(res)) {
if(imgdcb)