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/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 { | 20 namespace { |
21 const float kMaxScaleRatioDuringPinch = 2.0f; | 21 const float kMaxScaleRatioDuringPinch = 2.0f; |
22 } | 22 } |
23 | 23 |
24 namespace cc { | 24 namespace cc { |
25 | 25 |
26 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* treeImpl, int id) | 26 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* treeImpl, int id) |
27 : LayerImpl(treeImpl, id), | 27 : LayerImpl(treeImpl, id), |
28 tilings_(this), | 28 tilings_(new PictureLayerTilingSet(this)), |
29 pile_(PicturePileImpl::Create()), | 29 pile_(PicturePileImpl::Create()), |
30 last_update_time_(0), | 30 last_update_time_(0), |
31 last_content_scale_(0), | 31 last_content_scale_(0), |
32 ideal_contents_scale_(0), | 32 ideal_contents_scale_(0), |
33 is_mask_(false) { | 33 is_mask_(false) { |
34 } | 34 } |
35 | 35 |
36 PictureLayerImpl::~PictureLayerImpl() { | 36 PictureLayerImpl::~PictureLayerImpl() { |
37 } | 37 } |
38 | 38 |
39 const char* PictureLayerImpl::layerTypeAsString() const { | 39 const char* PictureLayerImpl::layerTypeAsString() const { |
40 return "PictureLayer"; | 40 return "PictureLayer"; |
41 } | 41 } |
42 | 42 |
| 43 scoped_ptr<LayerImpl> PictureLayerImpl::createLayerImpl( |
| 44 LayerTreeImpl* treeImpl) { |
| 45 return PictureLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>(); |
| 46 } |
| 47 |
| 48 void PictureLayerImpl::pushPropertiesTo(LayerImpl* base_layer) { |
| 49 LayerImpl::pushPropertiesTo(base_layer); |
| 50 |
| 51 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); |
| 52 layer_impl->SetIsMask(is_mask_); |
| 53 layer_impl->tilings_.swap(tilings_); |
| 54 tilings_.reset(new PictureLayerTilingSet(this)); |
| 55 layer_impl->pile_ = pile_; |
| 56 pile_ = PicturePileImpl::Create(); |
| 57 } |
| 58 |
| 59 |
43 void PictureLayerImpl::appendQuads(QuadSink& quadSink, | 60 void PictureLayerImpl::appendQuads(QuadSink& quadSink, |
44 AppendQuadsData& appendQuadsData) { | 61 AppendQuadsData& appendQuadsData) { |
45 | 62 |
46 const gfx::Rect& rect = visibleContentRect(); | 63 const gfx::Rect& rect = visibleContentRect(); |
47 gfx::Rect content_rect(gfx::Point(), contentBounds()); | 64 gfx::Rect content_rect(gfx::Point(), contentBounds()); |
48 | 65 |
49 SharedQuadState* sharedQuadState = | 66 SharedQuadState* sharedQuadState = |
50 quadSink.useSharedQuadState(createSharedQuadState()); | 67 quadSink.useSharedQuadState(createSharedQuadState()); |
51 bool clipped = false; | 68 bool clipped = false; |
52 gfx::QuadF target_quad = MathUtil::mapQuad( | 69 gfx::QuadF target_quad = MathUtil::mapQuad( |
53 drawTransform(), | 70 drawTransform(), |
54 gfx::QuadF(rect), | 71 gfx::QuadF(rect), |
55 clipped); | 72 clipped); |
56 bool isAxisAlignedInTarget = !clipped && target_quad.IsRectilinear(); | 73 bool isAxisAlignedInTarget = !clipped && target_quad.IsRectilinear(); |
57 bool useAA = !isAxisAlignedInTarget; | 74 bool useAA = !isAxisAlignedInTarget; |
58 | 75 |
59 if (showDebugBorders()) { | 76 if (showDebugBorders()) { |
60 for (PictureLayerTilingSet::Iterator iter(&tilings_, | 77 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
61 contentsScaleX(), | 78 contentsScaleX(), |
62 rect, | 79 rect, |
63 ideal_contents_scale_); | 80 ideal_contents_scale_); |
64 iter; | 81 iter; |
65 ++iter) { | 82 ++iter) { |
66 SkColor color; | 83 SkColor color; |
67 float width; | 84 float width; |
68 if (*iter && iter->GetResourceId()) { | 85 if (*iter && iter->GetResourceId()) { |
69 color = DebugColors::TileBorderColor(); | 86 color = DebugColors::TileBorderColor(); |
70 width = DebugColors::TileBorderWidth(layerTreeImpl()); | 87 width = DebugColors::TileBorderWidth(layerTreeImpl()); |
71 } else { | 88 } else { |
72 color = DebugColors::MissingTileBorderColor(); | 89 color = DebugColors::MissingTileBorderColor(); |
73 width = DebugColors::MissingTileBorderWidth(layerTreeImpl()); | 90 width = DebugColors::MissingTileBorderWidth(layerTreeImpl()); |
74 } | 91 } |
75 | 92 |
76 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = | 93 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = |
77 DebugBorderDrawQuad::Create(); | 94 DebugBorderDrawQuad::Create(); |
78 gfx::Rect geometry_rect = iter.geometry_rect(); | 95 gfx::Rect geometry_rect = iter.geometry_rect(); |
79 debugBorderQuad->SetNew(sharedQuadState, geometry_rect, color, width); | 96 debugBorderQuad->SetNew(sharedQuadState, geometry_rect, color, width); |
80 quadSink.append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData); | 97 quadSink.append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData); |
81 } | 98 } |
82 } | 99 } |
83 | 100 |
84 // Keep track of the tilings that were used so that tilings that are | 101 // Keep track of the tilings that were used so that tilings that are |
85 // unused can be considered for removal. | 102 // unused can be considered for removal. |
86 std::vector<PictureLayerTiling*> seen_tilings; | 103 std::vector<PictureLayerTiling*> seen_tilings; |
87 | 104 |
88 for (PictureLayerTilingSet::Iterator iter(&tilings_, | 105 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
89 contentsScaleX(), | 106 contentsScaleX(), |
90 rect, | 107 rect, |
91 ideal_contents_scale_); | 108 ideal_contents_scale_); |
92 iter; | 109 iter; |
93 ++iter) { | 110 ++iter) { |
94 ResourceProvider::ResourceId resource = 0; | 111 ResourceProvider::ResourceId resource = 0; |
95 if (*iter) | 112 if (*iter) |
96 resource = iter->GetResourceId(); | 113 resource = iter->GetResourceId(); |
97 | 114 |
98 gfx::Rect geometry_rect = iter.geometry_rect(); | 115 gfx::Rect geometry_rect = iter.geometry_rect(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 screenSpaceTransform(); | 173 screenSpaceTransform(); |
157 double current_time = | 174 double current_time = |
158 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); | 175 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); |
159 double time_delta = 0; | 176 double time_delta = 0; |
160 if (last_update_time_ != 0 && last_bounds_ == bounds() && | 177 if (last_update_time_ != 0 && last_bounds_ == bounds() && |
161 last_content_bounds_ == contentBounds() && | 178 last_content_bounds_ == contentBounds() && |
162 last_content_scale_ == contentsScaleX()) { | 179 last_content_scale_ == contentsScaleX()) { |
163 time_delta = current_time - last_update_time_; | 180 time_delta = current_time - last_update_time_; |
164 } | 181 } |
165 WhichTree tree = layerTreeImpl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 182 WhichTree tree = layerTreeImpl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
166 tilings_.UpdateTilePriorities( | 183 tilings_->UpdateTilePriorities( |
167 tree, | 184 tree, |
168 layerTreeImpl()->device_viewport_size(), | 185 layerTreeImpl()->device_viewport_size(), |
169 last_content_scale_, | 186 last_content_scale_, |
170 contentsScaleX(), | 187 contentsScaleX(), |
171 last_screen_space_transform_, | 188 last_screen_space_transform_, |
172 current_screen_space_transform, | 189 current_screen_space_transform, |
173 time_delta); | 190 time_delta); |
174 | 191 |
175 last_screen_space_transform_ = current_screen_space_transform; | 192 last_screen_space_transform_ = current_screen_space_transform; |
176 last_update_time_ = current_time; | 193 last_update_time_ = current_time; |
177 last_bounds_ = bounds(); | 194 last_bounds_ = bounds(); |
178 last_content_bounds_ = contentBounds(); | 195 last_content_bounds_ = contentBounds(); |
179 last_content_scale_ = contentsScaleX(); | 196 last_content_scale_ = contentsScaleX(); |
180 } | 197 } |
181 | 198 |
182 void PictureLayerImpl::didBecomeActive() { | 199 void PictureLayerImpl::didBecomeActive() { |
183 tilings_.MoveTilePriorities(PENDING_TREE, ACTIVE_TREE); | 200 LayerImpl::didBecomeActive(); |
| 201 tilings_->MoveTilePriorities(PENDING_TREE, ACTIVE_TREE); |
184 } | 202 } |
185 | 203 |
186 void PictureLayerImpl::didLoseOutputSurface() { | 204 void PictureLayerImpl::didLoseOutputSurface() { |
187 tilings_.RemoveAllTilings(); | 205 tilings_->RemoveAllTilings(); |
188 } | 206 } |
189 | 207 |
190 void PictureLayerImpl::calculateContentsScale( | 208 void PictureLayerImpl::calculateContentsScale( |
191 float ideal_contents_scale, | 209 float ideal_contents_scale, |
192 float* contents_scale_x, | 210 float* contents_scale_x, |
193 float* contents_scale_y, | 211 float* contents_scale_y, |
194 gfx::Size* content_bounds) { | 212 gfx::Size* content_bounds) { |
195 if (!drawsContent()) { | 213 if (!drawsContent()) { |
196 DCHECK(!tilings_.num_tilings()); | 214 DCHECK(!tilings_->num_tilings()); |
197 return; | 215 return; |
198 } | 216 } |
199 | 217 |
200 float min_contents_scale = layerTreeImpl()->settings().minimumContentsScale; | 218 float min_contents_scale = layerTreeImpl()->settings().minimumContentsScale; |
201 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); | 219 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); |
202 | 220 |
203 ManageTilings(ideal_contents_scale_); | 221 ManageTilings(ideal_contents_scale_); |
204 | 222 |
205 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. | 223 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. |
206 // There are (usually) several tilings at different scales. However, the | 224 // There are (usually) several tilings at different scales. However, the |
207 // content bounds is the (integer!) space in which quads are generated. | 225 // content bounds is the (integer!) space in which quads are generated. |
208 // In order to guarantee that we can fill this integer space with any set of | 226 // In order to guarantee that we can fill this integer space with any set of |
209 // tilings (and then map back to floating point texture coordinates), the | 227 // tilings (and then map back to floating point texture coordinates), the |
210 // contents scale must be at least as large as the largest of the tilings. | 228 // contents scale must be at least as large as the largest of the tilings. |
211 float max_contents_scale = min_contents_scale; | 229 float max_contents_scale = min_contents_scale; |
212 for (size_t i = 0; i < tilings_.num_tilings(); ++i) { | 230 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
213 const PictureLayerTiling* tiling = tilings_.tiling_at(i); | 231 const PictureLayerTiling* tiling = tilings_->tiling_at(i); |
214 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | 232 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); |
215 } | 233 } |
216 | 234 |
217 *contents_scale_x = max_contents_scale; | 235 *contents_scale_x = max_contents_scale; |
218 *contents_scale_y = max_contents_scale; | 236 *contents_scale_y = max_contents_scale; |
219 *content_bounds = gfx::ToCeiledSize( | 237 *content_bounds = gfx::ToCeiledSize( |
220 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale)); | 238 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale)); |
221 } | 239 } |
222 | 240 |
223 skia::RefPtr<SkPicture> PictureLayerImpl::getPicture() { | 241 skia::RefPtr<SkPicture> PictureLayerImpl::getPicture() { |
(...skipping 22 matching lines...) Expand all Loading... |
246 // tiles. This needs to be done last, after setting invalidation and the | 264 // tiles. This needs to be done last, after setting invalidation and the |
247 // pile. | 265 // pile. |
248 PictureLayerImpl* active_twin = static_cast<PictureLayerImpl*>( | 266 PictureLayerImpl* active_twin = static_cast<PictureLayerImpl*>( |
249 layerTreeImpl()->FindActiveTreeLayerById(id())); | 267 layerTreeImpl()->FindActiveTreeLayerById(id())); |
250 if (!active_twin) | 268 if (!active_twin) |
251 return; | 269 return; |
252 SyncFromActiveLayer(active_twin); | 270 SyncFromActiveLayer(active_twin); |
253 } | 271 } |
254 | 272 |
255 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { | 273 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { |
256 tilings_.CloneAll(other->tilings_, invalidation_); | 274 tilings_->CloneAll(*other->tilings_, invalidation_); |
257 } | 275 } |
258 | 276 |
259 void PictureLayerImpl::SyncTiling( | 277 void PictureLayerImpl::SyncTiling( |
260 const PictureLayerTiling* tiling) { | 278 const PictureLayerTiling* tiling) { |
261 tilings_.Clone(tiling, invalidation_); | 279 tilings_->Clone(tiling, invalidation_); |
262 } | 280 } |
263 | 281 |
264 void PictureLayerImpl::SetIsMask(bool is_mask) { | 282 void PictureLayerImpl::SetIsMask(bool is_mask) { |
265 if (is_mask_ == is_mask) | 283 if (is_mask_ == is_mask) |
266 return; | 284 return; |
267 is_mask_ = is_mask; | 285 is_mask_ = is_mask; |
268 tilings_.RemoveAllTiles(); | 286 tilings_->RemoveAllTiles(); |
269 } | 287 } |
270 | 288 |
271 ResourceProvider::ResourceId PictureLayerImpl::contentsResourceId() const { | 289 ResourceProvider::ResourceId PictureLayerImpl::contentsResourceId() const { |
272 gfx::Rect content_rect(gfx::Point(), contentBounds()); | 290 gfx::Rect content_rect(gfx::Point(), contentBounds()); |
273 float scale = contentsScaleX(); | 291 float scale = contentsScaleX(); |
274 for (PictureLayerTilingSet::Iterator iter(&tilings_, | 292 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
275 scale, | 293 scale, |
276 content_rect, | 294 content_rect, |
277 ideal_contents_scale_); | 295 ideal_contents_scale_); |
278 iter; | 296 iter; |
279 ++iter) { | 297 ++iter) { |
280 // Mask resource not ready yet. | 298 // Mask resource not ready yet. |
281 if (!*iter || !iter->GetResourceId()) | 299 if (!*iter || !iter->GetResourceId()) |
282 return 0; | 300 return 0; |
283 // Masks only supported if they fit on exactly one tile. | 301 // Masks only supported if they fit on exactly one tile. |
284 if (iter.geometry_rect() != content_rect) | 302 if (iter.geometry_rect() != content_rect) |
285 return 0; | 303 return 0; |
286 return iter->GetResourceId(); | 304 return iter->GetResourceId(); |
287 } | 305 } |
288 return 0; | 306 return 0; |
289 } | 307 } |
290 | 308 |
291 bool PictureLayerImpl::areVisibleResourcesReady() const { | 309 bool PictureLayerImpl::areVisibleResourcesReady() const { |
292 const gfx::Rect& rect = visibleContentRect(); | 310 const gfx::Rect& rect = visibleContentRect(); |
293 | 311 |
294 for (size_t i = 0; i < tilings_.num_tilings(); ++i) { | 312 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
295 const PictureLayerTiling* tiling = tilings_.tiling_at(i); | 313 const PictureLayerTiling* tiling = tilings_->tiling_at(i); |
296 | 314 |
297 // Ignore non-high resolution tilings. | 315 // Ignore non-high resolution tilings. |
298 if (tiling->resolution() != HIGH_RESOLUTION) | 316 if (tiling->resolution() != HIGH_RESOLUTION) |
299 continue; | 317 continue; |
300 | 318 |
301 for (PictureLayerTiling::Iterator iter(tiling, | 319 for (PictureLayerTiling::Iterator iter(tiling, |
302 tiling->contents_scale(), | 320 tiling->contents_scale(), |
303 rect); | 321 rect); |
304 iter; | 322 iter; |
305 ++iter) { | 323 ++iter) { |
306 // Resource not ready yet. | 324 // Resource not ready yet. |
307 if (!*iter || !iter->GetResourceId()) | 325 if (!*iter || !iter->GetResourceId()) |
308 return false; | 326 return false; |
309 } | 327 } |
310 return true; | 328 return true; |
311 } | 329 } |
312 return false; | 330 return false; |
313 } | 331 } |
314 | 332 |
315 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 333 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
316 if (contents_scale < layerTreeImpl()->settings().minimumContentsScale) | 334 if (contents_scale < layerTreeImpl()->settings().minimumContentsScale) |
317 return NULL; | 335 return NULL; |
318 | 336 |
319 PictureLayerTiling* tiling = tilings_.AddTiling( | 337 PictureLayerTiling* tiling = tilings_->AddTiling( |
320 contents_scale, | 338 contents_scale, |
321 TileSize()); | 339 TileSize()); |
322 | 340 |
323 // If a new tiling is created on the active tree, sync it to the pending tree | 341 // If a new tiling is created on the active tree, sync it to the pending tree |
324 // so that it can share the same tiles. | 342 // so that it can share the same tiles. |
325 if (layerTreeImpl()->IsPendingTree()) | 343 if (layerTreeImpl()->IsPendingTree()) |
326 return tiling; | 344 return tiling; |
327 | 345 |
328 PictureLayerImpl* pending_twin = static_cast<PictureLayerImpl*>( | 346 PictureLayerImpl* pending_twin = static_cast<PictureLayerImpl*>( |
329 layerTreeImpl()->FindPendingTreeLayerById(id())); | 347 layerTreeImpl()->FindPendingTreeLayerById(id())); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 float low_res_factor = layerTreeImpl()->settings().lowResContentsScaleFactor; | 388 float low_res_factor = layerTreeImpl()->settings().lowResContentsScaleFactor; |
371 float low_res_contents_scale = ideal_contents_scale * low_res_factor; | 389 float low_res_contents_scale = ideal_contents_scale * low_res_factor; |
372 | 390 |
373 // Remove any tilings from the pending tree that don't exactly match the | 391 // Remove any tilings from the pending tree that don't exactly match the |
374 // contents scale. The pending tree should always come in crisp. However, | 392 // contents scale. The pending tree should always come in crisp. However, |
375 // don't do this during a pinch, to avoid throwing away a tiling that should | 393 // don't do this during a pinch, to avoid throwing away a tiling that should |
376 // have been kept. | 394 // have been kept. |
377 if (layerTreeImpl()->IsPendingTree() && | 395 if (layerTreeImpl()->IsPendingTree() && |
378 !layerTreeImpl()->PinchGestureActive()) { | 396 !layerTreeImpl()->PinchGestureActive()) { |
379 std::vector<PictureLayerTiling*> remove_list; | 397 std::vector<PictureLayerTiling*> remove_list; |
380 for (size_t i = 0; i < tilings_.num_tilings(); ++i) { | 398 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
381 PictureLayerTiling* tiling = tilings_.tiling_at(i); | 399 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
382 if (tiling->contents_scale() == ideal_contents_scale) | 400 if (tiling->contents_scale() == ideal_contents_scale) |
383 continue; | 401 continue; |
384 if (tiling->contents_scale() == low_res_contents_scale) | 402 if (tiling->contents_scale() == low_res_contents_scale) |
385 continue; | 403 continue; |
386 remove_list.push_back(tiling); | 404 remove_list.push_back(tiling); |
387 } | 405 } |
388 | 406 |
389 for (size_t i = 0; i < remove_list.size(); ++i) | 407 for (size_t i = 0; i < remove_list.size(); ++i) |
390 tilings_.Remove(remove_list[i]); | 408 tilings_->Remove(remove_list[i]); |
391 } | 409 } |
392 | 410 |
393 // Find existing tilings closest to ideal high / low res. | 411 // Find existing tilings closest to ideal high / low res. |
394 PictureLayerTiling* high_res = NULL; | 412 PictureLayerTiling* high_res = NULL; |
395 PictureLayerTiling* low_res = NULL; | 413 PictureLayerTiling* low_res = NULL; |
396 for (size_t i = 0; i < tilings_.num_tilings(); ++i) { | 414 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
397 PictureLayerTiling* tiling = tilings_.tiling_at(i); | 415 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
398 if (!high_res || IsCloserToThan(tiling, high_res, ideal_contents_scale)) | 416 if (!high_res || IsCloserToThan(tiling, high_res, ideal_contents_scale)) |
399 high_res = tiling; | 417 high_res = tiling; |
400 if (!low_res || IsCloserToThan(tiling, low_res, low_res_contents_scale)) | 418 if (!low_res || IsCloserToThan(tiling, low_res, low_res_contents_scale)) |
401 low_res = tiling; | 419 low_res = tiling; |
402 | 420 |
403 // Reset all tilings to non-ideal until the end of this function. | 421 // Reset all tilings to non-ideal until the end of this function. |
404 tiling->set_resolution(NON_IDEAL_RESOLUTION); | 422 tiling->set_resolution(NON_IDEAL_RESOLUTION); |
405 } | 423 } |
406 | 424 |
407 // The active tree always has calcDrawProperties called on it first, and | 425 // The active tree always has calcDrawProperties called on it first, and |
(...skipping 23 matching lines...) Expand all Loading... |
431 if (high_res) | 449 if (high_res) |
432 high_res->set_resolution(HIGH_RESOLUTION); | 450 high_res->set_resolution(HIGH_RESOLUTION); |
433 if (low_res && low_res != high_res) | 451 if (low_res && low_res != high_res) |
434 low_res->set_resolution(LOW_RESOLUTION); | 452 low_res->set_resolution(LOW_RESOLUTION); |
435 } | 453 } |
436 | 454 |
437 void PictureLayerImpl::CleanUpUnusedTilings( | 455 void PictureLayerImpl::CleanUpUnusedTilings( |
438 std::vector<PictureLayerTiling*> used_tilings) { | 456 std::vector<PictureLayerTiling*> used_tilings) { |
439 std::vector<PictureLayerTiling*> to_remove; | 457 std::vector<PictureLayerTiling*> to_remove; |
440 | 458 |
441 for (size_t i = 0; i < tilings_.num_tilings(); ++i) { | 459 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
442 PictureLayerTiling* tiling = tilings_.tiling_at(i); | 460 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
443 // Don't remove the current high or low res tilinig. | 461 // Don't remove the current high or low res tilinig. |
444 if (tiling->resolution() != NON_IDEAL_RESOLUTION) | 462 if (tiling->resolution() != NON_IDEAL_RESOLUTION) |
445 continue; | 463 continue; |
446 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) == | 464 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) == |
447 used_tilings.end()) | 465 used_tilings.end()) |
448 to_remove.push_back(tiling); | 466 to_remove.push_back(tiling); |
449 } | 467 } |
450 | 468 |
451 for (size_t i = 0; i < to_remove.size(); ++i) | 469 for (size_t i = 0; i < to_remove.size(); ++i) |
452 tilings_.Remove(to_remove[i]); | 470 tilings_->Remove(to_remove[i]); |
453 } | 471 } |
454 | 472 |
455 } // namespace cc | 473 } // namespace cc |
OLD | NEW |