summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-26 21:00:35 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-26 21:00:35 +0000
commit6d885c6e9c2a053b0b6d9317b58e12c404a4536d (patch)
treeb1879e8cbc05c420a55723f43356e4dbd28b364d
parent6a1fac40777f4c4820209c2727974f8e08193ff9 (diff)
downloadchromium_src-6d885c6e9c2a053b0b6d9317b58e12c404a4536d.zip
chromium_src-6d885c6e9c2a053b0b6d9317b58e12c404a4536d.tar.gz
chromium_src-6d885c6e9c2a053b0b6d9317b58e12c404a4536d.tar.bz2
cc: Change PictureLayerTiling::UpdatePile to GetPile().
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
-rw-r--r--cc/layers/picture_image_layer_impl_unittest.cc2
-rw-r--r--cc/layers/picture_layer_impl.cc4
-rw-r--r--cc/layers/picture_layer_impl.h2
-rw-r--r--cc/resources/picture_layer_tiling.cc6
-rw-r--r--cc/resources/picture_layer_tiling.h3
-rw-r--r--cc/resources/picture_layer_tiling_set_unittest.cc8
-rw-r--r--cc/test/fake_picture_layer_tiling_client.cc4
-rw-r--r--cc/test/fake_picture_layer_tiling_client.h4
8 files changed, 19 insertions, 14 deletions
diff --git a/cc/layers/picture_image_layer_impl_unittest.cc b/cc/layers/picture_image_layer_impl_unittest.cc
index 456c6ee..00fc475 100644
--- a/cc/layers/picture_image_layer_impl_unittest.cc
+++ b/cc/layers/picture_image_layer_impl_unittest.cc
@@ -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);
}
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 8624788..1e81721 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -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() {
diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h
index e8eba29..3b07c5d 100644
--- a/cc/layers/picture_layer_impl.h
+++ b/cc/layers/picture_layer_impl.h
@@ -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;
diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc
index 33e9038..fb68cbb 100644
--- a/cc/resources/picture_layer_tiling.cc
+++ b/cc/resources/picture_layer_tiling.cc
@@ -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());
@@ -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);
}
}
diff --git a/cc/resources/picture_layer_tiling.h b/cc/resources/picture_layer_tiling.h
index df58618..108b922 100644
--- a/cc/resources/picture_layer_tiling.h
+++ b/cc/resources/picture_layer_tiling.h
@@ -23,6 +23,7 @@ namespace cc {
template <typename LayerType>
class OcclusionTracker;
class PictureLayerTiling;
+class PicturePileImpl;
class CC_EXPORT PictureLayerTilingClient {
public:
@@ -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;
diff --git a/cc/resources/picture_layer_tiling_set_unittest.cc b/cc/resources/picture_layer_tiling_set_unittest.cc
index 259301b..868ff55 100644
--- a/cc/resources/picture_layer_tiling_set_unittest.cc
+++ b/cc/resources/picture_layer_tiling_set_unittest.cc
@@ -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());
@@ -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();
@@ -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())
diff --git a/cc/test/fake_picture_layer_tiling_client.cc b/cc/test/fake_picture_layer_tiling_client.cc
index dd64ac2..7834bc0 100644
--- a/cc/test/fake_picture_layer_tiling_client.cc
+++ b/cc/test/fake_picture_layer_tiling_client.cc
@@ -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;
}
diff --git a/cc/test/fake_picture_layer_tiling_client.h b/cc/test/fake_picture_layer_tiling_client.h
index 7440ea7..6bdede0 100644
--- a/cc/test/fake_picture_layer_tiling_client.h
+++ b/cc/test/fake_picture_layer_tiling_client.h
@@ -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;
@@ -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(