Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2143)

Unified Diff: android_webview/browser/browser_view_renderer.cc

Issue 519593002: aw: Make force-gpu-mem-available-mb work (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/browser/browser_view_renderer.cc
diff --git a/android_webview/browser/browser_view_renderer.cc b/android_webview/browser/browser_view_renderer.cc
index 7a3c703b7848ef18bbc00c5c3b6d5d4cf9fffaa6..8a0547456a123c03ddbc62267af2c7382a27e10d 100644
--- a/android_webview/browser/browser_view_renderer.cc
+++ b/android_webview/browser/browser_view_renderer.cc
@@ -20,6 +20,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
+#include "gpu/command_buffer/service/gpu_switches.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkPicture.h"
@@ -42,6 +43,7 @@ const int64 kFallbackTickTimeoutInMilliseconds = 100;
const size_t kMemoryMultiplier = 20;
const size_t kBytesPerPixel = 4;
const size_t kMemoryAllocationStep = 5 * 1024 * 1024;
+uint64 g_memory_override_in_bytes = 0u;
// Used to calculate tile allocation. Determined experimentally.
const size_t kTileMultiplier = 12;
@@ -75,6 +77,19 @@ class TracedValue : public base::debug::ConvertableToTraceFormat {
// static
void BrowserViewRenderer::CalculateTileMemoryPolicy(bool use_zero_copy) {
+ CommandLine* cl = CommandLine::ForCurrentProcess();
+
+ // If the value was overridden on the command line, use the specified value.
+ bool client_hard_limit_bytes_overridden =
+ cl->HasSwitch(switches::kForceGpuMemAvailableMb);
+ if (client_hard_limit_bytes_overridden) {
+ base::StringToUint64(
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kForceGpuMemAvailableMb),
+ &g_memory_override_in_bytes);
+ g_memory_override_in_bytes *= 1024 * 1024;
+ }
+
if (!use_zero_copy) {
// Use chrome's default tile size, which varies from 256 to 512.
// Be conservative here and use the smallest tile size possible.
@@ -85,7 +100,6 @@ void BrowserViewRenderer::CalculateTileMemoryPolicy(bool use_zero_copy) {
return;
}
- CommandLine* cl = CommandLine::ForCurrentProcess();
const char kDefaultTileSize[] = "384";
if (!cl->HasSwitch(switches::kDefaultTileWidth))
@@ -180,6 +194,9 @@ BrowserViewRenderer::CalculateDesiredMemoryPolicy() {
policy.bytes_limit =
(policy.bytes_limit / kMemoryAllocationStep + 1) * kMemoryAllocationStep;
+ if (g_memory_override_in_bytes)
+ policy.bytes_limit = static_cast<size_t>(g_memory_override_in_bytes);
+
size_t tiles = width * height * kTileMultiplier / g_tile_area;
// Round up to a multiple of kTileAllocationStep. The minimum number of tiles
// is also kTileAllocationStep.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698