Index: tests/ImageFilterTest.cpp |
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp |
index 55499d74c37058e79b035ec230743c6996c61899..fd7cfed486ea834d320badd31d7888b39a1eaca6 100644 |
--- a/tests/ImageFilterTest.cpp |
+++ b/tests/ImageFilterTest.cpp |
@@ -12,6 +12,7 @@ |
#include "SkCanvas.h" |
#include "SkColorFilterImageFilter.h" |
#include "SkColorMatrixFilter.h" |
+#include "SkComposeImageFilter.h" |
#include "SkDeviceImageFilterProxy.h" |
#include "SkDisplacementMapEffect.h" |
#include "SkDropShadowImageFilter.h" |
@@ -584,6 +585,20 @@ DEF_TEST(ImageFilterDilateThenBlurBounds, reporter) { |
REPORTER_ASSERT(reporter, bounds == expectedBounds); |
} |
+DEF_TEST(ImageFilterComposedBlurFastBounds, reporter) { |
+ SkAutoTUnref<SkImageFilter> filter1(makeBlur()); |
+ SkAutoTUnref<SkImageFilter> filter2(makeBlur()); |
+ SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(filter1.get(), filter2.get())); |
+ |
+ SkRect boundsSrc = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); |
+ SkRect expectedBounds = SkRect::MakeXYWH( |
+ SkIntToScalar(-6), SkIntToScalar(-6), SkIntToScalar(112), SkIntToScalar(112)); |
+ SkRect boundsDst = SkRect::MakeEmpty(); |
+ composedFilter->computeFastBounds(boundsSrc, &boundsDst); |
+ |
+ REPORTER_ASSERT(reporter, boundsDst == expectedBounds); |
+} |
+ |
static void draw_blurred_rect(SkCanvas* canvas) { |
SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(SkIntToScalar(8), 0)); |
SkPaint filterPaint; |
@@ -1068,6 +1083,23 @@ DEF_TEST(XfermodeImageFilterCroppedInput, reporter) { |
test_xfermode_cropped_input(&device, reporter); |
} |
+DEF_TEST(ComposedImageFilterOffset, reporter) { |
+ SkBitmap bitmap; |
+ bitmap.allocN32Pixels(100, 100); |
+ bitmap.eraseARGB(0, 0, 0, 0); |
+ SkBitmapDevice device(bitmap); |
+ SkDeviceImageFilterProxy proxy(&device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)); |
+ |
+ SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20)); |
+ SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, NULL, &cropRect)); |
+ SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(makeBlur(), offsetFilter.get())); |
+ SkBitmap result; |
+ SkIPoint offset; |
+ SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL); |
+ REPORTER_ASSERT(reporter, composedFilter->filterImage(&proxy, bitmap, ctx, &result, &offset)); |
+ REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0); |
+} |
+ |
#if SK_SUPPORT_GPU |
const SkSurfaceProps gProps = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); |