Fix bug in SkGifCodec / Switch SkImageDec tests to use Codec

SkImageDecoder is still used throughout tests, tools, gms etc.
Deleting it from tests is an easy first step.

Bonus is that we add tests of SkCodec.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1733863003

Review URL: https://codereview.chromium.org/1733863003
diff --git a/tests/BadIcoTest.cpp b/tests/BadIcoTest.cpp
index 240de51..c387e15 100644
--- a/tests/BadIcoTest.cpp
+++ b/tests/BadIcoTest.cpp
@@ -8,7 +8,8 @@
 #include "Resources.h"
 #include "Test.h"
 #include "SkBitmap.h"
-#include "SkImageDecoder.h"
+#include "SkCodec.h"
+#include "SkStream.h"
 #include "SkOSFile.h"
 
 DEF_TEST(BadImage, reporter) {
@@ -27,12 +28,18 @@
 
     SkString resourcePath = GetResourcePath(badImagesFolder);
 
-    SkBitmap bm;
     for (size_t i = 0; i < SK_ARRAY_COUNT(badImages); ++i) {
         SkString fullPath = SkOSPath::Join(resourcePath.c_str(), badImages[i]);
-        bool success = SkImageDecoder::DecodeFile(fullPath.c_str(), &bm);
-        // These files are invalid, and should not decode. More importantly,
-        // though, we reached here without crashing.
-        REPORTER_ASSERT(reporter, !success);
+        SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fullPath.c_str()));
+        SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
+
+        // These images are corrupt.  It's not important whether we succeed/fail in codec
+        // creation or decoding.  We just want to make sure that we don't crash.
+        if (codec) {
+            SkBitmap bm;
+            bm.allocPixels(codec->getInfo());
+            codec->getPixels(codec->getInfo(), bm.getPixels(),
+                    bm.rowBytes());
+        }
     }
 }
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
index 51af15f..a0d71bb 100644
--- a/tests/CachedDecodingPixelRefTest.cpp
+++ b/tests/CachedDecodingPixelRefTest.cpp
@@ -9,7 +9,8 @@
 #include "SkCanvas.h"
 #include "SkData.h"
 #include "SkDiscardableMemoryPool.h"
-#include "SkImageDecoder.h"
+#include "SkImage.h"
+#include "SkImageEncoder.h"
 #include "SkImageGeneratorPriv.h"
 #include "SkResourceCache.h"
 #include "SkStream.h"
diff --git a/tests/CodecPriv.h b/tests/CodecPriv.h
new file mode 100644
index 0000000..1123a41
--- /dev/null
+++ b/tests/CodecPriv.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkBitmap.h"
+#include "SkCodec.h"
+#include "SkData.h"
+
+inline bool decode_memory(const void* mem, size_t size, SkBitmap* bm) {
+    SkAutoTUnref<SkData> data(SkData::NewWithoutCopy(mem, size));
+
+    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data.get()));
+    if (!codec) {
+        return false;
+    }
+
+    // Construct a color table for the decode if necessary
+    SkAutoTUnref<SkColorTable> colorTable(nullptr);
+    SkPMColor* colorPtr = nullptr;
+    int* colorCountPtr = nullptr;
+    int maxColors = 256;
+    if (kIndex_8_SkColorType == codec->getInfo().colorType()) {
+        SkPMColor colors[256];
+        colorTable.reset(new SkColorTable(colors, maxColors));
+        colorPtr = const_cast<SkPMColor*>(colorTable->readColors());
+        colorCountPtr = &maxColors;
+    }
+
+    bm->allocPixels(codec->getInfo(), nullptr, colorTable.get());
+    const SkCodec::Result result = codec->getPixels(codec->getInfo(), bm->getPixels(),
+            bm->rowBytes(), nullptr, colorPtr, colorCountPtr);
+    return result == SkCodec::kSuccess || result == SkCodec::kIncompleteInput;
+}
diff --git a/tests/CodexTest.cpp b/tests/CodexTest.cpp
index 37e4f30..51e4123 100644
--- a/tests/CodexTest.cpp
+++ b/tests/CodexTest.cpp
@@ -12,7 +12,6 @@
 #include "SkCodecImageGenerator.h"
 #include "SkData.h"
 #include "SkFrontBufferedStream.h"
