Skip to content

Commit

Permalink
Using pending tree was breaking the dchecks, use active tree instead.
Browse files Browse the repository at this point in the history
BUG=
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

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

Cr-Commit-Position: refs/heads/master@{#351265}
  • Loading branch information
sohan.jyoti authored and Commit bot committed Sep 29, 2015
1 parent 2ec1d6f commit a543d12
Showing 1 changed file with 46 additions and 47 deletions.
93 changes: 46 additions & 47 deletions cc/layers/picture_layer_impl_perftest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,35 +54,36 @@ class PictureLayerImplPerfTest : public testing::Test {
host_impl_.InitializeRenderer(output_surface_.get());
}

void SetupActiveTree(const gfx::Size& layer_bounds) {
void SetupPendingTree(const gfx::Size& layer_bounds) {
scoped_refptr<FakeDisplayListRasterSource> raster_source =
FakeDisplayListRasterSource::CreateFilled(layer_bounds);
LayerTreeImpl* active_tree = host_impl_.active_tree();
active_tree->DetachLayerTree();
host_impl_.CreatePendingTree();
LayerTreeImpl* pending_tree = host_impl_.pending_tree();
pending_tree->DetachLayerTree();

scoped_ptr<FakePictureLayerImpl> active_layer =
FakePictureLayerImpl::CreateWithRasterSource(active_tree, 7,
scoped_ptr<FakePictureLayerImpl> pending_layer =
FakePictureLayerImpl::CreateWithRasterSource(pending_tree, 7,
raster_source);
active_layer->SetDrawsContent(true);
active_layer->SetHasRenderSurface(true);
active_tree->SetRootLayer(active_layer.Pass());
pending_layer->SetDrawsContent(true);
pending_layer->SetHasRenderSurface(true);
pending_tree->SetRootLayer(pending_layer.Pass());

active_layer_ = static_cast<FakePictureLayerImpl*>(
host_impl_.active_tree()->LayerById(7));
pending_layer_ = static_cast<FakePictureLayerImpl*>(
host_impl_.pending_tree()->LayerById(7));
}

void RunRasterQueueConstructAndIterateTest(const std::string& test_name,
int num_tiles,
const gfx::Size& viewport_size) {
host_impl_.SetViewportSize(viewport_size);
bool update_lcd_text = false;
host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);

timer_.Reset();
do {
int count = num_tiles;
scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll(
active_layer_->picture_layer_tiling_set(), false));
pending_layer_->picture_layer_tiling_set(), false));
while (count--) {
ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count;
ASSERT_TRUE(queue->Top().tile()) << "count: " << count;
Expand All @@ -98,15 +99,15 @@ class PictureLayerImplPerfTest : public testing::Test {
void RunRasterQueueConstructTest(const std::string& test_name,
const gfx::Rect& viewport) {
host_impl_.SetViewportSize(viewport.size());
active_layer_->PushScrollOffsetFromMainThreadAndClobberActiveValue(
pending_layer_->PushScrollOffsetFromMainThread(
gfx::ScrollOffset(viewport.x(), viewport.y()));
bool update_lcd_text = false;
host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);

timer_.Reset();
do {
scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll(
active_layer_->picture_layer_tiling_set(), false));
pending_layer_->picture_layer_tiling_set(), false));
timer_.NextLap();
} while (!timer_.HasTimeLimitExpired());

Expand All @@ -119,15 +120,14 @@ class PictureLayerImplPerfTest : public testing::Test {
int num_tiles,
const gfx::Size& viewport_size) {
host_impl_.SetViewportSize(viewport_size);
active_layer_->MarkAllTilingsUsed();
bool update_lcd_text = false;
host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);

timer_.Reset();
do {
int count = num_tiles;
scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue(
active_layer_->picture_layer_tiling_set()));
pending_layer_->picture_layer_tiling_set()));
while (count--) {
ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count;
ASSERT_TRUE(queue->Top().tile()) << "count: " << count;
Expand All @@ -144,16 +144,15 @@ class PictureLayerImplPerfTest : public testing::Test {
void RunEvictionQueueConstructTest(const std::string& test_name,
const gfx::Rect& viewport) {
host_impl_.SetViewportSize(viewport.size());
active_layer_->PushScrollOffsetFromMainThreadAndClobberActiveValue(
pending_layer_->PushScrollOffsetFromMainThread(
gfx::ScrollOffset(viewport.x(), viewport.y()));
active_layer_->MarkAllTilingsUsed();
bool update_lcd_text = false;
host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);

timer_.Reset();
do {
scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue(
active_layer_->picture_layer_tiling_set()));
pending_layer_->picture_layer_tiling_set()));
timer_.NextLap();
} while (!timer_.HasTimeLimitExpired());

