Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Unified Diff: gm/image_pict.cpp

Issue 1976163002: GMs: fail gracefully for null surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix another GM Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/image.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/image_pict.cpp
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index fd7ac2adb12089efffa2b6619a8c4b5ae6f8d6c4..9d1dc513a8cbd74eba522595d90cc5937f12a2a8 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());
}
« no previous file with comments | « gm/image.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698