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