cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / cc / output / managed_memory_policy.cc
blob7e837662c29c8011eace94aa556182735e9bfce8
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
3 // found in the LICENSE file.
5 #include "cc/output/managed_memory_policy.h"
7 #include "base/logging.h"
8 #include "cc/resources/priority_calculator.h"
10 namespace cc {
12 const size_t ManagedMemoryPolicy::kDefaultNumResourcesLimit = 10 * 1000 * 1000;
14 ManagedMemoryPolicy::ManagedMemoryPolicy(size_t bytes_limit_when_visible)
15 : bytes_limit_when_visible(bytes_limit_when_visible),
16 priority_cutoff_when_visible(CUTOFF_ALLOW_EVERYTHING),
17 bytes_limit_when_not_visible(0),
18 priority_cutoff_when_not_visible(CUTOFF_ALLOW_NOTHING),
19 num_resources_limit(kDefaultNumResourcesLimit) {}
21 ManagedMemoryPolicy::ManagedMemoryPolicy(
22 size_t bytes_limit_when_visible,
23 PriorityCutoff priority_cutoff_when_visible,
24 size_t bytes_limit_when_not_visible,
25 PriorityCutoff priority_cutoff_when_not_visible,
26 size_t num_resources_limit)
27 : bytes_limit_when_visible(bytes_limit_when_visible),
28 priority_cutoff_when_visible(priority_cutoff_when_visible),
29 bytes_limit_when_not_visible(bytes_limit_when_not_visible),
30 priority_cutoff_when_not_visible(priority_cutoff_when_not_visible),
31 num_resources_limit(num_resources_limit) {}
33 bool ManagedMemoryPolicy::operator==(const ManagedMemoryPolicy& other) const {
34 return bytes_limit_when_visible == other.bytes_limit_when_visible &&
35 priority_cutoff_when_visible == other.priority_cutoff_when_visible &&
36 bytes_limit_when_not_visible == other.bytes_limit_when_not_visible &&
37 priority_cutoff_when_not_visible ==
38 other.priority_cutoff_when_not_visible &&
39 num_resources_limit == other.num_resources_limit;
42 bool ManagedMemoryPolicy::operator!=(const ManagedMemoryPolicy& other) const {
43 return !(*this == other);
46 // static
47 int ManagedMemoryPolicy::PriorityCutoffToValue(PriorityCutoff priority_cutoff) {
48 switch (priority_cutoff) {
49 case CUTOFF_ALLOW_NOTHING:
50 return PriorityCalculator::AllowNothingCutoff();
51 case CUTOFF_ALLOW_REQUIRED_ONLY:
52 return PriorityCalculator::AllowVisibleOnlyCutoff();
53 case CUTOFF_ALLOW_NICE_TO_HAVE:
54 return PriorityCalculator::AllowVisibleAndNearbyCutoff();
55 case CUTOFF_ALLOW_EVERYTHING:
56 return PriorityCalculator::AllowEverythingCutoff();
58 NOTREACHED();
59 return PriorityCalculator::AllowNothingCutoff();
62 // static
63 TileMemoryLimitPolicy
64 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy(
65 PriorityCutoff priority_cutoff) {
66 switch (priority_cutoff) {
67 case CUTOFF_ALLOW_NOTHING:
68 return ALLOW_NOTHING;
69 case CUTOFF_ALLOW_REQUIRED_ONLY:
70 return ALLOW_ABSOLUTE_MINIMUM;
71 case CUTOFF_ALLOW_NICE_TO_HAVE:
72 return ALLOW_PREPAINT_ONLY;
73 case CUTOFF_ALLOW_EVERYTHING:
74 return ALLOW_ANYTHING;
76 NOTREACHED();
77 return ALLOW_NOTHING;
80 } // namespace cc