diff options
Diffstat (limited to 'chromium/cc/layers/picture_layer_impl_perftest.cc')
-rw-r--r-- | chromium/cc/layers/picture_layer_impl_perftest.cc | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/chromium/cc/layers/picture_layer_impl_perftest.cc b/chromium/cc/layers/picture_layer_impl_perftest.cc index 56bf774aad3..e9a87d6e833 100644 --- a/chromium/cc/layers/picture_layer_impl_perftest.cc +++ b/chromium/cc/layers/picture_layer_impl_perftest.cc @@ -6,16 +6,13 @@ #include "base/threading/thread_task_runner_handle.h" #include "base/timer/lap_timer.h" -#include "cc/test/fake_impl_task_runner_provider.h" -#include "cc/test/fake_layer_tree_frame_sink.h" -#include "cc/test/fake_layer_tree_host_impl.h" #include "cc/test/fake_picture_layer_impl.h" #include "cc/test/fake_raster_source.h" -#include "cc/test/test_task_graph_runner.h" +#include "cc/test/layer_tree_impl_test_base.h" #include "cc/tiles/tiling_set_raster_queue_all.h" #include "cc/trees/layer_tree_impl.h" #include "testing/gtest/include/gtest/gtest.h" -#include "testing/perf/perf_test.h" +#include "testing/perf/perf_result_reporter.h" namespace cc { namespace { @@ -37,50 +34,42 @@ void AddTiling(float scale, tiling_tiles.begin(), tiling_tiles.end(), std::back_inserter(*all_tiles)); } -class PictureLayerImplPerfTest : public testing::Test { +class PictureLayerImplPerfTest : public LayerTreeImplTestBase, + public testing::Test { public: PictureLayerImplPerfTest() - : task_runner_provider_(base::ThreadTaskRunnerHandle::Get()), - layer_tree_frame_sink_(FakeLayerTreeFrameSink::Create3d()), - host_impl_(LayerTreeSettings(), - &task_runner_provider_, - &task_graph_runner_), - timer_(kWarmupRuns, + : timer_(kWarmupRuns, base::TimeDelta::FromMilliseconds(kTimeLimitMillis), kTimeCheckInterval) {} PictureLayerImplPerfTest(const PictureLayerImplPerfTest&) = delete; PictureLayerImplPerfTest& operator=(const PictureLayerImplPerfTest&) = delete; - void SetUp() override { - host_impl_.SetVisible(true); - host_impl_.InitializeFrameSink(layer_tree_frame_sink_.get()); - } - void SetupPendingTree(const gfx::Size& layer_bounds) { scoped_refptr<FakeRasterSource> raster_source = FakeRasterSource::CreateFilled(layer_bounds); - host_impl_.CreatePendingTree(); - LayerTreeImpl* pending_tree = host_impl_.pending_tree(); + host_impl()->CreatePendingTree(); + LayerTreeImpl* pending_tree = host_impl()->pending_tree(); pending_tree->DetachLayers(); std::unique_ptr<FakePictureLayerImpl> pending_layer = - FakePictureLayerImpl::CreateWithRasterSource(pending_tree, 7, - raster_source); + FakePictureLayerImpl::Create(pending_tree, 7, raster_source); pending_layer->SetDrawsContent(true); - pending_layer->test_properties()->force_render_surface = true; + pending_layer_ = pending_layer.get(); + pending_tree->SetElementIdsForTesting(); + SetupRootProperties(pending_layer_); pending_tree->SetRootLayerForTesting(std::move(pending_layer)); - pending_tree->BuildLayerListAndPropertyTreesForTesting(); - pending_layer_ = static_cast<FakePictureLayerImpl*>( - host_impl_.pending_tree()->LayerById(7)); + PrepareForUpdateDrawProperties(pending_tree); + // Don't update draw properties because the tilings will conflict with the + // tilings that will be added in the tests. } void RunRasterQueueConstructAndIterateTest(const std::string& test_name, int num_tiles, const gfx::Rect& viewport_rect) { - host_impl_.active_tree()->SetDeviceViewportRect(viewport_rect); - host_impl_.pending_tree()->UpdateDrawProperties(); + host_impl()->active_tree()->SetDeviceViewportRect(viewport_rect); + host_impl()->pending_tree()->UpdateDrawProperties(); timer_.Reset(); do { @@ -96,19 +85,21 @@ class PictureLayerImplPerfTest : public testing::Test { timer_.NextLap(); } while (!timer_.HasTimeLimitExpired()); - perf_test::PrintResult("tiling_set_raster_queue_construct_and_iterate", "", - test_name, timer_.LapsPerSecond(), "runs/s", true); + perf_test::PerfResultReporter reporter = SetUpReporter(test_name); + reporter.AddResult("_raster_queue_construct_and_iterate", + timer_.LapsPerSecond()); } void RunRasterQueueConstructTest(const std::string& test_name, const gfx::Rect& viewport) { - host_impl_.active_tree()->SetDeviceViewportRect(viewport); - host_impl_.pending_tree() + host_impl()->active_tree()->SetDeviceViewportRect(viewport); + host_impl() + ->pending_tree() ->property_trees() ->scroll_tree.UpdateScrollOffsetBaseForTesting( pending_layer_->element_id(), gfx::ScrollOffset(viewport.x(), viewport.y())); - host_impl_.pending_tree()->UpdateDrawProperties(); + host_impl()->pending_tree()->UpdateDrawProperties(); timer_.Reset(); do { @@ -118,15 +109,15 @@ class PictureLayerImplPerfTest : public testing::Test { timer_.NextLap(); } while (!timer_.HasTimeLimitExpired()); - perf_test::PrintResult("tiling_set_raster_queue_construct", "", test_name, - timer_.LapsPerSecond(), "runs/s", true); + perf_test::PerfResultReporter reporter = SetUpReporter(test_name); + reporter.AddResult("_raster_queue_construct", timer_.LapsPerSecond()); } void RunEvictionQueueConstructAndIterateTest(const std::string& test_name, int num_tiles, const gfx::Rect& viewport_rect) { - host_impl_.active_tree()->SetDeviceViewportRect(viewport_rect); - host_impl_.pending_tree()->UpdateDrawProperties(); + host_impl()->active_tree()->SetDeviceViewportRect(viewport_rect); + host_impl()->pending_tree()->UpdateDrawProperties(); timer_.Reset(); do { @@ -142,20 +133,21 @@ class PictureLayerImplPerfTest : public testing::Test { timer_.NextLap(); } while (!timer_.HasTimeLimitExpired()); - perf_test::PrintResult("tiling_set_eviction_queue_construct_and_iterate", - "", test_name, timer_.LapsPerSecond(), "runs/s", - true); + perf_test::PerfResultReporter reporter = SetUpReporter(test_name); + reporter.AddResult("_eviction_queue_construct_and_iterate", + timer_.LapsPerSecond()); } void RunEvictionQueueConstructTest(const std::string& test_name, const gfx::Rect& viewport) { - host_impl_.active_tree()->SetDeviceViewportRect(viewport); - host_impl_.pending_tree() + host_impl()->active_tree()->SetDeviceViewportRect(viewport); + host_impl() + ->pending_tree() ->property_trees() ->scroll_tree.UpdateScrollOffsetBaseForTesting( pending_layer_->element_id(), gfx::ScrollOffset(viewport.x(), viewport.y())); - host_impl_.pending_tree()->UpdateDrawProperties(); + host_impl()->pending_tree()->UpdateDrawProperties(); timer_.Reset(); do { @@ -165,15 +157,21 @@ class PictureLayerImplPerfTest : public testing::Test { timer_.NextLap(); } while (!timer_.HasTimeLimitExpired()); - perf_test::PrintResult("tiling_set_eviction_queue_construct", "", test_name, - timer_.LapsPerSecond(), "runs/s", true); + perf_test::PerfResultReporter reporter = SetUpReporter(test_name); + reporter.AddResult("_eviction_queue_construct", timer_.LapsPerSecond()); } protected: - TestTaskGraphRunner task_graph_runner_; - FakeImplTaskRunnerProvider task_runner_provider_; - std::unique_ptr<LayerTreeFrameSink> layer_tree_frame_sink_; - FakeLayerTreeHostImpl host_impl_; + perf_test::PerfResultReporter SetUpReporter(const std::string& story_name) { + perf_test::PerfResultReporter reporter("tiling_set", story_name); + reporter.RegisterImportantMetric("_raster_queue_construct_and_iterate", + "runs/s"); + reporter.RegisterImportantMetric("_raster_queue_construct", "runs/s"); + reporter.RegisterImportantMetric("_eviction_queue_construct_and_iterate", + "runs/s"); + return reporter; + } + FakePictureLayerImpl* pending_layer_; base::LapTimer timer_; }; @@ -181,7 +179,7 @@ class PictureLayerImplPerfTest : public testing::Test { TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstructAndIterate) { SetupPendingTree(gfx::Size(10000, 10000)); - float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; + float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; pending_layer_->AddTiling( gfx::AxisTransform2d(low_res_factor, gfx::Vector2dF())); @@ -199,7 +197,7 @@ TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstructAndIterate) { TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstruct) { SetupPendingTree(gfx::Size(10000, 10000)); - float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; + float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; pending_layer_->AddTiling( gfx::AxisTransform2d(low_res_factor, gfx::Vector2dF())); @@ -216,7 +214,7 @@ TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstruct) { TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstructAndIterate) { SetupPendingTree(gfx::Size(10000, 10000)); - float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; + float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; std::vector<Tile*> all_tiles; AddTiling(low_res_factor, pending_layer_, &all_tiles); @@ -225,8 +223,9 @@ TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstructAndIterate) { AddTiling(1.0f, pending_layer_, &all_tiles); AddTiling(2.0f, pending_layer_, &all_tiles); - ASSERT_TRUE(host_impl_.tile_manager() != nullptr); - host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); + ASSERT_TRUE(host_impl()->tile_manager() != nullptr); + host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( + all_tiles); RunEvictionQueueConstructAndIterateTest("32_100x100", 32, gfx::Rect(100, 100)); @@ -241,7 +240,7 @@ TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstructAndIterate) { TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstruct) { SetupPendingTree(gfx::Size(10000, 10000)); - float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; + float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; std::vector<Tile*> all_tiles; AddTiling(low_res_factor, pending_layer_, &all_tiles); @@ -250,8 +249,9 @@ TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstruct) { AddTiling(1.0f, pending_layer_, &all_tiles); AddTiling(2.0f, pending_layer_, &all_tiles); - ASSERT_TRUE(host_impl_.tile_manager() != nullptr); - host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); + ASSERT_TRUE(host_impl()->tile_manager() != nullptr); + host_impl()->tile_manager()->InitializeTilesWithResourcesForTesting( + all_tiles); RunEvictionQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); RunEvictionQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100)); |