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

Side by Side Diff: tests/BlurTest.cpp

Issue 1448873002: Generate list of GPU contexts outside tests (Closed) Base URL: https://skia.googlesource.com/skia.git@commandbuffer-as-api-01-gpu-test-context-support
Patch Set: rebase, remove a hunk Created 5 years 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 | « no previous file | tests/ClipBoundsTest.cpp » ('j') | 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 refColor = bgColor; 92 refColor = bgColor;
93 } 93 }
94 if (refColor != testColor) { 94 if (refColor != testColor) {
95 return false; 95 return false;
96 } 96 }
97 } 97 }
98 } 98 }
99 return true; 99 return true;
100 } 100 }
101 101
102 static void test_blur_drawing(skiatest::Reporter* reporter) { 102 DEF_TEST(BlurDrawing, reporter) {
103
104 SkPaint paint; 103 SkPaint paint;
105 paint.setColor(SK_ColorGRAY); 104 paint.setColor(SK_ColorGRAY);
106 paint.setStyle(SkPaint::kStroke_Style); 105 paint.setStyle(SkPaint::kStroke_Style);
107 paint.setStrokeWidth(SkIntToScalar(strokeWidth)); 106 paint.setStrokeWidth(SkIntToScalar(strokeWidth));
108 107
109 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)); 108 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5));
110 for (int style = 0; style <= kLastEnum_SkBlurStyle; ++style) { 109 for (int style = 0; style <= kLastEnum_SkBlurStyle; ++style) {
111 SkBlurStyle blurStyle = static_cast<SkBlurStyle>(style); 110 SkBlurStyle blurStyle = static_cast<SkBlurStyle>(style);
112 111
113 const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag; 112 const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 bitmap.allocN32Pixels(resultCount, 30); 268 bitmap.allocN32Pixels(resultCount, 30);
270 SkCanvas canvas(bitmap); 269 SkCanvas canvas(bitmap);
271 270
272 blur_path(&canvas, path, gaussianSigma); 271 blur_path(&canvas, path, gaussianSigma);
273 readback(&canvas, result, resultCount); 272 readback(&canvas, result, resultCount);
274 } 273 }
275 274
276 #if SK_SUPPORT_GPU 275 #if SK_SUPPORT_GPU
277 #if 0 276 #if 0
278 // temporary disable; see below for explanation 277 // temporary disable; see below for explanation
279 static bool gpu_blur_path(GrContextFactory* factory, const SkPath& path, 278 static bool gpu_blur_path(GrContext* context, const SkPath& path,
280 SkScalar gaussianSigma, 279 SkScalar gaussianSigma,
281 int* result, int resultCount) { 280 int* result, int resultCount) {
282
283 GrContext* grContext = factory->get(GrContextFactory::kNative_GLContextType) ;
284 if (nullptr == grContext) {
285 return false;
286 }
287
288 GrSurfaceDesc desc; 281 GrSurfaceDesc desc;
289 desc.fConfig = kSkia8888_GrPixelConfig; 282 desc.fConfig = kSkia8888_GrPixelConfig;
290 desc.fFlags = kRenderTarget_GrSurfaceFlag; 283 desc.fFlags = kRenderTarget_GrSurfaceFlag;
291 desc.fWidth = resultCount; 284 desc.fWidth = resultCount;
292 desc.fHeight = 30; 285 desc.fHeight = 30;
293 desc.fSampleCnt = 0; 286 desc.fSampleCnt = 0;
294 287
295 SkAutoTUnref<GrTexture> texture(grContext->createTexture(desc, false, nullpt r, 0)); 288 SkAutoTUnref<GrTexture> texture(grContext->createTexture(desc, false, nullpt r, 0));
296 SkAutoTUnref<SkGpuDevice> device(new SkGpuDevice (grContext, texture.get()) ); 289 SkAutoTUnref<SkGpuDevice> device(new SkGpuDevice (grContext, texture.get()) );
297 SkCanvas canvas(device.get()); 290 SkCanvas canvas(device.get());
(...skipping 21 matching lines...) Expand all
319 delta = first[i] - second[i]; 312 delta = first[i] - second[i];
320 if (delta > tol || delta < -tol) { 313 if (delta > tol || delta < -tol) {
321 return false; 314 return false;
322 } 315 }
323 } 316 }
324 317
325 return true; 318 return true;
326 } 319 }
327 320
328 // Test out the normal blur style with a wide range of sigmas 321 // Test out the normal blur style with a wide range of sigmas
329 static void test_sigma_range(skiatest::Reporter* reporter, GrContextFactory* fac tory) { 322 DEF_GPUTEST_FOR_NATIVE_CONTEXT(BlurSigmaRange, reporter, context) {
bsalomon 2015/11/30 15:35:35 Might as well make these do all rendering contexts
Kimmo Kinnunen 2015/12/01 06:57:14 Done.
330
331 static const int kSize = 100; 323 static const int kSize = 100;
332 324
333 // The geometry is offset a smidge to trigger: 325 // The geometry is offset a smidge to trigger:
334 // https://code.google.com/p/chromium/issues/detail?id=282418 326 // https://code.google.com/p/chromium/issues/detail?id=282418
335 SkPath rectPath; 327 SkPath rectPath;
336 rectPath.addRect(0.3f, 0.3f, 100.3f, 100.3f); 328 rectPath.addRect(0.3f, 0.3f, 100.3f, 100.3f);
337 329
338 SkPoint polyPts[] = { 330 SkPoint polyPts[] = {
339 { 0.3f, 0.3f }, 331 { 0.3f, 0.3f },
340 { 100.3f, 0.3f }, 332 { 100.3f, 0.3f },
(...skipping 17 matching lines...) Expand all
358 cpu_blur_path(polyPath, sigma, generalCaseResult, kSize); 350 cpu_blur_path(polyPath, sigma, generalCaseResult, kSize);
359 351
360 ground_truth_2d(100, 100, sigma, groundTruthResult, kSize); 352 ground_truth_2d(100, 100, sigma, groundTruthResult, kSize);
361 brute_force_1d(-50.0f, 50.0f, sigma, bruteForce1DResult, kSize); 353 brute_force_1d(-50.0f, 50.0f, sigma, bruteForce1DResult, kSize);
362 354
363 REPORTER_ASSERT(reporter, match(rectSpecialCaseResult, bruteForce1DResul t, kSize, 5)); 355 REPORTER_ASSERT(reporter, match(rectSpecialCaseResult, bruteForce1DResul t, kSize, 5));
364 REPORTER_ASSERT(reporter, match(generalCaseResult, bruteForce1DResult, k Size, 15)); 356 REPORTER_ASSERT(reporter, match(generalCaseResult, bruteForce1DResult, k Size, 15));
365 #if SK_SUPPORT_GPU 357 #if SK_SUPPORT_GPU
366 #if 0 358 #if 0
367 int gpuResult[kSize]; 359 int gpuResult[kSize];
368 bool haveGPUResult = gpu_blur_path(factory, rectPath, sigma, gpuResult, kSize); 360 bool haveGPUResult = gpu_blur_path(context, rectPath, sigma, gpuResult, kSize);
369 // Disabling this test for now -- I don't think it's a legit comparison. 361 // Disabling this test for now -- I don't think it's a legit comparison.
370 // Will continue to investigate this. 362 // Will continue to investigate this.
371 if (haveGPUResult) { 363 if (haveGPUResult) {
372 // 1 works everywhere but: Ubuntu13 & Nexus4 364 // 1 works everywhere but: Ubuntu13 & Nexus4
373 REPORTER_ASSERT(reporter, match(gpuResult, bruteForce1DResult, kSize , 10)); 365 REPORTER_ASSERT(reporter, match(gpuResult, bruteForce1DResult, kSize , 10));
374 } 366 }
375 #endif 367 #endif
376 #endif 368 #endif
377 REPORTER_ASSERT(reporter, match(groundTruthResult, bruteForce1DResult, k Size, 1)); 369 REPORTER_ASSERT(reporter, match(groundTruthResult, bruteForce1DResult, k Size, 1));
378 370
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 make_blur_layer(&builder, mf); 492 make_blur_layer(&builder, mf);
501 test_delete_looper(reporter, builder.detachLooper(), sigma, style, quality, expectSuccess); 493 test_delete_looper(reporter, builder.detachLooper(), sigma, style, quality, expectSuccess);
502 494
503 // 3 layers is too many 495 // 3 layers is too many
504 make_noop_layer(&builder); 496 make_noop_layer(&builder);
505 make_blur_layer(&builder, mf); 497 make_blur_layer(&builder, mf);
506 make_noop_layer(&builder); 498 make_noop_layer(&builder);
507 test_delete_looper(reporter, builder.detachLooper(), sigma, style, quality, false); 499 test_delete_looper(reporter, builder.detachLooper(), sigma, style, quality, false);
508 } 500 }
509 501
510 static void test_asABlur(skiatest::Reporter* reporter) { 502 DEF_TEST(BlurAsABlur, reporter) {
511 const SkBlurStyle styles[] = { 503 const SkBlurStyle styles[] = {
512 kNormal_SkBlurStyle, kSolid_SkBlurStyle, kOuter_SkBlurStyle, kInner_SkBl urStyle 504 kNormal_SkBlurStyle, kSolid_SkBlurStyle, kOuter_SkBlurStyle, kInner_SkBl urStyle
513 }; 505 };
514 const SkScalar sigmas[] = { 506 const SkScalar sigmas[] = {
515 // values <= 0 should not success for a blur 507 // values <= 0 should not success for a blur
516 -1, 0, 0.5f, 2 508 -1, 0, 0.5f, 2
517 }; 509 };
518 510
519 // Test asABlur for SkBlurMaskFilter 511 // Test asABlur for SkBlurMaskFilter
520 // 512 //
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 if (mf.get()) { 551 if (mf.get()) {
560 SkMaskFilter::BlurRec rec; 552 SkMaskFilter::BlurRec rec;
561 bool success = mf->asABlur(&rec); 553 bool success = mf->asABlur(&rec);
562 REPORTER_ASSERT(reporter, !success); 554 REPORTER_ASSERT(reporter, !success);
563 } 555 }
564 } 556 }
565 } 557 }
566 } 558 }
567 559
568 //////////////////////////////////////////////////////////////////////////////// /////////// 560 //////////////////////////////////////////////////////////////////////////////// ///////////
569
570 DEF_GPUTEST(Blur, reporter, factory) {
571 test_blur_drawing(reporter);
572 test_sigma_range(reporter, factory);
573 test_asABlur(reporter);
574 }
OLDNEW
« no previous file with comments | « no previous file | tests/ClipBoundsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698