hide SkImageDecoder::Chooser
BUG=skia:
R=scroggo@google.com
Author: reed@google.com
Review URL: https://codereview.chromium.org/331433003
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp
index 5d38b40..13e0c23 100644
--- a/src/images/SkImageDecoder.cpp
+++ b/src/images/SkImageDecoder.cpp
@@ -30,7 +30,9 @@
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() {
SkSafeUnref(fPeeker);
+#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
SkSafeUnref(fChooser);
+#endif
SkSafeUnref(fAllocator);
}
@@ -52,7 +56,9 @@
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 @@
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 @@
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 @@
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 fd1db5e..effc1ed 100644
--- a/src/images/SkImageDecoder_ktx.cpp
+++ b/src/images/SkImageDecoder_ktx.cpp
@@ -62,10 +62,12 @@
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 bbcd223..7b6a474 100644
--- a/src/images/SkImageDecoder_libgif.cpp
+++ b/src/images/SkImageDecoder_libgif.cpp
@@ -309,10 +309,12 @@
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 c6dd6f0..e6ae16f 100644
--- a/src/images/SkImageDecoder_libico.cpp
+++ b/src/images/SkImageDecoder_libico.cpp
@@ -94,6 +94,7 @@
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 @@
//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 befe6dc..9b93716 100644
--- a/src/images/SkImageDecoder_libjpeg.cpp
+++ b/src/images/SkImageDecoder_libjpeg.cpp
@@ -613,10 +613,12 @@
}
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 70cc1b9..9c911e2 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -607,9 +607,11 @@
}
}
+#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 8baa10c..7a3c658 100644
--- a/src/images/SkImageDecoder_libwebp.cpp
+++ b/src/images/SkImageDecoder_libwebp.cpp
@@ -292,9 +292,11 @@
}
}
+#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 @@
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 79da8da..d555c6a 100644
--- a/src/images/SkImageDecoder_pkm.cpp
+++ b/src/images/SkImageDecoder_pkm.cpp
@@ -46,10 +46,12 @@
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 d8f3315..1759e36 100644
--- a/src/ports/SkImageDecoder_empty.cpp
+++ b/src/ports/SkImageDecoder_empty.cpp
@@ -73,9 +73,11 @@
return NULL;
}
+#ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER
SkImageDecoder::Chooser* SkImageDecoder::setChooser(Chooser*) {
return NULL;
}
+#endif
SkBitmap::Allocator* SkImageDecoder::setAllocator(SkBitmap::Allocator*) {
return NULL;