-#include "SkImageDecoder.h"
 #include "SkMD5.h"
 #include "SkRandom.h"
 #include "SkStream.h"
@@ -918,10 +917,10 @@
     test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr);
 }
 
-// SkCodec's wbmp decoder was initially more restrictive than SkImageDecoder.
-// It required the second byte to be zero. But SkImageDecoder allowed a couple
-// of bits to be 1 (so long as they do not overlap with 0x9F). Test that
-// SkCodec now supports an image with these bits set.
+// SkCodec's wbmp decoder was initially unnecessarily restrictive.
+// It required the second byte to be zero. The wbmp specification allows
+// a couple of bits to be 1 (so long as they do not overlap with 0x9F).
+// Test that SkCodec now supports an image with these bits set.
 DEF_TEST(Codec_wbmp, r) {
     const char* path = "mandrill.wbmp";
     SkAutoTDelete<SkStream> stream(resource(path));
@@ -935,11 +934,7 @@
     uint8_t* writeableData = static_cast<uint8_t*>(data->writable_data());
     writeableData[1] = static_cast<uint8_t>(~0x9F);
 
-    // SkImageDecoder supports this.
-    SkBitmap bitmap;
-    REPORTER_ASSERT(r, SkImageDecoder::DecodeMemory(data->data(), data->size(), &bitmap));
-
-    // So SkCodec should, too.
+    // SkCodec should support this.
     SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
     REPORTER_ASSERT(r, codec);
     if (!codec) {
diff --git a/tests/FrontBufferedStreamTest.cpp b/tests/FrontBufferedStreamTest.cpp
index 7821c5e..e3df466 100644
--- a/tests/FrontBufferedStreamTest.cpp
+++ b/tests/FrontBufferedStreamTest.cpp
@@ -6,8 +6,8 @@
  */
 
 #include "SkBitmap.h"
+#include "SkCodec.h"
 #include "SkFrontBufferedStream.h"
-#include "SkImageDecoder.h"
 #include "SkRefCnt.h"
 #include "SkStream.h"
 #include "SkTypes.h"
@@ -289,11 +289,9 @@
 DEF_TEST(ShortFrontBufferedStream, reporter) {
     FailingStream* failingStream = new FailingStream;
     SkAutoTDelete<SkStreamRewindable> stream(SkFrontBufferedStream::Create(failingStream, 64));
-    SkBitmap bm;
-    // The return value of DecodeStream is not important. We are just using DecodeStream because
-    // it simulates a bug. DecodeStream will read the stream, then rewind, then attempt to read
-    // again. FrontBufferedStream::read should not continue to read its underlying stream beyond
-    // its end.
-    SkImageDecoder::DecodeStream(stream, &bm);
+
+    // This will fail to create a codec.  However, what we really want to test is that we
+    // won't read past the end of the stream.
+    SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
     REPORTER_ASSERT(reporter, !failingStream->readAfterEnd());
 }
diff --git a/tests/GifTest.cpp b/tests/GifTest.cpp
index 978e374..caa0f6f 100644
--- a/tests/GifTest.cpp
+++ b/tests/GifTest.cpp
@@ -5,25 +5,16 @@
  * found in the LICENSE file.
  */
 
-#include "SkTypes.h"
-
-// This tests out GIF decoder (SkImageDecoder_libgif.cpp)
-// It is not used on these platforms:
-#if (!defined(SK_BUILD_FOR_WIN32)) &&           \
-    (!defined(SK_BUILD_FOR_IOS)) &&             \
-    (!defined(SK_BUILD_FOR_MAC))
-
+#include "CodecPriv.h"
 #include "Resources.h"
+#include "SkAndroidCodec.h"
 #include "SkBitmap.h"
 #include "SkData.h"
-#include "SkForceLinking.h"
 #include "SkImage.h"
-#include "SkImageDecoder.h"
 #include "SkStream.h"
+#include "SkTypes.h"
 #include "Test.h"
 
-__SK_FORCE_IMAGE_DECODER_LINKING;
-
 static unsigned char gGIFData[] = {
   0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x03, 0x00, 0x03, 0x00, 0xe3, 0x08,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00,
@@ -55,20 +46,18 @@
                                       void* data,
                                       size_t size) {
     SkBitmap bm;
-    bool imageDecodeSuccess = SkImageDecoder::DecodeMemory(
-        data, size, &bm);
+    bool imageDecodeSuccess = decode_memory(data, size, &bm);
     REPORTER_ASSERT(r, imageDecodeSuccess);
     REPORTER_ASSERT(r, bm.width() == 1);
     REPORTER_ASSERT(r, bm.height() == 1);
     REPORTER_ASSERT(r, !(bm.empty()));
     if (!(bm.empty())) {
-        REPORTER_ASSERT(r, bm.getColor(0, 0) == 0x00000000);
+        REPORTER_ASSERT(r, bm.getColor(0, 0) == 0xFF000000);
     }
 }
 static void test_gif_data(skiatest::Reporter* r, void* data, size_t size) {
     SkBitmap bm;
-    bool imageDecodeSuccess = SkImageDecoder::DecodeMemory(
-        data, size, &bm);
+    bool imageDecodeSuccess = decode_memory(data, size, &bm);
     REPORTER_ASSERT(r, imageDecodeSuccess);
     REPORTER_ASSERT(r, bm.width() == 3);
     REPORTER_ASSERT(r, bm.height() == 3);
@@ -85,12 +74,20 @@
         REPORTER_ASSERT(r, bm.getColor(2, 2) == 0xff0000ff);
     }
 }
+static void test_gif_data_dims(skiatest::Reporter* r, void* data, size_t size, int width,
+        int height) {
+    SkBitmap bm;
+    bool imageDecodeSuccess = decode_memory(data, size, &bm);
+    REPORTER_ASSERT(r, imageDecodeSuccess);
+    REPORTER_ASSERT(r, bm.width() == width);
+    REPORTER_ASSERT(r, bm.height() == height);
+    REPORTER_ASSERT(r, !(bm.empty()));
+}
 static void test_interlaced_gif_data(skiatest::Reporter* r,
                                      void* data,
                                      size_t size) {
     SkBitmap bm;
-    bool imageDecodeSuccess = SkImageDecoder::DecodeMemory(
-        data, size, &bm);
+    bool imageDecodeSuccess = decode_memory(data, size, &bm);
     REPORTER_ASSERT(r, imageDecodeSuccess);
     REPORTER_ASSERT(r, bm.width() == 9);
     REPORTER_ASSERT(r, bm.height() == 9);
@@ -122,8 +119,7 @@
                                 void* data,
                                 size_t size) {
     SkBitmap bm;
-    bool imageDecodeSuccess = SkImageDecoder::DecodeMemory(
-        data, size, &bm);
+    bool imageDecodeSuccess = decode_memory(data, size, &bm);
     REPORTER_ASSERT(r, imageDecodeSuccess);
     REPORTER_ASSERT(r, bm.width() == 3);
     REPORTER_ASSERT(r, bm.height() == 3);
@@ -139,7 +135,7 @@
 }
 
 /**
-  This test will test the ability of the SkImageDecoder to deal with
+  This test will test the ability of the SkCodec to deal with
   GIF files which have been mangled somehow.  We want to display as
   much of the GIF as possible.
 */
@@ -151,10 +147,6 @@
 
     unsigned char badData[sizeof(gGIFData)];
 
-    /* If you set the environment variable
-       skia_images_gif_suppressDecoderWarnings to 'false', you will
-       see warnings on stderr.  This is a feature.  */
-
     memcpy(badData, gGIFData, sizeof(gGIFData));
     badData[6] = 0x01;  // image too wide
     test_gif_data(reporter, static_cast<void *>(badData), sizeof(gGIFData));
@@ -167,25 +159,21 @@
 
     memcpy(badData, gGIFData, sizeof(gGIFData));
     badData[62] = 0x01;  // image shifted right
-    test_gif_data(reporter, static_cast<void *>(badData), sizeof(gGIFData));
-    // "libgif warning [shifting image left to fit]"
+    test_gif_data_dims(reporter, static_cast<void *>(badData), sizeof(gGIFData), 4, 3);
 
     memcpy(badData, gGIFData, sizeof(gGIFData));
     badData[64] = 0x01;  // image shifted down
-    test_gif_data(reporter, static_cast<void *>(badData), sizeof(gGIFData));
-    // "libgif warning [shifting image up to fit]"
+    test_gif_data_dims(reporter, static_cast<void *>(badData), sizeof(gGIFData), 3, 4);
 
     memcpy(badData, gGIFData, sizeof(gGIFData));
-    badData[62] = 0xff;  // image shifted left
-    badData[63] = 0xff;  // 2's complement -1 short
-    test_gif_data(reporter, static_cast<void *>(badData), sizeof(gGIFData));
-    // "libgif warning [shifting image left to fit]"
+    badData[62] = 0xff;  // image shifted right
+    badData[63] = 0xff;
+    test_gif_data_dims(reporter, static_cast<void *>(badData), sizeof(gGIFData), 3 + 0xFFFF, 3);
 
     memcpy(badData, gGIFData, sizeof(gGIFData));
-    badData[64] = 0xff;  // image shifted up
-    badData[65] = 0xff;  // 2's complement -1 short
-    test_gif_data(reporter, static_cast<void *>(badData), sizeof(gGIFData));
-    // "libgif warning [shifting image up to fit]"
+    badData[64] = 0xff;  // image shifted down
+    badData[65] = 0xff;
+    test_gif_data_dims(reporter, static_cast<void *>(badData), sizeof(gGIFData), 3, 3 + 0xFFFF);
 
     test_gif_data_no_colormap(reporter, static_cast<void *>(gGIFDataNoColormap),
                               sizeof(gGIFDataNoColormap));
@@ -203,22 +191,39 @@
 // Regression test for decoding a gif image with sampleSize of 4, which was
 // previously crashing.
 DEF_TEST(Gif_Sampled, r) {
-    SkFILEStream fileStream(GetResourcePath("test640x479.gif").c_str());
-    REPORTER_ASSERT(r, fileStream.isValid());
-    if (!fileStream.isValid()) {
+    SkAutoTDelete<SkFILEStream> stream(
+            new SkFILEStream(GetResourcePath("test640x479.gif").c_str()));
+    REPORTER_ASSERT(r, stream->isValid());
+    if (!stream->isValid()) {
         return;
     }
 
-    SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(&fileStream));
-    REPORTER_ASSERT(r, decoder);
-    if (!decoder) {
+    SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.detach()));
+    REPORTER_ASSERT(r, codec);
+    if (!codec) {
         return;
     }
-    decoder->setSampleSize(4);
+
+    // Construct a color table for the decode if necessary
+    SkAutoTUnref<SkColorTable> colorTable(nullptr);
+    SkPMColor* colorPtr = nullptr;
+    int* colorCountPtr = nullptr;
+    int maxColors = 256;
+    if (kIndex_8_SkColorType == codec->getInfo().colorType()) {
+        SkPMColor colors[256];
+        colorTable.reset(new SkColorTable(colors, maxColors));
+        colorPtr = const_cast<SkPMColor*>(colorTable->readColors());
+        colorCountPtr = &maxColors;
+    }
+
+    SkAndroidCodec::AndroidOptions options;
+    options.fSampleSize = 4;
+    options.fColorPtr = colorPtr;
+    options.fColorCount = colorCountPtr;
+
     SkBitmap bm;
-    const SkImageDecoder::Result result = decoder->decode(&fileStream, &bm,
-            SkImageDecoder::kDecodePixels_Mode);
-    REPORTER_ASSERT(r, result == SkImageDecoder::kSuccess);
+    bm.allocPixels(codec->getInfo(), nullptr, colorTable.get());
+    const SkCodec::Result result = codec->getAndroidPixels(codec->getInfo(), bm.getPixels(),
+            bm.rowBytes(), &options);
+    REPORTER_ASSERT(r, result == SkCodec::kSuccess);
 }
