diff options
author | Mike Reed <reed@google.com> | 2018-01-30 11:15:27 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-30 16:40:25 +0000 |
commit | c4e31092b13ed9563d567043613897f0112236cd (patch) | |
tree | fe38cb6fada736fe9ed7b0a79637a23a7372a27d /tests/ImageTest.cpp | |
parent | 31ac39c77c23db0d2aa23ec6a66beb6def8c9e33 (diff) |
don't draw images with nonfinite dst bounds
Bug: skia:
Change-Id: I95f32f8b9d6c47c3d95c0a19f7fdaaa6a648ef09
Reviewed-on: https://skia-review.googlesource.com/101745
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'tests/ImageTest.cpp')
-rw-r--r-- | tests/ImageTest.cpp | 30 |
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); + } + } + } +} + |