OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkBitmapDevice.h" | 9 #include "SkBitmapDevice.h" |
10 #include "SkBlurImageFilter.h" | 10 #include "SkBlurImageFilter.h" |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 573 |
574 sk_sp<SkSpecialImage> positiveResult2(negativeFilter->filterImage(imgSrc.get
(), | 574 sk_sp<SkSpecialImage> positiveResult2(negativeFilter->filterImage(imgSrc.get
(), |
575 negativeCT
X, | 575 negativeCT
X, |
576 &offset)); | 576 &offset)); |
577 REPORTER_ASSERT(reporter, positiveResult2); | 577 REPORTER_ASSERT(reporter, positiveResult2); |
578 | 578 |
579 | 579 |
580 SkBitmap positiveResultBM1, positiveResultBM2; | 580 SkBitmap positiveResultBM1, positiveResultBM2; |
581 SkBitmap negativeResultBM1, negativeResultBM2; | 581 SkBitmap negativeResultBM1, negativeResultBM2; |
582 | 582 |
583 TestingSpecialImageAccess::GetROPixels(positiveResult1.get(), &positiveResul
tBM1); | 583 REPORTER_ASSERT(reporter, positiveResult1->getROPixels(&positiveResultBM1)); |
584 TestingSpecialImageAccess::GetROPixels(positiveResult2.get(), &positiveResul
tBM2); | 584 REPORTER_ASSERT(reporter, positiveResult2->getROPixels(&positiveResultBM2)); |
585 TestingSpecialImageAccess::GetROPixels(negativeResult1.get(), &negativeResul
tBM1); | 585 REPORTER_ASSERT(reporter, negativeResult1->getROPixels(&negativeResultBM1)); |
586 TestingSpecialImageAccess::GetROPixels(negativeResult2.get(), &negativeResul
tBM2); | 586 REPORTER_ASSERT(reporter, negativeResult2->getROPixels(&negativeResultBM2)); |
587 | 587 |
588 SkAutoLockPixels lockP1(positiveResultBM1); | 588 SkAutoLockPixels lockP1(positiveResultBM1); |
589 SkAutoLockPixels lockP2(positiveResultBM2); | 589 SkAutoLockPixels lockP2(positiveResultBM2); |
590 SkAutoLockPixels lockN1(negativeResultBM1); | 590 SkAutoLockPixels lockN1(negativeResultBM1); |
591 SkAutoLockPixels lockN2(negativeResultBM2); | 591 SkAutoLockPixels lockN2(negativeResultBM2); |
592 for (int y = 0; y < height; y++) { | 592 for (int y = 0; y < height; y++) { |
593 int diffs = memcmp(positiveResultBM1.getAddr32(0, y), | 593 int diffs = memcmp(positiveResultBM1.getAddr32(0, y), |
594 negativeResultBM1.getAddr32(0, y), | 594 negativeResultBM1.getAddr32(0, y), |
595 positiveResultBM1.rowBytes()); | 595 positiveResultBM1.rowBytes()); |
596 REPORTER_ASSERT(reporter, !diffs); | 596 REPORTER_ASSERT(reporter, !diffs); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 SkIPoint offset; | 676 SkIPoint offset; |
677 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr); | 677 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr); |
678 | 678 |
679 sk_sp<SkSpecialImage> result(filter->filterImage(image.get(), ctx, &offset))
; | 679 sk_sp<SkSpecialImage> result(filter->filterImage(image.get(), ctx, &offset))
; |
680 REPORTER_ASSERT(reporter, offset.fX == 5 && offset.fY == 0); | 680 REPORTER_ASSERT(reporter, offset.fX == 5 && offset.fY == 0); |
681 REPORTER_ASSERT(reporter, result); | 681 REPORTER_ASSERT(reporter, result); |
682 REPORTER_ASSERT(reporter, result->width() == 5 && result->height() == 10); | 682 REPORTER_ASSERT(reporter, result->width() == 5 && result->height() == 10); |
683 | 683 |
684 SkBitmap resultBM; | 684 SkBitmap resultBM; |
685 | 685 |
686 TestingSpecialImageAccess::GetROPixels(result.get(), &resultBM); | 686 REPORTER_ASSERT(reporter, result->getROPixels(&resultBM)); |
687 | 687 |
688 SkAutoLockPixels lock(resultBM); | 688 SkAutoLockPixels lock(resultBM); |
689 for (int y = 0; y < resultBM.height(); y++) { | 689 for (int y = 0; y < resultBM.height(); y++) { |
690 for (int x = 0; x < resultBM.width(); x++) { | 690 for (int x = 0; x < resultBM.width(); x++) { |
691 bool diff = *resultBM.getAddr32(x, y) != SK_ColorGREEN; | 691 bool diff = *resultBM.getAddr32(x, y) != SK_ColorGREEN; |
692 REPORTER_ASSERT(reporter, !diff); | 692 REPORTER_ASSERT(reporter, !diff); |
693 if (diff) { | 693 if (diff) { |
694 break; | 694 break; |
695 } | 695 } |
696 } | 696 } |
(...skipping 21 matching lines...) Expand all Loading... |
718 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 1, 1), nul
lptr); | 718 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 1, 1), nul
lptr); |
719 sk_sp<SkColorFilter> green(SkColorFilter::MakeModeFilter(SK_ColorGREEN, SkXf
ermode::kSrc_Mode)); | 719 sk_sp<SkColorFilter> green(SkColorFilter::MakeModeFilter(SK_ColorGREEN, SkXf
ermode::kSrc_Mode)); |
720 SkASSERT(green->affectsTransparentBlack()); | 720 SkASSERT(green->affectsTransparentBlack()); |
721 sk_sp<SkImageFilter> greenFilter(SkColorFilterImageFilter::Make(std::move(gr
een), | 721 sk_sp<SkImageFilter> greenFilter(SkColorFilterImageFilter::Make(std::move(gr
een), |
722 std::move(fa
ilFilter))); | 722 std::move(fa
ilFilter))); |
723 SkIPoint offset; | 723 SkIPoint offset; |
724 sk_sp<SkSpecialImage> result(greenFilter->filterImage(source.get(), ctx, &of
fset)); | 724 sk_sp<SkSpecialImage> result(greenFilter->filterImage(source.get(), ctx, &of
fset)); |
725 REPORTER_ASSERT(reporter, nullptr != result.get()); | 725 REPORTER_ASSERT(reporter, nullptr != result.get()); |
726 if (result.get()) { | 726 if (result.get()) { |
727 SkBitmap resultBM; | 727 SkBitmap resultBM; |
728 TestingSpecialImageAccess::GetROPixels(result.get(), &resultBM); | 728 REPORTER_ASSERT(reporter, result->getROPixels(&resultBM)); |
729 SkAutoLockPixels lock(resultBM); | 729 SkAutoLockPixels lock(resultBM); |
730 REPORTER_ASSERT(reporter, *resultBM.getAddr32(0, 0) == SK_ColorGREEN); | 730 REPORTER_ASSERT(reporter, *resultBM.getAddr32(0, 0) == SK_ColorGREEN); |
731 } | 731 } |
732 } | 732 } |
733 | 733 |
734 DEF_TEST(ImageFilterFailAffectsTransparentBlack, reporter) { | 734 DEF_TEST(ImageFilterFailAffectsTransparentBlack, reporter) { |
735 run_raster_test(reporter, 100, test_fail_affects_transparent_black); | 735 run_raster_test(reporter, 100, test_fail_affects_transparent_black); |
736 } | 736 } |
737 | 737 |
738 #if SK_SUPPORT_GPU | 738 #if SK_SUPPORT_GPU |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 | 1497 |
1498 sk_sp<SkSpecialImage> sourceImage(create_empty_special_image(context, proxy,
100)); | 1498 sk_sp<SkSpecialImage> sourceImage(create_empty_special_image(context, proxy,
100)); |
1499 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr
); | 1499 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr
); |
1500 SkIPoint offset; | 1500 SkIPoint offset; |
1501 sk_sp<SkSpecialImage> result(composedFilter->filterImage(sourceImage.get(),
ctx, &offset)); | 1501 sk_sp<SkSpecialImage> result(composedFilter->filterImage(sourceImage.get(),
ctx, &offset)); |
1502 REPORTER_ASSERT(reporter, offset.isZero()); | 1502 REPORTER_ASSERT(reporter, offset.isZero()); |
1503 REPORTER_ASSERT(reporter, result); | 1503 REPORTER_ASSERT(reporter, result); |
1504 REPORTER_ASSERT(reporter, result->subset().size() == SkISize::Make(100, 100)
); | 1504 REPORTER_ASSERT(reporter, result->subset().size() == SkISize::Make(100, 100)
); |
1505 | 1505 |
1506 SkBitmap resultBM; | 1506 SkBitmap resultBM; |
1507 TestingSpecialImageAccess::GetROPixels(result.get(), &resultBM); | 1507 REPORTER_ASSERT(reporter, result->getROPixels(&resultBM)); |
1508 SkAutoLockPixels lock(resultBM); | 1508 SkAutoLockPixels lock(resultBM); |
1509 REPORTER_ASSERT(reporter, resultBM.getColor(50, 50) == SK_ColorGREEN); | 1509 REPORTER_ASSERT(reporter, resultBM.getColor(50, 50) == SK_ColorGREEN); |
1510 } | 1510 } |
1511 | 1511 |
1512 DEF_TEST(ComposedImageFilterBounds, reporter) { | 1512 DEF_TEST(ComposedImageFilterBounds, reporter) { |
1513 run_raster_test(reporter, 100, test_composed_imagefilter_bounds); | 1513 run_raster_test(reporter, 100, test_composed_imagefilter_bounds); |
1514 } | 1514 } |
1515 | 1515 |
1516 #if SK_SUPPORT_GPU | 1516 #if SK_SUPPORT_GPU |
1517 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ComposedImageFilterBounds_Gpu, reporter, c
txInfo) { | 1517 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ComposedImageFilterBounds_Gpu, reporter, c
txInfo) { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 | 1709 |
1710 test_xfermode_cropped_input(&canvas, reporter); | 1710 test_xfermode_cropped_input(&canvas, reporter); |
1711 } | 1711 } |
1712 | 1712 |
1713 DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(BlurLargeImage_Gpu, reporter, ctxInfo) { | 1713 DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(BlurLargeImage_Gpu, reporter, ctxInfo) { |
1714 auto surface(SkSurface::MakeRenderTarget(ctxInfo.fGrContext, SkBudgeted::kYe
s, | 1714 auto surface(SkSurface::MakeRenderTarget(ctxInfo.fGrContext, SkBudgeted::kYe
s, |
1715 SkImageInfo::MakeN32Premul(100, 100
))); | 1715 SkImageInfo::MakeN32Premul(100, 100
))); |
1716 test_large_blur_input(reporter, surface->getCanvas()); | 1716 test_large_blur_input(reporter, surface->getCanvas()); |
1717 } | 1717 } |
1718 #endif | 1718 #endif |
OLD | NEW |