Index: dm/DMSrcSink.cpp |
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp |
index 06e1fe746e148b035eb5bbcaba59e39646d49823..77131eb477490b406d4d91bd765f0a69ebf82973 100644 |
--- a/dm/DMSrcSink.cpp |
+++ b/dm/DMSrcSink.cpp |
@@ -9,8 +9,10 @@ |
#include "SamplePipeControllers.h" |
#include "SkCommonFlags.h" |
#include "SkCodec.h" |
+#include "SkData.h" |
#include "SkDocument.h" |
#include "SkError.h" |
+#include "SkImageGenerator.h" |
#include "SkMultiPictureDraw.h" |
#include "SkNullCanvas.h" |
#include "SkOSFile.h" |
@@ -21,6 +23,11 @@ |
#include "SkStream.h" |
#include "SkXMLWriter.h" |
+static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) { |
+ SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size)); |
+ return encoded && SkInstallDiscardablePixelRef(encoded, dst); |
+} |
+ |
namespace DM { |
GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} |
@@ -207,7 +214,7 @@ Error SKPSrc::draw(SkCanvas* canvas) const { |
if (!stream) { |
return SkStringPrintf("Couldn't read %s.", fPath.c_str()); |
} |
- SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream)); |
+ SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream, &lazy_decode_bitmap)); |
if (!pic) { |
return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()); |
} |
@@ -507,7 +514,7 @@ Error ViaSerialization::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream |
SkDynamicMemoryWStream wStream; |
pic->serialize(&wStream); |
SkAutoTDelete<SkStream> rStream(wStream.detachAsStream()); |
- SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream)); |
+ SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream, &lazy_decode_bitmap)); |
// Turn that deserialized picture into a Src, draw it into our Sink to fill bitmap or stream. |
struct ProxySrc : public Src { |