-
-#endif  // !(SK_BUILD_FOR_WIN32||SK_BUILD_FOR_IOS||SK_BUILD_FOR_MAC)
diff --git a/tests/IndexedPngOverflowTest.cpp b/tests/IndexedPngOverflowTest.cpp
index 78f8d94..f516898 100644
--- a/tests/IndexedPngOverflowTest.cpp
+++ b/tests/IndexedPngOverflowTest.cpp
@@ -5,10 +5,9 @@
  * found in the LICENSE file.
  */
 
+#include "CodecPriv.h"
 #include "SkBitmap.h"
 #include "SkCanvas.h"
-#include "SkForceLinking.h"
-#include "SkImageDecoder.h"
 #include "SkImageInfo.h"
 #include "SkSurface.h"
 #include "Test.h"
@@ -31,10 +30,7 @@
 
 DEF_TEST(IndexedPngOverflow, reporter) {
     SkBitmap image;
-    SkForceLinking(false);
-    bool success = SkImageDecoder::DecodeMemory(
-        gPng, sizeof(gPng), &image, SkColorType::kUnknown_SkColorType,
-        SkImageDecoder::kDecodePixels_Mode);
+    bool success = decode_memory(gPng, sizeof(gPng), &image);
     REPORTER_ASSERT(reporter, success);
 
     SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(SkImageInfo::MakeN32Premul(20, 1)));
