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