Expand All @@ -167,23 +166,23 @@ class PictureLayerImplPerfTest : public testing::Test {
FakeImplProxy proxy_;
scoped_ptr<OutputSurface> output_surface_;
FakeLayerTreeHostImpl host_impl_;
FakePictureLayerImpl* active_layer_;
FakePictureLayerImpl* pending_layer_;
LapTimer timer_;

private:
DISALLOW_COPY_AND_ASSIGN(PictureLayerImplPerfTest);
};

TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstructAndIterate) {
SetupActiveTree(gfx::Size(10000, 10000));
SetupPendingTree(gfx::Size(10000, 10000));

float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;

active_layer_->AddTiling(low_res_factor);
active_layer_->AddTiling(0.3f);
active_layer_->AddTiling(0.7f);
active_layer_->AddTiling(1.0f);
active_layer_->AddTiling(2.0f);
pending_layer_->AddTiling(low_res_factor);
pending_layer_->AddTiling(0.3f);
pending_layer_->AddTiling(0.7f);
pending_layer_->AddTiling(1.0f);
pending_layer_->AddTiling(2.0f);

RunRasterQueueConstructAndIterateTest("32_100x100", 32, gfx::Size(100, 100));
RunRasterQueueConstructAndIterateTest("32_500x500", 32, gfx::Size(500, 500));
Expand All @@ -192,32 +191,32 @@ TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstructAndIterate) {
}

TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstruct) {
SetupActiveTree(gfx::Size(10000, 10000));
SetupPendingTree(gfx::Size(10000, 10000));

float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;

active_layer_->AddTiling(low_res_factor);
active_layer_->AddTiling(0.3f);
active_layer_->AddTiling(0.7f);
active_layer_->AddTiling(1.0f);
active_layer_->AddTiling(2.0f);
pending_layer_->AddTiling(low_res_factor);
pending_layer_->AddTiling(0.3f);
pending_layer_->AddTiling(0.7f);
pending_layer_->AddTiling(1.0f);
pending_layer_->AddTiling(2.0f);

RunRasterQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100));
RunRasterQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100));
RunRasterQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100));
}

TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstructAndIterate) {
SetupActiveTree(gfx::Size(10000, 10000));
SetupPendingTree(gfx::Size(10000, 10000));

float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;

std::vector<Tile*> all_tiles;
AddTiling(low_res_factor, active_layer_, &all_tiles);
AddTiling(0.3f, active_layer_, &all_tiles);
AddTiling(0.7f, active_layer_, &all_tiles);
AddTiling(1.0f, active_layer_, &all_tiles);
AddTiling(2.0f, active_layer_, &all_tiles);
AddTiling(low_res_factor, pending_layer_, &all_tiles);
AddTiling(0.3f, pending_layer_, &all_tiles);
AddTiling(0.7f, pending_layer_, &all_tiles);
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);
Expand All @@ -233,16 +232,16 @@ TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstructAndIterate) {
}

TEST_F(PictureLayerImplPerfTest, TilingSetEvictionQueueConstruct) {
SetupActiveTree(gfx::Size(10000, 10000));
SetupPendingTree(gfx::Size(10000, 10000));

float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;

std::vector<Tile*> all_tiles;
AddTiling(low_res_factor, active_layer_, &all_tiles);
AddTiling(0.3f, active_layer_, &all_tiles);
AddTiling(0.7f, active_layer_, &all_tiles);
AddTiling(1.0f, active_layer_, &all_tiles);
AddTiling(2.0f, active_layer_, &all_tiles);
AddTiling(low_res_factor, pending_layer_, &all_tiles);
AddTiling(0.3f, pending_layer_, &all_tiles);
AddTiling(0.7f, pending_layer_, &all_tiles);
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);
Expand Down

0 comments on commit a543d12

Please sign in to comment.