| Index: gpu/skia_bindings/grcontext_for_gles2_interface.cc
|
| diff --git a/gpu/skia_bindings/grcontext_for_gles2_interface.cc b/gpu/skia_bindings/grcontext_for_gles2_interface.cc
|
| index ee7516b4db403403b85c3924433c774ad5cd5c8f..a4965a8361795a535cae4009feedf7c4ee1d18ae 100644
|
| --- a/gpu/skia_bindings/grcontext_for_gles2_interface.cc
|
| +++ b/gpu/skia_bindings/grcontext_for_gles2_interface.cc
|
| @@ -15,38 +15,48 @@
|
| #include "gpu/command_buffer/client/gles2_interface.h"
|
| #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
|
| #include "third_party/skia/include/gpu/GrContext.h"
|
| +#include "third_party/skia/include/gpu/GrContextOptions.h"
|
| #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
|
|
|
| namespace skia_bindings {
|
|
|
| GrContextForGLES2Interface::GrContextForGLES2Interface(
|
| gpu::gles2::GLES2Interface* gl) {
|
| + // Calculate limits to pass during initialization:
|
| + // The limit of the number of GPU resources we hold in the GrContext's
|
| + // GPU cache.
|
| + static const int kMaxGaneshResourceCacheCount = 16384;
|
| + // The limit of the bytes allocated toward GPU resources in the GrContext's
|
| + // GPU cache.
|
| + static const size_t kMaxLowEndGaneshResourceCacheBytes = 48 * 1024 * 1024;
|
| + static const size_t kMaxGaneshResourceCacheBytes = 96 * 1024 * 1024;
|
| + static const size_t kMaxHighEndGaneshResourceCacheBytes = 256 * 1024 * 1024;
|
| + // Limits for glyph cache textures.
|
| + static const size_t kMaxDefaultGlyphCacheTextureBytes = 2048 * 1024 * 4;
|
| + static const size_t kMaxLowEndGlyphCacheTextureBytes = 1024 * 512 * 4;
|
| + // High-end / low-end memory cutoffs.
|
| + static const int64_t kHighEndMemoryThreshold = (int64_t)4096 * 1024 * 1024;
|
| + static const int64_t kLowEndMemoryThreshold = (int64_t)512 * 1024 * 1024;
|
| +
|
| + size_t max_ganesh_resource_cache_bytes = kMaxGaneshResourceCacheBytes;
|
| + int max_glyph_cache_texture_bytes = kMaxDefaultGlyphCacheTextureBytes;
|
| + if (base::SysInfo::AmountOfPhysicalMemory() <= kLowEndMemoryThreshold) {
|
| + max_ganesh_resource_cache_bytes = kMaxLowEndGaneshResourceCacheBytes;
|
| + max_glyph_cache_texture_bytes = kMaxLowEndGlyphCacheTextureBytes;
|
| + } else if (base::SysInfo::AmountOfPhysicalMemory() >=
|
| + kHighEndMemoryThreshold) {
|
| + max_ganesh_resource_cache_bytes = kMaxHighEndGaneshResourceCacheBytes;
|
| + }
|
| +
|
| + GrContextOptions options;
|
| + options.fGlyphCacheTextureMaximumBytes = max_glyph_cache_texture_bytes;
|
| sk_sp<GrGLInterface> interface(
|
| skia_bindings::CreateGLES2InterfaceBindings(gl));
|
| - gr_context_ = sk_sp<GrContext>(
|
| - GrContext::Create(kOpenGL_GrBackend,
|
| - // GrContext takes ownership of |interface|.
|
| - reinterpret_cast<GrBackendContext>(interface.get())));
|
| + gr_context_ = sk_sp<GrContext>(GrContext::Create(
|
| + kOpenGL_GrBackend,
|
| + // GrContext takes ownership of |interface|.
|
| + reinterpret_cast<GrBackendContext>(interface.get()), options));
|
| if (gr_context_) {
|
| - // The limit of the number of GPU resources we hold in the GrContext's
|
| - // GPU cache.
|
| - static const int kMaxGaneshResourceCacheCount = 16384;
|
| - // The limit of the bytes allocated toward GPU resources in the GrContext's
|
| - // GPU cache.
|
| - static const size_t kMaxLowEndGaneshResourceCacheBytes = 48 * 1024 * 1024;
|
| - static const size_t kMaxGaneshResourceCacheBytes = 96 * 1024 * 1024;
|
| - static const size_t kMaxHighEndGaneshResourceCacheBytes = 256 * 1024 * 1024;
|
| - static const int64_t kHighEndMemoryThreshold = (int64_t)4096 * 1024 * 1024;
|
| - static const int64_t kLowEndMemoryThreshold = (int64_t)512 * 1024 * 1024;
|
| -
|
| - size_t max_ganesh_resource_cache_bytes = kMaxGaneshResourceCacheBytes;
|
| - if (base::SysInfo::AmountOfPhysicalMemory() <= kLowEndMemoryThreshold) {
|
| - max_ganesh_resource_cache_bytes = kMaxLowEndGaneshResourceCacheBytes;
|
| - } else if (base::SysInfo::AmountOfPhysicalMemory() >=
|
| - kHighEndMemoryThreshold) {
|
| - max_ganesh_resource_cache_bytes = kMaxHighEndGaneshResourceCacheBytes;
|
| - }
|
| -
|
| gr_context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount,
|
| max_ganesh_resource_cache_bytes);
|
| }
|
|
|