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

Unified Diff: cc/resources/picture_layer_tiling.cc

Issue 1139063002: cc: Partial tile update for one-copy raster. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: monocle: bademacs Created 5 years, 7 months 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
Index: cc/resources/picture_layer_tiling.cc
diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc
index de2cb4a19f1cca0e9587f3943e83c2d837072fe7..3e990690e510c3d48fe1ba9b328b7de6dae8ae9e 100644
--- a/cc/resources/picture_layer_tiling.cc
+++ b/cc/resources/picture_layer_tiling.cc
@@ -9,6 +9,8 @@
#include <limits>
#include <set>
+#include "base/containers/hash_tables.h"
+#include "base/containers/small_map.h"
#include "base/logging.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_argument.h"
@@ -227,11 +229,11 @@ void PictureLayerTiling::SetRasterSourceAndResize(
// Drop tiles outside the new layer bounds if the layer shrank.
for (int i = after_right + 1; i <= before_right; ++i) {
for (int j = before_top; j <= before_bottom; ++j)
- RemoveTileAt(i, j);
+ RemoveTileAt(i, j, nullptr);
}
for (int i = before_left; i <= after_right; ++i) {
for (int j = after_bottom + 1; j <= before_bottom; ++j)
- RemoveTileAt(i, j);
+ RemoveTileAt(i, j, nullptr);
}
if (after_right > before_right) {
@@ -262,7 +264,7 @@ void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_invalidation,
// twin, so it's slated for removal in the future.
if (live_tiles_rect_.IsEmpty())
return;
- std::vector<TileMapKey> new_tile_keys;
+ base::SmallMap<base::hash_map<TileMapKey, gfx::Rect>, 16> remove_tiles;
gfx::Rect expanded_live_tiles_rect =
tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_);
for (Region::Iterator iter(layer_invalidation); iter.has_rect();
@@ -286,15 +288,20 @@ void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_invalidation,
for (
TilingData::Iterator iter(&tiling_data_, content_rect, include_borders);
iter; ++iter) {
- if (RemoveTileAt(iter.index_x(), iter.index_y())) {
- if (recreate_tiles)
- new_tile_keys.push_back(iter.index());
- }
+ // This also adds the TileMapKey to the map.
+ remove_tiles[iter.index()].Union(content_rect);
}
}
- for (const auto& key : new_tile_keys)
- CreateTile(key.first, key.second);
+ for (const auto& pair : remove_tiles) {
+ const TileMapKey& key = pair.first;
+ const gfx::Rect& invalid_content_rect = pair.second;
+ Tile::Id old_id;
+ if (RemoveTileAt(key.first, key.second, &old_id) && recreate_tiles) {
+ Tile* tile = CreateTile(key.first, key.second);
+ tile->SetInvalidated(invalid_content_rect, old_id);
+ }
+ }
}
void PictureLayerTiling::SetRasterSourceOnTiles() {
@@ -500,10 +507,12 @@ gfx::RectF PictureLayerTiling::CoverageIterator::texture_rect() const {
return texture_rect;
}
-bool PictureLayerTiling::RemoveTileAt(int i, int j) {
+bool PictureLayerTiling::RemoveTileAt(int i, int j, Tile::Id* id) {
TileMap::iterator found = tiles_.find(TileMapKey(i, j));
if (found == tiles_.end())
return false;
+ if (id)
+ *id = found->second->id();
tiles_.erase(found);
return true;
}
@@ -661,7 +670,7 @@ void PictureLayerTiling::SetLiveTilesRect(
for (TilingData::DifferenceIterator iter(&tiling_data_, live_tiles_rect_,
new_live_tiles_rect);
iter; ++iter) {
- RemoveTileAt(iter.index_x(), iter.index_y());
+ RemoveTileAt(iter.index_x(), iter.index_y(), nullptr);
}
// Iterate to allocate new tiles for all regions with newly exposed area.

Powered by Google App Engine
This is Rietveld 408576698