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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 break; | 393 break; |
394 } | 394 } |
395 } | 395 } |
396 } | 396 } |
397 | 397 |
398 DEF_TEST(TestNegativeBlurSigma, reporter) { | 398 DEF_TEST(TestNegativeBlurSigma, reporter) { |
399 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); | 399 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
400 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 400 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
401 | 401 |
402 SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props)); | 402 SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props)); |
403 SkImageFilter::Proxy proxy(device); | 403 SkImageFilter::DeviceProxy proxy(device); |
404 | 404 |
405 test_negative_blur_sigma(&proxy, reporter); | 405 test_negative_blur_sigma(&proxy, reporter); |
406 } | 406 } |
407 | 407 |
408 DEF_TEST(ImageFilterDrawTiled, reporter) { | 408 DEF_TEST(ImageFilterDrawTiled, reporter) { |
409 // Check that all filters when drawn tiled (with subsequent clip rects) exac
tly | 409 // Check that all filters when drawn tiled (with subsequent clip rects) exac
tly |
410 // match the same filters drawn with a single full-canvas bitmap draw. | 410 // match the same filters drawn with a single full-canvas bitmap draw. |
411 // Tests pass by not asserting. | 411 // Tests pass by not asserting. |
412 | 412 |
413 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
SkXfermode::kSrcIn_Mode)); | 413 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
SkXfermode::kSrcIn_Mode)); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 canvas.saveLayer(&bounds, &filterPaint); | 766 canvas.saveLayer(&bounds, &filterPaint); |
767 canvas.drawRect(rect, rectPaint); | 767 canvas.drawRect(rect, rectPaint); |
768 canvas.restore(); | 768 canvas.restore(); |
769 } | 769 } |
770 | 770 |
771 DEF_TEST(ImageFilterCropRect, reporter) { | 771 DEF_TEST(ImageFilterCropRect, reporter) { |
772 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); | 772 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
773 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 773 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
774 | 774 |
775 SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props)); | 775 SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props)); |
776 SkImageFilter::Proxy proxy(device); | 776 SkImageFilter::DeviceProxy proxy(device); |
777 | 777 |
778 test_crop_rects(&proxy, reporter); | 778 test_crop_rects(&proxy, reporter); |
779 } | 779 } |
780 | 780 |
781 DEF_TEST(ImageFilterMatrix, reporter) { | 781 DEF_TEST(ImageFilterMatrix, reporter) { |
782 SkBitmap temp; | 782 SkBitmap temp; |
783 temp.allocN32Pixels(100, 100); | 783 temp.allocN32Pixels(100, 100); |
784 SkCanvas canvas(temp); | 784 SkCanvas canvas(temp); |
785 canvas.scale(SkIntToScalar(2), SkIntToScalar(2)); | 785 canvas.scale(SkIntToScalar(2), SkIntToScalar(2)); |
786 | 786 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 | 880 |
881 SkAutoTUnref<SkImageFilter> imageFilter(SkPictureImageFilter::Create(picture
.get())); | 881 SkAutoTUnref<SkImageFilter> imageFilter(SkPictureImageFilter::Create(picture
.get())); |
882 | 882 |
883 SkBitmap result; | 883 SkBitmap result; |
884 SkIPoint offset; | 884 SkIPoint offset; |
885 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), nul
lptr); | 885 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), nul
lptr); |
886 SkBitmap bitmap; | 886 SkBitmap bitmap; |
887 bitmap.allocN32Pixels(2, 2); | 887 bitmap.allocN32Pixels(2, 2); |
888 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 888 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
889 SkBitmapDevice device(bitmap, props); | 889 SkBitmapDevice device(bitmap, props); |
890 SkImageFilter::Proxy proxy(&device); | 890 SkImageFilter::DeviceProxy proxy(&device); |
891 REPORTER_ASSERT(reporter, !imageFilter->filterImage(&proxy, bitmap, ctx, &re
sult, &offset)); | 891 REPORTER_ASSERT(reporter, !imageFilter->filterImage(&proxy, bitmap, ctx, &re
sult, &offset)); |
892 } | 892 } |
893 | 893 |
894 DEF_TEST(ImageFilterEmptySaveLayer, reporter) { | 894 DEF_TEST(ImageFilterEmptySaveLayer, reporter) { |
895 // Even when there's an empty saveLayer()/restore(), ensure that an image | 895 // Even when there's an empty saveLayer()/restore(), ensure that an image |
896 // filter or color filter which affects transparent black still draws. | 896 // filter or color filter which affects transparent black still draws. |
897 | 897 |
898 SkBitmap bitmap; | 898 SkBitmap bitmap; |
899 bitmap.allocN32Pixels(10, 10); | 899 bitmap.allocN32Pixels(10, 10); |
900 SkCanvas canvas(bitmap); | 900 SkCanvas canvas(bitmap); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 SkCanvas canvas(temp); | 1119 SkCanvas canvas(temp); |
1120 test_xfermode_cropped_input(&canvas, reporter); | 1120 test_xfermode_cropped_input(&canvas, reporter); |
1121 } | 1121 } |
1122 | 1122 |
1123 DEF_TEST(ComposedImageFilterOffset, reporter) { | 1123 DEF_TEST(ComposedImageFilterOffset, reporter) { |
1124 SkBitmap bitmap; | 1124 SkBitmap bitmap; |
1125 bitmap.allocN32Pixels(100, 100); | 1125 bitmap.allocN32Pixels(100, 100); |
1126 bitmap.eraseARGB(0, 0, 0, 0); | 1126 bitmap.eraseARGB(0, 0, 0, 0); |
1127 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1127 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1128 SkBitmapDevice device(bitmap, props); | 1128 SkBitmapDevice device(bitmap, props); |
1129 SkImageFilter::Proxy proxy(&device); | 1129 SkImageFilter::DeviceProxy proxy(&device); |
1130 | 1130 |
1131 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20)); | 1131 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20)); |
1132 SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, n
ullptr, &cropRect)); | 1132 SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, n
ullptr, &cropRect)); |
1133 SkAutoTUnref<SkImageFilter> blurFilter(makeBlur()); | 1133 SkAutoTUnref<SkImageFilter> blurFilter(makeBlur()); |
1134 SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(blur
Filter, offsetFilter.get())); | 1134 SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(blur
Filter, offsetFilter.get())); |
1135 SkBitmap result; | 1135 SkBitmap result; |
1136 SkIPoint offset; | 1136 SkIPoint offset; |
1137 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr); | 1137 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr); |
1138 REPORTER_ASSERT(reporter, composedFilter->filterImage(&proxy, bitmap, ctx, &
result, &offset)); | 1138 REPORTER_ASSERT(reporter, composedFilter->filterImage(&proxy, bitmap, ctx, &
result, &offset)); |
1139 REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0); | 1139 REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0); |
1140 } | 1140 } |
1141 | 1141 |
1142 DEF_TEST(PartialCropRect, reporter) { | 1142 DEF_TEST(PartialCropRect, reporter) { |
1143 SkBitmap bitmap; | 1143 SkBitmap bitmap; |
1144 bitmap.allocN32Pixels(100, 100); | 1144 bitmap.allocN32Pixels(100, 100); |
1145 bitmap.eraseARGB(0, 0, 0, 0); | 1145 bitmap.eraseARGB(0, 0, 0, 0); |
1146 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1146 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1147 SkBitmapDevice device(bitmap, props); | 1147 SkBitmapDevice device(bitmap, props); |
1148 SkImageFilter::Proxy proxy(&device); | 1148 SkImageFilter::DeviceProxy proxy(&device); |
1149 | 1149 |
1150 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(100, 0, 20, 30), | 1150 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(100, 0, 20, 30), |
1151 SkImageFilter::CropRect::kHasWidth_CropEdge | SkImageFilter::CropRect::k
HasHeight_CropEdge); | 1151 SkImageFilter::CropRect::kHasWidth_CropEdge | SkImageFilter::CropRect::k
HasHeight_CropEdge); |
1152 SkAutoTUnref<SkImageFilter> filter(make_grayscale(nullptr, &cropRect)); | 1152 SkAutoTUnref<SkImageFilter> filter(make_grayscale(nullptr, &cropRect)); |
1153 SkBitmap result; | 1153 SkBitmap result; |
1154 SkIPoint offset; | 1154 SkIPoint offset; |
1155 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr); | 1155 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr); |
1156 REPORTER_ASSERT(reporter, filter->filterImage(&proxy, bitmap, ctx, &result,
&offset)); | 1156 REPORTER_ASSERT(reporter, filter->filterImage(&proxy, bitmap, ctx, &result,
&offset)); |
1157 REPORTER_ASSERT(reporter, offset.fX == 0); | 1157 REPORTER_ASSERT(reporter, offset.fX == 0); |
1158 REPORTER_ASSERT(reporter, offset.fY == 0); | 1158 REPORTER_ASSERT(reporter, offset.fY == 0); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 return; | 1245 return; |
1246 } | 1246 } |
1247 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1247 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1248 | 1248 |
1249 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1249 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
1250 SkSurface::kNo_Budgeted
, | 1250 SkSurface::kNo_Budgeted
, |
1251 SkImageInfo::MakeN32Pre
mul(100, 100), | 1251 SkImageInfo::MakeN32Pre
mul(100, 100), |
1252 0, | 1252 0, |
1253 &props, | 1253 &props, |
1254 SkGpuDevice::kUninit_In
itContents)); | 1254 SkGpuDevice::kUninit_In
itContents)); |
1255 SkImageFilter::Proxy proxy(device); | 1255 SkImageFilter::DeviceProxy proxy(device); |
1256 | 1256 |
1257 test_crop_rects(&proxy, reporter); | 1257 test_crop_rects(&proxy, reporter); |
1258 } | 1258 } |
1259 | 1259 |
1260 DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) { | 1260 DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) { |
1261 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 1261 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
1262 if (nullptr == context) { | 1262 if (nullptr == context) { |
1263 return; | 1263 return; |
1264 } | 1264 } |
1265 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1265 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 return; | 1299 return; |
1300 } | 1300 } |
1301 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1301 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1302 | 1302 |
1303 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1303 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
1304 SkSurface::kNo_Budgeted
, | 1304 SkSurface::kNo_Budgeted
, |
1305 SkImageInfo::MakeN32Pre
mul(1, 1), | 1305 SkImageInfo::MakeN32Pre
mul(1, 1), |
1306 0, | 1306 0, |
1307 &props, | 1307 &props, |
1308 SkGpuDevice::kUninit_In
itContents)); | 1308 SkGpuDevice::kUninit_In
itContents)); |
1309 SkImageFilter::Proxy proxy(device); | 1309 SkImageFilter::DeviceProxy proxy(device); |
1310 | 1310 |
1311 test_negative_blur_sigma(&proxy, reporter); | 1311 test_negative_blur_sigma(&proxy, reporter); |
1312 } | 1312 } |
1313 #endif | 1313 #endif |
OLD | NEW |