diff options
-rw-r--r-- | android_webview/browser/in_process_view_renderer.cc | 28 | ||||
-rw-r--r-- | android_webview/common/aw_switches.cc | 2 | ||||
-rw-r--r-- | android_webview/common/aw_switches.h | 3 |
3 files changed, 22 insertions, 11 deletions
diff --git a/android_webview/browser/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc index c1b4e5e..016aec8 100644 --- a/android_webview/browser/in_process_view_renderer.cc +++ b/android_webview/browser/in_process_view_renderer.cc @@ -147,7 +147,7 @@ const int64 kFallbackTickTimeoutInMilliseconds = 20; // Used to calculate memory and resource allocation. Determined experimentally. size_t g_memory_multiplier = 10; -const size_t kMaxNumTilesToFillDisplay = 20; +size_t g_num_gralloc_limit = 150; const size_t kBytesPerPixel = 4; const size_t kMemoryAllocationStep = 5 * 1024 * 1024; @@ -283,23 +283,29 @@ void InProcessViewRenderer::CalculateTileMemoryPolicy() { if (cl->HasSwitch(switches::kTileMemoryMultiplier)) { std::string string_value = cl->GetSwitchValueASCII(switches::kTileMemoryMultiplier); - int int_value; + int int_value = 0; if (base::StringToInt(string_value, &int_value) && int_value >= 2 && int_value <= 50) { g_memory_multiplier = int_value; } } - if (cl->HasSwitch(switches::kDefaultTileWidth) || - cl->HasSwitch(switches::kDefaultTileHeight)) { - return; + if (cl->HasSwitch(switches::kNumGrallocBuffersPerWebview)) { + std::string string_value = + cl->GetSwitchValueASCII(switches::kNumGrallocBuffersPerWebview); + int int_value = 0; + if (base::StringToInt(string_value, &int_value) && + int_value >= 50 && int_value <= 500) { + g_num_gralloc_limit = int_value; + } } - const int default_tile_size = 512; - std::stringstream size; - size << default_tile_size; - cl->AppendSwitchASCII(switches::kDefaultTileWidth, size.str()); - cl->AppendSwitchASCII(switches::kDefaultTileHeight, size.str()); + const char kDefaultTileSize[] = "384"; + if (!cl->HasSwitch(switches::kDefaultTileWidth)) + cl->AppendSwitchASCII(switches::kDefaultTileWidth, kDefaultTileSize); + + if (!cl->HasSwitch(switches::kDefaultTileHeight)) + cl->AppendSwitchASCII(switches::kDefaultTileHeight, kDefaultTileSize); } bool InProcessViewRenderer::RequestProcessGL() { @@ -471,7 +477,7 @@ void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { // Round up to a multiple of kMemoryAllocationStep. policy.bytes_limit = (policy.bytes_limit / kMemoryAllocationStep + 1) * kMemoryAllocationStep; - policy.num_resources_limit = kMaxNumTilesToFillDisplay * g_memory_multiplier; + policy.num_resources_limit = g_num_gralloc_limit; SetMemoryPolicy(policy); DCHECK(gl_surface_); diff --git a/android_webview/common/aw_switches.cc b/android_webview/common/aw_switches.cc index b2663fa..216b4e3 100644 --- a/android_webview/common/aw_switches.cc +++ b/android_webview/common/aw_switches.cc @@ -12,4 +12,6 @@ const char kDisableWebViewGLMode[] = "disable-webview-gl-mode"; const char kTileMemoryMultiplier[] = "tile-memory-multiplier"; +const char kNumGrallocBuffersPerWebview[] = "num-gralloc-buffers-per-webview"; + } // namespace switches diff --git a/android_webview/common/aw_switches.h b/android_webview/common/aw_switches.h index e855bb7..c718c05 100644 --- a/android_webview/common/aw_switches.h +++ b/android_webview/common/aw_switches.h @@ -17,6 +17,9 @@ extern const char kDisableWebViewGLMode[]; // displays that a single layer will have enough memory for. extern const char kTileMemoryMultiplier[]; +// Maximum number of gralloc allocations per webview. +extern const char kNumGrallocBuffersPerWebview[]; + } // namespace switches #endif // ANDROID_WEBVIEW_COMMON_AW_SWITCHES_H_ |