Chromium Code Reviews| Index: cc/resources/picture_layer_tiling_perftest.cc |
| diff --git a/cc/resources/picture_layer_tiling_perftest.cc b/cc/resources/picture_layer_tiling_perftest.cc |
| index a610c1ea28e9a331aa9c9f0982362b0bf54dde61..c78f5716995af1b592069876e9ad537e7357b34c 100644 |
| --- a/cc/resources/picture_layer_tiling_perftest.cc |
| +++ b/cc/resources/picture_layer_tiling_perftest.cc |
| @@ -4,7 +4,13 @@ |
| #include "cc/debug/lap_timer.h" |
| #include "cc/resources/picture_layer_tiling.h" |
| +#include "cc/resources/resource_provider.h" |
| +#include "cc/resources/scoped_resource.h" |
| +#include "cc/test/fake_output_surface.h" |
| +#include "cc/test/fake_output_surface_client.h" |
| #include "cc/test/fake_picture_layer_tiling_client.h" |
| +#include "cc/test/test_context_provider.h" |
| +#include "cc/test/test_shared_bitmap_manager.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "testing/perf/perf_test.h" |
| @@ -22,7 +28,19 @@ class PictureLayerTilingPerfTest : public testing::Test { |
| PictureLayerTilingPerfTest() |
| : timer_(kWarmupRuns, |
| base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| - kTimeCheckInterval) {} |
| + kTimeCheckInterval), |
| + context_provider_(TestContextProvider::Create()) { |
| + output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
| + CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| + |
| + shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
| + resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
| + shared_bitmap_manager_.get(), |
| + 0, |
| + false, |
| + 1, |
| + false).Pass(); |
| + } |
| virtual void SetUp() OVERRIDE { |
| picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256)); |
| @@ -141,11 +159,106 @@ class PictureLayerTilingPerfTest : public testing::Test { |
| true); |
| } |
| + void RunEvictionIteratorConstructTest(const std::string& test_name, |
| + const gfx::Rect& viewport) { |
| + gfx::Size bounds(viewport.size()); |
| + picture_layer_tiling_ = |
| + PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| + picture_layer_tiling_->UpdateTilePriorities( |
| + ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); |
| + |
| + timer_.Reset(); |
| + TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| + SMOOTHNESS_TAKES_PRIORITY, |
| + NEW_CONTENT_TAKES_PRIORITY}; |
| + int priority_count = 0; |
| + do { |
| + PictureLayerTiling::TilingEvictionTileIterator it( |
| + picture_layer_tiling_.get(), priorities[priority_count]); |
| + priority_count = (priority_count + 1) % arraysize(priorities); |
| + timer_.NextLap(); |
| + } while (!timer_.HasTimeLimitExpired()); |
| + |
| + perf_test::PrintResult("tiling_eviction_tile_iterator_construct", |
| + "", |
| + test_name, |
| + timer_.LapsPerSecond(), |
| + "runs/s", |
| + true); |
| + } |
| + |
| + void RunEvictionIteratorConstructAndIterateTest(const std::string& test_name, |
| + int num_tiles, |
| + const gfx::Rect& viewport) { |
| + gfx::Size bounds(10000, 10000); |
| + picture_layer_tiling_ = |
| + PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| + picture_layer_tiling_->UpdateTilePriorities( |
| + ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); |
| + |
| + TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
| + SMOOTHNESS_TAKES_PRIORITY, |
| + NEW_CONTENT_TAKES_PRIORITY}; |
| + |
| + // Ensure all tiles have resources. |
| + for (PictureLayerTiling::TilingRasterTileIterator it( |
|
reveman
2014/07/17 16:26:23
nit: I think it's a bit awkward to use an iterator
vmpstr
2014/07/17 16:40:54
Done.
|
| + picture_layer_tiling_.get(), ACTIVE_TREE); |
| + it; |
| + ++it) { |
| + Tile* tile = *it; |
| + ManagedTileState::TileVersion& tile_version = |
| + tile->GetTileVersionForTesting(tile->GetRasterModeForTesting()); |
| + tile_version.SetResourceForTesting( |
| + ScopedResource::Create(resource_provider_.get()).Pass()); |
| + } |
| + |
| + int priority_count = 0; |
| + timer_.Reset(); |
| + do { |
| + int count = num_tiles; |
| + PictureLayerTiling::TilingEvictionTileIterator it( |
| + picture_layer_tiling_.get(), priorities[priority_count]); |
| + ASSERT_TRUE(it); |
| + for (; it && count; ++it) { |
| + --count; |
| + } |
| + ASSERT_EQ(0, count); |
|
reveman
2014/07/17 16:26:23
nit: same suggestion as the other patch, maybe rep
vmpstr
2014/07/17 16:40:54
Done.
|
| + priority_count = (priority_count + 1) % arraysize(priorities); |
| + timer_.NextLap(); |
| + } while (!timer_.HasTimeLimitExpired()); |
| + |
| + // Remove all resources form tiles to make sure the tile version destructor |
| + // doesn't complain. |
| + for (PictureLayerTiling::TilingEvictionTileIterator it( |
| + picture_layer_tiling_.get(), SAME_PRIORITY_FOR_BOTH_TREES); |
| + it; |
| + ++it) { |
| + Tile* tile = *it; |
| + ManagedTileState::TileVersion& tile_version = |
| + tile->GetTileVersionForTesting(tile->GetRasterModeForTesting()); |
| + tile_version.SetResourceForTesting(scoped_ptr<ScopedResource>()); |
| + } |
| + |
| + perf_test::PrintResult( |
| + "tiling_eviction_tile_iterator_construct_and_iterate", |
| + "", |
| + test_name, |
| + timer_.LapsPerSecond(), |
| + "runs/s", |
| + true); |
| + } |
| + |
| private: |
| FakePictureLayerTilingClient picture_layer_tiling_client_; |
| scoped_ptr<PictureLayerTiling> picture_layer_tiling_; |
| LapTimer timer_; |
| + |
| + scoped_refptr<ContextProvider> context_provider_; |
| + FakeOutputSurfaceClient output_surface_client_; |
| + scoped_ptr<FakeOutputSurface> output_surface_; |
| + scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
| + scoped_ptr<ResourceProvider> resource_provider_; |
| }; |
| TEST_F(PictureLayerTilingPerfTest, Invalidate) { |
| @@ -186,6 +299,27 @@ TEST_F(PictureLayerTilingPerfTest, TilingRasterTileIterator) { |
| RunTilingRasterTileIteratorTest("64_500x500", 64, gfx::Rect(0, 0, 500, 500)); |
| } |
| +TEST_F(PictureLayerTilingPerfTest, TilingEvictionTileIteratorConstruct) { |
| + RunEvictionIteratorConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); |
| + RunEvictionIteratorConstructTest("50_0_100x100", gfx::Rect(50, 0, 100, 100)); |
| + RunEvictionIteratorConstructTest("100_0_100x100", |
| + gfx::Rect(100, 0, 100, 100)); |
| + RunEvictionIteratorConstructTest("150_0_100x100", |
| + gfx::Rect(150, 0, 100, 100)); |
| +} |
| + |
| +TEST_F(PictureLayerTilingPerfTest, |
| + TilingEvictionTileIteratorConstructAndIterate) { |
| + RunEvictionIteratorConstructAndIterateTest( |
| + "32_100x100", 32, gfx::Rect(0, 0, 100, 100)); |
| + RunEvictionIteratorConstructAndIterateTest( |
| + "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); |
| + RunEvictionIteratorConstructAndIterateTest( |
| + "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); |
| + RunEvictionIteratorConstructAndIterateTest( |
| + "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); |
| +} |
| + |
| } // namespace |
| } // namespace cc |