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

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

Issue 421183003: Revert of Add builders for tracing event's structural arguments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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.cc ('k') | cc/resources/tile_priority.cc » ('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>
11 10
12 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 #include "cc/resources/picture_pile.h" 13 #include "cc/resources/picture_pile.h"
15 #include "ui/gfx/quad_f.h" 14 #include "ui/gfx/quad_f.h"
16 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
17 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
18 17
19 namespace base { 18 namespace base {
20 class Value; 19 class Value;
21 } 20 }
22 21
23 namespace cc { 22 namespace cc {
24 23
25 enum WhichTree { 24 enum WhichTree {
26 // Note: these must be 0 and 1 because we index with them in various places, 25 // Note: these must be 0 and 1 because we index with them in various places,
27 // e.g. in Tile::priority_. 26 // e.g. in Tile::priority_.
28 ACTIVE_TREE = 0, 27 ACTIVE_TREE = 0,
29 PENDING_TREE = 1, 28 PENDING_TREE = 1,
30 NUM_TREES = 2 29 NUM_TREES = 2
31 // Be sure to update WhichTreeAsValue when adding new fields. 30 // Be sure to update WhichTreeAsValue when adding new fields.
32 }; 31 };
33 scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree); 32 scoped_ptr<base::Value> WhichTreeAsValue(
33 WhichTree tree);
34 34
35 enum TileResolution { 35 enum TileResolution {
36 LOW_RESOLUTION = 0 , 36 LOW_RESOLUTION = 0 ,
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 scoped_ptr<base::Value> TileResolutionAsValue(
41 TileResolution resolution);
41 42
42 struct CC_EXPORT TilePriority { 43 struct CC_EXPORT TilePriority {
43 enum PriorityBin { NOW, SOON, EVENTUALLY }; 44 enum PriorityBin { NOW, SOON, EVENTUALLY };
44 45
45 TilePriority() 46 TilePriority()
46 : resolution(NON_IDEAL_RESOLUTION), 47 : resolution(NON_IDEAL_RESOLUTION),
47 required_for_activation(false), 48 required_for_activation(false),
48 priority_bin(EVENTUALLY), 49 priority_bin(EVENTUALLY),
49 distance_to_visible(std::numeric_limits<float>::infinity()) {} 50 distance_to_visible(std::numeric_limits<float>::infinity()) {}
50 51
(...skipping 24 matching lines...) Expand all
75 } else if (active.priority_bin > pending.priority_bin) { 76 } else if (active.priority_bin > pending.priority_bin) {
76 priority_bin = pending.priority_bin; 77 priority_bin = pending.priority_bin;
77 distance_to_visible = pending.distance_to_visible; 78 distance_to_visible = pending.distance_to_visible;
78 } else { 79 } else {
79 priority_bin = active.priority_bin; 80 priority_bin = active.priority_bin;
80 distance_to_visible = 81 distance_to_visible =
81 std::min(active.distance_to_visible, pending.distance_to_visible); 82 std::min(active.distance_to_visible, pending.distance_to_visible);
82 } 83 }
83 } 84 }
84 85
85 void AsValueInto(base::debug::TracedValue* dict) const; 86 scoped_ptr<base::Value> AsValue() const;
86 87
87 bool operator ==(const TilePriority& other) const { 88 bool operator ==(const TilePriority& other) const {
88 return resolution == other.resolution && 89 return resolution == other.resolution &&
89 priority_bin == other.priority_bin && 90 priority_bin == other.priority_bin &&
90 distance_to_visible == other.distance_to_visible && 91 distance_to_visible == other.distance_to_visible &&
91 required_for_activation == other.required_for_activation; 92 required_for_activation == other.required_for_activation;
92 } 93 }
93 94
94 bool operator !=(const TilePriority& other) const { 95 bool operator !=(const TilePriority& other) const {
95 return !(*this == other); 96 return !(*this == other);
96 } 97 }
97 98
98 bool IsHigherPriorityThan(const TilePriority& other) const { 99 bool IsHigherPriorityThan(const TilePriority& other) const {
99 return priority_bin < other.priority_bin || 100 return priority_bin < other.priority_bin ||
100 (priority_bin == other.priority_bin && 101 (priority_bin == other.priority_bin &&
101 distance_to_visible < other.distance_to_visible); 102 distance_to_visible < other.distance_to_visible);
102 } 103 }
103 104
104 TileResolution resolution; 105 TileResolution resolution;
105 bool required_for_activation; 106 bool required_for_activation;
106 PriorityBin priority_bin; 107 PriorityBin priority_bin;
107 float distance_to_visible; 108 float distance_to_visible;
108 }; 109 };
109 110
110 std::string TilePriorityBinToString(TilePriority::PriorityBin bin); 111 scoped_ptr<base::Value> TilePriorityBinAsValue(TilePriority::PriorityBin bin);
111 112
112 enum TileMemoryLimitPolicy { 113 enum TileMemoryLimitPolicy {
113 // Nothing. 114 // Nothing.
114 ALLOW_NOTHING = 0, 115 ALLOW_NOTHING = 0,
115 116
116 // You might be made visible, but you're not being interacted with. 117 // You might be made visible, but you're not being interacted with.
117 ALLOW_ABSOLUTE_MINIMUM = 1, // Tall. 118 ALLOW_ABSOLUTE_MINIMUM = 1, // Tall.
118 119
119 // You're being interacted with, but we're low on memory. 120 // You're being interacted with, but we're low on memory.
120 ALLOW_PREPAINT_ONLY = 2, // Grande. 121 ALLOW_PREPAINT_ONLY = 2, // Grande.
121 122
122 // You're the only thing in town. Go crazy. 123 // You're the only thing in town. Go crazy.
123 ALLOW_ANYTHING = 3, // Venti. 124 ALLOW_ANYTHING = 3, // Venti.
124 125
125 NUM_TILE_MEMORY_LIMIT_POLICIES = 4, 126 NUM_TILE_MEMORY_LIMIT_POLICIES = 4,
126 127
127 // NOTE: Be sure to update TreePriorityAsValue and kBinPolicyMap when adding 128 // NOTE: Be sure to update TreePriorityAsValue and kBinPolicyMap when adding
128 // or reordering fields. 129 // or reordering fields.
129 }; 130 };
130 std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy); 131 scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue(
132 TileMemoryLimitPolicy policy);
131 133
132 enum TreePriority { 134 enum TreePriority {
133 SAME_PRIORITY_FOR_BOTH_TREES, 135 SAME_PRIORITY_FOR_BOTH_TREES,
134 SMOOTHNESS_TAKES_PRIORITY, 136 SMOOTHNESS_TAKES_PRIORITY,
135 NEW_CONTENT_TAKES_PRIORITY, 137 NEW_CONTENT_TAKES_PRIORITY,
136 NUM_TREE_PRIORITIES 138 NUM_TREE_PRIORITIES
137 // Be sure to update TreePriorityAsValue when adding new fields. 139 // Be sure to update TreePriorityAsValue when adding new fields.
138 }; 140 };
139 std::string TreePriorityToString(TreePriority prio); 141 scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio);
140 142
141 class GlobalStateThatImpactsTilePriority { 143 class GlobalStateThatImpactsTilePriority {
142 public: 144 public:
143 GlobalStateThatImpactsTilePriority() 145 GlobalStateThatImpactsTilePriority()
144 : memory_limit_policy(ALLOW_NOTHING), 146 : memory_limit_policy(ALLOW_NOTHING),
145 soft_memory_limit_in_bytes(0), 147 soft_memory_limit_in_bytes(0),
146 hard_memory_limit_in_bytes(0), 148 hard_memory_limit_in_bytes(0),
147 num_resources_limit(0), 149 num_resources_limit(0),
148 tree_priority(SAME_PRIORITY_FOR_BOTH_TREES) {} 150 tree_priority(SAME_PRIORITY_FOR_BOTH_TREES) {}
149 151
150 TileMemoryLimitPolicy memory_limit_policy; 152 TileMemoryLimitPolicy memory_limit_policy;
151 153
152 size_t soft_memory_limit_in_bytes; 154 size_t soft_memory_limit_in_bytes;
153 size_t hard_memory_limit_in_bytes; 155 size_t hard_memory_limit_in_bytes;
154 size_t num_resources_limit; 156 size_t num_resources_limit;
155 157
156 TreePriority tree_priority; 158 TreePriority tree_priority;
157 159
158 bool operator==(const GlobalStateThatImpactsTilePriority& other) const { 160 bool operator==(const GlobalStateThatImpactsTilePriority& other) const {
159 return memory_limit_policy == other.memory_limit_policy && 161 return memory_limit_policy == other.memory_limit_policy &&
160 soft_memory_limit_in_bytes == other.soft_memory_limit_in_bytes && 162 soft_memory_limit_in_bytes == other.soft_memory_limit_in_bytes &&
161 hard_memory_limit_in_bytes == other.hard_memory_limit_in_bytes && 163 hard_memory_limit_in_bytes == other.hard_memory_limit_in_bytes &&
162 num_resources_limit == other.num_resources_limit && 164 num_resources_limit == other.num_resources_limit &&
163 tree_priority == other.tree_priority; 165 tree_priority == other.tree_priority;
164 } 166 }
165 bool operator!=(const GlobalStateThatImpactsTilePriority& other) const { 167 bool operator!=(const GlobalStateThatImpactsTilePriority& other) const {
166 return !(*this == other); 168 return !(*this == other);
167 } 169 }
168 170
169 void AsValueInto(base::debug::TracedValue* dict) const; 171 scoped_ptr<base::Value> AsValue() const;
170 }; 172 };
171 173
172 } // namespace cc 174 } // namespace cc
173 175
174 #endif // CC_RESOURCES_TILE_PRIORITY_H_ 176 #endif // CC_RESOURCES_TILE_PRIORITY_H_
OLDNEW
« no previous file with comments | « cc/resources/tile_manager.cc ('k') | cc/resources/tile_priority.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698