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

Side by Side Diff: tests/BlurTest.cpp

Issue 324463005: Rollback of fe689c46 and all subsequent changes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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/SkBlurMaskFilter.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 2011 Google Inc. 2 * Copyright 2011 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 "SkBlurMask.h" 8 #include "SkBlurMask.h"
9 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkBlurDrawLooper.h" 10 #include "SkBlurDrawLooper.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 266
267 SkBitmap bitmap; 267 SkBitmap bitmap;
268 bitmap.allocN32Pixels(resultCount, 30); 268 bitmap.allocN32Pixels(resultCount, 30);
269 SkCanvas canvas(bitmap); 269 SkCanvas canvas(bitmap);
270 270
271 blur_path(&canvas, path, gaussianSigma); 271 blur_path(&canvas, path, gaussianSigma);
272 readback(&canvas, result, resultCount); 272 readback(&canvas, result, resultCount);
273 } 273 }
274 274
275 #if SK_SUPPORT_GPU 275 #if SK_SUPPORT_GPU
276 #if 0
277 // temporary disable; see below for explanation
278 static bool gpu_blur_path(GrContextFactory* factory, const SkPath& path, 276 static bool gpu_blur_path(GrContextFactory* factory, const SkPath& path,
279 SkScalar gaussianSigma, 277 SkScalar gaussianSigma,
280 int* result, int resultCount) { 278 int* result, int resultCount) {
281 279
282 GrContext* grContext = factory->get(GrContextFactory::kNative_GLContextType) ; 280 GrContext* grContext = factory->get(GrContextFactory::kNative_GLContextType) ;
283 if (NULL == grContext) { 281 if (NULL == grContext) {
284 return false; 282 return false;
285 } 283 }
286 284
287 GrTextureDesc desc; 285 GrTextureDesc desc;
288 desc.fConfig = kSkia8888_GrPixelConfig; 286 desc.fConfig = kSkia8888_GrPixelConfig;
289 desc.fFlags = kRenderTarget_GrTextureFlagBit; 287 desc.fFlags = kRenderTarget_GrTextureFlagBit;
290 desc.fWidth = resultCount; 288 desc.fWidth = resultCount;
291 desc.fHeight = 30; 289 desc.fHeight = 30;
292 desc.fSampleCnt = 0; 290 desc.fSampleCnt = 0;
293 291
294 SkAutoTUnref<GrTexture> texture(grContext->createUncachedTexture(desc, NULL, 0)); 292 SkAutoTUnref<GrTexture> texture(grContext->createUncachedTexture(desc, NULL, 0));
295 SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (grContext, texture .get()))); 293 SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (grContext, texture .get())));
296 SkCanvas canvas(device.get()); 294 SkCanvas canvas(device.get());
297 295
298 blur_path(&canvas, path, gaussianSigma); 296 blur_path(&canvas, path, gaussianSigma);
299 readback(&canvas, result, resultCount); 297 readback(&canvas, result, resultCount);
300 return true; 298 return true;
301 } 299 }
302 #endif 300 #endif
303 #endif
304 301
305 #if WRITE_CSV 302 #if WRITE_CSV
306 static void write_as_csv(const char* label, SkScalar scale, int* data, int count ) { 303 static void write_as_csv(const char* label, SkScalar scale, int* data, int count ) {
307 SkDebugf("%s_%.2f,", label, scale); 304 SkDebugf("%s_%.2f,", label, scale);
308 for (int i = 0; i < count-1; ++i) { 305 for (int i = 0; i < count-1; ++i) {
309 SkDebugf("%d,", data[i]); 306 SkDebugf("%d,", data[i]);
310 } 307 }
311 SkDebugf("%d\n", data[count-1]); 308 SkDebugf("%d\n", data[count-1]);
312 } 309 }
313 #endif 310 #endif
(...skipping 25 matching lines...) Expand all
339 { 100.3f, 0.3f }, 336 { 100.3f, 0.3f },
340 { 100.3f, 100.3f }, 337 { 100.3f, 100.3f },
341 { 0.3f, 100.3f }, 338 { 0.3f, 100.3f },
342 { 2.3f, 50.3f } // a little divet to throw off the rect special case 339 { 2.3f, 50.3f } // a little divet to throw off the rect special case
343 }; 340 };
344 SkPath polyPath; 341 SkPath polyPath;
345 polyPath.addPoly(polyPts, SK_ARRAY_COUNT(polyPts), true); 342 polyPath.addPoly(polyPts, SK_ARRAY_COUNT(polyPts), true);
346 343
347 int rectSpecialCaseResult[kSize]; 344 int rectSpecialCaseResult[kSize];
348 int generalCaseResult[kSize]; 345 int generalCaseResult[kSize];
346 #if SK_SUPPORT_GPU
347 int gpuResult[kSize];
348 #endif
349 int groundTruthResult[kSize]; 349 int groundTruthResult[kSize];
350 int bruteForce1DResult[kSize]; 350 int bruteForce1DResult[kSize];
351 351
352 SkScalar sigma = 10.0f; 352 SkScalar sigma = 10.0f;
353 353
354 for (int i = 0; i < 4; ++i, sigma /= 10) { 354 for (int i = 0; i < 4; ++i, sigma /= 10) {
355 355
356 cpu_blur_path(rectPath, sigma, rectSpecialCaseResult, kSize); 356 cpu_blur_path(rectPath, sigma, rectSpecialCaseResult, kSize);
357 cpu_blur_path(polyPath, sigma, generalCaseResult, kSize); 357 cpu_blur_path(polyPath, sigma, generalCaseResult, kSize);
358 358 #if SK_SUPPORT_GPU
359 bool haveGPUResult = gpu_blur_path(factory, rectPath, sigma, gpuResult, kSize);
360 #endif
359 ground_truth_2d(100, 100, sigma, groundTruthResult, kSize); 361 ground_truth_2d(100, 100, sigma, groundTruthResult, kSize);
360 brute_force_1d(-50.0f, 50.0f, sigma, bruteForce1DResult, kSize); 362 brute_force_1d(-50.0f, 50.0f, sigma, bruteForce1DResult, kSize);
361 363
362 REPORTER_ASSERT(reporter, match(rectSpecialCaseResult, bruteForce1DResul t, kSize, 5)); 364 REPORTER_ASSERT(reporter, match(rectSpecialCaseResult, bruteForce1DResul t, kSize, 5));
363 REPORTER_ASSERT(reporter, match(generalCaseResult, bruteForce1DResult, k Size, 15)); 365 REPORTER_ASSERT(reporter, match(generalCaseResult, bruteForce1DResult, k Size, 15));
364 #if SK_SUPPORT_GPU 366 #if SK_SUPPORT_GPU
365 #if 0
366 int gpuResult[kSize];
367 bool haveGPUResult = gpu_blur_path(factory, rectPath, sigma, gpuResult, kSize);
368 // Disabling this test for now -- I don't think it's a legit comparison.
369 // Will continue to investigate this.
370 if (haveGPUResult) { 367 if (haveGPUResult) {
371 // 1 works everywhere but: Ubuntu13 & Nexus4 368 // 1 works everywhere but: Ubuntu13 & Nexus4
372 REPORTER_ASSERT(reporter, match(gpuResult, bruteForce1DResult, kSize , 10)); 369 REPORTER_ASSERT(reporter, match(gpuResult, bruteForce1DResult, kSize , 10));
373 } 370 }
374 #endif 371 #endif
375 #endif
376 REPORTER_ASSERT(reporter, match(groundTruthResult, bruteForce1DResult, k Size, 1)); 372 REPORTER_ASSERT(reporter, match(groundTruthResult, bruteForce1DResult, k Size, 1));
377 373
378 #if WRITE_CSV 374 #if WRITE_CSV
379 write_as_csv("RectSpecialCase", sigma, rectSpecialCaseResult, kSize); 375 write_as_csv("RectSpecialCase", sigma, rectSpecialCaseResult, kSize);
380 write_as_csv("GeneralCase", sigma, generalCaseResult, kSize); 376 write_as_csv("GeneralCase", sigma, generalCaseResult, kSize);
381 #if SK_SUPPORT_GPU 377 #if SK_SUPPORT_GPU
382 write_as_csv("GPU", sigma, gpuResult, kSize); 378 write_as_csv("GPU", sigma, gpuResult, kSize);
383 #endif 379 #endif
384 write_as_csv("GroundTruth2D", sigma, groundTruthResult, kSize); 380 write_as_csv("GroundTruth2D", sigma, groundTruthResult, kSize);
385 write_as_csv("BruteForce1D", sigma, bruteForce1DResult, kSize); 381 write_as_csv("BruteForce1D", sigma, bruteForce1DResult, kSize);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 560 }
565 } 561 }
566 562
567 //////////////////////////////////////////////////////////////////////////////// /////////// 563 //////////////////////////////////////////////////////////////////////////////// ///////////
568 564
569 DEF_GPUTEST(Blur, reporter, factory) { 565 DEF_GPUTEST(Blur, reporter, factory) {
570 test_blur_drawing(reporter); 566 test_blur_drawing(reporter);
571 test_sigma_range(reporter, factory); 567 test_sigma_range(reporter, factory);
572 test_asABlur(reporter); 568 test_asABlur(reporter);
573 } 569 }
OLDNEW
« no previous file with comments | « src/effects/SkBlurMaskFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698