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 { | |
52 gfx::Size content_bounds = | |
53 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)); | |
54 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); | |
55 | |
56 tiling_data_.SetTotalSize(content_bounds); | |
57 tiling_data_.SetMaxTextureSize(tile_size); | |
35 } | 58 } |
36 | 59 |
37 PictureLayerTiling::~PictureLayerTiling() { | 60 PictureLayerTiling::~PictureLayerTiling() { |
38 } | 61 } |
39 | 62 |
40 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { | 63 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { |
41 client_ = client; | 64 client_ = client; |
42 } | 65 } |
43 | 66 |
44 gfx::Rect PictureLayerTiling::ContentRect() const { | 67 gfx::Rect PictureLayerTiling::ContentRect() const { |
45 return gfx::Rect(tiling_data_.total_size()); | 68 return gfx::Rect(tiling_data_.total_size()); |
46 } | 69 } |
47 | 70 |
48 gfx::SizeF PictureLayerTiling::ContentSizeF() const { | 71 gfx::SizeF PictureLayerTiling::ContentSizeF() const { |
49 return gfx::ScaleSize(layer_bounds_, contents_scale_); | 72 return gfx::ScaleSize(layer_bounds_, contents_scale_); |
50 } | 73 } |
51 | 74 |
52 Tile* PictureLayerTiling::TileAt(int i, int j) const { | 75 Tile* PictureLayerTiling::TileAt(int i, int j) const { |
53 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); | 76 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); |
54 if (iter == tiles_.end()) | 77 if (iter == tiles_.end()) |
55 return NULL; | 78 return NULL; |
56 return iter->second.get(); | 79 return iter->second.get(); |
57 } | 80 } |
58 | 81 |
59 void PictureLayerTiling::CreateTile(int i, int j) { | 82 void PictureLayerTiling::CreateTile(int i, int j) { |
60 gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j); | 83 TileMapKey key(i, j); |
84 tiles_.erase(key); | |
enne (OOO)
2013/04/10 20:25:30
I liked the dcheck better.
whunt
2013/04/10 20:52:30
The DCHECK is wrong given the way that SetLiveTile
enne (OOO)
2013/04/10 21:21:24
What do you mean by grow slightly? I thought all t
whunt
2013/04/10 21:45:59
I mean grow the interest rect. We use difference
| |
85 | |
86 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); | |
87 gfx::Rect tile_rect = paint_rect; | |
61 tile_rect.set_size(tiling_data_.max_texture_size()); | 88 tile_rect.set_size(tiling_data_.max_texture_size()); |
62 TileMapKey key(i, j); | 89 |
63 DCHECK(tiles_.find(key) == tiles_.end()); | 90 // Check our twin for a valid tile. |
91 const PictureLayerTiling* twin = client_->GetTwinTiling(this); | |
92 if (twin && tiling_data_.max_texture_size() == | |
93 twin->tiling_data_.max_texture_size()) { | |
94 Tile* candidate_tile = twin->TileAt(i, j); | |
95 if (candidate_tile) { | |
96 gfx::Rect rect = | |
97 gfx::ToEnclosingRect(ScaleRect(paint_rect, 1.0f / contents_scale_)); | |
98 if (!client_->GetInvalidation()->Intersects(rect)) { | |
99 tiles_[key] = candidate_tile; | |
100 return; | |
101 } | |
102 } | |
103 } | |
104 | |
105 // Create a new tile because our twin didn't have a valid one. | |
64 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); | 106 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); |
65 if (tile) | 107 if (tile) |
66 tiles_[key] = tile; | 108 tiles_[key] = tile; |
67 } | 109 } |
68 | 110 |
69 Region PictureLayerTiling::OpaqueRegionInContentRect( | 111 Region PictureLayerTiling::OpaqueRegionInContentRect( |
70 const gfx::Rect& content_rect) const { | 112 const gfx::Rect& content_rect) const { |
71 Region opaque_region; | 113 Region opaque_region; |
72 // TODO(enne): implement me | 114 // TODO(enne): implement me |
73 return opaque_region; | 115 return opaque_region; |
74 } | 116 } |
75 | 117 |
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() { | 118 void PictureLayerTiling::InvalidateTilesWithText() { |
160 std::vector<TileMapKey> new_tiles; | 119 std::vector<TileMapKey> new_tiles; |
161 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 120 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
162 if (it->second->has_text()) | 121 if (it->second->has_text()) |
163 new_tiles.push_back(it->first); | 122 new_tiles.push_back(it->first); |
164 } | 123 } |
165 | 124 |
166 for (size_t i = 0; i < new_tiles.size(); ++i) { | 125 for (size_t i = 0; i < new_tiles.size(); ++i) { |
167 tiles_.erase(new_tiles[i]); | 126 tiles_.erase(new_tiles[i]); |
168 CreateTile(new_tiles[i].first, new_tiles[i].second); | 127 CreateTile(new_tiles[i].first, new_tiles[i].second); |
169 } | 128 } |
170 } | 129 } |
171 | 130 |
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() | 131 PictureLayerTiling::CoverageIterator::CoverageIterator() |
190 : tiling_(NULL), | 132 : tiling_(NULL), |
191 current_tile_(NULL), | 133 current_tile_(NULL), |
192 tile_i_(0), | 134 tile_i_(0), |
193 tile_j_(0), | 135 tile_j_(0), |
194 left_(0), | 136 left_(0), |
195 top_(0), | 137 top_(0), |
196 right_(-1), | 138 right_(-1), |
197 bottom_(-1) { | 139 bottom_(-1) { |
198 } | 140 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); | 273 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); |
332 texture_rect.Intersect(tiling_->ContentRect()); | 274 texture_rect.Intersect(tiling_->ContentRect()); |
333 | 275 |
334 return texture_rect; | 276 return texture_rect; |
335 } | 277 } |
336 | 278 |
337 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { | 279 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { |
338 return tiling_->tiling_data_.max_texture_size(); | 280 return tiling_->tiling_data_.max_texture_size(); |
339 } | 281 } |
340 | 282 |
283 void PictureLayerTiling::Reset() { | |
284 live_tiles_rect_ = gfx::Rect(); | |
285 tiles_.clear(); | |
286 } | |
287 | |
341 void PictureLayerTiling::UpdateTilePriorities( | 288 void PictureLayerTiling::UpdateTilePriorities( |
342 WhichTree tree, | 289 WhichTree tree, |
343 gfx::Size device_viewport, | 290 gfx::Size device_viewport, |
344 const gfx::RectF& viewport_in_layer_space, | 291 const gfx::RectF& viewport_in_layer_space, |
345 gfx::Size last_layer_bounds, | 292 gfx::Size last_layer_bounds, |
346 gfx::Size current_layer_bounds, | 293 gfx::Size current_layer_bounds, |
347 float last_layer_contents_scale, | 294 float last_layer_contents_scale, |
348 float current_layer_contents_scale, | 295 float current_layer_contents_scale, |
349 const gfx::Transform& last_screen_transform, | 296 const gfx::Transform& last_screen_transform, |
350 const gfx::Transform& current_screen_transform, | 297 const gfx::Transform& current_screen_transform, |
351 int current_source_frame_number, | 298 int current_source_frame_number, |
352 double current_frame_time, | 299 double current_frame_time, |
353 bool store_screen_space_quads_on_tiles, | 300 bool store_screen_space_quads_on_tiles, |
354 size_t max_tiles_for_interest_area) { | 301 size_t max_tiles_for_interest_area) { |
355 if (ContentRect().IsEmpty()) | 302 if (ContentRect().IsEmpty()) |
356 return; | 303 return; |
357 | 304 |
305 gfx::Rect viewport_in_content_space = | |
306 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, | |
307 contents_scale_)); | |
308 | |
309 gfx::Size tile_size = tiling_data_.max_texture_size(); | |
310 int64 interest_rect_area = | |
311 max_tiles_for_interest_area * tile_size.width() * tile_size.height(); | |
312 | |
313 gfx::Rect interest_rect = ExpandRectEquallyToAreaBoundedBy( | |
314 viewport_in_content_space, | |
315 interest_rect_area, | |
316 ContentRect()); | |
317 DCHECK(ContentRect().Contains(interest_rect)); | |
318 | |
319 SetLiveTilesRect(interest_rect); | |
320 | |
358 bool first_update_in_new_source_frame = | 321 bool first_update_in_new_source_frame = |
359 current_source_frame_number != last_source_frame_number_; | 322 current_source_frame_number != last_source_frame_number_; |
360 | 323 |
361 bool first_update_in_new_impl_frame = | 324 bool first_update_in_new_impl_frame = |
362 current_frame_time != last_impl_frame_time_; | 325 current_frame_time != last_impl_frame_time_; |
363 | 326 |
364 // In pending tree, this is always called. We update priorities: | 327 // In pending tree, this is always called. We update priorities: |
365 // - Immediately after a commit (first_update_in_new_source_frame). | 328 // - Immediately after a commit (first_update_in_new_source_frame). |
366 // - On animation ticks after the first frame in the tree | 329 // - On animation ticks after the first frame in the tree |
367 // (first_update_in_new_impl_frame). | 330 // (first_update_in_new_impl_frame). |
368 // In active tree, this is only called during draw. We update priorities: | 331 // 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 | 332 // - On draw if properties were not already computed by the pending tree |
370 // and activated for the frame (first_update_in_new_impl_frame). | 333 // 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) | 334 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame) |
372 return; | 335 return; |
373 | 336 |
374 double time_delta = 0; | 337 double time_delta = 0.0; |
375 if (last_impl_frame_time_ != 0 && last_layer_bounds == current_layer_bounds) | 338 if (last_impl_frame_time_ != 0.0 && |
339 last_layer_bounds == current_layer_bounds) | |
376 time_delta = current_frame_time - last_impl_frame_time_; | 340 time_delta = current_frame_time - last_impl_frame_time_; |
377 | 341 |
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); | 342 gfx::Rect view_rect(device_viewport); |
412 float current_scale = current_layer_contents_scale / contents_scale_; | 343 float current_scale = current_layer_contents_scale / contents_scale_; |
413 float last_scale = last_layer_contents_scale / contents_scale_; | 344 float last_scale = last_layer_contents_scale / contents_scale_; |
414 | 345 |
415 // Fast path tile priority calculation when both transforms are translations. | 346 // Fast path tile priority calculation when both transforms are translations. |
416 if (last_screen_transform.IsIdentityOrTranslation() && | 347 if (last_screen_transform.IsIdentityOrTranslation() && |
417 current_screen_transform.IsIdentityOrTranslation()) { | 348 current_screen_transform.IsIdentityOrTranslation()) { |
418 gfx::Vector2dF current_offset( | 349 gfx::Vector2dF current_offset( |
419 current_screen_transform.matrix().get(0, 3), | 350 current_screen_transform.matrix().get(0, 3), |
420 current_screen_transform.matrix().get(1, 3)); | 351 current_screen_transform.matrix().get(1, 3)); |
421 gfx::Vector2dF last_offset( | 352 gfx::Vector2dF last_offset( |
422 last_screen_transform.matrix().get(0, 3), | 353 last_screen_transform.matrix().get(0, 3), |
423 last_screen_transform.matrix().get(1, 3)); | 354 last_screen_transform.matrix().get(1, 3)); |
424 | 355 |
425 for (TilingData::Iterator iter(&tiling_data_, prioritized_rect); | 356 for (TilingData::Iterator iter(&tiling_data_, interest_rect); |
426 iter; ++iter) { | 357 iter; ++iter) { |
427 TileMap::iterator find = tiles_.find(iter.index()); | 358 TileMap::iterator find = tiles_.find(iter.index()); |
428 if (find == tiles_.end()) | 359 if (find == tiles_.end()) |
429 continue; | 360 continue; |
430 Tile* tile = find->second.get(); | 361 Tile* tile = find->second.get(); |
431 | 362 |
432 gfx::Rect tile_bounds = | 363 gfx::Rect tile_bounds = |
433 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | 364 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); |
434 gfx::RectF current_screen_rect = gfx::ScaleRect( | 365 gfx::RectF current_screen_rect = gfx::ScaleRect( |
435 tile_bounds, | 366 tile_bounds, |
(...skipping 12 matching lines...) Expand all Loading... | |
448 last_screen_rect, current_screen_rect, time_delta, view_rect); | 379 last_screen_rect, current_screen_rect, time_delta, view_rect); |
449 TilePriority priority( | 380 TilePriority priority( |
450 resolution_, | 381 resolution_, |
451 time_to_visible_in_seconds, | 382 time_to_visible_in_seconds, |
452 distance_to_visible_in_pixels); | 383 distance_to_visible_in_pixels); |
453 if (store_screen_space_quads_on_tiles) | 384 if (store_screen_space_quads_on_tiles) |
454 priority.set_current_screen_quad(gfx::QuadF(current_screen_rect)); | 385 priority.set_current_screen_quad(gfx::QuadF(current_screen_rect)); |
455 tile->SetPriority(tree, priority); | 386 tile->SetPriority(tree, priority); |
456 } | 387 } |
457 } else { | 388 } else { |
458 for (TilingData::Iterator iter(&tiling_data_, prioritized_rect); | 389 for (TilingData::Iterator iter(&tiling_data_, interest_rect); |
459 iter; ++iter) { | 390 iter; ++iter) { |
460 TileMap::iterator find = tiles_.find(iter.index()); | 391 TileMap::iterator find = tiles_.find(iter.index()); |
461 if (find == tiles_.end()) | 392 if (find == tiles_.end()) |
462 continue; | 393 continue; |
463 Tile* tile = find->second.get(); | 394 Tile* tile = find->second.get(); |
464 | 395 |
465 gfx::Rect tile_bounds = | 396 gfx::Rect tile_bounds = |
466 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | 397 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); |
467 gfx::RectF current_layer_content_rect = gfx::ScaleRect( | 398 gfx::RectF current_layer_content_rect = gfx::ScaleRect( |
468 tile_bounds, | 399 tile_bounds, |
(...skipping 27 matching lines...) Expand all Loading... | |
496 &clipped)); | 427 &clipped)); |
497 } | 428 } |
498 tile->SetPriority(tree, priority); | 429 tile->SetPriority(tree, priority); |
499 } | 430 } |
500 } | 431 } |
501 | 432 |
502 last_source_frame_number_ = current_source_frame_number; | 433 last_source_frame_number_ = current_source_frame_number; |
503 last_impl_frame_time_ = current_frame_time; | 434 last_impl_frame_time_ = current_frame_time; |
504 } | 435 } |
505 | 436 |
437 void PictureLayerTiling::SetLiveTilesRect( | |
438 const gfx::Rect& new_live_tiles_rect_input) { | |
enne (OOO)
2013/04/10 20:25:30
This function should take a gfx::Rect by value.
| |
439 gfx::Rect new_live_tiles_rect = new_live_tiles_rect_input; | |
440 gfx::Rect content_rect = | |
enne (OOO)
2013/04/10 20:25:30
I'd really rather just dcheck this than intersect
whunt
2013/04/10 20:52:30
If SetLiveTilesRect can be made private we can use
| |
441 gfx::ToEnclosingRect(gfx::ScaleRect(gfx::Rect(layer_bounds_), | |
442 contents_scale_)); | |
443 new_live_tiles_rect.Intersect(content_rect); | |
444 if (live_tiles_rect_ == new_live_tiles_rect) | |
445 return; | |
446 | |
447 // Iterate to delete all tiles outside of our new live_tiles rect. | |
448 for (TilingData::DifferenceIterator iter(&tiling_data_, | |
449 live_tiles_rect_, | |
450 new_live_tiles_rect); | |
451 iter; | |
452 ++iter) { | |
453 TileMapKey key(iter.index()); | |
454 TileMap::iterator found = tiles_.find(key); | |
455 if (found != tiles_.end()) { | |
enne (OOO)
2013/04/10 20:25:30
This change seems unnecessary.
whunt
2013/04/10 20:52:30
It was introduced during debugging and can be dele
| |
456 if (found != tiles_.end() && | |
457 !new_live_tiles_rect.Intersects(found->second->content_rect())) | |
458 tiles_.erase(found); | |
459 } | |
460 } | |
461 | |
462 // Iterate to allocate new tiles for all regions with newly exposed area. | |
463 for (TilingData::DifferenceIterator iter(&tiling_data_, | |
464 new_live_tiles_rect, | |
465 live_tiles_rect_); | |
466 iter; | |
467 ++iter) { | |
468 TileMapKey key(iter.index()); | |
469 CreateTile(key.first, key.second); | |
470 } | |
471 | |
472 live_tiles_rect_ = new_live_tiles_rect; | |
473 } | |
474 | |
506 void PictureLayerTiling::DidBecomeActive() { | 475 void PictureLayerTiling::DidBecomeActive() { |
507 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 476 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
508 it->second->SetPriority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); | 477 it->second->SetPriority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); |
509 it->second->SetPriority(PENDING_TREE, TilePriority()); | 478 it->second->SetPriority(PENDING_TREE, TilePriority()); |
510 | 479 |
511 // Tile holds a ref onto a picture pile. If the tile never gets invalidated | 480 // 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 | 481 // 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 | 482 // 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 | 483 // will cause PicturePileImpls and their clones to get deleted once the |
515 // corresponding PictureLayerImpl and any in flight raster jobs go out of | 484 // corresponding PictureLayerImpl and any in flight raster jobs go out of |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
621 | 590 |
622 // If our delta is less then our event distance, we're done. | 591 // If our delta is less then our event distance, we're done. |
623 if (delta < event.distance) | 592 if (delta < event.distance) |
624 break; | 593 break; |
625 } | 594 } |
626 | 595 |
627 return gfx::Rect(origin_x, origin_y, width, height); | 596 return gfx::Rect(origin_x, origin_y, width, height); |
628 } | 597 } |
629 | 598 |
630 } // namespace cc | 599 } // namespace cc |
OLD | NEW |