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

Unified Diff: dm/DMSrcSink.cpp

Issue 943383002: DM: lazy decoding on SKP playback (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-02-23 (Monday) 11:08:28 EST Created 5 years, 10 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 | no next file » | no next file with comments »
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 b44f1d78180e94e9d9f5505789024e5db42c4007..7e38b87f1ac9e4c29dd952ec06c2f4f7939dd144 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1,7 +1,9 @@
#include "DMSrcSink.h"
#include "SamplePipeControllers.h"
#include "SkCommonFlags.h"
+#include "SkData.h"
#include "SkDocument.h"
+#include "SkImageGenerator.h"
#include "SkMultiPictureDraw.h"
#include "SkNullCanvas.h"
#include "SkOSFile.h"
@@ -108,13 +110,19 @@ Name ImageSrc::name() const {
static const SkRect kSKPViewport = {0,0, 1000,1000};
SKPSrc::SKPSrc(Path path) : fPath(path) {}
+namespace {
+bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) {
mtklein 2015/02/23 17:01:10 static instead?
hal.canary 2015/02/23 18:16:35 Done.
+ SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size));
+ return encoded.get() ? SkInstallDiscardablePixelRef(encoded, dst) : false;
+}
+} // namespace
Error SKPSrc::draw(SkCanvas* canvas) const {
SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str()));
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());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698