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 "SkImage.h" | 10 #include "SkImage.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 EmptyGenerator(const SkImageInfo& info) : SkImageGenerator(info) {} | 204 EmptyGenerator(const SkImageInfo& info) : SkImageGenerator(info) {} |
205 }; | 205 }; |
206 | 206 |
207 #if SK_SUPPORT_GPU | 207 #if SK_SUPPORT_GPU |
208 class TextureGenerator : public SkImageGenerator { | 208 class TextureGenerator : public SkImageGenerator { |
209 public: | 209 public: |
210 TextureGenerator(GrContext* ctx, const SkImageInfo& info, SkPicture* pic) | 210 TextureGenerator(GrContext* ctx, const SkImageInfo& info, SkPicture* pic) |
211 : SkImageGenerator(info) | 211 : SkImageGenerator(info) |
212 , fCtx(SkRef(ctx)) | 212 , fCtx(SkRef(ctx)) |
213 { | 213 { |
214 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudget
ed::kNo, | 214 auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info)); |
215 info, 0)); | |
216 surface->getCanvas()->clear(0); | 215 surface->getCanvas()->clear(0); |
217 surface->getCanvas()->translate(-100, -100); | 216 surface->getCanvas()->translate(-100, -100); |
218 surface->getCanvas()->drawPicture(pic); | 217 surface->getCanvas()->drawPicture(pic); |
219 sk_sp<SkImage> image(surface->makeImageSnapshot()); | 218 sk_sp<SkImage> image(surface->makeImageSnapshot()); |
220 fTexture.reset(SkRef(as_IB(image)->peekTexture())); | 219 fTexture.reset(SkRef(as_IB(image)->peekTexture())); |
221 } | 220 } |
222 protected: | 221 protected: |
223 GrTexture* onGenerateTexture(GrContext* ctx, const SkIRect* subset) override
{ | 222 GrTexture* onGenerateTexture(GrContext* ctx, const SkIRect* subset) override
{ |
224 if (ctx) { | 223 if (ctx) { |
225 SkASSERT(ctx == fCtx.get()); | 224 SkASSERT(ctx == fCtx.get()); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 }; | 369 }; |
371 DEF_GM( return new ImageCacheratorGM("picture", make_pic_generator); ) | 370 DEF_GM( return new ImageCacheratorGM("picture", make_pic_generator); ) |
372 DEF_GM( return new ImageCacheratorGM("raster", make_ras_generator); ) | 371 DEF_GM( return new ImageCacheratorGM("raster", make_ras_generator); ) |
373 DEF_GM( return new ImageCacheratorGM("ctable", make_ctable_generator); ) | 372 DEF_GM( return new ImageCacheratorGM("ctable", make_ctable_generator); ) |
374 #if SK_SUPPORT_GPU | 373 #if SK_SUPPORT_GPU |
375 DEF_GM( return new ImageCacheratorGM("texture", make_tex_generator); ) | 374 DEF_GM( return new ImageCacheratorGM("texture", make_tex_generator); ) |
376 #endif | 375 #endif |
377 | 376 |
378 | 377 |
379 | 378 |
OLD | NEW |