aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
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());
}