| 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 0e15071458f3842a22cbe1913183b66eeacbc1bc..007059749676cdffb3affc9a4a426c502d463628 100644
|
| --- a/cc/trees/layer_tree_host_unittest_context.cc
|
| +++ b/cc/trees/layer_tree_host_unittest_context.cc
|
| @@ -28,6 +28,8 @@
|
| #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"
|
| @@ -323,11 +325,19 @@ class LayerTreeHostContextTestLostContextSucceedsWithContent
|
| root_->SetBounds(gfx::Size(10, 10));
|
| root_->SetIsDrawable(true);
|
|
|
| - content_ = FakeContentLayer::Create(&client_);
|
| - content_->SetBounds(gfx::Size(10, 10));
|
| - content_->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);
|
|
|
| - root_->AddChild(content_);
|
| + 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_);
|
|
|
| layer_tree_host()->SetRootLayer(root_);
|
| LayerTreeHostContextTest::SetupTree();
|
| @@ -337,27 +347,33 @@ 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.
|
| - content_->SetNeedsDisplay();
|
| + layer_->SetNeedsDisplay();
|
| LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit();
|
| }
|
|
|
| virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
|
| - 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));
|
| + 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());
|
| + }
|
| }
|
|
|
| protected:
|
| FakeContentLayerClient client_;
|
| scoped_refptr<Layer> root_;
|
| - scoped_refptr<ContentLayer> content_;
|
| + scoped_refptr<Layer> layer_;
|
| };
|
|
|
| -// This test uses TiledLayer to check for a working context.
|
| -SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
|
| +// This test uses TiledLayer and PictureLayer to check for a working context.
|
| +SINGLE_AND_MULTI_THREAD_TEST_F(
|
| LayerTreeHostContextTestLostContextSucceedsWithContent);
|
|
|
| class LayerTreeHostContextTestCreateOutputSurfaceFails
|
| @@ -437,13 +453,26 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
|
| public:
|
| LayerTreeHostContextTestLostContextAndEvictTextures()
|
| : LayerTreeHostContextTest(),
|
| - layer_(FakeContentLayer::Create(&client_)),
|
| impl_host_(0),
|
| - num_commits_(0) {}
|
| + num_commits_(0),
|
| + lost_context_(false) {}
|
|
|
| virtual void SetupTree() OVERRIDE {
|
| - layer_->SetBounds(gfx::Size(10, 20));
|
| - layer_tree_host()->SetRootLayer(layer_);
|
| + // Paint non-solid color.
|
| + SkPaint paint;
|
| + paint.setColor(SkColorSetARGB(100, 80, 200, 200));
|
| + client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint);
|
| +
|
| + 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_);
|
| + }
|
| +
|
| LayerTreeHostContextTest::SetupTree();
|
| }
|
|
|
| @@ -464,14 +493,19 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
|
|
|
| void EvictTexturesOnImplThread() {
|
| impl_host_->EvictTexturesForTesting();
|
| - if (lose_after_evict_)
|
| +
|
| + if (lose_after_evict_) {
|
| LoseContext();
|
| + lost_context_ = true;
|
| + }
|
| }
|
|
|
| virtual void DidCommitAndDrawFrame() OVERRIDE {
|
| if (num_commits_ > 1)
|
| return;
|
| - EXPECT_TRUE(layer_->HaveBackingAt(0, 0));
|
| + if (!layer_tree_host()->settings().impl_side_painting) {
|
| + EXPECT_TRUE(content_layer_->HaveBackingAt(0, 0));
|
| + }
|
| PostEvictTextures();
|
| }
|
|
|
| @@ -480,21 +514,40 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
|
| if (num_commits_ > 1)
|
| return;
|
| ++num_commits_;
|
| - if (!lose_after_evict_)
|
| + if (!lose_after_evict_) {
|
| LoseContext();
|
| + lost_context_ = true;
|
| + }
|
| + }
|
| +
|
| + virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
|
| + if (impl->settings().impl_side_painting) {
|
| + FakePictureLayerImpl* picture_impl =
|
| + static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer());
|
| + EXPECT_TRUE(picture_impl->HighResTiling()->TileAt(0, 0)->IsReadyToDraw());
|
| + } else {
|
| + FakeContentLayerImpl* content_impl =
|
| + static_cast<FakeContentLayerImpl*>(impl->active_tree()->root_layer());
|
| + EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0));
|
| + }
|
| +
|
| impl_host_ = impl;
|
| + if (lost_context_)
|
| + EndTest();
|
| }
|
|
|
| - virtual void DidInitializeOutputSurface() OVERRIDE { EndTest(); }
|
| + virtual void DidInitializeOutputSurface() OVERRIDE {}
|
|
|
| virtual void AfterTest() OVERRIDE {}
|
|
|
| protected:
|
| bool lose_after_evict_;
|
| FakeContentLayerClient client_;
|
| - scoped_refptr<FakeContentLayer> layer_;
|
| + scoped_refptr<FakeContentLayer> content_layer_;
|
| + scoped_refptr<FakePictureLayer> picture_layer_;
|
| LayerTreeHostImpl* impl_host_;
|
| int num_commits_;
|
| + bool lost_context_;
|
| };
|
|
|
| TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
|
| @@ -568,9 +621,7 @@ class LayerTreeHostContextTestLostContextWhileUpdatingResources
|
| : public LayerTreeHostContextTest {
|
| public:
|
| LayerTreeHostContextTestLostContextWhileUpdatingResources()
|
| - : parent_(FakeContentLayer::Create(&client_)),
|
| - num_children_(50),
|
| - times_to_lose_on_end_query_(3) {}
|
| + : num_children_(50), times_to_lose_on_end_query_(3) {}
|
|
|
| virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() OVERRIDE {
|
| scoped_ptr<TestWebGraphicsContext3D> context =
|
| @@ -583,11 +634,19 @@ 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<FakeContentLayer> child =
|
| - FakeContentLayer::Create(&client_);
|
| + scoped_refptr<Layer> child;
|
| + if (layer_tree_host()->settings().impl_side_painting)
|
| + child = FakePictureLayer::Create(&client_);
|
| + else
|
| + child = FakeContentLayer::Create(&client_);
|
| child->SetPosition(gfx::PointF(i, 0.f));
|
| child->SetBounds(gfx::Size(1, 1));
|
| parent_->AddChild(child);
|
| @@ -610,7 +669,7 @@ class LayerTreeHostContextTestLostContextWhileUpdatingResources
|
|
|
| private:
|
| FakeContentLayerClient client_;
|
| - scoped_refptr<FakeContentLayer> parent_;
|
| + scoped_refptr<Layer> parent_;
|
| int num_children_;
|
| int times_to_lose_on_end_query_;
|
| };
|
| @@ -624,9 +683,15 @@ class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest {
|
| : LayerTreeHostContextTest(), num_commits_(0) {}
|
|
|
| virtual void SetupTree() OVERRIDE {
|
| - root_ = FakeContentLayer::Create(&client_);
|
| - child_ = FakeContentLayer::Create(&client_);
|
| - grandchild_ = FakeContentLayer::Create(&client_);
|
| + 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_->AddChild(child_);
|
| child_->AddChild(grandchild_);
|
| @@ -640,27 +705,58 @@ class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest {
|
| virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
|
| LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl);
|
|
|
| - 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]);
|
| + 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]);
|
| + }
|
|
|
| ++num_commits_;
|
| switch (num_commits_) {
|
| case 1:
|
| - EXPECT_EQ(0u, root->lost_output_surface_count());
|
| - EXPECT_EQ(0u, child->lost_output_surface_count());
|
| - EXPECT_EQ(0u, grandchild->lost_output_surface_count());
|
| + 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());
|
| + }
|
| +
|
| // Lose the context and struggle to recreate it.
|
| LoseContext();
|
| times_to_fail_create_ = 1;
|
| break;
|
| case 2:
|
| - EXPECT_GE(1u, root->lost_output_surface_count());
|
| - EXPECT_GE(1u, child->lost_output_surface_count());
|
| - EXPECT_GE(1u, grandchild->lost_output_surface_count());
|
| + 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());
|
| + }
|
| +
|
| EndTest();
|
| break;
|
| default:
|
| @@ -674,9 +770,9 @@ class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest {
|
| int num_commits_;
|
|
|
| FakeContentLayerClient client_;
|
| - scoped_refptr<FakeContentLayer> root_;
|
| - scoped_refptr<FakeContentLayer> child_;
|
| - scoped_refptr<FakeContentLayer> grandchild_;
|
| + scoped_refptr<Layer> root_;
|
| + scoped_refptr<Layer> child_;
|
| + scoped_refptr<Layer> grandchild_;
|
| };
|
|
|
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified);
|
| @@ -754,10 +850,14 @@ class LayerTreeHostContextTestDontUseLostResources
|
| delegated->SetIsDrawable(true);
|
| root->AddChild(delegated);
|
|
|
| - scoped_refptr<ContentLayer> content = ContentLayer::Create(&client_);
|
| - content->SetBounds(gfx::Size(10, 10));
|
| - content->SetIsDrawable(true);
|
| - root->AddChild(content);
|
| + 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<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL);
|
| texture->SetBounds(gfx::Size(10, 10));
|
| @@ -769,15 +869,22 @@ class LayerTreeHostContextTestDontUseLostResources
|
| EmptyReleaseCallback)));
|
| root->AddChild(texture);
|
|
|
| - scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client_);
|
| + scoped_refptr<Layer> mask;
|
| + if (layer_tree_host()->settings().impl_side_painting)
|
| + mask = PictureLayer::Create(&client_);
|
| + else
|
| + mask = ContentLayer::Create(&client_);
|
| mask->SetBounds(gfx::Size(10, 10));
|
|
|
| - 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<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<VideoLayer> video_color =
|
| VideoLayer::Create(&color_frame_provider_, media::VIDEO_ROTATION_0);
|
| @@ -838,7 +945,7 @@ class LayerTreeHostContextTestDontUseLostResources
|
|
|
| scoped_refptr<PaintedScrollbarLayer> scrollbar =
|
| PaintedScrollbarLayer::Create(
|
| - scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), content->id());
|
| + scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), layer->id());
|
| scrollbar->SetBounds(gfx::Size(10, 10));
|
| scrollbar->SetIsDrawable(true);
|
| root->AddChild(scrollbar);
|
| @@ -1411,12 +1518,19 @@ class LayerTreeHostContextTestSurfaceCreateCallback
|
| : public LayerTreeHostContextTest {
|
| public:
|
| LayerTreeHostContextTestSurfaceCreateCallback()
|
| - : LayerTreeHostContextTest(),
|
| - layer_(FakeContentLayer::Create(&client_)) {}
|
| + : LayerTreeHostContextTest() {}
|
|
|
| virtual void SetupTree() OVERRIDE {
|
| - layer_->SetBounds(gfx::Size(10, 20));
|
| - layer_tree_host()->SetRootLayer(layer_);
|
| + 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_);
|
| + }
|
| +
|
| LayerTreeHostContextTest::SetupTree();
|
| }
|
|
|
| @@ -1425,18 +1539,30 @@ class LayerTreeHostContextTestSurfaceCreateCallback
|
| virtual void DidCommit() OVERRIDE {
|
| switch (layer_tree_host()->source_frame_number()) {
|
| case 1:
|
| - EXPECT_EQ(1u, layer_->output_surface_created_count());
|
| + 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());
|
| layer_tree_host()->SetNeedsCommit();
|
| break;
|
| case 2:
|
| - EXPECT_EQ(1u, layer_->output_surface_created_count());
|
| + 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());
|
| layer_tree_host()->SetNeedsCommit();
|
| break;
|
| case 3:
|
| - EXPECT_EQ(1u, layer_->output_surface_created_count());
|
| + 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());
|
| break;
|
| case 4:
|
| - EXPECT_EQ(2u, layer_->output_surface_created_count());
|
| + 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());
|
| layer_tree_host()->SetNeedsCommit();
|
| break;
|
| }
|
| @@ -1462,7 +1588,8 @@ class LayerTreeHostContextTestSurfaceCreateCallback
|
|
|
| protected:
|
| FakeContentLayerClient client_;
|
| - scoped_refptr<FakeContentLayer> layer_;
|
| + scoped_refptr<FakePictureLayer> picture_layer_;
|
| + scoped_refptr<FakeContentLayer> content_layer_;
|
| };
|
|
|
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback);
|
|
|