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

Side by Side Diff: gm/image_shader.cpp

Issue 1972933002: Fail gracefully if MakeRenderTarget fails (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 20 matching lines...) Expand all
31 surface->getCanvas()->clear(0); 31 surface->getCanvas()->clear(0);
32 surface->getCanvas()->drawPicture(pic); 32 surface->getCanvas()->drawPicture(pic);
33 return surface->makeImageSnapshot(); 33 return surface->makeImageSnapshot();
34 } 34 }
35 35
36 static sk_sp<SkImage> make_texture(GrContext* ctx, SkPicture* pic, const SkImage Info& info) { 36 static sk_sp<SkImage> make_texture(GrContext* ctx, SkPicture* pic, const SkImage Info& info) {
37 if (!ctx) { 37 if (!ctx) {
38 return nullptr; 38 return nullptr;
39 } 39 }
40 auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info)); 40 auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
41 if (!surface) {
42 return nullptr;
43 }
41 surface->getCanvas()->clear(0); 44 surface->getCanvas()->clear(0);
42 surface->getCanvas()->drawPicture(pic); 45 surface->getCanvas()->drawPicture(pic);
43 return surface->makeImageSnapshot(); 46 return surface->makeImageSnapshot();
44 } 47 }
45 48
46 static sk_sp<SkImage> make_pict_gen(GrContext*, SkPicture* pic, const SkImageInf o& info) { 49 static sk_sp<SkImage> make_pict_gen(GrContext*, SkPicture* pic, const SkImageInf o& info) {
47 return SkImage::MakeFromPicture(sk_ref_sp(pic), info.dimensions(), nullptr, nullptr); 50 return SkImage::MakeFromPicture(sk_ref_sp(pic), info.dimensions(), nullptr, nullptr);
48 } 51 }
49 52
50 static sk_sp<SkImage> make_encode_gen(GrContext* ctx, SkPicture* pic, const SkIm ageInfo& info) { 53 static sk_sp<SkImage> make_encode_gen(GrContext* ctx, SkPicture* pic, const SkIm ageInfo& info) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 this->testImage(canvas, image.get()); 120 this->testImage(canvas, image.get());
118 } 121 }
119 canvas->translate(120, 0); 122 canvas->translate(120, 0);
120 } 123 }
121 } 124 }
122 125
123 private: 126 private:
124 typedef skiagm::GM INHERITED; 127 typedef skiagm::GM INHERITED;
125 }; 128 };
126 DEF_GM( return new ImageShaderGM; ) 129 DEF_GM( return new ImageShaderGM; )
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698