diff options
author | 2014-12-22 07:37:29 -0800 | |
---|---|---|
committer | 2014-12-22 07:37:29 -0800 | |
commit | 2d73d80d68bc4b358eaa6da9f725d83f390af96a (patch) | |
tree | 9508ffd41c9accbaf63eec3424ae4d870312a1df /src/images | |
parent | 080e673b10ac607305f140ddb245e140ccde40c6 (diff) |
remove dead SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER code
BUG=skia:
Review URL: https://codereview.chromium.org/816273002
Diffstat (limited to 'src/images')
-rw-r--r-- | src/images/SkImageDecoder.cpp | 31 | ||||
-rw-r--r-- | src/images/SkImageDecoder_astc.cpp | 7 | ||||
-rw-r--r-- | src/images/SkImageDecoder_ktx.cpp | 7 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libgif.cpp | 7 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libico.cpp | 60 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libjpeg.cpp | 7 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libpng.cpp | 6 | ||||
-rw-r--r-- | src/images/SkImageDecoder_libwebp.cpp | 14 | ||||
-rw-r--r-- | src/images/SkImageDecoder_pkm.cpp | 7 |
9 files changed, 5 insertions, 141 deletions
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp index c5e973903d..596d05ec2d 100644 --- a/src/images/SkImageDecoder.cpp +++ b/src/images/SkImageDecoder.cpp @@ -16,9 +16,6 @@ SkImageDecoder::SkImageDecoder() : fPeeker(NULL) -#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER - , fChooser(NULL) -#endif , fAllocator(NULL) , fSampleSize(1) , fDefaultPref(kUnknown_SkColorType) @@ -31,9 +28,6 @@ SkImageDecoder::SkImageDecoder() SkImageDecoder::~SkImageDecoder() { SkSafeUnref(fPeeker); -#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER - SkSafeUnref(fChooser); -#endif SkSafeUnref(fAllocator); } @@ -42,9 +36,6 @@ 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); other->setPreserveSrcDepth(fPreserveSrcDepth); @@ -97,13 +88,6 @@ 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); return alloc; @@ -116,21 +100,6 @@ 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 { - Chooser* chooser = fChooser; - - if (NULL == chooser) { // no chooser, we just say YES to decoding :) - return true; - } - chooser->begin(1); - chooser->inspect(0, SkColorTypeToBitmapConfig(colorType), width, height); - return chooser->choose() == 0; -} -#endif - bool SkImageDecoder::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) const { return bitmap->tryAllocPixels(fAllocator, ctable); diff --git a/src/images/SkImageDecoder_astc.cpp b/src/images/SkImageDecoder_astc.cpp index 30f42f05df..96d28f8569 100644 --- a/src/images/SkImageDecoder_astc.cpp +++ b/src/images/SkImageDecoder_astc.cpp @@ -117,13 +117,6 @@ SkImageDecoder::Result SkASTCImageDecoder::onDecode(SkStream* stream, SkBitmap* // Advance the buffer past the image dimensions buf += 9; -#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 kFailure; - } -#endif - // Setup the sampler... SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); diff --git a/src/images/SkImageDecoder_ktx.cpp b/src/images/SkImageDecoder_ktx.cpp index 8566375f0c..8ef592adc9 100644 --- a/src/images/SkImageDecoder_ktx.cpp +++ b/src/images/SkImageDecoder_ktx.cpp @@ -62,13 +62,6 @@ SkImageDecoder::Result SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* b 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 kFailure; - } -#endif - // Set a flag if our source is premultiplied alpha const SkString premulKey("KTXPremultipliedAlpha"); const bool bSrcIsPremul = ktxFile.getValueForKey(premulKey) == SkString("True"); diff --git a/src/images/SkImageDecoder_libgif.cpp b/src/images/SkImageDecoder_libgif.cpp index fb5d18fc08..1d0e500206 100644 --- a/src/images/SkImageDecoder_libgif.cpp +++ b/src/images/SkImageDecoder_libgif.cpp @@ -310,13 +310,6 @@ SkImageDecoder::Result SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap 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()); bm->setInfo(SkImageInfo::Make(sampler.scaledWidth(), sampler.scaledHeight(), diff --git a/src/images/SkImageDecoder_libico.cpp b/src/images/SkImageDecoder_libico.cpp index b9b5c6a453..a3297062ce 100644 --- a/src/images/SkImageDecoder_libico.cpp +++ b/src/images/SkImageDecoder_libico.cpp @@ -97,67 +97,17 @@ SkImageDecoder::Result SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* b return kFailure; } -#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER - int choice; - Chooser* chooser = this->getChooser(); - //FIXME:if no chooser, consider providing the largest color image - //what are the odds that the largest image would be monochrome? - if (NULL == chooser) { - choice = 0; - } else { - chooser->begin(count); - for (int i = 0; i < count; i++) - { - //need to find out the config, width, and height from the stream - int width = readByte(buf, 6 + i*16); - int height = readByte(buf, 7 + i*16); - int offset = read4Bytes(buf, 18 + i*16); - int bitCount = read2Bytes(buf, offset+14); - SkBitmap::Config c; - //currently only provide ARGB_8888_, but maybe we want kIndex8_Config for 1 and 4, and possibly 8? - //or maybe we'll determine this based on the provided config - switch (bitCount) - { - case 1: - case 4: - // In reality, at least for the moment, these will be decoded into kARGB_8888 bitmaps. - // However, this will be used to distinguish between the lower quality 1bpp and 4 bpp - // images and the higher quality images. - c = SkBitmap::kIndex8_Config; - break; - case 8: - case 24: - case 32: - c = SkBitmap::kARGB_8888_Config; - break; - default: - SkDEBUGF(("Image with %ibpp not supported\n", bitCount)); - continue; - } - chooser->inspect(i, c, width, height); - } - choice = chooser->choose(); - } - - //you never know what the chooser is going to supply - if (choice >= count || choice < 0) { - return kFailure; - } -#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 //otherwise, they could be used for error checking - int w = readByte(buf, 6 + choice*16); - int h = readByte(buf, 7 + choice*16); - int colorCount = readByte(buf, 8 + choice*16); + int w = readByte(buf, 6); + int h = readByte(buf, 7); + int colorCount = readByte(buf, 8); //int reservedToo = readByte(buf, 9 + choice*16); //0 //int planes = read2Bytes(buf, 10 + choice*16); //1 - but often 0 //int fakeBitCount = read2Bytes(buf, 12 + choice*16); //should be real - usually 0 - const size_t size = read4Bytes(buf, 14 + choice*16); //matters? - const size_t offset = read4Bytes(buf, 18 + choice*16); + const size_t size = read4Bytes(buf, 14); //matters? + const size_t offset = read4Bytes(buf, 18); // promote the sum to 64-bits to avoid overflow if (offset > length || size > length || ((uint64_t)offset + size) > length) { return kFailure; diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp index e6bc8827cd..f25fb9fcce 100644 --- a/src/images/SkImageDecoder_libjpeg.cpp +++ b/src/images/SkImageDecoder_libjpeg.cpp @@ -640,13 +640,6 @@ SkImageDecoder::Result SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* } 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_failure(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 // individual pixel. It is very unlikely to be opaque, since diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp index 8a3e40ea19..e997fdbd7e 100644 --- a/src/images/SkImageDecoder_libpng.cpp +++ b/src/images/SkImageDecoder_libpng.cpp @@ -614,12 +614,6 @@ bool SkPNGImageDecoder::getBitmapColorType(png_structp png_ptr, png_infop info_p } } -#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 colortype is 8888. if (this->getRequireUnpremultipliedColors() && *hasAlphap) { diff --git a/src/images/SkImageDecoder_libwebp.cpp b/src/images/SkImageDecoder_libwebp.cpp index 2a7bb0fe59..d5caf702ee 100644 --- a/src/images/SkImageDecoder_libwebp.cpp +++ b/src/images/SkImageDecoder_libwebp.cpp @@ -303,12 +303,6 @@ 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)) { if (this->getRequireUnpremultipliedColors()) { @@ -390,14 +384,6 @@ 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 746ae40c4c..17ef2f3037 100644 --- a/src/images/SkImageDecoder_pkm.cpp +++ b/src/images/SkImageDecoder_pkm.cpp @@ -47,13 +47,6 @@ SkImageDecoder::Result SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* b 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 kFailure; - } -#endif - // Setup the sampler... SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); |