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/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "cc/base/math_util.h" | 11 #include "cc/base/math_util.h" |
12 #include "ui/gfx/point_conversions.h" | 12 #include "ui/gfx/point_conversions.h" |
13 #include "ui/gfx/rect_conversions.h" | 13 #include "ui/gfx/rect_conversions.h" |
14 #include "ui/gfx/safe_integer_conversions.h" | 14 #include "ui/gfx/safe_integer_conversions.h" |
15 #include "ui/gfx/size_conversions.h" | 15 #include "ui/gfx/size_conversions.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 19 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
20 float contents_scale) { | 20 float contents_scale, |
21 return make_scoped_ptr(new PictureLayerTiling(contents_scale)); | 21 gfx::Size layer_bounds, |
22 PictureLayerTilingClient* client) { | |
23 return make_scoped_ptr(new PictureLayerTiling(contents_scale, | |
24 layer_bounds, | |
25 client)); | |
22 } | 26 } |
23 | 27 |
24 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Clone() const { | 28 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Clone( |
25 return make_scoped_ptr(new PictureLayerTiling(*this)); | 29 gfx::Size layer_bounds, |
30 PictureLayerTilingClient* client) const { | |
31 scoped_ptr<PictureLayerTiling> out = | |
32 make_scoped_ptr(new PictureLayerTiling(contents_scale_, | |
33 layer_bounds, | |
34 client)); | |
35 out->resolution_ = resolution_; | |
36 out->last_source_frame_number_ = last_source_frame_number_; | |
37 out->last_impl_frame_time_ = last_impl_frame_time_; | |
38 return out.Pass(); | |
26 } | 39 } |
27 | 40 |
28 PictureLayerTiling::PictureLayerTiling(float contents_scale) | 41 PictureLayerTiling::PictureLayerTiling(float contents_scale, |
29 : client_(NULL), | 42 gfx::Size layer_bounds, |
30 contents_scale_(contents_scale), | 43 PictureLayerTilingClient* client) |
44 : contents_scale_(contents_scale), | |
45 layer_bounds_(layer_bounds), | |
46 resolution_(NON_IDEAL_RESOLUTION), | |
47 client_(client), | |
31 tiling_data_(gfx::Size(), gfx::Size(), true), | 48 tiling_data_(gfx::Size(), gfx::Size(), true), |
32 resolution_(NON_IDEAL_RESOLUTION), | |
33 last_source_frame_number_(0), | 49 last_source_frame_number_(0), |
34 last_impl_frame_time_(0) { | 50 last_impl_frame_time_(0.0) { |
51 gfx::Size content_bounds = | |
52 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)); | |
53 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); | |
54 | |
55 tiling_data_.SetTotalSize(content_bounds); | |
56 tiling_data_.SetMaxTextureSize(tile_size); | |
35 } | 57 } |
36 | 58 |
37 PictureLayerTiling::~PictureLayerTiling() { | 59 PictureLayerTiling::~PictureLayerTiling() { |
38 } | 60 } |
39 | 61 |
40 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { | 62 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { |
41 client_ = client; | 63 client_ = client; |
42 } | 64 } |
43 | 65 |
44 gfx::Rect PictureLayerTiling::ContentRect() const { | 66 gfx::Rect PictureLayerTiling::ContentRect() const { |
45 return gfx::Rect(tiling_data_.total_size()); | 67 return gfx::Rect(tiling_data_.total_size()); |
46 } | 68 } |
47 | 69 |
48 gfx::SizeF PictureLayerTiling::ContentSizeF() const { | 70 gfx::SizeF PictureLayerTiling::ContentSizeF() const { |
49 return gfx::ScaleSize(layer_bounds_, contents_scale_); | 71 return gfx::ScaleSize(layer_bounds_, contents_scale_); |
50 } | 72 } |
51 | 73 |
52 Tile* PictureLayerTiling::TileAt(int i, int j) const { | 74 Tile* PictureLayerTiling::TileAt(int i, int j) const { |
53 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); | 75 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); |
54 if (iter == tiles_.end()) | 76 if (iter == tiles_.end()) |
55 return NULL; | 77 return NULL; |
56 return iter->second.get(); | 78 return iter->second.get(); |
57 } | 79 } |
58 | 80 |
59 void PictureLayerTiling::CreateTile(int i, int j) { | 81 void PictureLayerTiling::CreateTile(int i, int j) { |
60 gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j); | |
61 tile_rect.set_size(tiling_data_.max_texture_size()); | |
62 TileMapKey key(i, j); | 82 TileMapKey key(i, j); |
63 DCHECK(tiles_.find(key) == tiles_.end()); | 83 DCHECK(tiles_.find(key) == tiles_.end()); |
84 | |
85 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); | |
86 gfx::Rect tile_rect = paint_rect; | |
87 tile_rect.set_size(tiling_data_.max_texture_size()); | |
88 | |
89 // Check our twin for a valid tile. | |
90 const PictureLayerTiling* twin = client_->GetTwinTiling(this); | |
91 if (twin && tiling_data_.max_texture_size() == | |
92 twin->tiling_data_.max_texture_size()) { | |
93 Tile* candidate_tile = twin->TileAt(i, j); | |
94 if (candidate_tile) { | |
95 gfx::Rect rect = | |
96 gfx::ToEnclosingRect(ScaleRect(paint_rect, 1.0f / contents_scale_)); | |
97 if (!client_->GetInvalidation()->Intersects(rect)) { | |
98 tiles_[key] = candidate_tile; | |
99 return; | |
100 } | |
101 } | |
102 } | |
103 | |
104 // Create a new tile because our twin didn't have a valid one. | |
64 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); | 105 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); |
65 if (tile) | 106 if (tile) |
66 tiles_[key] = tile; | 107 tiles_[key] = tile; |
67 } | 108 } |
68 | 109 |
69 Region PictureLayerTiling::OpaqueRegionInContentRect( | 110 Region PictureLayerTiling::OpaqueRegionInContentRect( |
70 const gfx::Rect& content_rect) const { | 111 const gfx::Rect& content_rect) const { |
71 Region opaque_region; | 112 Region opaque_region; |
72 // TODO(enne): implement me | 113 // TODO(enne): implement me |
73 return opaque_region; | 114 return opaque_region; |
74 } | 115 } |
75 | 116 |
76 void PictureLayerTiling::SetLayerBounds(gfx::Size layer_bounds) { | |
77 if (layer_bounds_ == layer_bounds) | |
78 return; | |
79 | |
80 gfx::Size old_layer_bounds = layer_bounds_; | |
81 layer_bounds_ = layer_bounds; | |
82 gfx::Size old_content_bounds = tiling_data_.total_size(); | |
83 gfx::Size content_bounds = | |
84 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds_, contents_scale_)); | |
85 | |
86 tiling_data_.SetTotalSize(content_bounds); | |
87 if (layer_bounds_.IsEmpty()) { | |
88 tiles_.clear(); | |
89 return; | |
90 } | |
91 | |
92 gfx::Size tile_size = client_->CalculateTileSize( | |
93 tiling_data_.max_texture_size(), | |
94 content_bounds); | |
95 if (tile_size != tiling_data_.max_texture_size()) { | |
96 tiling_data_.SetMaxTextureSize(tile_size); | |
97 tiles_.clear(); | |
98 CreateTilesFromLayerRect(gfx::Rect(layer_bounds_)); | |
99 return; | |
100 } | |
101 | |
102 // Any tiles outside our new bounds are invalid and should be dropped. | |
103 if (old_content_bounds.width() > content_bounds.width() || | |
104 old_content_bounds.height() > content_bounds.height()) { | |
105 int right = | |
106 tiling_data_.TileXIndexFromSrcCoord(content_bounds.width() - 1); | |
107 int bottom = | |
108 tiling_data_.TileYIndexFromSrcCoord(content_bounds.height() - 1); | |
109 | |
110 std::vector<TileMapKey> invalid_tile_keys; | |
111 for (TileMap::const_iterator it = tiles_.begin(); | |
112 it != tiles_.end(); ++it) { | |
113 if (it->first.first > right || it->first.second > bottom) | |
114 invalid_tile_keys.push_back(it->first); | |
115 } | |
116 for (size_t i = 0; i < invalid_tile_keys.size(); ++i) | |
117 tiles_.erase(invalid_tile_keys[i]); | |
118 } | |
119 | |
120 // Create tiles for newly exposed areas. | |
121 Region layer_region((gfx::Rect(layer_bounds_))); | |
122 layer_region.Subtract(gfx::Rect(old_layer_bounds)); | |
123 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { | |
124 Invalidate(iter.rect()); | |
125 CreateTilesFromLayerRect(iter.rect()); | |
126 } | |
127 } | |
128 | |
129 void PictureLayerTiling::Invalidate(const Region& layer_invalidation) { | |
130 std::vector<TileMapKey> new_tiles; | |
131 | |
132 for (Region::Iterator region_iter(layer_invalidation); | |
133 region_iter.has_rect(); | |
134 region_iter.next()) { | |
135 gfx::Rect layer_invalidation = region_iter.rect(); | |
136 layer_invalidation.Intersect(gfx::Rect(layer_bounds_)); | |
137 gfx::Rect rect = | |
138 gfx::ToEnclosingRect(ScaleRect(layer_invalidation, contents_scale_)); | |
139 | |
140 for (PictureLayerTiling::CoverageIterator tile_iter(this, | |
141 contents_scale_, | |
142 rect); | |
143 tile_iter; | |
144 ++tile_iter) { | |
145 TileMapKey key(tile_iter.tile_i_, tile_iter.tile_j_); | |
146 TileMap::iterator found = tiles_.find(key); | |
147 if (found == tiles_.end()) | |
148 continue; | |
149 | |
150 tiles_.erase(found); | |
151 new_tiles.push_back(key); | |
152 } | |
153 } | |
154 | |
155 for (size_t i = 0; i < new_tiles.size(); ++i) | |
156 CreateTile(new_tiles[i].first, new_tiles[i].second); | |
157 } | |
158 | |
159 void PictureLayerTiling::InvalidateTilesWithText() { | 117 void PictureLayerTiling::InvalidateTilesWithText() { |
160 std::vector<TileMapKey> new_tiles; | 118 std::vector<TileMapKey> new_tiles; |
161 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 119 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
162 if (it->second->has_text()) | 120 if (it->second->has_text()) |
163 new_tiles.push_back(it->first); | 121 new_tiles.push_back(it->first); |
164 } | 122 } |
165 | 123 |
166 for (size_t i = 0; i < new_tiles.size(); ++i) { | 124 for (size_t i = 0; i < new_tiles.size(); ++i) { |
167 tiles_.erase(new_tiles[i]); | 125 tiles_.erase(new_tiles[i]); |
168 CreateTile(new_tiles[i].first, new_tiles[i].second); | 126 CreateTile(new_tiles[i].first, new_tiles[i].second); |
169 } | 127 } |
170 } | 128 } |
171 | 129 |
172 void PictureLayerTiling::CreateTilesFromLayerRect(gfx::Rect layer_rect) { | |
173 gfx::Rect content_rect = | |
174 gfx::ToEnclosingRect(ScaleRect(layer_rect, contents_scale_)); | |
175 CreateTilesFromContentRect(content_rect); | |
176 } | |
177 | |
178 void PictureLayerTiling::CreateTilesFromContentRect(gfx::Rect content_rect) { | |
179 for (TilingData::Iterator iter(&tiling_data_, content_rect); iter; ++iter) { | |
180 TileMap::iterator found = | |
181 tiles_.find(TileMapKey(iter.index_x(), iter.index_y())); | |
182 // Ignore any tiles that already exist. | |
183 if (found != tiles_.end()) | |
184 continue; | |
185 CreateTile(iter.index_x(), iter.index_y()); | |
186 } | |
187 } | |
188 | |
189 PictureLayerTiling::CoverageIterator::CoverageIterator() | 130 PictureLayerTiling::CoverageIterator::CoverageIterator() |
190 : tiling_(NULL), | 131 : tiling_(NULL), |
191 current_tile_(NULL), | 132 current_tile_(NULL), |
192 tile_i_(0), | 133 tile_i_(0), |
193 tile_j_(0), | 134 tile_j_(0), |
194 left_(0), | 135 left_(0), |
195 top_(0), | 136 top_(0), |
196 right_(-1), | 137 right_(-1), |
197 bottom_(-1) { | 138 bottom_(-1) { |
198 } | 139 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); | 272 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); |
332 texture_rect.Intersect(tiling_->ContentRect()); | 273 texture_rect.Intersect(tiling_->ContentRect()); |
333 | 274 |
334 return texture_rect; | 275 return texture_rect; |
335 } | 276 } |
336 | 277 |
337 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { | 278 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { |
338 return tiling_->tiling_data_.max_texture_size(); | 279 return tiling_->tiling_data_.max_texture_size(); |
339 } | 280 } |
340 | 281 |
282 void PictureLayerTiling::Reset() { | |
283 live_tiles_rect_ = gfx::Rect(); | |
284 tiles_.clear(); | |
285 } | |
286 | |
341 void PictureLayerTiling::UpdateTilePriorities( | 287 void PictureLayerTiling::UpdateTilePriorities( |
342 WhichTree tree, | 288 WhichTree tree, |
343 gfx::Size device_viewport, | 289 gfx::Size device_viewport, |
344 const gfx::RectF& viewport_in_layer_space, | 290 const gfx::RectF& viewport_in_layer_space, |
345 gfx::Size last_layer_bounds, | 291 gfx::Size last_layer_bounds, |
346 gfx::Size current_layer_bounds, | 292 gfx::Size current_layer_bounds, |
347 float last_layer_contents_scale, | 293 float last_layer_contents_scale, |
348 float current_layer_contents_scale, | 294 float current_layer_contents_scale, |
349 const gfx::Transform& last_screen_transform, | 295 const gfx::Transform& last_screen_transform, |
350 const gfx::Transform& current_screen_transform, | 296 const gfx::Transform& current_screen_transform, |
351 int current_source_frame_number, | 297 int current_source_frame_number, |
352 double current_frame_time, | 298 double current_frame_time, |
353 bool store_screen_space_quads_on_tiles, | 299 bool store_screen_space_quads_on_tiles, |
354 size_t max_tiles_for_interest_area) { | 300 size_t max_tiles_for_interest_area) { |
355 if (ContentRect().IsEmpty()) | 301 if (ContentRect().IsEmpty()) |
356 return; | 302 return; |
357 | 303 |
304 gfx::Rect viewport_in_content_space = | |
305 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, | |
306 contents_scale_)); | |
307 | |
308 gfx::Size tile_size = tiling_data_.max_texture_size(); | |
309 int64 interest_rect_area = | |
310 max_tiles_for_interest_area * tile_size.width() * tile_size.height(); | |
311 | |
312 gfx::Rect interest_rect = ExpandRectEquallyToAreaBoundedBy( | |
313 viewport_in_content_space, | |
314 interest_rect_area, | |
315 ContentRect()); | |
316 DCHECK(ContentRect().Contains(interest_rect)); | |
317 | |
318 SetLiveTilesRect(interest_rect); | |
319 | |
358 bool first_update_in_new_source_frame = | 320 bool first_update_in_new_source_frame = |
359 current_source_frame_number != last_source_frame_number_; | 321 current_source_frame_number != last_source_frame_number_; |
360 | 322 |
361 bool first_update_in_new_impl_frame = | 323 bool first_update_in_new_impl_frame = |
362 current_frame_time != last_impl_frame_time_; | 324 current_frame_time != last_impl_frame_time_; |
363 | 325 |
364 // In pending tree, this is always called. We update priorities: | 326 // In pending tree, this is always called. We update priorities: |
365 // - Immediately after a commit (first_update_in_new_source_frame). | 327 // - Immediately after a commit (first_update_in_new_source_frame). |
366 // - On animation ticks after the first frame in the tree | 328 // - On animation ticks after the first frame in the tree |
367 // (first_update_in_new_impl_frame). | 329 // (first_update_in_new_impl_frame). |
368 // In active tree, this is only called during draw. We update priorities: | 330 // In active tree, this is only called during draw. We update priorities: |
369 // - On draw if properties were not already computed by the pending tree | 331 // - On draw if properties were not already computed by the pending tree |
370 // and activated for the frame (first_update_in_new_impl_frame). | 332 // and activated for the frame (first_update_in_new_impl_frame). |
371 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame) | 333 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame) |
372 return; | 334 return; |
373 | 335 |
374 double time_delta = 0; | 336 double time_delta = 0.0; |
375 if (last_impl_frame_time_ != 0 && last_layer_bounds == current_layer_bounds) | 337 if (last_impl_frame_time_ != 0.0 && |
338 last_layer_bounds == current_layer_bounds) | |
376 time_delta = current_frame_time - last_impl_frame_time_; | 339 time_delta = current_frame_time - last_impl_frame_time_; |
377 | 340 |
378 gfx::Rect viewport_in_content_space = | |
379 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, | |
380 contents_scale_)); | |
381 | |
382 gfx::Size tile_size = tiling_data_.max_texture_size(); | |
383 int64 prioritized_rect_area = | |
384 max_tiles_for_interest_area * | |
385 tile_size.width() * tile_size.height(); | |
386 | |
387 gfx::Rect prioritized_rect = ExpandRectEquallyToAreaBoundedBy( | |
388 viewport_in_content_space, | |
389 prioritized_rect_area, | |
390 ContentRect()); | |
391 DCHECK(ContentRect().Contains(prioritized_rect)); | |
392 | |
393 // Iterate through all of the tiles that were live last frame but will | |
394 // not be live this frame, and mark them as being dead. | |
395 for (TilingData::DifferenceIterator iter(&tiling_data_, | |
396 last_prioritized_rect_, | |
397 prioritized_rect); | |
398 iter; | |
399 ++iter) { | |
400 TileMap::iterator find = tiles_.find(iter.index()); | |
401 if (find == tiles_.end()) | |
402 continue; | |
403 | |
404 TilePriority priority; | |
405 DCHECK(!priority.is_live); | |
406 Tile* tile = find->second.get(); | |
407 tile->SetPriority(tree, priority); | |
408 } | |
409 last_prioritized_rect_ = prioritized_rect; | |
410 | |
411 gfx::Rect view_rect(device_viewport); | 341 gfx::Rect view_rect(device_viewport); |
412 float current_scale = current_layer_contents_scale / contents_scale_; | 342 float current_scale = current_layer_contents_scale / contents_scale_; |
413 float last_scale = last_layer_contents_scale / contents_scale_; | 343 float last_scale = last_layer_contents_scale / contents_scale_; |
414 | 344 |
415 // Fast path tile priority calculation when both transforms are translations. | 345 // Fast path tile priority calculation when both transforms are translations. |
416 if (last_screen_transform.IsIdentityOrTranslation() && | 346 if (last_screen_transform.IsIdentityOrTranslation() && |
417 current_screen_transform.IsIdentityOrTranslation()) { | 347 current_screen_transform.IsIdentityOrTranslation()) { |
418 gfx::Vector2dF current_offset( | 348 gfx::Vector2dF current_offset( |
419 current_screen_transform.matrix().get(0, 3), | 349 current_screen_transform.matrix().get(0, 3), |
420 current_screen_transform.matrix().get(1, 3)); | 350 current_screen_transform.matrix().get(1, 3)); |
421 gfx::Vector2dF last_offset( | 351 gfx::Vector2dF last_offset( |
422 last_screen_transform.matrix().get(0, 3), | 352 last_screen_transform.matrix().get(0, 3), |
423 last_screen_transform.matrix().get(1, 3)); | 353 last_screen_transform.matrix().get(1, 3)); |
424 | 354 |
425 for (TilingData::Iterator iter(&tiling_data_, prioritized_rect); | 355 for (TilingData::Iterator iter(&tiling_data_, interest_rect); |
426 iter; ++iter) { | 356 iter; ++iter) { |
427 TileMap::iterator find = tiles_.find(iter.index()); | 357 TileMap::iterator find = tiles_.find(iter.index()); |
428 if (find == tiles_.end()) | 358 if (find == tiles_.end()) |
429 continue; | 359 continue; |
430 Tile* tile = find->second.get(); | 360 Tile* tile = find->second.get(); |
431 | 361 |
432 gfx::Rect tile_bounds = | 362 gfx::Rect tile_bounds = |
433 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | 363 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); |
434 gfx::RectF current_screen_rect = gfx::ScaleRect( | 364 gfx::RectF current_screen_rect = gfx::ScaleRect( |
435 tile_bounds, | 365 tile_bounds, |
(...skipping 12 matching lines...) Expand all Loading... | |
448 last_screen_rect, current_screen_rect, time_delta, view_rect); | 378 last_screen_rect, current_screen_rect, time_delta, view_rect); |
449 TilePriority priority( | 379 TilePriority priority( |
450 resolution_, | 380 resolution_, |
451 time_to_visible_in_seconds, | 381 time_to_visible_in_seconds, |
452 distance_to_visible_in_pixels); | 382 distance_to_visible_in_pixels); |
453 if (store_screen_space_quads_on_tiles) | 383 if (store_screen_space_quads_on_tiles) |
454 priority.set_current_screen_quad(gfx::QuadF(current_screen_rect)); | 384 priority.set_current_screen_quad(gfx::QuadF(current_screen_rect)); |
455 tile->SetPriority(tree, priority); | 385 tile->SetPriority(tree, priority); |
456 } | 386 } |
457 } else { | 387 } else { |
458 for (TilingData::Iterator iter(&tiling_data_, prioritized_rect); | 388 for (TilingData::Iterator iter(&tiling_data_, interest_rect); |
459 iter; ++iter) { | 389 iter; ++iter) { |
460 TileMap::iterator find = tiles_.find(iter.index()); | 390 TileMap::iterator find = tiles_.find(iter.index()); |
461 if (find == tiles_.end()) | 391 if (find == tiles_.end()) |
462 continue; | 392 continue; |
463 Tile* tile = find->second.get(); | 393 Tile* tile = find->second.get(); |
464 | 394 |
465 gfx::Rect tile_bounds = | 395 gfx::Rect tile_bounds = |
466 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | 396 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); |
467 gfx::RectF current_layer_content_rect = gfx::ScaleRect( | 397 gfx::RectF current_layer_content_rect = gfx::ScaleRect( |
468 tile_bounds, | 398 tile_bounds, |
(...skipping 27 matching lines...) Expand all Loading... | |
496 &clipped)); | 426 &clipped)); |
497 } | 427 } |
498 tile->SetPriority(tree, priority); | 428 tile->SetPriority(tree, priority); |
499 } | 429 } |
500 } | 430 } |
501 | 431 |
502 last_source_frame_number_ = current_source_frame_number; | 432 last_source_frame_number_ = current_source_frame_number; |
503 last_impl_frame_time_ = current_frame_time; | 433 last_impl_frame_time_ = current_frame_time; |
504 } | 434 } |
505 | 435 |
436 void PictureLayerTiling::SetLiveTilesRect( | |
437 gfx::Rect new_live_tiles_rect) { | |
438 gfx::Rect content_rect = | |
439 gfx::ToEnclosingRect(gfx::ScaleRect(gfx::Rect(layer_bounds_), | |
440 contents_scale_)); | |
441 DCHECK(content_rect.Contains(new_live_tiles_rect)); | |
enne (OOO)
2013/04/11 00:16:02
s/content_rect/ContentRect()/
| |
442 if (live_tiles_rect_ == new_live_tiles_rect) | |
443 return; | |
444 | |
445 // Iterate to delete all tiles outside of our new live_tiles rect. | |
446 for (TilingData::DifferenceIterator iter(&tiling_data_, | |
447 live_tiles_rect_, | |
448 new_live_tiles_rect); | |
449 iter; | |
450 ++iter) { | |
451 TileMapKey key(iter.index()); | |
452 TileMap::iterator found = tiles_.find(key); | |
453 DCHECK(found != tiles_.end()); | |
454 tiles_.erase(found); | |
455 } | |
456 | |
457 // Iterate to allocate new tiles for all regions with newly exposed area. | |
458 for (TilingData::DifferenceIterator iter(&tiling_data_, | |
459 new_live_tiles_rect, | |
460 live_tiles_rect_); | |
461 iter; | |
462 ++iter) { | |
463 TileMapKey key(iter.index()); | |
464 CreateTile(key.first, key.second); | |
465 } | |
466 | |
467 live_tiles_rect_ = new_live_tiles_rect; | |
468 } | |
469 | |
506 void PictureLayerTiling::DidBecomeActive() { | 470 void PictureLayerTiling::DidBecomeActive() { |
507 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 471 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
508 it->second->SetPriority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); | 472 it->second->SetPriority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); |
509 it->second->SetPriority(PENDING_TREE, TilePriority()); | 473 it->second->SetPriority(PENDING_TREE, TilePriority()); |
510 | 474 |
511 // Tile holds a ref onto a picture pile. If the tile never gets invalidated | 475 // Tile holds a ref onto a picture pile. If the tile never gets invalidated |
512 // and recreated, then that picture pile ref could exist indefinitely. To | 476 // and recreated, then that picture pile ref could exist indefinitely. To |
513 // prevent this, ask the client to update the pile to its own ref. This | 477 // prevent this, ask the client to update the pile to its own ref. This |
514 // will cause PicturePileImpls and their clones to get deleted once the | 478 // will cause PicturePileImpls and their clones to get deleted once the |
515 // corresponding PictureLayerImpl and any in flight raster jobs go out of | 479 // corresponding PictureLayerImpl and any in flight raster jobs go out of |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 | 615 |
652 // If our delta is less then our event distance, we're done. | 616 // If our delta is less then our event distance, we're done. |
653 if (delta < event.distance) | 617 if (delta < event.distance) |
654 break; | 618 break; |
655 } | 619 } |
656 | 620 |
657 return gfx::Rect(origin_x, origin_y, width, height); | 621 return gfx::Rect(origin_x, origin_y, width, height); |
658 } | 622 } |
659 | 623 |
660 } // namespace cc | 624 } // namespace cc |
OLD | NEW |