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

Unified Diff: cc/resources/picture_pile_base.cc

Issue 196023015: Revert of cc: Replace recorded region with direct map lookup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
« no previous file with comments | « cc/resources/picture_pile_base.h ('k') | cc/resources/prioritized_tile_set_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/picture_pile_base.cc
diff --git a/cc/resources/picture_pile_base.cc b/cc/resources/picture_pile_base.cc
index 4f04fddec7108b1de02d05d0c68a38079efd4972..2c87f596c800b708d2e6f3218397b420f1942a31 100644
--- a/cc/resources/picture_pile_base.cc
+++ b/cc/resources/picture_pile_base.cc
@@ -44,8 +44,7 @@
slow_down_raster_scale_factor_for_debug_(0),
contents_opaque_(false),
show_debug_picture_borders_(false),
- clear_canvas_with_debug_color_(kDefaultClearCanvasSetting),
- has_any_recordings_(false) {
+ clear_canvas_with_debug_color_(kDefaultClearCanvasSetting) {
tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize));
tile_grid_info_.fTileInterval.setEmpty();
tile_grid_info_.fMargin.setEmpty();
@@ -55,7 +54,7 @@
PicturePileBase::PicturePileBase(const PicturePileBase* other)
: picture_map_(other->picture_map_),
tiling_(other->tiling_),
- recorded_viewport_(other->recorded_viewport_),
+ recorded_region_(other->recorded_region_),
min_contents_scale_(other->min_contents_scale_),
tile_grid_info_(other->tile_grid_info_),
background_color_(other->background_color_),
@@ -63,13 +62,13 @@
other->slow_down_raster_scale_factor_for_debug_),
contents_opaque_(other->contents_opaque_),
show_debug_picture_borders_(other->show_debug_picture_borders_),
- clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
- has_any_recordings_(other->has_any_recordings_) {}
-
-PicturePileBase::PicturePileBase(const PicturePileBase* other,
- unsigned thread_index)
+ clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_) {
+}
+
+PicturePileBase::PicturePileBase(
+ const PicturePileBase* other, unsigned thread_index)
: tiling_(other->tiling_),
- recorded_viewport_(other->recorded_viewport_),
+ recorded_region_(other->recorded_region_),
min_contents_scale_(other->min_contents_scale_),
tile_grid_info_(other->tile_grid_info_),
background_color_(other->background_color_),
@@ -77,8 +76,7 @@
other->slow_down_raster_scale_factor_for_debug_),
contents_opaque_(other->contents_opaque_),
show_debug_picture_borders_(other->show_debug_picture_borders_),
- clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
- has_any_recordings_(other->has_any_recordings_) {
+ clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_) {
for (PictureMap::const_iterator it = other->picture_map_.begin();
it != other->picture_map_.end();
++it) {
@@ -95,8 +93,6 @@
gfx::Size old_size = size();
tiling_.SetTotalSize(new_size);
-
- has_any_recordings_ = false;
// Find all tiles that contain any pixels outside the new size.
std::vector<PictureMapKey> to_erase;
@@ -108,18 +104,13 @@
it != picture_map_.end();
++it) {
const PictureMapKey& key = it->first;
- if (key.first < min_toss_x && key.second < min_toss_y) {
- has_any_recordings_ |= !!it->second.GetPicture();
+ if (key.first < min_toss_x && key.second < min_toss_y)
continue;
- }
to_erase.push_back(key);
}
for (size_t i = 0; i < to_erase.size(); ++i)
picture_map_.erase(to_erase[i]);
-
- // Don't waste time in Resize figuring out what these hints should be.
- recorded_viewport_ = gfx::Rect();
}
void PicturePileBase::SetMinContentsScale(float min_contents_scale) {
@@ -175,6 +166,18 @@
picture_map_.clear();
}
+void PicturePileBase::UpdateRecordedRegion() {
+ recorded_region_.Clear();
+ for (PictureMap::const_iterator it = picture_map_.begin();
+ it != picture_map_.end();
+ ++it) {
+ if (it->second.GetPicture()) {
+ const PictureMapKey& key = it->first;
+ recorded_region_.Union(tile_bounds(key.first, key.second));
+ }
+ }
+}
+
bool PicturePileBase::HasRecordingAt(int x, int y) {
PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y));
if (found == picture_map_.end())
@@ -189,28 +192,7 @@
gfx::Rect layer_rect = gfx::ScaleToEnclosingRect(
content_rect, 1.f / contents_scale);
layer_rect.Intersect(gfx::Rect(tiling_.total_size()));
-
- // Common case inside of viewport to avoid the slower map lookups.
- if (recorded_viewport_.Contains(layer_rect)) {
- // Sanity check that there are no false positives in recorded_viewport_.
- DCHECK(CanRasterSlowTileCheck(layer_rect));
- return true;
- }
-
- return CanRasterSlowTileCheck(layer_rect);
-}
-
-bool PicturePileBase::CanRasterSlowTileCheck(
- const gfx::Rect& layer_rect) const {
- for (TilingData::Iterator tile_iter(&tiling_, layer_rect); tile_iter;
- ++tile_iter) {
- PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index());
- if (map_iter == picture_map_.end())
- return false;
- if (!map_iter->second.GetPicture())
- return false;
- }
- return true;
+ return recorded_region_.Contains(layer_rect);
}
gfx::Rect PicturePileBase::PaddedRect(const PictureMapKey& key) {
« no previous file with comments | « cc/resources/picture_pile_base.h ('k') | cc/resources/prioritized_tile_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698