summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorboliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-01 20:24:55 +0000
committerboliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-01 20:24:55 +0000
commit9012dae313242a23e986991bd7b9df77242058c2 (patch)
tree87b6bf9c7b0dd6836bf98b052043449c873f133a
parent5f39c0e104ed07c6bae0c1667f30c6dae0e0766e (diff)
downloadchromium_src-9012dae313242a23e986991bd7b9df77242058c2.zip
chromium_src-9012dae313242a23e986991bd7b9df77242058c2.tar.gz
chromium_src-9012dae313242a23e986991bd7b9df77242058c2.tar.bz2
[Android WebView] Change tile size to 384
512x512 tiles uses exactly 1MB in memory. However the allocator on certain devices allocates 1.25MB instead (due to performance heuristics), so 20% of allocated tile memory is wasted in this case. Determined experimentally that 384 tiles do not have any overhead, so update tile size to 384. Also reduce the number of resources per webview from 200 to 150 to overcome potential file handle limit problems, and add a command line switch to control this value. Internal bug b/11446261 BUG= NOTRY=true Review URL: https://codereview.chromium.org/56083003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232457 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--android_webview/browser/in_process_view_renderer.cc28
-rw-r--r--android_webview/common/aw_switches.cc2
-rw-r--r--android_webview/common/aw_switches.h3
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_