OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/output/managed_memory_policy.h" | 5 #include "cc/output/managed_memory_policy.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "cc/resources/priority_calculator.h" | 8 #include "cc/resources/priority_calculator.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
11 | 11 |
12 const size_t ManagedMemoryPolicy::kDefaultNumResourcesLimit = 10 * 1000 * 1000; | 12 const size_t ManagedMemoryPolicy::kDefaultNumResourcesLimit = 10 * 1000 * 1000; |
13 | 13 |
14 using gpu::MemoryAllocation; | 14 using gpu::MemoryAllocation; |
15 | 15 |
16 ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytes_limit_when_visible) | 16 ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytes_limit_when_visible) |
17 : bytes_limit_when_visible(bytes_limit_when_visible), | 17 : bytes_limit_when_visible(bytes_limit_when_visible), |
18 priority_cutoff_when_visible(MemoryAllocation::CUTOFF_ALLOW_EVERYTHING), | 18 priority_cutoff_when_visible(MemoryAllocation::CUTOFF_ALLOW_EVERYTHING), |
19 bytes_limit_when_not_visible(0), | |
20 priority_cutoff_when_not_visible(MemoryAllocation::CUTOFF_ALLOW_NOTHING), | |
21 num_resources_limit(kDefaultNumResourcesLimit) {} | 19 num_resources_limit(kDefaultNumResourcesLimit) {} |
22 | 20 |
23 ManagedMemoryPolicy::ManagedMemoryPolicy( | 21 ManagedMemoryPolicy::ManagedMemoryPolicy( |
24 const gpu::MemoryAllocation& allocation) | 22 const gpu::MemoryAllocation& allocation) |
25 : bytes_limit_when_visible(allocation.bytes_limit_when_visible), | 23 : bytes_limit_when_visible(allocation.bytes_limit_when_visible), |
26 priority_cutoff_when_visible(allocation.priority_cutoff_when_visible), | 24 priority_cutoff_when_visible(allocation.priority_cutoff_when_visible), |
27 bytes_limit_when_not_visible(allocation.bytes_limit_when_not_visible), | |
28 priority_cutoff_when_not_visible( | |
29 allocation.priority_cutoff_when_not_visible), | |
30 num_resources_limit(kDefaultNumResourcesLimit) {} | 25 num_resources_limit(kDefaultNumResourcesLimit) {} |
31 | 26 |
32 ManagedMemoryPolicy::ManagedMemoryPolicy( | 27 ManagedMemoryPolicy::ManagedMemoryPolicy( |
33 size_t bytes_limit_when_visible, | 28 size_t bytes_limit_when_visible, |
34 MemoryAllocation::PriorityCutoff priority_cutoff_when_visible, | 29 MemoryAllocation::PriorityCutoff priority_cutoff_when_visible, |
35 size_t bytes_limit_when_not_visible, | |
36 MemoryAllocation::PriorityCutoff priority_cutoff_when_not_visible, | |
37 size_t num_resources_limit) | 30 size_t num_resources_limit) |
38 : bytes_limit_when_visible(bytes_limit_when_visible), | 31 : bytes_limit_when_visible(bytes_limit_when_visible), |
39 priority_cutoff_when_visible(priority_cutoff_when_visible), | 32 priority_cutoff_when_visible(priority_cutoff_when_visible), |
40 bytes_limit_when_not_visible(bytes_limit_when_not_visible), | |
41 priority_cutoff_when_not_visible(priority_cutoff_when_not_visible), | |
42 num_resources_limit(num_resources_limit) {} | 33 num_resources_limit(num_resources_limit) {} |
43 | 34 |
44 bool ManagedMemoryPolicy::operator==(const ManagedMemoryPolicy& other) const { | 35 bool ManagedMemoryPolicy::operator==(const ManagedMemoryPolicy& other) const { |
45 return bytes_limit_when_visible == other.bytes_limit_when_visible && | 36 return bytes_limit_when_visible == other.bytes_limit_when_visible && |
46 priority_cutoff_when_visible == other.priority_cutoff_when_visible && | 37 priority_cutoff_when_visible == other.priority_cutoff_when_visible && |
47 bytes_limit_when_not_visible == other.bytes_limit_when_not_visible && | |
48 priority_cutoff_when_not_visible == | |
49 other.priority_cutoff_when_not_visible && | |
50 num_resources_limit == other.num_resources_limit; | 38 num_resources_limit == other.num_resources_limit; |
51 } | 39 } |
52 | 40 |
53 bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy& other) const { | 41 bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy& other) const { |
54 return !(*this == other); | 42 return !(*this == other); |
55 } | 43 } |
56 | 44 |
57 // static | 45 // static |
58 int ManagedMemoryPolicy::PriorityCutoffToValue( | 46 int ManagedMemoryPolicy::PriorityCutoffToValue( |
59 MemoryAllocation::PriorityCutoff priority_cutoff) { | 47 MemoryAllocation::PriorityCutoff priority_cutoff) { |
(...skipping 23 matching lines...) Expand all Loading... |
83 case MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE: | 71 case MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE: |
84 return ALLOW_PREPAINT_ONLY; | 72 return ALLOW_PREPAINT_ONLY; |
85 case MemoryAllocation::CUTOFF_ALLOW_EVERYTHING: | 73 case MemoryAllocation::CUTOFF_ALLOW_EVERYTHING: |
86 return ALLOW_ANYTHING; | 74 return ALLOW_ANYTHING; |
87 } | 75 } |
88 NOTREACHED(); | 76 NOTREACHED(); |
89 return ALLOW_NOTHING; | 77 return ALLOW_NOTHING; |
90 } | 78 } |
91 | 79 |
92 } // namespace cc | 80 } // namespace cc |
OLD | NEW |