| 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; | |
| 13 | |
| 14 using gpu::MemoryAllocation; | 12 using gpu::MemoryAllocation; |
| 15 | 13 |
| 16 ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytes_limit_when_visible) | 14 ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytes_limit_when_visible) |
| 17 : bytes_limit_when_visible(bytes_limit_when_visible), | 15 : bytes_limit_when_visible(bytes_limit_when_visible), |
| 18 priority_cutoff_when_visible(MemoryAllocation::CUTOFF_ALLOW_EVERYTHING), | 16 priority_cutoff_when_visible(MemoryAllocation::CUTOFF_ALLOW_EVERYTHING) { |
| 19 num_resources_limit(kDefaultNumResourcesLimit) {} | 17 } |
| 20 | 18 |
| 21 ManagedMemoryPolicy::ManagedMemoryPolicy( | 19 ManagedMemoryPolicy::ManagedMemoryPolicy( |
| 22 const gpu::MemoryAllocation& allocation) | 20 const gpu::MemoryAllocation& allocation) |
| 23 : bytes_limit_when_visible(allocation.bytes_limit_when_visible), | 21 : bytes_limit_when_visible(allocation.bytes_limit_when_visible), |
| 24 priority_cutoff_when_visible(allocation.priority_cutoff_when_visible), | 22 priority_cutoff_when_visible(allocation.priority_cutoff_when_visible) { |
| 25 num_resources_limit(kDefaultNumResourcesLimit) {} | 23 } |
| 26 | 24 |
| 27 ManagedMemoryPolicy::ManagedMemoryPolicy( | 25 ManagedMemoryPolicy::ManagedMemoryPolicy( |
| 28 size_t bytes_limit_when_visible, | 26 size_t bytes_limit_when_visible, |
| 29 MemoryAllocation::PriorityCutoff priority_cutoff_when_visible, | 27 MemoryAllocation::PriorityCutoff priority_cutoff_when_visible) |
| 30 size_t num_resources_limit) | |
| 31 : bytes_limit_when_visible(bytes_limit_when_visible), | 28 : bytes_limit_when_visible(bytes_limit_when_visible), |
| 32 priority_cutoff_when_visible(priority_cutoff_when_visible), | 29 priority_cutoff_when_visible(priority_cutoff_when_visible) { |
| 33 num_resources_limit(num_resources_limit) {} | 30 } |
| 34 | 31 |
| 35 bool ManagedMemoryPolicy::operator==(const ManagedMemoryPolicy& other) const { | 32 bool ManagedMemoryPolicy::operator==(const ManagedMemoryPolicy& other) const { |
| 36 return bytes_limit_when_visible == other.bytes_limit_when_visible && | 33 return bytes_limit_when_visible == other.bytes_limit_when_visible && |
| 37 priority_cutoff_when_visible == other.priority_cutoff_when_visible && | 34 priority_cutoff_when_visible == other.priority_cutoff_when_visible; |
| 38 num_resources_limit == other.num_resources_limit; | |
| 39 } | 35 } |
| 40 | 36 |
| 41 bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy& other) const { | 37 bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy& other) const { |
| 42 return !(*this == other); | 38 return !(*this == other); |
| 43 } | 39 } |
| 44 | 40 |
| 45 // static | 41 // static |
| 46 int ManagedMemoryPolicy::PriorityCutoffToValue( | 42 int ManagedMemoryPolicy::PriorityCutoffToValue( |
| 47 MemoryAllocation::PriorityCutoff priority_cutoff) { | 43 MemoryAllocation::PriorityCutoff priority_cutoff) { |
| 48 switch (priority_cutoff) { | 44 switch (priority_cutoff) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 71 case MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE: | 67 case MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE: |
| 72 return ALLOW_PREPAINT_ONLY; | 68 return ALLOW_PREPAINT_ONLY; |
| 73 case MemoryAllocation::CUTOFF_ALLOW_EVERYTHING: | 69 case MemoryAllocation::CUTOFF_ALLOW_EVERYTHING: |
| 74 return ALLOW_ANYTHING; | 70 return ALLOW_ANYTHING; |
| 75 } | 71 } |
| 76 NOTREACHED(); | 72 NOTREACHED(); |
| 77 return ALLOW_NOTHING; | 73 return ALLOW_NOTHING; |
| 78 } | 74 } |
| 79 | 75 |
| 80 } // namespace cc | 76 } // namespace cc |
| OLD | NEW |