Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: cc/resources/tile_priority.h

Issue 367833003: cc: Start using raster/eviction iterators. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/resources/tile_manager_unittest.cc ('k') | cc/test/fake_picture_layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #ifndef CC_RESOURCES_TILE_PRIORITY_H_ 5 #ifndef CC_RESOURCES_TILE_PRIORITY_H_
6 #define CC_RESOURCES_TILE_PRIORITY_H_ 6 #define CC_RESOURCES_TILE_PRIORITY_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 26 matching lines...) Expand all
37 HIGH_RESOLUTION = 1, 37 HIGH_RESOLUTION = 1,
38 NON_IDEAL_RESOLUTION = 2, 38 NON_IDEAL_RESOLUTION = 2,
39 }; 39 };
40 std::string TileResolutionToString(TileResolution resolution); 40 std::string TileResolutionToString(TileResolution resolution);
41 41
42 struct CC_EXPORT TilePriority { 42 struct CC_EXPORT TilePriority {
43 enum PriorityBin { NOW, SOON, EVENTUALLY }; 43 enum PriorityBin { NOW, SOON, EVENTUALLY };
44 44
45 TilePriority() 45 TilePriority()
46 : resolution(NON_IDEAL_RESOLUTION), 46 : resolution(NON_IDEAL_RESOLUTION),
47 required_for_activation(false),
48 priority_bin(EVENTUALLY), 47 priority_bin(EVENTUALLY),
49 distance_to_visible(std::numeric_limits<float>::infinity()) {} 48 distance_to_visible(std::numeric_limits<float>::infinity()) {}
50 49
51 TilePriority(TileResolution resolution, 50 TilePriority(TileResolution resolution,
52 PriorityBin bin, 51 PriorityBin bin,
53 float distance_to_visible) 52 float distance_to_visible)
54 : resolution(resolution), 53 : resolution(resolution),
55 required_for_activation(false),
56 priority_bin(bin), 54 priority_bin(bin),
57 distance_to_visible(distance_to_visible) {} 55 distance_to_visible(distance_to_visible) {}
58 56
59 TilePriority(const TilePriority& active, const TilePriority& pending) { 57 TilePriority(const TilePriority& active, const TilePriority& pending) {
60 if (active.resolution == HIGH_RESOLUTION || 58 if (active.resolution == HIGH_RESOLUTION ||
61 pending.resolution == HIGH_RESOLUTION) 59 pending.resolution == HIGH_RESOLUTION)
62 resolution = HIGH_RESOLUTION; 60 resolution = HIGH_RESOLUTION;
63 else if (active.resolution == LOW_RESOLUTION || 61 else if (active.resolution == LOW_RESOLUTION ||
64 pending.resolution == LOW_RESOLUTION) 62 pending.resolution == LOW_RESOLUTION)
65 resolution = LOW_RESOLUTION; 63 resolution = LOW_RESOLUTION;
66 else 64 else
67 resolution = NON_IDEAL_RESOLUTION; 65 resolution = NON_IDEAL_RESOLUTION;
68 66
69 required_for_activation =
70 active.required_for_activation || pending.required_for_activation;
71
72 if (active.priority_bin < pending.priority_bin) { 67 if (active.priority_bin < pending.priority_bin) {
73 priority_bin = active.priority_bin; 68 priority_bin = active.priority_bin;
74 distance_to_visible = active.distance_to_visible; 69 distance_to_visible = active.distance_to_visible;
75 } else if (active.priority_bin > pending.priority_bin) { 70 } else if (active.priority_bin > pending.priority_bin) {
76 priority_bin = pending.priority_bin; 71 priority_bin = pending.priority_bin;
77 distance_to_visible = pending.distance_to_visible; 72 distance_to_visible = pending.distance_to_visible;
78 } else { 73 } else {
79 priority_bin = active.priority_bin; 74 priority_bin = active.priority_bin;
80 distance_to_visible = 75 distance_to_visible =
81 std::min(active.distance_to_visible, pending.distance_to_visible); 76 std::min(active.distance_to_visible, pending.distance_to_visible);
82 } 77 }
83 } 78 }
84 79
85 void AsValueInto(base::debug::TracedValue* dict) const; 80 void AsValueInto(base::debug::TracedValue* dict) const;
86 81
87 bool operator ==(const TilePriority& other) const { 82 bool operator ==(const TilePriority& other) const {
88 return resolution == other.resolution && 83 return resolution == other.resolution &&
89 priority_bin == other.priority_bin && 84 priority_bin == other.priority_bin &&
90 distance_to_visible == other.distance_to_visible && 85 distance_to_visible == other.distance_to_visible;
91 required_for_activation == other.required_for_activation;
92 } 86 }
93 87
94 bool operator !=(const TilePriority& other) const { 88 bool operator !=(const TilePriority& other) const {
95 return !(*this == other); 89 return !(*this == other);
96 } 90 }
97 91
98 bool IsHigherPriorityThan(const TilePriority& other) const { 92 bool IsHigherPriorityThan(const TilePriority& other) const {
99 return priority_bin < other.priority_bin || 93 return priority_bin < other.priority_bin ||
100 (priority_bin == other.priority_bin && 94 (priority_bin == other.priority_bin &&
101 distance_to_visible < other.distance_to_visible); 95 distance_to_visible < other.distance_to_visible);
102 } 96 }
103 97
104 TileResolution resolution; 98 TileResolution resolution;
105 bool required_for_activation;
106 PriorityBin priority_bin; 99 PriorityBin priority_bin;
107 float distance_to_visible; 100 float distance_to_visible;
108 }; 101 };
109 102
110 std::string TilePriorityBinToString(TilePriority::PriorityBin bin); 103 std::string TilePriorityBinToString(TilePriority::PriorityBin bin);
111 104
112 enum TileMemoryLimitPolicy { 105 enum TileMemoryLimitPolicy {
113 // Nothing. This mode is used when visible is set to false. 106 // Nothing. This mode is used when visible is set to false.
114 ALLOW_NOTHING = 0, 107 ALLOW_NOTHING = 0,
115 108
116 // You might be made visible, but you're not being interacted with. 109 // You might be made visible, but you're not being interacted with.
117 ALLOW_ABSOLUTE_MINIMUM = 1, // Tall. 110 ALLOW_ABSOLUTE_MINIMUM = 1, // Tall.
118 111
119 // You're being interacted with, but we're low on memory. 112 // You're being interacted with, but we're low on memory.
120 ALLOW_PREPAINT_ONLY = 2, // Grande. 113 ALLOW_PREPAINT_ONLY = 2, // Grande.
121 114
122 // You're the only thing in town. Go crazy. 115 // You're the only thing in town. Go crazy.
123 ALLOW_ANYTHING = 3, // Venti. 116 ALLOW_ANYTHING = 3 // Venti.
124 NUM_TILE_MEMORY_LIMIT_POLICIES = 4,
125
126 // NOTE: Be sure to update TreePriorityAsValue and kBinPolicyMap when adding
127 // or reordering fields.
128 }; 117 };
129 std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy); 118 std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy);
130 119
131 enum TreePriority { 120 enum TreePriority {
132 SAME_PRIORITY_FOR_BOTH_TREES, 121 SAME_PRIORITY_FOR_BOTH_TREES,
133 SMOOTHNESS_TAKES_PRIORITY, 122 SMOOTHNESS_TAKES_PRIORITY,
134 NEW_CONTENT_TAKES_PRIORITY, 123 NEW_CONTENT_TAKES_PRIORITY,
135 NUM_TREE_PRIORITIES 124 NUM_TREE_PRIORITIES
136 // Be sure to update TreePriorityAsValue when adding new fields. 125 // Be sure to update TreePriorityAsValue when adding new fields.
137 }; 126 };
(...skipping 26 matching lines...) Expand all
164 bool operator!=(const GlobalStateThatImpactsTilePriority& other) const { 153 bool operator!=(const GlobalStateThatImpactsTilePriority& other) const {
165 return !(*this == other); 154 return !(*this == other);
166 } 155 }
167 156
168 void AsValueInto(base::debug::TracedValue* dict) const; 157 void AsValueInto(base::debug::TracedValue* dict) const;
169 }; 158 };
170 159
171 } // namespace cc 160 } // namespace cc
172 161
173 #endif // CC_RESOURCES_TILE_PRIORITY_H_ 162 #endif // CC_RESOURCES_TILE_PRIORITY_H_
OLDNEW
« no previous file with comments | « cc/resources/tile_manager_unittest.cc ('k') | cc/test/fake_picture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698