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

Unified Diff: cc/trees/layer_tree_host_unittest_context.cc

Issue 581643005: Revert "cc: Use impl-side painting in LTH context lost tests." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/trees/layer_tree_host_impl_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_unittest_context.cc
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index b87eeafa1e969aa79c7ab8619b06095c34b9a8ec..0e15071458f3842a22cbe1913183b66eeacbc1bc 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -28,8 +28,6 @@
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_output_surface_client.h"
#include "cc/test/fake_painted_scrollbar_layer.h"
-#include "cc/test/fake_picture_layer.h"
-#include "cc/test/fake_picture_layer_impl.h"
#include "cc/test/fake_scoped_ui_resource.h"
#include "cc/test/fake_scrollbar.h"
#include "cc/test/fake_video_frame_provider.h"
@@ -325,19 +323,11 @@ class LayerTreeHostContextTestLostContextSucceedsWithContent
root_->SetBounds(gfx::Size(10, 10));
root_->SetIsDrawable(true);
- // Paint non-solid color.
- SkPaint paint;
- paint.setColor(SkColorSetARGB(100, 80, 200, 200));
- client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint);
+ content_ = FakeContentLayer::Create(&client_);
+ content_->SetBounds(gfx::Size(10, 10));
+ content_->SetIsDrawable(true);
- if (layer_tree_host()->settings().impl_side_painting)
- layer_ = FakePictureLayer::Create(&client_);
- else
- layer_ = FakeContentLayer::Create(&client_);
- layer_->SetBounds(gfx::Size(10, 10));
- layer_->SetIsDrawable(true);
-
- root_->AddChild(layer_);
+ root_->AddChild(content_);
layer_tree_host()->SetRootLayer(root_);
LayerTreeHostContextTest::SetupTree();
@@ -347,33 +337,27 @@ class LayerTreeHostContextTestLostContextSucceedsWithContent
// Invalidate the render surface so we don't try to use a cached copy of the
// surface. We want to make sure to test the drawing paths for drawing to
// a child surface.
- layer_->SetNeedsDisplay();
+ content_->SetNeedsDisplay();
LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit();
}
virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
- if (!host_impl->settings().impl_side_painting) {
- FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>(
- host_impl->active_tree()->root_layer()->children()[0]);
- // Even though the context was lost, we should have a resource. The
- // TestWebGraphicsContext3D ensures that this resource is created with
- // the active context.
- EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0));
- } else {
- FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>(
- host_impl->active_tree()->root_layer()->children()[0]);
- EXPECT_TRUE(picture_impl->HighResTiling()->TileAt(0, 0)->IsReadyToDraw());
- }
+ FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>(
+ host_impl->active_tree()->root_layer()->children()[0]);
+ // Even though the context was lost, we should have a resource. The
+ // TestWebGraphicsContext3D ensures that this resource is created with
+ // the active context.
+ EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0));
}
protected:
FakeContentLayerClient client_;
scoped_refptr<Layer> root_;
- scoped_refptr<Layer> layer_;
+ scoped_refptr<ContentLayer> content_;
};
-// This test uses TiledLayer and PictureLayer to check for a working context.
-SINGLE_AND_MULTI_THREAD_TEST_F(
+// This test uses TiledLayer to check for a working context.
+SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
LayerTreeHostContextTestLostContextSucceedsWithContent);
class LayerTreeHostContextTestCreateOutputSurfaceFails
@@ -453,20 +437,13 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
public:
LayerTreeHostContextTestLostContextAndEvictTextures()
: LayerTreeHostContextTest(),
+ layer_(FakeContentLayer::Create(&client_)),
impl_host_(0),
num_commits_(0) {}
virtual void SetupTree() OVERRIDE {
- if (layer_tree_host()->settings().impl_side_painting) {
- picture_layer_ = FakePictureLayer::Create(&client_);
- picture_layer_->SetBounds(gfx::Size(10, 20));
- layer_tree_host()->SetRootLayer(picture_layer_);
- } else {
- content_layer_ = FakeContentLayer::Create(&client_);
- content_layer_->SetBounds(gfx::Size(10, 20));
- layer_tree_host()->SetRootLayer(content_layer_);
- }
-
+ layer_->SetBounds(gfx::Size(10, 20));
+ layer_tree_host()->SetRootLayer(layer_);
LayerTreeHostContextTest::SetupTree();
}
@@ -487,12 +464,6 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
void EvictTexturesOnImplThread() {
impl_host_->EvictTexturesForTesting();
- if (impl_host_->settings().impl_side_painting) {
- FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>(
- impl_host_->active_tree()->root_layer()->children()[0]);
- EXPECT_FALSE(
- picture_impl->HighResTiling()->TileAt(0, 0)->IsReadyToDraw());
- }
if (lose_after_evict_)
LoseContext();
}
@@ -500,19 +471,17 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
virtual void DidCommitAndDrawFrame() OVERRIDE {
if (num_commits_ > 1)
return;
- if (!layer_tree_host()->settings().impl_side_painting) {
- EXPECT_TRUE(content_layer_->HaveBackingAt(0, 0));
- }
+ EXPECT_TRUE(layer_->HaveBackingAt(0, 0));
PostEvictTextures();
}
- virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
- if (impl->settings().impl_side_painting) {
- FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>(
- impl->active_tree()->root_layer()->children()[0]);
- EXPECT_TRUE(picture_impl->HighResTiling()->TileAt(0, 0)->IsReadyToDraw());
- }
-
+ virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
+ LayerTreeHostContextTest::CommitCompleteOnThread(impl);
+ if (num_commits_ > 1)
+ return;
+ ++num_commits_;
+ if (!lose_after_evict_)
+ LoseContext();
impl_host_ = impl;
}
@@ -523,8 +492,7 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
protected:
bool lose_after_evict_;
FakeContentLayerClient client_;
- scoped_refptr<FakeContentLayer> content_layer_;
- scoped_refptr<FakePictureLayer> picture_layer_;
+ scoped_refptr<FakeContentLayer> layer_;
LayerTreeHostImpl* impl_host_;
int num_commits_;
};
@@ -600,7 +568,9 @@ class LayerTreeHostContextTestLostContextWhileUpdatingResources
: public LayerTreeHostContextTest {
public:
LayerTreeHostContextTestLostContextWhileUpdatingResources()
- : num_children_(50), times_to_lose_on_end_query_(3) {}
+ : parent_(FakeContentLayer::Create(&client_)),
+ num_children_(50),
+ times_to_lose_on_end_query_(3) {}
virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() OVERRIDE {
scoped_ptr<TestWebGraphicsContext3D> context =
@@ -613,19 +583,11 @@ class LayerTreeHostContextTestLostContextWhileUpdatingResources
}
virtual void SetupTree() OVERRIDE {
- if (layer_tree_host()->settings().impl_side_painting)
- parent_ = FakePictureLayer::Create(&client_);
- else
- parent_ = FakeContentLayer::Create(&client_);
-
parent_->SetBounds(gfx::Size(num_children_, 1));
for (int i = 0; i < num_children_; i++) {
- scoped_refptr<Layer> child;
- if (layer_tree_host()->settings().impl_side_painting)
- child = FakePictureLayer::Create(&client_);
- else
- child = FakeContentLayer::Create(&client_);
+ scoped_refptr<FakeContentLayer> child =
+ FakeContentLayer::Create(&client_);
child->SetPosition(gfx::PointF(i, 0.f));
child->SetBounds(gfx::Size(1, 1));
parent_->AddChild(child);
@@ -648,7 +610,7 @@ class LayerTreeHostContextTestLostContextWhileUpdatingResources
private:
FakeContentLayerClient client_;
- scoped_refptr<Layer> parent_;
+ scoped_refptr<FakeContentLayer> parent_;
int num_children_;
int times_to_lose_on_end_query_;
};
@@ -662,15 +624,9 @@ class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest {
: LayerTreeHostContextTest(), num_commits_(0) {}
virtual void SetupTree() OVERRIDE {
- if (layer_tree_host()->settings().impl_side_painting) {
- root_ = FakePictureLayer::Create(&client_);
- child_ = FakePictureLayer::Create(&client_);
- grandchild_ = FakePictureLayer::Create(&client_);
- } else {
- root_ = FakeContentLayer::Create(&client_);
- child_ = FakeContentLayer::Create(&client_);
- grandchild_ = FakeContentLayer::Create(&client_);
- }
+ root_ = FakeContentLayer::Create(&client_);
+ child_ = FakeContentLayer::Create(&client_);
+ grandchild_ = FakeContentLayer::Create(&client_);
root_->AddChild(child_);
child_->AddChild(grandchild_);
@@ -684,58 +640,27 @@ class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest {
virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl);
- FakePictureLayerImpl* root_picture = NULL;
- FakePictureLayerImpl* child_picture = NULL;
- FakePictureLayerImpl* grandchild_picture = NULL;
- FakeContentLayerImpl* root_content = NULL;
- FakeContentLayerImpl* child_content = NULL;
- FakeContentLayerImpl* grandchild_content = NULL;
-
- if (layer_tree_host()->settings().impl_side_painting) {
- root_picture = static_cast<FakePictureLayerImpl*>(
- host_impl->active_tree()->root_layer());
- child_picture =
- static_cast<FakePictureLayerImpl*>(root_picture->children()[0]);
- grandchild_picture =
- static_cast<FakePictureLayerImpl*>(child_picture->children()[0]);
-
- } else {
- root_content = static_cast<FakeContentLayerImpl*>(
- host_impl->active_tree()->root_layer());
- child_content =
- static_cast<FakeContentLayerImpl*>(root_content->children()[0]);
- grandchild_content =
- static_cast<FakeContentLayerImpl*>(child_content->children()[0]);
- }
+ FakeContentLayerImpl* root = static_cast<FakeContentLayerImpl*>(
+ host_impl->active_tree()->root_layer());
+ FakeContentLayerImpl* child =
+ static_cast<FakeContentLayerImpl*>(root->children()[0]);
+ FakeContentLayerImpl* grandchild =
+ static_cast<FakeContentLayerImpl*>(child->children()[0]);
++num_commits_;
switch (num_commits_) {
case 1:
- if (layer_tree_host()->settings().impl_side_painting) {
- EXPECT_EQ(0u, root_picture->release_resources_count());
- EXPECT_EQ(0u, child_picture->release_resources_count());
- EXPECT_EQ(0u, grandchild_picture->release_resources_count());
- } else {
- EXPECT_EQ(0u, root_content->lost_output_surface_count());
- EXPECT_EQ(0u, child_content->lost_output_surface_count());
- EXPECT_EQ(0u, grandchild_content->lost_output_surface_count());
- }
-
+ EXPECT_EQ(0u, root->lost_output_surface_count());
+ EXPECT_EQ(0u, child->lost_output_surface_count());
+ EXPECT_EQ(0u, grandchild->lost_output_surface_count());
// Lose the context and struggle to recreate it.
LoseContext();
times_to_fail_create_ = 1;
break;
case 2:
- if (layer_tree_host()->settings().impl_side_painting) {
- EXPECT_TRUE(root_picture->release_resources_count());
- EXPECT_TRUE(child_picture->release_resources_count());
- EXPECT_TRUE(grandchild_picture->release_resources_count());
- } else {
- EXPECT_TRUE(root_content->lost_output_surface_count());
- EXPECT_TRUE(child_content->lost_output_surface_count());
- EXPECT_TRUE(grandchild_content->lost_output_surface_count());
- }
-
+ EXPECT_GE(1u, root->lost_output_surface_count());
+ EXPECT_GE(1u, child->lost_output_surface_count());
+ EXPECT_GE(1u, grandchild->lost_output_surface_count());
EndTest();
break;
default:
@@ -749,9 +674,9 @@ class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest {
int num_commits_;
FakeContentLayerClient client_;
- scoped_refptr<Layer> root_;
- scoped_refptr<Layer> child_;
- scoped_refptr<Layer> grandchild_;
+ scoped_refptr<FakeContentLayer> root_;
+ scoped_refptr<FakeContentLayer> child_;
+ scoped_refptr<FakeContentLayer> grandchild_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified);
@@ -829,14 +754,10 @@ class LayerTreeHostContextTestDontUseLostResources
delegated->SetIsDrawable(true);
root->AddChild(delegated);
- scoped_refptr<Layer> layer;
- if (layer_tree_host()->settings().impl_side_painting)
- layer = PictureLayer::Create(&client_);
- else
- layer = ContentLayer::Create(&client_);
- layer->SetBounds(gfx::Size(10, 10));
- layer->SetIsDrawable(true);
- root->AddChild(layer);
+ scoped_refptr<ContentLayer> content = ContentLayer::Create(&client_);
+ content->SetBounds(gfx::Size(10, 10));
+ content->SetIsDrawable(true);
+ root->AddChild(content);
scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL);
texture->SetBounds(gfx::Size(10, 10));
@@ -848,22 +769,15 @@ class LayerTreeHostContextTestDontUseLostResources
EmptyReleaseCallback)));
root->AddChild(texture);
- scoped_refptr<Layer> mask;
- if (layer_tree_host()->settings().impl_side_painting)
- mask = PictureLayer::Create(&client_);
- else
- mask = ContentLayer::Create(&client_);
+ scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client_);
mask->SetBounds(gfx::Size(10, 10));
- scoped_refptr<Layer> layer_with_mask;
- if (layer_tree_host()->settings().impl_side_painting)
- layer_with_mask = PictureLayer::Create(&client_);
- else
- layer_with_mask = ContentLayer::Create(&client_);
- layer_with_mask->SetBounds(gfx::Size(10, 10));
- layer_with_mask->SetIsDrawable(true);
- layer_with_mask->SetMaskLayer(mask.get());
- root->AddChild(layer_with_mask);
+ scoped_refptr<ContentLayer> content_with_mask =
+ ContentLayer::Create(&client_);
+ content_with_mask->SetBounds(gfx::Size(10, 10));
+ content_with_mask->SetIsDrawable(true);
+ content_with_mask->SetMaskLayer(mask.get());
+ root->AddChild(content_with_mask);
scoped_refptr<VideoLayer> video_color =
VideoLayer::Create(&color_frame_provider_, media::VIDEO_ROTATION_0);
@@ -924,7 +838,7 @@ class LayerTreeHostContextTestDontUseLostResources
scoped_refptr<PaintedScrollbarLayer> scrollbar =
PaintedScrollbarLayer::Create(
- scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), layer->id());
+ scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), content->id());
scrollbar->SetBounds(gfx::Size(10, 10));
scrollbar->SetIsDrawable(true);
root->AddChild(scrollbar);
@@ -1497,19 +1411,12 @@ class LayerTreeHostContextTestSurfaceCreateCallback
: public LayerTreeHostContextTest {
public:
LayerTreeHostContextTestSurfaceCreateCallback()
- : LayerTreeHostContextTest() {}
+ : LayerTreeHostContextTest(),
+ layer_(FakeContentLayer::Create(&client_)) {}
virtual void SetupTree() OVERRIDE {
- if (layer_tree_host()->settings().impl_side_painting) {
- picture_layer_ = FakePictureLayer::Create(&client_);
- picture_layer_->SetBounds(gfx::Size(10, 20));
- layer_tree_host()->SetRootLayer(picture_layer_);
- } else {
- content_layer_ = FakeContentLayer::Create(&client_);
- content_layer_->SetBounds(gfx::Size(10, 20));
- layer_tree_host()->SetRootLayer(content_layer_);
- }
-
+ layer_->SetBounds(gfx::Size(10, 20));
+ layer_tree_host()->SetRootLayer(layer_);
LayerTreeHostContextTest::SetupTree();
}
@@ -1518,30 +1425,18 @@ class LayerTreeHostContextTestSurfaceCreateCallback
virtual void DidCommit() OVERRIDE {
switch (layer_tree_host()->source_frame_number()) {
case 1:
- if (layer_tree_host()->settings().impl_side_painting)
- EXPECT_EQ(1u, picture_layer_->output_surface_created_count());
- else
- EXPECT_EQ(1u, content_layer_->output_surface_created_count());
+ EXPECT_EQ(1u, layer_->output_surface_created_count());
layer_tree_host()->SetNeedsCommit();
break;
case 2:
- if (layer_tree_host()->settings().impl_side_painting)
- EXPECT_EQ(1u, picture_layer_->output_surface_created_count());
- else
- EXPECT_EQ(1u, content_layer_->output_surface_created_count());
+ EXPECT_EQ(1u, layer_->output_surface_created_count());
layer_tree_host()->SetNeedsCommit();
break;
case 3:
- if (layer_tree_host()->settings().impl_side_painting)
- EXPECT_EQ(1u, picture_layer_->output_surface_created_count());
- else
- EXPECT_EQ(1u, content_layer_->output_surface_created_count());
+ EXPECT_EQ(1u, layer_->output_surface_created_count());
break;
case 4:
- if (layer_tree_host()->settings().impl_side_painting)
- EXPECT_EQ(2u, picture_layer_->output_surface_created_count());
- else
- EXPECT_EQ(2u, content_layer_->output_surface_created_count());
+ EXPECT_EQ(2u, layer_->output_surface_created_count());
layer_tree_host()->SetNeedsCommit();
break;
}
@@ -1567,8 +1462,7 @@ class LayerTreeHostContextTestSurfaceCreateCallback
protected:
FakeContentLayerClient client_;
- scoped_refptr<FakePictureLayer> picture_layer_;
- scoped_refptr<FakeContentLayer> content_layer_;
+ scoped_refptr<FakeContentLayer> layer_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback);
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698