Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Side by Side Diff: tests/ReadPixelsTest.cpp

Issue 2102633003: Fix Vulkan readPixels (Closed) Base URL: https://skia.googlesource.com/skia.git@unitTests2
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/vk/GrVkGpu.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 int devy = by + srcRect.fTop; 193 int devy = by + srcRect.fTop;
194 194
195 const uint32_t* pixel = bitmap.getAddr32(bx, by); 195 const uint32_t* pixel = bitmap.getAddr32(bx, by);
196 196
197 if (clippedSrcRect.contains(devx, devy)) { 197 if (clippedSrcRect.contains(devx, devy)) {
198 if (checkCanvasPixels) { 198 if (checkCanvasPixels) {
199 SkPMColor canvasPixel = get_src_color(devx, devy); 199 SkPMColor canvasPixel = get_src_color(devx, devy);
200 bool didPremul; 200 bool didPremul;
201 SkPMColor pmPixel = convert_to_pmcolor(ct, at, pixel, &didPr emul); 201 SkPMColor pmPixel = convert_to_pmcolor(ct, at, pixel, &didPr emul);
202 if (!check_read_pixel(pmPixel, canvasPixel, didPremul)) { 202 if (!check_read_pixel(pmPixel, canvasPixel, didPremul)) {
203 ERRORF(reporter, "Expected readback pixel value 0x%08x, got 0x%08x. " 203 ERRORF(reporter, "Expected readback pixel (%d, %d) value 0x%08x, got 0x%08x. "
204 "Readback was unpremul: %d", canvasPixel, pmPixel , didPremul); 204 "Readback was unpremul: %d", bx, by, canvasPixel, pmPixel, didPremul);
205 return false; 205 return false;
206 } 206 }
207 } 207 }
208 } else if (checkBitmapPixels) { 208 } else if (checkBitmapPixels) {
209 uint32_t origDstPixel = get_dst_bmp_init_color(bx, by, bw); 209 uint32_t origDstPixel = get_dst_bmp_init_color(bx, by, bw);
210 if (origDstPixel != *pixel) { 210 if (origDstPixel != *pixel) {
211 ERRORF(reporter, "Expected clipped out area of readback to b e unchanged. " 211 ERRORF(reporter, "Expected clipped out area of readback to b e unchanged. "
212 "Expected 0x%08x, got 0x%08x", origDstPixel, *pixel); 212 "Expected 0x%08x, got 0x%08x", origDstPixel, *pixel);
213 return false; 213 return false;
214 } 214 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_GL_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, ctxInfo) { 390 DEF_GPUTEST_FOR_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.grContext()->textureProvider()->createTexture(desc, SkBudget ed::kNo)); 399 ctxInfo.grContext()->textureProvider()->createTexture(desc, SkBudget ed::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
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_GL_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) { 445 DEF_GPUTEST_FOR_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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 /* 570 /*
571 * Test two different ways to turn a subset of a bitmap into a texture 571 * Test two different ways to turn a subset of a bitmap into a texture
572 * - subset and then upload to a texture 572 * - subset and then upload to a texture
573 * - upload to a texture and then subset 573 * - upload to a texture and then subset
574 * 574 *
575 * These two techniques result in the same pixels (ala readPixels) 575 * These two techniques result in the same pixels (ala readPixels)
576 * but when we draw them (rotated+scaled) we don't always get the same results. 576 * but when we draw them (rotated+scaled) we don't always get the same results.
577 * 577 *
578 * https://bug.skia.org/4351 578 * https://bug.skia.org/4351
579 */ 579 */
580 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadPixels_Subset_Gpu, reporter, ctxInfo) { 580 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Subset_Gpu, reporter, ctxInfo) {
581 SkBitmap bitmap; 581 SkBitmap bitmap;
582 make_ringed_bitmap(&bitmap, 6, 6); 582 make_ringed_bitmap(&bitmap, 6, 6);
583 const SkIRect subset = SkIRect::MakeLTRB(2, 2, 4, 4); 583 const SkIRect subset = SkIRect::MakeLTRB(2, 2, 4, 4);
584 584
585 // make two textures... 585 // make two textures...
586 SkBitmap bm_subset, tx_subset; 586 SkBitmap bm_subset, tx_subset;
587 587
588 // ... one from a texture-subset 588 // ... one from a texture-subset
589 SkAutoTUnref<GrTexture> fullTx(GrRefCachedBitmapTexture(ctxInfo.grContext(), bitmap, 589 SkAutoTUnref<GrTexture> fullTx(GrRefCachedBitmapTexture(ctxInfo.grContext(), bitmap,
590 GrTextureParams::Cla mpNoFilter(), 590 GrTextureParams::Cla mpNoFilter(),
(...skipping 29 matching lines...) Expand all
620 SkAutoTUnref<SkData> dataB(draw_into_surface(surfB.get(), tx_subset, qua lity)); 620 SkAutoTUnref<SkData> dataB(draw_into_surface(surfB.get(), tx_subset, qua lity));
621 621
622 REPORTER_ASSERT(reporter, dataA->equals(dataB)); 622 REPORTER_ASSERT(reporter, dataA->equals(dataB));
623 if (false) { 623 if (false) {
624 dump_to_file("test_image_A.png", dataA); 624 dump_to_file("test_image_A.png", dataA);
625 dump_to_file("test_image_B.png", dataB); 625 dump_to_file("test_image_B.png", dataB);
626 } 626 }
627 } 627 }
628 } 628 }
629 #endif 629 #endif
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkGpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698