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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 26371002: Change SkImageFilter's cropRect from SkIRect to a CropRect struct (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Alternate version, using a single fFlags member. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkXfermodeImageFilter.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 /* 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 "Test.h" 9 #include "Test.h"
10 #include "SkBicubicImageFilter.h" 10 #include "SkBicubicImageFilter.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 static SkImageFilter* make_scale(float amount, SkImageFilter* input = NULL) { 60 static SkImageFilter* make_scale(float amount, SkImageFilter* input = NULL) {
61 SkScalar s = SkFloatToScalar(amount); 61 SkScalar s = SkFloatToScalar(amount);
62 SkScalar matrix[20] = { s, 0, 0, 0, 0, 62 SkScalar matrix[20] = { s, 0, 0, 0, 0,
63 0, s, 0, 0, 0, 63 0, s, 0, 0, 0,
64 0, 0, s, 0, 0, 64 0, 0, s, 0, 0,
65 0, 0, 0, s, 0 }; 65 0, 0, 0, s, 0 };
66 SkAutoTUnref<SkColorFilter> filter(new SkColorMatrixFilter(matrix)); 66 SkAutoTUnref<SkColorFilter> filter(new SkColorMatrixFilter(matrix));
67 return SkColorFilterImageFilter::Create(filter, input); 67 return SkColorFilterImageFilter::Create(filter, input);
68 } 68 }
69 69
70 static SkImageFilter* make_grayscale(SkImageFilter* input = NULL, const SkIR ect* cropRect = NULL) { 70 static SkImageFilter* make_grayscale(SkImageFilter* input = NULL, const SkIm ageFilter::CropRect* cropRect = NULL) {
71 SkScalar matrix[20]; 71 SkScalar matrix[20];
72 memset(matrix, 0, 20 * sizeof(SkScalar)); 72 memset(matrix, 0, 20 * sizeof(SkScalar));
73 matrix[0] = matrix[5] = matrix[10] = SkFloatToScalar(0.2126f); 73 matrix[0] = matrix[5] = matrix[10] = SkFloatToScalar(0.2126f);
74 matrix[1] = matrix[6] = matrix[11] = SkFloatToScalar(0.7152f); 74 matrix[1] = matrix[6] = matrix[11] = SkFloatToScalar(0.7152f);
75 matrix[2] = matrix[7] = matrix[12] = SkFloatToScalar(0.0722f); 75 matrix[2] = matrix[7] = matrix[12] = SkFloatToScalar(0.0722f);
76 matrix[18] = SkFloatToScalar(1.0f); 76 matrix[18] = SkFloatToScalar(1.0f);
77 SkAutoTUnref<SkColorFilter> filter(new SkColorMatrixFilter(matrix)); 77 SkAutoTUnref<SkColorFilter> filter(new SkColorMatrixFilter(matrix));
78 return SkColorFilterImageFilter::Create(filter, input, cropRect); 78 return SkColorFilterImageFilter::Create(filter, input, cropRect);
79 } 79 }
80 80
(...skipping 21 matching lines...) Expand all
102 { 102 {
103 // Check that a color filter image filter without a crop rect can be 103 // Check that a color filter image filter without a crop rect can be
104 // expressed as a color filter. 104 // expressed as a color filter.
105 SkAutoTUnref<SkImageFilter> gray(make_grayscale()); 105 SkAutoTUnref<SkImageFilter> gray(make_grayscale());
106 REPORTER_ASSERT(reporter, true == gray->asColorFilter(NULL)); 106 REPORTER_ASSERT(reporter, true == gray->asColorFilter(NULL));
107 } 107 }
108 108
109 { 109 {
110 // Check that a color filter image filter with a crop rect cannot 110 // Check that a color filter image filter with a crop rect cannot
111 // be expressed as a color filter. 111 // be expressed as a color filter.
112 #ifdef SK_CROP_RECT_IS_INT
112 SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100); 113 SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100);
114 #else
115 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(0, 0, 100, 100));
116 #endif
113 SkAutoTUnref<SkImageFilter> grayWithCrop(make_grayscale(NULL, &cropR ect)); 117 SkAutoTUnref<SkImageFilter> grayWithCrop(make_grayscale(NULL, &cropR ect));
114 REPORTER_ASSERT(reporter, false == grayWithCrop->asColorFilter(NULL) ); 118 REPORTER_ASSERT(reporter, false == grayWithCrop->asColorFilter(NULL) );
115 } 119 }
116 120
117 { 121 {
118 // Tests pass by not asserting 122 // Tests pass by not asserting
119 SkBitmap bitmap, result; 123 SkBitmap bitmap, result;
120 make_small_bitmap(bitmap); 124 make_small_bitmap(bitmap);
121 result.setConfig(SkBitmap::kARGB_8888_Config, kBitmapSize, kBitmapSi ze); 125 result.setConfig(SkBitmap::kARGB_8888_Config, kBitmapSize, kBitmapSi ze);
122 result.allocPixels(); 126 result.allocPixels();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 REPORTER_ASSERT(reporter, 158 REPORTER_ASSERT(reporter,
155 !bicubic->filterImage(&proxy, bitmap, SkMatrix::I(), &result , &loc)); 159 !bicubic->filterImage(&proxy, bitmap, SkMatrix::I(), &result , &loc));
156 } 160 }
157 } 161 }
158 } 162 }
159 }; 163 };
160 164
161 165
162 #include "TestClassDef.h" 166 #include "TestClassDef.h"
163 DEFINE_TESTCLASS("ImageFilterTest", ImageFilterTestClass, ImageFilterTest::Test) 167 DEFINE_TESTCLASS("ImageFilterTest", ImageFilterTestClass, ImageFilterTest::Test)
OLDNEW
« no previous file with comments | « src/effects/SkXfermodeImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698