add SK_ENABLE_LIBPNG to force reference to PNG codec
git-svn-id: http://skia.googlecode.com/svn/trunk@550 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
887e4f325c
commit
dfee579a8d
2
Makefile
2
Makefile
@ -61,7 +61,7 @@ ifeq ($(SKIA_BUILD_FOR),mac)
|
||||
SRC_LIST += src/ports/SkFontHost_mac.cpp
|
||||
else
|
||||
LINKER_OPTS += -lpng -lfreetype
|
||||
DEFINES += -DSK_BUILD_FOR_UNIX
|
||||
DEFINES += -DSK_BUILD_FOR_UNIX -DSK_ENABLE_LIBPNG
|
||||
|
||||
# needed for freetype support
|
||||
C_INCLUDES += -I/usr/include/freetype2
|
||||
|
@ -24,10 +24,15 @@ typedef SkTRegistry<SkImageDecoder*, SkStream*> DecodeReg;
|
||||
|
||||
template DecodeReg* DecodeReg::gHead;
|
||||
|
||||
#ifdef SK_ENABLE_LIBPNG
|
||||
extern SkImageDecoder* sk_libpng_dfactory(SkStream*);
|
||||
#endif
|
||||
|
||||
SkImageDecoder* SkImageDecoder::Factory(SkStream* stream) {
|
||||
SkImageDecoder* codec = NULL;
|
||||
const DecodeReg* curr = DecodeReg::Head();
|
||||
while (curr) {
|
||||
SkImageDecoder* codec = curr->factory()(stream);
|
||||
codec = curr->factory()(stream);
|
||||
// we rewind here, because we promise later when we call "decode", that
|
||||
// the stream will be at its beginning.
|
||||
stream->rewind();
|
||||
@ -36,6 +41,13 @@ SkImageDecoder* SkImageDecoder::Factory(SkStream* stream) {
|
||||
}
|
||||
curr = curr->next();
|
||||
}
|
||||
#ifdef SK_ENABLE_LIBPNG
|
||||
codec = sk_libpng_dfactory(stream);
|
||||
stream->rewind();
|
||||
if (codec) {
|
||||
return codec;
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -845,7 +845,12 @@ bool SkPNGImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap,
|
||||
|
||||
#include "SkTRegistry.h"
|
||||
|
||||
static SkImageDecoder* DFactory(SkStream* stream) {
|
||||
#ifdef SK_ENABLE_LIBPNG
|
||||
SkImageDecoder* sk_libpng_dfactory(SkStream*);
|
||||
SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type);
|
||||
#endif
|
||||
|
||||
SkImageDecoder* sk_libpng_dfactory(SkStream* stream) {
|
||||
char buf[PNG_BYTES_TO_CHECK];
|
||||
if (stream->read(buf, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK &&
|
||||
!png_sig_cmp((png_bytep) buf, (png_size_t)0, PNG_BYTES_TO_CHECK)) {
|
||||
@ -854,9 +859,9 @@ static SkImageDecoder* DFactory(SkStream* stream) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SkImageEncoder* EFactory(SkImageEncoder::Type t) {
|
||||
SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) {
|
||||
return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL;
|
||||
}
|
||||
|
||||
static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(EFactory);
|
||||
static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(DFactory);
|
||||
static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libpng_efactory);
|
||||
static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libpng_dfactory);
|
||||
|
@ -21,15 +21,24 @@ typedef SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> EncodeReg;
|
||||
|
||||
template EncodeReg* EncodeReg::gHead;
|
||||
|
||||
#ifdef SK_ENABLE_LIBPNG
|
||||
extern SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type);
|
||||
#endif
|
||||
|
||||
SkImageEncoder* SkImageEncoder::Create(Type t) {
|
||||
SkImageEncoder* codec = NULL;
|
||||
const EncodeReg* curr = EncodeReg::Head();
|
||||
while (curr) {
|
||||
SkImageEncoder* codec = curr->factory()(t);
|
||||
if (codec) {
|
||||
if ((codec = curr->factory()(t)) != NULL) {
|
||||
return codec;
|
||||
}
|
||||
curr = curr->next();
|
||||
}
|
||||
#ifdef SK_ENABLE_LIBPNG
|
||||
if ((codec = sk_libpng_efactory(t)) != NULL) {
|
||||
return codec;
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user