aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@chromium.org>2016-05-13 07:25:44 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-13 07:25:44 -0700
commite6f0d6e5feb9644816f7e6770507351e36c11115 (patch)
tree73a622014e9fca4251ceff7422c941804e08c7b6 /gm
parent6ce4b003a2626d8eaf4b28b32cdbad9068bec118 (diff)
GMs: fail gracefully for null surface
A couple more instances where MakeRenderTarget returns nullptr due to --preAbandonGpuContext. BUG=skia5282 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1976163002 Review-Url: https://codereview.chromium.org/1976163002
Diffstat (limited to 'gm')
-rw-r--r--gm/image.cpp1
-rw-r--r--gm/image_pict.cpp16
2 files changed, 12 insertions, 5 deletions
diff --git a/gm/image.cpp b/gm/image.cpp
index a84e19b3f7..b57ec3a687 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -258,6 +258,7 @@ static sk_sp<SkImage> make_codec(const SkImageInfo& info, GrContext*, void (*dra
static sk_sp<SkImage> make_gpu(const SkImageInfo& info, GrContext* ctx, void (*draw)(SkCanvas*)) {
if (!ctx) { return nullptr; }
auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
+ if (!surface) { return nullptr; }
draw(surface->getCanvas());
return surface->makeImageSnapshot();
}
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index fd7ac2adb1..9d1dc513a8 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -212,11 +212,13 @@ public:
, fCtx(SkRef(ctx))
{
auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
- surface->getCanvas()->clear(0);
- surface->getCanvas()->translate(-100, -100);
- surface->getCanvas()->drawPicture(pic);
- sk_sp<SkImage> image(surface->makeImageSnapshot());
- fTexture.reset(SkRef(as_IB(image)->peekTexture()));
+ if (surface) {
+ surface->getCanvas()->clear(0);
+ surface->getCanvas()->translate(-100, -100);
+ surface->getCanvas()->drawPicture(pic);
+ sk_sp<SkImage> image(surface->makeImageSnapshot());
+ fTexture.reset(SkRef(as_IB(image)->peekTexture()));
+ }
}
protected:
GrTexture* onGenerateTexture(GrContext* ctx, const SkIRect* subset) override {
@@ -224,6 +226,10 @@ protected:
SkASSERT(ctx == fCtx.get());
}
+ if (!fTexture) {
+ return nullptr;
+ }
+
if (!subset) {
return SkRef(fTexture.get());
}