OLD | NEW |
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 #include "cc/resources/tile_priority.h" | 5 #include "cc/resources/tile_priority.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 switch (resolution) { | 80 switch (resolution) { |
81 case LOW_RESOLUTION: | 81 case LOW_RESOLUTION: |
82 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 82 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
83 "LOW_RESOLUTION")); | 83 "LOW_RESOLUTION")); |
84 case HIGH_RESOLUTION: | 84 case HIGH_RESOLUTION: |
85 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 85 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
86 "HIGH_RESOLUTION")); | 86 "HIGH_RESOLUTION")); |
87 case NON_IDEAL_RESOLUTION: | 87 case NON_IDEAL_RESOLUTION: |
88 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 88 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
89 "NON_IDEAL_RESOLUTION")); | 89 "NON_IDEAL_RESOLUTION")); |
90 default: | |
91 DCHECK(false) << "Unrecognized TileResolution value " << resolution; | |
92 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | |
93 "<unknown TileResolution value>")); | |
94 } | 90 } |
| 91 DCHECK(false) << "Unrecognized TileResolution value " << resolution; |
| 92 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 93 "<unknown TileResolution value>")); |
95 } | 94 } |
96 | 95 |
97 scoped_ptr<base::Value> TilePriority::AsValue() const { | 96 scoped_ptr<base::Value> TilePriority::AsValue() const { |
98 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 97 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
99 state->Set("resolution", TileResolutionAsValue(resolution).release()); | 98 state->Set("resolution", TileResolutionAsValue(resolution).release()); |
100 state->Set("time_to_visible_in_seconds", | 99 state->Set("time_to_visible_in_seconds", |
101 MathUtil::AsValueSafely(time_to_visible_in_seconds).release()); | 100 MathUtil::AsValueSafely(time_to_visible_in_seconds).release()); |
102 state->Set("distance_to_visible_in_pixels", | 101 state->Set("distance_to_visible_in_pixels", |
103 MathUtil::AsValueSafely(distance_to_visible_in_pixels).release()); | 102 MathUtil::AsValueSafely(distance_to_visible_in_pixels).release()); |
104 return state.PassAs<base::Value>(); | 103 return state.PassAs<base::Value>(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 switch (prio) { | 168 switch (prio) { |
170 case SAME_PRIORITY_FOR_BOTH_TREES: | 169 case SAME_PRIORITY_FOR_BOTH_TREES: |
171 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 170 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
172 "SAME_PRIORITY_FOR_BOTH_TREES")); | 171 "SAME_PRIORITY_FOR_BOTH_TREES")); |
173 case SMOOTHNESS_TAKES_PRIORITY: | 172 case SMOOTHNESS_TAKES_PRIORITY: |
174 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 173 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
175 "SMOOTHNESS_TAKES_PRIORITY")); | 174 "SMOOTHNESS_TAKES_PRIORITY")); |
176 case NEW_CONTENT_TAKES_PRIORITY: | 175 case NEW_CONTENT_TAKES_PRIORITY: |
177 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 176 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
178 "NEW_CONTENT_TAKES_PRIORITY")); | 177 "NEW_CONTENT_TAKES_PRIORITY")); |
179 default: | |
180 DCHECK(false) << "Unrecognized priority value " << prio; | |
181 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | |
182 "<unknown>")); | |
183 } | 178 } |
| 179 DCHECK(false) << "Unrecognized priority value " << prio; |
| 180 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 181 "<unknown>")); |
184 } | 182 } |
185 | 183 |
186 scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const { | 184 scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const { |
187 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 185 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
188 state->Set("memory_limit_policy", | 186 state->Set("memory_limit_policy", |
189 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); | 187 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); |
190 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); | 188 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); |
191 state->SetInteger("unused_memory_limit_in_bytes", | 189 state->SetInteger("unused_memory_limit_in_bytes", |
192 unused_memory_limit_in_bytes); | 190 unused_memory_limit_in_bytes); |
193 state->SetInteger("num_resources_limit", num_resources_limit); | 191 state->SetInteger("num_resources_limit", num_resources_limit); |
194 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); | 192 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); |
195 return state.PassAs<base::Value>(); | 193 return state.PassAs<base::Value>(); |
196 } | 194 } |
197 | 195 |
198 } // namespace cc | 196 } // namespace cc |
OLD | NEW |