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

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

Issue 2825853002: Improvements to uses of base::SmallMap (Closed)
Patch Set: 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
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>
(...skipping 239 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 // Pick 16 for the size of the small_map before it promotes to a
261 // 4x4 tiles should cover most small invalidations, and walking a vector of 261 // unordered_map. 4x4 tiles should cover most small invalidations, and
262 // 16 is fast enough. If an invalidation is huge we will fall back to a 262 // walking a vector of 16 is fast enough. If an invalidation is huge we will
263 // unordered_map instead of a vector in the SmallMap. 263 // fall back to a unordered_map instead of a vector in the small_map.
264 base::SmallMap<std::unordered_map<TileMapKey, gfx::Rect, TileMapKeyHash>, 16> 264 base::small_map<std::unordered_map<TileMapKey, gfx::Rect, TileMapKeyHash>, 16>
danakj 2017/04/18 21:35:50 This should be a flat_map too
265 remove_tiles; 265 remove_tiles;
266 gfx::Rect expanded_live_tiles_rect = 266 gfx::Rect expanded_live_tiles_rect =
267 tiling_data_.ExpandRectToTileBounds(live_tiles_rect_); 267 tiling_data_.ExpandRectToTileBounds(live_tiles_rect_);
268 for (Region::Iterator iter(layer_invalidation); iter.has_rect(); 268 for (Region::Iterator iter(layer_invalidation); iter.has_rect();
269 iter.next()) { 269 iter.next()) {
270 gfx::Rect layer_rect = iter.rect(); 270 gfx::Rect layer_rect = iter.rect();
271 // The pixels which are invalid in content space. 271 // The pixels which are invalid in content space.
272 gfx::Rect invalid_content_rect = 272 gfx::Rect invalid_content_rect =
273 EnclosingContentsRectFromLayerRect(layer_rect); 273 EnclosingContentsRectFromLayerRect(layer_rect);
274 gfx::Rect coverage_content_rect = invalid_content_rect; 274 gfx::Rect coverage_content_rect = invalid_content_rect;
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 return ToEnclosingRect(raster_transform_.MapRect(gfx::RectF(layer_rect))); 949 return ToEnclosingRect(raster_transform_.MapRect(gfx::RectF(layer_rect)));
950 } 950 }
951 951
952 gfx::Rect PictureLayerTiling::EnclosingLayerRectFromContentsRect( 952 gfx::Rect PictureLayerTiling::EnclosingLayerRectFromContentsRect(
953 const gfx::Rect& contents_rect) const { 953 const gfx::Rect& contents_rect) const {
954 return ToEnclosingRect( 954 return ToEnclosingRect(
955 raster_transform_.InverseMapRect(gfx::RectF(contents_rect))); 955 raster_transform_.InverseMapRect(gfx::RectF(contents_rect)));
956 } 956 }
957 957
958 } // namespace cc 958 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698