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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2161323002: cc: Make LayerTreeHostImpl unittests use a delegating output surface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: display-lthi-tests: . Created 4 years, 5 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/test/test_gles2_interface.cc ('k') | content/test/layouttest_support.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 37e62fb3c520d32ca0c50dd789f28836d7a9dc36..cffc90d33ed59532d7063cfac4bb29097b8cb74a 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -57,11 +57,13 @@
#include "cc/test/gpu_rasterization_enabled_settings.h"
#include "cc/test/layer_test_common.h"
#include "cc/test/layer_tree_test.h"
+#include "cc/test/test_delegating_output_surface.h"
#include "cc/test/test_gpu_memory_buffer_manager.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "cc/trees/effect_node.h"
+#include "cc/trees/layer_tree_host_common.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/single_thread_proxy.h"
#include "cc/trees/transform_node.h"
@@ -456,6 +458,7 @@ class LayerTreeHostImplTest : public testing::Test,
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
host_impl_->DidDrawAllLayers(frame);
+ host_impl_->SwapBuffers(frame);
}
void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor);
@@ -470,7 +473,7 @@ class LayerTreeHostImplTest : public testing::Test,
protected:
virtual std::unique_ptr<OutputSurface> CreateOutputSurface() {
- return FakeOutputSurface::Create3d();
+ return FakeOutputSurface::CreateDelegating3d();
}
void DrawOneFrame() {
@@ -570,7 +573,7 @@ TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) {
TEST_F(LayerTreeHostImplTest, ResourcelessDrawWithEmptyViewport) {
CreateHostImpl(DefaultSettings(),
- FakeOutputSurface::CreateSoftware(
+ FakeOutputSurface::CreateDelegatingSoftware(
base::WrapUnique(new SoftwareOutputDevice())));
SetupScrollAndContentsLayers(gfx::Size(100, 100));
host_impl_->active_tree()->BuildPropertyTreesForTesting();
@@ -733,9 +736,9 @@ TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) {
context_owned->set_context_lost(true);
// Initialization will fail.
- EXPECT_FALSE(
- CreateHostImpl(DefaultSettings(),
- FakeOutputSurface::Create3d(std::move(context_owned))));
+ EXPECT_FALSE(CreateHostImpl(
+ DefaultSettings(),
+ FakeOutputSurface::CreateDelegating3d(std::move(context_owned))));
SetupScrollAndContentsLayers(gfx::Size(100, 100));
@@ -3428,6 +3431,7 @@ TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) {
LayerTreeHostImpl::FrameData frame;
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
host_impl_->DidDrawAllLayers(frame);
EXPECT_TRUE(layer->will_draw_called());
@@ -3445,6 +3449,7 @@ TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) {
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
host_impl_->DidDrawAllLayers(frame);
EXPECT_TRUE(layer->will_draw_called());
@@ -3478,6 +3483,7 @@ TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
host_impl_->DidDrawAllLayers(frame);
EXPECT_FALSE(layer->will_draw_called());
@@ -3495,6 +3501,7 @@ TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
host_impl_->DidDrawAllLayers(frame);
EXPECT_TRUE(layer->will_draw_called());
@@ -3537,6 +3544,7 @@ TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
host_impl_->DidDrawAllLayers(frame);
EXPECT_FALSE(occluded_layer->will_draw_called());
@@ -3575,6 +3583,7 @@ TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
*host_impl_->active_tree()->begin());
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
host_impl_->DidDrawAllLayers(frame);
EXPECT_TRUE(root->did_draw_called());
@@ -3791,7 +3800,7 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsAndFails) {
TEST_F(LayerTreeHostImplTest,
PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) {
CreateHostImpl(DefaultSettings(),
- FakeOutputSurface::CreateSoftware(
+ FakeOutputSurface::CreateDelegatingSoftware(
base::WrapUnique(new SoftwareOutputDevice())));
const gfx::Transform external_transform;
@@ -6473,6 +6482,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->DrawLayers(&frame);
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
+ host_impl_->SwapBuffers(frame);
// Layer with translucent content and painting, so drawn with blending.
layer1->SetContentsOpaque(false);
@@ -6481,6 +6491,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6493,6 +6504,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6505,6 +6517,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6528,6 +6541,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6542,6 +6556,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6557,6 +6572,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6579,6 +6595,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6599,6 +6616,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6617,6 +6635,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6636,6 +6655,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6650,6 +6670,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6663,6 +6684,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6676,6 +6698,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
@@ -6690,6 +6713,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->active_tree()->BuildPropertyTreesForTesting();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
+ host_impl_->SwapBuffers(frame);
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
}
@@ -6703,10 +6727,10 @@ class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) {
if (software) {
- return FakeOutputSurface::CreateSoftware(
+ return FakeOutputSurface::CreateDelegatingSoftware(
base::WrapUnique(new SoftwareOutputDevice()));
}
- return FakeOutputSurface::Create3d();
+ return FakeOutputSurface::CreateDelegating3d();
}
void SetupActiveTreeLayers() {
@@ -7006,59 +7030,6 @@ class FakeDrawableLayerImpl: public LayerImpl {
: LayerImpl(tree_impl, id) {}
};
-// Only reshape when we know we are going to draw. Otherwise, the reshape
-// can leave the window at the wrong size if we never draw and the proper
-// viewport size is never set.
-TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) {
- scoped_refptr<TestContextProvider> provider(TestContextProvider::Create());
- std::unique_ptr<OutputSurface> output_surface(
- FakeOutputSurface::Create3d(provider));
- CreateHostImpl(DefaultSettings(), std::move(output_surface));
-
- std::unique_ptr<LayerImpl> root =
- FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
- root->SetBounds(gfx::Size(10, 10));
- root->SetDrawsContent(true);
- root->test_properties()->force_render_surface = true;
- host_impl_->active_tree()->SetRootLayerForTesting(std::move(root));
- host_impl_->active_tree()->BuildPropertyTreesForTesting();
-
- EXPECT_FALSE(provider->TestContext3d()->reshape_called());
- provider->TestContext3d()->clear_reshape_called();
-
- LayerTreeHostImpl::FrameData frame;
- host_impl_->SetViewportSize(gfx::Size(10, 10));
- host_impl_->active_tree()->SetDeviceScaleFactor(1.f);
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame);
- EXPECT_TRUE(provider->TestContext3d()->reshape_called());
- EXPECT_EQ(provider->TestContext3d()->width(), 10);
- EXPECT_EQ(provider->TestContext3d()->height(), 10);
- EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f);
- host_impl_->DidDrawAllLayers(frame);
- provider->TestContext3d()->clear_reshape_called();
-
- host_impl_->SetViewportSize(gfx::Size(20, 30));
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame);
- EXPECT_TRUE(provider->TestContext3d()->reshape_called());
- EXPECT_EQ(provider->TestContext3d()->width(), 20);
- EXPECT_EQ(provider->TestContext3d()->height(), 30);
- EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f);
- host_impl_->DidDrawAllLayers(frame);
- provider->TestContext3d()->clear_reshape_called();
-
- host_impl_->active_tree()->SetDeviceScaleFactor(2.f);
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame);
- EXPECT_TRUE(provider->TestContext3d()->reshape_called());
- EXPECT_EQ(provider->TestContext3d()->width(), 20);
- EXPECT_EQ(provider->TestContext3d()->height(), 30);
- EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f);
- host_impl_->DidDrawAllLayers(frame);
- provider->TestContext3d()->clear_reshape_called();
-}
-
// Make sure damage tracking propagates all the way to the graphics context,
// where it should request to swap only the sub-buffer that is damaged.
TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
@@ -7068,7 +7039,7 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
context_provider->TestContext3d()->set_have_post_sub_buffer(true);
std::unique_ptr<FakeOutputSurface> output_surface(
- FakeOutputSurface::Create3d(context_provider));
+ FakeOutputSurface::CreateDelegating3d(context_provider));
FakeOutputSurface* fake_output_surface = output_surface.get();
// This test creates its own LayerTreeHostImpl, so
@@ -7107,14 +7078,12 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
layer_tree_host_impl->DrawLayers(&frame);
layer_tree_host_impl->DidDrawAllLayers(frame);
layer_tree_host_impl->SwapBuffers(frame);
- gfx::Rect expected_swap_rect(0, 0, 500, 500);
+ gfx::Rect expected_swap_rect(500, 500);
EXPECT_EQ(expected_swap_rect.ToString(),
fake_output_surface->last_swap_rect().ToString());
// Second frame, only the damaged area should get swapped. Damage should be
- // the union of old and new child rects.
- // expected damage rect: gfx::Rect(26, 28);
- // expected swap rect: vertically flipped, with origin at bottom left corner.
+ // the union of old and new child rects: gfx::Rect(26, 28).
layer_tree_host_impl->active_tree()
->root_layer_for_testing()
->test_properties()
@@ -7131,10 +7100,7 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
host_impl_->DidDrawAllLayers(frame);
layer_tree_host_impl->SwapBuffers(frame);
- // Make sure that partial swap is constrained to the viewport dimensions
- // expected damage rect: gfx::Rect(500, 500);
- // expected swap rect: flipped damage rect, but also clamped to viewport
- expected_swap_rect = gfx::Rect(0, 500-28, 26, 28);
+ expected_swap_rect = gfx::Rect(26, 28);
EXPECT_EQ(expected_swap_rect.ToString(),
fake_output_surface->last_swap_rect().ToString());
@@ -7148,7 +7114,7 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) {
host_impl_->DidDrawAllLayers(frame);
layer_tree_host_impl->SwapBuffers(frame);
- expected_swap_rect = gfx::Rect(0, 0, 10, 10);
+ expected_swap_rect = gfx::Rect(10, 10);
EXPECT_EQ(expected_swap_rect.ToString(),
fake_output_surface->last_swap_rect().ToString());
@@ -7204,174 +7170,6 @@ class FakeLayerWithQuads : public LayerImpl {
: LayerImpl(tree_impl, id) {}
};
-class MockContext : public TestWebGraphicsContext3D {
- public:
- MOCK_METHOD1(useProgram, void(GLuint program));
- MOCK_METHOD5(uniform4f, void(GLint location,
- GLfloat x,
- GLfloat y,
- GLfloat z,
- GLfloat w));
- MOCK_METHOD4(uniformMatrix4fv, void(GLint location,
- GLsizei count,
- GLboolean transpose,
- const GLfloat* value));
- MOCK_METHOD4(drawElements, void(GLenum mode,
- GLsizei count,
- GLenum type,
- GLintptr offset));
- MOCK_METHOD1(enable, void(GLenum cap));
- MOCK_METHOD1(disable, void(GLenum cap));
- MOCK_METHOD4(scissor, void(GLint x,
- GLint y,
- GLsizei width,
- GLsizei height));
-};
-
-class MockContextHarness {
- private:
- MockContext* context_;
-
- public:
- explicit MockContextHarness(MockContext* context)
- : context_(context) {
- context_->set_have_post_sub_buffer(true);
-
- // Catch "uninteresting" calls
- EXPECT_CALL(*context_, useProgram(_))
- .Times(0);
-
- EXPECT_CALL(*context_, drawElements(_, _, _, _))
- .Times(0);
-
- // These are not asserted
- EXPECT_CALL(*context_, uniformMatrix4fv(_, _, _, _))
- .WillRepeatedly(Return());
-
- EXPECT_CALL(*context_, uniform4f(_, _, _, _, _))
- .WillRepeatedly(Return());
-
- // Any un-sanctioned calls to enable() are OK
- EXPECT_CALL(*context_, enable(_))
- .WillRepeatedly(Return());
-
- // Any un-sanctioned calls to disable() are OK
- EXPECT_CALL(*context_, disable(_))
- .WillRepeatedly(Return());
- }
-
- void MustDrawSolidQuad() {
- EXPECT_CALL(*context_, drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0))
- .WillOnce(Return())
- .RetiresOnSaturation();
-
- EXPECT_CALL(*context_, useProgram(_))
- .WillOnce(Return())
- .RetiresOnSaturation();
- }
-
- void MustSetScissor(int x, int y, int width, int height) {
- EXPECT_CALL(*context_, enable(GL_SCISSOR_TEST))
- .WillRepeatedly(Return());
-
- EXPECT_CALL(*context_, scissor(x, y, width, height))
- .Times(AtLeast(1))
- .WillRepeatedly(Return());
- }
-
- void MustSetNoScissor() {
- EXPECT_CALL(*context_, disable(GL_SCISSOR_TEST))
- .WillRepeatedly(Return());
-
- EXPECT_CALL(*context_, enable(GL_SCISSOR_TEST))
- .Times(0);
-
- EXPECT_CALL(*context_, scissor(_, _, _, _))
- .Times(0);
- }
-};
-
-TEST_F(LayerTreeHostImplTest, NoPartialSwap) {
- std::unique_ptr<MockContext> mock_context_owned(new MockContext);
- MockContext* mock_context = mock_context_owned.get();
- MockContextHarness harness(mock_context);
-
- // Run test case
- LayerTreeSettings settings = DefaultSettings();
- settings.renderer_settings.partial_swap_enabled = false;
- CreateHostImpl(settings,
- FakeOutputSurface::Create3d(std::move(mock_context_owned)));
- SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
- host_impl_->active_tree()->BuildPropertyTreesForTesting();
-
- // Without partial swap, and no clipping, no scissor is set.
- harness.MustDrawSolidQuad();
- harness.MustSetNoScissor();
- {
- LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame);
- host_impl_->DidDrawAllLayers(frame);
- }
- Mock::VerifyAndClearExpectations(&mock_context);
-
- // Without partial swap, but a layer does clip its subtree, one scissor is
- // set.
- auto* root = host_impl_->active_tree()->root_layer_for_testing();
- root->SetMasksToBounds(true);
- host_impl_->active_tree()->BuildPropertyTreesForTesting();
- root->NoteLayerPropertyChanged();
- harness.MustDrawSolidQuad();
- harness.MustSetScissor(0, 0, 10, 10);
- {
- LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame);
- host_impl_->DidDrawAllLayers(frame);
- }
- Mock::VerifyAndClearExpectations(&mock_context);
-}
-
-TEST_F(LayerTreeHostImplTest, PartialSwap) {
- std::unique_ptr<MockContext> context_owned(new MockContext);
- MockContext* mock_context = context_owned.get();
- MockContextHarness harness(mock_context);
-
- LayerTreeSettings settings = DefaultSettings();
- settings.renderer_settings.partial_swap_enabled = true;
- CreateHostImpl(settings,
- FakeOutputSurface::Create3d(std::move(context_owned)));
- SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
- host_impl_->active_tree()->BuildPropertyTreesForTesting();
-
- // The first frame is not a partially-swapped one. No scissor should be set.
- harness.MustSetNoScissor();
- harness.MustDrawSolidQuad();
- {
- LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame);
- host_impl_->DidDrawAllLayers(frame);
- }
- Mock::VerifyAndClearExpectations(&mock_context);
-
- // Damage a portion of the frame.
- auto* root = host_impl_->active_tree()->root_layer_for_testing();
- root->SetUpdateRect(gfx::Rect(0, 0, 2, 3));
- host_impl_->active_tree()->BuildPropertyTreesForTesting();
-
- // The second frame will be partially-swapped (the y coordinates are flipped).
- harness.MustSetScissor(0, 7, 2, 3);
- harness.MustDrawSolidQuad();
- {
- LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
- host_impl_->DrawLayers(&frame);
- host_impl_->DidDrawAllLayers(frame);
- }
- Mock::VerifyAndClearExpectations(&mock_context);
-}
-
static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity(
LayerTreeSettings settings,
bool partial_swap,
@@ -7454,7 +7252,7 @@ TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) {
provider->BindToCurrentThread();
provider->TestContext3d()->set_have_post_sub_buffer(true);
std::unique_ptr<OutputSurface> output_surface(
- FakeOutputSurface::Create3d(provider));
+ FakeOutputSurface::CreateDelegating3d(provider));
std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity(
DefaultSettings(), true, this, &task_runner_provider_,
&shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_,
@@ -7485,7 +7283,7 @@ TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
provider->BindToCurrentThread();
provider->TestContext3d()->set_have_post_sub_buffer(true);
std::unique_ptr<OutputSurface> output_surface(
- FakeOutputSurface::Create3d(provider));
+ FakeOutputSurface::CreateDelegating3d(provider));
std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity(
DefaultSettings(), false, this, &task_runner_provider_,
&shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_,
@@ -7514,7 +7312,7 @@ TEST_F(LayerTreeHostImplTest, LayersFreeTextures) {
TestWebGraphicsContext3D::Create();
TestWebGraphicsContext3D* context3d = context.get();
std::unique_ptr<OutputSurface> output_surface(
- FakeOutputSurface::Create3d(std::move(context)));
+ FakeOutputSurface::CreateDelegating3d(std::move(context)));
CreateHostImpl(DefaultSettings(), std::move(output_surface));
std::unique_ptr<LayerImpl> root_layer =
@@ -7562,15 +7360,6 @@ class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D {
};
TEST_F(LayerTreeHostImplTest, HasTransparentBackground) {
- std::unique_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned(
- new MockDrawQuadsToFillScreenContext);
- MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get();
-
- // Run test case
- LayerTreeSettings settings = DefaultSettings();
- settings.renderer_settings.partial_swap_enabled = false;
- CreateHostImpl(settings,
- FakeOutputSurface::Create3d(std::move(mock_context_owned)));
SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
host_impl_->active_tree()->BuildPropertyTreesForTesting();
@@ -7578,23 +7367,31 @@ TEST_F(LayerTreeHostImplTest, HasTransparentBackground) {
// Verify one quad is drawn when transparent background set is not set.
host_impl_->active_tree()->set_has_transparent_background(false);
- EXPECT_CALL(*mock_context, useProgram(_))
- .Times(1);
- EXPECT_CALL(*mock_context, drawElements(_, _, _, _))
- .Times(1);
LayerTreeHostImpl::FrameData frame;
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ {
+ const auto& root_pass = frame.render_passes.back();
+ ASSERT_EQ(1u, root_pass->quad_list.size());
+ EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.front()->material);
+ }
host_impl_->DrawLayers(&frame);
host_impl_->DidDrawAllLayers(frame);
- Mock::VerifyAndClearExpectations(&mock_context);
+ host_impl_->SwapBuffers(frame);
+
+ // Cause damage so we would draw something if possible.
+ host_impl_->SetFullRootLayerDamage();
// Verify no quads are drawn when transparent background is set.
host_impl_->active_tree()->set_has_transparent_background(true);
host_impl_->SetFullRootLayerDamage();
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ {
+ const auto& root_pass = frame.render_passes.back();
+ ASSERT_EQ(0u, root_pass->quad_list.size());
+ }
host_impl_->DrawLayers(&frame);
host_impl_->DidDrawAllLayers(frame);
- Mock::VerifyAndClearExpectations(&mock_context);
+ host_impl_->SwapBuffers(frame);
}
class LayerTreeHostImplTestWithDelegatingRenderer
@@ -7810,44 +7607,11 @@ class CountingSoftwareDevice : public SoftwareOutputDevice {
int frames_began_, frames_ended_;
};
-TEST_F(LayerTreeHostImplTest, ForcedDrawToSoftwareDeviceBasicRender) {
- // No main thread evictions in resourceless software mode.
- set_reduce_memory_result(false);
- CountingSoftwareDevice* software_device = new CountingSoftwareDevice();
- EXPECT_TRUE(CreateHostImpl(
- DefaultSettings(),
- FakeOutputSurface::CreateSoftware(base::WrapUnique(software_device))));
- host_impl_->SetViewportSize(gfx::Size(50, 50));
-
- SetupScrollAndContentsLayers(gfx::Size(100, 100));
-
- const gfx::Transform external_transform;
- const gfx::Rect external_viewport;
- const gfx::Rect external_clip;
- const bool resourceless_software_draw = true;
- host_impl_->SetExternalTilePriorityConstraints(external_viewport,
- external_transform);
-
- EXPECT_EQ(0, software_device->frames_began_);
- EXPECT_EQ(0, software_device->frames_ended_);
-
- host_impl_->OnDraw(external_transform, external_viewport, external_clip,
- resourceless_software_draw);
-
- EXPECT_EQ(1, software_device->frames_began_);
- EXPECT_EQ(1, software_device->frames_ended_);
-
- // Call another API method that is likely to hit nullptr in this mode.
- std::unique_ptr<base::trace_event::TracedValue> state(
- new base::trace_event::TracedValue());
- host_impl_->ActivationStateAsValueInto(state.get());
-}
-
TEST_F(LayerTreeHostImplTest,
ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) {
set_reduce_memory_result(false);
EXPECT_TRUE(CreateHostImpl(
- DefaultSettings(), FakeOutputSurface::CreateSoftware(
+ DefaultSettings(), FakeOutputSurface::CreateDelegatingSoftware(
base::WrapUnique(new CountingSoftwareDevice))));
const gfx::Transform external_transform;
@@ -7892,7 +7656,7 @@ TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) {
AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0);
output_surface_ =
- FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create());
+ FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::Create());
host_impl_->SetVisible(true);
host_impl_->InitializeRenderer(output_surface_.get());
EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes());
@@ -7977,7 +7741,7 @@ TEST_F(LayerTreeHostImplTest, UIResourceManagement) {
TestWebGraphicsContext3D::Create();
TestWebGraphicsContext3D* context3d = context.get();
std::unique_ptr<FakeOutputSurface> output_surface =
- FakeOutputSurface::Create3d();
+ FakeOutputSurface::CreateDelegating3d();
CreateHostImpl(DefaultSettings(), std::move(output_surface));
EXPECT_EQ(0u, context3d->NumTextures());
@@ -8020,7 +7784,7 @@ TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) {
std::unique_ptr<TestWebGraphicsContext3D> context =
TestWebGraphicsContext3D::Create();
TestWebGraphicsContext3D* context3d = context.get();
- CreateHostImpl(DefaultSettings(), FakeOutputSurface::Create3d());
+ CreateHostImpl(DefaultSettings(), FakeOutputSurface::CreateDelegating3d());
EXPECT_EQ(0u, context3d->NumTextures());
@@ -8047,8 +7811,13 @@ TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) {
scoped_refptr<TestContextProvider> context_provider =
TestContextProvider::Create();
- CreateHostImpl(DefaultSettings(),
- FakeOutputSurface::Create3d(context_provider));
+ CreateHostImpl(
+ DefaultSettings(),
+ base::MakeUnique<TestDelegatingOutputSurface>(
+ context_provider, TestContextProvider::CreateWorker(),
+ FakeOutputSurface::Create3d(context_provider), nullptr, nullptr,
+ RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(),
+ true /* synchronous_composite */));
SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
@@ -8062,6 +7831,7 @@ TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) {
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame);
host_impl_->DidDrawAllLayers(frame);
+ host_impl_->SwapBuffers(frame);
// The CopyOutputResult's callback has a ref on the ContextProvider and a
// texture in a texture mailbox.
@@ -10787,7 +10557,8 @@ TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusModes) {
LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings();
msaaSettings.gpu_rasterization_msaa_sample_count = 4;
EXPECT_TRUE(CreateHostImpl(
- msaaSettings, FakeOutputSurface::Create3d(std::move(context_with_msaa))));
+ msaaSettings,
+ FakeOutputSurface::CreateDelegating3d(std::move(context_with_msaa))));
host_impl_->SetHasGpuRasterizationTrigger(true);
host_impl_->SetContentIsSuitableForGpuRasterization(false);
EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT,
@@ -10797,7 +10568,8 @@ TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusModes) {
LayerTreeSettings settings = DefaultSettings();
settings.gpu_rasterization_enabled = false;
- EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d()));
+ EXPECT_TRUE(
+ CreateHostImpl(settings, FakeOutputSurface::CreateDelegating3d()));
host_impl_->SetHasGpuRasterizationTrigger(true);
host_impl_->SetContentIsSuitableForGpuRasterization(true);
EXPECT_EQ(GpuRasterizationStatus::OFF_DEVICE,
@@ -10805,7 +10577,8 @@ TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusModes) {
EXPECT_FALSE(host_impl_->use_gpu_rasterization());
settings.gpu_rasterization_forced = true;
- EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d()));
+ EXPECT_TRUE(
+ CreateHostImpl(settings, FakeOutputSurface::CreateDelegating3d()));
host_impl_->SetHasGpuRasterizationTrigger(false);
host_impl_->SetContentIsSuitableForGpuRasterization(false);
@@ -10824,7 +10597,7 @@ class MsaaIsSlowLayerTreeHostImplTest : public LayerTreeHostImplTest {
context_provider->UnboundTestContext3d()->SetMaxSamples(4);
context_provider->UnboundTestContext3d()->set_msaa_is_slow(msaa_is_slow);
auto msaa_is_normal_output_surface =
- FakeOutputSurface::Create3d(context_provider);
+ FakeOutputSurface::CreateDelegating3d(context_provider);
EXPECT_TRUE(
CreateHostImpl(settings, std::move(msaa_is_normal_output_surface)));
}
@@ -11046,12 +10819,12 @@ TEST_F(LayerTreeHostImplTest, RecomputeGpuRasterOnOutputSurfaceChange) {
// InitializeRenderer with a gpu-raster enabled output surface.
auto gpu_raster_output_surface =
- FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create());
+ FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::Create());
host_impl_->InitializeRenderer(gpu_raster_output_surface.get());
EXPECT_TRUE(host_impl_->use_gpu_rasterization());
// Re-initialize with a software output surface.
- output_surface_ = FakeOutputSurface::CreateSoftware(
+ output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(
base::WrapUnique(new SoftwareOutputDevice));
host_impl_->InitializeRenderer(output_surface_.get());
EXPECT_FALSE(host_impl_->use_gpu_rasterization());
« no previous file with comments | « cc/test/test_gles2_interface.cc ('k') | content/test/layouttest_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698