epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 8 | #include "SkBlurMask.h" |
reed@google.com | 2b75f42 | 2011-07-07 13:43:38 +0000 | [diff] [blame] | 9 | #include "SkBlurMaskFilter.h" |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 10 | #include "SkCanvas.h" |
tomhudson@google.com | 889bd8b | 2011-09-27 17:38:17 +0000 | [diff] [blame] | 11 | #include "SkMath.h" |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 12 | #include "SkPaint.h" |
tfarina@chromium.org | 4ee16bf | 2014-01-10 22:08:27 +0000 | [diff] [blame] | 13 | #include "Test.h" |
tfarina@chromium.org | 4ee16bf | 2014-01-10 22:08:27 +0000 | [diff] [blame] | 14 | |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 15 | #if SK_SUPPORT_GPU |
| 16 | #include "GrContextFactory.h" |
| 17 | #include "SkGpuDevice.h" |
| 18 | #endif |
| 19 | |
| 20 | #define WRITE_CSV 0 |
reed@google.com | 2b75f42 | 2011-07-07 13:43:38 +0000 | [diff] [blame] | 21 | |
| 22 | /////////////////////////////////////////////////////////////////////////////// |
| 23 | |
| 24 | #define ILLEGAL_MODE ((SkXfermode::Mode)-1) |
| 25 | |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 26 | static const int outset = 100; |
| 27 | static const SkColor bgColor = SK_ColorWHITE; |
| 28 | static const int strokeWidth = 4; |
| 29 | |
commit-bot@chromium.org | fa9e5fa | 2014-02-13 22:00:04 +0000 | [diff] [blame] | 30 | static void create(SkBitmap* bm, const SkIRect& bound) { |
| 31 | bm->allocN32Pixels(bound.width(), bound.height()); |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | static void drawBG(SkCanvas* canvas) { |
| 35 | canvas->drawColor(bgColor); |
| 36 | } |
| 37 | |
| 38 | |
| 39 | struct BlurTest { |
| 40 | void (*addPath)(SkPath*); |
| 41 | int viewLen; |
| 42 | SkIRect views[9]; |
| 43 | }; |
| 44 | |
| 45 | //Path Draw Procs |
| 46 | //Beware that paths themselves my draw differently depending on the clip. |
| 47 | static void draw50x50Rect(SkPath* path) { |
| 48 | path->addRect(0, 0, SkIntToScalar(50), SkIntToScalar(50)); |
| 49 | } |
| 50 | |
| 51 | //Tests |
| 52 | static BlurTest tests[] = { |
| 53 | { draw50x50Rect, 3, { |
| 54 | //inner half of blur |
| 55 | { 0, 0, 50, 50 }, |
| 56 | //blur, but no path. |
| 57 | { 50 + strokeWidth/2, 50 + strokeWidth/2, 100, 100 }, |
| 58 | //just an edge |
| 59 | { 40, strokeWidth, 60, 50 - strokeWidth }, |
| 60 | }}, |
| 61 | }; |
| 62 | |
| 63 | /** Assumes that the ref draw was completely inside ref canvas -- |
| 64 | implies that everything outside is "bgColor". |
| 65 | Checks that all overlap is the same and that all non-overlap on the |
| 66 | ref is "bgColor". |
| 67 | */ |
| 68 | static bool compare(const SkBitmap& ref, const SkIRect& iref, |
| 69 | const SkBitmap& test, const SkIRect& itest) |
| 70 | { |
| 71 | const int xOff = itest.fLeft - iref.fLeft; |
| 72 | const int yOff = itest.fTop - iref.fTop; |
| 73 | |
| 74 | SkAutoLockPixels alpRef(ref); |
| 75 | SkAutoLockPixels alpTest(test); |
| 76 | |
| 77 | for (int y = 0; y < test.height(); ++y) { |
| 78 | for (int x = 0; x < test.width(); ++x) { |
| 79 | SkColor testColor = test.getColor(x, y); |
| 80 | int refX = x + xOff; |
| 81 | int refY = y + yOff; |
| 82 | SkColor refColor; |
| 83 | if (refX >= 0 && refX < ref.width() && |
| 84 | refY >= 0 && refY < ref.height()) |
| 85 | { |
| 86 | refColor = ref.getColor(refX, refY); |
| 87 | } else { |
| 88 | refColor = bgColor; |
| 89 | } |
| 90 | if (refColor != testColor) { |
| 91 | return false; |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | return true; |
| 96 | } |
| 97 | |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 98 | static void test_blur_drawing(skiatest::Reporter* reporter) { |
reed@google.com | 2b75f42 | 2011-07-07 13:43:38 +0000 | [diff] [blame] | 99 | |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 100 | SkPaint paint; |
| 101 | paint.setColor(SK_ColorGRAY); |
| 102 | paint.setStyle(SkPaint::kStroke_Style); |
| 103 | paint.setStrokeWidth(SkIntToScalar(strokeWidth)); |
reed@google.com | 2b75f42 | 2011-07-07 13:43:38 +0000 | [diff] [blame] | 104 | |
robertphillips@google.com | b706117 | 2013-09-06 14:16:12 +0000 | [diff] [blame] | 105 | SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)); |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 106 | for (int style = 0; style < SkBlurMaskFilter::kBlurStyleCount; ++style) { |
| 107 | SkBlurMaskFilter::BlurStyle blurStyle = |
| 108 | static_cast<SkBlurMaskFilter::BlurStyle>(style); |
reed@google.com | 2b75f42 | 2011-07-07 13:43:38 +0000 | [diff] [blame] | 109 | |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 110 | const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag; |
| 111 | for (uint32_t flags = 0; flags < flagPermutations; ++flags) { |
| 112 | SkMaskFilter* filter; |
robertphillips@google.com | b706117 | 2013-09-06 14:16:12 +0000 | [diff] [blame] | 113 | filter = SkBlurMaskFilter::Create(blurStyle, sigma, flags); |
reed@google.com | 2b75f42 | 2011-07-07 13:43:38 +0000 | [diff] [blame] | 114 | |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 115 | paint.setMaskFilter(filter); |
| 116 | filter->unref(); |
| 117 | |
tomhudson@google.com | 83a4446 | 2011-10-27 15:27:51 +0000 | [diff] [blame] | 118 | for (size_t test = 0; test < SK_ARRAY_COUNT(tests); ++test) { |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 119 | SkPath path; |
| 120 | tests[test].addPath(&path); |
bungeman@google.com | d16872c | 2011-09-02 15:46:17 +0000 | [diff] [blame] | 121 | SkPath strokedPath; |
| 122 | paint.getFillPath(path, &strokedPath); |
| 123 | SkRect refBound = strokedPath.getBounds(); |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 124 | SkIRect iref; |
| 125 | refBound.roundOut(&iref); |
bungeman@google.com | d16872c | 2011-09-02 15:46:17 +0000 | [diff] [blame] | 126 | iref.inset(-outset, -outset); |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 127 | SkBitmap refBitmap; |
commit-bot@chromium.org | fa9e5fa | 2014-02-13 22:00:04 +0000 | [diff] [blame] | 128 | create(&refBitmap, iref); |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 129 | |
| 130 | SkCanvas refCanvas(refBitmap); |
| 131 | refCanvas.translate(SkIntToScalar(-iref.fLeft), |
| 132 | SkIntToScalar(-iref.fTop)); |
| 133 | drawBG(&refCanvas); |
| 134 | refCanvas.drawPath(path, paint); |
| 135 | |
| 136 | for (int view = 0; view < tests[test].viewLen; ++view) { |
| 137 | SkIRect itest = tests[test].views[view]; |
| 138 | SkBitmap testBitmap; |
commit-bot@chromium.org | fa9e5fa | 2014-02-13 22:00:04 +0000 | [diff] [blame] | 139 | create(&testBitmap, itest); |
bungeman@google.com | 5af16f8 | 2011-09-02 15:06:44 +0000 | [diff] [blame] | 140 | |
| 141 | SkCanvas testCanvas(testBitmap); |
| 142 | testCanvas.translate(SkIntToScalar(-itest.fLeft), |
| 143 | SkIntToScalar(-itest.fTop)); |
| 144 | drawBG(&testCanvas); |
| 145 | testCanvas.drawPath(path, paint); |
| 146 | |
| 147 | REPORTER_ASSERT(reporter, |
| 148 | compare(refBitmap, iref, testBitmap, itest)); |
| 149 | } |
| 150 | } |
| 151 | } |
reed@google.com | 2b75f42 | 2011-07-07 13:43:38 +0000 | [diff] [blame] | 152 | } |
| 153 | } |
| 154 | |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 155 | /////////////////////////////////////////////////////////////////////////////// |
| 156 | |
| 157 | // Use SkBlurMask::BlurGroundTruth to blur a 'width' x 'height' solid |
| 158 | // white rect. Return the right half of the middle row in 'result'. |
skia.committer@gmail.com | 6fc1b49 | 2013-09-06 07:01:45 +0000 | [diff] [blame] | 159 | static void ground_truth_2d(int width, int height, |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 160 | SkScalar sigma, |
| 161 | int* result, int resultCount) { |
| 162 | SkMask src, dst; |
| 163 | |
| 164 | src.fBounds.set(0, 0, width, height); |
| 165 | src.fFormat = SkMask::kA8_Format; |
| 166 | src.fRowBytes = src.fBounds.width(); |
| 167 | src.fImage = SkMask::AllocImage(src.computeTotalImageSize()); |
| 168 | |
| 169 | memset(src.fImage, 0xff, src.computeTotalImageSize()); |
| 170 | |
| 171 | dst.fImage = NULL; |
| 172 | SkBlurMask::BlurGroundTruth(sigma, &dst, src, SkBlurMask::kNormal_Style); |
| 173 | |
| 174 | int midX = dst.fBounds.centerX(); |
| 175 | int midY = dst.fBounds.centerY(); |
| 176 | uint8_t* bytes = dst.getAddr8(midX, midY); |
| 177 | int i; |
| 178 | for (i = 0; i < dst.fBounds.width()-(midX-dst.fBounds.fLeft); ++i) { |
| 179 | if (i < resultCount) { |
| 180 | result[i] = bytes[i]; |
| 181 | } |
| 182 | } |
| 183 | for ( ; i < resultCount; ++i) { |
| 184 | result[i] = 0; |
| 185 | } |
robertphillips@google.com | 6d837aa | 2013-10-11 14:38:46 +0000 | [diff] [blame] | 186 | |
| 187 | SkMask::FreeImage(src.fImage); |
| 188 | SkMask::FreeImage(dst.fImage); |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | // Implement a step function that is 255 between min and max; 0 elsewhere. |
| 192 | static int step(int x, SkScalar min, SkScalar max) { |
| 193 | if (min < x && x < max) { |
| 194 | return 255; |
| 195 | } |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | // Implement a Gaussian function with 0 mean and std.dev. of 'sigma'. |
| 200 | static float gaussian(int x, SkScalar sigma) { |
robertphillips@google.com | b85564a | 2013-09-05 17:53:34 +0000 | [diff] [blame] | 201 | float k = SK_Scalar1/(sigma * sqrtf(2.0f*SK_ScalarPI)); |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 202 | float exponent = -(x * x) / (2 * sigma * sigma); |
robertphillips@google.com | b85564a | 2013-09-05 17:53:34 +0000 | [diff] [blame] | 203 | return k * expf(exponent); |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | // Perform a brute force convolution of a step function with a Gaussian. |
| 207 | // Return the right half in 'result' |
skia.committer@gmail.com | 6fc1b49 | 2013-09-06 07:01:45 +0000 | [diff] [blame] | 208 | static void brute_force_1d(SkScalar stepMin, SkScalar stepMax, |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 209 | SkScalar gaussianSigma, |
| 210 | int* result, int resultCount) { |
| 211 | |
| 212 | int gaussianRange = SkScalarCeilToInt(10 * gaussianSigma); |
| 213 | |
| 214 | for (int i = 0; i < resultCount; ++i) { |
| 215 | SkScalar sum = 0.0f; |
| 216 | for (int j = -gaussianRange; j < gaussianRange; ++j) { |
| 217 | sum += gaussian(j, gaussianSigma) * step(i-j, stepMin, stepMax); |
| 218 | } |
| 219 | |
| 220 | result[i] = SkClampMax(SkClampPos(int(sum + 0.5f)), 255); |
| 221 | } |
| 222 | } |
| 223 | |
skia.committer@gmail.com | 6fc1b49 | 2013-09-06 07:01:45 +0000 | [diff] [blame] | 224 | static void blur_path(SkCanvas* canvas, const SkPath& path, |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 225 | SkScalar gaussianSigma) { |
| 226 | |
| 227 | SkScalar midX = path.getBounds().centerX(); |
| 228 | SkScalar midY = path.getBounds().centerY(); |
| 229 | |
| 230 | canvas->translate(-midX, -midY); |
| 231 | |
| 232 | SkPaint blurPaint; |
| 233 | blurPaint.setColor(SK_ColorWHITE); |
| 234 | SkMaskFilter* filter = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle, |
| 235 | gaussianSigma, |
| 236 | SkBlurMaskFilter::kHighQuality_BlurFlag); |
| 237 | blurPaint.setMaskFilter(filter)->unref(); |
| 238 | |
| 239 | canvas->drawColor(SK_ColorBLACK); |
| 240 | canvas->drawPath(path, blurPaint); |
| 241 | } |
| 242 | |
| 243 | // Readback the blurred draw results from the canvas |
| 244 | static void readback(SkCanvas* canvas, int* result, int resultCount) { |
| 245 | SkBitmap readback; |
commit-bot@chromium.org | fa9e5fa | 2014-02-13 22:00:04 +0000 | [diff] [blame] | 246 | readback.allocN32Pixels(resultCount, 30); |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 247 | |
| 248 | SkIRect readBackRect = { 0, 0, resultCount, 30 }; |
| 249 | |
| 250 | canvas->readPixels(readBackRect, &readback); |
| 251 | |
| 252 | readback.lockPixels(); |
| 253 | SkPMColor* pixels = (SkPMColor*) readback.getAddr32(0, 15); |
| 254 | |
| 255 | for (int i = 0; i < resultCount; ++i) { |
| 256 | result[i] = SkColorGetR(pixels[i]); |
| 257 | } |
| 258 | } |
| 259 | |
skia.committer@gmail.com | 6fc1b49 | 2013-09-06 07:01:45 +0000 | [diff] [blame] | 260 | // Draw a blurred version of the provided path. |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 261 | // Return the right half of the middle row in 'result'. |
| 262 | static void cpu_blur_path(const SkPath& path, SkScalar gaussianSigma, |
| 263 | int* result, int resultCount) { |
| 264 | |
| 265 | SkBitmap bitmap; |
commit-bot@chromium.org | fa9e5fa | 2014-02-13 22:00:04 +0000 | [diff] [blame] | 266 | bitmap.allocN32Pixels(resultCount, 30); |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 267 | SkCanvas canvas(bitmap); |
| 268 | |
| 269 | blur_path(&canvas, path, gaussianSigma); |
| 270 | readback(&canvas, result, resultCount); |
| 271 | } |
| 272 | |
| 273 | #if SK_SUPPORT_GPU |
robertphillips@google.com | cb3b615 | 2013-11-14 14:47:56 +0000 | [diff] [blame] | 274 | static bool gpu_blur_path(GrContextFactory* factory, const SkPath& path, |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 275 | SkScalar gaussianSigma, |
| 276 | int* result, int resultCount) { |
| 277 | |
| 278 | GrContext* grContext = factory->get(GrContextFactory::kNative_GLContextType); |
| 279 | if (NULL == grContext) { |
robertphillips@google.com | cb3b615 | 2013-11-14 14:47:56 +0000 | [diff] [blame] | 280 | return false; |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | GrTextureDesc desc; |
| 284 | desc.fConfig = kSkia8888_GrPixelConfig; |
| 285 | desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| 286 | desc.fWidth = resultCount; |
| 287 | desc.fHeight = 30; |
| 288 | desc.fSampleCnt = 0; |
| 289 | |
| 290 | SkAutoTUnref<GrTexture> texture(grContext->createUncachedTexture(desc, NULL, 0)); |
| 291 | SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (grContext, texture.get()))); |
| 292 | SkCanvas canvas(device.get()); |
| 293 | |
| 294 | blur_path(&canvas, path, gaussianSigma); |
| 295 | readback(&canvas, result, resultCount); |
robertphillips@google.com | cb3b615 | 2013-11-14 14:47:56 +0000 | [diff] [blame] | 296 | return true; |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 297 | } |
| 298 | #endif |
| 299 | |
| 300 | #if WRITE_CSV |
| 301 | static void write_as_csv(const char* label, SkScalar scale, int* data, int count) { |
| 302 | SkDebugf("%s_%.2f,", label, scale); |
| 303 | for (int i = 0; i < count-1; ++i) { |
| 304 | SkDebugf("%d,", data[i]); |
| 305 | } |
| 306 | SkDebugf("%d\n", data[count-1]); |
| 307 | } |
| 308 | #endif |
| 309 | |
| 310 | static bool match(int* first, int* second, int count, int tol) { |
| 311 | int delta; |
| 312 | for (int i = 0; i < count; ++i) { |
| 313 | delta = first[i] - second[i]; |
| 314 | if (delta > tol || delta < -tol) { |
| 315 | return false; |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | return true; |
| 320 | } |
| 321 | |
| 322 | // Test out the normal blur style with a wide range of sigmas |
| 323 | static void test_sigma_range(skiatest::Reporter* reporter, GrContextFactory* factory) { |
| 324 | |
| 325 | static const int kSize = 100; |
| 326 | |
| 327 | // The geometry is offset a smidge to trigger: |
| 328 | // https://code.google.com/p/chromium/issues/detail?id=282418 |
| 329 | SkPath rectPath; |
| 330 | rectPath.addRect(0.3f, 0.3f, 100.3f, 100.3f); |
| 331 | |
| 332 | SkPoint polyPts[] = { |
| 333 | { 0.3f, 0.3f }, |
| 334 | { 100.3f, 0.3f }, |
| 335 | { 100.3f, 100.3f }, |
| 336 | { 0.3f, 100.3f }, |
| 337 | { 2.3f, 50.3f } // a little divet to throw off the rect special case |
| 338 | }; |
| 339 | SkPath polyPath; |
| 340 | polyPath.addPoly(polyPts, SK_ARRAY_COUNT(polyPts), true); |
| 341 | |
| 342 | int rectSpecialCaseResult[kSize]; |
| 343 | int generalCaseResult[kSize]; |
| 344 | #if SK_SUPPORT_GPU |
| 345 | int gpuResult[kSize]; |
| 346 | #endif |
| 347 | int groundTruthResult[kSize]; |
| 348 | int bruteForce1DResult[kSize]; |
| 349 | |
commit-bot@chromium.org | 4b413c8 | 2013-11-25 19:44:07 +0000 | [diff] [blame] | 350 | SkScalar sigma = 10.0f; |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 351 | |
| 352 | for (int i = 0; i < 4; ++i, sigma /= 10) { |
| 353 | |
| 354 | cpu_blur_path(rectPath, sigma, rectSpecialCaseResult, kSize); |
| 355 | cpu_blur_path(polyPath, sigma, generalCaseResult, kSize); |
| 356 | #if SK_SUPPORT_GPU |
robertphillips@google.com | cb3b615 | 2013-11-14 14:47:56 +0000 | [diff] [blame] | 357 | bool haveGPUResult = gpu_blur_path(factory, rectPath, sigma, gpuResult, kSize); |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 358 | #endif |
| 359 | ground_truth_2d(100, 100, sigma, groundTruthResult, kSize); |
| 360 | brute_force_1d(-50.0f, 50.0f, sigma, bruteForce1DResult, kSize); |
| 361 | |
| 362 | REPORTER_ASSERT(reporter, match(rectSpecialCaseResult, bruteForce1DResult, kSize, 5)); |
| 363 | REPORTER_ASSERT(reporter, match(generalCaseResult, bruteForce1DResult, kSize, 15)); |
| 364 | #if SK_SUPPORT_GPU |
robertphillips@google.com | cb3b615 | 2013-11-14 14:47:56 +0000 | [diff] [blame] | 365 | if (haveGPUResult) { |
| 366 | // 1 works everywhere but: Ubuntu13 & Nexus4 |
| 367 | REPORTER_ASSERT(reporter, match(gpuResult, bruteForce1DResult, kSize, 10)); |
| 368 | } |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 369 | #endif |
| 370 | REPORTER_ASSERT(reporter, match(groundTruthResult, bruteForce1DResult, kSize, 1)); |
| 371 | |
| 372 | #if WRITE_CSV |
| 373 | write_as_csv("RectSpecialCase", sigma, rectSpecialCaseResult, kSize); |
| 374 | write_as_csv("GeneralCase", sigma, generalCaseResult, kSize); |
| 375 | #if SK_SUPPORT_GPU |
| 376 | write_as_csv("GPU", sigma, gpuResult, kSize); |
| 377 | #endif |
| 378 | write_as_csv("GroundTruth2D", sigma, groundTruthResult, kSize); |
| 379 | write_as_csv("BruteForce1D", sigma, bruteForce1DResult, kSize); |
| 380 | #endif |
| 381 | } |
| 382 | } |
| 383 | |
tfarina@chromium.org | 4ee16bf | 2014-01-10 22:08:27 +0000 | [diff] [blame] | 384 | DEF_GPUTEST(Blur, reporter, factory) { |
robertphillips@google.com | 3dfa4cc | 2013-09-05 16:39:03 +0000 | [diff] [blame] | 385 | test_blur_drawing(reporter); |
| 386 | test_sigma_range(reporter, factory); |
| 387 | } |