diff options
-rw-r--r-- | include/core/SkImageDecoder.h | 6 | ||||
-rw-r--r-- | src/images/SkImageDecoder.cpp | 10 | ||||
-rw-r--r-- | src/images/SkImageDecoder_ktx.cpp | 2 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libgif.cpp | 2 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libico.cpp | 4 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libjpeg.cpp | 2 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libpng.cpp | 2 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libwebp.cpp | 4 | ||||
-rw-r--r-- | src/images/SkImageDecoder_pkm.cpp | 2 | ||||
-rw-r--r-- | src/ports/SkImageDecoder_empty.cpp | 2 |
10 files changed, 36 insertions, 0 deletions
diff --git a/include/core/SkImageDecoder.h b/include/core/SkImageDecoder.h index f8e682baf0..e8e8e01337 100644 --- a/include/core/SkImageDecoder.h +++ b/include/core/SkImageDecoder.h @@ -137,6 +137,7 @@ public: Peeker* getPeeker() const { return fPeeker; } Peeker* setPeeker(Peeker*); +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER /** \class Chooser Base class for optional callbacks to choose an image from a format that @@ -158,6 +159,7 @@ public: Chooser* getChooser() const { return fChooser; } Chooser* setChooser(Chooser*); +#endif /** * Optional table describing the caller's preferred config based on @@ -436,9 +438,11 @@ public: protected: SkImageDecoder(); +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER // helper function for decoders to handle the (common) case where there is only // once choice available in the image file. bool chooseFromOneChoice(SkColorType, int width, int height) const; +#endif /* Helper for subclasses. Call this to allocate the pixel memory given the bitmap's width/height/rowbytes/config. Returns true on success. This method handles checking @@ -469,7 +473,9 @@ protected: private: Peeker* fPeeker; +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER Chooser* fChooser; +#endif SkBitmap::Allocator* fAllocator; int fSampleSize; SkBitmap::Config fDefaultPref; // use if fUsePrefTable is false diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp index 5d38b40412..13e0c232dc 100644 --- a/src/images/SkImageDecoder.cpp +++ b/src/images/SkImageDecoder.cpp @@ -30,7 +30,9 @@ void SkImageDecoder::SetDeviceConfig(SkBitmap::Config config) SkImageDecoder::SkImageDecoder() : fPeeker(NULL) +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER , fChooser(NULL) +#endif , fAllocator(NULL) , fSampleSize(1) , fDefaultPref(SkBitmap::kNo_Config) @@ -43,7 +45,9 @@ SkImageDecoder::SkImageDecoder() SkImageDecoder::~SkImageDecoder() { SkSafeUnref(fPeeker); +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER SkSafeUnref(fChooser); +#endif SkSafeUnref(fAllocator); } @@ -52,7 +56,9 @@ void SkImageDecoder::copyFieldsToOther(SkImageDecoder* other) { return; } other->setPeeker(fPeeker); +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER other->setChooser(fChooser); +#endif other->setAllocator(fAllocator); other->setSampleSize(fSampleSize); if (fUsePrefTable) { @@ -107,10 +113,12 @@ SkImageDecoder::Peeker* SkImageDecoder::setPeeker(Peeker* peeker) { return peeker; } +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER SkImageDecoder::Chooser* SkImageDecoder::setChooser(Chooser* chooser) { SkRefCnt_SafeAssign(fChooser, chooser); return chooser; } +#endif SkBitmap::Allocator* SkImageDecoder::setAllocator(SkBitmap::Allocator* alloc) { SkRefCnt_SafeAssign(fAllocator, alloc); @@ -124,6 +132,7 @@ void SkImageDecoder::setSampleSize(int size) { fSampleSize = size; } +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER // TODO: change Chooser virtual to take colorType, so we can stop calling SkColorTypeToBitmapConfig // bool SkImageDecoder::chooseFromOneChoice(SkColorType colorType, int width, int height) const { @@ -136,6 +145,7 @@ bool SkImageDecoder::chooseFromOneChoice(SkColorType colorType, int width, int h chooser->inspect(0, SkColorTypeToBitmapConfig(colorType), width, height); return chooser->choose() == 0; } +#endif bool SkImageDecoder::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) const { diff --git a/src/images/SkImageDecoder_ktx.cpp b/src/images/SkImageDecoder_ktx.cpp index fd1db5e9d2..effc1edcc1 100644 --- a/src/images/SkImageDecoder_ktx.cpp +++ b/src/images/SkImageDecoder_ktx.cpp @@ -62,10 +62,12 @@ bool SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { const unsigned short width = ktxFile.width(); const unsigned short height = ktxFile.height(); +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER // should we allow the Chooser (if present) to pick a config for us??? if (!this->chooseFromOneChoice(kN32_SkColorType, width, height)) { return false; } +#endif // Set a flag if our source is premultiplied alpha const SkString premulKey("KTXPremultipliedAlpha"); diff --git a/src/images/SkImageDecoder_libgif.cpp b/src/images/SkImageDecoder_libgif.cpp index bbcd223169..7b6a4741df 100644 --- a/src/images/SkImageDecoder_libgif.cpp +++ b/src/images/SkImageDecoder_libgif.cpp @@ -309,10 +309,12 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, Mode mode) { imageTop = 0; } +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER // FIXME: We could give the caller a choice of images or configs. if (!this->chooseFromOneChoice(kIndex_8_SkColorType, width, height)) { return error_return(*bm, "chooseFromOneChoice"); } +#endif SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); diff --git a/src/images/SkImageDecoder_libico.cpp b/src/images/SkImageDecoder_libico.cpp index c6dd6f0836..e6ae16f0bd 100644 --- a/src/images/SkImageDecoder_libico.cpp +++ b/src/images/SkImageDecoder_libico.cpp @@ -94,6 +94,7 @@ bool SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) if (length < (size_t)(6 + count*16)) return false; +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER int choice; Chooser* chooser = this->getChooser(); //FIXME:if no chooser, consider providing the largest color image @@ -138,6 +139,9 @@ bool SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) //you never know what the chooser is going to supply if (choice >= count || choice < 0) return false; +#else + const int choice = 0; // TODO: fold this value into the expressions below +#endif //skip ahead to the correct header //commented out lines are not used, but if i switch to other read method, need to know how many to skip diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp index befe6dc580..9b937162b3 100644 --- a/src/images/SkImageDecoder_libjpeg.cpp +++ b/src/images/SkImageDecoder_libjpeg.cpp @@ -613,10 +613,12 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { } sampleSize = recompute_sampleSize(sampleSize, cinfo); +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER // should we allow the Chooser (if present) to pick a colortype for us??? if (!this->chooseFromOneChoice(colorType, cinfo.output_width, cinfo.output_height)) { return return_false(cinfo, *bm, "chooseFromOneChoice"); } +#endif SkScaledBitmapSampler sampler(cinfo.output_width, cinfo.output_height, sampleSize); // Assume an A8 bitmap is not opaque to avoid the check of each diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp index 70cc1b9f75..9c911e29fc 100644 --- a/src/images/SkImageDecoder_libpng.cpp +++ b/src/images/SkImageDecoder_libpng.cpp @@ -607,9 +607,11 @@ bool SkPNGImageDecoder::getBitmapConfig(png_structp png_ptr, png_infop info_ptr, } } +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER if (!this->chooseFromOneChoice(*colorTypep, origWidth, origHeight)) { return false; } +#endif // If the image has alpha and the decoder wants unpremultiplied // colors, the only supported config is 8888. diff --git a/src/images/SkImageDecoder_libwebp.cpp b/src/images/SkImageDecoder_libwebp.cpp index 8baa10c454..7a3c65875c 100644 --- a/src/images/SkImageDecoder_libwebp.cpp +++ b/src/images/SkImageDecoder_libwebp.cpp @@ -292,9 +292,11 @@ bool SkWEBPImageDecoder::setDecodeConfig(SkBitmap* decodedBitmap, int width, int } } +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER if (!this->chooseFromOneChoice(colorType, width, height)) { return false; } +#endif SkAlphaType alphaType = kOpaque_SkAlphaType; if (SkToBool(fHasAlpha)) { @@ -379,12 +381,14 @@ bool SkWEBPImageDecoder::onDecodeSubset(SkBitmap* decodedBitmap, if (!allocResult) { return return_false(*decodedBitmap, "allocPixelRef"); } +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER } else { // This is also called in setDecodeConfig in above block. // i.e., when bitmap->isNull() is true. if (!chooseFromOneChoice(bitmap->colorType(), width, height)) { return false; } +#endif } SkAutoLockPixels alp(*bitmap); diff --git a/src/images/SkImageDecoder_pkm.cpp b/src/images/SkImageDecoder_pkm.cpp index 79da8da51a..d555c6afcc 100644 --- a/src/images/SkImageDecoder_pkm.cpp +++ b/src/images/SkImageDecoder_pkm.cpp @@ -46,10 +46,12 @@ bool SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { const unsigned short width = etc1_pkm_get_width(buf); const unsigned short height = etc1_pkm_get_height(buf); +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER // should we allow the Chooser (if present) to pick a config for us??? if (!this->chooseFromOneChoice(kN32_SkColorType, width, height)) { return false; } +#endif // Setup the sampler... SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); diff --git a/src/ports/SkImageDecoder_empty.cpp b/src/ports/SkImageDecoder_empty.cpp index d8f3315d2b..1759e36352 100644 --- a/src/ports/SkImageDecoder_empty.cpp +++ b/src/ports/SkImageDecoder_empty.cpp @@ -73,9 +73,11 @@ SkImageDecoder::Peeker* SkImageDecoder::setPeeker(Peeker*) { return NULL; } +#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER SkImageDecoder::Chooser* SkImageDecoder::setChooser(Chooser*) { return NULL; } +#endif SkBitmap::Allocator* SkImageDecoder::setAllocator(SkBitmap::Allocator*) { return NULL; |