aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bench/ETCBitmapBench.cpp6
-rw-r--r--gm/astcbitmap.cpp6
-rw-r--r--gm/colorwheel.cpp1
-rw-r--r--gm/etc1bitmap.cpp10
-rw-r--r--gm/factory.cpp7
-rw-r--r--gm/image.cpp4
-rw-r--r--gyp/images.gyp2
-rw-r--r--include/core/SkImage.h9
-rw-r--r--include/core/SkImageGenerator.h5
-rw-r--r--samplecode/SampleEncode.cpp7
-rw-r--r--samplecode/SamplePicture.cpp5
-rw-r--r--src/c/sk_surface.cpp12
-rw-r--r--src/image/SkImage.cpp9
-rw-r--r--src/image/SkImage_Raster.cpp2
-rw-r--r--src/lazy/SkDiscardablePixelRef.cpp8
-rw-r--r--src/ports/SkImageGenerator_skia.cpp116
-rw-r--r--src/utils/SkLua.cpp5
-rw-r--r--tests/CachedDecodingPixelRefTest.cpp9
-rw-r--r--tests/ImageDecodingTest.cpp4
-rw-r--r--tests/KtxTest.cpp6
-rw-r--r--tests/PDFJpegEmbedTest.cpp5
-rw-r--r--tests/PictureTest.cpp5
-rw-r--r--tests/SurfaceTest.cpp4
-rw-r--r--tools/LazyDecodeBitmap.cpp5
-rw-r--r--tools/Resources.cpp6
25 files changed, 177 insertions, 81 deletions
diff --git a/bench/ETCBitmapBench.cpp b/bench/ETCBitmapBench.cpp
index 36573c8245..4255923c4b 100644
--- a/bench/ETCBitmapBench.cpp
+++ b/bench/ETCBitmapBench.cpp
@@ -9,7 +9,7 @@
#include "Resources.h"
#include "SkCanvas.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
+#include "SkImageGenerator.h"
#include "SkImageDecoder.h"
#include "SkOSFile.h"
#include "SkPixelRef.h"
@@ -151,9 +151,7 @@ protected:
}
// Install pixel ref
- if (!SkInstallDiscardablePixelRef(
- SkDecodingImageGenerator::Create(
- fPKMData, SkDecodingImageGenerator::Options()), &(this->fBitmap))) {
+ if (!SkInstallDiscardablePixelRef(fPKMData, &(this->fBitmap))) {
SkDebugf("Could not install discardable pixel ref.\n");
return;
}
diff --git a/gm/astcbitmap.cpp b/gm/astcbitmap.cpp
index 3c9079cfa8..b415a82a66 100644
--- a/gm/astcbitmap.cpp
+++ b/gm/astcbitmap.cpp
@@ -10,7 +10,7 @@
#include "Resources.h"
#include "SkCanvas.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
+#include "SkImageGenerator.h"
#include "SkImageDecoder.h"
#include "SkOSFile.h"
#include "SkTextureCompressor.h"
@@ -76,9 +76,7 @@ protected:
}
SkBitmap bm;
- if (!SkInstallDiscardablePixelRef(
- SkDecodingImageGenerator::Create(
- fileData, SkDecodingImageGenerator::Options()), &bm)) {
+ if (!SkInstallDiscardablePixelRef(fileData, &bm)) {
SkDebugf("Could not install discardable pixel ref.\n");
return;
}
diff --git a/gm/colorwheel.cpp b/gm/colorwheel.cpp
index 93af361720..f74eaf6a98 100644
--- a/gm/colorwheel.cpp
+++ b/gm/colorwheel.cpp
@@ -7,7 +7,6 @@
#include "Resources.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
#include "gm.h"
#include "sk_tool_utils.h"
diff --git a/gm/etc1bitmap.cpp b/gm/etc1bitmap.cpp
index fcf521a180..76593f4441 100644
--- a/gm/etc1bitmap.cpp
+++ b/gm/etc1bitmap.cpp
@@ -10,7 +10,7 @@
#include "Resources.h"
#include "SkCanvas.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
+#include "SkImageGenerator.h"
#include "SkImageDecoder.h"
#include "SkOSFile.h"
@@ -103,9 +103,7 @@ protected:
return;
}
- if (!SkInstallDiscardablePixelRef(
- SkDecodingImageGenerator::Create(
- fileData, SkDecodingImageGenerator::Options()), &bm)) {
+ if (!SkInstallDiscardablePixelRef(fileData, &bm)) {
SkDebugf("Could not install discardable pixel ref.\n");
return;
}
@@ -204,9 +202,7 @@ protected:
size_t dataSz = etc1_get_encoded_data_size(width, height) + ETC_PKM_HEADER_SIZE;
SkAutoDataUnref nonPOTData(SkData::NewWithCopy(am.get(), dataSz));
- if (!SkInstallDiscardablePixelRef(
- SkDecodingImageGenerator::Create(
- nonPOTData, SkDecodingImageGenerator::Options()), &bm)) {
+ if (!SkInstallDiscardablePixelRef(nonPOTData, &bm)) {
SkDebugf("Could not install discardable pixel ref.\n");
return;
}
diff --git a/gm/factory.cpp b/gm/factory.cpp
index a9bf519c00..9cc5bb8df4 100644
--- a/gm/factory.cpp
+++ b/gm/factory.cpp
@@ -10,7 +10,6 @@
#include "Resources.h"
#include "SkCanvas.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
#include "SkDiscardableMemoryPool.h"
#include "SkDiscardablePixelRef.h"
#include "SkImageDecoder.h"
@@ -37,10 +36,8 @@ protected:
// bitmap is unlocked.
SkAutoTUnref<SkDiscardableMemoryPool> pool(
SkDiscardableMemoryPool::Create(1));
- SkAssertResult(SkInstallDiscardablePixelRef(
- SkDecodingImageGenerator::Create(
- data, SkDecodingImageGenerator::Options()),
- &fBitmap, pool));
+ SkAssertResult(SkInstallDiscardablePixelRef(SkImageGenerator::NewFromData(data),
+ &fBitmap, pool));
}
}
diff --git a/gm/image.cpp b/gm/image.cpp
index 05a3fab2b4..bd7bbe7952 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -8,7 +8,6 @@
#include "gm.h"
#include "SkSurface.h"
#include "SkCanvas.h"
-#include "SkDecodingImageGenerator.h"
#include "SkStream.h"
#include "SkData.h"
@@ -24,8 +23,7 @@ static void drawJpeg(SkCanvas* canvas, const SkISize& size) {
if (NULL == data.get()) {
return;
}
- SkImage* image = SkImage::NewFromGenerator(
- SkDecodingImageGenerator::Create(data, SkDecodingImageGenerator::Options()));
+ SkImage* image = SkImage::NewFromData(data);
if (image) {
SkAutoCanvasRestore acr(canvas, true);
canvas->scale(size.width() * 1.0f / image->width(),
diff --git a/gyp/images.gyp b/gyp/images.gyp
index 13cf3bbf9a..75eb76b9e8 100644
--- a/gyp/images.gyp
+++ b/gyp/images.gyp
@@ -70,6 +70,8 @@
'../src/images/SkScaledBitmapSampler.cpp',
'../src/images/SkScaledBitmapSampler.h',
+ '../src/ports/SkImageGenerator_skia.cpp',
+
'../src/ports/SkImageDecoder_CG.cpp',
'../src/ports/SkImageDecoder_WIC.cpp',
],
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 5ce32eafb7..9cc26ed4be 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -63,6 +63,15 @@ public:
*/
static SkImage* NewFromGenerator(SkImageGenerator*);
+ /**
+ * Construct a new SkImage based on the specified encoded data. Returns NULL on failure,
+ * which can mean that the format of the encoded data was not recognized/supported.
+ *
+ * Regardless of success or failure, the caller is responsible for managing their ownership
+ * of the data.
+ */
+ static SkImage* NewFromData(SkData* data);
+
int width() const { return fWidth; }
int height() const { return fHeight; }
uint32_t uniqueID() const { return fUniqueID; }
diff --git a/include/core/SkImageGenerator.h b/include/core/SkImageGenerator.h
index 635a8d4b44..cbceaa2308 100644
--- a/include/core/SkImageGenerator.h
+++ b/include/core/SkImageGenerator.h
@@ -35,6 +35,11 @@ class SkImageGenerator;
*/
SK_API bool SkInstallDiscardablePixelRef(SkImageGenerator*, SkBitmap* destination);
+/**
+ * On success, installs a discradable pixelref into destination, based on encoded data.
+ * Regardless of success or failure, the caller must still balance their ownership of encoded.
+ */
+SK_API bool SkInstallDiscardablePixelRef(SkData* encoded, SkBitmap* destination);
/**
* An interface that allows a purgeable PixelRef (such as a
diff --git a/samplecode/SampleEncode.cpp b/samplecode/SampleEncode.cpp
index e65b2d3855..185208b35b 100644
--- a/samplecode/SampleEncode.cpp
+++ b/samplecode/SampleEncode.cpp
@@ -9,7 +9,7 @@
#include "SkView.h"
#include "SkCanvas.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
+#include "SkImageGenerator.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
#include "SkImageDecoder.h"
@@ -193,10 +193,7 @@ protected:
encoded = fEncodedPNGs[i].get();
}
if (encoded) {
- if (!SkInstallDiscardablePixelRef(
- SkDecodingImageGenerator::Create(encoded,
- SkDecodingImageGenerator::Options()),
- &bm)) {
+ if (!SkInstallDiscardablePixelRef(encoded, &bm)) {
SkDebugf("[%s:%d] failed to decode %s%s\n",
__FILE__, __LINE__,gConfigLabels[i], gExt[j]);
}
diff --git a/samplecode/SamplePicture.cpp b/samplecode/SamplePicture.cpp
index 46c57d7f39..c78571a89b 100644
--- a/samplecode/SamplePicture.cpp
+++ b/samplecode/SamplePicture.cpp
@@ -13,7 +13,7 @@
#include "SkColorFilter.h"
#include "SkColorPriv.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
+#include "SkImageGenerator.h"
#include "SkDumpCanvas.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
@@ -40,8 +40,7 @@ static SkBitmap load_bitmap() {
SkString pngFilename = GetResourcePath("mandrill_512.png");
SkAutoDataUnref data(SkData::NewFromFileName(pngFilename.c_str()));
if (data.get() != NULL) {
- SkInstallDiscardablePixelRef(SkDecodingImageGenerator::Create(
- data, SkDecodingImageGenerator::Options()), &bm);
+ SkInstallDiscardablePixelRef(data, &bm);
}
return bm;
}
diff --git a/src/c/sk_surface.cpp b/src/c/sk_surface.cpp
index b60596008f..89b53d0a0e 100644
--- a/src/c/sk_surface.cpp
+++ b/src/c/sk_surface.cpp
@@ -230,18 +230,8 @@ sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t* cinfo, const void* pi
return (sk_image_t*)SkImage::NewRasterCopy(info, pixels, rowBytes);
}
-#include "SkDecodingImageGenerator.h"
-
sk_image_t* sk_image_new_from_data(const sk_data_t* cdata) {
- SkImageGenerator* gen = NULL;
-#if 0
- // enable this when SkDecodingImageGenerator is available in chrome (decode codecs)
- gen = SkDecodingImageGenerator::Create(AsData(cdata), SkDecodingImageGenerator::Options());
-#endif
- if (NULL == gen) {
- return NULL;
- }
- return ToImage(SkImage::NewFromGenerator(gen));
+ return ToImage(SkImage::NewFromData(AsData(cdata)));
}
sk_data_t* sk_image_encode(const sk_image_t* cimage) {
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 8796b03283..97e7475a34 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -7,6 +7,7 @@
#include "SkBitmap.h"
#include "SkCanvas.h"
+#include "SkImageGenerator.h"
#include "SkImagePriv.h"
#include "SkImage_Base.h"
#include "SkReadPixelsRec.h"
@@ -72,6 +73,14 @@ SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const {
return NULL;
}
+SkImage* SkImage::NewFromData(SkData* data) {
+ if (NULL == data) {
+ return NULL;
+ }
+ SkImageGenerator* generator = SkImageGenerator::NewFromData(data);
+ return generator ? SkImage::NewFromGenerator(generator) : NULL;
+}
+
SkSurface* SkImage::newSurface(const SkImageInfo& info, const SkSurfaceProps* props) const {
if (NULL == props) {
props = &as_IB(this)->props();
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 0ee391464f..01a287bdc4 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -10,7 +10,7 @@
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
+#include "SkImageGenerator.h"
#include "SkSurface.h"
class SkImage_Raster : public SkImage_Base {
diff --git a/src/lazy/SkDiscardablePixelRef.cpp b/src/lazy/SkDiscardablePixelRef.cpp
index 84152ed188..4b7d47b94d 100644
--- a/src/lazy/SkDiscardablePixelRef.cpp
+++ b/src/lazy/SkDiscardablePixelRef.cpp
@@ -116,7 +116,13 @@ bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst,
return true;
}
-// This is the public API
+// These are the public API
+
bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst) {
return SkInstallDiscardablePixelRef(generator, dst, NULL);
}
+
+bool SkInstallDiscardablePixelRef(SkData* encoded, SkBitmap* dst) {
+ SkImageGenerator* generator = SkImageGenerator::NewFromData(encoded);
+ return generator ? SkInstallDiscardablePixelRef(generator, dst, NULL) : false;
+}
diff --git a/src/ports/SkImageGenerator_skia.cpp b/src/ports/SkImageGenerator_skia.cpp
new file mode 100644
index 0000000000..cd02ae2567
--- /dev/null
+++ b/src/ports/SkImageGenerator_skia.cpp
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkData.h"
+#include "SkImageDecoder.h"
+#include "SkImageGenerator.h"
+#include "SkStream.h"
+
+class BareMemoryAllocator : public SkBitmap::Allocator {
+ const SkImageInfo fInfo;
+ void* const fMemory;
+ const size_t fRowBytes;
+
+public:
+ BareMemoryAllocator(const SkImageInfo& info, void* memory, size_t rowBytes)
+ : fInfo(info), fMemory(memory), fRowBytes(rowBytes)
+ {}
+
+protected:
+ bool allocPixelRef(SkBitmap* bm, SkColorTable* ctable) SK_OVERRIDE {
+ const SkImageInfo bmi = bm->info();
+ if (bmi.width() != fInfo.width() || bmi.height() != fInfo.height() ||
+ bmi.colorType() != fInfo.colorType())
+ {
+ return false;
+ }
+ return bm->installPixels(bmi, fMemory, fRowBytes, ctable, NULL, NULL);
+ }
+};
+
+class SkImageDecoderGenerator : public SkImageGenerator {
+ const SkImageInfo fInfo;
+ SkAutoTDelete<SkImageDecoder> fDecoder;
+ SkAutoTUnref<SkData> fData;
+
+public:
+ SkImageDecoderGenerator(const SkImageInfo& info, SkImageDecoder* decoder, SkData* data)
+ : fInfo(info), fDecoder(decoder), fData(SkRef(data))
+ {}
+
+protected:
+ SkData* onRefEncodedData() SK_OVERRIDE {
+ return SkRef(fData.get());
+ }
+
+ virtual bool onGetInfo(SkImageInfo* info) {
+ *info = fInfo;
+ return true;
+ }
+
+ virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ SkPMColor ctableEntries[], int* ctableCount) {
+ SkMemoryStream stream(fData->data(), fData->size(), false);
+ SkAutoTUnref<BareMemoryAllocator> allocator(SkNEW_ARGS(BareMemoryAllocator,
+ (info, pixels, rowBytes)));
+ fDecoder->setAllocator(allocator);
+ fDecoder->setRequireUnpremultipliedColors(kUnpremul_SkAlphaType == info.alphaType());
+
+ SkBitmap bm;
+ SkImageDecoder::Result result = fDecoder->decode(&stream, &bm, info.colorType(),
+ SkImageDecoder::kDecodePixels_Mode);
+ switch (result) {
+ case SkImageDecoder::kSuccess:
+ break;
+ default:
+ return false;
+ }
+
+ SkASSERT(info.colorType() == bm.info().colorType());
+
+ if (kIndex_8_SkColorType == info.colorType()) {
+ SkASSERT(ctableEntries);
+
+ SkColorTable* ctable = bm.getColorTable();
+ if (NULL == ctable) {
+ return false;
+ }
+ const int count = ctable->count();
+ memcpy(ctableEntries, ctable->readColors(), count * sizeof(SkPMColor));
+ *ctableCount = count;
+ }
+ return true;
+ }
+
+ bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
+ SkYUVColorSpace* colorSpace) SK_OVERRIDE {
+ SkMemoryStream stream(fData->data(), fData->size(), false);
+ return fDecoder->decodeYUV8Planes(&stream, sizes, planes, rowBytes, colorSpace);
+ }
+
+};
+
+SkImageGenerator* SkImageGenerator::NewFromData(SkData* data) {
+ if (NULL == data) {
+ return NULL;
+ }
+
+ SkMemoryStream stream(data->data(), data->size(), false);
+ SkImageDecoder* decoder = SkImageDecoder::Factory(&stream);
+ if (NULL == decoder) {
+ return NULL;
+ }
+
+ SkBitmap bm;
+ stream.rewind();
+ if (!decoder->decode(&stream, &bm, kUnknown_SkColorType, SkImageDecoder::kDecodeBounds_Mode)) {
+ SkDELETE(decoder);
+ return NULL;
+ }
+
+ return SkNEW_ARGS(SkImageDecoderGenerator, (bm.info(), decoder, data));
+}
diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp
index 2370b9925c..ba79933c18 100644
--- a/src/utils/SkLua.cpp
+++ b/src/utils/SkLua.cpp
@@ -14,7 +14,6 @@
#include "SkBlurImageFilter.h"
#include "SkCanvas.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
#include "SkDocument.h"
#include "SkGradientShader.h"
#include "SkImage.h"
@@ -2008,9 +2007,7 @@ static int lsk_loadImage(lua_State* L) {
const char* name = lua_tolstring(L, 1, NULL);
SkAutoDataUnref data(SkData::NewFromFileName(name));
if (data.get()) {
- SkImage* image = SkImage::NewFromGenerator(
- SkDecodingImageGenerator::Create(data, SkDecodingImageGenerator::Options()));
-
+ SkImage* image = SkImage::NewFromData(data);
if (image) {
push_ref(L, image)->unref();
return 1;
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
index b3eb5327d9..48100e714b 100644
--- a/tests/CachedDecodingPixelRefTest.cpp
+++ b/tests/CachedDecodingPixelRefTest.cpp
@@ -9,7 +9,6 @@
#include "SkCachingPixelRef.h"
#include "SkCanvas.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
#include "SkDiscardableMemoryPool.h"
#include "SkImageDecoder.h"
#include "SkImageGeneratorPriv.h"
@@ -143,15 +142,11 @@ static void test_three_encodings(skiatest::Reporter* reporter,
////////////////////////////////////////////////////////////////////////////////
static bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) {
- return SkCachingPixelRef::Install(
- SkDecodingImageGenerator::Create(
- encoded, SkDecodingImageGenerator::Options()), dst);
+ return SkCachingPixelRef::Install(SkImageGenerator::NewFromData(encoded), dst);
}
static bool install_skDiscardablePixelRef(SkData* encoded, SkBitmap* dst) {
// Use system-default discardable memory.
- return SkInstallDiscardablePixelRef(
- SkDecodingImageGenerator::Create(
- encoded, SkDecodingImageGenerator::Options()), dst);
+ return SkInstallDiscardablePixelRef(encoded, dst);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/tests/ImageDecodingTest.cpp b/tests/ImageDecodingTest.cpp
index 762852d62a..528c295d93 100644
--- a/tests/ImageDecodingTest.cpp
+++ b/tests/ImageDecodingTest.cpp
@@ -455,9 +455,7 @@ DEF_TEST(WebP, reporter) {
sizeof(encodedWebP)));
SkBitmap bm;
- bool success = SkInstallDiscardablePixelRef(
- SkDecodingImageGenerator::Create(encoded,
- SkDecodingImageGenerator::Options()), &bm);
+ bool success = SkInstallDiscardablePixelRef(encoded, &bm);
REPORTER_ASSERT(reporter, success);
if (!success) {
diff --git a/tests/KtxTest.cpp b/tests/KtxTest.cpp
index 499db6ab48..23c1d70900 100644
--- a/tests/KtxTest.cpp
+++ b/tests/KtxTest.cpp
@@ -8,7 +8,7 @@
#include "Resources.h"
#include "SkBitmap.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
+#include "SkImageGenerator.h"
#include "SkForceLinking.h"
#include "SkImageDecoder.h"
#include "SkOSFile.h"
@@ -151,9 +151,7 @@ DEF_TEST(KtxReexportPKM, reporter) {
}
bool installDiscardablePixelRefSuccess =
- SkInstallDiscardablePixelRef(
- SkDecodingImageGenerator::Create(
- fileData, SkDecodingImageGenerator::Options()), &etcBitmap);
+ SkInstallDiscardablePixelRef(fileData, &etcBitmap);
REPORTER_ASSERT(reporter, installDiscardablePixelRefSuccess);
// Write the bitmap out to a KTX file.
diff --git a/tests/PDFJpegEmbedTest.cpp b/tests/PDFJpegEmbedTest.cpp
index 422b59a18f..beb949dfc9 100644
--- a/tests/PDFJpegEmbedTest.cpp
+++ b/tests/PDFJpegEmbedTest.cpp
@@ -10,7 +10,6 @@
#include "SkImageGenerator.h"
#include "SkData.h"
#include "SkStream.h"
-#include "SkDecodingImageGenerator.h"
#include "Resources.h"
#include "Test.h"
@@ -19,9 +18,7 @@
static SkBitmap bitmap_from_data(SkData* data) {
SkASSERT(data);
SkBitmap bm;
- SkInstallDiscardablePixelRef(
- SkDecodingImageGenerator::Create(
- data, SkDecodingImageGenerator::Options()), &bm);
+ SkInstallDiscardablePixelRef(data, &bm);
return bm;
}
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index a66185b95b..c2e1bb103c 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -12,7 +12,7 @@
#include "SkColorPriv.h"
#include "SkDashPathEffect.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
+#include "SkImageGenerator.h"
#include "SkError.h"
#include "SkImageEncoder.h"
#include "SkImageGenerator.h"
@@ -1495,8 +1495,7 @@ static void test_bitmap_with_encoded_data(skiatest::Reporter* reporter) {
SkAutoDataUnref data(wStream.copyToData());
SkBitmap bm;
- bool installSuccess = SkInstallDiscardablePixelRef(
- SkDecodingImageGenerator::Create(data, SkDecodingImageGenerator::Options()), &bm);
+ bool installSuccess = SkInstallDiscardablePixelRef(data, &bm);
REPORTER_ASSERT(reporter, installSuccess);
// Write both bitmaps to pictures, and ensure that the resulting data streams are the same.
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index d8c6d9d76c..c09d97cabe 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -7,7 +7,6 @@
#include "SkCanvas.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
#include "SkImageEncoder.h"
#include "SkRRect.h"
#include "SkSurface.h"
@@ -139,8 +138,7 @@ static SkImage* createImage(ImageType imageType, GrContext* context, SkColor col
bitmap.installPixels(info, addr, rowBytes);
SkAutoTUnref<SkData> src(
SkImageEncoder::EncodeData(bitmap, SkImageEncoder::kPNG_Type, 100));
- return SkImage::NewFromGenerator(
- SkDecodingImageGenerator::Create(src, SkDecodingImageGenerator::Options()));
+ return SkImage::NewFromData(src);
}
}
SkASSERT(false);
diff --git a/tools/LazyDecodeBitmap.cpp b/tools/LazyDecodeBitmap.cpp
index ec275eacab..0dca16b3f1 100644
--- a/tools/LazyDecodeBitmap.cpp
+++ b/tools/LazyDecodeBitmap.cpp
@@ -8,7 +8,6 @@
#include "LazyDecodeBitmap.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
#include "SkDiscardableMemoryPool.h"
#include "SkImageGeneratorPriv.h"
#include "SkForceLinking.h"
@@ -31,9 +30,7 @@ bool sk_tools::LazyDecodeBitmap(const void* src,
return false;
}
- SkAutoTDelete<SkImageGenerator> gen(
- SkDecodingImageGenerator::Create(
- data, SkDecodingImageGenerator::Options()));
+ SkAutoTDelete<SkImageGenerator> gen(SkImageGenerator::NewFromData(data));
SkImageInfo info;
if ((NULL == gen.get()) || !gen->getInfo(&info)) {
return false;
diff --git a/tools/Resources.cpp b/tools/Resources.cpp
index 50c08922fa..43cc21d209 100644
--- a/tools/Resources.cpp
+++ b/tools/Resources.cpp
@@ -9,7 +9,7 @@
#include "SkBitmap.h"
#include "SkCommandLineFlags.h"
#include "SkData.h"
-#include "SkDecodingImageGenerator.h"
+#include "SkImageGenerator.h"
#include "SkOSFile.h"
DEFINE_string2(resourcePath, i, "resources", "Directory with test resources: images, fonts, etc.");
@@ -26,7 +26,5 @@ bool GetResourceAsBitmap(const char* resource, SkBitmap* dst) {
SkString resourcePath = GetResourcePath(resource);
SkAutoTUnref<SkData> resourceData(
SkData::NewFromFileName(resourcePath.c_str()));
- return resourceData && SkInstallDiscardablePixelRef(
- SkDecodingImageGenerator::Create(
- resourceData, SkDecodingImageGenerator::Options()), dst);
+ return resourceData && SkInstallDiscardablePixelRef(resourceData, dst);
}