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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 610723002: Sanitize SkMatrixConvolutionImageFilter creation params. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix style Created 6 years, 2 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 | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | no next file » | 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 * 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 "SkBitmapSource.h" 10 #include "SkBitmapSource.h"
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 canvas.drawSprite(bitmap, 0, 0, &paint); 888 canvas.drawSprite(bitmap, 0, 0, &paint);
889 } 889 }
890 890
891 DEF_TEST(HugeBlurImageFilter, reporter) { 891 DEF_TEST(HugeBlurImageFilter, reporter) {
892 SkBitmap temp; 892 SkBitmap temp;
893 temp.allocN32Pixels(100, 100); 893 temp.allocN32Pixels(100, 100);
894 SkBitmapDevice device(temp); 894 SkBitmapDevice device(temp);
895 test_huge_blur(&device, reporter); 895 test_huge_blur(&device, reporter);
896 } 896 }
897 897
898 DEF_TEST(MatrixConvolutionSanityTest, reporter) {
899 SkScalar kernel[1] = { 0 };
900 SkScalar gain = SK_Scalar1, bias = 0;
901 SkIPoint kernelOffset = SkIPoint::Make(1, 1);
902
903 // Check that an enormous (non-allocatable) kernel gives a NULL filter.
904 SkAutoTUnref<SkImageFilter> conv(SkMatrixConvolutionImageFilter::Create(
905 SkISize::Make(1<<30, 1<<30),
906 kernel,
907 gain,
908 bias,
909 kernelOffset,
910 SkMatrixConvolutionImageFilter::kRepeat_TileMode,
911 false));
912
913 REPORTER_ASSERT(reporter, NULL == conv.get());
914
915 // Check that a NULL kernel gives a NULL filter.
916 conv.reset(SkMatrixConvolutionImageFilter::Create(
917 SkISize::Make(1, 1),
918 NULL,
919 gain,
920 bias,
921 kernelOffset,
922 SkMatrixConvolutionImageFilter::kRepeat_TileMode,
923 false));
924
925 REPORTER_ASSERT(reporter, NULL == conv.get());
926
927 // Check that a kernel width < 1 gives a NULL filter.
928 conv.reset(SkMatrixConvolutionImageFilter::Create(
929 SkISize::Make(0, 1),
930 kernel,
931 gain,
932 bias,
933 kernelOffset,
934 SkMatrixConvolutionImageFilter::kRepeat_TileMode,
935 false));
936
937 REPORTER_ASSERT(reporter, NULL == conv.get());
938
939 // Check that kernel height < 1 gives a NULL filter.
940 conv.reset(SkMatrixConvolutionImageFilter::Create(
941 SkISize::Make(1, -1),
942 kernel,
943 gain,
944 bias,
945 kernelOffset,
946 SkMatrixConvolutionImageFilter::kRepeat_TileMode,
947 false));
948
949 REPORTER_ASSERT(reporter, NULL == conv.get());
950 }
951
898 static void test_xfermode_cropped_input(SkBaseDevice* device, skiatest::Reporter * reporter) { 952 static void test_xfermode_cropped_input(SkBaseDevice* device, skiatest::Reporter * reporter) {
899 SkCanvas canvas(device); 953 SkCanvas canvas(device);
900 canvas.clear(0); 954 canvas.clear(0);
901 955
902 SkBitmap bitmap; 956 SkBitmap bitmap;
903 bitmap.allocN32Pixels(1, 1); 957 bitmap.allocN32Pixels(1, 1);
904 bitmap.eraseARGB(255, 255, 255, 255); 958 bitmap.eraseARGB(255, 255, 255, 255);
905 959
906 SkAutoTUnref<SkColorFilter> green( 960 SkAutoTUnref<SkColorFilter> green(
907 SkColorFilter::CreateModeFilter(SK_ColorGREEN, SkXfermode::kSrcIn_Mode)) ; 961 SkColorFilter::CreateModeFilter(SK_ColorGREEN, SkXfermode::kSrcIn_Mode)) ;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1085
1032 DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) { 1086 DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) {
1033 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0)); 1087 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0));
1034 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, 1088 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
1035 SkImageInfo::MakeN32Pre mul(1, 1), 1089 SkImageInfo::MakeN32Pre mul(1, 1),
1036 gProps, 1090 gProps,
1037 0)); 1091 0));
1038 test_negative_blur_sigma(device, reporter); 1092 test_negative_blur_sigma(device, reporter);
1039 } 1093 }
1040 #endif 1094 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698