diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-03-17 17:59:53 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-03-17 17:59:53 +0000 |
commit | a14ea0e930c82daa2364ece4bd0b06256272302a (patch) | |
tree | 425f401e5731ead3050590fcc878ea49d006aaab /src/images | |
parent | 452f844f64d97e0f54b9258b800755686193136e (diff) |
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
Diffstat (limited to 'src/images')
-rw-r--r-- | src/images/SkImageRef.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
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<SkImageDecoder> ad(codec); |