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

Side by Side Diff: gm/image.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 unified diff | Download patch
« no previous file with comments | « no previous file | gm/image_pict.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include <functional> 8 #include <functional>
9 #include "gm.h" 9 #include "gm.h"
10 #include "SkAutoPixmapStorage.h" 10 #include "SkAutoPixmapStorage.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 static sk_sp<SkImage> make_codec(const SkImageInfo& info, GrContext*, void (*dra w)(SkCanvas*)) { 252 static sk_sp<SkImage> make_codec(const SkImageInfo& info, GrContext*, void (*dra w)(SkCanvas*)) {
253 sk_sp<SkImage> image(make_raster(info, nullptr, draw)); 253 sk_sp<SkImage> image(make_raster(info, nullptr, draw));
254 sk_sp<SkData> data(image->encode()); 254 sk_sp<SkData> data(image->encode());
255 return SkImage::MakeFromEncoded(data); 255 return SkImage::MakeFromEncoded(data);
256 } 256 }
257 257
258 static sk_sp<SkImage> make_gpu(const SkImageInfo& info, GrContext* ctx, void (*d raw)(SkCanvas*)) { 258 static sk_sp<SkImage> make_gpu(const SkImageInfo& info, GrContext* ctx, void (*d raw)(SkCanvas*)) {
259 if (!ctx) { return nullptr; } 259 if (!ctx) { return nullptr; }
260 auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info)); 260 auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
261 if (!surface) { return nullptr; }
261 draw(surface->getCanvas()); 262 draw(surface->getCanvas());
262 return surface->makeImageSnapshot(); 263 return surface->makeImageSnapshot();
263 } 264 }
264 265
265 typedef sk_sp<SkImage> (*ImageMakerProc)(const SkImageInfo&, GrContext*, void (* )(SkCanvas*)); 266 typedef sk_sp<SkImage> (*ImageMakerProc)(const SkImageInfo&, GrContext*, void (* )(SkCanvas*));
266 267
267 class ScalePixelsGM : public skiagm::GM { 268 class ScalePixelsGM : public skiagm::GM {
268 public: 269 public:
269 ScalePixelsGM() {} 270 ScalePixelsGM() {}
270 271
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 } 501 }
501 if (context) { 502 if (context) {
502 sk_sp<SkImage> texImage(image->makeTextureImage(context)); 503 sk_sp<SkImage> texImage(image->makeTextureImage(context));
503 if (texImage) { 504 if (texImage) {
504 canvas->drawImage(texImage, 0, 0); 505 canvas->drawImage(texImage, 0, 0);
505 } 506 }
506 } 507 }
507 canvas->translate(image->width() + kPad, 0); 508 canvas->translate(image->width() + kPad, 0);
508 } 509 }
509 } 510 }
OLDNEW
« no previous file with comments | « no previous file | gm/image_pict.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698