diff options
author | reed <reed@google.com> | 2014-06-11 10:33:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-06-11 10:33:13 -0700 |
commit | 5926b86b90c68bffefbdc8639e41b5bc9102cec6 (patch) | |
tree | a20f97bc8a3c5f8224071b23c0b1112f669f05bf /src | |
parent | d58a0ba9cff9fcefe5047e88ccb4a6e76c591c40 (diff) |
hide SkImageDecoder::Chooser
BUG=skia:
R=scroggo@google.com
Author: reed@google.com
Review URL: https://codereview.chromium.org/331433003
Diffstat (limited to 'src')
-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 |
9 files changed, 30 insertions, 0 deletions
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; |