Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Unified Diff: dm/DMSrcSink.cpp

Issue 1010983004: Lazy SKP image decoding in DM. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: double check Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/images/SkImageDecoder_libjpeg.cpp » ('j') | src/images/SkImageDecoder_libjpeg.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « no previous file | src/images/SkImageDecoder_libjpeg.cpp » ('j') | src/images/SkImageDecoder_libjpeg.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698