diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-29 13:11:04 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-29 13:11:04 +0000 |
commit | fd32d12c2b5df2ea7391003dca7307094535a297 (patch) | |
tree | da94ae6e14da3c03f679bb81a848fa653d6beca2 /cc/output/managed_memory_policy.cc | |
parent | fecf9f77fccd08c22e9655843a534c79ed0ba567 (diff) | |
download | chromium_src-fd32d12c2b5df2ea7391003dca7307094535a297.zip chromium_src-fd32d12c2b5df2ea7391003dca7307094535a297.tar.gz chromium_src-fd32d12c2b5df2ea7391003dca7307094535a297.tar.bz2 |
cc: Pipe visibility and memory allocation to DelegatingRenderer
The GPU process makes memory allocation decisions based on the visibility of
surface. In the DelegatingRenderer case we don't use the surface directly, but
we still have it - just like composite-to-mailbox. So we can use
setVisibilityCHROMIUM to signal the GPU process, and listen to the memory
allocation callback.
This CL refactors a bunch of the logic that was hardcoded in GLRenderer into
OutputSurface which is shared. That also opens the door to implementing a memory
manager for the software renderer.
BUG=123444
Review URL: https://chromiumcodereview.appspot.com/18121005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209287 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/output/managed_memory_policy.cc')
-rw-r--r-- | cc/output/managed_memory_policy.cc | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/cc/output/managed_memory_policy.cc b/cc/output/managed_memory_policy.cc new file mode 100644 index 0000000..f21fbd6 --- /dev/null +++ b/cc/output/managed_memory_policy.cc @@ -0,0 +1,74 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "cc/output/managed_memory_policy.h" + +#include "base/logging.h" +#include "cc/resources/priority_calculator.h" + +namespace cc { + +ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytes_limit_when_visible) + : bytes_limit_when_visible(bytes_limit_when_visible), + priority_cutoff_when_visible(CUTOFF_ALLOW_EVERYTHING), + bytes_limit_when_not_visible(0), + priority_cutoff_when_not_visible(CUTOFF_ALLOW_NOTHING) {} + +ManagedMemoryPolicy::ManagedMemoryPolicy( + size_t bytes_limit_when_visible, + PriorityCutoff priority_cutoff_when_visible, + size_t bytes_limit_when_not_visible, + PriorityCutoff priority_cutoff_when_not_visible) + : bytes_limit_when_visible(bytes_limit_when_visible), + priority_cutoff_when_visible(priority_cutoff_when_visible), + bytes_limit_when_not_visible(bytes_limit_when_not_visible), + priority_cutoff_when_not_visible(priority_cutoff_when_not_visible) {} + +bool ManagedMemoryPolicy::operator==(const ManagedMemoryPolicy& other) const { + return bytes_limit_when_visible == other.bytes_limit_when_visible && + priority_cutoff_when_visible == other.priority_cutoff_when_visible && + bytes_limit_when_not_visible == other.bytes_limit_when_not_visible && + priority_cutoff_when_not_visible == + other.priority_cutoff_when_not_visible; +} + +bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy& other) const { + return !(*this == other); +} + +// static +int ManagedMemoryPolicy::PriorityCutoffToValue(PriorityCutoff priority_cutoff) { + switch (priority_cutoff) { + case CUTOFF_ALLOW_NOTHING: + return PriorityCalculator::AllowNothingCutoff(); + case CUTOFF_ALLOW_REQUIRED_ONLY: + return PriorityCalculator::AllowVisibleOnlyCutoff(); + case CUTOFF_ALLOW_NICE_TO_HAVE: + return PriorityCalculator::AllowVisibleAndNearbyCutoff(); + case CUTOFF_ALLOW_EVERYTHING: + return PriorityCalculator::AllowEverythingCutoff(); + } + NOTREACHED(); + return PriorityCalculator::AllowNothingCutoff(); +} + +// static +TileMemoryLimitPolicy +ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( + PriorityCutoff priority_cutoff) { + switch (priority_cutoff) { + case CUTOFF_ALLOW_NOTHING: + return ALLOW_NOTHING; + case CUTOFF_ALLOW_REQUIRED_ONLY: + return ALLOW_ABSOLUTE_MINIMUM; + case CUTOFF_ALLOW_NICE_TO_HAVE: + return ALLOW_PREPAINT_ONLY; + case CUTOFF_ALLOW_EVERYTHING: + return ALLOW_ANYTHING; + } + NOTREACHED(); + return ALLOW_NOTHING; +} + +} // namespace cc |