OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkMathPriv.h" | 10 #include "SkMathPriv.h" |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 } | 380 } |
381 } | 381 } |
382 } | 382 } |
383 DEF_TEST(ReadPixels, reporter) { | 383 DEF_TEST(ReadPixels, reporter) { |
384 const SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H); | 384 const SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H); |
385 auto surface(SkSurface::MakeRaster(info)); | 385 auto surface(SkSurface::MakeRaster(info)); |
386 // SW readback fails a premul check when reading back to an unaligned rowbyt
es. | 386 // SW readback fails a premul check when reading back to an unaligned rowbyt
es. |
387 test_readpixels(reporter, surface, kLastAligned_BitmapInit); | 387 test_readpixels(reporter, surface, kLastAligned_BitmapInit); |
388 } | 388 } |
389 #if SK_SUPPORT_GPU | 389 #if SK_SUPPORT_GPU |
390 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, ctxInfo) { | 390 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, ctxInfo) { |
391 for (auto& origin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin})
{ | 391 for (auto& origin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin})
{ |
392 GrSurfaceDesc desc; | 392 GrSurfaceDesc desc; |
393 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 393 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
394 desc.fWidth = DEV_W; | 394 desc.fWidth = DEV_W; |
395 desc.fHeight = DEV_H; | 395 desc.fHeight = DEV_H; |
396 desc.fConfig = kSkia8888_GrPixelConfig; | 396 desc.fConfig = kSkia8888_GrPixelConfig; |
397 desc.fOrigin = origin; | 397 desc.fOrigin = origin; |
398 SkAutoTUnref<GrTexture> surfaceTexture( | 398 SkAutoTUnref<GrTexture> surfaceTexture( |
399 ctxInfo.fGrContext->textureProvider()->createTexture(desc, SkBudgete
d::kNo)); | 399 ctxInfo.fGrContext->textureProvider()->createTexture(desc, SkBudgete
d::kNo)); |
400 auto surface(SkSurface::MakeRenderTargetDirect(surfaceTexture->asRenderT
arget())); | 400 auto surface(SkSurface::MakeRenderTargetDirect(surfaceTexture->asRenderT
arget())); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 bmp.height(), dstConfig,
bmp.getPixels(), | 435 bmp.height(), dstConfig,
bmp.getPixels(), |
436 bmp.rowBytes(), flags); | 436 bmp.rowBytes(), flags); |
437 bmp.unlockPixels(); | 437 bmp.unlockPixels(); |
438 check_read(reporter, bmp, srcRect.fLeft, srcRect.fTop, | 438 check_read(reporter, bmp, srcRect.fLeft, srcRect.fTop, |
439 success, true); | 439 success, true); |
440 } | 440 } |
441 } | 441 } |
442 } | 442 } |
443 } | 443 } |
444 } | 444 } |
445 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) { | 445 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) { |
446 // On the GPU we will also try reading back from a non-renderable texture. | 446 // On the GPU we will also try reading back from a non-renderable texture. |
447 for (auto& origin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin})
{ | 447 for (auto& origin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin})
{ |
448 SkAutoTUnref<GrTexture> texture; | 448 SkAutoTUnref<GrTexture> texture; |
449 GrSurfaceDesc desc; | 449 GrSurfaceDesc desc; |
450 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 450 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
451 desc.fWidth = DEV_W; | 451 desc.fWidth = DEV_W; |
452 desc.fHeight = DEV_H; | 452 desc.fHeight = DEV_H; |
453 desc.fConfig = kSkia8888_GrPixelConfig; | 453 desc.fConfig = kSkia8888_GrPixelConfig; |
454 desc.fOrigin = origin; | 454 desc.fOrigin = origin; |
455 desc.fFlags = kNone_GrSurfaceFlags; | 455 desc.fFlags = kNone_GrSurfaceFlags; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 /* | 569 /* |
570 * Test two different ways to turn a subset of a bitmap into a texture | 570 * Test two different ways to turn a subset of a bitmap into a texture |
571 * - subset and then upload to a texture | 571 * - subset and then upload to a texture |
572 * - upload to a texture and then subset | 572 * - upload to a texture and then subset |
573 * | 573 * |
574 * These two techniques result in the same pixels (ala readPixels) | 574 * These two techniques result in the same pixels (ala readPixels) |
575 * but when we draw them (rotated+scaled) we don't always get the same results. | 575 * but when we draw them (rotated+scaled) we don't always get the same results. |
576 * | 576 * |
577 * https://bug.skia.org/4351 | 577 * https://bug.skia.org/4351 |
578 */ | 578 */ |
579 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Subset_Gpu, reporter, ctxInfo) { | 579 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadPixels_Subset_Gpu, reporter, ctxInfo)
{ |
580 SkBitmap bitmap; | 580 SkBitmap bitmap; |
581 make_ringed_bitmap(&bitmap, 6, 6); | 581 make_ringed_bitmap(&bitmap, 6, 6); |
582 const SkIRect subset = SkIRect::MakeLTRB(2, 2, 4, 4); | 582 const SkIRect subset = SkIRect::MakeLTRB(2, 2, 4, 4); |
583 | 583 |
584 // make two textures... | 584 // make two textures... |
585 SkBitmap bm_subset, tx_subset; | 585 SkBitmap bm_subset, tx_subset; |
586 | 586 |
587 // ... one from a texture-subset | 587 // ... one from a texture-subset |
588 SkAutoTUnref<GrTexture> fullTx(GrRefCachedBitmapTexture(ctxInfo.fGrContext,
bitmap, | 588 SkAutoTUnref<GrTexture> fullTx(GrRefCachedBitmapTexture(ctxInfo.fGrContext,
bitmap, |
589 GrTextureParams::Cla
mpNoFilter())); | 589 GrTextureParams::Cla
mpNoFilter())); |
(...skipping 27 matching lines...) Expand all Loading... |
617 SkAutoTUnref<SkData> dataB(draw_into_surface(surfB.get(), tx_subset, qua
lity)); | 617 SkAutoTUnref<SkData> dataB(draw_into_surface(surfB.get(), tx_subset, qua
lity)); |
618 | 618 |
619 REPORTER_ASSERT(reporter, dataA->equals(dataB)); | 619 REPORTER_ASSERT(reporter, dataA->equals(dataB)); |
620 if (false) { | 620 if (false) { |
621 dump_to_file("test_image_A.png", dataA); | 621 dump_to_file("test_image_A.png", dataA); |
622 dump_to_file("test_image_B.png", dataB); | 622 dump_to_file("test_image_B.png", dataB); |
623 } | 623 } |
624 } | 624 } |
625 } | 625 } |
626 #endif | 626 #endif |
OLD | NEW |