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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 "HIGH_RESOLUTION")); | 78 "HIGH_RESOLUTION")); |
79 case NON_IDEAL_RESOLUTION: | 79 case NON_IDEAL_RESOLUTION: |
80 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 80 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
81 "NON_IDEAL_RESOLUTION")); | 81 "NON_IDEAL_RESOLUTION")); |
82 } | 82 } |
83 DCHECK(false) << "Unrecognized TileResolution value " << resolution; | 83 DCHECK(false) << "Unrecognized TileResolution value " << resolution; |
84 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 84 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
85 "<unknown TileResolution value>")); | 85 "<unknown TileResolution value>")); |
86 } | 86 } |
87 | 87 |
88 scoped_ptr<base::Value> TilePriorityBinAsValue(TilePriority::PriorityBin bin) { | |
89 switch (bin) { | |
90 case TilePriority::NOW: | |
91 return scoped_ptr<base::Value>(base::Value::CreateStringValue("NOW")); | |
92 case TilePriority::SOON: | |
93 return scoped_ptr<base::Value>(base::Value::CreateStringValue("SOON")); | |
94 case TilePriority::EVENTUALLY: | |
95 return scoped_ptr<base::Value>( | |
96 base::Value::CreateStringValue("EVENTUALLY")); | |
97 } | |
98 DCHECK(false) << "Unrecognized TilePriority::PriorityBin value " << bin; | |
99 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | |
100 "<unknown TilePriority::PriorityBin value>")); | |
101 } | |
102 | |
88 scoped_ptr<base::Value> TilePriority::AsValue() const { | 103 scoped_ptr<base::Value> TilePriority::AsValue() const { |
89 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 104 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
90 state->Set("resolution", TileResolutionAsValue(resolution).release()); | 105 state->Set("resolution", TileResolutionAsValue(resolution).release()); |
91 state->Set("time_to_visible_in_seconds", | 106 state->Set("priority_bin", TilePriorityBinAsValue(priority_bin).release()); |
vmpstr
2014/01/31 20:53:38
This will also require some traceviewer changes...
enne (OOO)
2014/01/31 23:07:46
Do you know if TraceViewer will break in the short
vmpstr
2014/02/03 20:27:24
A bit of both. It will "break" in the sense that s
| |
92 MathUtil::AsValueSafely(time_to_visible_in_seconds).release()); | 107 state->Set("distance_to_visible", |
93 state->Set("distance_to_visible_in_pixels", | 108 MathUtil::AsValueSafely(distance_to_visible).release()); |
94 MathUtil::AsValueSafely(distance_to_visible_in_pixels).release()); | |
95 return state.PassAs<base::Value>(); | 109 return state.PassAs<base::Value>(); |
96 } | 110 } |
97 | 111 |
98 float TilePriority::TimeForBoundsToIntersect(const gfx::RectF& previous_bounds, | |
99 const gfx::RectF& current_bounds, | |
100 float time_delta, | |
101 const gfx::RectF& target_bounds) { | |
102 // Perform an intersection test explicitly between current and target. | |
103 if (current_bounds.x() < target_bounds.right() && | |
104 current_bounds.y() < target_bounds.bottom() && | |
105 target_bounds.x() < current_bounds.right() && | |
106 target_bounds.y() < current_bounds.bottom()) | |
107 return 0.0f; | |
108 | |
109 const float kMaxTimeToVisibleInSeconds = | |
110 std::numeric_limits<float>::infinity(); | |
111 | |
112 if (time_delta == 0.0f) | |
113 return kMaxTimeToVisibleInSeconds; | |
114 | |
115 // As we are trying to solve the case of both scaling and scrolling, using | |
116 // a single coordinate with velocity is not enough. The logic here is to | |
117 // calculate the velocity for each edge. Then we calculate the time range that | |
118 // each edge will stay on the same side of the target bounds. If there is an | |
119 // overlap between these time ranges, the bounds must have intersect with | |
120 // each other during that period of time. | |
121 Range range(0.0f, kMaxTimeToVisibleInSeconds); | |
122 IntersectPositiveHalfplane( | |
123 &range, previous_bounds.x(), current_bounds.x(), | |
124 target_bounds.right(), time_delta); | |
125 IntersectNegativeHalfplane( | |
126 &range, previous_bounds.right(), current_bounds.right(), | |
127 target_bounds.x(), time_delta); | |
128 IntersectPositiveHalfplane( | |
129 &range, previous_bounds.y(), current_bounds.y(), | |
130 target_bounds.bottom(), time_delta); | |
131 IntersectNegativeHalfplane( | |
132 &range, previous_bounds.bottom(), current_bounds.bottom(), | |
133 target_bounds.y(), time_delta); | |
134 return range.IsEmpty() ? kMaxTimeToVisibleInSeconds : range.start_; | |
135 } | |
136 | |
137 scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( | 112 scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( |
138 TileMemoryLimitPolicy policy) { | 113 TileMemoryLimitPolicy policy) { |
139 switch (policy) { | 114 switch (policy) { |
140 case ALLOW_NOTHING: | 115 case ALLOW_NOTHING: |
141 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 116 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
142 "ALLOW_NOTHING")); | 117 "ALLOW_NOTHING")); |
143 case ALLOW_ABSOLUTE_MINIMUM: | 118 case ALLOW_ABSOLUTE_MINIMUM: |
144 return scoped_ptr<base::Value>(base::Value::CreateStringValue( | 119 return scoped_ptr<base::Value>(base::Value::CreateStringValue( |
145 "ALLOW_ABSOLUTE_MINIMUM")); | 120 "ALLOW_ABSOLUTE_MINIMUM")); |
146 case ALLOW_PREPAINT_ONLY: | 121 case ALLOW_PREPAINT_ONLY: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); | 154 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); |
180 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); | 155 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); |
181 state->SetInteger("unused_memory_limit_in_bytes", | 156 state->SetInteger("unused_memory_limit_in_bytes", |
182 unused_memory_limit_in_bytes); | 157 unused_memory_limit_in_bytes); |
183 state->SetInteger("num_resources_limit", num_resources_limit); | 158 state->SetInteger("num_resources_limit", num_resources_limit); |
184 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); | 159 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); |
185 return state.PassAs<base::Value>(); | 160 return state.PassAs<base::Value>(); |
186 } | 161 } |
187 | 162 |
188 } // namespace cc | 163 } // namespace cc |
OLD | NEW |