blob: 01e793aa94057ec791f986f323a38aa2dc71a05a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright 2011 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 "managed_memory_policy.h"
#include "base/logging.h"
#include "priority_calculator.h"
namespace cc {
ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytesLimitWhenVisible)
: bytesLimitWhenVisible(bytesLimitWhenVisible)
, priorityCutoffWhenVisible(CUTOFF_ALLOW_EVERYTHING)
, bytesLimitWhenNotVisible(0)
, priorityCutoffWhenNotVisible(CUTOFF_ALLOW_NOTHING)
{
}
ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytesLimitWhenVisible,
PriorityCutoff priorityCutoffWhenVisible,
size_t bytesLimitWhenNotVisible,
PriorityCutoff priorityCutoffWhenNotVisible)
: bytesLimitWhenVisible(bytesLimitWhenVisible)
, priorityCutoffWhenVisible(priorityCutoffWhenVisible)
, bytesLimitWhenNotVisible(bytesLimitWhenNotVisible)
, priorityCutoffWhenNotVisible(priorityCutoffWhenNotVisible)
{
}
bool ManagedMemoryPolicy::operator==(const ManagedMemoryPolicy& other) const
{
return bytesLimitWhenVisible == other.bytesLimitWhenVisible &&
priorityCutoffWhenVisible == other.priorityCutoffWhenVisible &&
bytesLimitWhenNotVisible == other.bytesLimitWhenNotVisible &&
priorityCutoffWhenNotVisible == other.priorityCutoffWhenNotVisible;
}
bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy& other) const
{
return !(*this == other);
}
// static
int ManagedMemoryPolicy::priorityCutoffToValue(PriorityCutoff priorityCutoff)
{
switch (priorityCutoff) {
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 priorityCutoff)
{
switch (priorityCutoff) {
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
|