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

Unified Diff: tests/ImageFilterTest.cpp

Issue 908273002: Fix SkComposeImageFilter's bounds computation and offset handling (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Add curly braces Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkComposeImageFilter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/effects/SkComposeImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698