1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/output/managed_memory_policy.h"
7 #include "base/logging.h"
8 #include "cc/resources/priority_calculator.h"
12 ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytes_limit_when_visible
)
13 : bytes_limit_when_visible(bytes_limit_when_visible
),
14 priority_cutoff_when_visible(CUTOFF_ALLOW_EVERYTHING
),
15 bytes_limit_when_not_visible(0),
16 priority_cutoff_when_not_visible(CUTOFF_ALLOW_NOTHING
) {}
18 ManagedMemoryPolicy::ManagedMemoryPolicy(
19 size_t bytes_limit_when_visible
,
20 PriorityCutoff priority_cutoff_when_visible
,
21 size_t bytes_limit_when_not_visible
,
22 PriorityCutoff priority_cutoff_when_not_visible
)
23 : bytes_limit_when_visible(bytes_limit_when_visible
),
24 priority_cutoff_when_visible(priority_cutoff_when_visible
),
25 bytes_limit_when_not_visible(bytes_limit_when_not_visible
),
26 priority_cutoff_when_not_visible(priority_cutoff_when_not_visible
) {}
28 bool ManagedMemoryPolicy::operator==(const ManagedMemoryPolicy
& other
) const {
29 return bytes_limit_when_visible
== other
.bytes_limit_when_visible
&&
30 priority_cutoff_when_visible
== other
.priority_cutoff_when_visible
&&
31 bytes_limit_when_not_visible
== other
.bytes_limit_when_not_visible
&&
32 priority_cutoff_when_not_visible
==
33 other
.priority_cutoff_when_not_visible
;
36 bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy
& other
) const {
37 return !(*this == other
);
41 int ManagedMemoryPolicy::PriorityCutoffToValue(PriorityCutoff priority_cutoff
) {
42 switch (priority_cutoff
) {
43 case CUTOFF_ALLOW_NOTHING
:
44 return PriorityCalculator::AllowNothingCutoff();
45 case CUTOFF_ALLOW_REQUIRED_ONLY
:
46 return PriorityCalculator::AllowVisibleOnlyCutoff();
47 case CUTOFF_ALLOW_NICE_TO_HAVE
:
48 return PriorityCalculator::AllowVisibleAndNearbyCutoff();
49 case CUTOFF_ALLOW_EVERYTHING
:
50 return PriorityCalculator::AllowEverythingCutoff();
53 return PriorityCalculator::AllowNothingCutoff();
58 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy(
59 PriorityCutoff priority_cutoff
) {
60 switch (priority_cutoff
) {
61 case CUTOFF_ALLOW_NOTHING
:
63 case CUTOFF_ALLOW_REQUIRED_ONLY
:
64 return ALLOW_ABSOLUTE_MINIMUM
;
65 case CUTOFF_ALLOW_NICE_TO_HAVE
:
66 return ALLOW_PREPAINT_ONLY
;
67 case CUTOFF_ALLOW_EVERYTHING
:
68 return ALLOW_ANYTHING
;