diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-05 00:54:41 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-05 00:54:41 +0000 |
commit | 56a6f9060826af89b1fc8362f2f930bc59588c7f (patch) | |
tree | d2f1aea295202683a40fa50d6df333219ef7c895 | |
parent | 4adfc3b9f3248205a61829893ef7a604bb89e38b (diff) | |
download | chromium_src-56a6f9060826af89b1fc8362f2f930bc59588c7f.zip chromium_src-56a6f9060826af89b1fc8362f2f930bc59588c7f.tar.gz chromium_src-56a6f9060826af89b1fc8362f2f930bc59588c7f.tar.bz2 |
cc: Allow activating to something other than high-res
If the pending tree is only allowed to activate when it has all of its
high res visible tiles ready to draw, then this can starve activation in
cases where the pending tree could have activated earlier without a
flash.
The fix is that when the active tree has high res tiles that are not
ready to draw or are shared with the pending tree, then the pending tree
does not need those tiles to be ready before activating. To compensate
for not needing high res tiles, the pending tree may need to require low
res tiles if the active tree is drawing its low res tiles. This
strategy allows faster activation during scrolling when both the active
and pending tree may be checkerboarding or showing low res.
Pending layers are still not allowed to activate with no content if the
active layer does not exist or if the active layer has no tilings (i.e.
didn't draw any content on previous frames). This prevents newly
visible layers from activating without their content ready (which would
cause the content to incrementally appear over several frames in a
visually unappealing way).
BUG=315180
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=237385
Review URL: https://codereview.chromium.org/75883002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238836 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/layers/picture_layer_impl.cc | 92 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl.h | 9 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_unittest.cc | 122 | ||||
-rw-r--r-- | cc/resources/picture_layer_tiling.h | 8 | ||||
-rw-r--r-- | cc/resources/picture_pile_base.h | 4 | ||||
-rw-r--r-- | cc/resources/tile.h | 1 | ||||
-rw-r--r-- | cc/test/fake_picture_layer_impl.cc | 57 | ||||
-rw-r--r-- | cc/test/fake_picture_layer_impl.h | 5 | ||||
-rw-r--r-- | cc/test/fake_picture_layer_tiling_client.cc | 2 | ||||
-rw-r--r-- | cc/test/fake_picture_layer_tiling_client.h | 2 | ||||
-rw-r--r-- | cc/test/fake_picture_pile_impl.cc | 13 | ||||
-rw-r--r-- | cc/test/fake_picture_pile_impl.h | 5 |
12 files changed, 303 insertions, 17 deletions
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index a8fecb9..e0e9340 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -488,7 +488,7 @@ const Region* PictureLayerImpl::GetInvalidation() { } const PictureLayerTiling* PictureLayerImpl::GetTwinTiling( - const PictureLayerTiling* tiling) { + const PictureLayerTiling* tiling) const { if (!twin_layer_) return NULL; @@ -659,6 +659,10 @@ void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { DCHECK(ideal_contents_scale_); DCHECK_GT(tilings_->num_tilings(), 0u); + // The goal of this function is to find the minimum set of tiles that need to + // be ready to draw in order to activate without flashing content from a + // higher res on the active tree to a lower res on the pending tree. + gfx::Rect rect(visible_content_rect()); float min_acceptable_scale = @@ -675,17 +679,21 @@ void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { } } - // Mark tiles for activation in two passes. Ready to draw tiles in acceptable - // but non-ideal tilings are marked as required for activation, but any - // non-ready tiles are not marked as required. From there, any missing holes - // will need to be filled in from the high res tiling. - PictureLayerTiling* high_res = NULL; + PictureLayerTiling* low_res = NULL; + + // First pass: ready to draw tiles in acceptable but non-ideal tilings are + // marked as required for activation so that their textures are not thrown + // away; any non-ready tiles are not marked as required. Region missing_region = rect; for (size_t i = 0; i < tilings_->num_tilings(); ++i) { PictureLayerTiling* tiling = tilings_->tiling_at(i); DCHECK(tiling->has_ever_been_updated()); + if (tiling->resolution() == LOW_RESOLUTION) { + DCHECK(!low_res) << "There can only be one low res tiling"; + low_res = tiling; + } if (tiling->contents_scale() < min_acceptable_scale) continue; if (tiling->resolution() == HIGH_RESOLUTION) { @@ -711,21 +719,69 @@ void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { iter->MarkRequiredForActivation(); } } - DCHECK(high_res) << "There must be one high res tiling"; - for (PictureLayerTiling::CoverageIterator iter(high_res, - contents_scale_x(), + + // If these pointers are null (because no twin, no matching tiling, or the + // simpification just below), then high res tiles will be required to fill any + // holes left by the first pass above. If the pointers are valid, then this + // layer is allowed to skip any tiles that are not ready on its twin. + const PictureLayerTiling* twin_high_res = NULL; + const PictureLayerTiling* twin_low_res = NULL; + + // As a simplification, only allow activating to skip twin tiles that the + // active layer is also missing when both this layer and its twin have 2 + // tilings (high and low). This avoids having to iterate/track coverage of + // non-ideal tilings during the last draw call on the active layer. + if (high_res && low_res && tilings_->num_tilings() == 2 && + twin_layer_ && twin_layer_->tilings_->num_tilings() == 2) { + twin_low_res = GetTwinTiling(low_res); + if (twin_low_res) + twin_high_res = GetTwinTiling(high_res); + } + // If this layer and its twin have different transforms, then don't compare + // them and only allow activating to high res tiles, since tiles on each layer + // will be in different places on screen. + if (!twin_high_res || !twin_low_res || + draw_properties().screen_space_transform != + twin_layer_->draw_properties().screen_space_transform) { + twin_high_res = NULL; + twin_low_res = NULL; + } + + // As a second pass, mark as required any visible high res tiles not filled in + // by acceptable non-ideal tiles from the first pass. + if (MarkVisibleTilesAsRequired( + high_res, twin_high_res, contents_scale_x(), rect, missing_region)) { + // As an optional third pass, if a high res tile was skipped because its + // twin was also missing, then fall back to mark low res tiles as required + // in case the active twin is substituting those for missing high res + // content. + MarkVisibleTilesAsRequired( + low_res, twin_low_res, contents_scale_x(), rect, missing_region); + } +} + +bool PictureLayerImpl::MarkVisibleTilesAsRequired( + PictureLayerTiling* tiling, + const PictureLayerTiling* optional_twin_tiling, + float contents_scale, + gfx::Rect rect, + const Region& missing_region) const { + bool twin_had_missing_tile = false; + for (PictureLayerTiling::CoverageIterator iter(tiling, + contents_scale, rect); iter; ++iter) { + Tile* tile = *iter; // A null tile (i.e. missing recording) can just be skipped. - if (!*iter) + if (!tile) continue; // This iteration is over the visible content rect which is potentially // less conservative than projecting the viewport into the layer. // Ignore tiles that are know to be outside the viewport. - if (iter->priority(PENDING_TREE).distance_to_visible_in_pixels != 0) + if (tile->priority(PENDING_TREE).distance_to_visible_in_pixels != 0) continue; // If the missing region doesn't cover it, this tile is fully @@ -733,8 +789,20 @@ void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { if (!missing_region.Intersects(iter.geometry_rect())) continue; - iter->MarkRequiredForActivation(); + // If the twin tile doesn't exist (i.e. missing recording or so far away + // that it is outside the visible tile rect) or this tile is shared between + // with the twin, then this tile isn't required to prevent flashing. + if (optional_twin_tiling) { + Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j()); + if (!twin_tile || twin_tile == tile) { + twin_had_missing_tile = true; + continue; + } + } + + tile->MarkRequiredForActivation(); } + return twin_had_missing_tile; } void PictureLayerImpl::DoPostCommitInitialization() { diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h index 3c94301..46db1b3 100644 --- a/cc/layers/picture_layer_impl.h +++ b/cc/layers/picture_layer_impl.h @@ -60,7 +60,7 @@ class CC_EXPORT PictureLayerImpl gfx::Size content_bounds) const OVERRIDE; virtual const Region* GetInvalidation() OVERRIDE; virtual const PictureLayerTiling* GetTwinTiling( - const PictureLayerTiling* tiling) OVERRIDE; + const PictureLayerTiling* tiling) const OVERRIDE; // PushPropertiesTo active tree => pending tree. void SyncTiling(const PictureLayerTiling* tiling); @@ -91,6 +91,13 @@ class CC_EXPORT PictureLayerImpl void UpdateLCDTextStatus(bool new_status); void ResetRasterScale(); void MarkVisibleResourcesAsRequired() const; + bool MarkVisibleTilesAsRequired( + PictureLayerTiling* tiling, + const PictureLayerTiling* optional_twin_tiling, + float contents_scale, + gfx::Rect rect, + const Region& missing_region) const; + void DoPostCommitInitializationIfNeeded() { if (needs_post_commit_initialization_) DoPostCommitInitialization(); diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 2c09c63..ef69963 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -76,6 +76,13 @@ class PictureLayerImplTest : public testing::Test { host_impl_.active_tree()->LayerById(id_)); } + void SetupDefaultTreesWithFixedTileSize(gfx::Size layer_bounds, + gfx::Size tile_size) { + SetupDefaultTrees(layer_bounds); + pending_layer_->set_fixed_tile_size(tile_size); + active_layer_->set_fixed_tile_size(tile_size); + } + void SetupTrees( scoped_refptr<PicturePileImpl> pending_pile, scoped_refptr<PicturePileImpl> active_pile) { @@ -84,6 +91,14 @@ class PictureLayerImplTest : public testing::Test { SetupPendingTree(pending_pile); } + void CreateHighLowResAndSetAllTilesVisible() { + // Active layer must get updated first so pending layer can share from it. + active_layer_->CreateDefaultTilingsAndTiles(); + active_layer_->SetAllTilesVisible(); + pending_layer_->CreateDefaultTilingsAndTiles(); + pending_layer_->SetAllTilesVisible(); + } + void AddDefaultTilingsWithInvalidation(const Region& invalidation) { active_layer_->AddTiling(2.3f); active_layer_->AddTiling(1.0f); @@ -153,6 +168,20 @@ class PictureLayerImplTest : public testing::Test { active_layer_->DidLoseOutputSurface(); } + void AssertAllTilesRequired(PictureLayerTiling* tiling) { + std::vector<Tile*> tiles = tiling->AllTilesForTesting(); + for (size_t i = 0; i < tiles.size(); ++i) + EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i; + EXPECT_GT(tiles.size(), 0u); + } + + void AssertNoTilesRequired(PictureLayerTiling* tiling) { + std::vector<Tile*> tiles = tiling->AllTilesForTesting(); + for (size_t i = 0; i < tiles.size(); ++i) + EXPECT_FALSE(tiles[i]->required_for_activation()) << "i: " << i; + EXPECT_GT(tiles.size(), 0u); + } + protected: void TestTileGridAlignmentCommon() { // Layer to span 4 raster tiles in x and in y @@ -1228,6 +1257,99 @@ TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { EXPECT_GT(num_offscreen, 0); } +TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { + gfx::Size layer_bounds(400, 400); + gfx::Size tile_size(100, 100); + SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); + + // No tiles shared. + pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); + + CreateHighLowResAndSetAllTilesVisible(); + + active_layer_->SetAllTilesReady(); + + // No shared tiles and all active tiles ready, so pending can only + // activate with all high res tiles. + pending_layer_->MarkVisibleResourcesAsRequired(); + AssertAllTilesRequired(pending_layer_->HighResTiling()); + AssertNoTilesRequired(pending_layer_->LowResTiling()); +} + +TEST_F(PictureLayerImplTest, NothingRequiredIfAllHighResTilesShared) { + gfx::Size layer_bounds(400, 400); + gfx::Size tile_size(100, 100); + SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); + + CreateHighLowResAndSetAllTilesVisible(); + + Tile* some_active_tile = + active_layer_->HighResTiling()->AllTilesForTesting()[0]; + EXPECT_FALSE(some_active_tile->IsReadyToDraw()); + + // All tiles shared (no invalidation), so even though the active tree's + // tiles aren't ready, there is nothing required. + pending_layer_->MarkVisibleResourcesAsRequired(); + AssertNoTilesRequired(pending_layer_->HighResTiling()); + AssertNoTilesRequired(pending_layer_->LowResTiling()); +} + +TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { + gfx::Size layer_bounds(400, 400); + gfx::Size tile_size(100, 100); + scoped_refptr<FakePicturePileImpl> pending_pile = + FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); + // 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::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); + + CreateHighLowResAndSetAllTilesVisible(); + + // Active layer has tilings, but no tiles due to missing recordings. + EXPECT_TRUE(active_layer_->CanHaveTilings()); + EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); + 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. 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()); +} + +TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { + gfx::Size layer_bounds(400, 400); + gfx::Size tile_size(100, 100); + scoped_refptr<FakePicturePileImpl> pending_pile = + FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); + scoped_refptr<FakePicturePileImpl> active_pile = + FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); + SetupTrees(pending_pile, active_pile); + pending_layer_->set_fixed_tile_size(tile_size); + active_layer_->set_fixed_tile_size(tile_size); + + CreateHighLowResAndSetAllTilesVisible(); + + // Active layer can't have tiles. + EXPECT_FALSE(active_layer_->CanHaveTilings()); + + // All high res tiles required. This should be considered identical + // to the case where there is no active layer, to avoid flashing content. + // This can happen if a layer exists for a while and switches from + // not being able to have content to having content. + pending_layer_->MarkVisibleResourcesAsRequired(); + AssertAllTilesRequired(pending_layer_->HighResTiling()); + AssertNoTilesRequired(pending_layer_->LowResTiling()); +} + TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { gfx::Size tile_size(100, 100); gfx::Size layer_bounds(400, 400); diff --git a/cc/resources/picture_layer_tiling.h b/cc/resources/picture_layer_tiling.h index 7d7626e..dae6272 100644 --- a/cc/resources/picture_layer_tiling.h +++ b/cc/resources/picture_layer_tiling.h @@ -34,7 +34,7 @@ class CC_EXPORT PictureLayerTilingClient { gfx::Size content_bounds) const = 0; virtual const Region* GetInvalidation() = 0; virtual const PictureLayerTiling* GetTwinTiling( - const PictureLayerTiling* tiling) = 0; + const PictureLayerTiling* tiling) const = 0; protected: virtual ~PictureLayerTilingClient() {} @@ -78,6 +78,8 @@ class CC_EXPORT PictureLayerTiling { return all_tiles; } + Tile* TileAt(int i, int j) const; + // Iterate over all tiles to fill content_rect. Even if tiles are invalid // (i.e. no valid resource) this tiling should still iterate over them. // The union of all geometry_rect calls for each element iterated over should @@ -107,6 +109,9 @@ class CC_EXPORT PictureLayerTiling { CoverageIterator& operator++(); operator bool() const { return tile_j_ <= bottom_; } + int i() const { return tile_i_; } + int j() const { return tile_j_; } + private: const PictureLayerTiling* tiling_; gfx::Rect dest_rect_; @@ -192,7 +197,6 @@ class CC_EXPORT PictureLayerTiling { PictureLayerTilingClient* client); void SetLiveTilesRect(gfx::Rect live_tiles_rect); void CreateTile(int i, int j, const PictureLayerTiling* twin_tiling); - Tile* TileAt(int, int) const; // Given properties. float contents_scale_; diff --git a/cc/resources/picture_pile_base.h b/cc/resources/picture_pile_base.h index e78778a..66a26e75 100644 --- a/cc/resources/picture_pile_base.h +++ b/cc/resources/picture_pile_base.h @@ -65,6 +65,10 @@ class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> { virtual ~PicturePileBase(); + void SetRecordedRegionForTesting(const Region& recorded_region) { + recorded_region_ = recorded_region; + } + int num_raster_threads() { return num_raster_threads_; } int buffer_pixels() const { return tiling_.border_texels(); } void Clear(); diff --git a/cc/resources/tile.h b/cc/resources/tile.h index fd184a6..440c6b0 100644 --- a/cc/resources/tile.h +++ b/cc/resources/tile.h @@ -111,6 +111,7 @@ class CC_EXPORT Tile : public RefCountedManaged<Tile> { friend class PrioritizedTileSet; friend class FakeTileManager; friend class BinComparator; + friend class FakePictureLayerImpl; // Methods called by by tile manager. Tile(TileManager* tile_manager, diff --git a/cc/test/fake_picture_layer_impl.cc b/cc/test/fake_picture_layer_impl.cc index bdf40a5..6e9ffde 100644 --- a/cc/test/fake_picture_layer_impl.cc +++ b/cc/test/fake_picture_layer_impl.cc @@ -4,6 +4,10 @@ #include "cc/test/fake_picture_layer_impl.h" +#include <vector> +#include "cc/resources/tile.h" +#include "cc/trees/layer_tree_impl.h" + namespace cc { FakePictureLayerImpl::FakePictureLayerImpl( @@ -66,4 +70,57 @@ PictureLayerTiling* FakePictureLayerImpl::LowResTiling() const { return result; } +void FakePictureLayerImpl::SetAllTilesVisible() { + WhichTree tree = + layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; + + for (size_t tiling_idx = 0; tiling_idx < tilings_->num_tilings(); + ++tiling_idx) { + PictureLayerTiling* tiling = tilings_->tiling_at(tiling_idx); + std::vector<Tile*> tiles = tiling->AllTilesForTesting(); + for (size_t tile_idx = 0; tile_idx < tiles.size(); ++tile_idx) { + Tile* tile = tiles[tile_idx]; + TilePriority priority; + priority.resolution = HIGH_RESOLUTION; + priority.time_to_visible_in_seconds = 0.f; + priority.distance_to_visible_in_pixels = 0.f; + tile->SetPriority(tree, priority); + } + } +} + +void FakePictureLayerImpl::SetAllTilesReady() { + for (size_t tiling_idx = 0; tiling_idx < tilings_->num_tilings(); + ++tiling_idx) { + PictureLayerTiling* tiling = tilings_->tiling_at(tiling_idx); + SetAllTilesReadyInTiling(tiling); + } +} + +void FakePictureLayerImpl::SetAllTilesReadyInTiling( + PictureLayerTiling* tiling) { + std::vector<Tile*> tiles = tiling->AllTilesForTesting(); + for (size_t tile_idx = 0; tile_idx < tiles.size(); ++tile_idx) { + Tile* tile = tiles[tile_idx]; + ManagedTileState& state = tile->managed_state(); + for (size_t mode_idx = 0; mode_idx < NUM_RASTER_MODES; ++mode_idx) + state.tile_versions[mode_idx].SetSolidColorForTesting(true); + DCHECK(tile->IsReadyToDraw()); + } +} + +void FakePictureLayerImpl::CreateDefaultTilingsAndTiles() { + layer_tree_impl()->UpdateDrawProperties(); + + if (CanHaveTilings()) { + DCHECK_EQ(tilings()->num_tilings(), 2u); + DCHECK_EQ(tilings()->tiling_at(0)->resolution(), HIGH_RESOLUTION); + DCHECK_EQ(tilings()->tiling_at(1)->resolution(), LOW_RESOLUTION); + HighResTiling()->CreateAllTilesForTesting(); + LowResTiling()->CreateAllTilesForTesting(); + } else { + DCHECK_EQ(tilings()->num_tilings(), 0u); + } +} + } // namespace cc diff --git a/cc/test/fake_picture_layer_impl.h b/cc/test/fake_picture_layer_impl.h index 759ceeb..0348377 100644 --- a/cc/test/fake_picture_layer_impl.h +++ b/cc/test/fake_picture_layer_impl.h @@ -55,6 +55,11 @@ class FakePictureLayerImpl : public PictureLayerImpl { void set_fixed_tile_size(gfx::Size size) { fixed_tile_size_ = size; } + void CreateDefaultTilingsAndTiles(); + void SetAllTilesVisible(); + void SetAllTilesReady(); + void SetAllTilesReadyInTiling(PictureLayerTiling* tiling); + protected: FakePictureLayerImpl( LayerTreeImpl* tree_impl, diff --git a/cc/test/fake_picture_layer_tiling_client.cc b/cc/test/fake_picture_layer_tiling_client.cc index 597e0d8..7ebd179 100644 --- a/cc/test/fake_picture_layer_tiling_client.cc +++ b/cc/test/fake_picture_layer_tiling_client.cc @@ -63,7 +63,7 @@ const Region* FakePictureLayerTilingClient::GetInvalidation() { } const PictureLayerTiling* FakePictureLayerTilingClient::GetTwinTiling( - const PictureLayerTiling* tiling) { + const PictureLayerTiling* tiling) const { return twin_tiling_; } diff --git a/cc/test/fake_picture_layer_tiling_client.h b/cc/test/fake_picture_layer_tiling_client.h index 1ad9c24..4b092e8 100644 --- a/cc/test/fake_picture_layer_tiling_client.h +++ b/cc/test/fake_picture_layer_tiling_client.h @@ -34,7 +34,7 @@ class FakePictureLayerTilingClient : public PictureLayerTilingClient { virtual const Region* GetInvalidation() OVERRIDE; virtual const PictureLayerTiling* GetTwinTiling( - const PictureLayerTiling* tiling) OVERRIDE; + const PictureLayerTiling* tiling) const OVERRIDE; void set_twin_tiling(PictureLayerTiling* tiling) { twin_tiling_ = tiling; } void set_text_rect(gfx::Rect rect) { text_rect_ = rect; } diff --git a/cc/test/fake_picture_pile_impl.cc b/cc/test/fake_picture_pile_impl.cc index 989c4f9..88c7d38 100644 --- a/cc/test/fake_picture_pile_impl.cc +++ b/cc/test/fake_picture_pile_impl.cc @@ -42,6 +42,19 @@ scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateEmptyPile( return pile; } +scoped_refptr<FakePicturePileImpl> +FakePicturePileImpl::CreatePileWithRecordedRegion( + gfx::Size tile_size, + 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); + pile->SetRecordedRegionForTesting(recorded_region); + return pile; +} + scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreatePile() { scoped_refptr<FakePicturePileImpl> pile(new FakePicturePileImpl()); gfx::Size size(std::numeric_limits<int>::max(), diff --git a/cc/test/fake_picture_pile_impl.h b/cc/test/fake_picture_pile_impl.h index ae8729e..20d44e3 100644 --- a/cc/test/fake_picture_pile_impl.h +++ b/cc/test/fake_picture_pile_impl.h @@ -21,6 +21,11 @@ class FakePicturePileImpl : public PicturePileImpl { gfx::Size tile_size, gfx::Size layer_bounds); + static scoped_refptr<FakePicturePileImpl> CreatePileWithRecordedRegion( + gfx::Size tile_size, + gfx::Size layer_bounds, + const Region& recorded_region); + static scoped_refptr<FakePicturePileImpl> CreatePile(); TilingData& tiling() { return tiling_; } |