summaryrefslogtreecommitdiff
path: root/chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-01-04 14:17:57 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-01-05 10:05:06 +0000
commit39d357e3248f80abea0159765ff39554affb40db (patch)
treeaba0e6bfb76de0244bba0f5fdbd64b830dd6e621 /chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc
parent87778abf5a1f89266f37d1321b92a21851d8244d (diff)
downloadqtwebengine-chromium-39d357e3248f80abea0159765ff39554affb40db.tar.gz
BASELINE: Update Chromium to 55.0.2883.105
And updates ninja to 1.7.2 Change-Id: I20d43c737f82764d857ada9a55586901b18b9243 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc')
-rw-r--r--chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc360
1 files changed, 189 insertions, 171 deletions
diff --git a/chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc b/chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc
index e27498a396e..ef0c1fbbc5a 100644
--- a/chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc
+++ b/chromium/cc/trees/layer_tree_host_unittest_copyrequest.cc
@@ -11,10 +11,13 @@
#include "cc/layers/layer_iterator.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
+#include "cc/output/direct_renderer.h"
+#include "cc/surfaces/display.h"
#include "cc/test/fake_content_layer_client.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_picture_layer.h"
#include "cc/test/layer_tree_test.h"
+#include "cc/test/test_compositor_frame_sink.h"
#include "cc/trees/layer_tree_impl.h"
#include "gpu/GLES2/gl2extchromium.h"
@@ -40,7 +43,7 @@ class LayerTreeHostCopyRequestTestMultipleRequests
grand_child->SetBounds(gfx::Size(5, 5));
child->AddChild(grand_child);
- layer_tree_host()->SetRootLayer(root);
+ layer_tree()->SetRootLayer(root);
LayerTreeHostCopyRequestTest::SetupTree();
client_.set_bounds(root->bounds());
}
@@ -57,7 +60,7 @@ class LayerTreeHostCopyRequestTestMultipleRequests
}
void NextStep() {
- int frame = layer_tree_host()->source_frame_number();
+ int frame = layer_tree_host()->SourceFrameNumber();
switch (frame) {
case 1:
child->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest(
@@ -116,7 +119,7 @@ class LayerTreeHostCopyRequestTestMultipleRequests
}
void CopyOutputCallback(size_t id, std::unique_ptr<CopyOutputResult> result) {
- EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread());
+ EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread());
EXPECT_TRUE(result->HasBitmap());
std::unique_ptr<SkBitmap> bitmap = result->TakeBitmap();
EXPECT_EQ(result->size().ToString(),
@@ -126,17 +129,19 @@ class LayerTreeHostCopyRequestTestMultipleRequests
void AfterTest() override { EXPECT_EQ(4u, callbacks_.size()); }
- std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
+ std::unique_ptr<OutputSurface> CreateDisplayOutputSurface(
+ scoped_refptr<ContextProvider> compositor_context_provider) override {
if (!use_gl_renderer_) {
return FakeOutputSurface::CreateSoftware(
base::WrapUnique(new SoftwareOutputDevice));
}
- std::unique_ptr<FakeOutputSurface> output_surface =
- FakeOutputSurface::Create3d();
- TestContextSupport* context_support = static_cast<TestContextSupport*>(
- output_surface->context_provider()->ContextSupport());
+
+ scoped_refptr<TestContextProvider> display_context_provider =
+ TestContextProvider::Create();
+ TestContextSupport* context_support = display_context_provider->support();
context_support->set_out_of_order_callbacks(out_of_order_callbacks_);
- return output_surface;
+
+ return FakeOutputSurface::Create3d(std::move(display_context_provider));
}
bool use_gl_renderer_;
@@ -148,43 +153,42 @@ class LayerTreeHostCopyRequestTestMultipleRequests
scoped_refptr<FakePictureLayer> grand_child;
};
-// Readback can't be done with a delegating renderer.
TEST_F(LayerTreeHostCopyRequestTestMultipleRequests,
GLRenderer_RunSingleThread) {
use_gl_renderer_ = true;
- RunTest(CompositorMode::SINGLE_THREADED, false);
+ RunTest(CompositorMode::SINGLE_THREADED);
}
TEST_F(LayerTreeHostCopyRequestTestMultipleRequests,
GLRenderer_RunMultiThread) {
use_gl_renderer_ = true;
- RunTest(CompositorMode::THREADED, false);
+ RunTest(CompositorMode::THREADED);
}
TEST_F(LayerTreeHostCopyRequestTestMultipleRequests,
GLRenderer_RunSingleThread_OutOfOrderCallbacks) {
use_gl_renderer_ = true;
out_of_order_callbacks_ = true;
- RunTest(CompositorMode::SINGLE_THREADED, false);
+ RunTest(CompositorMode::SINGLE_THREADED);
}
TEST_F(LayerTreeHostCopyRequestTestMultipleRequests,
GLRenderer_RunMultiThread_OutOfOrderCallbacks) {
use_gl_renderer_ = true;
out_of_order_callbacks_ = true;
- RunTest(CompositorMode::THREADED, false);
+ RunTest(CompositorMode::THREADED);
}
TEST_F(LayerTreeHostCopyRequestTestMultipleRequests,
SoftwareRenderer_RunSingleThread) {
use_gl_renderer_ = false;
- RunTest(CompositorMode::SINGLE_THREADED, false);
+ RunTest(CompositorMode::SINGLE_THREADED);
}
TEST_F(LayerTreeHostCopyRequestTestMultipleRequests,
SoftwareRenderer_RunMultiThread) {
use_gl_renderer_ = false;
- RunTest(CompositorMode::THREADED, false);
+ RunTest(CompositorMode::THREADED);
}
// TODO(crbug.com/564832): Remove this test when the workaround it tests is no
@@ -200,7 +204,7 @@ class LayerTreeHostCopyRequestCompletionCausesCommit
layer_->SetBounds(gfx::Size(15, 15));
root_->AddChild(layer_);
- layer_tree_host()->SetRootLayer(root_);
+ layer_tree()->SetRootLayer(root_);
LayerTreeHostCopyRequestTest::SetupTree();
client_.set_bounds(root_->bounds());
}
@@ -210,7 +214,7 @@ class LayerTreeHostCopyRequestCompletionCausesCommit
}
void DidCommit() override {
- int frame = layer_tree_host()->source_frame_number();
+ int frame = layer_tree_host()->SourceFrameNumber();
switch (frame) {
case 1:
layer_->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest(
@@ -238,8 +242,7 @@ class LayerTreeHostCopyRequestCompletionCausesCommit
scoped_refptr<FakePictureLayer> layer_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
- LayerTreeHostCopyRequestCompletionCausesCommit);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestCompletionCausesCommit);
class LayerTreeHostCopyRequestTestLayerDestroyed
: public LayerTreeHostCopyRequestTest {
@@ -256,7 +259,7 @@ class LayerTreeHostCopyRequestTestLayerDestroyed
impl_destroyed_->SetBounds(gfx::Size(10, 10));
root_->AddChild(impl_destroyed_);
- layer_tree_host()->SetRootLayer(root_);
+ layer_tree()->SetRootLayer(root_);
LayerTreeHostCopyRequestTest::SetupTree();
client_.set_bounds(root_->bounds());
}
@@ -267,7 +270,7 @@ class LayerTreeHostCopyRequestTestLayerDestroyed
}
void DidCommit() override {
- int frame = layer_tree_host()->source_frame_number();
+ int frame = layer_tree_host()->SourceFrameNumber();
switch (frame) {
case 1:
main_destroyed_->RequestCopyOfOutput(
@@ -288,7 +291,7 @@ class LayerTreeHostCopyRequestTestLayerDestroyed
EXPECT_EQ(1, callback_count_);
// Prevent drawing so we can't make a copy of the impl_destroyed layer.
- layer_tree_host()->SetViewportSize(gfx::Size());
+ layer_tree()->SetViewportSize(gfx::Size());
break;
case 2:
// Flush the message loops and make sure the callbacks run.
@@ -318,7 +321,7 @@ class LayerTreeHostCopyRequestTestLayerDestroyed
}
void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {
- EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread());
+ EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread());
EXPECT_TRUE(result->IsEmpty());
++callback_count_;
}
@@ -355,7 +358,7 @@ class LayerTreeHostCopyRequestTestInHiddenSubtree
copy_layer_->SetBounds(gfx::Size(10, 10));
parent_layer_->AddChild(copy_layer_);
- layer_tree_host()->SetRootLayer(root_);
+ layer_tree()->SetRootLayer(root_);
LayerTreeHostCopyRequestTest::SetupTree();
client_.set_bounds(root_->bounds());
}
@@ -376,7 +379,7 @@ class LayerTreeHostCopyRequestTestInHiddenSubtree
void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {
++callback_count_;
- EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread());
+ EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread());
EXPECT_EQ(copy_layer_->bounds().ToString(), result->size().ToString())
<< callback_count_;
switch (callback_count_) {
@@ -431,8 +434,7 @@ class LayerTreeHostCopyRequestTestInHiddenSubtree
scoped_refptr<FakePictureLayer> copy_layer_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
- LayerTreeHostCopyRequestTestInHiddenSubtree);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestInHiddenSubtree);
class LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest
: public LayerTreeHostCopyRequestTest {
@@ -456,13 +458,22 @@ class LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest
copy_layer_->SetBounds(gfx::Size(10, 10));
parent_layer_->AddChild(copy_layer_);
- layer_tree_host()->SetRootLayer(root_);
+ layer_tree()->SetRootLayer(root_);
LayerTreeHostCopyRequestTest::SetupTree();
client_.set_bounds(root_->bounds());
}
+ std::unique_ptr<TestCompositorFrameSink> CreateCompositorFrameSink(
+ scoped_refptr<ContextProvider> compositor_context_provider,
+ scoped_refptr<ContextProvider> worker_context_provider) override {
+ auto surface = LayerTreeHostCopyRequestTest::CreateCompositorFrameSink(
+ std::move(compositor_context_provider),
+ std::move(worker_context_provider));
+ display_ = surface->display();
+ return surface;
+ }
+
void BeginTest() override {
- did_draw_ = false;
PostSetNeedsCommitToMainThread();
copy_layer_->RequestCopyOfOutput(
@@ -473,50 +484,65 @@ class LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest
}
void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {
- EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread());
+ EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread());
EXPECT_EQ(copy_layer_->bounds().ToString(), result->size().ToString());
EndTest();
}
- void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
- Renderer* renderer = host_impl->renderer();
+ void DisplayWillDrawAndSwapOnThread(
+ bool will_draw_and_swap,
+ const RenderPassList& render_passes) override {
+ EXPECT_TRUE(will_draw_and_swap) << did_swap_;
+ if (did_swap_) {
+ // TODO(crbug.com/564832): Ignore the extra frame that occurs due to copy
+ // completion. This can be removed when the extra commit is removed.
+ EXPECT_EQ(1u, render_passes.size());
+ return;
+ }
+
+ EXPECT_EQ(2u, render_passes.size());
+ // The root pass is the back of the list.
+ copy_layer_render_pass_id = render_passes[0]->id;
+ parent_render_pass_id = render_passes[1]->id;
+ }
- LayerImpl* parent =
- host_impl->active_tree()->LayerById(parent_layer_->id());
- LayerImpl* copy_layer =
- host_impl->active_tree()->LayerById(copy_layer_->id());
+ void DisplayDidDrawAndSwapOnThread() override {
+ DirectRenderer* renderer = display_->renderer_for_testing();
// |parent| owns a surface, but it was hidden and not part of the copy
// request so it should not allocate any resource.
- EXPECT_FALSE(renderer->HasAllocatedResourcesForTesting(
- parent->render_surface()->GetRenderPassId()));
-
- // |copy_layer| should have been rendered to a texture since it was needed
- // for a copy request.
- if (did_draw_) {
- // TODO(crbug.com/564832): Ignore the extra frame that occurs due to copy
- // completion. This can be removed when the extra commit is removed.
- EXPECT_FALSE(copy_layer->render_surface());
+ EXPECT_FALSE(
+ renderer->HasAllocatedResourcesForTesting(parent_render_pass_id));
+
+ // TODO(crbug.com/564832): Ignore the extra frame that occurs due to copy
+ // completion. This can be removed when the extra commit is removed.
+ if (did_swap_) {
+ EXPECT_FALSE(
+ renderer->HasAllocatedResourcesForTesting(copy_layer_render_pass_id));
} else {
- EXPECT_TRUE(renderer->HasAllocatedResourcesForTesting(
- copy_layer->render_surface()->GetRenderPassId()));
+ // |copy_layer| should have been rendered to a texture since it was needed
+ // for a copy request.
+ EXPECT_TRUE(
+ renderer->HasAllocatedResourcesForTesting(copy_layer_render_pass_id));
}
- did_draw_ = true;
+ did_swap_ = true;
}
- void AfterTest() override { EXPECT_TRUE(did_draw_); }
+ void AfterTest() override { EXPECT_TRUE(did_swap_); }
+ RenderPassId parent_render_pass_id;
+ RenderPassId copy_layer_render_pass_id;
+ Display* display_ = nullptr;
+ bool did_swap_ = false;
FakeContentLayerClient client_;
- bool did_draw_;
scoped_refptr<FakePictureLayer> root_;
scoped_refptr<FakePictureLayer> grand_parent_layer_;
scoped_refptr<FakePictureLayer> parent_layer_;
scoped_refptr<FakePictureLayer> copy_layer_;
};
-// No output to copy for delegated renderers.
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
+SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest);
class LayerTreeHostCopyRequestTestClippedOut
@@ -536,7 +562,7 @@ class LayerTreeHostCopyRequestTestClippedOut
copy_layer_->SetBounds(gfx::Size(10, 10));
parent_layer_->AddChild(copy_layer_);
- layer_tree_host()->SetRootLayer(root_);
+ layer_tree()->SetRootLayer(root_);
LayerTreeHostCopyRequestTest::SetupTree();
client_.set_bounds(root_->bounds());
}
@@ -552,7 +578,7 @@ class LayerTreeHostCopyRequestTestClippedOut
void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {
// We should still get the content even if the copy requested layer was
// completely clipped away.
- EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread());
+ EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread());
EXPECT_EQ(gfx::Size(10, 10).ToString(), result->size().ToString());
EndTest();
}
@@ -565,8 +591,7 @@ class LayerTreeHostCopyRequestTestClippedOut
scoped_refptr<FakePictureLayer> copy_layer_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
- LayerTreeHostCopyRequestTestClippedOut);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestClippedOut);
class LayerTreeHostCopyRequestTestScaledLayer
: public LayerTreeHostCopyRequestTest {
@@ -587,7 +612,7 @@ class LayerTreeHostCopyRequestTestScaledLayer
child_layer_->SetBounds(gfx::Size(10, 10));
copy_layer_->AddChild(child_layer_);
- layer_tree_host()->SetRootLayer(root_);
+ layer_tree()->SetRootLayer(root_);
LayerTreeHostCopyRequestTest::SetupTree();
client_.set_bounds(root_->bounds());
}
@@ -618,8 +643,7 @@ class LayerTreeHostCopyRequestTestScaledLayer
scoped_refptr<FakePictureLayer> child_layer_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
- LayerTreeHostCopyRequestTestScaledLayer);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestScaledLayer);
class LayerTreeHostTestAsyncTwoReadbacksWithoutDraw
: public LayerTreeHostCopyRequestTest {
@@ -632,7 +656,7 @@ class LayerTreeHostTestAsyncTwoReadbacksWithoutDraw
copy_layer_->SetBounds(gfx::Size(10, 10));
root_->AddChild(copy_layer_);
- layer_tree_host()->SetRootLayer(root_);
+ layer_tree()->SetRootLayer(root_);
LayerTreeHostCopyRequestTest::SetupTree();
client_.set_bounds(root_->bounds());
}
@@ -650,7 +674,7 @@ class LayerTreeHostTestAsyncTwoReadbacksWithoutDraw
PostSetNeedsCommitToMainThread();
// Prevent drawing.
- layer_tree_host()->SetViewportSize(gfx::Size(0, 0));
+ layer_tree()->SetViewportSize(gfx::Size(0, 0));
AddCopyRequest(copy_layer_.get());
}
@@ -663,16 +687,16 @@ class LayerTreeHostTestAsyncTwoReadbacksWithoutDraw
}
void DidCommit() override {
- if (layer_tree_host()->source_frame_number() == 1) {
+ if (layer_tree_host()->SourceFrameNumber() == 1) {
// Allow drawing.
- layer_tree_host()->SetViewportSize(gfx::Size(root_->bounds()));
+ layer_tree()->SetViewportSize(gfx::Size(root_->bounds()));
AddCopyRequest(copy_layer_.get());
}
}
void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {
- EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread());
+ EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread());
// The first frame can't be drawn.
switch (callback_count_) {
@@ -702,21 +726,15 @@ class LayerTreeHostTestAsyncTwoReadbacksWithoutDraw
scoped_refptr<FakePictureLayer> copy_layer_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
- LayerTreeHostTestAsyncTwoReadbacksWithoutDraw);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAsyncTwoReadbacksWithoutDraw);
-class LayerTreeHostCopyRequestTestLostOutputSurface
+class LayerTreeHostCopyRequestTestDeleteTexture
: public LayerTreeHostCopyRequestTest {
protected:
- std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
- if (!first_context_provider_) {
- first_context_provider_ = TestContextProvider::Create();
- return FakeOutputSurface::Create3d(first_context_provider_);
- }
-
- EXPECT_FALSE(second_context_provider_);
- second_context_provider_ = TestContextProvider::Create();
- return FakeOutputSurface::Create3d(second_context_provider_);
+ std::unique_ptr<OutputSurface> CreateDisplayOutputSurface(
+ scoped_refptr<ContextProvider> compositor_context_provider) override {
+ display_context_provider_ = TestContextProvider::Create();
+ return FakeOutputSurface::Create3d(display_context_provider_);
}
void SetupTree() override {
@@ -727,7 +745,7 @@ class LayerTreeHostCopyRequestTestLostOutputSurface
copy_layer_->SetBounds(gfx::Size(10, 10));
root_->AddChild(copy_layer_);
- layer_tree_host()->SetRootLayer(root_);
+ layer_tree()->SetRootLayer(root_);
LayerTreeHostCopyRequestTest::SetupTree();
client_.set_bounds(root_->bounds());
}
@@ -736,7 +754,7 @@ class LayerTreeHostCopyRequestTestLostOutputSurface
void ReceiveCopyRequestOutputAndCommit(
std::unique_ptr<CopyOutputResult> result) {
- EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread());
+ EXPECT_TRUE(layer_tree_host()->GetTaskRunnerProvider()->IsMainThread());
EXPECT_EQ(gfx::Size(10, 10).ToString(), result->size().ToString());
EXPECT_TRUE(result->HasTexture());
@@ -750,7 +768,7 @@ class LayerTreeHostCopyRequestTestLostOutputSurface
void InsertCopyRequest() {
copy_layer_->RequestCopyOfOutput(CopyOutputRequest::CreateRequest(
- base::Bind(&LayerTreeHostCopyRequestTestLostOutputSurface::
+ base::Bind(&LayerTreeHostCopyRequestTestDeleteTexture::
ReceiveCopyRequestOutputAndCommit,
base::Unretained(this))));
}
@@ -760,112 +778,109 @@ class LayerTreeHostCopyRequestTestLostOutputSurface
result_ = nullptr;
ImplThreadTaskRunner()->PostTask(
- FROM_HERE, base::Bind(&LayerTreeHostCopyRequestTestLostOutputSurface::
+ FROM_HERE, base::Bind(&LayerTreeHostCopyRequestTestDeleteTexture::
CheckNumTexturesAfterReadbackDestroyed,
base::Unretained(this)));
}
void CheckNumTexturesAfterReadbackDestroyed() {
- // After the loss we had |num_textures_after_loss_| many textures, but
- // releasing the copy output request will cause the texture in the request
- // to be released, so we should have 1 less by now.
- EXPECT_EQ(num_textures_after_loss_ - 1,
- first_context_provider_->TestContext3d()->NumTextures());
+ // After the copy we had |num_textures_after_readback_| many textures, but
+ // releasing the copy output request should cause the texture in the request
+ // to be destroyed by the compositor, so we should have 1 less by now.
+ EXPECT_EQ(num_textures_after_readback_ - 1,
+ display_context_provider_->TestContext3d()->NumTextures());
EndTest();
}
- void SwapBuffersOnThread(LayerTreeHostImpl* impl, bool result) override {
- switch (impl->active_tree()->source_frame_number()) {
+ void DisplayDidDrawAndSwapOnThread() override {
+ switch (num_swaps_++) {
case 0:
- // The layers have been drawn, so their textures have been allocated.
+ // The layers have been drawn, so any textures required for drawing have
+ // been allocated.
EXPECT_FALSE(result_);
num_textures_without_readback_ =
- first_context_provider_->TestContext3d()->NumTextures();
+ display_context_provider_->TestContext3d()->NumTextures();
// Request a copy of the layer. This will use another texture.
MainThreadTaskRunner()->PostTask(
FROM_HERE,
- base::Bind(&LayerTreeHostCopyRequestTestLostOutputSurface::
- InsertCopyRequest,
- base::Unretained(this)));
+ base::Bind(
+ &LayerTreeHostCopyRequestTestDeleteTexture::InsertCopyRequest,
+ base::Unretained(this)));
break;
case 1:
// We did a readback, so there will be a readback texture around now.
- EXPECT_LT(num_textures_without_readback_,
- first_context_provider_->TestContext3d()->NumTextures());
-
- // The copy request will be serviced and the result sent to
- // ReceiveCopyRequestOutputAndCommit, which posts a new commit causing
- // the test to advance to the next case.
- break;
- case 2:
- // The readback texture is collected.
- EXPECT_TRUE(result_);
-
- // Lose the output surface.
- first_context_provider_->TestContext3d()->loseContextCHROMIUM(
- GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB);
- break;
- case 3:
- // The output surface has been recreated.
- EXPECT_TRUE(second_context_provider_);
-
- num_textures_after_loss_ =
- first_context_provider_->TestContext3d()->NumTextures();
+ num_textures_after_readback_ =
+ display_context_provider_->TestContext3d()->NumTextures();
+ EXPECT_LT(num_textures_without_readback_, num_textures_after_readback_);
// Now destroy the CopyOutputResult, releasing the texture inside back
// to the compositor. Then check the resulting number of allocated
// textures.
MainThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&LayerTreeHostCopyRequestTestLostOutputSurface::
- DestroyCopyResultAndCheckNumTextures,
- base::Unretained(this)));
+ FROM_HERE, base::Bind(&LayerTreeHostCopyRequestTestDeleteTexture::
+ DestroyCopyResultAndCheckNumTextures,
+ base::Unretained(this)));
break;
}
}
void AfterTest() override {}
- scoped_refptr<TestContextProvider> first_context_provider_;
- scoped_refptr<TestContextProvider> second_context_provider_;
+ scoped_refptr<TestContextProvider> display_context_provider_;
+ int num_swaps_ = 0;
size_t num_textures_without_readback_ = 0;
- size_t num_textures_after_loss_ = 0;
+ size_t num_textures_after_readback_ = 0;
FakeContentLayerClient client_;
scoped_refptr<FakePictureLayer> root_;
scoped_refptr<FakePictureLayer> copy_layer_;
std::unique_ptr<CopyOutputResult> result_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
- LayerTreeHostCopyRequestTestLostOutputSurface);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestDeleteTexture);
class LayerTreeHostCopyRequestTestCountTextures
: public LayerTreeHostCopyRequestTest {
protected:
- std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
- context_provider_ = TestContextProvider::Create();
- return FakeOutputSurface::Create3d(context_provider_);
+ void InitializeSettings(LayerTreeSettings* settings) override {
+ // Always allocate only a single texture at a time through ResourceProvider.
+ settings->renderer_settings.texture_id_allocation_chunk_size = 1;
+ }
+
+ std::unique_ptr<OutputSurface> CreateDisplayOutputSurface(
+ scoped_refptr<ContextProvider> compositor_context_provider) override {
+ // These tests expect the LayerTreeHostImpl to share a context with
+ // the Display so that sync points are not needed and the texture counts
+ // are visible together.
+ // Since this test does not override CreateCompositorFrameSink, the
+ // |compositor_context_provider| will be a TestContextProvider.
+ display_context_provider_ =
+ static_cast<TestContextProvider*>(compositor_context_provider.get());
+ return FakeOutputSurface::Create3d(std::move(compositor_context_provider));
}
void SetupTree() override {
- client_.set_fill_with_nonsolid_color(true);
+ // The layers in this test have solid color content, so they don't
+ // actually allocate any textures, making counting easier.
- root_ = FakePictureLayer::Create(&client_);
+ root_ = FakePictureLayer::Create(&root_client_);
root_->SetBounds(gfx::Size(20, 20));
+ root_client_.set_bounds(root_->bounds());
- copy_layer_ = FakePictureLayer::Create(&client_);
+ copy_layer_ = FakePictureLayer::Create(&copy_client_);
copy_layer_->SetBounds(gfx::Size(10, 10));
+ copy_client_.set_bounds(copy_layer_->bounds());
+ // Doing a copy makes the layer have a render surface which can cause
+ // texture allocations. So get those allocations out of the way in the
+ // first frame by forcing it to have a render surface.
+ copy_layer_->SetForceRenderSurfaceForTesting(true);
root_->AddChild(copy_layer_);
- layer_tree_host()->SetRootLayer(root_);
+ layer_tree()->SetRootLayer(root_);
LayerTreeHostCopyRequestTest::SetupTree();
- client_.set_bounds(root_->bounds());
}
void BeginTest() override {
- num_textures_without_readback_ = 0;
- num_textures_with_readback_ = 0;
waited_sync_token_after_readback_.Clear();
PostSetNeedsCommitToMainThread();
}
@@ -873,29 +888,33 @@ class LayerTreeHostCopyRequestTestCountTextures
virtual void RequestCopy(Layer* layer) = 0;
void DidCommit() override {
- switch (layer_tree_host()->source_frame_number()) {
+ switch (layer_tree_host()->SourceFrameNumber()) {
case 1:
- // The layers have been pushed to the impl side. The layer textures have
- // been allocated.
+ // The layers have been pushed to the impl side and drawn. Any textures
+ // that are created in that process will have been allocated.
RequestCopy(copy_layer_.get());
break;
}
}
- void SwapBuffersOnThread(LayerTreeHostImpl* impl, bool result) override {
- switch (impl->active_tree()->source_frame_number()) {
+ void DisplayDidDrawAndSwapOnThread() override {
+ switch (num_swaps_++) {
case 0:
- // The layers have been drawn, so their textures have been allocated.
+ // The first frame has been drawn, so textures for drawing have been
+ // allocated.
num_textures_without_readback_ =
- context_provider_->TestContext3d()->NumTextures();
+ display_context_provider_->TestContext3d()->NumTextures();
break;
case 1:
// We did a readback, so there will be a readback texture around now.
num_textures_with_readback_ =
- context_provider_->TestContext3d()->NumTextures();
+ display_context_provider_->TestContext3d()->NumTextures();
waited_sync_token_after_readback_ =
- context_provider_->TestContext3d()->last_waited_sync_token();
+ display_context_provider_->TestContext3d()
+ ->last_waited_sync_token();
+ // End the test after main thread has a chance to hear about the
+ // readback.
MainThreadTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&LayerTreeHostCopyRequestTestCountTextures::DoEndTest,
@@ -906,11 +925,13 @@ class LayerTreeHostCopyRequestTestCountTextures
virtual void DoEndTest() { EndTest(); }
- scoped_refptr<TestContextProvider> context_provider_;
- size_t num_textures_without_readback_;
- size_t num_textures_with_readback_;
+ scoped_refptr<TestContextProvider> display_context_provider_;
+ int num_swaps_ = 0;
+ size_t num_textures_without_readback_ = 0;
+ size_t num_textures_with_readback_ = 0;
gpu::SyncToken waited_sync_token_after_readback_;
- FakeContentLayerClient client_;
+ FakeContentLayerClient root_client_;
+ FakeContentLayerClient copy_client_;
scoped_refptr<FakePictureLayer> root_;
scoped_refptr<FakePictureLayer> copy_layer_;
};
@@ -931,23 +952,23 @@ class LayerTreeHostCopyRequestTestCreatesTexture
EXPECT_TRUE(result->HasTexture());
TextureMailbox mailbox;
- std::unique_ptr<SingleReleaseCallback> release;
- result->TakeTexture(&mailbox, &release);
- EXPECT_TRUE(release);
-
- release->Run(gpu::SyncToken(), false);
+ result->TakeTexture(&mailbox, &release_);
+ EXPECT_TRUE(release_);
}
void AfterTest() override {
+ release_->Run(gpu::SyncToken(), false);
+
// No sync point was needed.
EXPECT_FALSE(waited_sync_token_after_readback_.HasData());
// Except the copy to have made another texture.
EXPECT_EQ(num_textures_without_readback_ + 1, num_textures_with_readback_);
}
+
+ std::unique_ptr<SingleReleaseCallback> release_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
- LayerTreeHostCopyRequestTestCreatesTexture);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestCreatesTexture);
class LayerTreeHostCopyRequestTestProvideTexture
: public LayerTreeHostCopyRequestTestCountTextures {
@@ -1003,8 +1024,7 @@ class LayerTreeHostCopyRequestTestProvideTexture
gpu::SyncToken sync_token_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
- LayerTreeHostCopyRequestTestProvideTexture);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestProvideTexture);
class LayerTreeHostCopyRequestTestDestroyBeforeCopy
: public LayerTreeHostCopyRequestTest {
@@ -1017,7 +1037,7 @@ class LayerTreeHostCopyRequestTestDestroyBeforeCopy
copy_layer_->SetBounds(gfx::Size(10, 10));
root_->AddChild(copy_layer_);
- layer_tree_host()->SetRootLayer(root_);
+ layer_tree()->SetRootLayer(root_);
LayerTreeHostCopyRequestTest::SetupTree();
client_.set_bounds(root_->bounds());
}
@@ -1040,7 +1060,7 @@ class LayerTreeHostCopyRequestTestDestroyBeforeCopy
}
void DidActivate() {
- switch (layer_tree_host()->source_frame_number()) {
+ switch (layer_tree_host()->SourceFrameNumber()) {
case 1: {
EXPECT_EQ(0, callback_count_);
// Put a copy request on the layer, but then don't allow any
@@ -1052,7 +1072,7 @@ class LayerTreeHostCopyRequestTestDestroyBeforeCopy
base::Unretained(this)));
copy_layer_->RequestCopyOfOutput(std::move(request));
- layer_tree_host()->SetViewportSize(gfx::Size());
+ layer_tree()->SetViewportSize(gfx::Size());
break;
}
case 2:
@@ -1063,8 +1083,7 @@ class LayerTreeHostCopyRequestTestDestroyBeforeCopy
case 3:
EXPECT_EQ(1, callback_count_);
// Allow us to draw now.
- layer_tree_host()->SetViewportSize(
- layer_tree_host()->root_layer()->bounds());
+ layer_tree()->SetViewportSize(layer_tree()->root_layer()->bounds());
break;
case 4:
EXPECT_EQ(1, callback_count_);
@@ -1081,8 +1100,7 @@ class LayerTreeHostCopyRequestTestDestroyBeforeCopy
scoped_refptr<FakePictureLayer> copy_layer_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
- LayerTreeHostCopyRequestTestDestroyBeforeCopy);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestDestroyBeforeCopy);
class LayerTreeHostCopyRequestTestShutdownBeforeCopy
: public LayerTreeHostCopyRequestTest {
@@ -1095,7 +1113,7 @@ class LayerTreeHostCopyRequestTestShutdownBeforeCopy
copy_layer_->SetBounds(gfx::Size(10, 10));
root_->AddChild(copy_layer_);
- layer_tree_host()->SetRootLayer(root_);
+ layer_tree()->SetRootLayer(root_);
LayerTreeHostCopyRequestTest::SetupTree();
client_.set_bounds(root_->bounds());
}
@@ -1118,7 +1136,7 @@ class LayerTreeHostCopyRequestTestShutdownBeforeCopy
}
void DidActivate() {
- switch (layer_tree_host()->source_frame_number()) {
+ switch (layer_tree_host()->SourceFrameNumber()) {
case 1: {
EXPECT_EQ(0, callback_count_);
// Put a copy request on the layer, but then don't allow any
@@ -1130,7 +1148,7 @@ class LayerTreeHostCopyRequestTestShutdownBeforeCopy
base::Unretained(this)));
copy_layer_->RequestCopyOfOutput(std::move(request));
- layer_tree_host()->SetViewportSize(gfx::Size());
+ layer_tree()->SetViewportSize(gfx::Size());
break;
}
case 2:
@@ -1153,8 +1171,7 @@ class LayerTreeHostCopyRequestTestShutdownBeforeCopy
scoped_refptr<FakePictureLayer> copy_layer_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
- LayerTreeHostCopyRequestTestShutdownBeforeCopy);
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestShutdownBeforeCopy);
class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest
: public LayerTreeHostCopyRequestTest {
@@ -1168,7 +1185,7 @@ class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest
root->AddChild(child_);
child_->SetHideLayerAndSubtree(true);
- layer_tree_host()->SetRootLayer(root);
+ layer_tree()->SetRootLayer(root);
LayerTreeHostCopyRequestTest::SetupTree();
client_.set_bounds(root->bounds());
}
@@ -1182,7 +1199,7 @@ class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest
void DidCommit() override {
// Send a copy request after the first commit.
- if (layer_tree_host()->source_frame_number() == 1) {
+ if (layer_tree_host()->SourceFrameNumber() == 1) {
child_->RequestCopyOfOutput(
CopyOutputRequest::CreateBitmapRequest(base::Bind(
&LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest::
@@ -1227,7 +1244,8 @@ class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest
EXPECT_TRUE(saw_root);
EXPECT_TRUE(saw_child);
// Make another draw happen after doing the copy request.
- host_impl->SetNeedsRedrawRect(gfx::Rect(1, 1));
+ host_impl->SetViewportDamage(gfx::Rect(1, 1));
+ host_impl->SetNeedsRedraw();
break;
case 3:
// If LayerTreeHostImpl does the wrong thing, it will try to draw the
@@ -1269,7 +1287,7 @@ class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest
bool draw_happened_;
};
-SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
+SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest);
} // namespace