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 "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 462 |
463 for (int y = 0; y < height; y++) { | 463 for (int y = 0; y < height; y++) { |
464 int diffs = memcmp(result1.getAddr32(0, y), result2.getAddr32(0, y), res
ult1.rowBytes()); | 464 int diffs = memcmp(result1.getAddr32(0, y), result2.getAddr32(0, y), res
ult1.rowBytes()); |
465 REPORTER_ASSERT(reporter, !diffs); | 465 REPORTER_ASSERT(reporter, !diffs); |
466 if (diffs) { | 466 if (diffs) { |
467 break; | 467 break; |
468 } | 468 } |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
| 472 static SkImageFilter* makeBlur(SkImageFilter* input = NULL) { |
| 473 return SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1, input); |
| 474 } |
| 475 |
| 476 static SkImageFilter* makeDropShadow(SkImageFilter* input = NULL) { |
| 477 return SkDropShadowImageFilter::Create( |
| 478 SkIntToScalar(100), SkIntToScalar(100), |
| 479 SkIntToScalar(10), SkIntToScalar(10), |
| 480 SK_ColorBLUE, input); |
| 481 } |
| 482 |
| 483 DEF_TEST(ImageFilterBlurThenShadowBounds, reporter) { |
| 484 SkAutoTUnref<SkImageFilter> filter1(makeBlur()); |
| 485 SkAutoTUnref<SkImageFilter> filter2(makeDropShadow(filter1.get())); |
| 486 |
| 487 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); |
| 488 SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236); |
| 489 filter2->filterBounds(bounds, SkMatrix::I(), &bounds); |
| 490 |
| 491 REPORTER_ASSERT(reporter, bounds == expectedBounds); |
| 492 } |
| 493 |
| 494 DEF_TEST(ImageFilterShadowThenBlurBounds, reporter) { |
| 495 SkAutoTUnref<SkImageFilter> filter1(makeDropShadow()); |
| 496 SkAutoTUnref<SkImageFilter> filter2(makeBlur(filter1.get())); |
| 497 |
| 498 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); |
| 499 SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236); |
| 500 filter2->filterBounds(bounds, SkMatrix::I(), &bounds); |
| 501 |
| 502 REPORTER_ASSERT(reporter, bounds == expectedBounds); |
| 503 } |
| 504 |
| 505 DEF_TEST(ImageFilterDilateThenBlurBounds, reporter) { |
| 506 SkAutoTUnref<SkImageFilter> filter1(SkDilateImageFilter::Create(2, 2)); |
| 507 SkAutoTUnref<SkImageFilter> filter2(makeDropShadow(filter1.get())); |
| 508 |
| 509 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); |
| 510 SkIRect expectedBounds = SkIRect::MakeXYWH(-132, -132, 234, 234); |
| 511 filter2->filterBounds(bounds, SkMatrix::I(), &bounds); |
| 512 |
| 513 REPORTER_ASSERT(reporter, bounds == expectedBounds); |
| 514 } |
| 515 |
472 static void drawBlurredRect(SkCanvas* canvas) { | 516 static void drawBlurredRect(SkCanvas* canvas) { |
473 SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(SkIntToScalar(8
), 0)); | 517 SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(SkIntToScalar(8
), 0)); |
474 SkPaint filterPaint; | 518 SkPaint filterPaint; |
475 filterPaint.setColor(SK_ColorWHITE); | 519 filterPaint.setColor(SK_ColorWHITE); |
476 filterPaint.setImageFilter(filter); | 520 filterPaint.setImageFilter(filter); |
477 canvas->saveLayer(NULL, &filterPaint); | 521 canvas->saveLayer(NULL, &filterPaint); |
478 SkPaint whitePaint; | 522 SkPaint whitePaint; |
479 whitePaint.setColor(SK_ColorWHITE); | 523 whitePaint.setColor(SK_ColorWHITE); |
480 canvas->drawRect(SkRect::Make(SkIRect::MakeWH(4, 4)), whitePaint); | 524 canvas->drawRect(SkRect::Make(SkIRect::MakeWH(4, 4)), whitePaint); |
481 canvas->restore(); | 525 canvas->restore(); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 } | 953 } |
910 | 954 |
911 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { | 955 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { |
912 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 956 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
913 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 957 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
914 SkImageInfo::MakeN32Pre
mul(1, 1), | 958 SkImageInfo::MakeN32Pre
mul(1, 1), |
915 0)); | 959 0)); |
916 test_xfermode_cropped_input(device, reporter); | 960 test_xfermode_cropped_input(device, reporter); |
917 } | 961 } |
918 #endif | 962 #endif |
OLD | NEW |