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

Side by Side Diff: tests/ReadPixelsTest.cpp

Issue 1966013002: Turn ContextInfos returned by GrContextFactory into structs. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Address comment Created 4 years, 7 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 | « tests/ProxyTest.cpp ('k') | tests/ReadWriteAlphaTest.cpp » ('j') | 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_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.grContext()->textureProvider()->createTexture(desc, SkBudget ed::kNo));
400 auto surface(SkSurface::MakeRenderTargetDirect(surfaceTexture->asRenderT arget())); 400 auto surface(SkSurface::MakeRenderTargetDirect(surfaceTexture->asRenderT arget()));
401 desc.fFlags = kNone_GrSurfaceFlags; 401 desc.fFlags = kNone_GrSurfaceFlags;
402 test_readpixels(reporter, surface, kLast_BitmapInit); 402 test_readpixels(reporter, surface, kLast_BitmapInit);
403 } 403 }
404 } 404 }
405 #endif 405 #endif
406 406
407 #if SK_SUPPORT_GPU 407 #if SK_SUPPORT_GPU
408 static void test_readpixels_texture(skiatest::Reporter* reporter, GrTexture* tex ture) { 408 static void test_readpixels_texture(skiatest::Reporter* reporter, GrTexture* tex ture) {
409 fill_src_texture(texture); 409 fill_src_texture(texture);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
456 texture.reset(ctxInfo.fGrContext->textureProvider()->createTexture(desc, SkBudgeted::kNo)); 456 texture.reset(ctxInfo.grContext()->textureProvider()->createTexture(desc ,
457 SkBu dgeted::kNo));
457 test_readpixels_texture(reporter, texture); 458 test_readpixels_texture(reporter, texture);
458 } 459 }
459 } 460 }
460 #endif 461 #endif
461 ///////////////////// 462 /////////////////////
462 #if SK_SUPPORT_GPU 463 #if SK_SUPPORT_GPU
463 464
464 // make_ringed_bitmap was lifted from gm/bleed.cpp, as that GM was what showed t he following 465 // make_ringed_bitmap was lifted from gm/bleed.cpp, as that GM was what showed t he following
465 // bug when a change was made to SkImage_Raster.cpp. It is possible that other t est bitmaps 466 // bug when a change was made to SkImage_Raster.cpp. It is possible that other t est bitmaps
466 // would also tickle https://bug.skia.org/4351 but this one is know to do it, so I've pasted the code 467 // would also tickle https://bug.skia.org/4351 but this one is know to do it, so I've pasted the code
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 */ 579 */
579 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadPixels_Subset_Gpu, reporter, ctxInfo) { 580 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadPixels_Subset_Gpu, reporter, ctxInfo) {
580 SkBitmap bitmap; 581 SkBitmap bitmap;
581 make_ringed_bitmap(&bitmap, 6, 6); 582 make_ringed_bitmap(&bitmap, 6, 6);
582 const SkIRect subset = SkIRect::MakeLTRB(2, 2, 4, 4); 583 const SkIRect subset = SkIRect::MakeLTRB(2, 2, 4, 4);
583 584
584 // make two textures... 585 // make two textures...
585 SkBitmap bm_subset, tx_subset; 586 SkBitmap bm_subset, tx_subset;
586 587
587 // ... one from a texture-subset 588 // ... one from a texture-subset
588 SkAutoTUnref<GrTexture> fullTx(GrRefCachedBitmapTexture(ctxInfo.fGrContext, bitmap, 589 SkAutoTUnref<GrTexture> fullTx(GrRefCachedBitmapTexture(ctxInfo.grContext(), bitmap,
589 GrTextureParams::Cla mpNoFilter())); 590 GrTextureParams::Cla mpNoFilter()));
590 SkBitmap tx_full; 591 SkBitmap tx_full;
591 GrWrapTextureInBitmap(fullTx, bitmap.width(), bitmap.height(), true, &tx_ful l); 592 GrWrapTextureInBitmap(fullTx, bitmap.width(), bitmap.height(), true, &tx_ful l);
592 tx_full.extractSubset(&tx_subset, subset); 593 tx_full.extractSubset(&tx_subset, subset);
593 594
594 // ... one from a bitmap-subset 595 // ... one from a bitmap-subset
595 SkBitmap tmp_subset; 596 SkBitmap tmp_subset;
596 bitmap.extractSubset(&tmp_subset, subset); 597 bitmap.extractSubset(&tmp_subset, subset);
597 SkAutoTUnref<GrTexture> subsetTx(GrRefCachedBitmapTexture(ctxInfo.fGrContext , tmp_subset, 598 SkAutoTUnref<GrTexture> subsetTx(GrRefCachedBitmapTexture(ctxInfo.grContext( ), tmp_subset,
598 GrTextureParams::C lampNoFilter())); 599 GrTextureParams::C lampNoFilter()));
599 GrWrapTextureInBitmap(subsetTx, tmp_subset.width(), tmp_subset.height(), tru e, &bm_subset); 600 GrWrapTextureInBitmap(subsetTx, tmp_subset.width(), tmp_subset.height(), tru e, &bm_subset);
600 601
601 // did we get the same subset? 602 // did we get the same subset?
602 compare_textures(reporter, bm_subset.getTexture(), tx_subset.getTexture()); 603 compare_textures(reporter, bm_subset.getTexture(), tx_subset.getTexture());
603 604
604 // do they draw the same? 605 // do they draw the same?
605 const SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128); 606 const SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128);
606 auto surfA(SkSurface::MakeRenderTarget(ctxInfo.fGrContext, SkBudgeted::kNo, info)); 607 auto surfA(SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kNo, info));
607 auto surfB(SkSurface::MakeRenderTarget(ctxInfo.fGrContext, SkBudgeted::kNo, info)); 608 auto surfB(SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kNo, info));
608 609
609 if (false) { 610 if (false) {
610 // 611 //
611 // BUG: depending on the driver, if we calls this with various quality settings, it 612 // BUG: depending on the driver, if we calls this with various quality settings, it
612 // may fail. 613 // may fail.
613 // 614 //
614 SkFilterQuality quality = kLow_SkFilterQuality; 615 SkFilterQuality quality = kLow_SkFilterQuality;
615 616
616 SkAutoTUnref<SkData> dataA(draw_into_surface(surfA.get(), bm_subset, qua lity)); 617 SkAutoTUnref<SkData> dataA(draw_into_surface(surfA.get(), bm_subset, qua lity));
617 SkAutoTUnref<SkData> dataB(draw_into_surface(surfB.get(), tx_subset, qua lity)); 618 SkAutoTUnref<SkData> dataB(draw_into_surface(surfB.get(), tx_subset, qua lity));
618 619
619 REPORTER_ASSERT(reporter, dataA->equals(dataB)); 620 REPORTER_ASSERT(reporter, dataA->equals(dataB));
620 if (false) { 621 if (false) {
621 dump_to_file("test_image_A.png", dataA); 622 dump_to_file("test_image_A.png", dataA);
622 dump_to_file("test_image_B.png", dataB); 623 dump_to_file("test_image_B.png", dataB);
623 } 624 }
624 } 625 }
625 } 626 }
626 #endif 627 #endif
OLDNEW
« no previous file with comments | « tests/ProxyTest.cpp ('k') | tests/ReadWriteAlphaTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698