Allow decoding JPEG into A8.
If the original image is grayscale, allow decoding into A8.
Change the size of PrefConfigTable to allow for 8bit gray, a new source config.
Add a new sampler to SkScaledBitmapSampler to 'convert' to A8.
FIXME: Should there be a dithered option for gray scale?
R=reed@google.com
Review URL: https://codereview.chromium.org/18083026
git-svn-id: http://skia.googlecode.com/svn/trunk@10157 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/ImageDecodingTest.cpp b/tests/ImageDecodingTest.cpp
index 9a5d45b..76308c9 100644
--- a/tests/ImageDecodingTest.cpp
+++ b/tests/ImageDecodingTest.cpp
@@ -132,7 +132,41 @@
}
}
-static void test_imageDecodingTests(skiatest::Reporter* reporter) {
+// Create a fake ImageDecoder to test setPrefConfigTable for
+// backwards compatibility.
+class PrefConfigTestingImageDecoder : public SkImageDecoder {
+public:
+ void testPrefConfigTable(skiatest::Reporter* reporter) {
+ // Arbitrary list of Configs. The important thing about
+ // the list is that each one is different, so we can test
+ // to make sure the correct config is chosen.
+ const SkBitmap::Config configs[] = {
+ SkBitmap::kA1_Config,
+ SkBitmap::kA8_Config,
+ SkBitmap::kIndex8_Config,
+ SkBitmap::kRGB_565_Config,
+ SkBitmap::kARGB_4444_Config,
+ SkBitmap::kARGB_8888_Config,
+ };
+ this->setPrefConfigTable(configs);
+ REPORTER_ASSERT(reporter, configs[0] == this->getPrefConfig(kIndex_SrcDepth, false));
+ REPORTER_ASSERT(reporter, configs[1] == this->getPrefConfig(kIndex_SrcDepth, true));
+ REPORTER_ASSERT(reporter, configs[4] == this->getPrefConfig(k32Bit_SrcDepth, false));
+ REPORTER_ASSERT(reporter, configs[5] == this->getPrefConfig(k32Bit_SrcDepth, true));
+ }
+
+protected:
+ virtual bool onDecode(SkStream*, SkBitmap* bitmap, Mode) SK_OVERRIDE {
+ return false;
+ }
+};
+
+static void test_pref_config_table(skiatest::Reporter* reporter) {
+ PrefConfigTestingImageDecoder decoder;
+ decoder.testPrefConfigTable(reporter);
+}
+
+static void test_unpremul(skiatest::Reporter* reporter) {
// This test cannot run if there is no resource path.
SkString resourcePath = skiatest::Test::GetResourcePath();
if (resourcePath.isEmpty()) {
@@ -151,6 +185,11 @@
}
}
+static void test_imageDecodingTests(skiatest::Reporter* reporter) {
+ test_unpremul(reporter);
+ test_pref_config_table(reporter);
+}
+
#include "TestClassDef.h"
DEFINE_TESTCLASS("ImageDecoding", ImageDecodingTestClass,
test_imageDecodingTests)