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 { |
11 | 11 |
12 // 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 |
13 // don't need to define this. | 13 // don't need to define this. |
14 struct Range { | 14 struct Range { |
15 Range(float start, float end) : start_(start), end_(end) {} | 15 Range(float start, float end) : start_(start), end_(end) {} |
16 bool IsEmpty(); | 16 bool IsEmpty(); |
17 float start_; | 17 float start_; |
18 float end_; | 18 float end_; |
19 }; | 19 }; |
20 | 20 |
21 inline bool Intersects(const Range& a, const Range& b) { | |
22 return a.start_ < b.end_ && b.start_ < a.end_; | |
23 } | |
24 | |
25 inline Range Intersect(const Range& a, const Range& b) { | |
26 return Range(std::max(a.start_, b.start_), std::min(a.end_, b.end_)); | |
27 } | |
28 | |
29 bool Range::IsEmpty() { | 21 bool Range::IsEmpty() { |
30 return start_ >= end_; | 22 return start_ >= end_; |
31 } | 23 } |
32 | 24 |
33 inline void IntersectNegativeHalfplane(Range* out, | 25 inline void IntersectNegativeHalfplane(Range* out, |
34 float previous, | 26 float previous, |
35 float current, | 27 float current, |
36 float target, | 28 float target, |
37 float time_delta) { | 29 float time_delta) { |
38 float time_per_dist = time_delta / (current - previous); | 30 float time_per_dist = time_delta / (current - previous); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); | 179 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); |
188 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); | 180 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); |
189 state->SetInteger("unused_memory_limit_in_bytes", | 181 state->SetInteger("unused_memory_limit_in_bytes", |
190 unused_memory_limit_in_bytes); | 182 unused_memory_limit_in_bytes); |
191 state->SetInteger("num_resources_limit", num_resources_limit); | 183 state->SetInteger("num_resources_limit", num_resources_limit); |
192 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); | 184 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); |
193 return state.PassAs<base::Value>(); | 185 return state.PassAs<base::Value>(); |
194 } | 186 } |
195 | 187 |
196 } // namespace cc | 188 } // namespace cc |
OLD | NEW |