| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 namespace cc { | 61 namespace cc { |
| 62 | 62 |
| 63 scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree) { | 63 scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree) { |
| 64 switch (tree) { | 64 switch (tree) { |
| 65 case ACTIVE_TREE: | 65 case ACTIVE_TREE: |
| 66 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 66 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 67 "ACTIVE_TREE")); | 67 "ACTIVE_TREE")); |
| 68 case PENDING_TREE: | 68 case PENDING_TREE: |
| 69 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 69 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 70 "PENDING_TREE")); | 70 "PENDING_TREE")); |
| 71 default: | |
| 72 DCHECK(false) << "Unrecognized WhichTree value " << tree; | |
| 73 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | |
| 74 "<unknown WhichTree value>")); | |
| 75 } | 71 } |
| 72 DCHECK(false) << "Unrecognized WhichTree value " << tree; |
| 73 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 74 "<unknown WhichTree value>")); |
| 76 } | 75 } |
| 77 | 76 |
| 78 scoped_ptr<base::Value> TileResolutionAsValue( | 77 scoped_ptr<base::Value> TileResolutionAsValue( |
| 79 TileResolution resolution) { | 78 TileResolution resolution) { |
| 80 switch (resolution) { | 79 switch (resolution) { |
| 81 case LOW_RESOLUTION: | 80 case LOW_RESOLUTION: |
| 82 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 81 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 83 "LOW_RESOLUTION")); | 82 "LOW_RESOLUTION")); |
| 84 case HIGH_RESOLUTION: | 83 case HIGH_RESOLUTION: |
| 85 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 84 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 86 "HIGH_RESOLUTION")); | 85 "HIGH_RESOLUTION")); |
| 87 case NON_IDEAL_RESOLUTION: | 86 case NON_IDEAL_RESOLUTION: |
| 88 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 87 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 89 "NON_IDEAL_RESOLUTION")); | 88 "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 } | 89 } |
| 90 DCHECK(false) << "Unrecognized TileResolution value " << resolution; |
| 91 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 92 "<unknown TileResolution value>")); |
| 95 } | 93 } |
| 96 | 94 |
| 97 scoped_ptr<base::Value> TilePriority::AsValue() const { | 95 scoped_ptr<base::Value> TilePriority::AsValue() const { |
| 98 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 96 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 99 state->Set("resolution", TileResolutionAsValue(resolution).release()); | 97 state->Set("resolution", TileResolutionAsValue(resolution).release()); |
| 100 state->Set("time_to_visible_in_seconds", | 98 state->Set("time_to_visible_in_seconds", |
| 101 MathUtil::AsValueSafely(time_to_visible_in_seconds).release()); | 99 MathUtil::AsValueSafely(time_to_visible_in_seconds).release()); |
| 102 state->Set("distance_to_visible_in_pixels", | 100 state->Set("distance_to_visible_in_pixels", |
| 103 MathUtil::AsValueSafely(distance_to_visible_in_pixels).release()); | 101 MathUtil::AsValueSafely(distance_to_visible_in_pixels).release()); |
| 104 return state.PassAs<base::Value>(); | 102 return state.PassAs<base::Value>(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 "ALLOW_NOTHING")); | 149 "ALLOW_NOTHING")); |
| 152 case ALLOW_ABSOLUTE_MINIMUM: | 150 case ALLOW_ABSOLUTE_MINIMUM: |
| 153 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 151 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 154 "ALLOW_ABSOLUTE_MINIMUM")); | 152 "ALLOW_ABSOLUTE_MINIMUM")); |
| 155 case ALLOW_PREPAINT_ONLY: | 153 case ALLOW_PREPAINT_ONLY: |
| 156 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 154 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 157 "ALLOW_PREPAINT_ONLY")); | 155 "ALLOW_PREPAINT_ONLY")); |
| 158 case ALLOW_ANYTHING: | 156 case ALLOW_ANYTHING: |
| 159 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 157 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 160 "ALLOW_ANYTHING")); | 158 "ALLOW_ANYTHING")); |
| 161 default: | |
| 162 DCHECK(false) << "Unrecognized policy value"; | |
| 163 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | |
| 164 "<unknown>")); | |
| 165 } | 159 } |
| 160 DCHECK(false) << "Unrecognized policy value"; |
| 161 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 162 "<unknown>")); |
| 166 } | 163 } |
| 167 | 164 |
| 168 scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio) { | 165 scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio) { |
| 169 switch (prio) { | 166 switch (prio) { |
| 170 case SAME_PRIORITY_FOR_BOTH_TREES: | 167 case SAME_PRIORITY_FOR_BOTH_TREES: |
| 171 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 168 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 172 "SAME_PRIORITY_FOR_BOTH_TREES")); | 169 "SAME_PRIORITY_FOR_BOTH_TREES")); |
| 173 case SMOOTHNESS_TAKES_PRIORITY: | 170 case SMOOTHNESS_TAKES_PRIORITY: |
| 174 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 171 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 175 "SMOOTHNESS_TAKES_PRIORITY")); | 172 "SMOOTHNESS_TAKES_PRIORITY")); |
| 176 case NEW_CONTENT_TAKES_PRIORITY: | 173 case NEW_CONTENT_TAKES_PRIORITY: |
| 177 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 174 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 178 "NEW_CONTENT_TAKES_PRIORITY")); | 175 "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 } | 176 } |
| 177 DCHECK(false) << "Unrecognized priority value " << prio; |
| 178 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 179 "<unknown>")); |
| 184 } | 180 } |
| 185 | 181 |
| 186 scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const { | 182 scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const { |
| 187 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 183 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 188 state->Set("memory_limit_policy", | 184 state->Set("memory_limit_policy", |
| 189 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); | 185 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); |
| 190 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); | 186 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); |
| 191 state->SetInteger("unused_memory_limit_in_bytes", | 187 state->SetInteger("unused_memory_limit_in_bytes", |
| 192 unused_memory_limit_in_bytes); | 188 unused_memory_limit_in_bytes); |
| 193 state->SetInteger("num_resources_limit", num_resources_limit); | 189 state->SetInteger("num_resources_limit", num_resources_limit); |
| 194 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); | 190 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); |
| 195 return state.PassAs<base::Value>(); | 191 return state.PassAs<base::Value>(); |
| 196 } | 192 } |
| 197 | 193 |
| 198 } // namespace cc | 194 } // namespace cc |
| OLD | NEW |