OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |