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