diff --git a/tests/InvalidIndexedPngTest.cpp b/tests/InvalidIndexedPngTest.cpp
index 7ae99fd..5d9632d 100644
--- a/tests/InvalidIndexedPngTest.cpp
+++ b/tests/InvalidIndexedPngTest.cpp
@@ -5,9 +5,8 @@
  * found in the LICENSE file.
  */
 
+#include "CodecPriv.h"
 #include "SkBitmap.h"
-#include "SkForceLinking.h"
-#include "SkImageDecoder.h"
 #include "Test.h"
 
 // A valid 1x1 indexed PNG.
@@ -30,9 +29,8 @@
 // As a result, we do not have any REPORTER_ASSERT statements
 DEF_TEST(InvalidIndexedPng, reporter) {
     SkBitmap image;
-    SkForceLinking(false);
     // Make our PNG invalid by changing a byte.
     gPngData[sizeof(gPngData) - 1] = 1;
 
-    SkImageDecoder::DecodeMemory(gPngData, sizeof(gPngData), &image);
+    decode_memory(gPngData, sizeof(gPngData), &image);
 }
diff --git a/tests/KtxTest.cpp b/tests/KtxTest.cpp
deleted file mode 100644
index 7220cbf..0000000
--- a/tests/KtxTest.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "Resources.h"
-#include "SkBitmap.h"
-#include "SkData.h"
-#include "SkImageGenerator.h"
-#include "SkForceLinking.h"
-#include "SkImageDecoder.h"
-#include "SkOSFile.h"
-#include "SkRandom.h"
-#include "SkStream.h"
-#include "Test.h"
-
-__SK_FORCE_IMAGE_DECODER_LINKING;
-
-/**
- * First, make sure that writing an 8-bit RGBA KTX file and then
- * reading it produces the same bitmap.
- */
-DEF_TEST(KtxReadWrite, reporter) {
-
-    // Random number generator with explicit seed for reproducibility
-    SkRandom rand(0x1005cbad);
-
-    SkBitmap bm8888;
-    bm8888.allocN32Pixels(128, 128);
-
-    uint8_t *pixels = reinterpret_cast<uint8_t*>(bm8888.getPixels());
-    REPORTER_ASSERT(reporter, pixels);
-
-    if (nullptr == pixels) {
-        return;
-    }
-    
-    uint8_t *row = pixels;
-    for (int y = 0; y < bm8888.height(); ++y) {        
-        for (int x = 0; x < bm8888.width(); ++x) {
-            uint8_t a = rand.nextRangeU(0, 255);
-            uint8_t r = rand.nextRangeU(0, 255);
-            uint8_t g = rand.nextRangeU(0, 255);
-            uint8_t b = rand.nextRangeU(0, 255);
-
-            SkPMColor &pixel = *(reinterpret_cast<SkPMColor*>(row + x*sizeof(SkPMColor)));
-            pixel = SkPreMultiplyARGB(a, r, g, b);
-        }
-        row += bm8888.rowBytes();
-    }
-    REPORTER_ASSERT(reporter, !(bm8888.empty()));
-
-    SkAutoDataUnref encodedData(SkImageEncoder::EncodeData(bm8888, SkImageEncoder::kKTX_Type, 0));
-    if (nullptr == encodedData.get()) {
-        ERRORF(reporter, "failed to encode the bitmap to KTX");
-        return;
-    }
-
-
-    SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(encodedData));
-    REPORTER_ASSERT(reporter, stream);
-
-    SkBitmap decodedBitmap;
-    bool imageDecodeSuccess = SkImageDecoder::DecodeStream(stream, &decodedBitmap);
-    if (!imageDecodeSuccess) {
-        ERRORF(reporter, "failed to decode the KTX stream");
-        return;
-    }
-
-    REPORTER_ASSERT(reporter, decodedBitmap.colorType() == bm8888.colorType());
-    REPORTER_ASSERT(reporter, decodedBitmap.alphaType() == bm8888.alphaType());
-    REPORTER_ASSERT(reporter, decodedBitmap.width() == bm8888.width());
-    REPORTER_ASSERT(reporter, decodedBitmap.height() == bm8888.height());
-    REPORTER_ASSERT(reporter, !(decodedBitmap.empty()));
-
-    uint8_t *decodedPixels = reinterpret_cast<uint8_t*>(decodedBitmap.getPixels());
-    REPORTER_ASSERT(reporter, decodedPixels);
-    REPORTER_ASSERT(reporter, decodedBitmap.getSize() == bm8888.getSize());
-
-    if (nullptr == decodedPixels) {
-        return;
-    }
-
-    REPORTER_ASSERT(reporter, memcmp(decodedPixels, pixels, decodedBitmap.getSize()) == 0);
-}
-
-/**
- * Next test is to see whether or not reading an unpremultiplied KTX file accurately
- * creates a premultiplied buffer...
- */
-DEF_TEST(KtxReadUnpremul, reporter) {
-
-    static const uint8_t kHalfWhiteKTX[] = {
-        0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, // First twelve bytes is magic
-        0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A, // KTX identifier string
-        0x01, 0x02, 0x03, 0x04, // Then magic endian specifier
-        0x01, 0x14, 0x00, 0x00, // uint32_t fGLType;
-        0x01, 0x00, 0x00, 0x00, // uint32_t fGLTypeSize;
-        0x08, 0x19, 0x00, 0x00, // uint32_t fGLFormat;
-        0x58, 0x80, 0x00, 0x00, // uint32_t fGLInternalFormat;
-        0x08, 0x19, 0x00, 0x00, // uint32_t fGLBaseInternalFormat;
-        0x02, 0x00, 0x00, 0x00, // uint32_t fPixelWidth;
-        0x02, 0x00, 0x00, 0x00, // uint32_t fPixelHeight;
-        0x00, 0x00, 0x00, 0x00, // uint32_t fPixelDepth;
-        0x00, 0x00, 0x00, 0x00, // uint32_t fNumberOfArrayElements;
-        0x01, 0x00, 0x00, 0x00, // uint32_t fNumberOfFaces;
-        0x01, 0x00, 0x00, 0x00, // uint32_t fNumberOfMipmapLevels;
-        0x00, 0x00, 0x00, 0x00, // uint32_t fBytesOfKeyValueData;
-        0x10, 0x00, 0x00, 0x00, // image size: 2x2 image of RGBA = 4 * 4 = 16 bytes
-        0xFF, 0xFF, 0xFF, 0x80, // Pixel 1
-        0xFF, 0xFF, 0xFF, 0x80, // Pixel 2
-        0xFF, 0xFF, 0xFF, 0x80, // Pixel 3
-        0xFF, 0xFF, 0xFF, 0x80};// Pixel 4
-
-    SkAutoTDelete<SkMemoryStream> stream(new SkMemoryStream(kHalfWhiteKTX, sizeof(kHalfWhiteKTX)));
-    REPORTER_ASSERT(reporter, stream);
-
-    SkBitmap decodedBitmap;
-    bool imageDecodeSuccess = SkImageDecoder::DecodeStream(stream, &decodedBitmap);
-    if (!imageDecodeSuccess) {
-        ERRORF(reporter, "failed to decode the KTX stream");
-        return;
-    }
-
-    REPORTER_ASSERT(reporter, decodedBitmap.colorType() == kN32_SkColorType);
-    REPORTER_ASSERT(reporter, decodedBitmap.alphaType() == kPremul_SkAlphaType);
-    REPORTER_ASSERT(reporter, decodedBitmap.width() == 2);
-    REPORTER_ASSERT(reporter, decodedBitmap.height() == 2);
-    REPORTER_ASSERT(reporter, !(decodedBitmap.empty()));
-
-    uint8_t *decodedPixels = reinterpret_cast<uint8_t*>(decodedBitmap.getPixels());
-    REPORTER_ASSERT(reporter, decodedPixels);
-
-    uint8_t *row = decodedPixels;
-    for (int j = 0; j < decodedBitmap.height(); ++j) {
-        for (int i = 0; i < decodedBitmap.width(); ++i) {
-            SkPMColor pixel = *(reinterpret_cast<SkPMColor*>(row + i*sizeof(SkPMColor)));
-            REPORTER_ASSERT(reporter, SkPreMultiplyARGB(0x80, 0xFF, 0xFF, 0xFF) == pixel);
-        }
-        row += decodedBitmap.rowBytes();
-    }
-}
diff --git a/tests/PathOpsSkpClipTest.cpp b/tests/PathOpsSkpClipTest.cpp
index 326abb6..6d66a69 100644
--- a/tests/PathOpsSkpClipTest.cpp
+++ b/tests/PathOpsSkpClipTest.cpp
@@ -16,7 +16,6 @@
 #include "SkDevice.h"
 #include "SkForceLinking.h"
 #include "SkGraphics.h"
