Skip to content

Commit

Permalink
Add switch to configure gpu memory limit
Browse files Browse the repository at this point in the history
Bug: 923141
Test: None
Change-Id: I0c53c2272eda161a1d2d6ac16b66f260bd72dfd1
Reviewed-on: https://chromium-review.googlesource.com/c/1431133
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625542}
  • Loading branch information
mitoshima authored and Commit Bot committed Jan 24, 2019
1 parent c8f0858 commit b03357d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ui/compositor/compositor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ Compositor::Compositor(
#endif

settings.memory_policy.bytes_limit_when_visible = 512 * 1024 * 1024;

// Used to configure ui compositor memory limit for chromeos devices.
// See crbug.com/923141.
if (command_line->HasSwitch(
switches::kUiCompositorMemoryLimitWhenVisibleMB)) {
std::string value_str = command_line->GetSwitchValueASCII(
switches::kUiCompositorMemoryLimitWhenVisibleMB);
unsigned value_in_mb;
if (base::StringToUint(value_str, &value_in_mb)) {
settings.memory_policy.bytes_limit_when_visible =
1024 * 1024 * value_in_mb;
}
}

settings.memory_policy.priority_cutoff_when_visible =
gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;

Expand Down
3 changes: 3 additions & 0 deletions ui/compositor/compositor_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const char kUISlowAnimations[] = "ui-slow-animations";

const char kDisableVsyncForTests[] = "disable-vsync-for-tests";

const char kUiCompositorMemoryLimitWhenVisibleMB[] =
"ui-compositor-memory-limit-when-visible-mb";

} // namespace switches

namespace features {
Expand Down
1 change: 1 addition & 0 deletions ui/compositor/compositor_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ COMPOSITOR_EXPORT extern const char kUIDisableZeroCopy[];
COMPOSITOR_EXPORT extern const char kUIShowPaintRects[];
COMPOSITOR_EXPORT extern const char kUISlowAnimations[];
COMPOSITOR_EXPORT extern const char kDisableVsyncForTests[];
COMPOSITOR_EXPORT extern const char kUiCompositorMemoryLimitWhenVisibleMB[];

} // namespace switches

Expand Down

0 comments on commit b03357d

Please sign in to comment.