aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar kjlubick <kjlubick@google.com>2016-02-10 11:25:07 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-10 11:25:07 -0800
commit1de415f2c33febbac668500afbbb0c9b120c125f (patch)
tree6fea38167e591a5908c024866851a294dbd8e4c5 /tools
parent026388a01864c74208ad57d1ba4f711602d101c6 (diff)
Revert of Make SkPicture/SkImageGenerator default to SkCodec (patchset #7 id:120001 of https://codereview.chromium.org/1671193002/ )
Reason for revert: Breaks Ubuntu and Mac CMAKE Original issue's description: > 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. > > BUG=skia:4691 > BUG=skia:4290 > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1671193002 > > Committed: https://skia.googlesource.com/skia/+/026388a01864c74208ad57d1ba4f711602d101c6 TBR=msarett@google.com,reed@google.com,scroggo@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:4691 Review URL: https://codereview.chromium.org/1685963004
Diffstat (limited to 'tools')
-rw-r--r--tools/BUILD.public.expected2
-rw-r--r--tools/LazyDecodeBitmap.cpp44
-rw-r--r--tools/LazyDecodeBitmap.h24
-rw-r--r--tools/dump_record.cpp4
-rw-r--r--tools/gpuveto.cpp5
-rw-r--r--tools/lua/lua_pictures.cpp3
-rw-r--r--tools/pinspect.cpp3
7 files changed, 81 insertions, 4 deletions
diff --git a/tools/BUILD.public.expected b/tools/BUILD.public.expected
index b1707077c3..de6edf5e7e 100644
--- a/tools/BUILD.public.expected
+++ b/tools/BUILD.public.expected
@@ -2174,6 +2174,8 @@ DM_SRCS = ['dm/DM.cpp',
'tests/YUVCacheTest.cpp',
'tools/CrashHandler.cpp',
'tools/CrashHandler.h',
+ 'tools/LazyDecodeBitmap.cpp',
+ 'tools/LazyDecodeBitmap.h',
'tools/ProcStats.cpp',
'tools/ProcStats.h',
'tools/Resources.cpp',
diff --git a/tools/LazyDecodeBitmap.cpp b/tools/LazyDecodeBitmap.cpp
new file mode 100644
index 0000000000..d41889b861
--- /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);
+}
diff --git a/tools/LazyDecodeBitmap.h b/tools/LazyDecodeBitmap.h
new file mode 100644
index 0000000000..ecceb94f7e
--- /dev/null
+++ b/tools/LazyDecodeBitmap.h
@@ -0,0 +1,24 @@
+/*
+ * 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 96b893735b..029638efb1 100644
--- a/tools/dump_record.cpp
+++ b/tools/dump_record.cpp
@@ -6,6 +6,7 @@
*/
#include "DumpRecord.h"
+#include "LazyDecodeBitmap.h"
#include "SkCommandLineFlags.h"
#include "SkPicture.h"
#include "SkPictureRecorder.h"
@@ -49,7 +50,8 @@ int tool_main(int argc, char** argv) {
SkDebugf("Could not read %s.\n", FLAGS_skps[i]);
return 1;
}
- SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream));
+ SkAutoTUnref<SkPicture> src(
+ SkPicture::CreateFromStream(stream, sk_tools::LazyDecodeBitmap));
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 f2e103e1e3..204f44965b 100644
--- a/tools/gpuveto.cpp
+++ b/tools/gpuveto.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "LazyDecodeBitmap.h"
#include "SkCommandLineFlags.h"
#include "SkPicture.h"
#include "SkPictureRecorder.h"
@@ -41,7 +42,9 @@ int tool_main(int argc, char** argv) {
return kError;
}
- SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream));
+ SkPicture::InstallPixelRefProc proc = &sk_tools::LazyDecodeBitmap;
+
+ SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc));
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 57b0dcce8e..6fa5813d77 100644
--- a/tools/lua/lua_pictures.cpp
+++ b/tools/lua/lua_pictures.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "LazyDecodeBitmap.h"
#include "SkLua.h"
#include "SkLuaCanvas.h"
#include "SkPicture.h"
@@ -43,7 +44,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());
+ pic = SkPicture::CreateFromStream(stream.get(), &sk_tools::LazyDecodeBitmap);
}
return pic;
}
diff --git a/tools/pinspect.cpp b/tools/pinspect.cpp
index b8deba707a..5c04608c4e 100644
--- a/tools/pinspect.cpp
+++ b/tools/pinspect.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "LazyDecodeBitmap.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkGraphics.h"
@@ -34,7 +35,7 @@ static SkPicture* inspect(const char path[]) {
}
stream.rewind();
- SkPicture* pic = SkPicture::CreateFromStream(&stream);
+ SkPicture* pic = SkPicture::CreateFromStream(&stream, &sk_tools::LazyDecodeBitmap);
if (nullptr == pic) {
SkDebugf("Could not create SkPicture: %s\n", path);
return nullptr;