Chromium Code Reviews| Index: cc/trees/layer_tree_host_pixeltest_readback.cc |
| diff --git a/cc/trees/layer_tree_host_pixeltest_readback.cc b/cc/trees/layer_tree_host_pixeltest_readback.cc |
| index 6d3c6ec318412c474befc5ebd523cc01a42eb350..06d12c13104d5a59e110ba1f70150792ede08cea 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<ReadbackTestConfig> { |
| 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<Layer> content_root, |
| @@ -124,49 +136,7 @@ class LayerTreeHostReadbackPixelTest : public LayerTreePixelTest { |
| void IgnoreReadbackResult(scoped_ptr<CopyOutputResult> result) { |
| } |
| -TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_Software) { |
| - scoped_refptr<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> 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<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - background->AddChild(green); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - background->AddChild(green); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| @@ -246,728 +174,285 @@ 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<SolidColorLayer> background = |
| CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| + CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| background->AddChild(green); |
| + scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| + CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| + |
| + scoped_refptr<SolidColorLayer> target = |
| + CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); |
| + background->AddChild(target); |
| scoped_refptr<SolidColorLayer> 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<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| + CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| + |
| + scoped_refptr<SolidColorLayer> target = |
| + CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); |
| + background->AddChild(target); |
| scoped_refptr<SolidColorLayer> 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<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| - background->AddChild(green); |
| + scoped_refptr<SolidColorLayer> hidden_target = |
| + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| + hidden_target->SetHideLayerAndSubtree(true); |
| + background->AddChild(hidden_target); |
| + |
| + scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| - background->AddChild(green); |
| + scoped_refptr<SolidColorLayer> hidden_target = |
| + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| + hidden_target->SetHideLayerAndSubtree(true); |
| + background->AddChild(hidden_target); |
| scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| background->AddChild(green); |
| scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| + CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); |
| background->AddChild(green); |
| scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| - scoped_refptr<SolidColorLayer> target = |
| - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); |
| - background->AddChild(target); |
| + scoped_refptr<SolidColorLayer> parent = |
| + CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); |
| + background->AddChild(parent); |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); |
| - target->AddChild(green); |
| + scoped_refptr<SolidColorLayer> target = |
| + CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); |
| + parent->AddChild(target); |
| scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| - scoped_refptr<SolidColorLayer> target = |
| - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); |
| - background->AddChild(target); |
| + scoped_refptr<SolidColorLayer> parent = |
| + CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); |
| + EXPECT_FALSE(parent->masks_to_bounds()); |
| + background->AddChild(parent); |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); |
| - target->AddChild(green); |
| + scoped_refptr<SolidColorLayer> target = |
| + CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); |
| + parent->AddChild(target); |
| scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> target = |
| - CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); |
| - background->AddChild(target); |
| + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| scoped_refptr<SolidColorLayer> 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<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> target = |
| - CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); |
| - background->AddChild(target); |
| - |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); |
| - target->AddChild(green); |
| + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| scoped_refptr<SolidColorLayer> 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.For every copy |
|
danakj
2015/02/09 20:01:59
nit: space missing
ericrk
2015/02/09 21:11:19
Done.
|
| + // 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> target = |
| - CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); |
| - background->AddChild(target); |
| - |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); |
| - target->AddChild(green); |
| + CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - scoped_refptr<SolidColorLayer> blue = |
| - CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); |
| - target->AddChild(blue); |
| + background->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
|
danakj
2015/02/09 20:01:59
You just need one of these because one will come f
ericrk
2015/02/09 21:11:19
Ah, yeah - removed one of these.
|
| + base::Bind(&IgnoreReadbackResult))); |
| + 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> target = |
| - CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); |
| - background->AddChild(target); |
| - |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); |
| - target->AddChild(green); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| - |
| - scoped_refptr<SolidColorLayer> hidden_target = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - hidden_target->SetHideLayerAndSubtree(true); |
| - background->AddChild(hidden_target); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| - |
| - scoped_refptr<SolidColorLayer> hidden_target = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - hidden_target->SetHideLayerAndSubtree(true); |
| - background->AddChild(hidden_target); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| - |
| - scoped_refptr<SolidColorLayer> hidden_target = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - hidden_target->SetHideLayerAndSubtree(true); |
| - background->AddChild(hidden_target); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| - |
| - scoped_refptr<SolidColorLayer> hidden_target = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - hidden_target->SetHideLayerAndSubtree(true); |
| - background->AddChild(hidden_target); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| - |
| - scoped_refptr<SolidColorLayer> hidden_target = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - hidden_target->SetHideLayerAndSubtree(true); |
| - background->AddChild(hidden_target); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| - |
| - scoped_refptr<SolidColorLayer> hidden_target = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - hidden_target->SetHideLayerAndSubtree(true); |
| - background->AddChild(hidden_target); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - background->AddChild(green); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - background->AddChild(green); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - background->AddChild(green); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); |
| - background->AddChild(green); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); |
| - background->AddChild(green); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> green = |
| - CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); |
| - background->AddChild(green); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> parent = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); |
| - background->AddChild(parent); |
| - |
| - scoped_refptr<SolidColorLayer> target = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); |
| - parent->AddChild(target); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> parent = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); |
| - background->AddChild(parent); |
| - |
| - scoped_refptr<SolidColorLayer> target = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); |
| - parent->AddChild(target); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> parent = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); |
| - background->AddChild(parent); |
| - |
| - scoped_refptr<SolidColorLayer> target = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); |
| - parent->AddChild(target); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> parent = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); |
| - EXPECT_FALSE(parent->masks_to_bounds()); |
| - background->AddChild(parent); |
| - |
| - scoped_refptr<SolidColorLayer> target = |
| - CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); |
| - parent->AddChild(target); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> parent = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); |
| - EXPECT_FALSE(parent->masks_to_bounds()); |
| - background->AddChild(parent); |
| - |
| - scoped_refptr<SolidColorLayer> target = |
| - CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); |
| - parent->AddChild(target); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> parent = |
| - CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); |
| - EXPECT_FALSE(parent->masks_to_bounds()); |
| - background->AddChild(parent); |
| - |
| - scoped_refptr<SolidColorLayer> target = |
| - CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); |
| - parent->AddChild(target); |
| - |
| - scoped_refptr<SolidColorLayer> 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 +484,7 @@ class LayerTreeHostReadbackDeviceScalePixelTest |
| SolidColorContentLayerClient blue_client_; |
| }; |
| -TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect_Software) { |
| +TEST_P(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect) { |
| scoped_refptr<FakePictureLayer> background = |
| FakePictureLayer::Create(&white_client_); |
| background->SetBounds(gfx::Size(100, 100)); |
| @@ -1022,75 +507,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<FakePictureLayer> background = |
| - FakePictureLayer::Create(&white_client_); |
| - background->SetBounds(gfx::Size(100, 100)); |
| - background->SetIsDrawable(true); |
| - |
| - scoped_refptr<FakePictureLayer> green = |
| - FakePictureLayer::Create(&green_client_); |
| - green->SetBounds(gfx::Size(100, 100)); |
| - green->SetIsDrawable(true); |
| - background->AddChild(green); |
| - |
| - scoped_refptr<FakePictureLayer> 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<FakePictureLayer> background = |
| - FakePictureLayer::Create(&white_client_); |
| - background->SetBounds(gfx::Size(100, 100)); |
| - background->SetIsDrawable(true); |
| - |
| - scoped_refptr<FakePictureLayer> 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<FakePictureLayer> 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<FakePictureLayer> background = |
| FakePictureLayer::Create(&white_client_); |
| background->SetBounds(gfx::Size(100, 100)); |
| @@ -1114,67 +535,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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| - |
| - scoped_refptr<SolidColorLayer> 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<SolidColorLayer> 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<bool> {}; |
| - |
| -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<SolidColorLayer> background = |
| - CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| - |
| - scoped_refptr<SolidColorLayer> 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 |