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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 1389063002: Revert of factories should return baseclass, allowing the impl to specialize (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/effects/SkTileImageFilter.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 2013 Google Inc. 2 * Copyright 2013 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapDevice.h" 9 #include "SkBitmapDevice.h"
10 #include "SkBlurImageFilter.h" 10 #include "SkBlurImageFilter.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 ); 347 );
348 SkPaint paint; 348 SkPaint paint;
349 paint.setShader(shader); 349 paint.setShader(shader);
350 canvas.drawCircle(x, y, radius, paint); 350 canvas.drawCircle(x, y, radius, paint);
351 return bitmap; 351 return bitmap;
352 } 352 }
353 353
354 static void test_negative_blur_sigma(SkImageFilter::Proxy* proxy, skiatest::Repo rter* reporter) { 354 static void test_negative_blur_sigma(SkImageFilter::Proxy* proxy, skiatest::Repo rter* reporter) {
355 // Check that SkBlurImageFilter will accept a negative sigma, either in 355 // Check that SkBlurImageFilter will accept a negative sigma, either in
356 // the given arguments or after CTM application. 356 // the given arguments or after CTM application.
357 const int width = 32, height = 32; 357 int width = 32, height = 32;
358 const SkScalar five = SkIntToScalar(5); 358 SkScalar five = SkIntToScalar(5);
359 359
360 SkAutoTUnref<SkImageFilter> positiveFilter(SkBlurImageFilter::Create(five, f ive)); 360 SkAutoTUnref<SkBlurImageFilter> positiveFilter(
361 SkAutoTUnref<SkImageFilter> negativeFilter(SkBlurImageFilter::Create(-five, five)); 361 SkBlurImageFilter::Create(five, five)
362 );
363
364 SkAutoTUnref<SkBlurImageFilter> negativeFilter(
365 SkBlurImageFilter::Create(-five, five)
366 );
362 367
363 SkBitmap gradient = make_gradient_circle(width, height); 368 SkBitmap gradient = make_gradient_circle(width, height);
364 SkBitmap positiveResult1, negativeResult1; 369 SkBitmap positiveResult1, negativeResult1;
365 SkBitmap positiveResult2, negativeResult2; 370 SkBitmap positiveResult2, negativeResult2;
366 SkIPoint offset; 371 SkIPoint offset;
367 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr); 372 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr);
368 positiveFilter->filterImage(proxy, gradient, ctx, &positiveResult1, &offset) ; 373 positiveFilter->filterImage(proxy, gradient, ctx, &positiveResult1, &offset) ;
369 negativeFilter->filterImage(proxy, gradient, ctx, &negativeResult1, &offset) ; 374 negativeFilter->filterImage(proxy, gradient, ctx, &negativeResult1, &offset) ;
370 SkMatrix negativeScale; 375 SkMatrix negativeScale;
371 negativeScale.setScale(-SK_Scalar1, SK_Scalar1); 376 negativeScale.setScale(-SK_Scalar1, SK_Scalar1);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 // match the same filters drawn with a single full-canvas bitmap draw. 415 // match the same filters drawn with a single full-canvas bitmap draw.
411 // Tests pass by not asserting. 416 // Tests pass by not asserting.
412 417
413 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED, SkXfermode::kSrcIn_Mode)); 418 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED, SkXfermode::kSrcIn_Mode));
414 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); 419 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1);
415 SkScalar kernel[9] = { 420 SkScalar kernel[9] = {
416 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), 421 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1),
417 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), 422 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1),
418 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), 423 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1),
419 }; 424 };
420 const SkISize kernelSize = SkISize::Make(3, 3); 425 SkISize kernelSize = SkISize::Make(3, 3);
421 const SkScalar gain = SK_Scalar1, bias = 0; 426 SkScalar gain = SK_Scalar1, bias = 0;
422 const SkScalar five = SkIntToScalar(5); 427 SkScalar five = SkIntToScalar(5);
423 428
424 SkAutoTUnref<SkImage> gradientImage(SkImage::NewFromBitmap(make_gradient_cir cle(64, 64))); 429 SkAutoTUnref<SkImage> gradientImage(SkImage::NewFromBitmap(make_gradient_cir cle(64, 64)));
425 SkAutoTUnref<SkImageFilter> gradientSource(SkImageSource::Create(gradientIma ge)); 430 SkAutoTUnref<SkImageFilter> gradientSource(SkImageSource::Create(gradientIma ge));
426 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(five, five)); 431 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(five, five));
427 SkMatrix matrix; 432 SkMatrix matrix;
428 433
429 matrix.setTranslate(SK_Scalar1, SK_Scalar1); 434 matrix.setTranslate(SK_Scalar1, SK_Scalar1);
430 matrix.postRotate(SkIntToScalar(45), SK_Scalar1, SK_Scalar1); 435 matrix.postRotate(SkIntToScalar(45), SK_Scalar1, SK_Scalar1);
431 436
432 SkRTreeFactory factory; 437 SkRTreeFactory factory;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 { "erode", SkErodeImageFilter::Create(2, 3) }, 482 { "erode", SkErodeImageFilter::Create(2, 3) },
478 { "tile", SkTileImageFilter::Create(SkRect::MakeXYWH(0, 0, 50, 50), 483 { "tile", SkTileImageFilter::Create(SkRect::MakeXYWH(0, 0, 50, 50),
479 SkRect::MakeXYWH(0, 0, 100, 100), nu llptr) }, 484 SkRect::MakeXYWH(0, 0, 100, 100), nu llptr) },
480 { "matrix", SkImageFilter::CreateMatrixFilter(matrix, kLow_SkFilterQuali ty) }, 485 { "matrix", SkImageFilter::CreateMatrixFilter(matrix, kLow_SkFilterQuali ty) },
481 { "blur and offset", SkOffsetImageFilter::Create(five, five, blur.get()) }, 486 { "blur and offset", SkOffsetImageFilter::Create(five, five, blur.get()) },
482 { "picture and blur", SkBlurImageFilter::Create(five, five, pictureFilte r.get()) }, 487 { "picture and blur", SkBlurImageFilter::Create(five, five, pictureFilte r.get()) },
483 { "rect shader and blur", SkBlurImageFilter::Create(five, five, rectShad erFilter.get()) }, 488 { "rect shader and blur", SkBlurImageFilter::Create(five, five, rectShad erFilter.get()) },
484 }; 489 };
485 490
486 SkBitmap untiledResult, tiledResult; 491 SkBitmap untiledResult, tiledResult;
487 const int width = 64, height = 64; 492 int width = 64, height = 64;
488 untiledResult.allocN32Pixels(width, height); 493 untiledResult.allocN32Pixels(width, height);
489 tiledResult.allocN32Pixels(width, height); 494 tiledResult.allocN32Pixels(width, height);
490 SkCanvas tiledCanvas(tiledResult); 495 SkCanvas tiledCanvas(tiledResult);
491 SkCanvas untiledCanvas(untiledResult); 496 SkCanvas untiledCanvas(untiledResult);
492 int tileSize = 8; 497 int tileSize = 8;
493 498
494 for (int scale = 1; scale <= 2; ++scale) { 499 for (int scale = 1; scale <= 2; ++scale) {
495 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { 500 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
496 tiledCanvas.clear(0); 501 tiledCanvas.clear(0);
497 untiledCanvas.clear(0); 502 untiledCanvas.clear(0);
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 SkSurface::kNo_Budgeted , 1309 SkSurface::kNo_Budgeted ,
1305 SkImageInfo::MakeN32Pre mul(1, 1), 1310 SkImageInfo::MakeN32Pre mul(1, 1),
1306 0, 1311 0,
1307 &props, 1312 &props,
1308 SkGpuDevice::kUninit_In itContents)); 1313 SkGpuDevice::kUninit_In itContents));
1309 SkImageFilter::Proxy proxy(device); 1314 SkImageFilter::Proxy proxy(device);
1310 1315
1311 test_negative_blur_sigma(&proxy, reporter); 1316 test_negative_blur_sigma(&proxy, reporter);
1312 } 1317 }
1313 #endif 1318 #endif
OLDNEW
« no previous file with comments | « src/effects/SkTileImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698