| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 out->end_ = std::min(out->end_, t); | 48 out->end_ = std::min(out->end_, t); |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 namespace cc { | 53 namespace cc { |
| 54 | 54 |
| 55 scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree) { | 55 scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree) { |
| 56 switch (tree) { | 56 switch (tree) { |
| 57 case ACTIVE_TREE: | 57 case ACTIVE_TREE: |
| 58 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 58 return scoped_ptr<base::Value>(new base::StringValue("ACTIVE_TREE")); |
| 59 "ACTIVE_TREE")); | |
| 60 case PENDING_TREE: | 59 case PENDING_TREE: |
| 61 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 60 return scoped_ptr<base::Value>(new base::StringValue("PENDING_TREE")); |
| 62 "PENDING_TREE")); | |
| 63 default: | 61 default: |
| 64 DCHECK(false) << "Unrecognized WhichTree value " << tree; | 62 DCHECK(false) << "Unrecognized WhichTree value " << tree; |
| 65 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 63 return scoped_ptr<base::Value>(new base::StringValue( |
| 66 "<unknown WhichTree value>")); | 64 "<unknown WhichTree value>")); |
| 67 } | 65 } |
| 68 } | 66 } |
| 69 | 67 |
| 70 scoped_ptr<base::Value> TileResolutionAsValue( | 68 scoped_ptr<base::Value> TileResolutionAsValue( |
| 71 TileResolution resolution) { | 69 TileResolution resolution) { |
| 72 switch (resolution) { | 70 switch (resolution) { |
| 73 case LOW_RESOLUTION: | 71 case LOW_RESOLUTION: |
| 74 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 72 return scoped_ptr<base::Value>(new base::StringValue("LOW_RESOLUTION")); |
| 75 "LOW_RESOLUTION")); | |
| 76 case HIGH_RESOLUTION: | 73 case HIGH_RESOLUTION: |
| 77 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 74 return scoped_ptr<base::Value>(new base::StringValue("HIGH_RESOLUTION")); |
| 78 "HIGH_RESOLUTION")); | |
| 79 case NON_IDEAL_RESOLUTION: | 75 case NON_IDEAL_RESOLUTION: |
| 80 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 76 return scoped_ptr<base::Value>(new base::StringValue( |
| 81 "NON_IDEAL_RESOLUTION")); | 77 "NON_IDEAL_RESOLUTION")); |
| 82 } | 78 } |
| 83 DCHECK(false) << "Unrecognized TileResolution value " << resolution; | 79 DCHECK(false) << "Unrecognized TileResolution value " << resolution; |
| 84 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 80 return scoped_ptr<base::Value>(new base::StringValue( |
| 85 "<unknown TileResolution value>")); | 81 "<unknown TileResolution value>")); |
| 86 } | 82 } |
| 87 | 83 |
| 88 scoped_ptr<base::Value> TilePriority::AsValue() const { | 84 scoped_ptr<base::Value> TilePriority::AsValue() const { |
| 89 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 85 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 90 state->Set("resolution", TileResolutionAsValue(resolution).release()); | 86 state->Set("resolution", TileResolutionAsValue(resolution).release()); |
| 91 state->Set("time_to_visible_in_seconds", | 87 state->Set("time_to_visible_in_seconds", |
| 92 MathUtil::AsValueSafely(time_to_visible_in_seconds).release()); | 88 MathUtil::AsValueSafely(time_to_visible_in_seconds).release()); |
| 93 state->Set("distance_to_visible_in_pixels", | 89 state->Set("distance_to_visible_in_pixels", |
| 94 MathUtil::AsValueSafely(distance_to_visible_in_pixels).release()); | 90 MathUtil::AsValueSafely(distance_to_visible_in_pixels).release()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 IntersectNegativeHalfplane( | 127 IntersectNegativeHalfplane( |
| 132 &range, previous_bounds.bottom(), current_bounds.bottom(), | 128 &range, previous_bounds.bottom(), current_bounds.bottom(), |
| 133 target_bounds.y(), time_delta); | 129 target_bounds.y(), time_delta); |
| 134 return range.IsEmpty() ? kMaxTimeToVisibleInSeconds : range.start_; | 130 return range.IsEmpty() ? kMaxTimeToVisibleInSeconds : range.start_; |
| 135 } | 131 } |
| 136 | 132 |
| 137 scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( | 133 scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( |
| 138 TileMemoryLimitPolicy policy) { | 134 TileMemoryLimitPolicy policy) { |
| 139 switch (policy) { | 135 switch (policy) { |
| 140 case ALLOW_NOTHING: | 136 case ALLOW_NOTHING: |
| 141 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 137 return scoped_ptr<base::Value>(new base::StringValue("ALLOW_NOTHING")); |
| 142 "ALLOW_NOTHING")); | |
| 143 case ALLOW_ABSOLUTE_MINIMUM: | 138 case ALLOW_ABSOLUTE_MINIMUM: |
| 144 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 139 return scoped_ptr<base::Value>(new base::StringValue( |
| 145 "ALLOW_ABSOLUTE_MINIMUM")); | 140 "ALLOW_ABSOLUTE_MINIMUM")); |
| 146 case ALLOW_PREPAINT_ONLY: | 141 case ALLOW_PREPAINT_ONLY: |
| 147 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 142 return scoped_ptr<base::Value>(new base::StringValue( |
| 148 "ALLOW_PREPAINT_ONLY")); | 143 "ALLOW_PREPAINT_ONLY")); |
| 149 case ALLOW_ANYTHING: | 144 case ALLOW_ANYTHING: |
| 150 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 145 return scoped_ptr<base::Value>(new base::StringValue( |
| 151 "ALLOW_ANYTHING")); | 146 "ALLOW_ANYTHING")); |
| 152 default: | 147 default: |
| 153 DCHECK(false) << "Unrecognized policy value"; | 148 DCHECK(false) << "Unrecognized policy value"; |
| 154 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 149 return scoped_ptr<base::Value>(new base::StringValue( |
| 155 "<unknown>")); | 150 "<unknown>")); |
| 156 } | 151 } |
| 157 } | 152 } |
| 158 | 153 |
| 159 scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio) { | 154 scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio) { |
| 160 switch (prio) { | 155 switch (prio) { |
| 161 case SAME_PRIORITY_FOR_BOTH_TREES: | 156 case SAME_PRIORITY_FOR_BOTH_TREES: |
| 162 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 157 return scoped_ptr<base::Value>(new base::StringValue( |
| 163 "SAME_PRIORITY_FOR_BOTH_TREES")); | 158 "SAME_PRIORITY_FOR_BOTH_TREES")); |
| 164 case SMOOTHNESS_TAKES_PRIORITY: | 159 case SMOOTHNESS_TAKES_PRIORITY: |
| 165 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 160 return scoped_ptr<base::Value>(new base::StringValue( |
| 166 "SMOOTHNESS_TAKES_PRIORITY")); | 161 "SMOOTHNESS_TAKES_PRIORITY")); |
| 167 case NEW_CONTENT_TAKES_PRIORITY: | 162 case NEW_CONTENT_TAKES_PRIORITY: |
| 168 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 163 return scoped_ptr<base::Value>(new base::StringValue( |
| 169 "NEW_CONTENT_TAKES_PRIORITY")); | 164 "NEW_CONTENT_TAKES_PRIORITY")); |
| 170 } | 165 } |
| 171 DCHECK(false) << "Unrecognized priority value " << prio; | 166 DCHECK(false) << "Unrecognized priority value " << prio; |
| 172 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 167 return scoped_ptr<base::Value>(new base::StringValue( |
| 173 "<unknown>")); | 168 "<unknown>")); |
| 174 } | 169 } |
| 175 | 170 |
| 176 scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const { | 171 scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const { |
| 177 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 172 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 178 state->Set("memory_limit_policy", | 173 state->Set("memory_limit_policy", |
| 179 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); | 174 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); |
| 180 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); | 175 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); |
| 181 state->SetInteger("unused_memory_limit_in_bytes", | 176 state->SetInteger("unused_memory_limit_in_bytes", |
| 182 unused_memory_limit_in_bytes); | 177 unused_memory_limit_in_bytes); |
| 183 state->SetInteger("num_resources_limit", num_resources_limit); | 178 state->SetInteger("num_resources_limit", num_resources_limit); |
| 184 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); | 179 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); |
| 185 return state.PassAs<base::Value>(); | 180 return state.PassAs<base::Value>(); |
| 186 } | 181 } |
| 187 | 182 |
| 188 } // namespace cc | 183 } // namespace cc |
| OLD | NEW |