aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2015-07-13 10:27:05 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-13 10:27:05 -0700
commit24d2a7b463d585f9300ceac946431e822531d504 (patch)
tree512b294e76cdcb5e7b55aa6a5c68023cbd19651c /tests
parent4421a4c90df48931758cdb747d5be80edb56cd12 (diff)
Fix for partially-specified crop rects.
When only the left or top edge of a crop rect is given, the right and bottom should be computed based on the incoming width and height, not based on the crop rect's width & height. This complies more accurately with SVG semantics. BUG=240827 Review URL: https://codereview.chromium.org/1232873002
Diffstat (limited to 'tests')
-rw-r--r--tests/ImageFilterTest.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 480a75fe1d..dc35332593 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -1139,6 +1139,27 @@ DEF_TEST(ComposedImageFilterOffset, reporter) {
REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0);
}
+DEF_TEST(PartialCropRect, reporter) {
+ SkBitmap bitmap;
+ bitmap.allocN32Pixels(100, 100);
+ bitmap.eraseARGB(0, 0, 0, 0);
+ const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ SkBitmapDevice device(bitmap, props);
+ SkImageFilter::Proxy proxy(&device);
+
+ SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(100, 0, 20, 30),
+ SkImageFilter::CropRect::kHasRight_CropEdge | SkImageFilter::CropRect::kHasBottom_CropEdge);
+ SkAutoTUnref<SkImageFilter> filter(make_grayscale(NULL, &cropRect));
+ SkBitmap result;
+ SkIPoint offset;
+ SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL);
+ REPORTER_ASSERT(reporter, filter->filterImage(&proxy, bitmap, ctx, &result, &offset));
+ REPORTER_ASSERT(reporter, offset.fX == 0);
+ REPORTER_ASSERT(reporter, offset.fY == 0);
+ REPORTER_ASSERT(reporter, result.width() == 20);
+ REPORTER_ASSERT(reporter, result.height() == 30);
+}
+
#if SK_SUPPORT_GPU
DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) {