aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ImageTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ImageTest.cpp')
-rw-r--r--tests/ImageTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 6cc0fee4d9..83b1c7983d 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -29,6 +29,7 @@
#include "Test.h"
#include "Resources.h"
+#include "sk_pixel_iter.h"
#include "sk_tool_utils.h"
#if SK_SUPPORT_GPU
@@ -1392,3 +1393,32 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageScalePixels_Gpu, reporter, ctxInfo) {
test_scale_pixels(reporter, gpuImage.get(), pmRed);
}
#endif
+
+static sk_sp<SkImage> any_image_will_do() {
+ return GetResourceAsImage("images/mandrill_32.png");
+}
+
+DEF_TEST(Image_nonfinite_dst, reporter) {
+ auto surf = SkSurface::MakeRasterN32Premul(10, 10);
+ auto img = any_image_will_do();
+ SkPaint paint;
+
+ for (SkScalar bad : { SK_ScalarInfinity, SK_ScalarNaN}) {
+ for (int bits = 1; bits <= 15; ++bits) {
+ SkRect dst = { 0, 0, 10, 10 };
+ if (bits & 1) dst.fLeft = bad;
+ if (bits & 2) dst.fTop = bad;
+ if (bits & 4) dst.fRight = bad;
+ if (bits & 8) dst.fBottom = bad;
+
+ surf->getCanvas()->drawImageRect(img, dst, &paint);
+
+ // we should draw nothing
+ sk_tool_utils::PixelIter iter(surf.get());
+ while (void* addr = iter.next()) {
+ REPORTER_ASSERT(reporter, *(SkPMColor*)addr == 0);
+ }
+ }
+ }
+}
+