diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 06:51:56 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 06:51:56 +0000 |
commit | 8b09c34460ec0f1a41fc9f01049ac52d6ecea660 (patch) | |
tree | d93adba84e5a33b6b2aa0c66eebb569f74eb5e6f /cc | |
parent | 25eaf9b34c24d45b5c6f4bdb1c98ae20ae539d1f (diff) | |
download | chromium_src-8b09c34460ec0f1a41fc9f01049ac52d6ecea660.zip chromium_src-8b09c34460ec0f1a41fc9f01049ac52d6ecea660.tar.gz chromium_src-8b09c34460ec0f1a41fc9f01049ac52d6ecea660.tar.bz2 |
Revert of cc: Replace recorded region with direct map lookup (https://codereview.chromium.org/196343005/)
Reason for revert:
Probably broke telemetry's testMeasurementSmoke (which only runs on the cq and not the main waterfall for some reason): http://crbug.com/350697
Original issue's description:
> 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=b/13302269
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=256953
TBR=danakj@chromium.org,vmpstr@chromium.org,enne@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=b/13302269
Review URL: https://codereview.chromium.org/196023015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257051 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/picture_layer.cc | 1 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl.cc | 10 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_unittest.cc | 27 | ||||
-rw-r--r-- | cc/layers/picture_layer_unittest.cc | 2 | ||||
-rw-r--r-- | cc/resources/picture_pile.cc | 12 | ||||
-rw-r--r-- | cc/resources/picture_pile_base.cc | 62 | ||||
-rw-r--r-- | cc/resources/picture_pile_base.h | 20 | ||||
-rw-r--r-- | cc/resources/prioritized_tile_set_unittest.cc | 2 | ||||
-rw-r--r-- | cc/resources/tile_manager_perftest.cc | 2 | ||||
-rw-r--r-- | cc/resources/tile_manager_unittest.cc | 2 | ||||
-rw-r--r-- | cc/test/fake_picture_layer_tiling_client.cc | 18 | ||||
-rw-r--r-- | cc/test/fake_picture_pile_impl.cc | 29 | ||||
-rw-r--r-- | cc/test/fake_picture_pile_impl.h | 12 |
13 files changed, 97 insertions, 102 deletions
diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index 3a474d3..6f08b08 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -43,6 +43,7 @@ void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) { // Using layer_impl because either bounds() or paint_properties().bounds // may disagree and either one could have been pushed to layer_impl. pile_->Resize(gfx::Size()); + pile_->UpdateRecordedRegion(); } else if (update_source_frame_number_ == layer_tree_host()->source_frame_number()) { // If update called, then pile size must match bounds pushed to impl layer. diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 2006c51..735e4a4 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -864,7 +864,8 @@ PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { PictureLayerTiling* tiling = tilings_->AddTiling(contents_scale); - DCHECK(pile_->HasRecordings()); + const Region& recorded = pile_->recorded_region(); + DCHECK(!recorded.IsEmpty()); if (twin_layer_ && twin_layer_->ShouldUseGpuRasterization() == ShouldUseGpuRasterization()) @@ -1176,7 +1177,7 @@ void PictureLayerImpl::ResetRasterScale() { bool PictureLayerImpl::CanHaveTilings() const { if (!DrawsContent()) return false; - if (!pile_->HasRecordings()) + if (pile_->recorded_region().IsEmpty()) return false; return true; } @@ -1221,6 +1222,11 @@ void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { state->Set("pictures", pile_->AsValue().release()); state->Set("invalidation", invalidation_.AsValue().release()); + Region unrecorded_region(gfx::Rect(pile_->size())); + unrecorded_region.Subtract(pile_->recorded_region()); + if (!unrecorded_region.IsEmpty()) + state->Set("unrecorded_region", unrecorded_region.AsValue().release()); + scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), contents_scale_x(), diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index e27a0e6..59bcfd9 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -489,10 +489,12 @@ TEST_F(PictureLayerImplTest, AddTilesFromNewRecording) { ++iter) { EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); // Ensure there is a recording for this tile. - bool in_pending = pending_pile->CanRaster(tiling->contents_scale(), - iter.full_tile_geometry_rect()); - bool in_active = active_pile->CanRaster(tiling->contents_scale(), - iter.full_tile_geometry_rect()); + gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( + iter.full_tile_geometry_rect(), 1.f / tiling->contents_scale()); + layer_rect.Intersect(gfx::Rect(layer_bounds)); + + bool in_pending = pending_pile->recorded_region().Contains(layer_rect); + bool in_active = active_pile->recorded_region().Contains(layer_rect); if (in_pending && !in_active) EXPECT_EQ(pending_pile, iter->picture_pile()); @@ -632,7 +634,7 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { gfx::Size layer_bounds(1300, 1900); scoped_refptr<FakePicturePileImpl> empty_pile = - FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); + FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 0)); scoped_refptr<FakePicturePileImpl> valid_pile = FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); @@ -1319,13 +1321,13 @@ TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { gfx::Size tile_size(100, 100); scoped_refptr<FakePicturePileImpl> pending_pile = FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); - // This pile will create tilings, but has no recordings so will not create any - // tiles. This is attempting to simulate scrolling past the end of recorded - // content on the active layer, where the recordings are so far away that - // no tiles are created. + // An arbitrary bogus outside the layer recording. Enough for the layer to + // think it can create tiles, but not in bounds so all tiles are null. + Region active_recorded_region; + active_recorded_region.Union(gfx::Rect(1000, 1000, 1, 1)); scoped_refptr<FakePicturePileImpl> active_pile = - FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( - tile_size, layer_bounds); + FakePicturePileImpl::CreatePileWithRecordedRegion( + tile_size, layer_bounds, active_recorded_region); SetupTrees(pending_pile, active_pile); pending_layer_->set_fixed_tile_size(tile_size); active_layer_->set_fixed_tile_size(tile_size); @@ -1338,7 +1340,8 @@ TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); // Since the active layer has no tiles at all, the pending layer doesn't - // need content in order to activate. + // need content in order to activate. This is attempting to simulate + // scrolling past the end of recorded content on the active layer. pending_layer_->MarkVisibleResourcesAsRequired(); AssertNoTilesRequired(pending_layer_->HighResTiling()); AssertNoTilesRequired(pending_layer_->LowResTiling()); diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc index aac795c..6f2f940 100644 --- a/cc/layers/picture_layer_unittest.cc +++ b/cc/layers/picture_layer_unittest.cc @@ -58,7 +58,7 @@ TEST(PictureLayerTest, NoTilesIfEmptyBounds) { EXPECT_FALSE(layer_impl->CanHaveTilings()); EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); EXPECT_TRUE(layer_impl->pile()->size() == gfx::Size(0, 0)); - EXPECT_FALSE(layer_impl->pile()->HasRecordings()); + EXPECT_TRUE(layer_impl->pile()->recorded_region().IsEmpty()); } #ifndef NDEBUG proxy.SetCurrentThreadIsImplThread(false); diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc index abd18f6..43b13c5 100644 --- a/cc/resources/picture_pile.cc +++ b/cc/resources/picture_pile.cc @@ -164,8 +164,6 @@ bool PicturePile::Update( -kPixelDistanceToRecord, -kPixelDistanceToRecord, -kPixelDistanceToRecord); - recorded_viewport_ = interest_rect; - recorded_viewport_.Intersect(gfx::Rect(size())); bool invalidated = false; for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { @@ -207,8 +205,11 @@ bool PicturePile::Update( std::vector<gfx::Rect> record_rects; ClusterTiles(invalid_tiles, &record_rects); - if (record_rects.empty()) + if (record_rects.empty()) { + if (invalidated) + UpdateRecordedRegion(); return invalidated; + } for (std::vector<gfx::Rect>::iterator it = record_rects.begin(); it != record_rects.end(); @@ -244,7 +245,6 @@ bool PicturePile::Update( stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); } - bool found_tile_for_recorded_picture = false; for (TilingData::Iterator it(&tiling_, record_rect); it; ++it) { const PictureMapKey& key = it.index(); @@ -252,13 +252,11 @@ bool PicturePile::Update( if (record_rect.Contains(tile)) { PictureInfo& info = picture_map_[key]; info.SetPicture(picture); - found_tile_for_recorded_picture = true; } } - DCHECK(found_tile_for_recorded_picture); } - has_any_recordings_ = true; + UpdateRecordedRegion(); return true; } diff --git a/cc/resources/picture_pile_base.cc b/cc/resources/picture_pile_base.cc index 4f04fdd..2c87f59 100644 --- a/cc/resources/picture_pile_base.cc +++ b/cc/resources/picture_pile_base.cc @@ -44,8 +44,7 @@ PicturePileBase::PicturePileBase() 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() 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 @@ PicturePileBase::PicturePileBase(const PicturePileBase* other) 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_) { +} -PicturePileBase::PicturePileBase(const PicturePileBase* other, - unsigned thread_index) +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 @@ PicturePileBase::PicturePileBase(const PicturePileBase* other, 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) { @@ -96,8 +94,6 @@ void PicturePileBase::Resize(const gfx::Size& new_size) { 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; int min_toss_x = tiling_.FirstBorderTileXIndexFromSrcCoord( @@ -108,18 +104,13 @@ void PicturePileBase::Resize(const gfx::Size& new_size) { 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 @@ void PicturePileBase::Clear() { 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 @@ bool PicturePileBase::CanRaster(float contents_scale, 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) { diff --git a/cc/resources/picture_pile_base.h b/cc/resources/picture_pile_base.h index afdf1d9..26f6bdb 100644 --- a/cc/resources/picture_pile_base.h +++ b/cc/resources/picture_pile_base.h @@ -33,15 +33,15 @@ class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> { gfx::Size size() const { return tiling_.total_size(); } void SetMinContentsScale(float min_contents_scale); + void UpdateRecordedRegion(); + const Region& recorded_region() const { return recorded_region_; } + int num_tiles_x() const { return tiling_.num_tiles_x(); } int num_tiles_y() const { return tiling_.num_tiles_y(); } gfx::Rect tile_bounds(int x, int y) const { return tiling_.TileBounds(x, y); } bool HasRecordingAt(int x, int y); bool CanRaster(float contents_scale, const gfx::Rect& content_rect); - // If this pile contains any valid recordings. May have false positives. - bool HasRecordings() const { return has_any_recordings_; } - static void ComputeTileGridInfo(const gfx::Size& tile_grid_size, SkTileGridPicture::TileGridInfo* info); @@ -84,22 +84,21 @@ class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> { virtual ~PicturePileBase(); + void SetRecordedRegionForTesting(const Region& recorded_region) { + recorded_region_ = recorded_region; + } + int buffer_pixels() const { return tiling_.border_texels(); } void Clear(); gfx::Rect PaddedRect(const PictureMapKey& key); gfx::Rect PadRect(const gfx::Rect& rect); - // An internal CanRaster check that goes to the picture_map rather than - // using the recorded_viewport hint. - bool CanRasterSlowTileCheck(const gfx::Rect& layer_rect) const; - // A picture pile is a tiled set of pictures. The picture map is a map of tile // indices to picture infos. PictureMap picture_map_; TilingData tiling_; - // If non-empty, all pictures tiles inside this rect are recorded. - gfx::Rect recorded_viewport_; + Region recorded_region_; float min_contents_scale_; SkTileGridPicture::TileGridInfo tile_grid_info_; SkColor background_color_; @@ -107,9 +106,6 @@ class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> { bool contents_opaque_; bool show_debug_picture_borders_; bool clear_canvas_with_debug_color_; - // A hint about whether there are any recordings. This may be a false - // positive. - bool has_any_recordings_; private: void SetBufferPixels(int buffer_pixels); diff --git a/cc/resources/prioritized_tile_set_unittest.cc b/cc/resources/prioritized_tile_set_unittest.cc index 3f20dbe..a74cc6d 100644 --- a/cc/resources/prioritized_tile_set_unittest.cc +++ b/cc/resources/prioritized_tile_set_unittest.cc @@ -61,7 +61,7 @@ class PrioritizedTileSetTest : public testing::Test { 1).Pass(); tile_manager_.reset( new FakeTileManager(&tile_manager_client_, resource_provider_.get())); - picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile(); + picture_pile_ = FakePicturePileImpl::CreatePile(); } scoped_refptr<Tile> CreateTile() { diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc index d2a8ccd..4a85b6a 100644 --- a/cc/resources/tile_manager_perftest.cc +++ b/cc/resources/tile_manager_perftest.cc @@ -46,7 +46,7 @@ class TileManagerPerfTest : public testing::Test { make_scoped_ptr(new FakeTileManager(&tile_manager_client_, resource_provider_.get(), raster_task_limit_bytes)); - picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile(); + picture_pile_ = FakePicturePileImpl::CreatePile(); } GlobalStateThatImpactsTilePriority GlobalStateForTest() { diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc index 2493312..70260e3 100644 --- a/cc/resources/tile_manager_unittest.cc +++ b/cc/resources/tile_manager_unittest.cc @@ -38,7 +38,7 @@ class TileManagerTest : public testing::TestWithParam<bool>, memory_limit_policy_ = memory_limit_policy; max_tiles_ = max_tiles; - picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile(); + picture_pile_ = FakePicturePileImpl::CreatePile(); SetTreePriority(tree_priority); } diff --git a/cc/test/fake_picture_layer_tiling_client.cc b/cc/test/fake_picture_layer_tiling_client.cc index 4289b9d4..36d1eee 100644 --- a/cc/test/fake_picture_layer_tiling_client.cc +++ b/cc/test/fake_picture_layer_tiling_client.cc @@ -6,14 +6,26 @@ #include <limits> -#include "cc/test/fake_picture_pile_impl.h" #include "cc/test/fake_tile_manager.h" namespace cc { +class FakeInfinitePicturePileImpl : public PicturePileImpl { + public: + FakeInfinitePicturePileImpl() { + gfx::Size size(std::numeric_limits<int>::max(), + std::numeric_limits<int>::max()); + Resize(size); + recorded_region_ = Region(gfx::Rect(size)); + } + + protected: + virtual ~FakeInfinitePicturePileImpl() {} +}; + FakePictureLayerTilingClient::FakePictureLayerTilingClient() : tile_manager_(new FakeTileManager(&tile_manager_client_)), - pile_(FakePicturePileImpl::CreateInfiniteFilledPile()), + pile_(new FakeInfinitePicturePileImpl()), twin_tiling_(NULL), allow_create_tile_(true), max_tiles_for_interest_area_(10000), @@ -24,7 +36,7 @@ FakePictureLayerTilingClient::FakePictureLayerTilingClient( ResourceProvider* resource_provider) : tile_manager_( new FakeTileManager(&tile_manager_client_, resource_provider)), - pile_(FakePicturePileImpl::CreateInfiniteFilledPile()), + pile_(new FakeInfinitePicturePileImpl()), twin_tiling_(NULL), allow_create_tile_(true), max_tiles_for_interest_area_(10000), diff --git a/cc/test/fake_picture_pile_impl.cc b/cc/test/fake_picture_pile_impl.cc index 4bcf4b0..bb60034 100644 --- a/cc/test/fake_picture_pile_impl.cc +++ b/cc/test/fake_picture_pile_impl.cc @@ -23,12 +23,11 @@ scoped_refptr<FakePicturePileImpl> 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; } @@ -39,37 +38,29 @@ scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateEmptyPile( pile->tiling().SetTotalSize(layer_bounds); pile->tiling().SetMaxTextureSize(tile_size); pile->SetTileGridSize(ImplSidePaintingSettings().default_tile_size); - pile->recorded_viewport_ = gfx::Rect(); - pile->has_any_recordings_ = false; + pile->UpdateRecordedRegion(); return pile; } scoped_refptr<FakePicturePileImpl> -FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( +FakePicturePileImpl::CreatePileWithRecordedRegion( const gfx::Size& tile_size, - const gfx::Size& layer_bounds) { + const gfx::Size& layer_bounds, + const Region& recorded_region) { scoped_refptr<FakePicturePileImpl> pile(new FakePicturePileImpl()); pile->tiling().SetTotalSize(layer_bounds); pile->tiling().SetMaxTextureSize(tile_size); pile->SetTileGridSize(ImplSidePaintingSettings().default_tile_size); - // This simulates a false positive for this flag. - pile->recorded_viewport_ = gfx::Rect(); - pile->has_any_recordings_ = true; + pile->SetRecordedRegionForTesting(recorded_region); return pile; } -scoped_refptr<FakePicturePileImpl> -FakePicturePileImpl::CreateInfiniteFilledPile() { +scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreatePile() { scoped_refptr<FakePicturePileImpl> pile(new FakePicturePileImpl()); gfx::Size size(std::numeric_limits<int>::max(), std::numeric_limits<int>::max()); pile->Resize(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); + pile->recorded_region_ = Region(gfx::Rect(size)); return pile; } @@ -89,7 +80,7 @@ void FakePicturePileImpl::AddRecordingAt(int x, int y) { picture_map_[std::pair<int, int>(x, y)].SetPicture(picture); EXPECT_TRUE(HasRecordingAt(x, y)); - has_any_recordings_ = true; + UpdateRecordedRegion(); } void FakePicturePileImpl::RemoveRecordingAt(int x, int y) { @@ -102,6 +93,8 @@ void FakePicturePileImpl::RemoveRecordingAt(int x, int y) { return; picture_map_.erase(std::pair<int, int>(x, y)); EXPECT_FALSE(HasRecordingAt(x, y)); + + UpdateRecordedRegion(); } void FakePicturePileImpl::RerecordPile() { diff --git a/cc/test/fake_picture_pile_impl.h b/cc/test/fake_picture_pile_impl.h index 6bf1b88..d4ab8e0 100644 --- a/cc/test/fake_picture_pile_impl.h +++ b/cc/test/fake_picture_pile_impl.h @@ -16,13 +16,17 @@ class FakePicturePileImpl : public PicturePileImpl { static scoped_refptr<FakePicturePileImpl> CreateFilledPile( const gfx::Size& tile_size, const gfx::Size& layer_bounds); + static scoped_refptr<FakePicturePileImpl> CreateEmptyPile( const gfx::Size& tile_size, const gfx::Size& layer_bounds); - static scoped_refptr<FakePicturePileImpl> - CreateEmptyPileThatThinksItHasRecordings(const gfx::Size& tile_size, - const gfx::Size& layer_bounds); - static scoped_refptr<FakePicturePileImpl> CreateInfiniteFilledPile(); + + static scoped_refptr<FakePicturePileImpl> CreatePileWithRecordedRegion( + const gfx::Size& tile_size, + const gfx::Size& layer_bounds, + const Region& recorded_region); + + static scoped_refptr<FakePicturePileImpl> CreatePile(); TilingData& tiling() { return tiling_; } |