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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 1885623002: Make more unit tests run on Vulkan (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 659
660 (*test)(&proxy, reporter, context); 660 (*test)(&proxy, reporter, context);
661 } 661 }
662 #endif 662 #endif
663 663
664 DEF_TEST(ImageFilterNegativeBlurSigma, reporter) { 664 DEF_TEST(ImageFilterNegativeBlurSigma, reporter) {
665 run_raster_test(reporter, 100, test_negative_blur_sigma); 665 run_raster_test(reporter, 100, test_negative_blur_sigma);
666 } 666 }
667 667
668 #if SK_SUPPORT_GPU 668 #if SK_SUPPORT_GPU
669 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageFilterNegativeBlurSigma_Gpu, reporter , ctxInfo) { 669 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterNegativeBlurSigma_Gpu, reporter, c txInfo) {
670 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_negative_blur_sigma); 670 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_negative_blur_sigma);
671 } 671 }
672 #endif 672 #endif
673 673
674 static void test_zero_blur_sigma(SkImageFilter::Proxy* proxy, 674 static void test_zero_blur_sigma(SkImageFilter::Proxy* proxy,
675 skiatest::Reporter* reporter, 675 skiatest::Reporter* reporter,
676 GrContext* context) { 676 GrContext* context) {
677 // Check that SkBlurImageFilter with a zero sigma and a non-zero srcOffset w orks correctly. 677 // Check that SkBlurImageFilter with a zero sigma and a non-zero srcOffset w orks correctly.
678 SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(5, 0, 5, 10) )); 678 SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(5, 0, 5, 10) ));
679 sk_sp<SkImageFilter> input(SkOffsetImageFilter::Make(0, 0, nullptr, &cropRec t)); 679 sk_sp<SkImageFilter> input(SkOffsetImageFilter::Make(0, 0, nullptr, &cropRec t));
(...skipping 25 matching lines...) Expand all
705 } 705 }
706 } 706 }
707 } 707 }
708 } 708 }
709 709
710 DEF_TEST(ImageFilterZeroBlurSigma, reporter) { 710 DEF_TEST(ImageFilterZeroBlurSigma, reporter) {
711 run_raster_test(reporter, 100, test_zero_blur_sigma); 711 run_raster_test(reporter, 100, test_zero_blur_sigma);
712 } 712 }
713 713
714 #if SK_SUPPORT_GPU 714 #if SK_SUPPORT_GPU
715 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageFilterZeroBlurSigma_Gpu, reporter, ct xInfo) { 715 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterZeroBlurSigma_Gpu, reporter, ctxIn fo) {
716 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_zero_blur_sigma); 716 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_zero_blur_sigma);
717 } 717 }
718 #endif 718 #endif
719 719
720 720
721 // Tests that, even when an upstream filter has returned null (due to failure or clipping), a 721 // Tests that, even when an upstream filter has returned null (due to failure or clipping), a
722 // downstream filter that affects transparent black still does so even with a nu llptr input. 722 // downstream filter that affects transparent black still does so even with a nu llptr input.
723 static void test_fail_affects_transparent_black(SkImageFilter::Proxy* proxy, 723 static void test_fail_affects_transparent_black(SkImageFilter::Proxy* proxy,
724 skiatest::Reporter* reporter, 724 skiatest::Reporter* reporter,
725 GrContext* context) { 725 GrContext* context) {
(...skipping 13 matching lines...) Expand all
739 SkAutoLockPixels lock(resultBM); 739 SkAutoLockPixels lock(resultBM);
740 REPORTER_ASSERT(reporter, *resultBM.getAddr32(0, 0) == SK_ColorGREEN); 740 REPORTER_ASSERT(reporter, *resultBM.getAddr32(0, 0) == SK_ColorGREEN);
741 } 741 }
742 } 742 }
743 743
744 DEF_TEST(ImageFilterFailAffectsTransparentBlack, reporter) { 744 DEF_TEST(ImageFilterFailAffectsTransparentBlack, reporter) {
745 run_raster_test(reporter, 100, test_fail_affects_transparent_black); 745 run_raster_test(reporter, 100, test_fail_affects_transparent_black);
746 } 746 }
747 747
748 #if SK_SUPPORT_GPU 748 #if SK_SUPPORT_GPU
749 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageFilterFailAffectsTransparentBlack_Gpu , reporter, ctxInfo) { 749 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterFailAffectsTransparentBlack_Gpu, r eporter, ctxInfo) {
750 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_fail_affects_transparen t_black); 750 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_fail_affects_transparen t_black);
751 } 751 }
752 #endif 752 #endif
753 753
754 DEF_TEST(ImageFilterDrawTiled, reporter) { 754 DEF_TEST(ImageFilterDrawTiled, reporter) {
755 // Check that all filters when drawn tiled (with subsequent clip rects) exac tly 755 // Check that all filters when drawn tiled (with subsequent clip rects) exac tly
756 // match the same filters drawn with a single full-canvas bitmap draw. 756 // match the same filters drawn with a single full-canvas bitmap draw.
757 // Tests pass by not asserting. 757 // Tests pass by not asserting.
758 758
759 FilterList filters(nullptr); 759 FilterList filters(nullptr);
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 canvas.saveLayer(&bounds, &filterPaint); 1091 canvas.saveLayer(&bounds, &filterPaint);
1092 canvas.drawRect(rect, rectPaint); 1092 canvas.drawRect(rect, rectPaint);
1093 canvas.restore(); 1093 canvas.restore();
1094 } 1094 }
1095 1095
1096 DEF_TEST(ImageFilterCropRect, reporter) { 1096 DEF_TEST(ImageFilterCropRect, reporter) {
1097 run_raster_test(reporter, 100, test_crop_rects); 1097 run_raster_test(reporter, 100, test_crop_rects);
1098 } 1098 }
1099 1099
1100 #if SK_SUPPORT_GPU 1100 #if SK_SUPPORT_GPU
1101 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageFilterCropRect_Gpu, reporter, ctxInfo ) { 1101 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCropRect_Gpu, reporter, ctxInfo) {
1102 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_crop_rects); 1102 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_crop_rects);
1103 } 1103 }
1104 #endif 1104 #endif
1105 1105
1106 DEF_TEST(ImageFilterMatrix, reporter) { 1106 DEF_TEST(ImageFilterMatrix, reporter) {
1107 SkBitmap temp; 1107 SkBitmap temp;
1108 temp.allocN32Pixels(100, 100); 1108 temp.allocN32Pixels(100, 100);
1109 SkCanvas canvas(temp); 1109 SkCanvas canvas(temp);
1110 canvas.scale(SkIntToScalar(2), SkIntToScalar(2)); 1110 canvas.scale(SkIntToScalar(2), SkIntToScalar(2));
1111 1111
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 1214
1215 sk_sp<SkSpecialImage> resultImage(imageFilter->filterImage(srcImg.get(), ctx , &offset)); 1215 sk_sp<SkSpecialImage> resultImage(imageFilter->filterImage(srcImg.get(), ctx , &offset));
1216 REPORTER_ASSERT(reporter, !resultImage); 1216 REPORTER_ASSERT(reporter, !resultImage);
1217 } 1217 }
1218 1218
1219 DEF_TEST(ImageFilterClippedPictureImageFilter, reporter) { 1219 DEF_TEST(ImageFilterClippedPictureImageFilter, reporter) {
1220 run_raster_test(reporter, 2, test_clipped_picture_imagefilter); 1220 run_raster_test(reporter, 2, test_clipped_picture_imagefilter);
1221 } 1221 }
1222 1222
1223 #if SK_SUPPORT_GPU 1223 #if SK_SUPPORT_GPU
1224 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageFilterClippedPictureImageFilter_Gpu, reporter, ctxInfo) { 1224 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterClippedPictureImageFilter_Gpu, rep orter, ctxInfo) {
1225 run_gpu_test(reporter, ctxInfo.fGrContext, 2, test_clipped_picture_imagefilt er); 1225 run_gpu_test(reporter, ctxInfo.fGrContext, 2, test_clipped_picture_imagefilt er);
1226 } 1226 }
1227 #endif 1227 #endif
1228 1228
1229 DEF_TEST(ImageFilterEmptySaveLayer, reporter) { 1229 DEF_TEST(ImageFilterEmptySaveLayer, reporter) {
1230 // Even when there's an empty saveLayer()/restore(), ensure that an image 1230 // Even when there's an empty saveLayer()/restore(), ensure that an image
1231 // filter or color filter which affects transparent black still draws. 1231 // filter or color filter which affects transparent black still draws.
1232 1232
1233 SkBitmap bitmap; 1233 SkBitmap bitmap;
1234 bitmap.allocN32Pixels(10, 10); 1234 bitmap.allocN32Pixels(10, 10);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 sk_sp<SkSpecialImage> resultImg(composedFilter->filterImage(srcImg.get(), ct x, &offset)); 1473 sk_sp<SkSpecialImage> resultImg(composedFilter->filterImage(srcImg.get(), ct x, &offset));
1474 REPORTER_ASSERT(reporter, resultImg); 1474 REPORTER_ASSERT(reporter, resultImg);
1475 REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0); 1475 REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0);
1476 } 1476 }
1477 1477
1478 DEF_TEST(ComposedImageFilterOffset, reporter) { 1478 DEF_TEST(ComposedImageFilterOffset, reporter) {
1479 run_raster_test(reporter, 100, test_composed_imagefilter_offset); 1479 run_raster_test(reporter, 100, test_composed_imagefilter_offset);
1480 } 1480 }
1481 1481
1482 #if SK_SUPPORT_GPU 1482 #if SK_SUPPORT_GPU
1483 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ComposedImageFilterOffset_Gpu, reporter, c txInfo) { 1483 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ComposedImageFilterOffset_Gpu, reporter, ctxI nfo) {
1484 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_composed_imagefilter_of fset); 1484 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_composed_imagefilter_of fset);
1485 } 1485 }
1486 #endif 1486 #endif
1487 1487
1488 static void test_composed_imagefilter_bounds(SkImageFilter::Proxy* proxy, 1488 static void test_composed_imagefilter_bounds(SkImageFilter::Proxy* proxy,
1489 skiatest::Reporter* reporter, 1489 skiatest::Reporter* reporter,
1490 GrContext* context) { 1490 GrContext* context) {
1491 // The bounds passed to the inner filter must be filtered by the outer 1491 // The bounds passed to the inner filter must be filtered by the outer
1492 // filter, so that the inner filter produces the pixels that the outer 1492 // filter, so that the inner filter produces the pixels that the outer
1493 // filter requires as input. This matters if the outer filter moves pixels. 1493 // filter requires as input. This matters if the outer filter moves pixels.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 REPORTER_ASSERT(reporter, offset.fY == 0); 1547 REPORTER_ASSERT(reporter, offset.fY == 0);
1548 REPORTER_ASSERT(reporter, resultImg->width() == 20); 1548 REPORTER_ASSERT(reporter, resultImg->width() == 20);
1549 REPORTER_ASSERT(reporter, resultImg->height() == 30); 1549 REPORTER_ASSERT(reporter, resultImg->height() == 30);
1550 } 1550 }
1551 1551
1552 DEF_TEST(ImageFilterPartialCropRect, reporter) { 1552 DEF_TEST(ImageFilterPartialCropRect, reporter) {
1553 run_raster_test(reporter, 100, test_partial_crop_rect); 1553 run_raster_test(reporter, 100, test_partial_crop_rect);
1554 } 1554 }
1555 1555
1556 #if SK_SUPPORT_GPU 1556 #if SK_SUPPORT_GPU
1557 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageFilterPartialCropRect_Gpu, reporter, ctxInfo) { 1557 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterPartialCropRect_Gpu, reporter, ctx Info) {
1558 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_partial_crop_rect); 1558 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_partial_crop_rect);
1559 } 1559 }
1560 #endif 1560 #endif
1561 1561
1562 DEF_TEST(ImageFilterCanComputeFastBounds, reporter) { 1562 DEF_TEST(ImageFilterCanComputeFastBounds, reporter) {
1563 1563
1564 { 1564 {
1565 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); 1565 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1);
1566 sk_sp<SkImageFilter> lighting(SkLightingImageFilter::MakePointLitDiffuse (location, 1566 sk_sp<SkImageFilter> lighting(SkLightingImageFilter::MakePointLitDiffuse (location,
1567 SK_ColorGREEN, 1567 SK_ColorGREEN,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 canvas->drawRect(SkRect::MakeIWH(largeW, largeH), paint); 1688 canvas->drawRect(SkRect::MakeIWH(largeW, largeH), paint);
1689 } 1689 }
1690 1690
1691 DEF_TEST(ImageFilterBlurLargeImage, reporter) { 1691 DEF_TEST(ImageFilterBlurLargeImage, reporter) {
1692 auto surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100))); 1692 auto surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100)));
1693 test_large_blur_input(reporter, surface->getCanvas()); 1693 test_large_blur_input(reporter, surface->getCanvas());
1694 } 1694 }
1695 1695
1696 #if SK_SUPPORT_GPU 1696 #if SK_SUPPORT_GPU
1697 1697
1698 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ImageFilterHugeBlur_Gpu, reporter, ctxInfo ) { 1698 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterHugeBlur_Gpu, reporter, ctxInfo) {
1699 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); 1699 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
1700 1700
1701 sk_sp<SkGpuDevice> device(SkGpuDevice::Create(ctxInfo.fGrContext, 1701 sk_sp<SkGpuDevice> device(SkGpuDevice::Create(ctxInfo.fGrContext,
1702 SkBudgeted::kNo, 1702 SkBudgeted::kNo,
1703 SkImageInfo::MakeN32Premul(100 , 100), 1703 SkImageInfo::MakeN32Premul(100 , 100),
1704 0, 1704 0,
1705 &props, 1705 &props,
1706 SkGpuDevice::kUninit_InitConte nts)); 1706 SkGpuDevice::kUninit_InitConte nts));
1707 SkCanvas canvas(device.get()); 1707 SkCanvas canvas(device.get());
1708 1708
(...skipping 13 matching lines...) Expand all
1722 1722
1723 test_xfermode_cropped_input(&canvas, reporter); 1723 test_xfermode_cropped_input(&canvas, reporter);
1724 } 1724 }
1725 1725
1726 DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(ImageFilterBlurLargeImage_Gpu, reporter, ctxInfo ) { 1726 DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(ImageFilterBlurLargeImage_Gpu, reporter, ctxInfo ) {
1727 auto surface(SkSurface::MakeRenderTarget(ctxInfo.fGrContext, SkBudgeted::kYe s, 1727 auto surface(SkSurface::MakeRenderTarget(ctxInfo.fGrContext, SkBudgeted::kYe s,
1728 SkImageInfo::MakeN32Premul(100, 100 ))); 1728 SkImageInfo::MakeN32Premul(100, 100 )));
1729 test_large_blur_input(reporter, surface->getCanvas()); 1729 test_large_blur_input(reporter, surface->getCanvas());
1730 } 1730 }
1731 #endif 1731 #endif
OLDNEW
« no previous file with comments | « tests/ImageFilterCacheTest.cpp ('k') | tests/ImageNewShaderTest.cpp » ('j') | tests/Test.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698