Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: cc/resources/tile_priority.cc

Issue 13051003: cpplint.py pass on cc/(base|debug|quads|resources)/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix prioritized_resource_unittest Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/resources/tile_priority.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 } 23 }
24 24
25 inline Range Intersect(const Range& a, const Range& b) { 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_)); 26 return Range(std::max(a.start_, b.start_), std::min(a.end_, b.end_));
27 } 27 }
28 28
29 bool Range::IsEmpty() { 29 bool Range::IsEmpty() {
30 return start_ >= end_; 30 return start_ >= end_;
31 } 31 }
32 32
33 inline void IntersectNegativeHalfplane(Range& out, float previous, 33 inline void IntersectNegativeHalfplane(Range* out, float previous,
34 float current, float target, float time_delta) { 34 float current, float target, float time_delta) {
35 float time_per_dist = time_delta / (current - previous); 35 float time_per_dist = time_delta / (current - previous);
36 float t = (target - current) * time_per_dist; 36 float t = (target - current) * time_per_dist;
37 if (time_per_dist > 0.0f) 37 if (time_per_dist > 0.0f)
38 out.start_ = std::max(out.start_, t); 38 out->start_ = std::max(out->start_, t);
39 else 39 else
40 out.end_ = std::min(out.end_, t); 40 out->end_ = std::min(out->end_, t);
41 } 41 }
42 42
43 inline void IntersectPositiveHalfplane(Range& out, float previous, 43 inline void IntersectPositiveHalfplane(Range* out, float previous,
44 float current, float target, float time_delta) { 44 float current, float target, float time_delta) {
45 float time_per_dist = time_delta / (current - previous); 45 float time_per_dist = time_delta / (current - previous);
46 float t = (target - current) * time_per_dist; 46 float t = (target - current) * time_per_dist;
47 if (time_per_dist < 0.0f) 47 if (time_per_dist < 0.0f)
48 out.start_ = std::max(out.start_, t); 48 out->start_ = std::max(out->start_, t);
49 else 49 else
50 out.end_ = std::min(out.end_, t); 50 out->end_ = std::min(out->end_, t);
51 } 51 }
52 52
53 } // namespace 53 } // namespace
54 54
55 namespace cc { 55 namespace cc {
56 56
57 const float TilePriority::kMaxDistanceInContentSpace = 4096.0f; 57 const float TilePriority::kMaxDistanceInContentSpace = 4096.0f;
58 58
59 // At 256x256 tiles, 128 tiles cover an area of 2048x4096 pixels. 59 // At 256x256 tiles, 128 tiles cover an area of 2048x4096 pixels.
60 const int64 TilePriority:: 60 const int64 TilePriority::
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return kMaxTimeToVisibleInSeconds; 125 return kMaxTimeToVisibleInSeconds;
126 126
127 // As we are trying to solve the case of both scaling and scrolling, using 127 // As we are trying to solve the case of both scaling and scrolling, using
128 // a single coordinate with velocity is not enough. The logic here is to 128 // a single coordinate with velocity is not enough. The logic here is to
129 // calculate the velocity for each edge. Then we calculate the time range that 129 // calculate the velocity for each edge. Then we calculate the time range that
130 // each edge will stay on the same side of the target bounds. If there is an 130 // each edge will stay on the same side of the target bounds. If there is an
131 // overlap between these time ranges, the bounds must have intersect with 131 // overlap between these time ranges, the bounds must have intersect with
132 // each other during that period of time. 132 // each other during that period of time.
133 Range range(0.0f, kMaxTimeToVisibleInSeconds); 133 Range range(0.0f, kMaxTimeToVisibleInSeconds);
134 IntersectPositiveHalfplane( 134 IntersectPositiveHalfplane(
135 range, previous_bounds.x(), current_bounds.x(), 135 &range, previous_bounds.x(), current_bounds.x(),
136 target_bounds.right(), time_delta); 136 target_bounds.right(), time_delta);
137 IntersectNegativeHalfplane( 137 IntersectNegativeHalfplane(
138 range, previous_bounds.right(), current_bounds.right(), 138 &range, previous_bounds.right(), current_bounds.right(),
139 target_bounds.x(), time_delta); 139 target_bounds.x(), time_delta);
140 IntersectPositiveHalfplane( 140 IntersectPositiveHalfplane(
141 range, previous_bounds.y(), current_bounds.y(), 141 &range, previous_bounds.y(), current_bounds.y(),
142 target_bounds.bottom(), time_delta); 142 target_bounds.bottom(), time_delta);
143 IntersectNegativeHalfplane( 143 IntersectNegativeHalfplane(
144 range, previous_bounds.bottom(), current_bounds.bottom(), 144 &range, previous_bounds.bottom(), current_bounds.bottom(),
145 target_bounds.y(), time_delta); 145 target_bounds.y(), time_delta);
146 return range.IsEmpty() ? kMaxTimeToVisibleInSeconds : range.start_; 146 return range.IsEmpty() ? kMaxTimeToVisibleInSeconds : range.start_;
147 } 147 }
148 148
149 scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( 149 scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue(
150 TileMemoryLimitPolicy policy) { 150 TileMemoryLimitPolicy policy) {
151 switch (policy) { 151 switch (policy) {
152 case ALLOW_NOTHING: 152 case ALLOW_NOTHING:
153 return scoped_ptr<base::Value>(base::Value::CreateStringValue( 153 return scoped_ptr<base::Value>(base::Value::CreateStringValue(
154 "ALLOW_NOTHING")); 154 "ALLOW_NOTHING"));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const { 189 scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const {
190 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 190 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
191 state->Set("memory_limit_policy", 191 state->Set("memory_limit_policy",
192 TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); 192 TileMemoryLimitPolicyAsValue(memory_limit_policy).release());
193 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes); 193 state->SetInteger("memory_limit_in_bytes", memory_limit_in_bytes);
194 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); 194 state->Set("tree_priority", TreePriorityAsValue(tree_priority).release());
195 return state.PassAs<base::Value>(); 195 return state.PassAs<base::Value>();
196 } 196 }
197 197
198 } // namespace cc 198 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_priority.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698