| 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/tile_priority.h" | 5 #include "cc/tile_priority.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "cc/math_util.h" |
| 8 | 9 |
| 9 namespace { | 10 namespace { |
| 10 | 11 |
| 11 // TODO(qinmin): modify ui/range/Range.h to support template so that we | 12 // TODO(qinmin): modify ui/range/Range.h to support template so that we |
| 12 // don't need to define this. | 13 // don't need to define this. |
| 13 struct Range { | 14 struct Range { |
| 14 Range(float start, float end) : start_(start), end_(end) {} | 15 Range(float start, float end) : start_(start), end_(end) {} |
| 15 bool IsEmpty(); | 16 bool IsEmpty(); |
| 16 float start_; | 17 float start_; |
| 17 float end_; | 18 float end_; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 case PENDING_TREE: | 64 case PENDING_TREE: |
| 64 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 65 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 65 "PENDING_TREE")); | 66 "PENDING_TREE")); |
| 66 default: | 67 default: |
| 67 DCHECK(false) << "Unrecognized WhichTree value"; | 68 DCHECK(false) << "Unrecognized WhichTree value"; |
| 68 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 69 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 69 "<unknown WhichTree value>")); | 70 "<unknown WhichTree value>")); |
| 70 } | 71 } |
| 71 } | 72 } |
| 72 | 73 |
| 74 scoped_ptr<base::Value> TileResolutionAsValue( |
| 75 TileResolution resolution) { |
| 76 switch (resolution) { |
| 77 case LOW_RESOLUTION: |
| 78 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 79 "LOW_RESOLUTION")); |
| 80 case HIGH_RESOLUTION: |
| 81 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 82 "HIGH_RESOLUTION")); |
| 83 default: |
| 84 DCHECK(false) << "Unrecognized TileResolution value"; |
| 85 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
| 86 "<unknown TileResolution value>")); |
| 87 } |
| 88 } |
| 89 |
| 90 scoped_ptr<base::Value> TilePriority::AsValue() const { |
| 91 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 92 state->SetBoolean("is_live", is_live); |
| 93 state->Set("resolution", TileResolutionAsValue(resolution).release()); |
| 94 state->SetDouble("time_to_visible_in_seconds", time_to_visible_in_seconds); |
| 95 state->SetDouble("distance_to_visible_in_pixels", distance_to_visible_in_pixel
s); |
| 96 state->Set("current_screen_quad", MathUtil::asValue(current_screen_quad).relea
se()); |
| 97 return state.PassAs<base::Value>(); |
| 98 } |
| 73 | 99 |
| 74 float TilePriority::TimeForBoundsToIntersect(const gfx::RectF& previous_bounds, | 100 float TilePriority::TimeForBoundsToIntersect(const gfx::RectF& previous_bounds, |
| 75 const gfx::RectF& current_bounds, | 101 const gfx::RectF& current_bounds, |
| 76 float time_delta, | 102 float time_delta, |
| 77 const gfx::RectF& target_bounds) { | 103 const gfx::RectF& target_bounds) { |
| 78 // Perform an intersection test explicitly between current and target. | 104 // Perform an intersection test explicitly between current and target. |
| 79 if (current_bounds.x() < target_bounds.right() && | 105 if (current_bounds.x() < target_bounds.right() && |
| 80 current_bounds.y() < target_bounds.bottom() && | 106 current_bounds.y() < target_bounds.bottom() && |
| 81 target_bounds.x() < current_bounds.right() && | 107 target_bounds.x() < current_bounds.right() && |
| 82 target_bounds.y() < current_bounds.bottom()) | 108 target_bounds.y() < current_bounds.bottom()) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const { | 179 scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const { |
| 154 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 180 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 155 state->Set("memory_limit_policy", TileMemoryLimitPolicyAsValue(memory_limit_po
licy).release()); | 181 state->Set("memory_limit_policy", TileMemoryLimitPolicyAsValue(memory_limit_po
licy).release()); |
| 156 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); | 182 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); |
| 157 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); | 183 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); |
| 158 return state.PassAs<base::Value>(); | 184 return state.PassAs<base::Value>(); |
| 159 } | 185 } |
| 160 | 186 |
| 161 | 187 |
| 162 } // namespace cc | 188 } // namespace cc |
| OLD | NEW |