-#include "SkImageDecoder.h"
 #include "SkImageEncoder.h"
 #include "SkOSFile.h"
 #include "SkPathOpsDebug.h"
@@ -33,8 +32,6 @@
 
 #include <stdlib.h>
 
-__SK_FORCE_IMAGE_DECODER_LINKING;
-
 /* add local exceptions here */
 /* TODO : add command flag interface */
 const struct SkipOverTest {
@@ -470,7 +467,7 @@
             SkDebugf("invalid stream %s\n", path.c_str());
             goto finish;
         }
-        pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::DecodeMemory);
+        pic = SkPicture::CreateFromStream(&stream);
         if (!pic) {
             SkDebugf("unable to decode %s\n", fFilename);
             goto finish;
diff --git a/tests/SkpSkGrTest.cpp b/tests/SkpSkGrTest.cpp
index 8cc7ec4..67a6b26 100644
--- a/tests/SkpSkGrTest.cpp
+++ b/tests/SkpSkGrTest.cpp
@@ -16,7 +16,6 @@
 #include "SkColor.h"
 #include "SkDevice.h"
 #include "SkGraphics.h"
-#include "SkImageDecoder.h"
 #include "SkImageEncoder.h"
 #include "SkOSFile.h"
 #include "SkPicture.h"
@@ -400,7 +399,7 @@
             wStream.write(&bytes[0], length);
             wStream.flush();
         }
-        pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::DecodeMemory);
+        pic = SkPicture::CreateFromStream(&stream);
         if (!pic) {
             SkDebugf("unable to decode %s\n", fFilename);
             goto finish;