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

Side by Side Diff: tests/BlurTest.cpp

Issue 59713010: Address some more valgrind issues (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 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 #include "Test.h" 8 #include "Test.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 SkBitmap bitmap; 266 SkBitmap bitmap;
267 bitmap.setConfig(SkBitmap::kARGB_8888_Config, resultCount, 30); 267 bitmap.setConfig(SkBitmap::kARGB_8888_Config, resultCount, 30);
268 bitmap.allocPixels(); 268 bitmap.allocPixels();
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 static void gpu_blur_path(GrContextFactory* factory, const SkPath& path, 276 static bool gpu_blur_path(GrContextFactory* factory, const SkPath& path,
277 SkScalar gaussianSigma, 277 SkScalar gaussianSigma,
278 int* result, int resultCount) { 278 int* result, int resultCount) {
279 279
280 GrContext* grContext = factory->get(GrContextFactory::kNative_GLContextType) ; 280 GrContext* grContext = factory->get(GrContextFactory::kNative_GLContextType) ;
281 if (NULL == grContext) { 281 if (NULL == grContext) {
282 return; 282 return false;
283 } 283 }
284 284
285 GrTextureDesc desc; 285 GrTextureDesc desc;
286 desc.fConfig = kSkia8888_GrPixelConfig; 286 desc.fConfig = kSkia8888_GrPixelConfig;
287 desc.fFlags = kRenderTarget_GrTextureFlagBit; 287 desc.fFlags = kRenderTarget_GrTextureFlagBit;
288 desc.fWidth = resultCount; 288 desc.fWidth = resultCount;
289 desc.fHeight = 30; 289 desc.fHeight = 30;
290 desc.fSampleCnt = 0; 290 desc.fSampleCnt = 0;
291 291
292 SkAutoTUnref<GrTexture> texture(grContext->createUncachedTexture(desc, NULL, 0)); 292 SkAutoTUnref<GrTexture> texture(grContext->createUncachedTexture(desc, NULL, 0));
293 SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (grContext, texture .get()))); 293 SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (grContext, texture .get())));
294 SkCanvas canvas(device.get()); 294 SkCanvas canvas(device.get());
295 295
296 blur_path(&canvas, path, gaussianSigma); 296 blur_path(&canvas, path, gaussianSigma);
297 readback(&canvas, result, resultCount); 297 readback(&canvas, result, resultCount);
298 return true;
298 } 299 }
299 #endif 300 #endif
300 301
301 #if WRITE_CSV 302 #if WRITE_CSV
302 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 ) {
303 SkDebugf("%s_%.2f,", label, scale); 304 SkDebugf("%s_%.2f,", label, scale);
304 for (int i = 0; i < count-1; ++i) { 305 for (int i = 0; i < count-1; ++i) {
305 SkDebugf("%d,", data[i]); 306 SkDebugf("%d,", data[i]);
306 } 307 }
307 SkDebugf("%d\n", data[count-1]); 308 SkDebugf("%d\n", data[count-1]);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 int groundTruthResult[kSize]; 349 int groundTruthResult[kSize];
349 int bruteForce1DResult[kSize]; 350 int bruteForce1DResult[kSize];
350 351
351 SkScalar sigma = SkFloatToScalar(10.0f); 352 SkScalar sigma = SkFloatToScalar(10.0f);
352 353
353 for (int i = 0; i < 4; ++i, sigma /= 10) { 354 for (int i = 0; i < 4; ++i, sigma /= 10) {
354 355
355 cpu_blur_path(rectPath, sigma, rectSpecialCaseResult, kSize); 356 cpu_blur_path(rectPath, sigma, rectSpecialCaseResult, kSize);
356 cpu_blur_path(polyPath, sigma, generalCaseResult, kSize); 357 cpu_blur_path(polyPath, sigma, generalCaseResult, kSize);
357 #if SK_SUPPORT_GPU 358 #if SK_SUPPORT_GPU
358 gpu_blur_path(factory, rectPath, sigma, gpuResult, kSize); 359 bool haveGPUResult = gpu_blur_path(factory, rectPath, sigma, gpuResult, kSize);
359 #endif 360 #endif
360 ground_truth_2d(100, 100, sigma, groundTruthResult, kSize); 361 ground_truth_2d(100, 100, sigma, groundTruthResult, kSize);
361 brute_force_1d(-50.0f, 50.0f, sigma, bruteForce1DResult, kSize); 362 brute_force_1d(-50.0f, 50.0f, sigma, bruteForce1DResult, kSize);
362 363
363 REPORTER_ASSERT(reporter, match(rectSpecialCaseResult, bruteForce1DResul t, kSize, 5)); 364 REPORTER_ASSERT(reporter, match(rectSpecialCaseResult, bruteForce1DResul t, kSize, 5));
364 REPORTER_ASSERT(reporter, match(generalCaseResult, bruteForce1DResult, k Size, 15)); 365 REPORTER_ASSERT(reporter, match(generalCaseResult, bruteForce1DResult, k Size, 15));
365 #if SK_SUPPORT_GPU 366 #if SK_SUPPORT_GPU
robertphillips 2013/11/14 14:21:41 This addresses (since gpuResult wasn't getting fil
366 // 1 works everywhere but: Ubuntu13 & Nexus4 367 if (haveGPUResult) {
367 REPORTER_ASSERT(reporter, match(gpuResult, bruteForce1DResult, kSize, 10 )); 368 // 1 works everywhere but: Ubuntu13 & Nexus4
369 REPORTER_ASSERT(reporter, match(gpuResult, bruteForce1DResult, kSize , 10));
370 }
368 #endif 371 #endif
369 REPORTER_ASSERT(reporter, match(groundTruthResult, bruteForce1DResult, k Size, 1)); 372 REPORTER_ASSERT(reporter, match(groundTruthResult, bruteForce1DResult, k Size, 1));
370 373
371 #if WRITE_CSV 374 #if WRITE_CSV
372 write_as_csv("RectSpecialCase", sigma, rectSpecialCaseResult, kSize); 375 write_as_csv("RectSpecialCase", sigma, rectSpecialCaseResult, kSize);
373 write_as_csv("GeneralCase", sigma, generalCaseResult, kSize); 376 write_as_csv("GeneralCase", sigma, generalCaseResult, kSize);
374 #if SK_SUPPORT_GPU 377 #if SK_SUPPORT_GPU
375 write_as_csv("GPU", sigma, gpuResult, kSize); 378 write_as_csv("GPU", sigma, gpuResult, kSize);
376 #endif 379 #endif
377 write_as_csv("GroundTruth2D", sigma, groundTruthResult, kSize); 380 write_as_csv("GroundTruth2D", sigma, groundTruthResult, kSize);
378 write_as_csv("BruteForce1D", sigma, bruteForce1DResult, kSize); 381 write_as_csv("BruteForce1D", sigma, bruteForce1DResult, kSize);
379 #endif 382 #endif
380 } 383 }
381 } 384 }
382 385
383 /////////////////////////////////////////////////////////////////////////////// 386 ///////////////////////////////////////////////////////////////////////////////
384 387
385 static void test_blur(skiatest::Reporter* reporter, GrContextFactory* factory) { 388 static void test_blur(skiatest::Reporter* reporter, GrContextFactory* factory) {
386 test_blur_drawing(reporter); 389 test_blur_drawing(reporter);
387 test_sigma_range(reporter, factory); 390 test_sigma_range(reporter, factory);
388 } 391 }
389 392
390 #include "TestClassDef.h" 393 #include "TestClassDef.h"
391 DEFINE_GPUTESTCLASS("BlurMaskFilter", BlurTestClass, test_blur) 394 DEFINE_GPUTESTCLASS("BlurMaskFilter", BlurTestClass, test_blur)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698