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

Side by Side Diff: cc/picture_layer_impl.cc

Issue 11704002: cc: Generate tilings at other scales for impl-side painting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Create tilings during pinch Created 7 years, 11 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
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/picture_layer_impl.h" 5 #include "cc/picture_layer_impl.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "cc/append_quads_data.h" 8 #include "cc/append_quads_data.h"
9 #include "cc/checkerboard_draw_quad.h" 9 #include "cc/checkerboard_draw_quad.h"
10 #include "cc/debug_border_draw_quad.h" 10 #include "cc/debug_border_draw_quad.h"
11 #include "cc/debug_colors.h" 11 #include "cc/debug_colors.h"
12 #include "cc/layer_tree_impl.h" 12 #include "cc/layer_tree_impl.h"
13 #include "cc/math_util.h" 13 #include "cc/math_util.h"
14 #include "cc/quad_sink.h" 14 #include "cc/quad_sink.h"
15 #include "cc/solid_color_draw_quad.h" 15 #include "cc/solid_color_draw_quad.h"
16 #include "cc/tile_draw_quad.h" 16 #include "cc/tile_draw_quad.h"
17 #include "ui/gfx/quad_f.h" 17 #include "ui/gfx/quad_f.h"
18 #include "ui/gfx/size_conversions.h" 18 #include "ui/gfx/size_conversions.h"
19 19
20 namespace {
21 const float kMaxScaleRatioDuringPinch = 2.0f;
22 }
23
20 namespace cc { 24 namespace cc {
21 25
22 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* treeImpl, int id) 26 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* treeImpl, int id)
23 : LayerImpl(treeImpl, id), 27 : LayerImpl(treeImpl, id),
24 tilings_(this), 28 tilings_(this),
25 pile_(PicturePileImpl::Create()), 29 pile_(PicturePileImpl::Create()),
26 last_update_time_(0), 30 last_update_time_(0),
31 last_content_scale_(0),
32 ideal_contents_scale_(0),
27 is_mask_(false) { 33 is_mask_(false) {
28 } 34 }
29 35
30 PictureLayerImpl::~PictureLayerImpl() { 36 PictureLayerImpl::~PictureLayerImpl() {
31 } 37 }
32 38
33 const char* PictureLayerImpl::layerTypeAsString() const { 39 const char* PictureLayerImpl::layerTypeAsString() const {
34 return "PictureLayer"; 40 return "PictureLayer";
35 } 41 }
36 42
37 void PictureLayerImpl::appendQuads(QuadSink& quadSink, 43 void PictureLayerImpl::appendQuads(QuadSink& quadSink,
38 AppendQuadsData& appendQuadsData) { 44 AppendQuadsData& appendQuadsData) {
39 45
40 const gfx::Rect& rect = visibleContentRect(); 46 const gfx::Rect& rect = visibleContentRect();
41 gfx::Rect content_rect(gfx::Point(), contentBounds()); 47 gfx::Rect content_rect(gfx::Point(), contentBounds());
42 48
43 SharedQuadState* sharedQuadState = 49 SharedQuadState* sharedQuadState =
44 quadSink.useSharedQuadState(createSharedQuadState()); 50 quadSink.useSharedQuadState(createSharedQuadState());
45 bool clipped = false; 51 bool clipped = false;
46 gfx::QuadF target_quad = MathUtil::mapQuad( 52 gfx::QuadF target_quad = MathUtil::mapQuad(
47 drawTransform(), 53 drawTransform(),
48 gfx::QuadF(rect), 54 gfx::QuadF(rect),
49 clipped); 55 clipped);
50 bool isAxisAlignedInTarget = !clipped && target_quad.IsRectilinear(); 56 bool isAxisAlignedInTarget = !clipped && target_quad.IsRectilinear();
51 bool useAA = !isAxisAlignedInTarget; 57 bool useAA = !isAxisAlignedInTarget;
52 58
53 if (showDebugBorders()) { 59 if (showDebugBorders()) {
54 for (PictureLayerTilingSet::Iterator iter(&tilings_, 60 for (PictureLayerTilingSet::Iterator iter(&tilings_,
55 contentsScaleX(), 61 contentsScaleX(),
56 rect); 62 rect,
63 ideal_contents_scale_);
57 iter; 64 iter;
58 ++iter) { 65 ++iter) {
59 SkColor color; 66 SkColor color;
60 float width; 67 float width;
61 if (*iter && iter->GetResourceId()) { 68 if (*iter && iter->GetResourceId()) {
62 color = DebugColors::TileBorderColor(); 69 color = DebugColors::TileBorderColor();
63 width = DebugColors::TileBorderWidth(layerTreeImpl()); 70 width = DebugColors::TileBorderWidth(layerTreeImpl());
64 } else { 71 } else {
65 color = DebugColors::MissingTileBorderColor(); 72 color = DebugColors::MissingTileBorderColor();
66 width = DebugColors::MissingTileBorderWidth(layerTreeImpl()); 73 width = DebugColors::MissingTileBorderWidth(layerTreeImpl());
67 } 74 }
68 75
69 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = 76 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad =
70 DebugBorderDrawQuad::Create(); 77 DebugBorderDrawQuad::Create();
71 gfx::Rect geometry_rect = iter.geometry_rect(); 78 gfx::Rect geometry_rect = iter.geometry_rect();
72 debugBorderQuad->SetNew(sharedQuadState, geometry_rect, color, width); 79 debugBorderQuad->SetNew(sharedQuadState, geometry_rect, color, width);
73 quadSink.append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData); 80 quadSink.append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData);
74 } 81 }
75 } 82 }
76 83
77 for (PictureLayerTilingSet::Iterator iter(&tilings_, contentsScaleX(), rect); 84 // Keep track of the tilings that were used so that tilings that are
85 // unused can be considered for removal.
86 std::vector<PictureLayerTiling*> seen_tilings;
87
88 for (PictureLayerTilingSet::Iterator iter(&tilings_,
89 contentsScaleX(),
90 rect,
91 ideal_contents_scale_);
78 iter; 92 iter;
79 ++iter) { 93 ++iter) {
80 ResourceProvider::ResourceId resource = 0; 94 ResourceProvider::ResourceId resource = 0;
81 if (*iter) 95 if (*iter)
82 resource = iter->GetResourceId(); 96 resource = iter->GetResourceId();
83 97
84 gfx::Rect geometry_rect = iter.geometry_rect(); 98 gfx::Rect geometry_rect = iter.geometry_rect();
85 99
86 if (!resource) { 100 if (!resource) {
87 if (drawCheckerboardForMissingTiles()) { 101 if (drawCheckerboardForMissingTiles()) {
(...skipping 27 matching lines...) Expand all
115 opaque_rect, 129 opaque_rect,
116 resource, 130 resource,
117 texture_rect, 131 texture_rect,
118 iter.texture_size(), 132 iter.texture_size(),
119 iter->contents_swizzled(), 133 iter->contents_swizzled(),
120 outside_left_edge && useAA, 134 outside_left_edge && useAA,
121 outside_top_edge && useAA, 135 outside_top_edge && useAA,
122 outside_right_edge && useAA, 136 outside_right_edge && useAA,
123 outside_bottom_edge && useAA); 137 outside_bottom_edge && useAA);
124 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); 138 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData);
139
140 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling())
141 seen_tilings.push_back(iter.CurrentTiling());
125 } 142 }
143
144 // During a pinch, a user could zoom in and out, so throwing away a tiling may
145 // be premature.
146 if (!layerTreeImpl()->PinchGestureActive())
147 CleanUpUnusedTilings(seen_tilings);
danakj 2013/01/07 22:35:56 any reason why this isn't a didDraw() thing? it's
enne (OOO) 2013/01/08 01:08:00 didDraw isn't called before swap, just FYI.
danakj 2013/01/08 23:27:16 I guess you mean "is". Doh..
126 } 148 }
127 149
128 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const { 150 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const {
129 // TODO(enne): implement me 151 // TODO(enne): implement me
130 } 152 }
131 153
132 void PictureLayerImpl::didUpdateTransforms() { 154 void PictureLayerImpl::didUpdateTransforms() {
133 gfx::Transform current_screen_space_transform = 155 gfx::Transform current_screen_space_transform =
134 screenSpaceTransform(); 156 screenSpaceTransform();
135 double current_time = 157 double current_time =
136 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); 158 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
137 double time_delta = 0; 159 double time_delta = 0;
138 if (last_update_time_ != 0 && last_bounds_ == bounds() && 160 if (last_update_time_ != 0 && last_bounds_ == bounds() &&
139 last_content_bounds_ == contentBounds() && 161 last_content_bounds_ == contentBounds() &&
140 last_content_scale_x_ == contentsScaleX() && 162 last_content_scale_ == contentsScaleX()) {
141 last_content_scale_y_ == contentsScaleY()) {
142 time_delta = current_time - last_update_time_; 163 time_delta = current_time - last_update_time_;
143 } 164 }
144 WhichTree tree = layerTreeImpl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; 165 WhichTree tree = layerTreeImpl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE;
145 tilings_.UpdateTilePriorities( 166 tilings_.UpdateTilePriorities(
146 tree, 167 tree,
147 layerTreeImpl()->device_viewport_size(), 168 layerTreeImpl()->device_viewport_size(),
169 last_content_scale_,
148 contentsScaleX(), 170 contentsScaleX(),
149 contentsScaleY(),
150 last_screen_space_transform_, 171 last_screen_space_transform_,
151 current_screen_space_transform, 172 current_screen_space_transform,
152 time_delta); 173 time_delta);
153 174
154 last_screen_space_transform_ = current_screen_space_transform; 175 last_screen_space_transform_ = current_screen_space_transform;
155 last_update_time_ = current_time; 176 last_update_time_ = current_time;
156 last_bounds_ = bounds(); 177 last_bounds_ = bounds();
157 last_content_bounds_ = contentBounds(); 178 last_content_bounds_ = contentBounds();
158 last_content_scale_x_ = contentsScaleX(); 179 last_content_scale_ = contentsScaleX();
159 last_content_scale_y_ = contentsScaleY();
160 } 180 }
161 181
162 void PictureLayerImpl::calculateContentsScale( 182 void PictureLayerImpl::calculateContentsScale(
163 float ideal_contents_scale, 183 float ideal_contents_scale,
164 float* contents_scale_x, 184 float* contents_scale_x,
165 float* contents_scale_y, 185 float* contents_scale_y,
166 gfx::Size* content_bounds) { 186 gfx::Size* content_bounds) {
167 if (!drawsContent()) { 187 if (!drawsContent()) {
168 DCHECK(!tilings_.num_tilings()); 188 DCHECK(!tilings_.num_tilings());
169 return; 189 return;
170 } 190 }
171 191
172 float min_contents_scale = layerTreeImpl()->settings().minimumContentsScale; 192 float min_contents_scale = layerTreeImpl()->settings().minimumContentsScale;
173 ideal_contents_scale = std::max(ideal_contents_scale, min_contents_scale); 193 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale);
174 194
175 ManageTilings(ideal_contents_scale); 195 ManageTilings(ideal_contents_scale_);
176 196
177 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. 197 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious.
178 // There are (usually) several tilings at different scales. However, the 198 // There are (usually) several tilings at different scales. However, the
179 // content bounds is the (integer!) space in which quads are generated. 199 // content bounds is the (integer!) space in which quads are generated.
180 // In order to guarantee that we can fill this integer space with any set of 200 // In order to guarantee that we can fill this integer space with any set of
181 // tilings (and then map back to floating point texture coordinates), the 201 // tilings (and then map back to floating point texture coordinates), the
182 // contents scale must be at least as large as the largest of the tilings. 202 // contents scale must be at least as large as the largest of the tilings.
183 float max_contents_scale = min_contents_scale; 203 float max_contents_scale = min_contents_scale;
184 for (size_t i = 0; i < tilings_.num_tilings(); ++i) { 204 for (size_t i = 0; i < tilings_.num_tilings(); ++i) {
185 const PictureLayerTiling* tiling = tilings_.tiling_at(i); 205 const PictureLayerTiling* tiling = tilings_.tiling_at(i);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 void PictureLayerImpl::SetIsMask(bool is_mask) { 252 void PictureLayerImpl::SetIsMask(bool is_mask) {
233 if (is_mask_ == is_mask) 253 if (is_mask_ == is_mask)
234 return; 254 return;
235 is_mask_ = is_mask; 255 is_mask_ = is_mask;
236 tilings_.Reset(); 256 tilings_.Reset();
237 } 257 }
238 258
239 ResourceProvider::ResourceId PictureLayerImpl::contentsResourceId() const { 259 ResourceProvider::ResourceId PictureLayerImpl::contentsResourceId() const {
240 gfx::Rect content_rect(gfx::Point(), contentBounds()); 260 gfx::Rect content_rect(gfx::Point(), contentBounds());
241 float scale = contentsScaleX(); 261 float scale = contentsScaleX();
242 for (PictureLayerTilingSet::Iterator iter(&tilings_, scale, content_rect); 262 for (PictureLayerTilingSet::Iterator iter(&tilings_,
263 scale,
264 content_rect,
265 ideal_contents_scale_);
243 iter; 266 iter;
244 ++iter) { 267 ++iter) {
245 // Mask resource not ready yet. 268 // Mask resource not ready yet.
246 if (!*iter || !iter->GetResourceId()) 269 if (!*iter || !iter->GetResourceId())
247 return 0; 270 return 0;
248 // Masks only supported if they fit on exactly one tile. 271 // Masks only supported if they fit on exactly one tile.
249 if (iter.geometry_rect() != content_rect) 272 if (iter.geometry_rect() != content_rect)
250 return 0; 273 return 0;
251 return iter->GetResourceId(); 274 return iter->GetResourceId();
252 } 275 }
253 return 0; 276 return 0;
254 } 277 }
255 278
256 void PictureLayerImpl::AddTiling(float contents_scale, gfx::Size tile_size) { 279 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {
257 if (contents_scale < layerTreeImpl()->settings().minimumContentsScale) 280 if (contents_scale < layerTreeImpl()->settings().minimumContentsScale)
258 return; 281 return NULL;
259 282
260 const PictureLayerTiling* tiling = tilings_.AddTiling( 283 PictureLayerTiling* tiling = tilings_.AddTiling(
261 contents_scale, 284 contents_scale,
262 tile_size); 285 TileSize());
263 286
264 // If a new tiling is created on the active tree, sync it to the pending tree 287 // If a new tiling is created on the active tree, sync it to the pending tree
265 // so that it can share the same tiles. 288 // so that it can share the same tiles.
266 if (layerTreeImpl()->IsPendingTree()) 289 if (layerTreeImpl()->IsPendingTree())
267 return; 290 return tiling;
268 291
269 PictureLayerImpl* pending_twin = static_cast<PictureLayerImpl*>( 292 PictureLayerImpl* pending_twin = static_cast<PictureLayerImpl*>(
270 layerTreeImpl()->FindPendingTreeLayerById(id())); 293 layerTreeImpl()->FindPendingTreeLayerById(id()));
271 if (!pending_twin) 294 if (!pending_twin)
272 return; 295 return tiling;
273 DCHECK_EQ(id(), pending_twin->id()); 296 DCHECK_EQ(id(), pending_twin->id());
274 pending_twin->SyncTiling(tiling); 297 pending_twin->SyncTiling(tiling);
298 return tiling;
275 } 299 }
276 300
277 gfx::Size PictureLayerImpl::TileSize() const { 301 gfx::Size PictureLayerImpl::TileSize() const {
278 if (is_mask_) { 302 if (is_mask_) {
279 int max_size = layerTreeImpl()->MaxTextureSize(); 303 int max_size = layerTreeImpl()->MaxTextureSize();
280 return gfx::Size( 304 return gfx::Size(
281 std::min(max_size, contentBounds().width()), 305 std::min(max_size, contentBounds().width()),
282 std::min(max_size, contentBounds().height())); 306 std::min(max_size, contentBounds().height()));
283 } 307 }
284 308
285 return layerTreeImpl()->settings().defaultTileSize; 309 return layerTreeImpl()->settings().defaultTileSize;
286 } 310 }
287 311
312 namespace {
313
314 inline float PositiveRatio(float float1, float float2) {
315 DCHECK(float1 > 0);
316 DCHECK(float2 > 0);
317 return float1 > float2 ? float1 / float2 : float2 / float1;
318 }
319
320 inline bool IsCloserToThan(
321 PictureLayerTiling* layer1,
322 PictureLayerTiling* layer2,
323 float contents_scale) {
324 // Absolute value for ratios.
325 float ratio1 = PositiveRatio(layer1->contents_scale(), contents_scale);
326 float ratio2 = PositiveRatio(layer2->contents_scale(), contents_scale);
327 return ratio1 < ratio2;
328 }
329
330 } // namespace
331
288 void PictureLayerImpl::ManageTilings(float ideal_contents_scale) { 332 void PictureLayerImpl::ManageTilings(float ideal_contents_scale) {
289 if (drawsContent()) { 333 DCHECK(ideal_contents_scale);
290 // TODO(enne): Add tilings during pinch zoom 334 float low_res_factor = layerTreeImpl()->settings().lowResContentsScaleFactor;
291 // TODO(enne): Consider culling old tilings after pinch finishes. 335 float low_res_contents_scale = ideal_contents_scale * low_res_factor;
292 if (!tilings_.num_tilings()) { 336
293 AddTiling(ideal_contents_scale, TileSize()); 337 // Find existing tilings closest to ideal high / low res
294 // TODO(enne): Add a low-res tiling as well. 338 PictureLayerTiling* high_res = NULL;
339 PictureLayerTiling* low_res = NULL;
340
341 if (layerTreeImpl()->IsPendingTree() &&
danakj 2013/01/07 22:35:56 maybe a temp bool var here for this if()? then the
enne (OOO) 2013/01/08 01:08:00 Why the temp bool? It doesn't get reused anywhere.
danakj 2013/01/08 23:27:16 I thought maybe giving a name to the combined stat
342 !layerTreeImpl()->PinchGestureActive()) {
343 // Remove any tilings that don't exactly match the contents scale.
344 std::vector<PictureLayerTiling*> remove_list;
345 for (size_t i = 0; i < tilings_.num_tilings(); ++i) {
346 PictureLayerTiling* tiling = tilings_.tiling_at(i);
347 if (tiling->contents_scale() == ideal_contents_scale)
348 high_res = tiling;
349 else if (tiling->contents_scale() == low_res_contents_scale)
350 low_res = tiling;
351 else
352 remove_list.push_back(tiling);
295 } 353 }
354
355 for (size_t i = 0; i < remove_list.size(); ++i)
356 tilings_.Remove(remove_list[i]);
296 } else { 357 } else {
297 // TODO(enne): This should be unnecessary once there are two trees. 358 for (size_t i = 0; i < tilings_.num_tilings(); ++i) {
298 tilings_.Reset(); 359 PictureLayerTiling* tiling = tilings_.tiling_at(i);
360 if (!high_res || IsCloserToThan(tiling, high_res, ideal_contents_scale))
361 high_res = tiling;
362 if (!low_res || IsCloserToThan(tiling, low_res, low_res_contents_scale))
363 low_res = tiling;
364
365 // Set everything to non-ideal to start.
366 tiling->set_resolution(NON_IDEAL_RESOLUTION);
danakj 2013/01/07 22:35:56 should this be outside the else{}?
enne (OOO) 2013/01/08 01:08:00 Technically, everything gets removed but low_res a
367 }
368 }
369
370 // Active tree creates tilings first, and the pending tree will get them
danakj 2013/01/07 22:35:56 s/ first// I misunderstood this comment the first
enne (OOO) 2013/01/08 01:08:00 The active tree gets calcDrawProperties called on
371 // synced to it.
372 if (layerTreeImpl()->IsActiveTree()) {
373 if (layerTreeImpl()->PinchGestureActive()) {
374 if (high_res) {
375 // If zooming out, if only available high-res tiling is very high
376 // resolution, create additional tilings closer to the ideal.
377 float high_ratio = high_res->contents_scale() / ideal_contents_scale;
378 if (high_ratio >= kMaxScaleRatioDuringPinch)
danakj 2013/01/07 22:35:56 can you use PositiveRatio() to simplify this area
enne (OOO) 2013/01/08 01:08:00 Oh, nice thought, done.
379 high_res = AddTiling(ideal_contents_scale);
380
381 // When zooming in, add some additional tilings so that content
382 // "crisps up" prior to releasing pinch.
383 float low_ratio = ideal_contents_scale / high_res->contents_scale();
384 if (low_ratio >= kMaxScaleRatioDuringPinch)
385 high_res = AddTiling(ideal_contents_scale);
386 } else if (!low_res)
danakj 2013/01/07 22:35:56 why do you only do this if !high_res? What if you
enne (OOO) 2013/01/08 01:08:00 Fixed to always add.
387 // If no tilings at all, add a low res during pinch for sanity.
388 low_res = AddTiling(low_res_contents_scale);
389 } else {
390 // When not pinching, ensure exact contents scales
danakj 2013/01/07 22:35:56 nit: period
enne (OOO) 2013/01/08 01:08:00 Done.
391 if (!high_res || high_res->contents_scale() != ideal_contents_scale)
392 high_res = AddTiling(ideal_contents_scale);
393 if (!low_res || low_res->contents_scale() != low_res_contents_scale)
394 low_res = AddTiling(low_res_contents_scale);
395 }
396 }
397
398 if (high_res)
399 high_res->set_resolution(HIGH_RESOLUTION);
400 if (low_res) {
401 if (low_res == high_res)
402 low_res->set_resolution(NON_IDEAL_RESOLUTION);
danakj 2013/01/07 22:35:56 i don't get this. if low == high, then you set the
enne (OOO) 2013/01/08 01:08:00 I don't know what I was thinking. Fixed.
403 else
404 low_res->set_resolution(LOW_RESOLUTION);
299 } 405 }
300 } 406 }
301 407
408 void PictureLayerImpl::CleanUpUnusedTilings(
409 std::vector<PictureLayerTiling*> used) {
danakj 2013/01/07 22:35:56 i don't understand the reason for this parameter,
enne (OOO) 2013/01/08 01:08:00 Yeah, this is the important part and why I couldn'
danakj 2013/01/08 23:27:16 Oh, I see. |used| is a blacklist to not delete tho
410 if (ideal_contents_scale_ <= 0)
danakj 2013/01/07 22:35:56 how is this possible?
enne (OOO) 2013/01/08 01:08:00 This is vestigial. I added it previously to work
411 return;
412
413 std::vector<PictureLayerTiling*> to_remove;
414
415 PictureLayerTiling* low_res = NULL;
416 float low_res_factor = layerTreeImpl()->settings().lowResContentsScaleFactor;
417 float low_res_contents_scale = ideal_contents_scale_ * low_res_factor;
418 for (size_t i = 0; i < tilings_.num_tilings(); ++i) {
419 PictureLayerTiling* tiling = tilings_.tiling_at(i);
420 if (!low_res || IsCloserToThan(tiling, low_res, low_res_contents_scale))
421 low_res = tiling;
422 }
423
424 for (size_t i = 0; i < tilings_.num_tilings(); ++i) {
425 PictureLayerTiling* tiling = tilings_.tiling_at(i);
426 if (tiling->contents_scale() == ideal_contents_scale_)
427 continue;
428 if (tiling == low_res)
danakj 2013/01/07 22:35:56 can you not use the HIGH_RESOLUTION and LOW_RESOLU
enne (OOO) 2013/01/08 01:08:00 Oh, hey. That's a really good idea. It's almost
429 continue;
430 if (std::find(used.begin(), used.end(), tiling) == used.end())
431 to_remove.push_back(tiling);
432 }
433
434 for (size_t i = 0; i < to_remove.size(); ++i)
435 tilings_.Remove(to_remove[i]);
436 }
437
302 } // namespace cc 438 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture_layer_impl.h ('k') | cc/picture_layer_tiling.h » ('j') | cc/picture_layer_tiling.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698