| 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/proto/gpu_conversions.h" |
| 9 #include "cc/proto/managed_memory_policy.pb.h" |
| 8 | 10 |
| 9 namespace cc { | 11 namespace cc { |
| 10 | 12 |
| 11 const size_t ManagedMemoryPolicy::kDefaultNumResourcesLimit = 10 * 1000 * 1000; | 13 const size_t ManagedMemoryPolicy::kDefaultNumResourcesLimit = 10 * 1000 * 1000; |
| 12 | 14 |
| 13 using gpu::MemoryAllocation; | 15 using gpu::MemoryAllocation; |
| 14 | 16 |
| 15 ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytes_limit_when_visible) | 17 ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytes_limit_when_visible) |
| 16 : bytes_limit_when_visible(bytes_limit_when_visible), | 18 : bytes_limit_when_visible(bytes_limit_when_visible), |
| 17 priority_cutoff_when_visible(MemoryAllocation::CUTOFF_ALLOW_EVERYTHING), | 19 priority_cutoff_when_visible(MemoryAllocation::CUTOFF_ALLOW_EVERYTHING), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 34 bool ManagedMemoryPolicy::operator==(const ManagedMemoryPolicy& other) const { | 36 bool ManagedMemoryPolicy::operator==(const ManagedMemoryPolicy& other) const { |
| 35 return bytes_limit_when_visible == other.bytes_limit_when_visible && | 37 return bytes_limit_when_visible == other.bytes_limit_when_visible && |
| 36 priority_cutoff_when_visible == other.priority_cutoff_when_visible && | 38 priority_cutoff_when_visible == other.priority_cutoff_when_visible && |
| 37 num_resources_limit == other.num_resources_limit; | 39 num_resources_limit == other.num_resources_limit; |
| 38 } | 40 } |
| 39 | 41 |
| 40 bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy& other) const { | 42 bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy& other) const { |
| 41 return !(*this == other); | 43 return !(*this == other); |
| 42 } | 44 } |
| 43 | 45 |
| 46 void ManagedMemoryPolicy::ToProtobuf(proto::ManagedMemoryPolicy* proto) const { |
| 47 proto->set_bytes_limit_when_visible(bytes_limit_when_visible); |
| 48 proto->set_priority_cutoff_when_visible( |
| 49 MemoryAllocationPriorityCutoffToProto(priority_cutoff_when_visible)); |
| 50 proto->set_num_resources_limit(num_resources_limit); |
| 51 } |
| 52 |
| 53 void ManagedMemoryPolicy::FromProtobuf( |
| 54 const proto::ManagedMemoryPolicy& proto) { |
| 55 bytes_limit_when_visible = proto.bytes_limit_when_visible(); |
| 56 priority_cutoff_when_visible = MemoryAllocationPriorityCutoffFromProto( |
| 57 proto.priority_cutoff_when_visible()); |
| 58 num_resources_limit = proto.num_resources_limit(); |
| 59 } |
| 60 |
| 44 // static | 61 // static |
| 45 TileMemoryLimitPolicy | 62 TileMemoryLimitPolicy |
| 46 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( | 63 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( |
| 47 gpu::MemoryAllocation::PriorityCutoff priority_cutoff) { | 64 gpu::MemoryAllocation::PriorityCutoff priority_cutoff) { |
| 48 switch (priority_cutoff) { | 65 switch (priority_cutoff) { |
| 49 case MemoryAllocation::CUTOFF_ALLOW_NOTHING: | 66 case MemoryAllocation::CUTOFF_ALLOW_NOTHING: |
| 50 return ALLOW_NOTHING; | 67 return ALLOW_NOTHING; |
| 51 case MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY: | 68 case MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY: |
| 52 return ALLOW_ABSOLUTE_MINIMUM; | 69 return ALLOW_ABSOLUTE_MINIMUM; |
| 53 case MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE: | 70 case MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE: |
| 54 return ALLOW_PREPAINT_ONLY; | 71 return ALLOW_PREPAINT_ONLY; |
| 55 case MemoryAllocation::CUTOFF_ALLOW_EVERYTHING: | 72 case MemoryAllocation::CUTOFF_ALLOW_EVERYTHING: |
| 56 return ALLOW_ANYTHING; | 73 return ALLOW_ANYTHING; |
| 57 } | 74 } |
| 58 NOTREACHED(); | 75 NOTREACHED(); |
| 59 return ALLOW_NOTHING; | 76 return ALLOW_NOTHING; |
| 60 } | 77 } |
| 61 | 78 |
| 62 } // namespace cc | 79 } // namespace cc |
| OLD | NEW |