OLD | NEW |
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 Loading... |
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 int width = 32, height = 32; | 357 const int width = 32, height = 32; |
358 SkScalar five = SkIntToScalar(5); | 358 const SkScalar five = SkIntToScalar(5); |
359 | 359 |
360 SkAutoTUnref<SkBlurImageFilter> positiveFilter( | 360 SkAutoTUnref<SkImageFilter> positiveFilter(SkBlurImageFilter::Create(five, f
ive)); |
361 SkBlurImageFilter::Create(five, five) | 361 SkAutoTUnref<SkImageFilter> negativeFilter(SkBlurImageFilter::Create(-five,
five)); |
362 ); | |
363 | |
364 SkAutoTUnref<SkBlurImageFilter> negativeFilter( | |
365 SkBlurImageFilter::Create(-five, five) | |
366 ); | |
367 | 362 |
368 SkBitmap gradient = make_gradient_circle(width, height); | 363 SkBitmap gradient = make_gradient_circle(width, height); |
369 SkBitmap positiveResult1, negativeResult1; | 364 SkBitmap positiveResult1, negativeResult1; |
370 SkBitmap positiveResult2, negativeResult2; | 365 SkBitmap positiveResult2, negativeResult2; |
371 SkIPoint offset; | 366 SkIPoint offset; |
372 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr); | 367 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr); |
373 positiveFilter->filterImage(proxy, gradient, ctx, &positiveResult1, &offset)
; | 368 positiveFilter->filterImage(proxy, gradient, ctx, &positiveResult1, &offset)
; |
374 negativeFilter->filterImage(proxy, gradient, ctx, &negativeResult1, &offset)
; | 369 negativeFilter->filterImage(proxy, gradient, ctx, &negativeResult1, &offset)
; |
375 SkMatrix negativeScale; | 370 SkMatrix negativeScale; |
376 negativeScale.setScale(-SK_Scalar1, SK_Scalar1); | 371 negativeScale.setScale(-SK_Scalar1, SK_Scalar1); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 // match the same filters drawn with a single full-canvas bitmap draw. | 410 // match the same filters drawn with a single full-canvas bitmap draw. |
416 // Tests pass by not asserting. | 411 // Tests pass by not asserting. |
417 | 412 |
418 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
SkXfermode::kSrcIn_Mode)); | 413 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
SkXfermode::kSrcIn_Mode)); |
419 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); | 414 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); |
420 SkScalar kernel[9] = { | 415 SkScalar kernel[9] = { |
421 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), | 416 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), |
422 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), | 417 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), |
423 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), | 418 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), |
424 }; | 419 }; |
425 SkISize kernelSize = SkISize::Make(3, 3); | 420 const SkISize kernelSize = SkISize::Make(3, 3); |
426 SkScalar gain = SK_Scalar1, bias = 0; | 421 const SkScalar gain = SK_Scalar1, bias = 0; |
427 SkScalar five = SkIntToScalar(5); | 422 const SkScalar five = SkIntToScalar(5); |
428 | 423 |
429 SkAutoTUnref<SkImage> gradientImage(SkImage::NewFromBitmap(make_gradient_cir
cle(64, 64))); | 424 SkAutoTUnref<SkImage> gradientImage(SkImage::NewFromBitmap(make_gradient_cir
cle(64, 64))); |
430 SkAutoTUnref<SkImageFilter> gradientSource(SkImageSource::Create(gradientIma
ge)); | 425 SkAutoTUnref<SkImageFilter> gradientSource(SkImageSource::Create(gradientIma
ge)); |
431 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(five, five)); | 426 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(five, five)); |
432 SkMatrix matrix; | 427 SkMatrix matrix; |
433 | 428 |
434 matrix.setTranslate(SK_Scalar1, SK_Scalar1); | 429 matrix.setTranslate(SK_Scalar1, SK_Scalar1); |
435 matrix.postRotate(SkIntToScalar(45), SK_Scalar1, SK_Scalar1); | 430 matrix.postRotate(SkIntToScalar(45), SK_Scalar1, SK_Scalar1); |
436 | 431 |
437 SkRTreeFactory factory; | 432 SkRTreeFactory factory; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 { "erode", SkErodeImageFilter::Create(2, 3) }, | 477 { "erode", SkErodeImageFilter::Create(2, 3) }, |
483 { "tile", SkTileImageFilter::Create(SkRect::MakeXYWH(0, 0, 50, 50), | 478 { "tile", SkTileImageFilter::Create(SkRect::MakeXYWH(0, 0, 50, 50), |
484 SkRect::MakeXYWH(0, 0, 100, 100), nu
llptr) }, | 479 SkRect::MakeXYWH(0, 0, 100, 100), nu
llptr) }, |
485 { "matrix", SkImageFilter::CreateMatrixFilter(matrix, kLow_SkFilterQuali
ty) }, | 480 { "matrix", SkImageFilter::CreateMatrixFilter(matrix, kLow_SkFilterQuali
ty) }, |
486 { "blur and offset", SkOffsetImageFilter::Create(five, five, blur.get())
}, | 481 { "blur and offset", SkOffsetImageFilter::Create(five, five, blur.get())
}, |
487 { "picture and blur", SkBlurImageFilter::Create(five, five, pictureFilte
r.get()) }, | 482 { "picture and blur", SkBlurImageFilter::Create(five, five, pictureFilte
r.get()) }, |
488 { "rect shader and blur", SkBlurImageFilter::Create(five, five, rectShad
erFilter.get()) }, | 483 { "rect shader and blur", SkBlurImageFilter::Create(five, five, rectShad
erFilter.get()) }, |
489 }; | 484 }; |
490 | 485 |
491 SkBitmap untiledResult, tiledResult; | 486 SkBitmap untiledResult, tiledResult; |
492 int width = 64, height = 64; | 487 const int width = 64, height = 64; |
493 untiledResult.allocN32Pixels(width, height); | 488 untiledResult.allocN32Pixels(width, height); |
494 tiledResult.allocN32Pixels(width, height); | 489 tiledResult.allocN32Pixels(width, height); |
495 SkCanvas tiledCanvas(tiledResult); | 490 SkCanvas tiledCanvas(tiledResult); |
496 SkCanvas untiledCanvas(untiledResult); | 491 SkCanvas untiledCanvas(untiledResult); |
497 int tileSize = 8; | 492 int tileSize = 8; |
498 | 493 |
499 for (int scale = 1; scale <= 2; ++scale) { | 494 for (int scale = 1; scale <= 2; ++scale) { |
500 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { | 495 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { |
501 tiledCanvas.clear(0); | 496 tiledCanvas.clear(0); |
502 untiledCanvas.clear(0); | 497 untiledCanvas.clear(0); |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 SkSurface::kNo_Budgeted
, | 1304 SkSurface::kNo_Budgeted
, |
1310 SkImageInfo::MakeN32Pre
mul(1, 1), | 1305 SkImageInfo::MakeN32Pre
mul(1, 1), |
1311 0, | 1306 0, |
1312 &props, | 1307 &props, |
1313 SkGpuDevice::kUninit_In
itContents)); | 1308 SkGpuDevice::kUninit_In
itContents)); |
1314 SkImageFilter::Proxy proxy(device); | 1309 SkImageFilter::Proxy proxy(device); |
1315 | 1310 |
1316 test_negative_blur_sigma(&proxy, reporter); | 1311 test_negative_blur_sigma(&proxy, reporter); |
1317 } | 1312 } |
1318 #endif | 1313 #endif |
OLD | NEW |