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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 #if SK_SUPPORT_GPU | 389 #if SK_SUPPORT_GPU |
390 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, context) { | 390 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, context) { |
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 context->textureProvider()->createTexture(desc, false)); | 399 context->textureProvider()->createTexture(desc, SkBudgeted::kNo)); |
400 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(surface
Texture->asRenderTarget())); | 400 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(surface
Texture->asRenderTarget())); |
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 // On the GPU we will also try reading back from a non-renderable texture. | 445 // On the GPU we will also try reading back from a non-renderable texture. |
446 for (auto& origin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin})
{ | 446 for (auto& origin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin})
{ |
447 SkAutoTUnref<GrTexture> texture; | 447 SkAutoTUnref<GrTexture> texture; |
448 GrSurfaceDesc desc; | 448 GrSurfaceDesc desc; |
449 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 449 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
450 desc.fWidth = DEV_W; | 450 desc.fWidth = DEV_W; |
451 desc.fHeight = DEV_H; | 451 desc.fHeight = DEV_H; |
452 desc.fConfig = kSkia8888_GrPixelConfig; | 452 desc.fConfig = kSkia8888_GrPixelConfig; |
453 desc.fOrigin = origin; | 453 desc.fOrigin = origin; |
454 desc.fFlags = kNone_GrSurfaceFlags; | 454 desc.fFlags = kNone_GrSurfaceFlags; |
455 texture.reset(context->textureProvider()->createTexture(desc, false)); | 455 texture.reset(context->textureProvider()->createTexture(desc, SkBudgeted
::kNo)); |
456 test_readpixels_texture(reporter, texture); | 456 test_readpixels_texture(reporter, texture); |
457 } | 457 } |
458 } | 458 } |
459 #endif | 459 #endif |
460 ///////////////////// | 460 ///////////////////// |
461 #if SK_SUPPORT_GPU | 461 #if SK_SUPPORT_GPU |
462 | 462 |
463 // make_ringed_bitmap was lifted from gm/bleed.cpp, as that GM was what showed t
he following | 463 // make_ringed_bitmap was lifted from gm/bleed.cpp, as that GM was what showed t
he following |
464 // bug when a change was made to SkImage_Raster.cpp. It is possible that other t
est bitmaps | 464 // bug when a change was made to SkImage_Raster.cpp. It is possible that other t
est bitmaps |
465 // would also tickle https://bug.skia.org/4351 but this one is know to do it, so
I've pasted the code | 465 // would also tickle https://bug.skia.org/4351 but this one is know to do it, so
I've pasted the code |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 bitmap.extractSubset(&tmp_subset, subset); | 596 bitmap.extractSubset(&tmp_subset, subset); |
597 SkAutoTUnref<GrTexture> subsetTx(GrRefCachedBitmapTexture(context, tmp_subse
t, | 597 SkAutoTUnref<GrTexture> subsetTx(GrRefCachedBitmapTexture(context, tmp_subse
t, |
598 GrTextureParams::C
lampNoFilter())); | 598 GrTextureParams::C
lampNoFilter())); |
599 GrWrapTextureInBitmap(subsetTx, tmp_subset.width(), tmp_subset.height(), tru
e, &bm_subset); | 599 GrWrapTextureInBitmap(subsetTx, tmp_subset.width(), tmp_subset.height(), tru
e, &bm_subset); |
600 | 600 |
601 // did we get the same subset? | 601 // did we get the same subset? |
602 compare_textures(reporter, bm_subset.getTexture(), tx_subset.getTexture()); | 602 compare_textures(reporter, bm_subset.getTexture(), tx_subset.getTexture()); |
603 | 603 |
604 // do they draw the same? | 604 // do they draw the same? |
605 const SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128); | 605 const SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128); |
606 SkAutoTUnref<SkSurface> surfA(SkSurface::NewRenderTarget(context, SkSurface:
:kNo_Budgeted, info, 0)); | 606 SkAutoTUnref<SkSurface> surfA(SkSurface::NewRenderTarget(context, SkBudgeted
::kNo, info, 0)); |
607 SkAutoTUnref<SkSurface> surfB(SkSurface::NewRenderTarget(context, SkSurface:
:kNo_Budgeted, info, 0)); | 607 SkAutoTUnref<SkSurface> surfB(SkSurface::NewRenderTarget(context, SkBudgeted
::kNo, info, 0)); |
608 | 608 |
609 if (false) { | 609 if (false) { |
610 // | 610 // |
611 // BUG: depending on the driver, if we calls this with various quality
settings, it | 611 // BUG: depending on the driver, if we calls this with various quality
settings, it |
612 // may fail. | 612 // may fail. |
613 // | 613 // |
614 SkFilterQuality quality = kLow_SkFilterQuality; | 614 SkFilterQuality quality = kLow_SkFilterQuality; |
615 | 615 |
616 SkAutoTUnref<SkData> dataA(draw_into_surface(surfA, bm_subset, quality))
; | 616 SkAutoTUnref<SkData> dataA(draw_into_surface(surfA, bm_subset, quality))
; |
617 SkAutoTUnref<SkData> dataB(draw_into_surface(surfB, tx_subset, quality))
; | 617 SkAutoTUnref<SkData> dataB(draw_into_surface(surfB, tx_subset, quality))
; |
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 |