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

Unified Diff: cc/resources/picture_layer_tiling_set.cc

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/picture_layer_tiling_set.h ('k') | cc/resources/picture_pile.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 35170a0baf5e54665be05928bf9d26a51579a8e3..51896a5b5f7f29cfb287e970fb8b301aaa4b83a0 100644
--- a/cc/resources/picture_layer_tiling_set.cc
+++ b/cc/resources/picture_layer_tiling_set.cc
@@ -6,6 +6,7 @@
#include <limits>
#include <set>
+#include <vector>
namespace cc {
@@ -50,6 +51,68 @@ void PictureLayerTilingSet::RemoveTilesInRegion(const Region& region) {
tilings_[i]->RemoveTilesInRegion(region);
}
+void PictureLayerTilingSet::CleanUpTilings(
+ float min_acceptable_high_res_scale,
+ float max_acceptable_high_res_scale,
+ const std::vector<PictureLayerTiling*>& needed_tilings,
+ bool should_have_low_res,
+ PictureLayerTilingSet* twin_set,
+ PictureLayerTilingSet* recycled_twin_set) {
+ float twin_low_res_scale = 0.f;
+ if (twin_set) {
+ PictureLayerTiling* tiling =
+ twin_set->FindTilingWithResolution(LOW_RESOLUTION);
+ if (tiling)
+ twin_low_res_scale = tiling->contents_scale();
+ }
+
+ std::vector<PictureLayerTiling*> to_remove;
+ for (auto* tiling : tilings_) {
+ // Keep all tilings within the min/max scales.
+ if (tiling->contents_scale() >= min_acceptable_high_res_scale &&
+ tiling->contents_scale() <= max_acceptable_high_res_scale) {
+ continue;
+ }
+
+ // Keep low resolution tilings, if the tiling set should have them.
+ if (should_have_low_res &&
+ (tiling->resolution() == LOW_RESOLUTION ||
+ tiling->contents_scale() == twin_low_res_scale)) {
+ continue;
+ }
+
+ // Don't remove tilings that are required.
+ if (std::find(needed_tilings.begin(), needed_tilings.end(), tiling) !=
+ needed_tilings.end()) {
+ continue;
+ }
+
+ to_remove.push_back(tiling);
+ }
+
+ 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())
+ : nullptr;
+ // Remove the tiling from the recycle tree. Note that we ignore resolution,
+ // since we don't need to maintain high/low res on the recycle set.
+ if (recycled_twin_tiling)
+ recycled_twin_set->Remove(recycled_twin_tiling);
+
+ DCHECK_NE(HIGH_RESOLUTION, tiling->resolution());
+ Remove(tiling);
+ }
+}
+
void PictureLayerTilingSet::MarkAllTilingsNonIdeal() {
for (auto* tiling : tilings_)
tiling->set_resolution(NON_IDEAL_RESOLUTION);
@@ -171,16 +234,6 @@ void PictureLayerTilingSet::Remove(PictureLayerTiling* tiling) {
tilings_.erase(iter);
}
-void PictureLayerTilingSet::RemoveTilingWithScale(float scale) {
- auto iter = std::find_if(tilings_.begin(), tilings_.end(),
- [scale](const PictureLayerTiling* tiling) {
- return tiling->contents_scale() == scale;
- });
- if (iter == tilings_.end())
- return;
- tilings_.erase(iter);
-}
-
void PictureLayerTilingSet::RemoveAllTiles() {
for (size_t i = 0; i < tilings_.size(); ++i)
tilings_[i]->Reset();
« no previous file with comments | « cc/resources/picture_layer_tiling_set.h ('k') | cc/resources/picture_pile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698