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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 | 635 |
636 SkRect boundsSrc = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); | 636 SkRect boundsSrc = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); |
637 SkRect expectedBounds = SkRect::MakeXYWH( | 637 SkRect expectedBounds = SkRect::MakeXYWH( |
638 SkIntToScalar(-6), SkIntToScalar(-6), SkIntToScalar(112), SkIntToScalar(
112)); | 638 SkIntToScalar(-6), SkIntToScalar(-6), SkIntToScalar(112), SkIntToScalar(
112)); |
639 SkRect boundsDst = SkRect::MakeEmpty(); | 639 SkRect boundsDst = SkRect::MakeEmpty(); |
640 composedFilter->computeFastBounds(boundsSrc, &boundsDst); | 640 composedFilter->computeFastBounds(boundsSrc, &boundsDst); |
641 | 641 |
642 REPORTER_ASSERT(reporter, boundsDst == expectedBounds); | 642 REPORTER_ASSERT(reporter, boundsDst == expectedBounds); |
643 } | 643 } |
644 | 644 |
| 645 DEF_TEST(ImageFilterMergeResultSize, reporter) { |
| 646 SkBitmap greenBM; |
| 647 greenBM.allocN32Pixels(20, 20); |
| 648 greenBM.eraseColor(SK_ColorGREEN); |
| 649 SkAutoTUnref<SkImage> greenImage(SkImage::NewFromBitmap(greenBM)); |
| 650 SkAutoTUnref<SkImageFilter> source(SkImageSource::Create(greenImage.get())); |
| 651 SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(source.get(), s
ource.get())); |
| 652 |
| 653 SkBitmap bitmap; |
| 654 bitmap.allocN32Pixels(1, 1); |
| 655 bitmap.eraseColor(0); |
| 656 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
| 657 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 658 SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props)); |
| 659 SkImageFilter::DeviceProxy proxy(device); |
| 660 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 100, 100),
nullptr, |
| 661 SkImageFilter::kApprox_SizeConstraint); |
| 662 SkBitmap result; |
| 663 SkIPoint offset; |
| 664 REPORTER_ASSERT(reporter, merge->filterImage(&proxy, bitmap, ctx, &result, &
offset)); |
| 665 REPORTER_ASSERT(reporter, result.width() == 20 && result.height() == 20); |
| 666 } |
| 667 |
645 static void draw_blurred_rect(SkCanvas* canvas) { | 668 static void draw_blurred_rect(SkCanvas* canvas) { |
646 SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(SkIntToScalar(8
), 0)); | 669 SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(SkIntToScalar(8
), 0)); |
647 SkPaint filterPaint; | 670 SkPaint filterPaint; |
648 filterPaint.setColor(SK_ColorWHITE); | 671 filterPaint.setColor(SK_ColorWHITE); |
649 filterPaint.setImageFilter(filter); | 672 filterPaint.setImageFilter(filter); |
650 canvas->saveLayer(nullptr, &filterPaint); | 673 canvas->saveLayer(nullptr, &filterPaint); |
651 SkPaint whitePaint; | 674 SkPaint whitePaint; |
652 whitePaint.setColor(SK_ColorWHITE); | 675 whitePaint.setColor(SK_ColorWHITE); |
653 canvas->drawRect(SkRect::Make(SkIRect::MakeWH(4, 4)), whitePaint); | 676 canvas->drawRect(SkRect::Make(SkIRect::MakeWH(4, 4)), whitePaint); |
654 canvas->restore(); | 677 canvas->restore(); |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 SkSurface::kNo_Budgeted
, | 1326 SkSurface::kNo_Budgeted
, |
1304 SkImageInfo::MakeN32Pre
mul(1, 1), | 1327 SkImageInfo::MakeN32Pre
mul(1, 1), |
1305 0, | 1328 0, |
1306 &props, | 1329 &props, |
1307 SkGpuDevice::kUninit_In
itContents)); | 1330 SkGpuDevice::kUninit_In
itContents)); |
1308 SkImageFilter::DeviceProxy proxy(device); | 1331 SkImageFilter::DeviceProxy proxy(device); |
1309 | 1332 |
1310 test_negative_blur_sigma(&proxy, reporter); | 1333 test_negative_blur_sigma(&proxy, reporter); |
1311 } | 1334 } |
1312 #endif | 1335 #endif |
OLD | NEW |