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

Unified Diff: tools/LazyDecodeBitmap.cpp

Issue 1685963004: Revert of Make SkPicture/SkImageGenerator default to SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 | « tools/LazyDecodeBitmap.h ('k') | tools/dump_record.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/LazyDecodeBitmap.cpp
diff --git a/tools/LazyDecodeBitmap.cpp b/tools/LazyDecodeBitmap.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d41889b861a54cac1aef8f7a05b3d87c8255e910
--- /dev/null
+++ b/tools/LazyDecodeBitmap.cpp
@@ -0,0 +1,44 @@
+/*
+ * 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);
+}
« no previous file with comments | « tools/LazyDecodeBitmap.h ('k') | tools/dump_record.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698