diff options
author | msarett <msarett@google.com> | 2016-02-17 10:02:29 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-17 10:02:29 -0800 |
commit | 8715d47e247bf890ee78af0774ae7e8698146b67 (patch) | |
tree | aa8b25a8353ccd96e6eccb08f22457a1d89846e0 | |
parent | feec878e850850cb0a092a765e3af0f5a3fa2a42 (diff) |
Make SkPicture/SkImageGenerator default to SkCodec
Remove reference to SkImageDecoder from SkPicture. Make the default
InstallPixelRefProc passed to CreateFromStream use
SkImageGenerator::NewFromEncoded instead.
Make SkImageGenerator::NewFromEncoded create an SkCodecImageGenerator.
Remove the old version that used SkImageDecoder.
Remove all versions of lazy_decode_bitmap/LazyDecodeBitmap. The default
now behaves lazily.
Update all clients to use the default.
Move SkImageDecoderGenerator into KtxTest.cpp, and use it directly.
This is a rebased version of:
https://codereview.chromium.org/1671193002/
TBR=reed@google.com
BUG=skia:4691
BUG=skia:4290
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1699183004
Review URL: https://codereview.chromium.org/1699183004
-rw-r--r-- | bench/ETCBitmapBench.cpp | 7 | ||||
-rw-r--r-- | dm/DMSrcSink.cpp | 9 | ||||
-rw-r--r-- | gyp/codec.gyp | 1 | ||||
-rw-r--r-- | gyp/images.gyp | 2 | ||||
-rw-r--r-- | gyp/tools.gyp | 18 | ||||
-rw-r--r-- | include/core/SkPicture.h | 15 | ||||
-rw-r--r-- | public.bzl | 2 | ||||
-rw-r--r-- | src/core/SkPicture.cpp | 11 | ||||
-rw-r--r-- | src/images/SkImageDecoder_ktx.cpp | 99 | ||||
-rw-r--r-- | src/ports/SkImageGenerator_skia.cpp | 96 | ||||
-rw-r--r-- | tests/KtxTest.cpp | 5 | ||||
-rw-r--r-- | tests/PictureTest.cpp | 34 | ||||
-rw-r--r-- | tools/LazyDecodeBitmap.cpp | 44 | ||||
-rw-r--r-- | tools/LazyDecodeBitmap.h | 24 | ||||
-rw-r--r-- | tools/dump_record.cpp | 4 | ||||
-rw-r--r-- | tools/gpuveto.cpp | 5 | ||||
-rw-r--r-- | tools/lua/lua_pictures.cpp | 3 | ||||
-rw-r--r-- | tools/pinspect.cpp | 3 |
18 files changed, 173 insertions, 209 deletions
diff --git a/bench/ETCBitmapBench.cpp b/bench/ETCBitmapBench.cpp index 1b06112996..305f492108 100644 --- a/bench/ETCBitmapBench.cpp +++ b/bench/ETCBitmapBench.cpp @@ -73,6 +73,9 @@ static etc1_byte* create_expanded_etc1_bitmap(const uint8_t* orig, int factor) { return newData; } +// Defined in SkImageDecoder_ktx.cpp +extern SkImageGenerator* decoder_image_generator(SkData*); + // This is the base class for all of the benches in this file. In general // the ETC1 benches should all be working on the same data. Due to the // simplicity of the PKM file, that data is the 128x128 mandrill etc1 @@ -151,10 +154,10 @@ protected: } if (fDecompress) { - SkAutoTDelete<SkImageGenerator> gen(SkImageGenerator::NewFromEncoded(fPKMData)); + SkAutoTDelete<SkImageGenerator> gen(decoder_image_generator(fPKMData)); gen->generateBitmap(&fBitmap); } else { - fImage.reset(SkImage::NewFromEncoded(fPKMData)); + fImage.reset(SkImage::NewFromGenerator(decoder_image_generator(fPKMData))); } } diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index e5d18cdaaf..366d8f860e 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -40,11 +40,6 @@ DEFINE_bool(multiPage, false, "For document-type backends, render the source" " into multiple pages"); DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?"); -static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) { - SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size)); - return encoded && SkDEPRECATED_InstallDiscardablePixelRef(encoded, dst); -} - namespace DM { GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} @@ -805,7 +800,7 @@ Error SKPSrc::draw(SkCanvas* canvas) const { if (!stream) { return SkStringPrintf("Couldn't read %s.", fPath.c_str()); } - SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream, &lazy_decode_bitmap)); + SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream)); if (!pic) { return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()); } @@ -1178,7 +1173,7 @@ Error ViaSerialization::draw( SkDynamicMemoryWStream wStream; pic->serialize(&wStream); SkAutoTDelete<SkStream> rStream(wStream.detachAsStream()); - SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream, &lazy_decode_bitmap)); + SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream)); return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) { canvas->drawPicture(deserialized); diff --git a/gyp/codec.gyp b/gyp/codec.gyp index d4904dac84..08750e2627 100644 --- a/gyp/codec.gyp +++ b/gyp/codec.gyp @@ -57,6 +57,7 @@ '../src/codec/SkWebpCodec.cpp', '../src/codec/SkCodecImageGenerator.cpp', + '../src/ports/SkImageGenerator_skia.cpp', ], 'direct_dependent_settings': { 'include_dirs': [ diff --git a/gyp/images.gyp b/gyp/images.gyp index 8dbca85153..8c5b0a7d1b 100644 --- a/gyp/images.gyp +++ b/gyp/images.gyp @@ -75,8 +75,6 @@ '../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/gyp/tools.gyp b/gyp/tools.gyp index 4b89427545..1e6eb52f20 100644 --- a/gyp/tools.gyp +++ b/gyp/tools.gyp @@ -83,7 +83,6 @@ ], 'dependencies': [ 'flags.gyp:flags', - 'lazy_decode_bitmap', 'skia_lib.gyp:skia_lib', ], }, @@ -267,20 +266,6 @@ ], }, { - 'target_name': 'lazy_decode_bitmap', - 'type': 'static_library', - 'sources': [ '../tools/LazyDecodeBitmap.cpp' ], - 'include_dirs': [ - '../include/private', - '../src/core', - '../src/lazy', - ], - 'dependencies': [ - 'flags.gyp:flags', - 'skia_lib.gyp:skia_lib' - ], - }, - { 'target_name': 'get_images_from_skps', 'type': 'executable', 'sources': [ @@ -303,7 +288,6 @@ '../src/images', ], 'dependencies': [ - 'lazy_decode_bitmap', 'flags.gyp:flags', 'skia_lib.gyp:skia_lib', ], @@ -345,7 +329,6 @@ '../src/core/', ], 'dependencies': [ - 'lazy_decode_bitmap', 'effects.gyp:effects', 'flags.gyp:flags', 'images.gyp:images', @@ -379,7 +362,6 @@ '../tools/pinspect.cpp', ], 'dependencies': [ - 'lazy_decode_bitmap', 'flags.gyp:flags', 'skia_lib.gyp:skia_lib', ], diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h index 720747e9a3..7c8c187fd8 100644 --- a/include/core/SkPicture.h +++ b/include/core/SkPicture.h @@ -54,8 +54,19 @@ public: * @return A new SkPicture representing the serialized data, or NULL if the stream is * invalid. */ - static SkPicture* CreateFromStream(SkStream*, - InstallPixelRefProc proc = &SkImageDecoder::DecodeMemory); + static SkPicture* CreateFromStream(SkStream*, InstallPixelRefProc proc); + + /** + * Recreate a picture that was serialized into a stream. + * + * Any serialized images in the stream will be passed to + * SkImageGenerator::NewFromEncoded. + * + * @param SkStream Serialized picture data. Ownership is unchanged by this call. + * @return A new SkPicture representing the serialized data, or NULL if the stream is + * invalid. + */ + static SkPicture* CreateFromStream(SkStream*); /** * Recreate a picture that was serialized into a buffer. If the creation requires bitmap diff --git a/public.bzl b/public.bzl index f687a42fee..6239254674 100644 --- a/public.bzl +++ b/public.bzl @@ -373,8 +373,6 @@ DM_SRCS_ALL = struct( "tests/*.h", "tools/CrashHandler.cpp", "tools/CrashHandler.h", - "tools/LazyDecodeBitmap.cpp", - "tools/LazyDecodeBitmap.h", "tools/ProcStats.cpp", "tools/ProcStats.h", "tools/Resources.cpp", diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index 8247336d49..04f2f93ba7 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -6,6 +6,7 @@ */ #include "SkAtomics.h" +#include "SkImageGenerator.h" #include "SkMessageBus.h" #include "SkPicture.h" #include "SkPictureData.h" @@ -138,6 +139,16 @@ SkPicture* SkPicture::Forwardport(const SkPictInfo& info, const SkPictureData* d return r.endRecording(); } +static bool default_install(const void* src, size_t length, SkBitmap* dst) { + SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, length)); + return encoded && SkDEPRECATED_InstallDiscardablePixelRef( + SkImageGenerator::NewFromEncoded(encoded), dst); +} + +SkPicture* SkPicture::CreateFromStream(SkStream* stream) { + return CreateFromStream(stream, &default_install, nullptr); +} + SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc proc) { return CreateFromStream(stream, proc, nullptr); } diff --git a/src/images/SkImageDecoder_ktx.cpp b/src/images/SkImageDecoder_ktx.cpp index a95ab6f602..019fa97678 100644 --- a/src/images/SkImageDecoder_ktx.cpp +++ b/src/images/SkImageDecoder_ktx.cpp @@ -7,6 +7,7 @@ #include "SkColorPriv.h" #include "SkImageDecoder.h" +#include "SkImageGenerator.h" #include "SkPixelRef.h" #include "SkScaledBitmapSampler.h" #include "SkStream.h" @@ -328,3 +329,101 @@ SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) { static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory); static SkImageDecoder_FormatReg gFormatReg(get_format_ktx); static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory); + +///////////////////////////////////////////////////////////////////////////////////////// +// Old implementation of SkImageGenerator::NewFromEncoded which uses SkImageDecoder. +// Here because it is only needed by DM and tests for Ktx. +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) 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, nullptr, nullptr); + } +}; + +class SkImageDecoderGenerator : public SkImageGenerator { + const SkImageInfo fInfo; + SkAutoTDelete<SkImageDecoder> fDecoder; + SkAutoTUnref<SkData> fData; + +public: + SkImageDecoderGenerator(const SkImageInfo& info, SkImageDecoder* decoder, SkData* data) + : INHERITED(info), fInfo(info), fDecoder(decoder), fData(SkRef(data)) + {} + +protected: + SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) override { + return SkRef(fData.get()); + } + bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, + SkPMColor ctableEntries[], int* ctableCount) override { + SkMemoryStream stream(fData->data(), fData->size(), false); + SkAutoTUnref<BareMemoryAllocator> allocator( + new BareMemoryAllocator(info, pixels, rowBytes)); + fDecoder->setAllocator(allocator); + fDecoder->setRequireUnpremultipliedColors(kUnpremul_SkAlphaType == info.alphaType()); + + SkBitmap bm; + const SkImageDecoder::Result result = fDecoder->decode(&stream, &bm, info.colorType(), + SkImageDecoder::kDecodePixels_Mode); + if (SkImageDecoder::kFailure == result) { + return false; + } + + SkASSERT(info.colorType() == bm.info().colorType()); + + if (kIndex_8_SkColorType == info.colorType()) { + SkASSERT(ctableEntries); + + SkColorTable* ctable = bm.getColorTable(); + if (nullptr == 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) override { + SkMemoryStream stream(fData->data(), fData->size(), false); + return fDecoder->decodeYUV8Planes(&stream, sizes, planes, rowBytes, colorSpace); + } + +private: + typedef SkImageGenerator INHERITED; +}; + +SkImageGenerator* decoder_image_generator(SkData* data) { + SkMemoryStream stream(data->data(), data->size(), false); + SkImageDecoder* decoder = SkImageDecoder::Factory(&stream); + if (nullptr == decoder) { + return nullptr; + } + + SkBitmap bm; + stream.rewind(); + if (!decoder->decode(&stream, &bm, kUnknown_SkColorType, SkImageDecoder::kDecodeBounds_Mode)) { + delete decoder; + return nullptr; + } + + return new SkImageDecoderGenerator(bm.info(), decoder, data); +} + diff --git a/src/ports/SkImageGenerator_skia.cpp b/src/ports/SkImageGenerator_skia.cpp index 8dbad555dd..b6ddee935a 100644 --- a/src/ports/SkImageGenerator_skia.cpp +++ b/src/ports/SkImageGenerator_skia.cpp @@ -6,100 +6,8 @@ */ #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) 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, nullptr, nullptr); - } -}; - -class SkImageDecoderGenerator : public SkImageGenerator { - const SkImageInfo fInfo; - SkAutoTDelete<SkImageDecoder> fDecoder; - SkAutoTUnref<SkData> fData; - -public: - SkImageDecoderGenerator(const SkImageInfo& info, SkImageDecoder* decoder, SkData* data) - : INHERITED(info), fInfo(info), fDecoder(decoder), fData(SkRef(data)) - {} - -protected: - SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) override { - return SkRef(fData.get()); - } - bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, - SkPMColor ctableEntries[], int* ctableCount) override { - SkMemoryStream stream(fData->data(), fData->size(), false); - SkAutoTUnref<BareMemoryAllocator> allocator( - new BareMemoryAllocator(info, pixels, rowBytes)); - fDecoder->setAllocator(allocator); - fDecoder->setRequireUnpremultipliedColors(kUnpremul_SkAlphaType == info.alphaType()); - - SkBitmap bm; - const SkImageDecoder::Result result = fDecoder->decode(&stream, &bm, info.colorType(), - SkImageDecoder::kDecodePixels_Mode); - if (SkImageDecoder::kFailure == result) { - return false; - } - - SkASSERT(info.colorType() == bm.info().colorType()); - - if (kIndex_8_SkColorType == info.colorType()) { - SkASSERT(ctableEntries); - - SkColorTable* ctable = bm.getColorTable(); - if (nullptr == 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) override { - SkMemoryStream stream(fData->data(), fData->size(), false); - return fDecoder->decodeYUV8Planes(&stream, sizes, planes, rowBytes, colorSpace); - } - -private: - typedef SkImageGenerator INHERITED; -}; +#include "SkCodecImageGenerator.h" SkImageGenerator* SkImageGenerator::NewFromEncodedImpl(SkData* data) { - SkMemoryStream stream(data->data(), data->size(), false); - SkImageDecoder* decoder = SkImageDecoder::Factory(&stream); - if (nullptr == decoder) { - return nullptr; - } - - SkBitmap bm; - stream.rewind(); - if (!decoder->decode(&stream, &bm, kUnknown_SkColorType, SkImageDecoder::kDecodeBounds_Mode)) { - delete decoder; - return nullptr; - } - - return new SkImageDecoderGenerator(bm.info(), decoder, data); + return SkCodecImageGenerator::NewFromEncodedCodec(data); } diff --git a/tests/KtxTest.cpp b/tests/KtxTest.cpp index 84d162c0f8..99bae83329 100644 --- a/tests/KtxTest.cpp +++ b/tests/KtxTest.cpp @@ -143,6 +143,9 @@ DEF_TEST(KtxReadUnpremul, reporter) { } } +// For KtxReexportPKM, below. Defined in SkImageDecoder_ktx.cpp +extern SkImageGenerator* decoder_image_generator(SkData*); + /** * Finally, make sure that if we get ETC1 data from a PKM file that we can then * accurately write it out into a KTX file (i.e. transferring the ETC1 data from @@ -160,7 +163,7 @@ DEF_TEST(KtxReexportPKM, reporter) { } bool installDiscardablePixelRefSuccess = - SkDEPRECATED_InstallDiscardablePixelRef(fileData, &etcBitmap); + SkDEPRECATED_InstallDiscardablePixelRef(decoder_image_generator(fileData), &etcBitmap); if (!installDiscardablePixelRefSuccess) { ERRORF(reporter, "failed to create discardable pixelRef from KTX file"); return; diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp index 3d05a824a2..448e079958 100644 --- a/tests/PictureTest.cpp +++ b/tests/PictureTest.cpp @@ -17,6 +17,7 @@ #include "SkImageEncoder.h" #include "SkImageGenerator.h" #include "SkLayerInfo.h" +#include "SkMD5.h" #include "SkPaint.h" #include "SkPicture.h" #include "SkPictureRecorder.h" @@ -871,7 +872,18 @@ static void assert_one_parse_error_cb(SkError error, void* context) { SkGetLastErrorString()); } -static void test_bitmap_with_encoded_data(skiatest::Reporter* reporter) { +static void md5(const SkBitmap& bm, SkMD5::Digest* digest) { + SkAutoLockPixels autoLockPixels(bm); + SkASSERT(bm.getPixels()); + SkMD5 md5; + size_t rowLen = bm.info().bytesPerPixel() * bm.width(); + for (int y = 0; y < bm.height(); ++y) { + md5.update(static_cast<uint8_t*>(bm.getAddr(0, y)), rowLen); + } + md5.finish(*digest); +} + +DEF_TEST(Picture_EncodedData, reporter) { // Create a bitmap that will be encoded. SkBitmap original; make_bm(&original, 100, 100, SK_ColorBLUE, true); @@ -891,6 +903,7 @@ static void test_bitmap_with_encoded_data(skiatest::Reporter* reporter) { SkAutoDataUnref picture1(serialized_picture_from_bitmap(original)); SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); REPORTER_ASSERT(reporter, picture1->equals(picture2)); + // Now test that a parse error was generated when trying to create a new SkPicture without // providing a function to decode the bitmap. ErrorContext context; @@ -903,6 +916,24 @@ static void test_bitmap_with_encoded_data(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, pictureFromStream.get() != nullptr); SkClearLastError(); SkSetErrorCallback(nullptr, nullptr); + + // Test that using the version of CreateFromStream that just takes a stream also decodes the + // bitmap. Drawing this picture should look exactly like the original bitmap. + SkMD5::Digest referenceDigest; + md5(original, &referenceDigest); + + SkBitmap dst; + dst.allocPixels(original.info()); + dst.eraseColor(SK_ColorRED); + SkCanvas canvas(dst); + + pictureStream.rewind(); + pictureFromStream.reset(SkPicture::CreateFromStream(&pictureStream)); + canvas.drawPicture(pictureFromStream.get()); + + SkMD5::Digest digest2; + md5(dst, &digest2); + REPORTER_ASSERT(reporter, referenceDigest == digest2); } static void test_clip_bound_opt(skiatest::Reporter* reporter) { @@ -1174,7 +1205,6 @@ DEF_TEST(Picture, reporter) { test_has_text(reporter); test_images_are_found_by_willPlayBackBitmaps(reporter); test_analysis(reporter); - test_bitmap_with_encoded_data(reporter); test_clip_bound_opt(reporter); test_clip_expansion(reporter); test_hierarchical(reporter); diff --git a/tools/LazyDecodeBitmap.cpp b/tools/LazyDecodeBitmap.cpp deleted file mode 100644 index d41889b861..0000000000 --- a/tools/LazyDecodeBitmap.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2013 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "LazyDecodeBitmap.h" - -#include "SkData.h" -#include "SkDiscardableMemoryPool.h" -#include "SkImageGeneratorPriv.h" -#include "SkForceLinking.h" - -#include "SkCommandLineFlags.h" - -__SK_FORCE_IMAGE_DECODER_LINKING; - -DEFINE_bool(useVolatileCache, false, "Use a volatile cache for deferred image decoding pixels. " - "Only meaningful if --deferImageDecoding is set to true and the platform has an " - "implementation."); - -// Fits SkPicture::InstallPixelRefProc call signature. -// Used in SkPictureData::CreateFromStream -bool sk_tools::LazyDecodeBitmap(const void* src, size_t length, SkBitmap* dst) { - SkAutoDataUnref data(SkData::NewWithCopy(src, length)); - if (nullptr == data.get()) { - return false; - } - - SkAutoTDelete<SkImageGenerator> gen(SkImageGenerator::NewFromEncoded(data)); - if (nullptr == gen.get()) { - return false; - } - const SkImageInfo info = gen->getInfo(); - SkDiscardableMemory::Factory* pool = nullptr; - if ((!FLAGS_useVolatileCache) || (info.width() * info.height() < 32 * 1024)) { - // how to do switching with SkDiscardableMemory. - pool = SkGetGlobalDiscardableMemoryPool(); - // Only meaningful if platform has a default discardable - // memory implementation that differs from the global DM pool. - } - return SkDEPRECATED_InstallDiscardablePixelRef(gen.detach(), nullptr, dst, pool); -} diff --git a/tools/LazyDecodeBitmap.h b/tools/LazyDecodeBitmap.h deleted file mode 100644 index ecceb94f7e..0000000000 --- a/tools/LazyDecodeBitmap.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2013 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef LazyDecodeBitmap_DEFINED -#define LazyDecodeBitmap_DEFINED - -#include "SkTypes.h" - -class SkBitmap; - -namespace sk_tools { - -/** - * Decode the image with DecodeMemoryToTarget but defer the process until it is needed. - */ -bool LazyDecodeBitmap(const void* buffer, size_t size, SkBitmap* bitmap); - -} - -#endif // LazyDecodeBitmap_DEFINED diff --git a/tools/dump_record.cpp b/tools/dump_record.cpp index 029638efb1..96b893735b 100644 --- a/tools/dump_record.cpp +++ b/tools/dump_record.cpp @@ -6,7 +6,6 @@ */ #include "DumpRecord.h" -#include "LazyDecodeBitmap.h" #include "SkCommandLineFlags.h" #include "SkPicture.h" #include "SkPictureRecorder.h" @@ -50,8 +49,7 @@ int tool_main(int argc, char** argv) { SkDebugf("Could not read %s.\n", FLAGS_skps[i]); return 1; } - SkAutoTUnref<SkPicture> src( - SkPicture::CreateFromStream(stream, sk_tools::LazyDecodeBitmap)); + SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream)); if (!src) { SkDebugf("Could not read %s as an SkPicture.\n", FLAGS_skps[i]); return 1; diff --git a/tools/gpuveto.cpp b/tools/gpuveto.cpp index 204f44965b..f2e103e1e3 100644 --- a/tools/gpuveto.cpp +++ b/tools/gpuveto.cpp @@ -5,7 +5,6 @@ * found in the LICENSE file. */ -#include "LazyDecodeBitmap.h" #include "SkCommandLineFlags.h" #include "SkPicture.h" #include "SkPictureRecorder.h" @@ -42,9 +41,7 @@ int tool_main(int argc, char** argv) { return kError; } - SkPicture::InstallPixelRefProc proc = &sk_tools::LazyDecodeBitmap; - - SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc)); + SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream)); if (nullptr == picture.get()) { if (!FLAGS_quiet) { SkDebugf("Could not read the SkPicture\n"); diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp index 6fa5813d77..57b0dcce8e 100644 --- a/tools/lua/lua_pictures.cpp +++ b/tools/lua/lua_pictures.cpp @@ -5,7 +5,6 @@ * found in the LICENSE file. */ -#include "LazyDecodeBitmap.h" #include "SkLua.h" #include "SkLuaCanvas.h" #include "SkPicture.h" @@ -44,7 +43,7 @@ static SkPicture* load_picture(const char path[]) { SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); SkPicture* pic = nullptr; if (stream.get()) { - pic = SkPicture::CreateFromStream(stream.get(), &sk_tools::LazyDecodeBitmap); + pic = SkPicture::CreateFromStream(stream.get()); } return pic; } diff --git a/tools/pinspect.cpp b/tools/pinspect.cpp index 5c04608c4e..b8deba707a 100644 --- a/tools/pinspect.cpp +++ b/tools/pinspect.cpp @@ -5,7 +5,6 @@ * found in the LICENSE file. */ -#include "LazyDecodeBitmap.h" #include "SkBitmap.h" #include "SkCanvas.h" #include "SkGraphics.h" @@ -35,7 +34,7 @@ static SkPicture* inspect(const char path[]) { } stream.rewind(); - SkPicture* pic = SkPicture::CreateFromStream(&stream, &sk_tools::LazyDecodeBitmap); + SkPicture* pic = SkPicture::CreateFromStream(&stream); if (nullptr == pic) { SkDebugf("Could not create SkPicture: %s\n", path); return nullptr; |