Skip to content

Commit

Permalink
cc: Change PictureLayerTiling::UpdatePile to GetPile().
Browse files Browse the repository at this point in the history
This helps make the code more clear, and greatly reduce the number of
virtual function calls by doing them outside of loops.

R=enne
BUG=387116

Review URL: https://codereview.chromium.org/352933002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280100 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
danakj@chromium.org committed Jun 26, 2014
1 parent 6a1fac4 commit 6d885c6
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cc/layers/picture_image_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PictureImageLayerImplTest : public testing::Test {
layer->SetContentBounds(gfx::Size(100, 200));
layer->tilings_.reset(new PictureLayerTilingSet(&tiling_client_,
layer->bounds()));
layer->pile_ = tiling_client_.pile();
layer->pile_ = tiling_client_.GetPile();
return make_scoped_ptr(layer);
}

Expand Down
4 changes: 2 additions & 2 deletions cc/layers/picture_layer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,8 @@ scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
flags);
}

void PictureLayerImpl::UpdatePile(Tile* tile) {
tile->set_picture_pile(pile_);
PicturePileImpl* PictureLayerImpl::GetPile() {
return pile_.get();
}

const Region* PictureLayerImpl::GetInvalidation() {
Expand Down
2 changes: 1 addition & 1 deletion cc/layers/picture_layer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class CC_EXPORT PictureLayerImpl
virtual scoped_refptr<Tile> CreateTile(
PictureLayerTiling* tiling,
const gfx::Rect& content_rect) OVERRIDE;
virtual void UpdatePile(Tile* tile) OVERRIDE;
virtual PicturePileImpl* GetPile() OVERRIDE;
virtual gfx::Size CalculateTileSize(
const gfx::Size& content_bounds) const OVERRIDE;
virtual const Region* GetInvalidation() OVERRIDE;
Expand Down
6 changes: 4 additions & 2 deletions cc/resources/picture_layer_tiling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ void PictureLayerTiling::DidBecomeRecycled() {
}

void PictureLayerTiling::DidBecomeActive() {
PicturePileImpl* active_pile = client_->GetPile();
for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
it->second->SetPriority(ACTIVE_TREE, it->second->priority(PENDING_TREE));
it->second->SetPriority(PENDING_TREE, TilePriority());
Expand All @@ -617,13 +618,14 @@ void PictureLayerTiling::DidBecomeActive() {
// will cause PicturePileImpls and their clones to get deleted once the
// corresponding PictureLayerImpl and any in flight raster jobs go out of
// scope.
client_->UpdatePile(it->second.get());
it->second->set_picture_pile(active_pile);
}
}

void PictureLayerTiling::UpdateTilesToCurrentPile() {
PicturePileImpl* pile = client_->GetPile();
for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
client_->UpdatePile(it->second.get());
it->second->set_picture_pile(pile);
}
}

Expand Down
3 changes: 2 additions & 1 deletion cc/resources/picture_layer_tiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace cc {
template <typename LayerType>
class OcclusionTracker;
class PictureLayerTiling;
class PicturePileImpl;

class CC_EXPORT PictureLayerTilingClient {
public:
Expand All @@ -31,7 +32,7 @@ class CC_EXPORT PictureLayerTilingClient {
virtual scoped_refptr<Tile> CreateTile(
PictureLayerTiling* tiling,
const gfx::Rect& content_rect) = 0;
virtual void UpdatePile(Tile* tile) = 0;
virtual PicturePileImpl* GetPile() = 0;
virtual gfx::Size CalculateTileSize(
const gfx::Size& content_bounds) const = 0;
virtual const Region* GetInvalidation() = 0;
Expand Down
8 changes: 4 additions & 4 deletions cc/resources/picture_layer_tiling_set_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class PictureLayerTilingSetSyncTest : public testing::Test {
SyncTilings(new_bounds, invalidation, minimum_scale);
}

void VerifyTargetEqualsSource(const gfx::Size& new_bounds) const {
void VerifyTargetEqualsSource(const gfx::Size& new_bounds) {
ASSERT_FALSE(new_bounds.IsEmpty());
EXPECT_EQ(target_->num_tilings(), source_->num_tilings());
EXPECT_EQ(target_->layer_bounds().ToString(), new_bounds.ToString());
Expand All @@ -202,7 +202,7 @@ class PictureLayerTilingSetSyncTest : public testing::Test {
ValidateTargetTilingSet();
}

void ValidateTargetTilingSet() const {
void ValidateTargetTilingSet() {
// Tilings should be sorted largest to smallest.
if (target_->num_tilings() > 0) {
float last_scale = target_->tiling_at(0)->contents_scale();
Expand All @@ -214,11 +214,11 @@ class PictureLayerTilingSetSyncTest : public testing::Test {
}

for (size_t i = 0; i < target_->num_tilings(); ++i)
ValidateTiling(target_->tiling_at(i), target_client_.pile());
ValidateTiling(target_->tiling_at(i), target_client_.GetPile());
}

void ValidateTiling(const PictureLayerTiling* tiling,
const PicturePileImpl* pile) const {
const PicturePileImpl* pile) {
if (tiling->TilingRect().IsEmpty())
EXPECT_TRUE(tiling->live_tiles_rect().IsEmpty());
else if (!tiling->live_tiles_rect().IsEmpty())
Expand Down
4 changes: 4 additions & 0 deletions cc/test/fake_picture_layer_tiling_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ scoped_refptr<Tile> FakePictureLayerTilingClient::CreateTile(
pile_.get(), tile_size_, rect, gfx::Rect(), 1, 0, 0, 0);
}

PicturePileImpl* FakePictureLayerTilingClient::GetPile() {
return pile_.get();
}

void FakePictureLayerTilingClient::SetTileSize(const gfx::Size& tile_size) {
tile_size_ = tile_size;
}
Expand Down
4 changes: 1 addition & 3 deletions cc/test/fake_picture_layer_tiling_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FakePictureLayerTilingClient : public PictureLayerTilingClient {
// PictureLayerTilingClient implementation.
virtual scoped_refptr<Tile> CreateTile(
PictureLayerTiling* tiling, const gfx::Rect& rect) OVERRIDE;
virtual void UpdatePile(Tile* tile) OVERRIDE {}
virtual PicturePileImpl* GetPile() OVERRIDE;
virtual gfx::Size CalculateTileSize(
const gfx::Size& content_bounds) const OVERRIDE;
virtual size_t GetMaxTilesForInterestArea() const OVERRIDE;
Expand All @@ -32,8 +32,6 @@ class FakePictureLayerTilingClient : public PictureLayerTilingClient {

void SetTileSize(const gfx::Size& tile_size);
gfx::Size TileSize() const { return tile_size_; }
scoped_refptr<PicturePileImpl> pile() { return pile_; }
const PicturePileImpl* pile() const { return pile_.get(); }

virtual const Region* GetInvalidation() OVERRIDE;
virtual const PictureLayerTiling* GetTwinTiling(
Expand Down

0 comments on commit 6d885c6

Please sign in to comment.