| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 #include "cc/layers/solid_color_layer.h" | 6 #include "cc/layers/solid_color_layer.h" |
| 7 #include "cc/layers/texture_layer.h" | 7 #include "cc/layers/texture_layer.h" |
| 8 #include "cc/output/copy_output_request.h" | 8 #include "cc/output/copy_output_request.h" |
| 9 #include "cc/output/copy_output_result.h" | 9 #include "cc/output/copy_output_result.h" |
| 10 #include "cc/test/fake_picture_layer.h" | 10 #include "cc/test/fake_picture_layer.h" |
| 11 #include "cc/test/fake_picture_layer_impl.h" | 11 #include "cc/test/fake_picture_layer_impl.h" |
| 12 #include "cc/test/layer_tree_pixel_test.h" | 12 #include "cc/test/layer_tree_pixel_test.h" |
| 13 #include "cc/test/paths.h" | 13 #include "cc/test/paths.h" |
| 14 #include "cc/test/solid_color_content_layer_client.h" | 14 #include "cc/test/solid_color_content_layer_client.h" |
| 15 #include "cc/trees/layer_tree_impl.h" | 15 #include "cc/trees/layer_tree_impl.h" |
| 16 | 16 |
| 17 #if !defined(OS_ANDROID) | 17 #if !defined(OS_ANDROID) |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class LayerTreeHostReadbackPixelTest : public LayerTreePixelTest { | 22 class LayerTreeHostReadbackPixelTest : public LayerTreePixelTest { |
| 23 protected: | 23 protected: |
| 24 LayerTreeHostReadbackPixelTest() | 24 LayerTreeHostReadbackPixelTest() |
| 25 : insert_copy_request_after_frame_count_(0) {} | 25 : readback_type_(READBACK_INVALID), |
| 26 insert_copy_request_after_frame_count_(0) {} |
| 27 |
| 28 enum ReadbackType { |
| 29 READBACK_INVALID, |
| 30 READBACK_DEFAULT, |
| 31 READBACK_BITMAP, |
| 32 }; |
| 33 |
| 34 void RunReadbackTest(PixelTestType test_type, |
| 35 ReadbackType readback_type, |
| 36 scoped_refptr<Layer> content_root, |
| 37 base::FilePath file_name) { |
| 38 readback_type_ = readback_type; |
| 39 RunPixelTest(test_type, content_root, file_name); |
| 40 } |
| 41 |
| 42 void RunReadbackTestWithReadbackTarget(PixelTestType type, |
| 43 ReadbackType readback_type, |
| 44 scoped_refptr<Layer> content_root, |
| 45 Layer* target, |
| 46 base::FilePath file_name) { |
| 47 readback_type_ = readback_type; |
| 48 RunPixelTestWithReadbackTarget(type, content_root, target, file_name); |
| 49 } |
| 26 | 50 |
| 27 scoped_ptr<CopyOutputRequest> CreateCopyOutputRequest() override { | 51 scoped_ptr<CopyOutputRequest> CreateCopyOutputRequest() override { |
| 28 scoped_ptr<CopyOutputRequest> request; | 52 scoped_ptr<CopyOutputRequest> request; |
| 29 | 53 |
| 30 switch (test_type_) { | 54 if (readback_type_ == READBACK_BITMAP) { |
| 31 case GL_WITH_BITMAP: | 55 request = CopyOutputRequest::CreateBitmapRequest( |
| 32 case SOFTWARE_WITH_BITMAP: | 56 base::Bind(&LayerTreeHostReadbackPixelTest::ReadbackResultAsBitmap, |
| 33 request = CopyOutputRequest::CreateBitmapRequest( | 57 base::Unretained(this))); |
| 34 base::Bind(&LayerTreeHostReadbackPixelTest::ReadbackResultAsBitmap, | 58 } else { |
| 35 base::Unretained(this))); | 59 DCHECK_EQ(readback_type_, READBACK_DEFAULT); |
| 36 break; | 60 if (test_type_ == PIXEL_TEST_SOFTWARE) { |
| 37 case SOFTWARE_WITH_DEFAULT: | |
| 38 request = CopyOutputRequest::CreateRequest( | 61 request = CopyOutputRequest::CreateRequest( |
| 39 base::Bind(&LayerTreeHostReadbackPixelTest::ReadbackResultAsBitmap, | 62 base::Bind(&LayerTreeHostReadbackPixelTest::ReadbackResultAsBitmap, |
| 40 base::Unretained(this))); | 63 base::Unretained(this))); |
| 41 break; | 64 } else { |
| 42 case GL_WITH_DEFAULT: | 65 DCHECK_EQ(test_type_, PIXEL_TEST_GL); |
| 43 request = CopyOutputRequest::CreateRequest( | 66 request = CopyOutputRequest::CreateRequest( |
| 44 base::Bind(&LayerTreeHostReadbackPixelTest::ReadbackResultAsTexture, | 67 base::Bind(&LayerTreeHostReadbackPixelTest::ReadbackResultAsTexture, |
| 45 base::Unretained(this))); | 68 base::Unretained(this))); |
| 46 break; | 69 } |
| 47 } | 70 } |
| 48 | 71 |
| 49 if (!copy_subrect_.IsEmpty()) | 72 if (!copy_subrect_.IsEmpty()) |
| 50 request->set_area(copy_subrect_); | 73 request->set_area(copy_subrect_); |
| 51 return request.Pass(); | 74 return request.Pass(); |
| 52 } | 75 } |
| 53 | 76 |
| 54 void BeginTest() override { | 77 void BeginTest() override { |
| 55 if (insert_copy_request_after_frame_count_ == 0) { | 78 if (insert_copy_request_after_frame_count_ == 0) { |
| 56 Layer* const target = | 79 Layer* const target = |
| (...skipping 29 matching lines...) Expand all Loading... |
| 86 EXPECT_TRUE(texture_mailbox.IsValid()); | 109 EXPECT_TRUE(texture_mailbox.IsValid()); |
| 87 EXPECT_TRUE(texture_mailbox.IsTexture()); | 110 EXPECT_TRUE(texture_mailbox.IsTexture()); |
| 88 | 111 |
| 89 scoped_ptr<SkBitmap> bitmap = | 112 scoped_ptr<SkBitmap> bitmap = |
| 90 CopyTextureMailboxToBitmap(result->size(), texture_mailbox); | 113 CopyTextureMailboxToBitmap(result->size(), texture_mailbox); |
| 91 release_callback->Run(0, false); | 114 release_callback->Run(0, false); |
| 92 | 115 |
| 93 ReadbackResultAsBitmap(CopyOutputResult::CreateBitmapResult(bitmap.Pass())); | 116 ReadbackResultAsBitmap(CopyOutputResult::CreateBitmapResult(bitmap.Pass())); |
| 94 } | 117 } |
| 95 | 118 |
| 119 ReadbackType readback_type_; |
| 96 gfx::Rect copy_subrect_; | 120 gfx::Rect copy_subrect_; |
| 97 int insert_copy_request_after_frame_count_; | 121 int insert_copy_request_after_frame_count_; |
| 98 }; | 122 }; |
| 99 | 123 |
| 100 void IgnoreReadbackResult(scoped_ptr<CopyOutputResult> result) {} | 124 void IgnoreReadbackResult(scoped_ptr<CopyOutputResult> result) { |
| 125 } |
| 101 | 126 |
| 102 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_Software) { | 127 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_Software) { |
| 103 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 128 scoped_refptr<SolidColorLayer> background = |
| 104 gfx::Rect(200, 200), SK_ColorWHITE); | 129 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 105 | 130 |
| 106 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 131 scoped_refptr<SolidColorLayer> green = |
| 107 gfx::Rect(200, 200), SK_ColorGREEN); | 132 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 108 background->AddChild(green); | 133 background->AddChild(green); |
| 109 | 134 |
| 110 RunPixelTest(SOFTWARE_WITH_DEFAULT, | 135 RunReadbackTest(PIXEL_TEST_SOFTWARE, |
| 111 background, | 136 READBACK_DEFAULT, |
| 112 base::FilePath(FILE_PATH_LITERAL( | 137 background, |
| 113 "green.png"))); | 138 base::FilePath(FILE_PATH_LITERAL("green.png"))); |
| 114 } | 139 } |
| 115 | 140 |
| 116 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_Software_Bitmap) { | 141 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_Software_Bitmap) { |
| 117 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 142 scoped_refptr<SolidColorLayer> background = |
| 118 gfx::Rect(200, 200), SK_ColorWHITE); | 143 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 119 | 144 |
| 120 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 145 scoped_refptr<SolidColorLayer> green = |
| 121 gfx::Rect(200, 200), SK_ColorGREEN); | 146 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 122 background->AddChild(green); | 147 background->AddChild(green); |
| 123 | 148 |
| 124 RunPixelTest(SOFTWARE_WITH_BITMAP, | 149 RunReadbackTest(PIXEL_TEST_SOFTWARE, |
| 125 background, | 150 READBACK_BITMAP, |
| 126 base::FilePath(FILE_PATH_LITERAL( | 151 background, |
| 127 "green.png"))); | 152 base::FilePath(FILE_PATH_LITERAL("green.png"))); |
| 128 } | 153 } |
| 129 | 154 |
| 130 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_GL_Bitmap) { | 155 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_GL_Bitmap) { |
| 131 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 156 scoped_refptr<SolidColorLayer> background = |
| 132 gfx::Rect(200, 200), SK_ColorWHITE); | 157 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 133 | 158 |
| 134 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 159 scoped_refptr<SolidColorLayer> green = |
| 135 gfx::Rect(200, 200), SK_ColorGREEN); | 160 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 136 background->AddChild(green); | 161 background->AddChild(green); |
| 137 | 162 |
| 138 RunPixelTest(GL_WITH_BITMAP, | 163 RunReadbackTest(PIXEL_TEST_GL, |
| 139 background, | 164 READBACK_BITMAP, |
| 140 base::FilePath(FILE_PATH_LITERAL( | 165 background, |
| 141 "green.png"))); | 166 base::FilePath(FILE_PATH_LITERAL("green.png"))); |
| 142 } | 167 } |
| 143 | 168 |
| 144 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_GL) { | 169 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_GL) { |
| 145 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 170 scoped_refptr<SolidColorLayer> background = |
| 146 gfx::Rect(200, 200), SK_ColorWHITE); | 171 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 147 | 172 |
| 148 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 173 scoped_refptr<SolidColorLayer> green = |
| 149 gfx::Rect(200, 200), SK_ColorGREEN); | 174 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 150 background->AddChild(green); | 175 background->AddChild(green); |
| 151 | 176 |
| 152 RunPixelTest(GL_WITH_DEFAULT, | 177 RunReadbackTest(PIXEL_TEST_GL, |
| 153 background, | 178 READBACK_DEFAULT, |
| 154 base::FilePath(FILE_PATH_LITERAL( | 179 background, |
| 155 "green.png"))); | 180 base::FilePath(FILE_PATH_LITERAL("green.png"))); |
| 156 } | 181 } |
| 157 | 182 |
| 158 TEST_F(LayerTreeHostReadbackPixelTest, | 183 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild_Software) { |
| 159 ReadbackRootLayerWithChild_Software) { | 184 scoped_refptr<SolidColorLayer> background = |
| 160 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 185 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 161 gfx::Rect(200, 200), SK_ColorWHITE); | 186 |
| 162 | 187 scoped_refptr<SolidColorLayer> green = |
| 163 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 188 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 164 gfx::Rect(200, 200), SK_ColorGREEN); | 189 background->AddChild(green); |
| 165 background->AddChild(green); | 190 |
| 166 | 191 scoped_refptr<SolidColorLayer> blue = |
| 167 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 192 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
| 168 gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 193 green->AddChild(blue); |
| 169 green->AddChild(blue); | 194 |
| 170 | 195 RunReadbackTest( |
| 171 RunPixelTest(SOFTWARE_WITH_DEFAULT, | 196 PIXEL_TEST_SOFTWARE, |
| 172 background, | 197 READBACK_DEFAULT, |
| 173 base::FilePath(FILE_PATH_LITERAL( | 198 background, |
| 174 "green_with_blue_corner.png"))); | 199 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); |
| 175 } | 200 } |
| 176 | 201 |
| 177 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild_GL_Bitmap) { | 202 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild_GL_Bitmap) { |
| 178 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 203 scoped_refptr<SolidColorLayer> background = |
| 179 gfx::Rect(200, 200), SK_ColorWHITE); | 204 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 180 | 205 |
| 181 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 206 scoped_refptr<SolidColorLayer> green = |
| 182 gfx::Rect(200, 200), SK_ColorGREEN); | 207 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 183 background->AddChild(green); | 208 background->AddChild(green); |
| 184 | 209 |
| 185 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 210 scoped_refptr<SolidColorLayer> blue = |
| 186 gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 211 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
| 187 green->AddChild(blue); | 212 green->AddChild(blue); |
| 188 | 213 |
| 189 RunPixelTest(GL_WITH_BITMAP, | 214 RunReadbackTest( |
| 190 background, | 215 PIXEL_TEST_GL, |
| 191 base::FilePath(FILE_PATH_LITERAL( | 216 READBACK_BITMAP, |
| 192 "green_with_blue_corner.png"))); | 217 background, |
| 218 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); |
| 193 } | 219 } |
| 194 | 220 |
| 195 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild_GL) { | 221 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild_GL) { |
| 196 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 222 scoped_refptr<SolidColorLayer> background = |
| 197 gfx::Rect(200, 200), SK_ColorWHITE); | 223 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 198 | 224 |
| 199 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 225 scoped_refptr<SolidColorLayer> green = |
| 200 gfx::Rect(200, 200), SK_ColorGREEN); | 226 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 201 background->AddChild(green); | 227 background->AddChild(green); |
| 202 | 228 |
| 203 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 229 scoped_refptr<SolidColorLayer> blue = |
| 204 gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 230 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
| 205 green->AddChild(blue); | 231 green->AddChild(blue); |
| 206 | 232 |
| 207 RunPixelTest(GL_WITH_DEFAULT, | 233 RunReadbackTest( |
| 208 background, | 234 PIXEL_TEST_GL, |
| 209 base::FilePath(FILE_PATH_LITERAL( | 235 READBACK_DEFAULT, |
| 210 "green_with_blue_corner.png"))); | 236 background, |
| 237 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); |
| 211 } | 238 } |
| 212 | 239 |
| 213 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_Software) { | 240 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_Software) { |
| 214 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 241 scoped_refptr<SolidColorLayer> background = |
| 215 gfx::Rect(200, 200), SK_ColorWHITE); | 242 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 216 | 243 |
| 217 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 244 scoped_refptr<SolidColorLayer> green = |
| 218 gfx::Rect(200, 200), SK_ColorGREEN); | 245 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 219 background->AddChild(green); | 246 background->AddChild(green); |
| 220 | 247 |
| 221 RunPixelTestWithReadbackTarget(SOFTWARE_WITH_DEFAULT, | 248 RunReadbackTestWithReadbackTarget( |
| 222 background, | 249 PIXEL_TEST_SOFTWARE, |
| 223 green.get(), | 250 READBACK_DEFAULT, |
| 224 base::FilePath(FILE_PATH_LITERAL( | 251 background, |
| 225 "green.png"))); | 252 green.get(), |
| 253 base::FilePath(FILE_PATH_LITERAL("green.png"))); |
| 226 } | 254 } |
| 227 | 255 |
| 228 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_GL_Bitmap) { | 256 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_GL_Bitmap) { |
| 229 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 257 scoped_refptr<SolidColorLayer> background = |
| 230 gfx::Rect(200, 200), SK_ColorWHITE); | 258 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 231 | 259 |
| 232 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 260 scoped_refptr<SolidColorLayer> green = |
| 233 gfx::Rect(200, 200), SK_ColorGREEN); | 261 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 234 background->AddChild(green); | 262 background->AddChild(green); |
| 235 | 263 |
| 236 RunPixelTestWithReadbackTarget(GL_WITH_BITMAP, | 264 RunReadbackTestWithReadbackTarget( |
| 237 background, | 265 PIXEL_TEST_GL, |
| 238 green.get(), | 266 READBACK_BITMAP, |
| 239 base::FilePath(FILE_PATH_LITERAL( | 267 background, |
| 240 "green.png"))); | 268 green.get(), |
| 269 base::FilePath(FILE_PATH_LITERAL("green.png"))); |
| 241 } | 270 } |
| 242 | 271 |
| 243 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_GL) { | 272 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_GL) { |
| 244 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 273 scoped_refptr<SolidColorLayer> background = |
| 245 gfx::Rect(200, 200), SK_ColorWHITE); | 274 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 246 | 275 |
| 247 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 276 scoped_refptr<SolidColorLayer> green = |
| 248 gfx::Rect(200, 200), SK_ColorGREEN); | 277 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 249 background->AddChild(green); | 278 background->AddChild(green); |
| 250 | 279 |
| 251 RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, | 280 RunReadbackTestWithReadbackTarget( |
| 252 background, | 281 PIXEL_TEST_GL, |
| 253 green.get(), | 282 READBACK_DEFAULT, |
| 254 base::FilePath(FILE_PATH_LITERAL( | 283 background, |
| 255 "green.png"))); | 284 green.get(), |
| 256 } | 285 base::FilePath(FILE_PATH_LITERAL("green.png"))); |
| 257 | 286 } |
| 258 TEST_F(LayerTreeHostReadbackPixelTest, | 287 |
| 259 ReadbackSmallNonRootLayer_Software) { | 288 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer_Software) { |
| 260 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 289 scoped_refptr<SolidColorLayer> background = |
| 261 gfx::Rect(200, 200), SK_ColorWHITE); | 290 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 262 | 291 |
| 263 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 292 scoped_refptr<SolidColorLayer> green = |
| 264 gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); | 293 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| 265 background->AddChild(green); | 294 background->AddChild(green); |
| 266 | 295 |
| 267 RunPixelTestWithReadbackTarget(SOFTWARE_WITH_DEFAULT, | 296 RunReadbackTestWithReadbackTarget( |
| 268 background, | 297 PIXEL_TEST_SOFTWARE, |
| 269 green.get(), | 298 READBACK_DEFAULT, |
| 270 base::FilePath(FILE_PATH_LITERAL( | 299 background, |
| 271 "green_small.png"))); | 300 green.get(), |
| 301 base::FilePath(FILE_PATH_LITERAL("green_small.png"))); |
| 272 } | 302 } |
| 273 | 303 |
| 274 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer_GL_Bitmap) { | 304 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer_GL_Bitmap) { |
| 275 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 305 scoped_refptr<SolidColorLayer> background = |
| 276 gfx::Rect(200, 200), SK_ColorWHITE); | 306 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 277 | 307 |
| 278 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 308 scoped_refptr<SolidColorLayer> green = |
| 279 gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); | 309 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| 280 background->AddChild(green); | 310 background->AddChild(green); |
| 281 | 311 |
| 282 RunPixelTestWithReadbackTarget(GL_WITH_BITMAP, | 312 RunReadbackTestWithReadbackTarget( |
| 283 background, | 313 PIXEL_TEST_GL, |
| 284 green.get(), | 314 READBACK_BITMAP, |
| 285 base::FilePath(FILE_PATH_LITERAL( | 315 background, |
| 286 "green_small.png"))); | 316 green.get(), |
| 317 base::FilePath(FILE_PATH_LITERAL("green_small.png"))); |
| 287 } | 318 } |
| 288 | 319 |
| 289 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer_GL) { | 320 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer_GL) { |
| 290 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 321 scoped_refptr<SolidColorLayer> background = |
| 291 gfx::Rect(200, 200), SK_ColorWHITE); | 322 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 292 | 323 |
| 293 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 324 scoped_refptr<SolidColorLayer> green = |
| 294 gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); | 325 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| 295 background->AddChild(green); | 326 background->AddChild(green); |
| 296 | 327 |
| 297 RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, | 328 RunReadbackTestWithReadbackTarget( |
| 298 background, | 329 PIXEL_TEST_GL, |
| 299 green.get(), | 330 READBACK_DEFAULT, |
| 300 base::FilePath(FILE_PATH_LITERAL( | 331 background, |
| 301 "green_small.png"))); | 332 green.get(), |
| 333 base::FilePath(FILE_PATH_LITERAL("green_small.png"))); |
| 302 } | 334 } |
| 303 | 335 |
| 304 TEST_F(LayerTreeHostReadbackPixelTest, | 336 TEST_F(LayerTreeHostReadbackPixelTest, |
| 305 ReadbackSmallNonRootLayerWithChild_Software) { | 337 ReadbackSmallNonRootLayerWithChild_Software) { |
| 306 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 338 scoped_refptr<SolidColorLayer> background = |
| 307 gfx::Rect(200, 200), SK_ColorWHITE); | 339 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 308 | 340 |
| 309 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 341 scoped_refptr<SolidColorLayer> green = |
| 310 gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); | 342 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| 311 background->AddChild(green); | 343 background->AddChild(green); |
| 312 | 344 |
| 313 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 345 scoped_refptr<SolidColorLayer> blue = |
| 314 gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 346 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 315 green->AddChild(blue); | 347 green->AddChild(blue); |
| 316 | 348 |
| 317 RunPixelTestWithReadbackTarget(SOFTWARE_WITH_DEFAULT, | 349 RunReadbackTestWithReadbackTarget( |
| 318 background, | 350 PIXEL_TEST_SOFTWARE, |
| 319 green.get(), | 351 READBACK_DEFAULT, |
| 320 base::FilePath(FILE_PATH_LITERAL( | 352 background, |
| 321 "green_small_with_blue_corner.png"))); | 353 green.get(), |
| 354 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 322 } | 355 } |
| 323 | 356 |
| 324 TEST_F(LayerTreeHostReadbackPixelTest, | 357 TEST_F(LayerTreeHostReadbackPixelTest, |
| 325 ReadbackSmallNonRootLayerWithChild_GL_Bitmap) { | 358 ReadbackSmallNonRootLayerWithChild_GL_Bitmap) { |
| 326 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 359 scoped_refptr<SolidColorLayer> background = |
| 327 gfx::Rect(200, 200), SK_ColorWHITE); | 360 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 328 | 361 |
| 329 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 362 scoped_refptr<SolidColorLayer> green = |
| 330 gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); | 363 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| 331 background->AddChild(green); | 364 background->AddChild(green); |
| 332 | 365 |
| 333 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 366 scoped_refptr<SolidColorLayer> blue = |
| 334 gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 367 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 335 green->AddChild(blue); | 368 green->AddChild(blue); |
| 336 | 369 |
| 337 RunPixelTestWithReadbackTarget(GL_WITH_BITMAP, | 370 RunReadbackTestWithReadbackTarget( |
| 338 background, | 371 PIXEL_TEST_GL, |
| 339 green.get(), | 372 READBACK_BITMAP, |
| 340 base::FilePath(FILE_PATH_LITERAL( | 373 background, |
| 341 "green_small_with_blue_corner.png"))); | 374 green.get(), |
| 375 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 342 } | 376 } |
| 343 | 377 |
| 344 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayerWithChild_GL) { | 378 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayerWithChild_GL) { |
| 345 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 379 scoped_refptr<SolidColorLayer> background = |
| 346 gfx::Rect(200, 200), SK_ColorWHITE); | 380 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 347 | 381 |
| 348 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 382 scoped_refptr<SolidColorLayer> green = |
| 349 gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); | 383 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| 350 background->AddChild(green); | 384 background->AddChild(green); |
| 351 | 385 |
| 352 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 386 scoped_refptr<SolidColorLayer> blue = |
| 353 gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 387 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 354 green->AddChild(blue); | 388 green->AddChild(blue); |
| 355 | 389 |
| 356 RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, | 390 RunReadbackTestWithReadbackTarget( |
| 357 background, | 391 PIXEL_TEST_GL, |
| 358 green.get(), | 392 READBACK_DEFAULT, |
| 359 base::FilePath(FILE_PATH_LITERAL( | 393 background, |
| 360 "green_small_with_blue_corner.png"))); | 394 green.get(), |
| 395 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 361 } | 396 } |
| 362 | 397 |
| 363 TEST_F(LayerTreeHostReadbackPixelTest, | 398 TEST_F(LayerTreeHostReadbackPixelTest, |
| 364 ReadbackSubtreeSurroundsTargetLayer_Software) { | 399 ReadbackSubtreeSurroundsTargetLayer_Software) { |
| 365 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 400 scoped_refptr<SolidColorLayer> background = |
| 366 gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 401 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| 367 | 402 |
| 368 scoped_refptr<SolidColorLayer> target = CreateSolidColorLayer( | 403 scoped_refptr<SolidColorLayer> target = |
| 369 gfx::Rect(100, 100, 100, 100), SK_ColorRED); | 404 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); |
| 370 background->AddChild(target); | 405 background->AddChild(target); |
| 371 | 406 |
| 372 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 407 scoped_refptr<SolidColorLayer> green = |
| 373 gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); | 408 CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); |
| 374 target->AddChild(green); | 409 target->AddChild(green); |
| 375 | 410 |
| 376 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 411 scoped_refptr<SolidColorLayer> blue = |
| 377 gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 412 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 378 target->AddChild(blue); | 413 target->AddChild(blue); |
| 379 | 414 |
| 380 copy_subrect_ = gfx::Rect(0, 0, 100, 100); | 415 copy_subrect_ = gfx::Rect(0, 0, 100, 100); |
| 381 RunPixelTestWithReadbackTarget(SOFTWARE_WITH_DEFAULT, | 416 RunReadbackTestWithReadbackTarget( |
| 382 background, | 417 PIXEL_TEST_SOFTWARE, |
| 383 target.get(), | 418 READBACK_DEFAULT, |
| 384 base::FilePath(FILE_PATH_LITERAL( | 419 background, |
| 385 "green_small_with_blue_corner.png"))); | 420 target.get(), |
| 421 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 386 } | 422 } |
| 387 | 423 |
| 388 TEST_F(LayerTreeHostReadbackPixelTest, | 424 TEST_F(LayerTreeHostReadbackPixelTest, |
| 389 ReadbackSubtreeSurroundsLayer_GL_Bitmap) { | 425 ReadbackSubtreeSurroundsLayer_GL_Bitmap) { |
| 390 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 426 scoped_refptr<SolidColorLayer> background = |
| 391 gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 427 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| 392 | 428 |
| 393 scoped_refptr<SolidColorLayer> target = CreateSolidColorLayer( | 429 scoped_refptr<SolidColorLayer> target = |
| 394 gfx::Rect(100, 100, 100, 100), SK_ColorRED); | 430 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); |
| 395 background->AddChild(target); | 431 background->AddChild(target); |
| 396 | 432 |
| 397 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 433 scoped_refptr<SolidColorLayer> green = |
| 398 gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); | 434 CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); |
| 399 target->AddChild(green); | 435 target->AddChild(green); |
| 400 | 436 |
| 401 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 437 scoped_refptr<SolidColorLayer> blue = |
| 402 gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 438 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 403 target->AddChild(blue); | 439 target->AddChild(blue); |
| 404 | 440 |
| 405 copy_subrect_ = gfx::Rect(0, 0, 100, 100); | 441 copy_subrect_ = gfx::Rect(0, 0, 100, 100); |
| 406 RunPixelTestWithReadbackTarget(GL_WITH_BITMAP, | 442 RunReadbackTestWithReadbackTarget( |
| 407 background, | 443 PIXEL_TEST_GL, |
| 408 target.get(), | 444 READBACK_BITMAP, |
| 409 base::FilePath(FILE_PATH_LITERAL( | 445 background, |
| 410 "green_small_with_blue_corner.png"))); | 446 target.get(), |
| 411 } | 447 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 412 | 448 } |
| 413 TEST_F(LayerTreeHostReadbackPixelTest, | 449 |
| 414 ReadbackSubtreeSurroundsTargetLayer_GL) { | 450 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubtreeSurroundsTargetLayer_GL) { |
| 415 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 451 scoped_refptr<SolidColorLayer> background = |
| 416 gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 452 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| 417 | 453 |
| 418 scoped_refptr<SolidColorLayer> target = CreateSolidColorLayer( | 454 scoped_refptr<SolidColorLayer> target = |
| 419 gfx::Rect(100, 100, 100, 100), SK_ColorRED); | 455 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); |
| 420 background->AddChild(target); | 456 background->AddChild(target); |
| 421 | 457 |
| 422 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 458 scoped_refptr<SolidColorLayer> green = |
| 423 gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); | 459 CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); |
| 424 target->AddChild(green); | 460 target->AddChild(green); |
| 425 | 461 |
| 426 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 462 scoped_refptr<SolidColorLayer> blue = |
| 427 gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 463 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 428 target->AddChild(blue); | 464 target->AddChild(blue); |
| 429 | 465 |
| 430 copy_subrect_ = gfx::Rect(0, 0, 100, 100); | 466 copy_subrect_ = gfx::Rect(0, 0, 100, 100); |
| 431 RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, | 467 RunReadbackTestWithReadbackTarget( |
| 432 background, | 468 PIXEL_TEST_GL, |
| 433 target.get(), | 469 READBACK_DEFAULT, |
| 434 base::FilePath(FILE_PATH_LITERAL( | 470 background, |
| 435 "green_small_with_blue_corner.png"))); | 471 target.get(), |
| 472 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 436 } | 473 } |
| 437 | 474 |
| 438 TEST_F(LayerTreeHostReadbackPixelTest, | 475 TEST_F(LayerTreeHostReadbackPixelTest, |
| 439 ReadbackSubtreeExtendsBeyondTargetLayer_Software) { | 476 ReadbackSubtreeExtendsBeyondTargetLayer_Software) { |
| 440 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 477 scoped_refptr<SolidColorLayer> background = |
| 441 gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 478 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| 442 | 479 |
| 443 scoped_refptr<SolidColorLayer> target = CreateSolidColorLayer( | 480 scoped_refptr<SolidColorLayer> target = |
| 444 gfx::Rect(50, 50, 150, 150), SK_ColorRED); | 481 CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); |
| 445 background->AddChild(target); | 482 background->AddChild(target); |
| 446 | 483 |
| 447 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 484 scoped_refptr<SolidColorLayer> green = |
| 448 gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); | 485 CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); |
| 449 target->AddChild(green); | 486 target->AddChild(green); |
| 450 | 487 |
| 451 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 488 scoped_refptr<SolidColorLayer> blue = |
| 452 gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); | 489 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); |
| 453 target->AddChild(blue); | 490 target->AddChild(blue); |
| 454 | 491 |
| 455 copy_subrect_ = gfx::Rect(50, 50, 100, 100); | 492 copy_subrect_ = gfx::Rect(50, 50, 100, 100); |
| 456 RunPixelTestWithReadbackTarget(SOFTWARE_WITH_DEFAULT, | 493 RunReadbackTestWithReadbackTarget( |
| 457 background, | 494 PIXEL_TEST_SOFTWARE, |
| 458 target.get(), | 495 READBACK_DEFAULT, |
| 459 base::FilePath(FILE_PATH_LITERAL( | 496 background, |
| 460 "green_small_with_blue_corner.png"))); | 497 target.get(), |
| 498 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 461 } | 499 } |
| 462 | 500 |
| 463 TEST_F(LayerTreeHostReadbackPixelTest, | 501 TEST_F(LayerTreeHostReadbackPixelTest, |
| 464 ReadbackSubtreeExtendsBeyondTargetLayer_GL_Bitmap) { | 502 ReadbackSubtreeExtendsBeyondTargetLayer_GL_Bitmap) { |
| 465 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 503 scoped_refptr<SolidColorLayer> background = |
| 466 gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 504 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| 467 | 505 |
| 468 scoped_refptr<SolidColorLayer> target = CreateSolidColorLayer( | 506 scoped_refptr<SolidColorLayer> target = |
| 469 gfx::Rect(50, 50, 150, 150), SK_ColorRED); | 507 CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); |
| 470 background->AddChild(target); | 508 background->AddChild(target); |
| 471 | 509 |
| 472 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 510 scoped_refptr<SolidColorLayer> green = |
| 473 gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); | 511 CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); |
| 474 target->AddChild(green); | 512 target->AddChild(green); |
| 475 | 513 |
| 476 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 514 scoped_refptr<SolidColorLayer> blue = |
| 477 gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); | 515 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); |
| 478 target->AddChild(blue); | 516 target->AddChild(blue); |
| 479 | 517 |
| 480 copy_subrect_ = gfx::Rect(50, 50, 100, 100); | 518 copy_subrect_ = gfx::Rect(50, 50, 100, 100); |
| 481 RunPixelTestWithReadbackTarget(GL_WITH_BITMAP, | 519 RunReadbackTestWithReadbackTarget( |
| 482 background, | 520 PIXEL_TEST_GL, |
| 483 target.get(), | 521 READBACK_BITMAP, |
| 484 base::FilePath(FILE_PATH_LITERAL( | 522 background, |
| 485 "green_small_with_blue_corner.png"))); | 523 target.get(), |
| 524 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 486 } | 525 } |
| 487 | 526 |
| 488 TEST_F(LayerTreeHostReadbackPixelTest, | 527 TEST_F(LayerTreeHostReadbackPixelTest, |
| 489 ReadbackSubtreeExtendsBeyondTargetLayer_GL) { | 528 ReadbackSubtreeExtendsBeyondTargetLayer_GL) { |
| 490 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 529 scoped_refptr<SolidColorLayer> background = |
| 491 gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 530 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| 492 | 531 |
| 493 scoped_refptr<SolidColorLayer> target = CreateSolidColorLayer( | 532 scoped_refptr<SolidColorLayer> target = |
| 494 gfx::Rect(50, 50, 150, 150), SK_ColorRED); | 533 CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); |
| 495 background->AddChild(target); | 534 background->AddChild(target); |
| 496 | 535 |
| 497 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 536 scoped_refptr<SolidColorLayer> green = |
| 498 gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); | 537 CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); |
| 499 target->AddChild(green); | 538 target->AddChild(green); |
| 500 | 539 |
| 501 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 540 scoped_refptr<SolidColorLayer> blue = |
| 502 gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); | 541 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); |
| 503 target->AddChild(blue); | 542 target->AddChild(blue); |
| 504 | 543 |
| 505 copy_subrect_ = gfx::Rect(50, 50, 100, 100); | 544 copy_subrect_ = gfx::Rect(50, 50, 100, 100); |
| 506 RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, | 545 RunReadbackTestWithReadbackTarget( |
| 507 background, | 546 PIXEL_TEST_GL, |
| 508 target.get(), | 547 READBACK_DEFAULT, |
| 509 base::FilePath(FILE_PATH_LITERAL( | 548 background, |
| 510 "green_small_with_blue_corner.png"))); | 549 target.get(), |
| 550 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 511 } | 551 } |
| 512 | 552 |
| 513 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree_Software) { | 553 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree_Software) { |
| 514 scoped_refptr<SolidColorLayer> background = | 554 scoped_refptr<SolidColorLayer> background = |
| 515 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); | 555 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| 516 | 556 |
| 517 scoped_refptr<SolidColorLayer> hidden_target = | 557 scoped_refptr<SolidColorLayer> hidden_target = |
| 518 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 558 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 519 hidden_target->SetHideLayerAndSubtree(true); | 559 hidden_target->SetHideLayerAndSubtree(true); |
| 520 background->AddChild(hidden_target); | 560 background->AddChild(hidden_target); |
| 521 | 561 |
| 522 scoped_refptr<SolidColorLayer> blue = | 562 scoped_refptr<SolidColorLayer> blue = |
| 523 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 563 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
| 524 hidden_target->AddChild(blue); | 564 hidden_target->AddChild(blue); |
| 525 | 565 |
| 526 RunPixelTestWithReadbackTarget( | 566 RunReadbackTestWithReadbackTarget( |
| 527 SOFTWARE_WITH_DEFAULT, | 567 PIXEL_TEST_SOFTWARE, |
| 568 READBACK_DEFAULT, |
| 528 background, | 569 background, |
| 529 hidden_target.get(), | 570 hidden_target.get(), |
| 530 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); | 571 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); |
| 531 } | 572 } |
| 532 | 573 |
| 533 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree_GL_Bitmap) { | 574 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree_GL_Bitmap) { |
| 534 scoped_refptr<SolidColorLayer> background = | 575 scoped_refptr<SolidColorLayer> background = |
| 535 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); | 576 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| 536 | 577 |
| 537 scoped_refptr<SolidColorLayer> hidden_target = | 578 scoped_refptr<SolidColorLayer> hidden_target = |
| 538 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 579 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 539 hidden_target->SetHideLayerAndSubtree(true); | 580 hidden_target->SetHideLayerAndSubtree(true); |
| 540 background->AddChild(hidden_target); | 581 background->AddChild(hidden_target); |
| 541 | 582 |
| 542 scoped_refptr<SolidColorLayer> blue = | 583 scoped_refptr<SolidColorLayer> blue = |
| 543 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 584 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
| 544 hidden_target->AddChild(blue); | 585 hidden_target->AddChild(blue); |
| 545 | 586 |
| 546 RunPixelTestWithReadbackTarget( | 587 RunReadbackTestWithReadbackTarget( |
| 547 GL_WITH_BITMAP, | 588 PIXEL_TEST_GL, |
| 589 READBACK_BITMAP, |
| 548 background, | 590 background, |
| 549 hidden_target.get(), | 591 hidden_target.get(), |
| 550 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); | 592 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); |
| 551 } | 593 } |
| 552 | 594 |
| 553 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree_GL) { | 595 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree_GL) { |
| 554 scoped_refptr<SolidColorLayer> background = | 596 scoped_refptr<SolidColorLayer> background = |
| 555 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); | 597 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| 556 | 598 |
| 557 scoped_refptr<SolidColorLayer> hidden_target = | 599 scoped_refptr<SolidColorLayer> hidden_target = |
| 558 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 600 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 559 hidden_target->SetHideLayerAndSubtree(true); | 601 hidden_target->SetHideLayerAndSubtree(true); |
| 560 background->AddChild(hidden_target); | 602 background->AddChild(hidden_target); |
| 561 | 603 |
| 562 scoped_refptr<SolidColorLayer> blue = | 604 scoped_refptr<SolidColorLayer> blue = |
| 563 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 605 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
| 564 hidden_target->AddChild(blue); | 606 hidden_target->AddChild(blue); |
| 565 | 607 |
| 566 RunPixelTestWithReadbackTarget( | 608 RunReadbackTestWithReadbackTarget( |
| 567 GL_WITH_DEFAULT, | 609 PIXEL_TEST_GL, |
| 610 READBACK_DEFAULT, |
| 568 background, | 611 background, |
| 569 hidden_target.get(), | 612 hidden_target.get(), |
| 570 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); | 613 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); |
| 571 } | 614 } |
| 572 | 615 |
| 573 TEST_F(LayerTreeHostReadbackPixelTest, | 616 TEST_F(LayerTreeHostReadbackPixelTest, |
| 574 HiddenSubtreeNotVisibleWhenDrawnForReadback_Software) { | 617 HiddenSubtreeNotVisibleWhenDrawnForReadback_Software) { |
| 575 scoped_refptr<SolidColorLayer> background = | 618 scoped_refptr<SolidColorLayer> background = |
| 576 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); | 619 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| 577 | 620 |
| 578 scoped_refptr<SolidColorLayer> hidden_target = | 621 scoped_refptr<SolidColorLayer> hidden_target = |
| 579 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 622 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 580 hidden_target->SetHideLayerAndSubtree(true); | 623 hidden_target->SetHideLayerAndSubtree(true); |
| 581 background->AddChild(hidden_target); | 624 background->AddChild(hidden_target); |
| 582 | 625 |
| 583 scoped_refptr<SolidColorLayer> blue = | 626 scoped_refptr<SolidColorLayer> blue = |
| 584 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 627 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
| 585 hidden_target->AddChild(blue); | 628 hidden_target->AddChild(blue); |
| 586 | 629 |
| 587 hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( | 630 hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
| 588 base::Bind(&IgnoreReadbackResult))); | 631 base::Bind(&IgnoreReadbackResult))); |
| 589 RunPixelTest(SOFTWARE_WITH_DEFAULT, | 632 RunReadbackTest(PIXEL_TEST_SOFTWARE, |
| 590 background, | 633 READBACK_DEFAULT, |
| 591 base::FilePath(FILE_PATH_LITERAL("black.png"))); | 634 background, |
| 635 base::FilePath(FILE_PATH_LITERAL("black.png"))); |
| 592 } | 636 } |
| 593 | 637 |
| 594 TEST_F(LayerTreeHostReadbackPixelTest, | 638 TEST_F(LayerTreeHostReadbackPixelTest, |
| 595 HiddenSubtreeNotVisibleWhenDrawnForReadback_GL_Bitmap) { | 639 HiddenSubtreeNotVisibleWhenDrawnForReadback_GL_Bitmap) { |
| 596 scoped_refptr<SolidColorLayer> background = | 640 scoped_refptr<SolidColorLayer> background = |
| 597 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); | 641 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| 598 | 642 |
| 599 scoped_refptr<SolidColorLayer> hidden_target = | 643 scoped_refptr<SolidColorLayer> hidden_target = |
| 600 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 644 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 601 hidden_target->SetHideLayerAndSubtree(true); | 645 hidden_target->SetHideLayerAndSubtree(true); |
| 602 background->AddChild(hidden_target); | 646 background->AddChild(hidden_target); |
| 603 | 647 |
| 604 scoped_refptr<SolidColorLayer> blue = | 648 scoped_refptr<SolidColorLayer> blue = |
| 605 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 649 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
| 606 hidden_target->AddChild(blue); | 650 hidden_target->AddChild(blue); |
| 607 | 651 |
| 608 hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( | 652 hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
| 609 base::Bind(&IgnoreReadbackResult))); | 653 base::Bind(&IgnoreReadbackResult))); |
| 610 RunPixelTest(GL_WITH_BITMAP, | 654 RunReadbackTest(PIXEL_TEST_GL, |
| 611 background, | 655 READBACK_BITMAP, |
| 612 base::FilePath(FILE_PATH_LITERAL("black.png"))); | 656 background, |
| 657 base::FilePath(FILE_PATH_LITERAL("black.png"))); |
| 613 } | 658 } |
| 614 | 659 |
| 615 TEST_F(LayerTreeHostReadbackPixelTest, | 660 TEST_F(LayerTreeHostReadbackPixelTest, |
| 616 HiddenSubtreeNotVisibleWhenDrawnForReadback_GL) { | 661 HiddenSubtreeNotVisibleWhenDrawnForReadback_GL) { |
| 617 scoped_refptr<SolidColorLayer> background = | 662 scoped_refptr<SolidColorLayer> background = |
| 618 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); | 663 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
| 619 | 664 |
| 620 scoped_refptr<SolidColorLayer> hidden_target = | 665 scoped_refptr<SolidColorLayer> hidden_target = |
| 621 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 666 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 622 hidden_target->SetHideLayerAndSubtree(true); | 667 hidden_target->SetHideLayerAndSubtree(true); |
| 623 background->AddChild(hidden_target); | 668 background->AddChild(hidden_target); |
| 624 | 669 |
| 625 scoped_refptr<SolidColorLayer> blue = | 670 scoped_refptr<SolidColorLayer> blue = |
| 626 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 671 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
| 627 hidden_target->AddChild(blue); | 672 hidden_target->AddChild(blue); |
| 628 | 673 |
| 629 hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( | 674 hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
| 630 base::Bind(&IgnoreReadbackResult))); | 675 base::Bind(&IgnoreReadbackResult))); |
| 631 RunPixelTest(GL_WITH_DEFAULT, | 676 RunReadbackTest(PIXEL_TEST_GL, |
| 632 background, | 677 READBACK_DEFAULT, |
| 633 base::FilePath(FILE_PATH_LITERAL("black.png"))); | 678 background, |
| 679 base::FilePath(FILE_PATH_LITERAL("black.png"))); |
| 634 } | 680 } |
| 635 | 681 |
| 636 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_Software) { | 682 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_Software) { |
| 637 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 683 scoped_refptr<SolidColorLayer> background = |
| 638 gfx::Rect(200, 200), SK_ColorWHITE); | 684 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 639 | 685 |
| 640 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 686 scoped_refptr<SolidColorLayer> green = |
| 641 gfx::Rect(200, 200), SK_ColorGREEN); | 687 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 642 background->AddChild(green); | 688 background->AddChild(green); |
| 643 | 689 |
| 644 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 690 scoped_refptr<SolidColorLayer> blue = |
| 645 gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); | 691 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); |
| 646 green->AddChild(blue); | 692 green->AddChild(blue); |
| 647 | 693 |
| 648 // Grab the middle of the root layer. | 694 // Grab the middle of the root layer. |
| 649 copy_subrect_ = gfx::Rect(50, 50, 100, 100); | 695 copy_subrect_ = gfx::Rect(50, 50, 100, 100); |
| 650 | 696 |
| 651 RunPixelTest(SOFTWARE_WITH_DEFAULT, | 697 RunReadbackTest( |
| 652 background, | 698 PIXEL_TEST_SOFTWARE, |
| 653 base::FilePath(FILE_PATH_LITERAL( | 699 READBACK_DEFAULT, |
| 654 "green_small_with_blue_corner.png"))); | 700 background, |
| 701 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 655 } | 702 } |
| 656 | 703 |
| 657 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_GL_Bitmap) { | 704 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_GL_Bitmap) { |
| 658 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 705 scoped_refptr<SolidColorLayer> background = |
| 659 gfx::Rect(200, 200), SK_ColorWHITE); | 706 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 660 | 707 |
| 661 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 708 scoped_refptr<SolidColorLayer> green = |
| 662 gfx::Rect(200, 200), SK_ColorGREEN); | 709 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 663 background->AddChild(green); | 710 background->AddChild(green); |
| 664 | 711 |
| 665 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 712 scoped_refptr<SolidColorLayer> blue = |
| 666 gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); | 713 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); |
| 667 green->AddChild(blue); | 714 green->AddChild(blue); |
| 668 | 715 |
| 669 // Grab the middle of the root layer. | 716 // Grab the middle of the root layer. |
| 670 copy_subrect_ = gfx::Rect(50, 50, 100, 100); | 717 copy_subrect_ = gfx::Rect(50, 50, 100, 100); |
| 671 | 718 |
| 672 RunPixelTest(GL_WITH_BITMAP, | 719 RunReadbackTest( |
| 673 background, | 720 PIXEL_TEST_GL, |
| 674 base::FilePath(FILE_PATH_LITERAL( | 721 READBACK_BITMAP, |
| 675 "green_small_with_blue_corner.png"))); | 722 background, |
| 723 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 676 } | 724 } |
| 677 | 725 |
| 678 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_GL) { | 726 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_GL) { |
| 679 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 727 scoped_refptr<SolidColorLayer> background = |
| 680 gfx::Rect(200, 200), SK_ColorWHITE); | 728 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 681 | 729 |
| 682 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 730 scoped_refptr<SolidColorLayer> green = |
| 683 gfx::Rect(200, 200), SK_ColorGREEN); | 731 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 684 background->AddChild(green); | 732 background->AddChild(green); |
| 685 | 733 |
| 686 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 734 scoped_refptr<SolidColorLayer> blue = |
| 687 gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); | 735 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); |
| 688 green->AddChild(blue); | 736 green->AddChild(blue); |
| 689 | 737 |
| 690 // Grab the middle of the root layer. | 738 // Grab the middle of the root layer. |
| 691 copy_subrect_ = gfx::Rect(50, 50, 100, 100); | 739 copy_subrect_ = gfx::Rect(50, 50, 100, 100); |
| 692 | 740 |
| 693 RunPixelTest(GL_WITH_DEFAULT, | 741 RunReadbackTest( |
| 694 background, | 742 PIXEL_TEST_GL, |
| 695 base::FilePath(FILE_PATH_LITERAL( | 743 READBACK_DEFAULT, |
| 696 "green_small_with_blue_corner.png"))); | 744 background, |
| 745 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 697 } | 746 } |
| 698 | 747 |
| 699 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect_Software) { | 748 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect_Software) { |
| 700 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 749 scoped_refptr<SolidColorLayer> background = |
| 701 gfx::Rect(200, 200), SK_ColorWHITE); | 750 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 702 | 751 |
| 703 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 752 scoped_refptr<SolidColorLayer> green = |
| 704 gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); | 753 CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); |
| 705 background->AddChild(green); | 754 background->AddChild(green); |
| 706 | 755 |
| 707 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 756 scoped_refptr<SolidColorLayer> blue = |
| 708 gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); | 757 CreateSolidColorLayer(gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); |
| 709 green->AddChild(blue); | 758 green->AddChild(blue); |
| 710 | 759 |
| 711 // Grab the middle of the green layer. | 760 // Grab the middle of the green layer. |
| 712 copy_subrect_ = gfx::Rect(25, 25, 100, 100); | 761 copy_subrect_ = gfx::Rect(25, 25, 100, 100); |
| 713 | 762 |
| 714 RunPixelTestWithReadbackTarget(SOFTWARE_WITH_DEFAULT, | 763 RunReadbackTestWithReadbackTarget( |
| 715 background, | 764 PIXEL_TEST_SOFTWARE, |
| 716 green.get(), | 765 READBACK_DEFAULT, |
| 717 base::FilePath(FILE_PATH_LITERAL( | 766 background, |
| 718 "green_small_with_blue_corner.png"))); | 767 green.get(), |
| 768 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 719 } | 769 } |
| 720 | 770 |
| 721 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect_GL_Bitmap) { | 771 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect_GL_Bitmap) { |
| 722 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 772 scoped_refptr<SolidColorLayer> background = |
| 723 gfx::Rect(200, 200), SK_ColorWHITE); | 773 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 724 | 774 |
| 725 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 775 scoped_refptr<SolidColorLayer> green = |
| 726 gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); | 776 CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); |
| 727 background->AddChild(green); | 777 background->AddChild(green); |
| 728 | 778 |
| 729 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 779 scoped_refptr<SolidColorLayer> blue = |
| 730 gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); | 780 CreateSolidColorLayer(gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); |
| 731 green->AddChild(blue); | 781 green->AddChild(blue); |
| 732 | 782 |
| 733 // Grab the middle of the green layer. | 783 // Grab the middle of the green layer. |
| 734 copy_subrect_ = gfx::Rect(25, 25, 100, 100); | 784 copy_subrect_ = gfx::Rect(25, 25, 100, 100); |
| 735 | 785 |
| 736 RunPixelTestWithReadbackTarget(GL_WITH_BITMAP, | 786 RunReadbackTestWithReadbackTarget( |
| 737 background, | 787 PIXEL_TEST_GL, |
| 738 green.get(), | 788 READBACK_BITMAP, |
| 739 base::FilePath(FILE_PATH_LITERAL( | 789 background, |
| 740 "green_small_with_blue_corner.png"))); | 790 green.get(), |
| 791 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 741 } | 792 } |
| 742 | 793 |
| 743 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect_GL) { | 794 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect_GL) { |
| 744 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 795 scoped_refptr<SolidColorLayer> background = |
| 745 gfx::Rect(200, 200), SK_ColorWHITE); | 796 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 746 | 797 |
| 747 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 798 scoped_refptr<SolidColorLayer> green = |
| 748 gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); | 799 CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); |
| 749 background->AddChild(green); | 800 background->AddChild(green); |
| 750 | 801 |
| 751 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 802 scoped_refptr<SolidColorLayer> blue = |
| 752 gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); | 803 CreateSolidColorLayer(gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); |
| 753 green->AddChild(blue); | 804 green->AddChild(blue); |
| 754 | 805 |
| 755 // Grab the middle of the green layer. | 806 // Grab the middle of the green layer. |
| 756 copy_subrect_ = gfx::Rect(25, 25, 100, 100); | 807 copy_subrect_ = gfx::Rect(25, 25, 100, 100); |
| 757 | 808 |
| 758 RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, | 809 RunReadbackTestWithReadbackTarget( |
| 759 background, | 810 PIXEL_TEST_GL, |
| 760 green.get(), | 811 READBACK_DEFAULT, |
| 761 base::FilePath(FILE_PATH_LITERAL( | 812 background, |
| 762 "green_small_with_blue_corner.png"))); | 813 green.get(), |
| 814 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 763 } | 815 } |
| 764 | 816 |
| 765 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage_Software) { | 817 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage_Software) { |
| 766 scoped_refptr<SolidColorLayer> background = | 818 scoped_refptr<SolidColorLayer> background = |
| 767 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 819 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| 768 | 820 |
| 769 scoped_refptr<SolidColorLayer> parent = | 821 scoped_refptr<SolidColorLayer> parent = |
| 770 CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); | 822 CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); |
| 771 background->AddChild(parent); | 823 background->AddChild(parent); |
| 772 | 824 |
| 773 scoped_refptr<SolidColorLayer> target = | 825 scoped_refptr<SolidColorLayer> target = |
| 774 CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); | 826 CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); |
| 775 parent->AddChild(target); | 827 parent->AddChild(target); |
| 776 | 828 |
| 777 scoped_refptr<SolidColorLayer> blue = | 829 scoped_refptr<SolidColorLayer> blue = |
| 778 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 830 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 779 target->AddChild(blue); | 831 target->AddChild(blue); |
| 780 | 832 |
| 781 insert_copy_request_after_frame_count_ = 1; | 833 insert_copy_request_after_frame_count_ = 1; |
| 782 RunPixelTestWithReadbackTarget( | 834 RunReadbackTestWithReadbackTarget( |
| 783 SOFTWARE_WITH_DEFAULT, | 835 PIXEL_TEST_SOFTWARE, |
| 836 READBACK_DEFAULT, |
| 784 background, | 837 background, |
| 785 target.get(), | 838 target.get(), |
| 786 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 839 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 787 } | 840 } |
| 788 | 841 |
| 789 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage_GL_Bitmap) { | 842 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage_GL_Bitmap) { |
| 790 scoped_refptr<SolidColorLayer> background = | 843 scoped_refptr<SolidColorLayer> background = |
| 791 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 844 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| 792 | 845 |
| 793 scoped_refptr<SolidColorLayer> parent = | 846 scoped_refptr<SolidColorLayer> parent = |
| 794 CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); | 847 CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); |
| 795 background->AddChild(parent); | 848 background->AddChild(parent); |
| 796 | 849 |
| 797 scoped_refptr<SolidColorLayer> target = | 850 scoped_refptr<SolidColorLayer> target = |
| 798 CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); | 851 CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); |
| 799 parent->AddChild(target); | 852 parent->AddChild(target); |
| 800 | 853 |
| 801 scoped_refptr<SolidColorLayer> blue = | 854 scoped_refptr<SolidColorLayer> blue = |
| 802 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 855 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 803 target->AddChild(blue); | 856 target->AddChild(blue); |
| 804 | 857 |
| 805 insert_copy_request_after_frame_count_ = 1; | 858 insert_copy_request_after_frame_count_ = 1; |
| 806 RunPixelTestWithReadbackTarget( | 859 RunReadbackTestWithReadbackTarget( |
| 807 GL_WITH_BITMAP, | 860 PIXEL_TEST_GL, |
| 861 READBACK_BITMAP, |
| 808 background, | 862 background, |
| 809 target.get(), | 863 target.get(), |
| 810 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 864 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 811 } | 865 } |
| 812 | 866 |
| 813 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage_GL) { | 867 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage_GL) { |
| 814 scoped_refptr<SolidColorLayer> background = | 868 scoped_refptr<SolidColorLayer> background = |
| 815 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 869 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| 816 | 870 |
| 817 scoped_refptr<SolidColorLayer> parent = | 871 scoped_refptr<SolidColorLayer> parent = |
| 818 CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); | 872 CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); |
| 819 background->AddChild(parent); | 873 background->AddChild(parent); |
| 820 | 874 |
| 821 scoped_refptr<SolidColorLayer> target = | 875 scoped_refptr<SolidColorLayer> target = |
| 822 CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); | 876 CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); |
| 823 parent->AddChild(target); | 877 parent->AddChild(target); |
| 824 | 878 |
| 825 scoped_refptr<SolidColorLayer> blue = | 879 scoped_refptr<SolidColorLayer> blue = |
| 826 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 880 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 827 target->AddChild(blue); | 881 target->AddChild(blue); |
| 828 | 882 |
| 829 insert_copy_request_after_frame_count_ = 1; | 883 insert_copy_request_after_frame_count_ = 1; |
| 830 RunPixelTestWithReadbackTarget( | 884 RunReadbackTestWithReadbackTarget( |
| 831 GL_WITH_DEFAULT, | 885 PIXEL_TEST_GL, |
| 886 READBACK_DEFAULT, |
| 832 background, | 887 background, |
| 833 target.get(), | 888 target.get(), |
| 834 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 889 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 835 } | 890 } |
| 836 | 891 |
| 837 TEST_F(LayerTreeHostReadbackPixelTest, | 892 TEST_F(LayerTreeHostReadbackPixelTest, |
| 838 ReadbackOutsideViewportWhenNoDamage_Software) { | 893 ReadbackOutsideViewportWhenNoDamage_Software) { |
| 839 scoped_refptr<SolidColorLayer> background = | 894 scoped_refptr<SolidColorLayer> background = |
| 840 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 895 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| 841 | 896 |
| 842 scoped_refptr<SolidColorLayer> parent = | 897 scoped_refptr<SolidColorLayer> parent = |
| 843 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); | 898 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); |
| 844 EXPECT_FALSE(parent->masks_to_bounds()); | 899 EXPECT_FALSE(parent->masks_to_bounds()); |
| 845 background->AddChild(parent); | 900 background->AddChild(parent); |
| 846 | 901 |
| 847 scoped_refptr<SolidColorLayer> target = | 902 scoped_refptr<SolidColorLayer> target = |
| 848 CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); | 903 CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); |
| 849 parent->AddChild(target); | 904 parent->AddChild(target); |
| 850 | 905 |
| 851 scoped_refptr<SolidColorLayer> blue = | 906 scoped_refptr<SolidColorLayer> blue = |
| 852 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 907 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 853 target->AddChild(blue); | 908 target->AddChild(blue); |
| 854 | 909 |
| 855 insert_copy_request_after_frame_count_ = 1; | 910 insert_copy_request_after_frame_count_ = 1; |
| 856 RunPixelTestWithReadbackTarget( | 911 RunReadbackTestWithReadbackTarget( |
| 857 SOFTWARE_WITH_DEFAULT, | 912 PIXEL_TEST_SOFTWARE, |
| 913 READBACK_DEFAULT, |
| 858 background, | 914 background, |
| 859 target.get(), | 915 target.get(), |
| 860 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 916 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 861 } | 917 } |
| 862 | 918 |
| 863 TEST_F(LayerTreeHostReadbackPixelTest, | 919 TEST_F(LayerTreeHostReadbackPixelTest, |
| 864 ReadbackOutsideViewportWhenNoDamage_GL_Bitmap) { | 920 ReadbackOutsideViewportWhenNoDamage_GL_Bitmap) { |
| 865 scoped_refptr<SolidColorLayer> background = | 921 scoped_refptr<SolidColorLayer> background = |
| 866 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 922 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| 867 | 923 |
| 868 scoped_refptr<SolidColorLayer> parent = | 924 scoped_refptr<SolidColorLayer> parent = |
| 869 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); | 925 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); |
| 870 EXPECT_FALSE(parent->masks_to_bounds()); | 926 EXPECT_FALSE(parent->masks_to_bounds()); |
| 871 background->AddChild(parent); | 927 background->AddChild(parent); |
| 872 | 928 |
| 873 scoped_refptr<SolidColorLayer> target = | 929 scoped_refptr<SolidColorLayer> target = |
| 874 CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); | 930 CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); |
| 875 parent->AddChild(target); | 931 parent->AddChild(target); |
| 876 | 932 |
| 877 scoped_refptr<SolidColorLayer> blue = | 933 scoped_refptr<SolidColorLayer> blue = |
| 878 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 934 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 879 target->AddChild(blue); | 935 target->AddChild(blue); |
| 880 | 936 |
| 881 insert_copy_request_after_frame_count_ = 1; | 937 insert_copy_request_after_frame_count_ = 1; |
| 882 RunPixelTestWithReadbackTarget( | 938 RunReadbackTestWithReadbackTarget( |
| 883 GL_WITH_BITMAP, | 939 PIXEL_TEST_GL, |
| 940 READBACK_BITMAP, |
| 884 background, | 941 background, |
| 885 target.get(), | 942 target.get(), |
| 886 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 943 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 887 } | 944 } |
| 888 | 945 |
| 889 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackOutsideViewportWhenNoDamage_GL) { | 946 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackOutsideViewportWhenNoDamage_GL) { |
| 890 scoped_refptr<SolidColorLayer> background = | 947 scoped_refptr<SolidColorLayer> background = |
| 891 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 948 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
| 892 | 949 |
| 893 scoped_refptr<SolidColorLayer> parent = | 950 scoped_refptr<SolidColorLayer> parent = |
| 894 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); | 951 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); |
| 895 EXPECT_FALSE(parent->masks_to_bounds()); | 952 EXPECT_FALSE(parent->masks_to_bounds()); |
| 896 background->AddChild(parent); | 953 background->AddChild(parent); |
| 897 | 954 |
| 898 scoped_refptr<SolidColorLayer> target = | 955 scoped_refptr<SolidColorLayer> target = |
| 899 CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); | 956 CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); |
| 900 parent->AddChild(target); | 957 parent->AddChild(target); |
| 901 | 958 |
| 902 scoped_refptr<SolidColorLayer> blue = | 959 scoped_refptr<SolidColorLayer> blue = |
| 903 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 960 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 904 target->AddChild(blue); | 961 target->AddChild(blue); |
| 905 | 962 |
| 906 insert_copy_request_after_frame_count_ = 1; | 963 insert_copy_request_after_frame_count_ = 1; |
| 907 RunPixelTestWithReadbackTarget( | 964 RunReadbackTestWithReadbackTarget( |
| 908 GL_WITH_DEFAULT, | 965 PIXEL_TEST_GL, |
| 966 READBACK_DEFAULT, |
| 909 background, | 967 background, |
| 910 target.get(), | 968 target.get(), |
| 911 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 969 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 912 } | 970 } |
| 913 | 971 |
| 914 class LayerTreeHostReadbackDeviceScalePixelTest | 972 class LayerTreeHostReadbackDeviceScalePixelTest |
| 915 : public LayerTreeHostReadbackPixelTest { | 973 : public LayerTreeHostReadbackPixelTest { |
| 916 protected: | 974 protected: |
| 917 LayerTreeHostReadbackDeviceScalePixelTest() | 975 LayerTreeHostReadbackDeviceScalePixelTest() |
| 918 : device_scale_factor_(1.f), | 976 : device_scale_factor_(1.f), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 934 EXPECT_EQ(device_scale_factor_, | 992 EXPECT_EQ(device_scale_factor_, |
| 935 host_impl->active_tree()->device_scale_factor()); | 993 host_impl->active_tree()->device_scale_factor()); |
| 936 } | 994 } |
| 937 | 995 |
| 938 float device_scale_factor_; | 996 float device_scale_factor_; |
| 939 SolidColorContentLayerClient white_client_; | 997 SolidColorContentLayerClient white_client_; |
| 940 SolidColorContentLayerClient green_client_; | 998 SolidColorContentLayerClient green_client_; |
| 941 SolidColorContentLayerClient blue_client_; | 999 SolidColorContentLayerClient blue_client_; |
| 942 }; | 1000 }; |
| 943 | 1001 |
| 944 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, | 1002 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect_Software) { |
| 945 ReadbackSubrect_Software) { | |
| 946 scoped_refptr<FakePictureLayer> background = | 1003 scoped_refptr<FakePictureLayer> background = |
| 947 FakePictureLayer::Create(&white_client_); | 1004 FakePictureLayer::Create(&white_client_); |
| 948 background->SetBounds(gfx::Size(100, 100)); | 1005 background->SetBounds(gfx::Size(100, 100)); |
| 949 background->SetIsDrawable(true); | 1006 background->SetIsDrawable(true); |
| 950 | 1007 |
| 951 scoped_refptr<FakePictureLayer> green = | 1008 scoped_refptr<FakePictureLayer> green = |
| 952 FakePictureLayer::Create(&green_client_); | 1009 FakePictureLayer::Create(&green_client_); |
| 953 green->SetBounds(gfx::Size(100, 100)); | 1010 green->SetBounds(gfx::Size(100, 100)); |
| 954 green->SetIsDrawable(true); | 1011 green->SetIsDrawable(true); |
| 955 background->AddChild(green); | 1012 background->AddChild(green); |
| 956 | 1013 |
| 957 scoped_refptr<FakePictureLayer> blue = | 1014 scoped_refptr<FakePictureLayer> blue = |
| 958 FakePictureLayer::Create(&blue_client_); | 1015 FakePictureLayer::Create(&blue_client_); |
| 959 blue->SetPosition(gfx::Point(50, 50)); | 1016 blue->SetPosition(gfx::Point(50, 50)); |
| 960 blue->SetBounds(gfx::Size(25, 25)); | 1017 blue->SetBounds(gfx::Size(25, 25)); |
| 961 blue->SetIsDrawable(true); | 1018 blue->SetIsDrawable(true); |
| 962 green->AddChild(blue); | 1019 green->AddChild(blue); |
| 963 | 1020 |
| 964 // Grab the middle of the root layer. | 1021 // Grab the middle of the root layer. |
| 965 copy_subrect_ = gfx::Rect(25, 25, 50, 50); | 1022 copy_subrect_ = gfx::Rect(25, 25, 50, 50); |
| 966 device_scale_factor_ = 2.f; | 1023 device_scale_factor_ = 2.f; |
| 967 RunPixelTest(SOFTWARE_WITH_DEFAULT, | 1024 RunReadbackTest( |
| 968 background, | 1025 PIXEL_TEST_SOFTWARE, |
| 969 base::FilePath(FILE_PATH_LITERAL( | 1026 READBACK_DEFAULT, |
| 970 "green_small_with_blue_corner.png"))); | 1027 background, |
| 1028 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 971 } | 1029 } |
| 972 | 1030 |
| 973 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, | 1031 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect_GL) { |
| 974 ReadbackSubrect_GL) { | |
| 975 scoped_refptr<FakePictureLayer> background = | 1032 scoped_refptr<FakePictureLayer> background = |
| 976 FakePictureLayer::Create(&white_client_); | 1033 FakePictureLayer::Create(&white_client_); |
| 977 background->SetBounds(gfx::Size(100, 100)); | 1034 background->SetBounds(gfx::Size(100, 100)); |
| 978 background->SetIsDrawable(true); | 1035 background->SetIsDrawable(true); |
| 979 | 1036 |
| 980 scoped_refptr<FakePictureLayer> green = | 1037 scoped_refptr<FakePictureLayer> green = |
| 981 FakePictureLayer::Create(&green_client_); | 1038 FakePictureLayer::Create(&green_client_); |
| 982 green->SetBounds(gfx::Size(100, 100)); | 1039 green->SetBounds(gfx::Size(100, 100)); |
| 983 green->SetIsDrawable(true); | 1040 green->SetIsDrawable(true); |
| 984 background->AddChild(green); | 1041 background->AddChild(green); |
| 985 | 1042 |
| 986 scoped_refptr<FakePictureLayer> blue = | 1043 scoped_refptr<FakePictureLayer> blue = |
| 987 FakePictureLayer::Create(&blue_client_); | 1044 FakePictureLayer::Create(&blue_client_); |
| 988 blue->SetPosition(gfx::Point(50, 50)); | 1045 blue->SetPosition(gfx::Point(50, 50)); |
| 989 blue->SetBounds(gfx::Size(25, 25)); | 1046 blue->SetBounds(gfx::Size(25, 25)); |
| 990 blue->SetIsDrawable(true); | 1047 blue->SetIsDrawable(true); |
| 991 green->AddChild(blue); | 1048 green->AddChild(blue); |
| 992 | 1049 |
| 993 // Grab the middle of the root layer. | 1050 // Grab the middle of the root layer. |
| 994 copy_subrect_ = gfx::Rect(25, 25, 50, 50); | 1051 copy_subrect_ = gfx::Rect(25, 25, 50, 50); |
| 995 device_scale_factor_ = 2.f; | 1052 device_scale_factor_ = 2.f; |
| 996 RunPixelTest(GL_WITH_DEFAULT, | 1053 RunReadbackTest( |
| 997 background, | 1054 PIXEL_TEST_GL, |
| 998 base::FilePath(FILE_PATH_LITERAL( | 1055 READBACK_DEFAULT, |
| 999 "green_small_with_blue_corner.png"))); | 1056 background, |
| 1057 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 1000 } | 1058 } |
| 1001 | 1059 |
| 1002 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, | 1060 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, |
| 1003 ReadbackNonRootLayerSubrect_Software) { | 1061 ReadbackNonRootLayerSubrect_Software) { |
| 1004 scoped_refptr<FakePictureLayer> background = | 1062 scoped_refptr<FakePictureLayer> background = |
| 1005 FakePictureLayer::Create(&white_client_); | 1063 FakePictureLayer::Create(&white_client_); |
| 1006 background->SetBounds(gfx::Size(100, 100)); | 1064 background->SetBounds(gfx::Size(100, 100)); |
| 1007 background->SetIsDrawable(true); | 1065 background->SetIsDrawable(true); |
| 1008 | 1066 |
| 1009 scoped_refptr<FakePictureLayer> green = | 1067 scoped_refptr<FakePictureLayer> green = |
| 1010 FakePictureLayer::Create(&green_client_); | 1068 FakePictureLayer::Create(&green_client_); |
| 1011 green->SetPosition(gfx::Point(10, 20)); | 1069 green->SetPosition(gfx::Point(10, 20)); |
| 1012 green->SetBounds(gfx::Size(90, 80)); | 1070 green->SetBounds(gfx::Size(90, 80)); |
| 1013 green->SetIsDrawable(true); | 1071 green->SetIsDrawable(true); |
| 1014 background->AddChild(green); | 1072 background->AddChild(green); |
| 1015 | 1073 |
| 1016 scoped_refptr<FakePictureLayer> blue = | 1074 scoped_refptr<FakePictureLayer> blue = |
| 1017 FakePictureLayer::Create(&blue_client_); | 1075 FakePictureLayer::Create(&blue_client_); |
| 1018 blue->SetPosition(gfx::Point(50, 50)); | 1076 blue->SetPosition(gfx::Point(50, 50)); |
| 1019 blue->SetBounds(gfx::Size(25, 25)); | 1077 blue->SetBounds(gfx::Size(25, 25)); |
| 1020 blue->SetIsDrawable(true); | 1078 blue->SetIsDrawable(true); |
| 1021 green->AddChild(blue); | 1079 green->AddChild(blue); |
| 1022 | 1080 |
| 1023 // Grab the green layer's content with blue in the bottom right. | 1081 // Grab the green layer's content with blue in the bottom right. |
| 1024 copy_subrect_ = gfx::Rect(25, 25, 50, 50); | 1082 copy_subrect_ = gfx::Rect(25, 25, 50, 50); |
| 1025 device_scale_factor_ = 2.f; | 1083 device_scale_factor_ = 2.f; |
| 1026 RunPixelTestWithReadbackTarget(SOFTWARE_WITH_DEFAULT, | 1084 RunReadbackTestWithReadbackTarget( |
| 1027 background, | 1085 PIXEL_TEST_SOFTWARE, |
| 1028 green.get(), | 1086 READBACK_DEFAULT, |
| 1029 base::FilePath(FILE_PATH_LITERAL( | 1087 background, |
| 1030 "green_small_with_blue_corner.png"))); | 1088 green.get(), |
| 1089 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 1031 } | 1090 } |
| 1032 | 1091 |
| 1033 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, | 1092 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, |
| 1034 ReadbackNonRootLayerSubrect_GL) { | 1093 ReadbackNonRootLayerSubrect_GL) { |
| 1035 scoped_refptr<FakePictureLayer> background = | 1094 scoped_refptr<FakePictureLayer> background = |
| 1036 FakePictureLayer::Create(&white_client_); | 1095 FakePictureLayer::Create(&white_client_); |
| 1037 background->SetBounds(gfx::Size(100, 100)); | 1096 background->SetBounds(gfx::Size(100, 100)); |
| 1038 background->SetIsDrawable(true); | 1097 background->SetIsDrawable(true); |
| 1039 | 1098 |
| 1040 scoped_refptr<FakePictureLayer> green = | 1099 scoped_refptr<FakePictureLayer> green = |
| 1041 FakePictureLayer::Create(&green_client_); | 1100 FakePictureLayer::Create(&green_client_); |
| 1042 green->SetPosition(gfx::Point(10, 20)); | 1101 green->SetPosition(gfx::Point(10, 20)); |
| 1043 green->SetBounds(gfx::Size(90, 80)); | 1102 green->SetBounds(gfx::Size(90, 80)); |
| 1044 green->SetIsDrawable(true); | 1103 green->SetIsDrawable(true); |
| 1045 background->AddChild(green); | 1104 background->AddChild(green); |
| 1046 | 1105 |
| 1047 scoped_refptr<FakePictureLayer> blue = | 1106 scoped_refptr<FakePictureLayer> blue = |
| 1048 FakePictureLayer::Create(&blue_client_); | 1107 FakePictureLayer::Create(&blue_client_); |
| 1049 blue->SetPosition(gfx::Point(50, 50)); | 1108 blue->SetPosition(gfx::Point(50, 50)); |
| 1050 blue->SetBounds(gfx::Size(25, 25)); | 1109 blue->SetBounds(gfx::Size(25, 25)); |
| 1051 blue->SetIsDrawable(true); | 1110 blue->SetIsDrawable(true); |
| 1052 green->AddChild(blue); | 1111 green->AddChild(blue); |
| 1053 | 1112 |
| 1054 // Grab the green layer's content with blue in the bottom right. | 1113 // Grab the green layer's content with blue in the bottom right. |
| 1055 copy_subrect_ = gfx::Rect(25, 25, 50, 50); | 1114 copy_subrect_ = gfx::Rect(25, 25, 50, 50); |
| 1056 device_scale_factor_ = 2.f; | 1115 device_scale_factor_ = 2.f; |
| 1057 RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, | 1116 RunReadbackTestWithReadbackTarget( |
| 1058 background, | 1117 PIXEL_TEST_GL, |
| 1059 green.get(), | 1118 READBACK_DEFAULT, |
| 1060 base::FilePath(FILE_PATH_LITERAL( | 1119 background, |
| 1061 "green_small_with_blue_corner.png"))); | 1120 green.get(), |
| 1121 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
| 1062 } | 1122 } |
| 1063 | 1123 |
| 1064 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerOutsideViewport) { | 1124 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerOutsideViewport) { |
| 1065 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 1125 scoped_refptr<SolidColorLayer> background = |
| 1066 gfx::Rect(200, 200), SK_ColorWHITE); | 1126 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 1067 | 1127 |
| 1068 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( | 1128 scoped_refptr<SolidColorLayer> green = |
| 1069 gfx::Rect(200, 200), SK_ColorGREEN); | 1129 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 1070 // Only the top left quarter of the layer is inside the viewport, so the | 1130 // Only the top left quarter of the layer is inside the viewport, so the |
| 1071 // blue layer is entirely outside. | 1131 // blue layer is entirely outside. |
| 1072 green->SetPosition(gfx::Point(100, 100)); | 1132 green->SetPosition(gfx::Point(100, 100)); |
| 1073 background->AddChild(green); | 1133 background->AddChild(green); |
| 1074 | 1134 |
| 1075 scoped_refptr<SolidColorLayer> blue = CreateSolidColorLayer( | 1135 scoped_refptr<SolidColorLayer> blue = |
| 1076 gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 1136 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
| 1077 green->AddChild(blue); | 1137 green->AddChild(blue); |
| 1078 | 1138 |
| 1079 RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, | 1139 RunReadbackTestWithReadbackTarget( |
| 1080 background, | 1140 PIXEL_TEST_GL, |
| 1081 green.get(), | 1141 READBACK_DEFAULT, |
| 1082 base::FilePath(FILE_PATH_LITERAL( | 1142 background, |
| 1083 "green_with_blue_corner.png"))); | 1143 green.get(), |
| 1144 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); |
| 1084 } | 1145 } |
| 1085 | 1146 |
| 1086 } // namespace | 1147 } // namespace |
| 1087 } // namespace cc | 1148 } // namespace cc |
| 1088 | 1149 |
| 1089 #endif // OS_ANDROID | 1150 #endif // OS_ANDROID |
| OLD | NEW |