From a14ea0e930c82daa2364ece4bd0b06256272302a Mon Sep 17 00:00:00 2001 From: "reed@android.com" Date: Tue, 17 Mar 2009 17:59:53 +0000 Subject: Simplify font-chaining (fallbacks) to have fonthost just return the next logical fontID. Extend ImageRef to accept an imagedecoder factory, to replace calling the std one. git-svn-id: http://skia.googlecode.com/svn/trunk@125 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/images/SkImageRef.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/images') diff --git a/src/images/SkImageRef.cpp b/src/images/SkImageRef.cpp index 8b14375582..0865c88595 100644 --- a/src/images/SkImageRef.cpp +++ b/src/images/SkImageRef.cpp @@ -20,6 +20,7 @@ SkImageRef::SkImageRef(SkStream* stream, SkBitmap::Config config, fConfig = config; fSampleSize = sampleSize; fPrev = fNext = NULL; + fFactory = NULL; #ifdef DUMP_IMAGEREF_LIFECYCLE SkDebugf("add ImageRef %p [%d] data=%d\n", @@ -36,6 +37,7 @@ SkImageRef::~SkImageRef() { #endif fStream->unref(); + fFactory->safeUnref(); } bool SkImageRef::getInfo(SkBitmap* bitmap) { @@ -52,6 +54,12 @@ bool SkImageRef::getInfo(SkBitmap* bitmap) { return true; } +SkImageDecoderFactory* SkImageRef::setDecoderFactory( + SkImageDecoderFactory* fact) { + SkRefCnt_SafeAssign(fFactory, fact); + return fact; +} + /////////////////////////////////////////////////////////////////////////////// bool SkImageRef::onDecode(SkImageDecoder* codec, SkStream* stream, @@ -84,8 +92,14 @@ bool SkImageRef::prepareBitmap(SkImageDecoder::Mode mode) { SkASSERT(fBitmap.getPixels() == NULL); fStream->rewind(); - - SkImageDecoder* codec = SkImageDecoder::Factory(fStream); + + SkImageDecoder* codec; + if (fFactory) { + codec = fFactory->newDecoder(fStream); + } else { + codec = SkImageDecoder::Factory(fStream); + } + if (codec) { SkAutoTDelete ad(codec); -- cgit v1.2.3