Index: cc/resources/picture_layer_tiling_set.cc |
diff --git a/cc/resources/picture_layer_tiling_set.cc b/cc/resources/picture_layer_tiling_set.cc |
index 51896a5b5f7f29cfb287e970fb8b301aaa4b83a0..fbd1fcfc5b33126f0f9f279e6b418df586f21a4b 100644 |
--- a/cc/resources/picture_layer_tiling_set.cc |
+++ b/cc/resources/picture_layer_tiling_set.cc |
@@ -40,15 +40,109 @@ PictureLayerTilingSet::PictureLayerTilingSet(PictureLayerTilingClient* client) |
PictureLayerTilingSet::~PictureLayerTilingSet() { |
} |
-void PictureLayerTilingSet::SetClient(PictureLayerTilingClient* client) { |
- client_ = client; |
- for (size_t i = 0; i < tilings_.size(); ++i) |
- tilings_[i]->SetClient(client_); |
+void PictureLayerTilingSet::UpdateTilingsToCurrentRasterSource( |
+ RasterSource* raster_source, |
+ const gfx::Size& layer_bounds, |
+ bool solid_color, |
+ const Region& layer_invalidation, |
+ float minimum_contents_scale) { |
+ if (layer_bounds.IsEmpty() || solid_color) { |
vmpstr
2014/12/01 22:38:04
I'd like to at some point see this move to the cal
danakj
2014/12/05 22:30:44
Done. CanHaveTilings() should actually already cov
|
+ RemoveAllTilings(); |
+ return; |
+ } |
+ |
+ for (size_t i = 0; i < tilings_.size(); ++i) { |
vmpstr
2014/12/01 22:38:03
nit: would erase(remove_if) with a lambda work her
danakj
2014/12/05 22:30:44
remove_if does not work with ScopedPtrVector becau
|
+ float scale = tilings_[i]->contents_scale(); |
+ if (scale < minimum_contents_scale) { |
+ tilings_.swap(tilings_.begin() + i, tilings_.end() - 1); |
+ tilings_.pop_back(); |
+ --i; |
+ } |
+ } |
+ |
+ for (PictureLayerTiling* tiling : tilings_) { |
+ tiling->UpdateTilesToCurrentRasterSource(raster_source, layer_invalidation, |
vmpstr
2014/12/01 22:38:04
I think this function should have the word "invali
danakj
2014/12/08 16:49:25
To give my POV here.. to me "invalidate" is actual
|
+ layer_bounds); |
+ tiling->CreateMissingTilesInLiveTilesRect(); |
+ |
+ DCHECK(tiling->tile_size() == |
+ client_->CalculateTileSize(tiling->tiling_size())) |
+ << "tile_size: " << tiling->tile_size().ToString() |
+ << " tiling_size: " << tiling->tiling_size().ToString() |
+ << " CalculateTileSize: " |
+ << client_->CalculateTileSize(tiling->tiling_size()).ToString(); |
+ } |
} |
-void PictureLayerTilingSet::RemoveTilesInRegion(const Region& region) { |
- for (size_t i = 0; i < tilings_.size(); ++i) |
- tilings_[i]->RemoveTilesInRegion(region); |
+void PictureLayerTilingSet::UpdateTilingsFromPending( |
+ RasterSource* raster_source, |
+ const PictureLayerTilingSet& other, |
+ const gfx::Size& layer_bounds, |
+ bool solid_color, |
+ const Region& layer_invalidation, |
+ float minimum_contents_scale) { |
+ DCHECK_EQ(ACTIVE_TREE, client_->GetTree()); |
+ |
+ if (layer_bounds.IsEmpty() || solid_color) { |
+ RemoveAllTilings(); |
+ return; |
+ } |
+ |
+ for (size_t i = 0; i < tilings_.size(); ++i) { |
vmpstr
2014/12/01 22:38:04
This can probably be a separate function
danakj
2014/12/05 22:30:44
Done.
|
+ float scale = tilings_[i]->contents_scale(); |
+ if (scale < minimum_contents_scale) { |
+ tilings_.swap(tilings_.begin() + i, tilings_.end() - 1); |
+ tilings_.pop_back(); |
+ --i; |
+ } |
+ } |
+ |
+ for (PictureLayerTiling* tiling : tilings_) { |
+ // TODO(danakj): In the activate case can we do something simpler? Just copy |
enne (OOO)
2014/12/01 22:08:17
That sounds nice, although I think you'd still kee
vmpstr
2014/12/01 22:38:03
I agree... I think we should be able to "blit" pen
|
+ // things from the pending tree and share all the tiles? |
+ tiling->UpdateTilesToCurrentRasterSource(raster_source, layer_invalidation, |
+ layer_bounds); |
+ tiling->CreateMissingTilesInLiveTilesRect(); |
+ tiling->set_resolution(NON_IDEAL_RESOLUTION); |
+ |
+ DCHECK(tiling->tile_size() == |
+ client_->CalculateTileSize(tiling->tiling_size())) |
+ << "tile_size: " << tiling->tile_size().ToString() |
+ << " tiling_size: " << tiling->tiling_size().ToString() |
+ << " CalculateTileSize: " |
+ << client_->CalculateTileSize(tiling->tiling_size()).ToString(); |
+ } |
+ |
+ // Copy missing tilings, tiles and tiling resolutions from the pending tiling |
+ // set. |
+ for (size_t i = 0; i < other.tilings_.size(); ++i) { |
vmpstr
2014/12/01 22:38:04
nit: for (PLT* tiling : other.tilings)
danakj
2014/12/05 22:30:44
Done.
|
+ float contents_scale = other.tilings_[i]->contents_scale(); |
+ DCHECK_GE(contents_scale, minimum_contents_scale); |
+ |
+ PictureLayerTiling* this_tiling = FindTilingWithScale(contents_scale); |
+ if (!this_tiling) { |
+ scoped_ptr<PictureLayerTiling> new_tiling = |
+ PictureLayerTiling::Create(contents_scale, layer_bounds, client_); |
+ tilings_.push_back(new_tiling.Pass()); |
+ this_tiling = tilings_.back(); |
+ } |
+ this_tiling->CreateSharedTilesFromPending(*other.tilings_[i]); |
vmpstr
2014/12/01 22:38:03
I personally like this style of functionality, mod
danakj
2014/12/05 22:30:44
Done. CloneTilesAndPropertiesFrom()
|
+ this_tiling->set_resolution(other.tilings_[i]->resolution()); |
+ |
+ DCHECK_EQ(other.tilings_[i]->live_tiles_rect().ToString(), |
+ this_tiling->live_tiles_rect().ToString()); |
+ } |
+ |
+ tilings_.sort(LargestToSmallestScaleFunctor()); |
+ |
+#if DCHECK_IS_ON |
+ if (!tilings_.empty()) { |
+ size_t num_high_res = 0; |
+ for (const auto& t : tilings_) |
vmpstr
2014/12/01 22:38:03
count_if?
danakj
2014/12/05 22:30:44
Oh, cool. Done.
|
+ num_high_res += t->resolution() == HIGH_RESOLUTION ? 1 : 0; |
+ DCHECK_EQ(1u, num_high_res); |
+ } |
+#endif |
} |
void PictureLayerTilingSet::CleanUpTilings( |
@@ -91,14 +185,6 @@ void PictureLayerTilingSet::CleanUpTilings( |
} |
for (auto* tiling : to_remove) { |
- PictureLayerTiling* twin_tiling = |
- twin_set ? twin_set->FindTilingWithScale(tiling->contents_scale()) |
- : nullptr; |
- // Only remove tilings from the twin layer if they have |
- // NON_IDEAL_RESOLUTION. |
- if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION) |
- twin_set->Remove(twin_tiling); |
- |
PictureLayerTiling* recycled_twin_tiling = |
recycled_twin_set |
? recycled_twin_set->FindTilingWithScale(tiling->contents_scale()) |
@@ -113,6 +199,16 @@ void PictureLayerTilingSet::CleanUpTilings( |
} |
} |
+void PictureLayerTilingSet::RemoveNonIdealTilings() { |
+ for (size_t i = 0; i < tilings_.size(); ++i) { |
vmpstr
2014/12/01 22:38:04
nit: I'd prefer erase/remove_if, but feel free to
danakj
2014/12/05 22:30:44
Done.
|
+ PictureLayerTiling* tiling = tilings_[i]; |
+ if (tiling->resolution() == NON_IDEAL_RESOLUTION) { |
+ tilings_.erase(tilings_.begin() + i); |
+ --i; |
+ } |
+ } |
+} |
+ |
void PictureLayerTilingSet::MarkAllTilingsNonIdeal() { |
for (auto* tiling : tilings_) |
tiling->set_resolution(NON_IDEAL_RESOLUTION); |