diff options
author | Robert Phillips <robertphillips@google.com> | 2018-07-13 10:18:38 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-13 14:59:44 +0000 |
commit | a07bf6788e926c41d52ae4bed592ec8a187ee4ab (patch) | |
tree | 4d5aa4edbab9a50f156129f4520551ad9e20df5d | |
parent | 7651c1611e6c158545d0d96b77a61418aec3939c (diff) |
Add bullet proofing to image_subset GM for TSAN failures
The most common TSAN failure is:
glmsaa8 gm image_subset
with this stack trace:
5.73m /b/s/w/ir/build/dm(_ZNK7SkImage10makeSubsetERK7SkIRect+0x96) [0x1a7c356]
/b/s/w/ir/build/dm(_ZNK7SkImage10makeSubsetERK7SkIRect+0x96) [0x1a7c356]
5.73m /b/s/w/ir/build/dm() [0x12cf587]
/b/s/w/ir/build/dm() [0x12cf587]
5.73m /b/s/w/ir/build/dm(_ZN6skiagm8SimpleGM6onDrawEP8SkCanvas+0x25) [0x12ba205]
Change-Id: Ife1c27af935ef3f56073360e9781a89fe8206586
Reviewed-on: https://skia-review.googlesource.com/141280
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r-- | gm/image.cpp | 10 | ||||
-rw-r--r-- | src/image/SkImage.cpp | 3 |
2 files changed, 10 insertions, 3 deletions
diff --git a/gm/image.cpp b/gm/image.cpp index 2592131334..1e3edc3292 100644 --- a/gm/image.cpp +++ b/gm/image.cpp @@ -399,8 +399,11 @@ DEF_SIMPLE_GM(scalepixels_unpremul, canvas, 1080, 280) { static sk_sp<SkImage> make_lazy_image(SkSurface* surf) { surf->getCanvas()->drawCircle(100, 100, 100, SkPaint()); - auto data = surf->makeImageSnapshot()->encodeToData(); - return SkImage::MakeFromEncoded(data); + sk_sp<SkData> data = surf->makeImageSnapshot()->encodeToData(); + if (!data) { + return nullptr; + } + return SkImage::MakeFromEncoded(std::move(data)); } #include "SkWriteBuffer.h" @@ -420,6 +423,9 @@ DEF_SIMPLE_GM(image_subset, canvas, 440, 220) { SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200, nullptr); auto surf = sk_tool_utils::makeSurface(canvas, info, nullptr); auto img = make_lazy_image(surf.get()); + if (!img) { + return; + } canvas->drawImage(img, 10, 10, nullptr); auto sub = img->makeSubset({100, 100, 200, 200}); diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index 53add0e9d3..da2780b03d 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -127,7 +127,8 @@ sk_sp<SkImage> SkImage::MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* su if (nullptr == encoded || 0 == encoded->size()) { return nullptr; } - return SkImage::MakeFromGenerator(SkImageGenerator::MakeFromEncoded(encoded), subset); + return SkImage::MakeFromGenerator(SkImageGenerator::MakeFromEncoded(std::move(encoded)), + subset); } /////////////////////////////////////////////////////////////////////////////////////////////////// |