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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 1812023002: Switch SkSpecialImage & SkSpecialSurface classes over to smart pointers (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix build Created 4 years, 9 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
« no previous file with comments | « tests/ImageFilterCacheTest.cpp ('k') | tests/SpecialImageTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix)); 151 SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix));
152 return SkColorFilterImageFilter::Create(filter, input, cropRect); 152 return SkColorFilterImageFilter::Create(filter, input, cropRect);
153 } 153 }
154 154
155 static SkImageFilter* make_blue(SkImageFilter* input, const SkImageFilter::CropR ect* cropRect) { 155 static SkImageFilter* make_blue(SkImageFilter* input, const SkImageFilter::CropR ect* cropRect) {
156 SkAutoTUnref<SkColorFilter> filter(SkColorFilter::CreateModeFilter(SK_ColorB LUE, 156 SkAutoTUnref<SkColorFilter> filter(SkColorFilter::CreateModeFilter(SK_ColorB LUE,
157 SkXfermod e::kSrcIn_Mode)); 157 SkXfermod e::kSrcIn_Mode));
158 return SkColorFilterImageFilter::Create(filter, input, cropRect); 158 return SkColorFilterImageFilter::Create(filter, input, cropRect);
159 } 159 }
160 160
161 static SkSpecialSurface* create_empty_special_surface(GrContext* context, 161 static sk_sp<SkSpecialSurface> create_empty_special_surface(GrContext* context,
162 SkImageFilter::Proxy* prox y, 162 SkImageFilter::Proxy * proxy,
163 int widthHeight) { 163 int widthHeight) {
164 if (context) { 164 if (context) {
165 GrSurfaceDesc desc; 165 GrSurfaceDesc desc;
166 desc.fConfig = kSkia8888_GrPixelConfig; 166 desc.fConfig = kSkia8888_GrPixelConfig;
167 desc.fFlags = kRenderTarget_GrSurfaceFlag; 167 desc.fFlags = kRenderTarget_GrSurfaceFlag;
168 desc.fWidth = widthHeight; 168 desc.fWidth = widthHeight;
169 desc.fHeight = widthHeight; 169 desc.fHeight = widthHeight;
170 return SkSpecialSurface::NewRenderTarget(proxy, context, desc); 170 return SkSpecialSurface::MakeRenderTarget(proxy, context, desc);
171 } else { 171 } else {
172 const SkImageInfo info = SkImageInfo::MakeN32(widthHeight, widthHeight, 172 const SkImageInfo info = SkImageInfo::MakeN32(widthHeight, widthHeight,
173 kOpaque_SkAlphaType); 173 kOpaque_SkAlphaType);
174 return SkSpecialSurface::NewRaster(proxy, info); 174 return SkSpecialSurface::MakeRaster(proxy, info);
175 } 175 }
176 } 176 }
177 177
178 static SkSpecialImage* create_empty_special_image(GrContext* context, 178 static sk_sp<SkSpecialImage> create_empty_special_image(GrContext* context,
179 SkImageFilter::Proxy* proxy, 179 SkImageFilter::Proxy* pr oxy,
180 int widthHeight) { 180 int widthHeight) {
181 SkAutoTUnref<SkSpecialSurface> surf(create_empty_special_surface(context, pr oxy, widthHeight)); 181 sk_sp<SkSpecialSurface> surf(create_empty_special_surface(context, proxy, wi dthHeight));
182 182
183 SkASSERT(surf); 183 SkASSERT(surf);
184 184
185 SkCanvas* canvas = surf->getCanvas(); 185 SkCanvas* canvas = surf->getCanvas();
186 SkASSERT(canvas); 186 SkASSERT(canvas);
187 187
188 canvas->clear(0x0); 188 canvas->clear(0x0);
189 189
190 return surf->newImageSnapshot(); 190 return surf->makeImageSnapshot();
191 } 191 }
192 192
193 193
194 DEF_TEST(ImageFilter, reporter) { 194 DEF_TEST(ImageFilter, reporter) {
195 { 195 {
196 // Check that two non-clipping color-matrice-filters concatenate into a single filter. 196 // Check that two non-clipping color-matrice-filters concatenate into a single filter.
197 SkAutoTUnref<SkImageFilter> halfBrightness(make_scale(0.5f)); 197 SkAutoTUnref<SkImageFilter> halfBrightness(make_scale(0.5f));
198 SkAutoTUnref<SkImageFilter> quarterBrightness(make_scale(0.5f, halfBrigh tness)); 198 SkAutoTUnref<SkImageFilter> quarterBrightness(make_scale(0.5f, halfBrigh tness));
199 REPORTER_ASSERT(reporter, nullptr == quarterBrightness->getInput(0)); 199 REPORTER_ASSERT(reporter, nullptr == quarterBrightness->getInput(0));
200 SkColorFilter* cf; 200 SkColorFilter* cf;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 306 }
307 } 307 }
308 } 308 }
309 309
310 static void test_crop_rects(SkImageFilter::Proxy* proxy, 310 static void test_crop_rects(SkImageFilter::Proxy* proxy,
311 skiatest::Reporter* reporter, 311 skiatest::Reporter* reporter,
312 GrContext* context) { 312 GrContext* context) {
313 // Check that all filters offset to their absolute crop rect, 313 // Check that all filters offset to their absolute crop rect,
314 // unaffected by the input crop rect. 314 // unaffected by the input crop rect.
315 // Tests pass by not asserting. 315 // Tests pass by not asserting.
316 SkAutoTUnref<SkSpecialImage> srcImg(create_empty_special_image(context, prox y, 100)); 316 sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100) );
317 SkASSERT(srcImg); 317 SkASSERT(srcImg);
318 318
319 SkImageFilter::CropRect inputCropRect(SkRect::MakeXYWH(8, 13, 80, 80)); 319 SkImageFilter::CropRect inputCropRect(SkRect::MakeXYWH(8, 13, 80, 80));
320 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 30, 60, 60)); 320 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 30, 60, 60));
321 SkAutoTUnref<SkImageFilter> input(make_grayscale(nullptr, &inputCropRect)); 321 SkAutoTUnref<SkImageFilter> input(make_grayscale(nullptr, &inputCropRect));
322 322
323 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED, SkXfermode::kSrcIn_Mode)); 323 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED, SkXfermode::kSrcIn_Mode));
324 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); 324 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1);
325 SkScalar kernel[9] = { 325 SkScalar kernel[9] = {
326 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), 326 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1),
(...skipping 23 matching lines...) Expand all
350 SkTileImageFilter::Create(inputCropRect.rect(), cropRect.rect(), input.g et()), 350 SkTileImageFilter::Create(inputCropRect.rect(), cropRect.rect(), input.g et()),
351 SkXfermodeImageFilter::Create(SkXfermode::Create(SkXfermode::kSrcOver_Mo de), input.get(), input.get(), &cropRect), 351 SkXfermodeImageFilter::Create(SkXfermode::Create(SkXfermode::kSrcOver_Mo de), input.get(), input.get(), &cropRect),
352 }; 352 };
353 353
354 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { 354 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
355 SkImageFilter* filter = filters[i]; 355 SkImageFilter* filter = filters[i];
356 SkIPoint offset; 356 SkIPoint offset;
357 SkString str; 357 SkString str;
358 str.printf("filter %d", static_cast<int>(i)); 358 str.printf("filter %d", static_cast<int>(i));
359 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nul lptr); 359 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nul lptr);
360 SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset)); 360 SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
361 REPORTER_ASSERT_MESSAGE(reporter, resultImg, str.c_str()); 361 REPORTER_ASSERT_MESSAGE(reporter, resultImg, str.c_str());
362 REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, st r.c_str()); 362 REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, st r.c_str());
363 } 363 }
364 364
365 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { 365 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
366 SkSafeUnref(filters[i]); 366 SkSafeUnref(filters[i]);
367 } 367 }
368 } 368 }
369 369
370 static SkBitmap make_gradient_circle(int width, int height) { 370 static SkBitmap make_gradient_circle(int width, int height) {
(...skipping 21 matching lines...) Expand all
392 GrContext* context) { 392 GrContext* context) {
393 // Check that SkBlurImageFilter will accept a negative sigma, either in 393 // Check that SkBlurImageFilter will accept a negative sigma, either in
394 // the given arguments or after CTM application. 394 // the given arguments or after CTM application.
395 const int width = 32, height = 32; 395 const int width = 32, height = 32;
396 const SkScalar five = SkIntToScalar(5); 396 const SkScalar five = SkIntToScalar(5);
397 397
398 SkAutoTUnref<SkImageFilter> positiveFilter(SkBlurImageFilter::Create(five, f ive)); 398 SkAutoTUnref<SkImageFilter> positiveFilter(SkBlurImageFilter::Create(five, f ive));
399 SkAutoTUnref<SkImageFilter> negativeFilter(SkBlurImageFilter::Create(-five, five)); 399 SkAutoTUnref<SkImageFilter> negativeFilter(SkBlurImageFilter::Create(-five, five));
400 400
401 SkBitmap gradient = make_gradient_circle(width, height); 401 SkBitmap gradient = make_gradient_circle(width, height);
402 SkAutoTUnref<SkSpecialImage> imgSrc(SkSpecialImage::NewFromRaster(proxy, 402 sk_sp<SkSpecialImage> imgSrc(SkSpecialImage::MakeFromRaster(proxy,
403 SkIRect::M akeWH(width, 403 SkIRect::MakeWH( width, height),
404 height), 404 gradient));
405 gradient)) ;
406 405
407 SkIPoint offset; 406 SkIPoint offset;
408 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr); 407 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr);
409 408
410 SkAutoTUnref<SkSpecialImage> positiveResult1(positiveFilter->filterImage(img Src, ctx, &offset)); 409 SkAutoTUnref<SkSpecialImage> positiveResult1(positiveFilter->filterImage(img Src.get(),
410 ctx , &offset));
411 REPORTER_ASSERT(reporter, positiveResult1); 411 REPORTER_ASSERT(reporter, positiveResult1);
412 412
413 SkAutoTUnref<SkSpecialImage> negativeResult1(negativeFilter->filterImage(img Src, ctx, &offset)); 413 SkAutoTUnref<SkSpecialImage> negativeResult1(negativeFilter->filterImage(img Src.get(),
414 ctx , &offset));
414 REPORTER_ASSERT(reporter, negativeResult1); 415 REPORTER_ASSERT(reporter, negativeResult1);
415 416
416 SkMatrix negativeScale; 417 SkMatrix negativeScale;
417 negativeScale.setScale(-SK_Scalar1, SK_Scalar1); 418 negativeScale.setScale(-SK_Scalar1, SK_Scalar1);
418 SkImageFilter::Context negativeCTX(negativeScale, SkIRect::MakeWH(32, 32), n ullptr); 419 SkImageFilter::Context negativeCTX(negativeScale, SkIRect::MakeWH(32, 32), n ullptr);
419 420
420 SkAutoTUnref<SkSpecialImage> negativeResult2(positiveFilter->filterImage(img Src, 421 SkAutoTUnref<SkSpecialImage> negativeResult2(positiveFilter->filterImage(img Src.get(),
421 neg ativeCTX, 422 neg ativeCTX,
422 &of fset)); 423 &of fset));
423 REPORTER_ASSERT(reporter, negativeResult2); 424 REPORTER_ASSERT(reporter, negativeResult2);
424 425
425 SkAutoTUnref<SkSpecialImage> positiveResult2(negativeFilter->filterImage(img Src, 426 SkAutoTUnref<SkSpecialImage> positiveResult2(negativeFilter->filterImage(img Src.get(),
426 neg ativeCTX, 427 neg ativeCTX,
427 &of fset)); 428 &of fset));
428 REPORTER_ASSERT(reporter, positiveResult2); 429 REPORTER_ASSERT(reporter, positiveResult2);
429 430
430 431
431 SkBitmap positiveResultBM1, positiveResultBM2; 432 SkBitmap positiveResultBM1, positiveResultBM2;
432 SkBitmap negativeResultBM1, negativeResultBM2; 433 SkBitmap negativeResultBM1, negativeResultBM2;
433 434
434 TestingSpecialImageAccess::GetROPixels(positiveResult1, &positiveResultBM1); 435 TestingSpecialImageAccess::GetROPixels(positiveResult1, &positiveResultBM1);
435 TestingSpecialImageAccess::GetROPixels(positiveResult2, &positiveResultBM2); 436 TestingSpecialImageAccess::GetROPixels(positiveResult2, &positiveResultBM2);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 #endif 514 #endif
514 515
515 static void test_zero_blur_sigma(SkImageFilter::Proxy* proxy, 516 static void test_zero_blur_sigma(SkImageFilter::Proxy* proxy,
516 skiatest::Reporter* reporter, 517 skiatest::Reporter* reporter,
517 GrContext* context) { 518 GrContext* context) {
518 // Check that SkBlurImageFilter with a zero sigma and a non-zero srcOffset w orks correctly. 519 // Check that SkBlurImageFilter with a zero sigma and a non-zero srcOffset w orks correctly.
519 SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(5, 0, 5, 10) )); 520 SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(5, 0, 5, 10) ));
520 SkAutoTUnref<SkImageFilter> input(SkOffsetImageFilter::Create(0, 0, nullptr, &cropRect)); 521 SkAutoTUnref<SkImageFilter> input(SkOffsetImageFilter::Create(0, 0, nullptr, &cropRect));
521 SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(0, 0, input, &c ropRect)); 522 SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(0, 0, input, &c ropRect));
522 523
523 SkAutoTUnref<SkSpecialSurface> surf(create_empty_special_surface(context, pr oxy, 10)); 524 sk_sp<SkSpecialSurface> surf(create_empty_special_surface(context, proxy, 10 ));
524 surf->getCanvas()->clear(SK_ColorGREEN); 525 surf->getCanvas()->clear(SK_ColorGREEN);
525 SkAutoTUnref<SkSpecialImage> image(surf->newImageSnapshot()); 526 sk_sp<SkSpecialImage> image(surf->makeImageSnapshot());
526 527
527 SkIPoint offset; 528 SkIPoint offset;
528 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr); 529 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr);
529 530
530 SkAutoTUnref<SkSpecialImage> result(filter->filterImage(image, ctx, &offset) ); 531 SkAutoTUnref<SkSpecialImage> result(filter->filterImage(image.get(), ctx, &o ffset));
531 REPORTER_ASSERT(reporter, offset.fX == 5 && offset.fY == 0); 532 REPORTER_ASSERT(reporter, offset.fX == 5 && offset.fY == 0);
532 REPORTER_ASSERT(reporter, result); 533 REPORTER_ASSERT(reporter, result);
533 REPORTER_ASSERT(reporter, result->width() == 5 && result->height() == 10); 534 REPORTER_ASSERT(reporter, result->width() == 5 && result->height() == 10);
534 535
535 SkBitmap resultBM; 536 SkBitmap resultBM;
536 537
537 TestingSpecialImageAccess::GetROPixels(result, &resultBM); 538 TestingSpecialImageAccess::GetROPixels(result, &resultBM);
538 539
539 SkAutoLockPixels lock(resultBM); 540 SkAutoLockPixels lock(resultBM);
540 for (int y = 0; y < resultBM.height(); y++) { 541 for (int y = 0; y < resultBM.height(); y++) {
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 static void test_imagefilter_merge_result_size(SkImageFilter::Proxy* proxy, 822 static void test_imagefilter_merge_result_size(SkImageFilter::Proxy* proxy,
822 skiatest::Reporter* reporter, 823 skiatest::Reporter* reporter,
823 GrContext* context) { 824 GrContext* context) {
824 SkBitmap greenBM; 825 SkBitmap greenBM;
825 greenBM.allocN32Pixels(20, 20); 826 greenBM.allocN32Pixels(20, 20);
826 greenBM.eraseColor(SK_ColorGREEN); 827 greenBM.eraseColor(SK_ColorGREEN);
827 sk_sp<SkImage> greenImage(SkImage::MakeFromBitmap(greenBM)); 828 sk_sp<SkImage> greenImage(SkImage::MakeFromBitmap(greenBM));
828 SkAutoTUnref<SkImageFilter> source(SkImageSource::Create(greenImage.get())); 829 SkAutoTUnref<SkImageFilter> source(SkImageSource::Create(greenImage.get()));
829 SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(source.get(), s ource.get())); 830 SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(source.get(), s ource.get()));
830 831
831 SkAutoTUnref<SkSpecialImage> srcImg(create_empty_special_image(context, prox y, 1)); 832 sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 1));
832 833
833 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 100, 100), nullptr); 834 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 100, 100), nullptr);
834 SkIPoint offset; 835 SkIPoint offset;
835 836
836 SkAutoTUnref<SkSpecialImage> resultImg(merge->filterImage(srcImg, ctx, &offs et)); 837 SkAutoTUnref<SkSpecialImage> resultImg(merge->filterImage(srcImg.get(), ctx, &offset));
837 REPORTER_ASSERT(reporter, resultImg); 838 REPORTER_ASSERT(reporter, resultImg);
838 839
839 REPORTER_ASSERT(reporter, resultImg->width() == 20 && resultImg->height() == 20); 840 REPORTER_ASSERT(reporter, resultImg->width() == 20 && resultImg->height() == 20);
840 } 841 }
841 842
842 DEF_TEST(ImageFilterMergeResultSize, reporter) { 843 DEF_TEST(ImageFilterMergeResultSize, reporter) {
843 run_raster_test(reporter, 100, test_imagefilter_merge_result_size); 844 run_raster_test(reporter, 100, test_imagefilter_merge_result_size);
844 } 845 }
845 846
846 #if SK_SUPPORT_GPU 847 #if SK_SUPPORT_GPU
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 SkPictureRecorder recorder; 1085 SkPictureRecorder recorder;
1085 SkCanvas* recordingCanvas = recorder.beginRecording(1, 1, &factory, 0); 1086 SkCanvas* recordingCanvas = recorder.beginRecording(1, 1, &factory, 0);
1086 1087
1087 // Create an SkPicture which simply draws a green 1x1 rectangle. 1088 // Create an SkPicture which simply draws a green 1x1 rectangle.
1088 SkPaint greenPaint; 1089 SkPaint greenPaint;
1089 greenPaint.setColor(SK_ColorGREEN); 1090 greenPaint.setColor(SK_ColorGREEN);
1090 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPain t); 1091 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPain t);
1091 picture.reset(recorder.endRecording()); 1092 picture.reset(recorder.endRecording());
1092 } 1093 }
1093 1094
1094 SkAutoTUnref<SkSpecialImage> srcImg(create_empty_special_image(context, prox y, 2)); 1095 sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 2));
1095 1096
1096 SkAutoTUnref<SkImageFilter> imageFilter(SkPictureImageFilter::Create(picture .get())); 1097 SkAutoTUnref<SkImageFilter> imageFilter(SkPictureImageFilter::Create(picture .get()));
1097 1098
1098 SkIPoint offset; 1099 SkIPoint offset;
1099 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), nul lptr); 1100 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), nul lptr);
1100 1101
1101 SkAutoTUnref<SkSpecialImage> resultImage(imageFilter->filterImage(srcImg, ct x, &offset)); 1102 SkAutoTUnref<SkSpecialImage> resultImage(imageFilter->filterImage(srcImg.get (), ctx, &offset));
1102 REPORTER_ASSERT(reporter, !resultImage); 1103 REPORTER_ASSERT(reporter, !resultImage);
1103 } 1104 }
1104 1105
1105 DEF_TEST(ImageFilterClippedPictureImageFilter, reporter) { 1106 DEF_TEST(ImageFilterClippedPictureImageFilter, reporter) {
1106 run_raster_test(reporter, 2, test_clipped_picture_imagefilter); 1107 run_raster_test(reporter, 2, test_clipped_picture_imagefilter);
1107 } 1108 }
1108 1109
1109 #if SK_SUPPORT_GPU 1110 #if SK_SUPPORT_GPU
1110 DEF_GPUTEST_FOR_NATIVE_CONTEXT(ImageFilterClippedPictureImageFilter_Gpu, reporte r, context) { 1111 DEF_GPUTEST_FOR_NATIVE_CONTEXT(ImageFilterClippedPictureImageFilter_Gpu, reporte r, context) {
1111 run_gpu_test(reporter, context, 2, test_clipped_picture_imagefilter); 1112 run_gpu_test(reporter, context, 2, test_clipped_picture_imagefilter);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 DEF_TEST(XfermodeImageFilterCroppedInput, reporter) { 1337 DEF_TEST(XfermodeImageFilterCroppedInput, reporter) {
1337 SkBitmap temp; 1338 SkBitmap temp;
1338 temp.allocN32Pixels(100, 100); 1339 temp.allocN32Pixels(100, 100);
1339 SkCanvas canvas(temp); 1340 SkCanvas canvas(temp);
1340 test_xfermode_cropped_input(&canvas, reporter); 1341 test_xfermode_cropped_input(&canvas, reporter);
1341 } 1342 }
1342 1343
1343 static void test_composed_imagefilter_offset(SkImageFilter::Proxy* proxy, 1344 static void test_composed_imagefilter_offset(SkImageFilter::Proxy* proxy,
1344 skiatest::Reporter* reporter, 1345 skiatest::Reporter* reporter,
1345 GrContext* context) { 1346 GrContext* context) {
1346 SkAutoTUnref<SkSpecialImage> srcImg(create_empty_special_image(context, prox y, 100)); 1347 sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100) );
1347 1348
1348 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20)); 1349 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20));
1349 SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, n ullptr, &cropRect)); 1350 SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, n ullptr, &cropRect));
1350 SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1, 1351 SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1,
1351 nullptr, &c ropRect)); 1352 nullptr, &c ropRect));
1352 SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(blur Filter, 1353 SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(blur Filter,
1353 offs etFilter.get())); 1354 offs etFilter.get()));
1354 SkIPoint offset; 1355 SkIPoint offset;
1355 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr ); 1356 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr );
1356 1357
1357 SkAutoTUnref<SkSpecialImage> resultImg(composedFilter->filterImage(srcImg, c tx, &offset)); 1358 SkAutoTUnref<SkSpecialImage> resultImg(composedFilter->filterImage(srcImg.ge t(), ctx, &offset));
1358 REPORTER_ASSERT(reporter, resultImg); 1359 REPORTER_ASSERT(reporter, resultImg);
1359 REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0); 1360 REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0);
1360 } 1361 }
1361 1362
1362 DEF_TEST(ComposedImageFilterOffset, reporter) { 1363 DEF_TEST(ComposedImageFilterOffset, reporter) {
1363 run_raster_test(reporter, 100, test_composed_imagefilter_offset); 1364 run_raster_test(reporter, 100, test_composed_imagefilter_offset);
1364 } 1365 }
1365 1366
1366 #if SK_SUPPORT_GPU 1367 #if SK_SUPPORT_GPU
1367 DEF_GPUTEST_FOR_NATIVE_CONTEXT(ComposedImageFilterOffset_Gpu, reporter, context) { 1368 DEF_GPUTEST_FOR_NATIVE_CONTEXT(ComposedImageFilterOffset_Gpu, reporter, context) {
1368 run_gpu_test(reporter, context, 100, test_composed_imagefilter_offset); 1369 run_gpu_test(reporter, context, 100, test_composed_imagefilter_offset);
1369 } 1370 }
1370 #endif 1371 #endif
1371 1372
1372 static void test_partial_crop_rect(SkImageFilter::Proxy* proxy, 1373 static void test_partial_crop_rect(SkImageFilter::Proxy* proxy,
1373 skiatest::Reporter* reporter, 1374 skiatest::Reporter* reporter,
1374 GrContext* context) { 1375 GrContext* context) {
1375 SkAutoTUnref<SkSpecialImage> srcImg(create_empty_special_image(context, prox y, 100)); 1376 sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100) );
1376 1377
1377 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(100, 0, 20, 30), 1378 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(100, 0, 20, 30),
1378 SkImageFilter::CropRect::kHasWidth_CropEdge | SkImageFilter::CropRect::k HasHeight_CropEdge); 1379 SkImageFilter::CropRect::kHasWidth_CropEdge | SkImageFilter::CropRect::k HasHeight_CropEdge);
1379 SkAutoTUnref<SkImageFilter> filter(make_grayscale(nullptr, &cropRect)); 1380 SkAutoTUnref<SkImageFilter> filter(make_grayscale(nullptr, &cropRect));
1380 SkIPoint offset; 1381 SkIPoint offset;
1381 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr ); 1382 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr );
1382 1383
1383 SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &off set)); 1384 SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx , &offset));
1384 REPORTER_ASSERT(reporter, resultImg); 1385 REPORTER_ASSERT(reporter, resultImg);
1385 1386
1386 REPORTER_ASSERT(reporter, offset.fX == 0); 1387 REPORTER_ASSERT(reporter, offset.fX == 0);
1387 REPORTER_ASSERT(reporter, offset.fY == 0); 1388 REPORTER_ASSERT(reporter, offset.fY == 0);
1388 REPORTER_ASSERT(reporter, resultImg->width() == 20); 1389 REPORTER_ASSERT(reporter, resultImg->width() == 20);
1389 REPORTER_ASSERT(reporter, resultImg->height() == 30); 1390 REPORTER_ASSERT(reporter, resultImg->height() == 30);
1390 } 1391 }
1391 1392
1392 DEF_TEST(PartialCropRect, reporter) { 1393 DEF_TEST(PartialCropRect, reporter) {
1393 run_raster_test(reporter, 100, test_partial_crop_rect); 1394 run_raster_test(reporter, 100, test_partial_crop_rect);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 test_xfermode_cropped_input(&canvas, reporter); 1555 test_xfermode_cropped_input(&canvas, reporter);
1555 } 1556 }
1556 1557
1557 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { 1558 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) {
1558 SkAutoTUnref<SkSurface> surface( 1559 SkAutoTUnref<SkSurface> surface(
1559 SkSurface::NewRenderTarget(context, SkBudgeted::kYes, 1560 SkSurface::NewRenderTarget(context, SkBudgeted::kYes,
1560 SkImageInfo::MakeN32Premul(100, 100))); 1561 SkImageInfo::MakeN32Premul(100, 100)));
1561 test_large_blur_input(reporter, surface->getCanvas()); 1562 test_large_blur_input(reporter, surface->getCanvas());
1562 } 1563 }
1563 #endif 1564 #endif
OLDNEW
« no previous file with comments | « tests/ImageFilterCacheTest.cpp ('k') | tests/SpecialImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698