Commit dd2c102b authored by halcanary@google.com's avatar halcanary@google.com

Set ImageCacheSingleAllocationByteLimit to 64MB

This variable is the maximum allocation size allowed for
(high-quality) image scaling filters that require pre-scaling (and
caching of the results). Skia will fallback to a filter that doesn't
require pre-scaling if the selected filter would require an allocation
that exceeds this limit.

Motivation: If a web page scales an image by a large factor, the
resulting bitmap may take up quite a bit of space - this will clobber
Skia's Scaled Image Cache and other caches that share a quota with the
Scaled Image Cache.

See SkGraphics.h for more documentation. 

Future work: Someone may want to tune this value based on device
memory size.

BUG=389439

Review URL: https://codereview.chromium.org/397193002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284793 0039d316-1c4b-4281-b951-d872f2087c98
parent 1db48394
......@@ -172,6 +172,12 @@ const int kIdleCPUUsageThresholdInPercents = 3;
const int kMinRasterThreads = 1;
const int kMaxRasterThreads = 64;
// Maximum allocation size allowed for image scaling filters that
// require pre-scaling. Skia will fallback to a filter that doesn't
// require pre-scaling if the default filter would require an
// allocation that exceeds this limit.
const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024;
// Keep the global RenderThreadImpl in a TLS slot so it is impossible to access
// incorrectly from the wrong thread.
base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> >
......@@ -905,6 +911,9 @@ void RenderThreadImpl::EnsureWebKitInitialized() {
!is_impl_side_painting_enabled_)
SkGraphics::SetImageCacheByteLimit(0u);
SkGraphics::SetImageCacheSingleAllocationByteLimit(
kImageCacheSingleAllocationByteLimit);
if (command_line.HasSwitch(switches::kMemoryMetrics)) {
memory_observer_.reset(new MemoryObserver());
message_loop()->AddTaskObserver(memory_observer_.get());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment