From eaf9258c49f76a997f690a63cb7e3091a09990b0 Mon Sep 17 00:00:00 2001 From: ericrk Date: Mon, 9 Feb 2015 14:37:15 -0800 Subject: Fix render state restore bug in DirectRenderer When processing multiple copy requests, DirectRenderer must restore state between requests. Due to a change from an index based for loop to an iterator based loop, a check within the loop for the first iteration had gotten out of date. This caused DirectRenderer to miss a required state restore in some cases. This change restores the intended behavior. The software renderer had a bug where calling UseRenderPass multiple times would result in a crash. The bug addressed in this CL made this a more common occurrance. A fix to the software-renderer issue was committed in CL (899183003). This change doesn't revert the software renderer fix as it is still possible to hit the software renderer bug even with this bug fixed. See the additional unit test for a case where the software renderer fix is still necessary even with this patch. R=danakj@chromium.org Review URL: https://codereview.chromium.org/904033008 Cr-Commit-Position: refs/heads/master@{#315412} --- cc/output/direct_renderer.cc | 2 +- cc/trees/layer_tree_host_pixeltest_readback.cc | 1010 +++++------------------- 2 files changed, 193 insertions(+), 819 deletions(-) (limited to 'cc') diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc index 65a94d8..9fbd4a5 100644 --- a/cc/output/direct_renderer.cc +++ b/cc/output/direct_renderer.cc @@ -235,7 +235,7 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, pass->copy_requests.begin(); it != pass->copy_requests.end(); ++it) { - if (i > 0) { + if (it != pass->copy_requests.begin()) { // Doing a readback is destructive of our state on Mac, so make sure // we restore the state between readbacks. http://crbug.com/99393. UseRenderPass(&frame, pass); diff --git a/cc/trees/layer_tree_host_pixeltest_readback.cc b/cc/trees/layer_tree_host_pixeltest_readback.cc index 6d3c6ec..b372904 100644 --- a/cc/trees/layer_tree_host_pixeltest_readback.cc +++ b/cc/trees/layer_tree_host_pixeltest_readback.cc @@ -19,18 +19,30 @@ namespace cc { namespace { -class LayerTreeHostReadbackPixelTest : public LayerTreePixelTest { +// Can't templatize a class on its own members, so ReadbackType and +// ReadbackTestConfig are declared here, before LayerTreeHostReadbackPixelTest. +enum ReadbackType { + READBACK_INVALID, + READBACK_DEFAULT, + READBACK_BITMAP, +}; + +struct ReadbackTestConfig { + ReadbackTestConfig(LayerTreePixelTest::PixelTestType pixel_test_type_, + ReadbackType readback_type_) + : pixel_test_type(pixel_test_type_), readback_type(readback_type_) {} + LayerTreePixelTest::PixelTestType pixel_test_type; + ReadbackType readback_type; +}; + +class LayerTreeHostReadbackPixelTest + : public LayerTreePixelTest, + public testing::WithParamInterface { protected: LayerTreeHostReadbackPixelTest() : readback_type_(READBACK_INVALID), insert_copy_request_after_frame_count_(0) {} - enum ReadbackType { - READBACK_INVALID, - READBACK_DEFAULT, - READBACK_BITMAP, - }; - void RunReadbackTest(PixelTestType test_type, ReadbackType readback_type, scoped_refptr content_root, @@ -124,49 +136,7 @@ class LayerTreeHostReadbackPixelTest : public LayerTreePixelTest { void IgnoreReadbackResult(scoped_ptr result) { } -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_Software) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - background->AddChild(green); - - RunReadbackTest(PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - base::FilePath(FILE_PATH_LITERAL("green.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_Software_Bitmap) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - background->AddChild(green); - - RunReadbackTest(PIXEL_TEST_SOFTWARE, - READBACK_BITMAP, - background, - base::FilePath(FILE_PATH_LITERAL("green.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_GL_Bitmap) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - background->AddChild(green); - - RunReadbackTest(PIXEL_TEST_GL, - READBACK_BITMAP, - background, - base::FilePath(FILE_PATH_LITERAL("green.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_GL) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackRootLayer) { scoped_refptr background = CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); @@ -174,13 +144,11 @@ TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_GL) { CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); background->AddChild(green); - RunReadbackTest(PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - base::FilePath(FILE_PATH_LITERAL("green.png"))); + RunReadbackTest(GetParam().pixel_test_type, GetParam().readback_type, + background, base::FilePath(FILE_PATH_LITERAL("green.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild_Software) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild) { scoped_refptr background = CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); @@ -193,51 +161,11 @@ TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild_Software) { green->AddChild(blue); RunReadbackTest( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, + GetParam().pixel_test_type, GetParam().readback_type, background, base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild_GL_Bitmap) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - background->AddChild(green); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); - green->AddChild(blue); - - RunReadbackTest( - PIXEL_TEST_GL, - READBACK_BITMAP, - background, - base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild_GL) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - background->AddChild(green); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); - green->AddChild(blue); - - RunReadbackTest( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_Software) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer) { scoped_refptr background = CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); @@ -246,728 +174,284 @@ TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_Software) { background->AddChild(green); RunReadbackTestWithReadbackTarget( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - green.get(), - base::FilePath(FILE_PATH_LITERAL("green.png"))); + GetParam().pixel_test_type, GetParam().readback_type, background, + green.get(), base::FilePath(FILE_PATH_LITERAL("green.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_GL_Bitmap) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer) { scoped_refptr background = CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); + CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); background->AddChild(green); RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_BITMAP, - background, - green.get(), - base::FilePath(FILE_PATH_LITERAL("green.png"))); + GetParam().pixel_test_type, GetParam().readback_type, background, + green.get(), base::FilePath(FILE_PATH_LITERAL("green_small.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_GL) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayerWithChild) { scoped_refptr background = CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); + CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); background->AddChild(green); + scoped_refptr blue = + CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); + green->AddChild(blue); + RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, + GetParam().pixel_test_type, GetParam().readback_type, background, green.get(), - base::FilePath(FILE_PATH_LITERAL("green.png"))); + base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer_Software) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackSubtreeSurroundsTargetLayer) { scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); + CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); + + scoped_refptr target = + CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); + background->AddChild(target); scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); - background->AddChild(green); + CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); + target->AddChild(green); + + scoped_refptr blue = + CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); + target->AddChild(blue); + copy_subrect_ = gfx::Rect(0, 0, 100, 100); RunReadbackTestWithReadbackTarget( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - green.get(), - base::FilePath(FILE_PATH_LITERAL("green_small.png"))); + GetParam().pixel_test_type, GetParam().readback_type, background, + target.get(), + base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer_GL_Bitmap) { +TEST_P(LayerTreeHostReadbackPixelTest, + ReadbackSubtreeExtendsBeyondTargetLayer) { scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); + CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); + + scoped_refptr target = + CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); + background->AddChild(target); scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); - background->AddChild(green); + CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); + target->AddChild(green); + + scoped_refptr blue = + CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); + target->AddChild(blue); + copy_subrect_ = gfx::Rect(50, 50, 100, 100); RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_BITMAP, - background, - green.get(), - base::FilePath(FILE_PATH_LITERAL("green_small.png"))); + GetParam().pixel_test_type, GetParam().readback_type, background, + target.get(), + base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer_GL) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree) { scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); - background->AddChild(green); + scoped_refptr hidden_target = + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); + hidden_target->SetHideLayerAndSubtree(true); + background->AddChild(hidden_target); + + scoped_refptr blue = + CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); + hidden_target->AddChild(blue); RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - green.get(), - base::FilePath(FILE_PATH_LITERAL("green_small.png"))); + GetParam().pixel_test_type, GetParam().readback_type, background, + hidden_target.get(), + base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, - ReadbackSmallNonRootLayerWithChild_Software) { +TEST_P(LayerTreeHostReadbackPixelTest, + HiddenSubtreeNotVisibleWhenDrawnForReadback) { scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); - background->AddChild(green); + scoped_refptr hidden_target = + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); + hidden_target->SetHideLayerAndSubtree(true); + background->AddChild(hidden_target); scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); - green->AddChild(blue); + CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); + hidden_target->AddChild(blue); - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - green.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); + hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( + base::Bind(&IgnoreReadbackResult))); + RunReadbackTest(GetParam().pixel_test_type, GetParam().readback_type, + background, base::FilePath(FILE_PATH_LITERAL("black.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, - ReadbackSmallNonRootLayerWithChild_GL_Bitmap) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackSubrect) { scoped_refptr background = CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); background->AddChild(green); scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); + CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); green->AddChild(blue); - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_BITMAP, - background, - green.get(), + // Grab the middle of the root layer. + copy_subrect_ = gfx::Rect(50, 50, 100, 100); + + RunReadbackTest( + GetParam().pixel_test_type, GetParam().readback_type, background, base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayerWithChild_GL) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect) { scoped_refptr background = CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); + CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); background->AddChild(green); scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); + CreateSolidColorLayer(gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); green->AddChild(blue); + // Grab the middle of the green layer. + copy_subrect_ = gfx::Rect(25, 25, 100, 100); + RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, + GetParam().pixel_test_type, GetParam().readback_type, background, green.get(), base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, - ReadbackSubtreeSurroundsTargetLayer_Software) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage) { scoped_refptr background = CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); - scoped_refptr target = - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); - background->AddChild(target); + scoped_refptr parent = + CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); + background->AddChild(parent); - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); - target->AddChild(green); + scoped_refptr target = + CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); + parent->AddChild(target); scoped_refptr blue = CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); target->AddChild(blue); - copy_subrect_ = gfx::Rect(0, 0, 100, 100); + insert_copy_request_after_frame_count_ = 1; RunReadbackTestWithReadbackTarget( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, + GetParam().pixel_test_type, GetParam().readback_type, background, target.get(), base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, - ReadbackSubtreeSurroundsLayer_GL_Bitmap) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackOutsideViewportWhenNoDamage) { scoped_refptr background = CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); - scoped_refptr target = - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); - background->AddChild(target); + scoped_refptr parent = + CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); + EXPECT_FALSE(parent->masks_to_bounds()); + background->AddChild(parent); - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); - target->AddChild(green); + scoped_refptr target = + CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); + parent->AddChild(target); scoped_refptr blue = CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); target->AddChild(blue); - copy_subrect_ = gfx::Rect(0, 0, 100, 100); + insert_copy_request_after_frame_count_ = 1; RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_BITMAP, - background, + GetParam().pixel_test_type, GetParam().readback_type, background, target.get(), base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubtreeSurroundsTargetLayer_GL) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerOutsideViewport) { scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); - - scoped_refptr target = - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); - background->AddChild(target); + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); - target->AddChild(green); + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); + // Only the top left quarter of the layer is inside the viewport, so the + // blue layer is entirely outside. + green->SetPosition(gfx::Point(100, 100)); + background->AddChild(green); scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); - target->AddChild(blue); + CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); + green->AddChild(blue); - copy_subrect_ = gfx::Rect(0, 0, 100, 100); RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - target.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); + GetParam().pixel_test_type, GetParam().readback_type, background, + green.get(), + base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, - ReadbackSubtreeExtendsBeyondTargetLayer_Software) { +TEST_P(LayerTreeHostReadbackPixelTest, ReadbackNonRootOrFirstLayer) { + // This test has 3 render passes with the copy request on the render pass in + // the middle. This test caught an issue where copy requests on non-root + // non-first render passes were being treated differently from the first + // render pass. scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); - - scoped_refptr target = - CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); - background->AddChild(target); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); - target->AddChild(green); + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); - target->AddChild(blue); + CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); + blue->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( + base::Bind(&IgnoreReadbackResult))); + background->AddChild(blue); - copy_subrect_ = gfx::Rect(50, 50, 100, 100); RunReadbackTestWithReadbackTarget( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - target.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); + GetParam().pixel_test_type, GetParam().readback_type, background, + background.get(), + base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, - ReadbackSubtreeExtendsBeyondTargetLayer_GL_Bitmap) { +TEST_P(LayerTreeHostReadbackPixelTest, MultipleReadbacksOnLayer) { + // This test has 2 copy requests on the background layer. One is added in the + // test body, another is added in RunReadbackTestWithReadbackTarget. For every + // copy request after the first, state must be restored via a call to + // UseRenderPass (see http://crbug.com/99393). This test ensures that the + // renderer correctly handles cases where UseRenderPass is called multiple + // times for a single layer. scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); - - scoped_refptr target = - CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); - background->AddChild(target); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); - target->AddChild(green); + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); - target->AddChild(blue); + background->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( + base::Bind(&IgnoreReadbackResult))); - copy_subrect_ = gfx::Rect(50, 50, 100, 100); RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_BITMAP, - background, - target.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); + GetParam().pixel_test_type, GetParam().readback_type, background, + background.get(), base::FilePath(FILE_PATH_LITERAL("green.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, - ReadbackSubtreeExtendsBeyondTargetLayer_GL) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); - - scoped_refptr target = - CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); - background->AddChild(target); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); - target->AddChild(green); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); - target->AddChild(blue); - - copy_subrect_ = gfx::Rect(50, 50, 100, 100); - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - target.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree_Software) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); - - scoped_refptr hidden_target = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - hidden_target->SetHideLayerAndSubtree(true); - background->AddChild(hidden_target); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); - hidden_target->AddChild(blue); - - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - hidden_target.get(), - base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree_GL_Bitmap) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); - - scoped_refptr hidden_target = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - hidden_target->SetHideLayerAndSubtree(true); - background->AddChild(hidden_target); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); - hidden_target->AddChild(blue); - - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_BITMAP, - background, - hidden_target.get(), - base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree_GL) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); - - scoped_refptr hidden_target = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - hidden_target->SetHideLayerAndSubtree(true); - background->AddChild(hidden_target); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); - hidden_target->AddChild(blue); - - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - hidden_target.get(), - base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, - HiddenSubtreeNotVisibleWhenDrawnForReadback_Software) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); - - scoped_refptr hidden_target = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - hidden_target->SetHideLayerAndSubtree(true); - background->AddChild(hidden_target); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); - hidden_target->AddChild(blue); - - hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( - base::Bind(&IgnoreReadbackResult))); - RunReadbackTest(PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - base::FilePath(FILE_PATH_LITERAL("black.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, - HiddenSubtreeNotVisibleWhenDrawnForReadback_GL_Bitmap) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); - - scoped_refptr hidden_target = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - hidden_target->SetHideLayerAndSubtree(true); - background->AddChild(hidden_target); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); - hidden_target->AddChild(blue); - - hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( - base::Bind(&IgnoreReadbackResult))); - RunReadbackTest(PIXEL_TEST_GL, - READBACK_BITMAP, - background, - base::FilePath(FILE_PATH_LITERAL("black.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, - HiddenSubtreeNotVisibleWhenDrawnForReadback_GL) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); - - scoped_refptr hidden_target = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - hidden_target->SetHideLayerAndSubtree(true); - background->AddChild(hidden_target); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); - hidden_target->AddChild(blue); - - hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( - base::Bind(&IgnoreReadbackResult))); - RunReadbackTest(PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - base::FilePath(FILE_PATH_LITERAL("black.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_Software) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - background->AddChild(green); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); - green->AddChild(blue); - - // Grab the middle of the root layer. - copy_subrect_ = gfx::Rect(50, 50, 100, 100); - - RunReadbackTest( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_GL_Bitmap) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - background->AddChild(green); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); - green->AddChild(blue); - - // Grab the middle of the root layer. - copy_subrect_ = gfx::Rect(50, 50, 100, 100); - - RunReadbackTest( - PIXEL_TEST_GL, - READBACK_BITMAP, - background, - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_GL) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - background->AddChild(green); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); - green->AddChild(blue); - - // Grab the middle of the root layer. - copy_subrect_ = gfx::Rect(50, 50, 100, 100); - - RunReadbackTest( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect_Software) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); - background->AddChild(green); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); - green->AddChild(blue); - - // Grab the middle of the green layer. - copy_subrect_ = gfx::Rect(25, 25, 100, 100); - - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - green.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect_GL_Bitmap) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); - background->AddChild(green); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); - green->AddChild(blue); - - // Grab the middle of the green layer. - copy_subrect_ = gfx::Rect(25, 25, 100, 100); - - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_BITMAP, - background, - green.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect_GL) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); - background->AddChild(green); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); - green->AddChild(blue); - - // Grab the middle of the green layer. - copy_subrect_ = gfx::Rect(25, 25, 100, 100); - - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - green.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage_Software) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); - - scoped_refptr parent = - CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); - background->AddChild(parent); - - scoped_refptr target = - CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); - parent->AddChild(target); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); - target->AddChild(blue); - - insert_copy_request_after_frame_count_ = 1; - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - target.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage_GL_Bitmap) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); - - scoped_refptr parent = - CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); - background->AddChild(parent); - - scoped_refptr target = - CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); - parent->AddChild(target); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); - target->AddChild(blue); - - insert_copy_request_after_frame_count_ = 1; - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_BITMAP, - background, - target.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage_GL) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); - - scoped_refptr parent = - CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); - background->AddChild(parent); - - scoped_refptr target = - CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); - parent->AddChild(target); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); - target->AddChild(blue); - - insert_copy_request_after_frame_count_ = 1; - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - target.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, - ReadbackOutsideViewportWhenNoDamage_Software) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); - - scoped_refptr parent = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); - EXPECT_FALSE(parent->masks_to_bounds()); - background->AddChild(parent); - - scoped_refptr target = - CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); - parent->AddChild(target); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); - target->AddChild(blue); - - insert_copy_request_after_frame_count_ = 1; - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - target.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, - ReadbackOutsideViewportWhenNoDamage_GL_Bitmap) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); - - scoped_refptr parent = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); - EXPECT_FALSE(parent->masks_to_bounds()); - background->AddChild(parent); - - scoped_refptr target = - CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); - parent->AddChild(target); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); - target->AddChild(blue); - - insert_copy_request_after_frame_count_ = 1; - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_BITMAP, - background, - target.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackOutsideViewportWhenNoDamage_GL) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); - - scoped_refptr parent = - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); - EXPECT_FALSE(parent->masks_to_bounds()); - background->AddChild(parent); - - scoped_refptr target = - CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); - parent->AddChild(target); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); - target->AddChild(blue); - - insert_copy_request_after_frame_count_ = 1; - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - target.get(), - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} +INSTANTIATE_TEST_CASE_P( + LayerTreeHostReadbackPixelTests, + LayerTreeHostReadbackPixelTest, + ::testing::Values( + ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_SOFTWARE, + READBACK_DEFAULT), + ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, + READBACK_DEFAULT), + ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, + READBACK_BITMAP))); class LayerTreeHostReadbackDeviceScalePixelTest : public LayerTreeHostReadbackPixelTest { @@ -999,7 +483,7 @@ class LayerTreeHostReadbackDeviceScalePixelTest SolidColorContentLayerClient blue_client_; }; -TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect_Software) { +TEST_P(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect) { scoped_refptr background = FakePictureLayer::Create(&white_client_); background->SetBounds(gfx::Size(100, 100)); @@ -1022,75 +506,11 @@ TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect_Software) { copy_subrect_ = gfx::Rect(25, 25, 50, 50); device_scale_factor_ = 2.f; RunReadbackTest( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect_GL) { - scoped_refptr background = - FakePictureLayer::Create(&white_client_); - background->SetBounds(gfx::Size(100, 100)); - background->SetIsDrawable(true); - - scoped_refptr green = - FakePictureLayer::Create(&green_client_); - green->SetBounds(gfx::Size(100, 100)); - green->SetIsDrawable(true); - background->AddChild(green); - - scoped_refptr blue = - FakePictureLayer::Create(&blue_client_); - blue->SetPosition(gfx::Point(50, 50)); - blue->SetBounds(gfx::Size(25, 25)); - blue->SetIsDrawable(true); - green->AddChild(blue); - - // Grab the middle of the root layer. - copy_subrect_ = gfx::Rect(25, 25, 50, 50); - device_scale_factor_ = 2.f; - RunReadbackTest( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); -} - -TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, - ReadbackNonRootLayerSubrect_Software) { - scoped_refptr background = - FakePictureLayer::Create(&white_client_); - background->SetBounds(gfx::Size(100, 100)); - background->SetIsDrawable(true); - - scoped_refptr green = - FakePictureLayer::Create(&green_client_); - green->SetPosition(gfx::Point(10, 20)); - green->SetBounds(gfx::Size(90, 80)); - green->SetIsDrawable(true); - background->AddChild(green); - - scoped_refptr blue = - FakePictureLayer::Create(&blue_client_); - blue->SetPosition(gfx::Point(50, 50)); - blue->SetBounds(gfx::Size(25, 25)); - blue->SetIsDrawable(true); - green->AddChild(blue); - - // Grab the green layer's content with blue in the bottom right. - copy_subrect_ = gfx::Rect(25, 25, 50, 50); - device_scale_factor_ = 2.f; - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - green.get(), + GetParam().pixel_test_type, GetParam().readback_type, background, base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, - ReadbackNonRootLayerSubrect_GL) { +TEST_P(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackNonRootLayerSubrect) { scoped_refptr background = FakePictureLayer::Create(&white_client_); background->SetBounds(gfx::Size(100, 100)); @@ -1114,67 +534,21 @@ TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, copy_subrect_ = gfx::Rect(25, 25, 50, 50); device_scale_factor_ = 2.f; RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, + GetParam().pixel_test_type, GetParam().readback_type, background, green.get(), base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); } -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerOutsideViewport) { - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); - - scoped_refptr green = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - // Only the top left quarter of the layer is inside the viewport, so the - // blue layer is entirely outside. - green->SetPosition(gfx::Point(100, 100)); - background->AddChild(green); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); - green->AddChild(blue); - - RunReadbackTestWithReadbackTarget( - PIXEL_TEST_GL, - READBACK_DEFAULT, - background, - green.get(), - base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); -} - -class LayerTreeHostReadbackNonFirstNonRootRenderPassPixelTest - : public LayerTreeHostReadbackPixelTest, - public testing::WithParamInterface {}; - -TEST_P(LayerTreeHostReadbackNonFirstNonRootRenderPassPixelTest, - ReadbackNonRootOrFirstLayer) { - // This test has 3 render passes with the copy request on the render pass in - // the middle. Doing a copy request can be destructive of state, so for render - // passes after the first drawn the code path is different. This verifies the - // non-first and non-root path. See http://crbug.com/99393 for more info. - scoped_refptr background = - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); - - scoped_refptr blue = - CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); - blue->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( - base::Bind(&IgnoreReadbackResult))); - background->AddChild(blue); - - RunReadbackTestWithReadbackTarget( - GetParam() ? PIXEL_TEST_GL : PIXEL_TEST_SOFTWARE, - READBACK_DEFAULT, - background, - background.get(), - base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); -} - INSTANTIATE_TEST_CASE_P( - LayerTreeHostReadbackNonFirstNonRootRenderPassPixelTests, - LayerTreeHostReadbackNonFirstNonRootRenderPassPixelTest, - testing::Bool()); + LayerTreeHostReadbackDeviceScalePixelTests, + LayerTreeHostReadbackDeviceScalePixelTest, + ::testing::Values( + ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_SOFTWARE, + READBACK_DEFAULT), + ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, + READBACK_DEFAULT), + ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, + READBACK_BITMAP))); } // namespace } // namespace cc -- cgit v1.1