aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2014-08-01 09:25:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-01 09:25:11 -0700
commit66058b614d9c8cb63c24b1c779dd1a9a80752217 (patch)
tree9bddc5cd2393775435a484f976617a803aec63c1
parent6e33e232df34d74c62e51e7e30d3ce90f14b46da (diff)
Memory improvements to render_pdfs; better DM pool size defaults
Make SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE equal to skia_resource_cache_mb_limit, if that value is >0 (true for some low-memory Android devices). render_pdfs test program uses lazy decoding (and the discardable memory pool). BUG=skia:2743 R=djsollen@google.com, mtklein@google.com Author: halcanary@google.com Review URL: https://codereview.chromium.org/433063002
-rw-r--r--gyp/common_conditions.gypi1
-rw-r--r--gyp/tools.gyp5
-rw-r--r--src/lazy/SkDiscardableMemoryPool.h9
-rw-r--r--tools/render_pdfs_main.cpp5
4 files changed, 18 insertions, 2 deletions
diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi
index 4fa1ba0cbd..9884e1efeb 100644
--- a/gyp/common_conditions.gypi
+++ b/gyp/common_conditions.gypi
@@ -6,6 +6,7 @@
'SK_SUPPORT_GPU=<(skia_gpu)',
'SK_SUPPORT_OPENCL=<(skia_opencl)',
'SK_FORCE_DISTANCEFIELD_FONTS=<(skia_force_distancefield_fonts)',
+ 'SK_DEFAULT_RESOURCE_CACHE_MB_LIMIT=<(skia_resource_cache_mb_limit)',
],
'conditions' : [
['skia_pic', {
diff --git a/gyp/tools.gyp b/gyp/tools.gyp
index e2e12bf3fa..38996adbad 100644
--- a/gyp/tools.gyp
+++ b/gyp/tools.gyp
@@ -517,12 +517,17 @@
'type': 'executable',
'sources': [
'../tools/render_pdfs_main.cpp',
+ '../tools/flags/SkCommandLineFlags.cpp',
+ '../tools/LazyDecodeBitmap.cpp',
'../tools/PdfRenderer.cpp',
'../tools/PdfRenderer.h',
],
'include_dirs': [
+ '../src/core',
+ '../src/lazy',
'../src/pipe/utils/',
'../src/utils/',
+ '../tools/flags',
],
'dependencies': [
'pdf.gyp:pdf',
diff --git a/src/lazy/SkDiscardableMemoryPool.h b/src/lazy/SkDiscardableMemoryPool.h
index d141507004..57a14db0dd 100644
--- a/src/lazy/SkDiscardableMemoryPool.h
+++ b/src/lazy/SkDiscardableMemoryPool.h
@@ -62,7 +62,14 @@ public:
SkDiscardableMemoryPool* SkGetGlobalDiscardableMemoryPool();
#if !defined(SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE)
-#define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (128 * 1024 * 1024)
+ #if defined(SK_DEFAULT_RESOURCE_CACHE_MB_LIMIT) && \
+ SK_DEFAULT_RESOURCE_CACHE_MB_LIMIT > 0
+ #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE \
+ (SK_DEFAULT_RESOURCE_CACHE_MB_LIMIT * 1024 * 1024)
+ #else
+ #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE \
+ (128 * 1024 * 1024)
+ #endif
#endif
#endif // SkDiscardableMemoryPool_DEFINED
diff --git a/tools/render_pdfs_main.cpp b/tools/render_pdfs_main.cpp
index 6e1d609cde..5e87ec2e46 100644
--- a/tools/render_pdfs_main.cpp
+++ b/tools/render_pdfs_main.cpp
@@ -17,6 +17,7 @@
#include "SkTArray.h"
#include "PdfRenderer.h"
#include "picture_utils.h"
+#include "LazyDecodeBitmap.h"
__SK_FORCE_IMAGE_DECODER_LINKING;
@@ -158,7 +159,9 @@ static bool render_pdf(const SkString& inputPath, const SkString& outputDir,
return false;
}
- SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream));
+ SkAutoTUnref<SkPicture> picture(
+ SkPicture::CreateFromStream(
+ &inputStream, &sk_tools::LazyDecodeBitmap));
if (NULL == picture.get()) {
SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str());