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

Side by Side Diff: cc/tiles/picture_layer_tiling.cc

Issue 2825853002: Improvements to uses of base::SmallMap (Closed)
Patch Set: Review comments Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « cc/tiles/picture_layer_tiling.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/tiles/picture_layer_tiling.h" 5 #include "cc/tiles/picture_layer_tiling.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 #include <limits> 11 #include <limits>
12 #include <set> 12 #include <set>
13 13
14 #include "base/containers/small_map.h" 14 #include "base/containers/flat_map.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/numerics/safe_conversions.h" 17 #include "base/numerics/safe_conversions.h"
18 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
19 #include "base/trace_event/trace_event_argument.h" 19 #include "base/trace_event/trace_event_argument.h"
20 #include "cc/base/math_util.h" 20 #include "cc/base/math_util.h"
21 #include "cc/raster/raster_source.h" 21 #include "cc/raster/raster_source.h"
22 #include "cc/tiles/prioritized_tile.h" 22 #include "cc/tiles/prioritized_tile.h"
23 #include "cc/tiles/tile.h" 23 #include "cc/tiles/tile.h"
24 #include "cc/tiles/tile_priority.h" 24 #include "cc/tiles/tile_priority.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 DCHECK(tree_ != ACTIVE_TREE || !client_->GetPendingOrActiveTwinTiling(this)); 250 DCHECK(tree_ != ACTIVE_TREE || !client_->GetPendingOrActiveTwinTiling(this));
251 RemoveTilesInRegion(layer_invalidation, true /* recreate tiles */); 251 RemoveTilesInRegion(layer_invalidation, true /* recreate tiles */);
252 } 252 }
253 253
254 void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_invalidation, 254 void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_invalidation,
255 bool recreate_tiles) { 255 bool recreate_tiles) {
256 // We only invalidate the active tiling when it's orphaned: it has no pending 256 // We only invalidate the active tiling when it's orphaned: it has no pending
257 // twin, so it's slated for removal in the future. 257 // twin, so it's slated for removal in the future.
258 if (live_tiles_rect_.IsEmpty()) 258 if (live_tiles_rect_.IsEmpty())
259 return; 259 return;
260 // Pick 16 for the size of the SmallMap before it promotes to a unordered_map. 260
261 // 4x4 tiles should cover most small invalidations, and walking a vector of 261 base::flat_map<TileMapKey, gfx::Rect> remove_tiles;
262 // 16 is fast enough. If an invalidation is huge we will fall back to a
263 // unordered_map instead of a vector in the SmallMap.
264 base::SmallMap<std::unordered_map<TileMapKey, gfx::Rect, TileMapKeyHash>, 16>
265 remove_tiles;
266 gfx::Rect expanded_live_tiles_rect = 262 gfx::Rect expanded_live_tiles_rect =
267 tiling_data_.ExpandRectToTileBounds(live_tiles_rect_); 263 tiling_data_.ExpandRectToTileBounds(live_tiles_rect_);
268 for (Region::Iterator iter(layer_invalidation); iter.has_rect(); 264 for (Region::Iterator iter(layer_invalidation); iter.has_rect();
269 iter.next()) { 265 iter.next()) {
270 gfx::Rect layer_rect = iter.rect(); 266 gfx::Rect layer_rect = iter.rect();
271 // The pixels which are invalid in content space. 267 // The pixels which are invalid in content space.
272 gfx::Rect invalid_content_rect = 268 gfx::Rect invalid_content_rect =
273 EnclosingContentsRectFromLayerRect(layer_rect); 269 EnclosingContentsRectFromLayerRect(layer_rect);
274 gfx::Rect coverage_content_rect = invalid_content_rect; 270 gfx::Rect coverage_content_rect = invalid_content_rect;
275 // Avoid needless work by not bothering to invalidate where there aren't 271 // Avoid needless work by not bothering to invalidate where there aren't
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 return ToEnclosingRect(raster_transform_.MapRect(gfx::RectF(layer_rect))); 945 return ToEnclosingRect(raster_transform_.MapRect(gfx::RectF(layer_rect)));
950 } 946 }
951 947
952 gfx::Rect PictureLayerTiling::EnclosingLayerRectFromContentsRect( 948 gfx::Rect PictureLayerTiling::EnclosingLayerRectFromContentsRect(
953 const gfx::Rect& contents_rect) const { 949 const gfx::Rect& contents_rect) const {
954 return ToEnclosingRect( 950 return ToEnclosingRect(
955 raster_transform_.InverseMapRect(gfx::RectF(contents_rect))); 951 raster_transform_.InverseMapRect(gfx::RectF(contents_rect)));
956 } 952 }
957 953
958 } // namespace cc 954 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/picture_layer_tiling.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698