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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadPixels_Subset_Gpu, reporter, ctxInfo)
{ | 580 DEF_GPUTEST_FOR_GL_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(), |
| 591 SkSourceGammaTreatme
nt::kRespect)); |
591 SkBitmap tx_full; | 592 SkBitmap tx_full; |
592 GrWrapTextureInBitmap(fullTx, bitmap.width(), bitmap.height(), true, &tx_ful
l); | 593 GrWrapTextureInBitmap(fullTx, bitmap.width(), bitmap.height(), true, &tx_ful
l); |
593 tx_full.extractSubset(&tx_subset, subset); | 594 tx_full.extractSubset(&tx_subset, subset); |
594 | 595 |
595 // ... one from a bitmap-subset | 596 // ... one from a bitmap-subset |
596 SkBitmap tmp_subset; | 597 SkBitmap tmp_subset; |
597 bitmap.extractSubset(&tmp_subset, subset); | 598 bitmap.extractSubset(&tmp_subset, subset); |
598 SkAutoTUnref<GrTexture> subsetTx(GrRefCachedBitmapTexture(ctxInfo.grContext(
), tmp_subset, | 599 SkAutoTUnref<GrTexture> subsetTx(GrRefCachedBitmapTexture(ctxInfo.grContext(
), tmp_subset, |
599 GrTextureParams::C
lampNoFilter())); | 600 GrTextureParams::C
lampNoFilter(), |
| 601 SkSourceGammaTreat
ment::kRespect)); |
600 GrWrapTextureInBitmap(subsetTx, tmp_subset.width(), tmp_subset.height(), tru
e, &bm_subset); | 602 GrWrapTextureInBitmap(subsetTx, tmp_subset.width(), tmp_subset.height(), tru
e, &bm_subset); |
601 | 603 |
602 // did we get the same subset? | 604 // did we get the same subset? |
603 compare_textures(reporter, bm_subset.getTexture(), tx_subset.getTexture()); | 605 compare_textures(reporter, bm_subset.getTexture(), tx_subset.getTexture()); |
604 | 606 |
605 // do they draw the same? | 607 // do they draw the same? |
606 const SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128); | 608 const SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128); |
607 auto surfA(SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kNo,
info)); | 609 auto surfA(SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kNo,
info)); |
608 auto surfB(SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kNo,
info)); | 610 auto surfB(SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kNo,
info)); |
609 | 611 |
610 if (false) { | 612 if (false) { |
611 // | 613 // |
612 // BUG: depending on the driver, if we calls this with various quality
settings, it | 614 // BUG: depending on the driver, if we calls this with various quality
settings, it |
613 // may fail. | 615 // may fail. |
614 // | 616 // |
615 SkFilterQuality quality = kLow_SkFilterQuality; | 617 SkFilterQuality quality = kLow_SkFilterQuality; |
616 | 618 |
617 SkAutoTUnref<SkData> dataA(draw_into_surface(surfA.get(), bm_subset, qua
lity)); | 619 SkAutoTUnref<SkData> dataA(draw_into_surface(surfA.get(), bm_subset, qua
lity)); |
618 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)); |
619 | 621 |
620 REPORTER_ASSERT(reporter, dataA->equals(dataB)); | 622 REPORTER_ASSERT(reporter, dataA->equals(dataB)); |
621 if (false) { | 623 if (false) { |
622 dump_to_file("test_image_A.png", dataA); | 624 dump_to_file("test_image_A.png", dataA); |
623 dump_to_file("test_image_B.png", dataB); | 625 dump_to_file("test_image_B.png", dataB); |
624 } | 626 } |
625 } | 627 } |
626 } | 628 } |
627 #endif | 629 #endif |
OLD | NEW |