From 62b6fdb8d49e80c053fc6dd38548b933ba668e83 Mon Sep 17 00:00:00 2001 From: "enne@chromium.org" Date: Wed, 19 Mar 2014 05:46:33 +0000 Subject: cc: Replace recorded region with direct map lookup If the viewport is extremely large, then keeping track of the recorded region in PicturePile with an actual Region becomes extremely slow due to a large number of rects being inserted into it. The recorded region behaves as a cache to the picture map; it's a simpler way to know the state of all of the recordings contained within. In practice, the recorded region is only used for two things: a "should this pile bother to create tilings" optimization and a "can a tile be rastered in this content rect" check aka CanRaster. The optimization for "should create tilings" is replaced by a has_any_recordings_ boolean, which could have a false positive in theory (resizing to a smaller but non-empty size), but which shouldn't happen in practice. Even if it did, this would only be a performance penalty for creating no-op tilings that can't create tiles (due to CanRaster). The CanRaster check is replaced by a viewport hint, as most tiles that the tiling creates will be inside of the very large expanded viewport during recording, turning an expensive Region.Contains check to a Rect.Contains one. In the edge cases where tiles are being created outside of that expanded viewport, it will check the picture map directly. This should only happen when the user has scrolled thousands of pixels without a commit. BUG=353346 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=256953 Review URL: https://codereview.chromium.org/196343005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257852 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/test/fake_picture_pile_impl.cc | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'cc/test/fake_picture_pile_impl.cc') diff --git a/cc/test/fake_picture_pile_impl.cc b/cc/test/fake_picture_pile_impl.cc index bb60034..4bcf4b0 100644 --- a/cc/test/fake_picture_pile_impl.cc +++ b/cc/test/fake_picture_pile_impl.cc @@ -23,11 +23,12 @@ scoped_refptr FakePicturePileImpl::CreateFilledPile( pile->tiling().SetTotalSize(layer_bounds); pile->tiling().SetMaxTextureSize(tile_size); pile->SetTileGridSize(ImplSidePaintingSettings().default_tile_size); + pile->recorded_viewport_ = gfx::Rect(layer_bounds); + pile->has_any_recordings_ = true; for (int x = 0; x < pile->tiling().num_tiles_x(); ++x) { for (int y = 0; y < pile->tiling().num_tiles_y(); ++y) pile->AddRecordingAt(x, y); } - pile->UpdateRecordedRegion(); return pile; } @@ -38,29 +39,37 @@ scoped_refptr FakePicturePileImpl::CreateEmptyPile( pile->tiling().SetTotalSize(layer_bounds); pile->tiling().SetMaxTextureSize(tile_size); pile->SetTileGridSize(ImplSidePaintingSettings().default_tile_size); - pile->UpdateRecordedRegion(); + pile->recorded_viewport_ = gfx::Rect(); + pile->has_any_recordings_ = false; return pile; } scoped_refptr -FakePicturePileImpl::CreatePileWithRecordedRegion( +FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( const gfx::Size& tile_size, - const gfx::Size& layer_bounds, - const Region& recorded_region) { + const gfx::Size& layer_bounds) { scoped_refptr pile(new FakePicturePileImpl()); pile->tiling().SetTotalSize(layer_bounds); pile->tiling().SetMaxTextureSize(tile_size); pile->SetTileGridSize(ImplSidePaintingSettings().default_tile_size); - pile->SetRecordedRegionForTesting(recorded_region); + // This simulates a false positive for this flag. + pile->recorded_viewport_ = gfx::Rect(); + pile->has_any_recordings_ = true; return pile; } -scoped_refptr FakePicturePileImpl::CreatePile() { +scoped_refptr +FakePicturePileImpl::CreateInfiniteFilledPile() { scoped_refptr pile(new FakePicturePileImpl()); gfx::Size size(std::numeric_limits::max(), std::numeric_limits::max()); pile->Resize(size); - pile->recorded_region_ = Region(gfx::Rect(size)); + pile->tiling().SetTotalSize(size); + pile->tiling().SetMaxTextureSize(size); + pile->SetTileGridSize(size); + pile->recorded_viewport_ = gfx::Rect(size); + pile->has_any_recordings_ = true; + pile->AddRecordingAt(0, 0); return pile; } @@ -80,7 +89,7 @@ void FakePicturePileImpl::AddRecordingAt(int x, int y) { picture_map_[std::pair(x, y)].SetPicture(picture); EXPECT_TRUE(HasRecordingAt(x, y)); - UpdateRecordedRegion(); + has_any_recordings_ = true; } void FakePicturePileImpl::RemoveRecordingAt(int x, int y) { @@ -93,8 +102,6 @@ void FakePicturePileImpl::RemoveRecordingAt(int x, int y) { return; picture_map_.erase(std::pair(x, y)); EXPECT_FALSE(HasRecordingAt(x, y)); - - UpdateRecordedRegion(); } void FakePicturePileImpl::RerecordPile() { -- cgit v1.1