Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3489)

Unified Diff: cc/tiles/tile_manager_perftest.cc

Issue 1974033004: (reland) cc: Refactor layer/tile manager unittest to extract common code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix perftests Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/test/test_layer_tree_host_base.cc ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/tile_manager_perftest.cc
diff --git a/cc/tiles/tile_manager_perftest.cc b/cc/tiles/tile_manager_perftest.cc
index 5d7a03e40f42b2b4443d01ca5f24531761f11747..b6437ed2e86d2fc846d76a4f2e1491a6fa9b2f07 100644
--- a/cc/tiles/tile_manager_perftest.cc
+++ b/cc/tiles/tile_manager_perftest.cc
@@ -21,6 +21,7 @@
#include "cc/test/fake_tile_manager.h"
#include "cc/test/fake_tile_manager_client.h"
#include "cc/test/fake_tile_task_manager.h"
+#include "cc/test/test_layer_tree_host_base.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/test/test_tile_priorities.h"
@@ -41,97 +42,30 @@ static const int kTimeCheckInterval = 10;
base::LazyInstance<FakeTileTaskManagerImpl> g_fake_tile_task_manager =
LAZY_INSTANCE_INITIALIZER;
-class TileManagerPerfTest : public testing::Test {
+class TileManagerPerfTest : public TestLayerTreeHostBase {
public:
TileManagerPerfTest()
- : memory_limit_policy_(ALLOW_ANYTHING),
- max_tiles_(10000),
- id_(7),
- task_runner_provider_(base::ThreadTaskRunnerHandle::Get()),
- output_surface_(FakeOutputSurface::Create3d()),
- host_impl_(LayerTreeSettings(),
- &task_runner_provider_,
- &shared_bitmap_manager_,
- &task_graph_runner_),
- timer_(kWarmupRuns,
+ : timer_(kWarmupRuns,
base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
kTimeCheckInterval) {}
- void SetTreePriority(TreePriority tree_priority) {
- GlobalStateThatImpactsTilePriority state;
- gfx::Size tile_size(256, 256);
-
- state.soft_memory_limit_in_bytes = 100 * 1000 * 1000;
- state.num_resources_limit = max_tiles_;
- state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2;
- state.memory_limit_policy = memory_limit_policy_;
- state.tree_priority = tree_priority;
-
- global_state_ = state;
- host_impl_.resource_pool()->SetResourceUsageLimits(
- state.soft_memory_limit_in_bytes, state.num_resources_limit);
- host_impl_.tile_manager()->SetGlobalStateForTesting(state);
- }
-
- void SetUp() override {
- InitializeRenderer();
- SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES);
- }
-
- virtual void InitializeRenderer() {
- host_impl_.SetVisible(true);
- host_impl_.InitializeRenderer(output_surface_.get());
+ void InitializeRenderer() override {
+ host_impl()->SetVisible(true);
+ host_impl()->InitializeRenderer(output_surface());
tile_manager()->SetTileTaskManagerForTesting(
g_fake_tile_task_manager.Pointer());
}
- void SetupDefaultTrees(const gfx::Size& layer_bounds) {
+ void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds,
+ const gfx::Size& tile_size) {
scoped_refptr<FakeRasterSource> pending_raster_source =
FakeRasterSource::CreateFilled(layer_bounds);
scoped_refptr<FakeRasterSource> active_raster_source =
FakeRasterSource::CreateFilled(layer_bounds);
- SetupTrees(pending_raster_source, active_raster_source);
- }
-
- void ActivateTree() {
- host_impl_.ActivateSyncTree();
- CHECK(!host_impl_.pending_tree());
- pending_root_layer_ = NULL;
- active_root_layer_ = static_cast<FakePictureLayerImpl*>(
- host_impl_.active_tree()->LayerById(id_));
- }
-
- void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds,
- const gfx::Size& tile_size) {
- SetupDefaultTrees(layer_bounds);
- pending_root_layer_->set_fixed_tile_size(tile_size);
- active_root_layer_->set_fixed_tile_size(tile_size);
- }
-
- void SetupTrees(scoped_refptr<RasterSource> pending_raster_source,
- scoped_refptr<RasterSource> active_raster_source) {
- SetupPendingTree(active_raster_source);
+ SetupPendingTree(std::move(active_raster_source), tile_size, Region());
ActivateTree();
- SetupPendingTree(pending_raster_source);
- }
-
- void SetupPendingTree(scoped_refptr<RasterSource> raster_source) {
- host_impl_.CreatePendingTree();
- LayerTreeImpl* pending_tree = host_impl_.pending_tree();
- // Clear recycled tree.
- pending_tree->ClearLayers();
-
- std::unique_ptr<FakePictureLayerImpl> pending_layer =
- FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_,
- raster_source);
- pending_layer->SetDrawsContent(true);
- pending_layer->test_properties()->force_render_surface = true;
- pending_tree->SetRootLayer(std::move(pending_layer));
- pending_tree->BuildPropertyTreesForTesting();
-
- pending_root_layer_ = static_cast<FakePictureLayerImpl*>(
- host_impl_.pending_tree()->LayerById(id_));
+ SetupPendingTree(std::move(pending_raster_source), tile_size, Region());
}
void RunRasterQueueConstructTest(const std::string& test_name,
@@ -148,8 +82,8 @@ class TileManagerPerfTest : public testing::Test {
timer_.Reset();
do {
std::unique_ptr<RasterTilePriorityQueue> queue(
- host_impl_.BuildRasterQueue(priorities[priority_count],
- RasterTilePriorityQueue::Type::ALL));
+ host_impl()->BuildRasterQueue(priorities[priority_count],
+ RasterTilePriorityQueue::Type::ALL));
priority_count = (priority_count + 1) % arraysize(priorities);
timer_.NextLap();
} while (!timer_.HasTimeLimitExpired());
@@ -178,8 +112,8 @@ class TileManagerPerfTest : public testing::Test {
do {
int count = tile_count;
std::unique_ptr<RasterTilePriorityQueue> queue(
- host_impl_.BuildRasterQueue(priorities[priority_count],
- RasterTilePriorityQueue::Type::ALL));
+ host_impl()->BuildRasterQueue(priorities[priority_count],
+ RasterTilePriorityQueue::Type::ALL));
while (count--) {
ASSERT_FALSE(queue->IsEmpty());
ASSERT_TRUE(queue->Top().tile());
@@ -217,7 +151,7 @@ class TileManagerPerfTest : public testing::Test {
timer_.Reset();
do {
std::unique_ptr<EvictionTilePriorityQueue> queue(
- host_impl_.BuildEvictionQueue(priorities[priority_count]));
+ host_impl()->BuildEvictionQueue(priorities[priority_count]));
priority_count = (priority_count + 1) % arraysize(priorities);
timer_.NextLap();
} while (!timer_.HasTimeLimitExpired());
@@ -252,7 +186,7 @@ class TileManagerPerfTest : public testing::Test {
do {
int count = tile_count;
std::unique_ptr<EvictionTilePriorityQueue> queue(
- host_impl_.BuildEvictionQueue(priorities[priority_count]));
+ host_impl()->BuildEvictionQueue(priorities[priority_count]));
while (count--) {
ASSERT_FALSE(queue->IsEmpty());
ASSERT_TRUE(queue->Top().tile());
@@ -272,57 +206,53 @@ class TileManagerPerfTest : public testing::Test {
}
std::vector<FakePictureLayerImpl*> CreateLayers(int layer_count,
- int tiles_per_layer_count) {
+ int num_tiles_in_high_res) {
// Compute the width/height required for high res to get
- // tiles_per_layer_count tiles.
- float width = std::sqrt(static_cast<float>(tiles_per_layer_count));
- float height = tiles_per_layer_count / width;
+ // num_tiles_in_high_res tiles.
+ float width = std::sqrt(static_cast<float>(num_tiles_in_high_res));
+ float height = num_tiles_in_high_res / width;
// Adjust the width and height to account for the fact that tiles
- // are bigger than 1x1. Also, account for the fact that that we
- // will be creating one high res and one low res tiling. That is,
- // width and height should be smaller by sqrt(1 + low_res_scale).
- // This gives us _approximately_ correct counts.
- width *= settings_.default_tile_size.width() /
- std::sqrt(1 + settings_.low_res_contents_scale_factor);
- height *= settings_.default_tile_size.height() /
- std::sqrt(1 + settings_.low_res_contents_scale_factor);
+ // are bigger than 1x1.
+ LayerTreeSettings settings;
+ width *= settings.default_tile_size.width();
+ height *= settings.default_tile_size.height();
// Ensure that we start with blank trees and no tiles.
- host_impl_.ResetTreesForTesting();
+ host_impl()->ResetTreesForTesting();
tile_manager()->FreeResourcesAndCleanUpReleasedTilesForTesting();
gfx::Size layer_bounds(width, height);
gfx::Size viewport(width / 5, height / 5);
- host_impl_.SetViewportSize(viewport);
+ host_impl()->SetViewportSize(viewport);
SetupDefaultTreesWithFixedTileSize(layer_bounds,
- settings_.default_tile_size);
+ settings.default_tile_size);
std::vector<FakePictureLayerImpl*> layers;
// Pending layer counts as one layer.
- layers.push_back(pending_root_layer_);
- int next_id = id_ + 1;
+ layers.push_back(pending_layer());
+ int next_id = layer_id() + 1;
// Create the rest of the layers as children of the root layer.
scoped_refptr<FakeRasterSource> raster_source =
FakeRasterSource::CreateFilled(layer_bounds);
while (static_cast<int>(layers.size()) < layer_count) {
- std::unique_ptr<FakePictureLayerImpl> layer =
+ std::unique_ptr<FakePictureLayerImpl> child_layer =
FakePictureLayerImpl::CreateWithRasterSource(
- host_impl_.pending_tree(), next_id, raster_source);
- layer->SetBounds(layer_bounds);
- layer->SetDrawsContent(true);
- layers.push_back(layer.get());
- pending_root_layer_->AddChild(std::move(layer));
+ host_impl()->pending_tree(), next_id, raster_source);
+ child_layer->SetBounds(layer_bounds);
+ child_layer->SetDrawsContent(true);
+ layers.push_back(child_layer.get());
+ pending_layer()->AddChild(std::move(child_layer));
++next_id;
}
// Property trees need to be rebuilt because layers were added above.
- host_impl_.pending_tree()->property_trees()->needs_rebuild = true;
- host_impl_.pending_tree()->BuildPropertyTreesForTesting();
+ host_impl()->pending_tree()->property_trees()->needs_rebuild = true;
+ host_impl()->pending_tree()->BuildPropertyTreesForTesting();
bool update_lcd_text = false;
- host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
+ host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text);
for (FakePictureLayerImpl* layer : layers)
layer->CreateAllTiles();
@@ -331,7 +261,7 @@ class TileManagerPerfTest : public testing::Test {
GlobalStateThatImpactsTilePriority GlobalStateForTest() {
GlobalStateThatImpactsTilePriority state;
- gfx::Size tile_size = settings_.default_tile_size;
+ gfx::Size tile_size = LayerTreeSettings().default_tile_size;
state.soft_memory_limit_in_bytes =
10000u * 4u *
static_cast<size_t>(tile_size.width() * tile_size.height());
@@ -350,7 +280,7 @@ class TileManagerPerfTest : public testing::Test {
timer_.Reset();
do {
- host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
+ host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
for (const auto& layer : layers)
layer->UpdateTiles();
@@ -364,23 +294,10 @@ class TileManagerPerfTest : public testing::Test {
timer_.LapsPerSecond(), "runs/s", true);
}
- TileManager* tile_manager() { return host_impl_.tile_manager(); }
+ TileManager* tile_manager() { return host_impl()->tile_manager(); }
protected:
- GlobalStateThatImpactsTilePriority global_state_;
-
- TestSharedBitmapManager shared_bitmap_manager_;
- TestTaskGraphRunner task_graph_runner_;
- TileMemoryLimitPolicy memory_limit_policy_;
- int max_tiles_;
- int id_;
- FakeImplTaskRunnerProvider task_runner_provider_;
- std::unique_ptr<OutputSurface> output_surface_;
- FakeLayerTreeHostImpl host_impl_;
- FakePictureLayerImpl* pending_root_layer_;
- FakePictureLayerImpl* active_root_layer_;
LapTimer timer_;
- LayerTreeSettings settings_;
};
TEST_F(TileManagerPerfTest, PrepareTiles) {
« no previous file with comments | « cc/test/test_layer_tree_host_base.cc ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698