mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
More module work
This commit is contained in:
parent
c37ecb974c
commit
c6755bdb81
@ -30,6 +30,7 @@ REQUIRES += util jpeg xpcom img
|
||||
CPPSRCS = \
|
||||
jpeg.cpp \
|
||||
nsJPGDecoder.cpp \
|
||||
nsJPGModule.cpp \
|
||||
dllcompat.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
/*
|
||||
* jpeg.c --- Glue code to Independent JPEG Group decoder library
|
||||
* $Id: jpeg.cpp,v 1.5 1999/08/10 22:39:49 dp%netscape.com Exp $
|
||||
* $Id: jpeg.cpp,v 1.6 1999/09/30 21:17:40 kipp%netscape.com Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -201,14 +201,14 @@ boolean PR_CALLBACK
|
||||
fill_input_buffer (j_decompress_ptr jd)
|
||||
{
|
||||
il_source_mgr *src = (il_source_mgr *)jd->src;
|
||||
enum data_source_state data_source_state = src->state;
|
||||
enum data_source_state src_state = src->state;
|
||||
uint32 bytesToSkip, new_backtrack_buflen, new_buflen, roundup_buflen;
|
||||
unsigned char *new_buffer;
|
||||
|
||||
ILTRACE(5,("il:jpeg: fill, state=%d, nib=0x%x, bib=%d", data_source_state,
|
||||
ILTRACE(5,("il:jpeg: fill, state=%d, nib=0x%x, bib=%d", src_state,
|
||||
src->pub.next_input_byte, src->pub.bytes_in_buffer));
|
||||
|
||||
switch (data_source_state) {
|
||||
switch (src_state) {
|
||||
|
||||
/* Decompressor reached end of backtrack buffer. Return netlib buffer.*/
|
||||
case dss_consuming_backtrack_buffer:
|
||||
|
@ -85,8 +85,13 @@ DEPTH=..\..\..
|
||||
LINCS=-I$(DEPTH)/dist/public/xpcom -I. -I$(DEPTH)/dist/public/raptor -I$(DEPTH)/dist/public/jpeg
|
||||
REQUIRES=nspr xpcom util raptor jpeg
|
||||
CPPSRCS= nsJPGDecoder.cpp nsJPGCallback.cpp jpeg.cpp dllcompat.cpp
|
||||
CPP_OBJS= .\$(OBJDIR)\nsJPGDecoder.obj .\$(OBJDIR)\dllcompat.obj \
|
||||
.\$(OBJDIR)\jpeg.obj
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsJPGDecoder.obj \
|
||||
.\$(OBJDIR)\nsJPGModule.obj \
|
||||
.\$(OBJDIR)\dllcompat.obj \
|
||||
.\$(OBJDIR)\jpeg.obj \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
|
@ -43,29 +43,6 @@ PR_END_EXTERN_C
|
||||
|
||||
|
||||
/*-----------class----------------*/
|
||||
class JPGDecoder : public nsIImgDecoder
|
||||
{
|
||||
public:
|
||||
JPGDecoder(il_container* aContainer);
|
||||
virtual ~JPGDecoder();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* stream */
|
||||
NS_IMETHOD ImgDInit();
|
||||
|
||||
NS_IMETHOD ImgDWriteReady(PRUint32 *max_read);
|
||||
NS_IMETHOD ImgDWrite(const unsigned char *buf, int32 len);
|
||||
NS_IMETHOD ImgDComplete();
|
||||
NS_IMETHOD ImgDAbort();
|
||||
|
||||
NS_IMETHOD_(il_container *) SetContainer(il_container *ic){ilContainer = ic; return ic;}
|
||||
NS_IMETHOD_(il_container *) GetContainer() {return ilContainer;}
|
||||
|
||||
|
||||
private:
|
||||
il_container* ilContainer;
|
||||
};
|
||||
/*-------------------------------------------------*/
|
||||
|
||||
JPGDecoder::JPGDecoder(il_container* aContainer)
|
||||
@ -84,6 +61,8 @@ JPGDecoder::~JPGDecoder(void)
|
||||
NS_IMPL_ADDREF(JPGDecoder)
|
||||
NS_IMPL_RELEASE(JPGDecoder)
|
||||
|
||||
static NS_DEFINE_IID(kJPGDecoderIID, NS_JPGDECODER_IID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
JPGDecoder::QueryInterface(const nsIID& aIID, void** aInstPtr)
|
||||
{
|
||||
@ -104,151 +83,6 @@ JPGDecoder::QueryInterface(const nsIID& aIID, void** aInstPtr)
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------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 = compMgr->RegisterComponent(kJPGDecoderCID, "Netscape JPGDec", "component://netscape/image/decoder&type=image/jpeg", 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(kJPGDecoderCID, path);
|
||||
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
/*-----------class----------------*/
|
||||
class nsJPGDecFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsJPGDecFactory(const nsCID &aClass);
|
||||
virtual ~nsJPGDecFactory();
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
nsCID mClassID;
|
||||
il_container *ilContainer;
|
||||
};
|
||||
|
||||
/*-----------------------------------------*/
|
||||
|
||||
static nsJPGDecFactory* gFactory = NULL;
|
||||
|
||||
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
NS_IMPL_ISUPPORTS(nsJPGDecFactory, kIFactoryIID);
|
||||
|
||||
|
||||
nsJPGDecFactory::nsJPGDecFactory(const nsCID &aClass)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mClassID = aClass;
|
||||
}
|
||||
|
||||
nsJPGDecFactory::~nsJPGDecFactory(void)
|
||||
{
|
||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJPGDecFactory::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **ppv)
|
||||
{
|
||||
JPGDecoder *jpgdec = 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();
|
||||
|
||||
jpgdec = new JPGDecoder(ic);
|
||||
nsresult res = jpgdec->QueryInterface(aIID,(void**)ppv);
|
||||
//interface is other than nsISupports and gifdecoder
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
*ppv = NULL;
|
||||
delete jpgdec;
|
||||
}
|
||||
delete ic; /* is a place holder */
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD
|
||||
nsJPGDecFactory::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(kJPGDecoderCID))
|
||||
return NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
if( gFactory == NULL){
|
||||
gFactory = new nsJPGDecFactory(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
|
||||
*/
|
||||
|
@ -15,12 +15,10 @@
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsJPGDecoder_h___
|
||||
#define nsJPGDecoder_h___
|
||||
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* nsJPGDecoder.cpp --- interface to gif decoder
|
||||
*/
|
||||
#ifndef _nsJPGDec_h
|
||||
#define _nsJPGDec_h
|
||||
#include "nsIImgDecoder.h"
|
||||
|
||||
/* 1b0e6b90-d68a-11d2-802e-0060088f91a3 */
|
||||
#define NS_JPGDECODER_CID \
|
||||
@ -32,8 +30,28 @@
|
||||
{ 0x394711e0, 0xd68a, 0x11d2, \
|
||||
{ 0x80, 0x2c, 0x00, 0x60, 0x08, 0x8f, 0x91, 0xa3 } }
|
||||
|
||||
static NS_DEFINE_IID(kJPGDecoderIID, NS_JPGDECODER_IID);
|
||||
static NS_DEFINE_CID(kJPGDecoderCID, NS_JPGDECODER_CID);
|
||||
class JPGDecoder : public nsIImgDecoder
|
||||
{
|
||||
public:
|
||||
JPGDecoder(il_container* aContainer);
|
||||
virtual ~JPGDecoder();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* stream */
|
||||
NS_IMETHOD ImgDInit();
|
||||
|
||||
#endif
|
||||
NS_IMETHOD ImgDWriteReady(PRUint32 *max_read);
|
||||
NS_IMETHOD ImgDWrite(const unsigned char *buf, int32 len);
|
||||
NS_IMETHOD ImgDComplete();
|
||||
NS_IMETHOD ImgDAbort();
|
||||
|
||||
NS_IMETHOD_(il_container *) SetContainer(il_container *ic){ilContainer = ic; return ic;}
|
||||
NS_IMETHOD_(il_container *) GetContainer() {return ilContainer;}
|
||||
|
||||
|
||||
private:
|
||||
il_container* ilContainer;
|
||||
};
|
||||
|
||||
#endif /* nsJPGDecoder_h___ */
|
||||
|
@ -30,7 +30,7 @@ REQUIRES = util png zlib xpcom img
|
||||
CPPSRCS = \
|
||||
ipng.cpp \
|
||||
nsPNGDecoder.cpp \
|
||||
nsPNGCallback.cpp \
|
||||
nsPNGModule.cpp \
|
||||
dllcompat.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
@ -88,8 +88,11 @@ LINCS=-I$(DEPTH)/dist/public/xpcom -I. -I$(DEPTH)/dist/public/raptor \
|
||||
|
||||
REQUIRES=nspr xpcom util raptor png zlib
|
||||
CPPSRCS= dllcompat.cpp nsPNGDecoder.cpp nsPNGCallback.cpp ipng.cpp
|
||||
CPP_OBJS=.\$(OBJDIR)\nsPNGDecoder.obj .\$(OBJDIR)\nsPNGCallback.obj .\$(OBJDIR)\dllcompat.obj \
|
||||
.\$(OBJDIR)\ipng.obj
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsPNGDecoder.obj \
|
||||
.\$(OBJDIR)\nsPNGModule.obj \
|
||||
.\$(OBJDIR)\dllcompat.obj \
|
||||
.\$(OBJDIR)\ipng.obj
|
||||
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
@ -1,37 +0,0 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#if 0 // OBSOLETE
|
||||
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* nsPNGDecoder.cpp --- interface to png decoder
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "nsPNGCallback.h"
|
||||
|
||||
/* callbks: */
|
||||
/*-------------class----------*/
|
||||
|
||||
NS_IMPL_ISUPPORTS(PNGCallbk, kImgDCallbkIID)
|
||||
|
||||
/*-----------------------------*/
|
||||
|
||||
#endif /* 0 */
|
@ -1,59 +0,0 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#if 0 // OBSOLETE
|
||||
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* nsPNGDecoder.cpp --- interface to png decoder
|
||||
*/
|
||||
#ifndef _nsPNGCallbk_h
|
||||
#define _nsPNGCallbk_h
|
||||
|
||||
|
||||
#include "nsIImgDecoder.h"
|
||||
#include "nsPNGDecoder.h"
|
||||
|
||||
|
||||
/* 2b0c6b90-d8b1-11d2-802c-0060088f91a3 */
|
||||
#define NS_PNGCALLBK_CID \
|
||||
{ 0x2b0c6b90, 0xd8b1, 0x11d2, \
|
||||
{ 0x80, 0x2c, 0x00, 0x60, 0x08, 0x8f, 0x91, 0xa3 } }
|
||||
|
||||
/* 5cb47c60-d8b1-11d2-802c-0060088f91a3 */
|
||||
#define NS_PNGCALLBK_IID \
|
||||
{ 0x5cb47c60, 0xd8b1, 0x11d2, \
|
||||
{ 0x80, 0x2c, 0x00, 0x60, 0x08, 0x8f, 0x91, 0xa3 } }
|
||||
|
||||
|
||||
class PNGCallbk : public nsIImgDCallbk {
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
il_container *GetContainer() {return ilContainer;};
|
||||
il_container *SetContainer(il_container *ic) {ilContainer=ic; return ic;};
|
||||
|
||||
PNGCallbk(il_container *aContainer){ilContainer=aContainer;};
|
||||
virtual ~PNGCallbk() {}; // XXX Pam needs to fix this
|
||||
|
||||
private:
|
||||
il_container* ilContainer;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* 0 */
|
@ -43,29 +43,6 @@ PR_END_EXTERN_C
|
||||
|
||||
|
||||
/*-----------class----------------*/
|
||||
class PNGDecoder : public nsIImgDecoder
|
||||
{
|
||||
public:
|
||||
PNGDecoder(il_container* aContainer);
|
||||
virtual ~PNGDecoder();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* stream */
|
||||
NS_IMETHOD ImgDInit();
|
||||
|
||||
NS_IMETHOD ImgDWriteReady(PRUint32 *max_read);
|
||||
NS_IMETHOD ImgDWrite(const unsigned char *buf, int32 len);
|
||||
NS_IMETHOD ImgDComplete();
|
||||
NS_IMETHOD ImgDAbort();
|
||||
|
||||
NS_IMETHOD_(il_container *) SetContainer(il_container *ic){ilContainer = ic; return ic;}
|
||||
NS_IMETHOD_(il_container *) GetContainer() {return ilContainer;}
|
||||
|
||||
|
||||
private:
|
||||
il_container* ilContainer;
|
||||
};
|
||||
/*-------------------------------------------------*/
|
||||
|
||||
PNGDecoder::PNGDecoder(il_container* aContainer)
|
||||
@ -80,6 +57,7 @@ PNGDecoder::~PNGDecoder(void)
|
||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
||||
};
|
||||
|
||||
static NS_DEFINE_IID(kPNGDecoderIID, NS_PNGDECODER_IID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
PNGDecoder::QueryInterface(const nsIID& aIID, void** aInstPtr)
|
||||
@ -104,149 +82,6 @@ PNGDecoder::QueryInterface(const nsIID& aIID, void** aInstPtr)
|
||||
NS_IMPL_ADDREF(PNGDecoder)
|
||||
NS_IMPL_RELEASE(PNGDecoder)
|
||||
|
||||
/*-----------class----------------*/
|
||||
class nsPNGDecFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsPNGDecFactory(const nsCID &aClass);
|
||||
virtual ~nsPNGDecFactory();
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
nsCID mClassID;
|
||||
il_container *ilContainer;
|
||||
};
|
||||
|
||||
/*-----------------------------------------*/
|
||||
|
||||
static nsPNGDecFactory* gFactory = NULL;
|
||||
|
||||
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
NS_IMPL_ISUPPORTS(nsPNGDecFactory, kIFactoryIID)
|
||||
|
||||
|
||||
nsPNGDecFactory::nsPNGDecFactory(const nsCID &aClass)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mClassID = aClass;
|
||||
}
|
||||
|
||||
nsPNGDecFactory::~nsPNGDecFactory(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 = compMgr->RegisterComponent(kPNGDecoderCID,
|
||||
"Netscape PNGDec",
|
||||
"component://netscape/image/decoder&type=image/png", 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(kPNGDecoderCID, path);
|
||||
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*--------------------*/
|
||||
NS_IMETHODIMP
|
||||
nsPNGDecFactory::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **ppv)
|
||||
{
|
||||
PNGDecoder *pngdec = 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();
|
||||
|
||||
pngdec = new PNGDecoder(ic);
|
||||
nsresult res = pngdec->QueryInterface(aIID,(void**)ppv);
|
||||
//interface is other than nsISupports and pngdecoder
|
||||
|
||||
if (NS_FAILED(res)) {
|
||||
*ppv = NULL;
|
||||
delete pngdec;
|
||||
}
|
||||
delete ic; /* is a place holder */
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsPNGDecFactory::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(kPNGDecoderCID))
|
||||
return NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
if( gFactory == NULL){
|
||||
gFactory = new nsPNGDecFactory(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
|
||||
/*------------------------------------------------------*/
|
||||
|
@ -15,12 +15,10 @@
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsPNGDecoder_h___
|
||||
#define nsPNGDecoder_h___
|
||||
|
||||
/* -*- Mode: C; tab-width: 4 -*-
|
||||
* nsPNGDecoder.cpp --- interface to png decoder
|
||||
*/
|
||||
#ifndef _nsPNGDec_h
|
||||
#define _nsPNGDec_h
|
||||
#include "nsIImgDecoder.h"
|
||||
|
||||
/* 573010b0-de61-11d2-802c-0060088f91a3 */
|
||||
#define NS_PNGDECODER_CID \
|
||||
@ -32,9 +30,28 @@
|
||||
{ 0x789d4ab0, 0xde61, 0x11d2, \
|
||||
{ 0x80, 0x2c, 0x00, 0x60, 0x08, 0x8f, 0x91, 0xa3 } }
|
||||
|
||||
class PNGDecoder : public nsIImgDecoder
|
||||
{
|
||||
public:
|
||||
PNGDecoder(il_container* aContainer);
|
||||
virtual ~PNGDecoder();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
static NS_DEFINE_IID(kPNGDecoderIID, NS_PNGDECODER_IID);
|
||||
static NS_DEFINE_CID(kPNGDecoderCID, NS_PNGDECODER_CID);
|
||||
/* stream */
|
||||
NS_IMETHOD ImgDInit();
|
||||
|
||||
NS_IMETHOD ImgDWriteReady(PRUint32 *max_read);
|
||||
NS_IMETHOD ImgDWrite(const unsigned char *buf, int32 len);
|
||||
NS_IMETHOD ImgDComplete();
|
||||
NS_IMETHOD ImgDAbort();
|
||||
|
||||
#endif
|
||||
NS_IMETHOD_(il_container *) SetContainer(il_container *ic){ilContainer = ic; return ic;}
|
||||
NS_IMETHOD_(il_container *) GetContainer() {return ilContainer;}
|
||||
|
||||
|
||||
private:
|
||||
il_container* ilContainer;
|
||||
};
|
||||
|
||||
#endif /* nsPNGDecoder_h___ */
|
||||
|
Loading…
Reference in New Issue
Block a user