summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsohan.jyoti <sohan.jyoti@samsung.com>2014-09-17 01:03:23 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-17 08:03:52 +0000
commitfa27ef28c604c3bd343f7d8298ac3f328a9a0037 (patch)
tree6db6264edc5b3c5a18aeaba9e1adaa433b427fe8
parentee619053c02ead7375c1626d4de9870ddb330614 (diff)
downloadchromium_src-fa27ef28c604c3bd343f7d8298ac3f328a9a0037.zip
chromium_src-fa27ef28c604c3bd343f7d8298ac3f328a9a0037.tar.gz
chromium_src-fa27ef28c604c3bd343f7d8298ac3f328a9a0037.tar.bz2
cc: Use impl-side painting in LTH context lost tests.
BUG=401492 Review URL: https://codereview.chromium.org/475633008 Cr-Commit-Position: refs/heads/master@{#295241}
-rw-r--r--cc/test/fake_picture_layer.cc7
-rw-r--r--cc/test/fake_picture_layer.h6
-rw-r--r--cc/test/fake_picture_layer_impl.cc14
-rw-r--r--cc/test/fake_picture_layer_impl.h6
-rw-r--r--cc/trees/layer_tree_host_impl.cc5
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc121
-rw-r--r--cc/trees/layer_tree_host_unittest_context.cc248
7 files changed, 298 insertions, 109 deletions
diff --git a/cc/test/fake_picture_layer.cc b/cc/test/fake_picture_layer.cc
index 2a5d2e9..12cad83 100644
--- a/cc/test/fake_picture_layer.cc
+++ b/cc/test/fake_picture_layer.cc
@@ -12,7 +12,8 @@ FakePictureLayer::FakePictureLayer(ContentLayerClient* client)
: PictureLayer(client),
update_count_(0),
push_properties_count_(0),
- always_update_resources_(false) {
+ always_update_resources_(false),
+ output_surface_created_count_(0) {
SetBounds(gfx::Size(1, 1));
SetIsDrawable(true);
}
@@ -36,5 +37,9 @@ void FakePictureLayer::PushPropertiesTo(LayerImpl* layer) {
push_properties_count_++;
}
+void FakePictureLayer::OnOutputSurfaceCreated() {
+ PictureLayer::OnOutputSurfaceCreated();
+ output_surface_created_count_++;
+}
} // namespace cc
diff --git a/cc/test/fake_picture_layer.h b/cc/test/fake_picture_layer.h
index 99217c2..10f9a9c 100644
--- a/cc/test/fake_picture_layer.h
+++ b/cc/test/fake_picture_layer.h
@@ -35,6 +35,11 @@ class FakePictureLayer : public PictureLayer {
virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
+ virtual void OnOutputSurfaceCreated() OVERRIDE;
+ size_t output_surface_created_count() const {
+ return output_surface_created_count_;
+ }
+
private:
explicit FakePictureLayer(ContentLayerClient* client);
virtual ~FakePictureLayer();
@@ -42,6 +47,7 @@ class FakePictureLayer : public PictureLayer {
size_t update_count_;
size_t push_properties_count_;
bool always_update_resources_;
+ size_t output_surface_created_count_;
};
} // namespace cc
diff --git a/cc/test/fake_picture_layer_impl.cc b/cc/test/fake_picture_layer_impl.cc
index 98e0f6e..f2a5d5c 100644
--- a/cc/test/fake_picture_layer_impl.cc
+++ b/cc/test/fake_picture_layer_impl.cc
@@ -17,7 +17,8 @@ FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl,
append_quads_count_(0),
did_become_active_call_count_(0),
has_valid_tile_priorities_(false),
- use_set_valid_tile_priorities_flag_(false) {
+ use_set_valid_tile_priorities_flag_(false),
+ release_resources_count_(0) {
pile_ = pile;
SetBounds(pile_->tiling_size());
SetContentBounds(pile_->tiling_size());
@@ -31,7 +32,8 @@ FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl,
append_quads_count_(0),
did_become_active_call_count_(0),
has_valid_tile_priorities_(false),
- use_set_valid_tile_priorities_flag_(false) {
+ use_set_valid_tile_priorities_flag_(false),
+ release_resources_count_(0) {
pile_ = pile;
SetBounds(layer_bounds);
SetContentBounds(layer_bounds);
@@ -42,7 +44,8 @@ FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id)
append_quads_count_(0),
did_become_active_call_count_(0),
has_valid_tile_priorities_(false),
- use_set_valid_tile_priorities_flag_(false) {
+ use_set_valid_tile_priorities_flag_(false),
+ release_resources_count_(0) {
}
scoped_ptr<LayerImpl> FakePictureLayerImpl::CreateLayerImpl(
@@ -179,4 +182,9 @@ bool FakePictureLayerImpl::HasValidTilePriorities() const {
: PictureLayerImpl::HasValidTilePriorities();
}
+void FakePictureLayerImpl::ReleaseResources() {
+ PictureLayerImpl::ReleaseResources();
+ ++release_resources_count_;
+}
+
} // namespace cc
diff --git a/cc/test/fake_picture_layer_impl.h b/cc/test/fake_picture_layer_impl.h
index fbaecf7..a06805c 100644
--- a/cc/test/fake_picture_layer_impl.h
+++ b/cc/test/fake_picture_layer_impl.h
@@ -112,6 +112,11 @@ class FakePictureLayerImpl : public PictureLayerImpl {
void ResetAllTilesPriorities();
PictureLayerTilingSet* GetTilings() { return tilings_.get(); }
+ size_t release_resources_count() const { return release_resources_count_; }
+ void reset_release_resources_count() { release_resources_count_ = 0; }
+
+ virtual void ReleaseResources() OVERRIDE;
+
protected:
FakePictureLayerImpl(
LayerTreeImpl* tree_impl,
@@ -130,6 +135,7 @@ class FakePictureLayerImpl : public PictureLayerImpl {
size_t did_become_active_call_count_;
bool has_valid_tile_priorities_;
bool use_set_valid_tile_priorities_flag_;
+ size_t release_resources_count_;
};
} // namespace cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 26e0690..0fa8553 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -2115,6 +2115,11 @@ bool LayerTreeHostImpl::InitializeRenderer(
client_->SetMaxSwapsPendingOnImplThread(max_frames_pending);
client_->OnCanDrawStateChanged(CanDraw());
+ // There will not be anything to draw here, so set high res
+ // to avoid checkerboards, typically when we are recovering
+ // from lost context.
+ active_tree_->SetRequiresHighResToDraw();
+
return true;
}
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 94ecb17..40c9bdd 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -1921,6 +1921,12 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) {
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame);
+ host_impl_->SwapBuffers(frame);
+
bool tile_missing = true;
bool had_incomplete_tile = false;
bool is_animating = false;
@@ -1931,10 +1937,10 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) {
had_incomplete_tile,
is_animating,
host_impl_->resource_provider()));
- LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
- host_impl_->DidDrawAllLayers(frame);
+ LayerTreeHostImpl::FrameData frame2;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2));
+ host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame2);
}
TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) {
@@ -1943,6 +1949,12 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) {
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame);
+ host_impl_->SwapBuffers(frame);
+
bool tile_missing = false;
bool had_incomplete_tile = true;
bool is_animating = false;
@@ -1953,10 +1965,10 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) {
had_incomplete_tile,
is_animating,
host_impl_->resource_provider()));
- LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
- host_impl_->DidDrawAllLayers(frame);
+ LayerTreeHostImpl::FrameData frame2;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2));
+ host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame2);
}
TEST_F(LayerTreeHostImplTest,
@@ -1965,6 +1977,13 @@ TEST_F(LayerTreeHostImplTest,
DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
+
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame);
+ host_impl_->SwapBuffers(frame);
+
bool tile_missing = true;
bool had_incomplete_tile = false;
bool is_animating = true;
@@ -1975,11 +1994,11 @@ TEST_F(LayerTreeHostImplTest,
had_incomplete_tile,
is_animating,
host_impl_->resource_provider()));
- LayerTreeHostImpl::FrameData frame;
+ LayerTreeHostImpl::FrameData frame2;
EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS,
- host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
- host_impl_->DidDrawAllLayers(frame);
+ host_impl_->PrepareToDraw(&frame2));
+ host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame2);
}
TEST_F(LayerTreeHostImplTest,
@@ -1988,6 +2007,13 @@ TEST_F(LayerTreeHostImplTest,
DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
+
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame);
+ host_impl_->SwapBuffers(frame);
+
bool tile_missing = false;
bool had_incomplete_tile = true;
bool is_animating = true;
@@ -1998,10 +2024,10 @@ TEST_F(LayerTreeHostImplTest,
had_incomplete_tile,
is_animating,
host_impl_->resource_provider()));
- LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
- host_impl_->DidDrawAllLayers(frame);
+ LayerTreeHostImpl::FrameData frame2;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2));
+ host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame2);
}
TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) {
@@ -2009,6 +2035,13 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) {
DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
+
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame);
+ host_impl_->SwapBuffers(frame);
+
bool tile_missing = false;
bool had_incomplete_tile = false;
bool is_animating = false;
@@ -2020,10 +2053,10 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) {
is_animating,
host_impl_->resource_provider()));
host_impl_->active_tree()->SetRequiresHighResToDraw();
- LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
- host_impl_->DidDrawAllLayers(frame);
+ LayerTreeHostImpl::FrameData frame2;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2));
+ host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame2);
}
TEST_F(LayerTreeHostImplTest,
@@ -2032,6 +2065,13 @@ TEST_F(LayerTreeHostImplTest,
DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
+
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame);
+ host_impl_->SwapBuffers(frame);
+
bool tile_missing = false;
bool had_incomplete_tile = true;
bool is_animating = false;
@@ -2043,11 +2083,11 @@ TEST_F(LayerTreeHostImplTest,
is_animating,
host_impl_->resource_provider()));
host_impl_->active_tree()->SetRequiresHighResToDraw();
- LayerTreeHostImpl::FrameData frame;
+ LayerTreeHostImpl::FrameData frame2;
EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
- host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
- host_impl_->DidDrawAllLayers(frame);
+ host_impl_->PrepareToDraw(&frame2));
+ host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame2);
}
TEST_F(LayerTreeHostImplTest,
@@ -2056,6 +2096,13 @@ TEST_F(LayerTreeHostImplTest,
DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
+
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame);
+ host_impl_->SwapBuffers(frame);
+
bool tile_missing = true;
bool had_incomplete_tile = false;
bool is_animating = false;
@@ -2067,11 +2114,11 @@ TEST_F(LayerTreeHostImplTest,
is_animating,
host_impl_->resource_provider()));
host_impl_->active_tree()->SetRequiresHighResToDraw();
- LayerTreeHostImpl::FrameData frame;
+ LayerTreeHostImpl::FrameData frame2;
EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
- host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
- host_impl_->DidDrawAllLayers(frame);
+ host_impl_->PrepareToDraw(&frame2));
+ host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame2);
}
TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
@@ -5889,7 +5936,11 @@ TEST_F(LayerTreeHostImplTest, MemoryPolicy) {
TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) {
ASSERT_TRUE(host_impl_->active_tree());
- EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw());
+ // RequiresHighResToDraw is set when new output surface is used.
+ EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw());
+
+ host_impl_->active_tree()->ResetRequiresHighResToDraw();
+
host_impl_->SetVisible(false);
EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw());
host_impl_->SetVisible(true);
@@ -5897,8 +5948,7 @@ TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) {
host_impl_->SetVisible(false);
EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw());
- host_impl_->CreatePendingTree();
- host_impl_->ActivateSyncTree();
+ host_impl_->active_tree()->ResetRequiresHighResToDraw();
EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw());
host_impl_->SetVisible(true);
@@ -5909,7 +5959,11 @@ TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) {
ASSERT_TRUE(host_impl_->active_tree());
EXPECT_FALSE(host_impl_->use_gpu_rasterization());
- EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw());
+ // RequiresHighResToDraw is set when new output surface is used.
+ EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw());
+
+ host_impl_->active_tree()->ResetRequiresHighResToDraw();
+
host_impl_->SetUseGpuRasterization(false);
EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw());
host_impl_->SetUseGpuRasterization(true);
@@ -5917,8 +5971,7 @@ TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) {
host_impl_->SetUseGpuRasterization(false);
EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw());
- host_impl_->CreatePendingTree();
- host_impl_->ActivateSyncTree();
+ host_impl_->active_tree()->ResetRequiresHighResToDraw();
EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw());
host_impl_->SetUseGpuRasterization(true);
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index 0e15071..b87eeaf 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,20 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
public:
LayerTreeHostContextTestLostContextAndEvictTextures()
: LayerTreeHostContextTest(),
- layer_(FakeContentLayer::Create(&client_)),
impl_host_(0),
num_commits_(0) {}
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();
}
@@ -464,6 +487,12 @@ 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();
}
@@ -471,17 +500,19 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
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();
}
- virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
- LayerTreeHostContextTest::CommitCompleteOnThread(impl);
- if (num_commits_ > 1)
- return;
- ++num_commits_;
- if (!lose_after_evict_)
- LoseContext();
+ 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());
+ }
+
impl_host_ = impl;
}
@@ -492,7 +523,8 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
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_;
};
@@ -568,9 +600,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 +613,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 +648,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 +662,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 +684,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 +749,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 +829,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 +848,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 +924,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 +1497,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 +1518,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 +1567,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);