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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 { | 213 { |
214 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurfac
e::kNo_Budgeted, | 214 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkSurfac
e::kNo_Budgeted, |
215 info, 0)); | 215 info, 0)); |
216 surface->getCanvas()->clear(0); | 216 surface->getCanvas()->clear(0); |
217 surface->getCanvas()->translate(-100, -100); | 217 surface->getCanvas()->translate(-100, -100); |
218 surface->getCanvas()->drawPicture(pic); | 218 surface->getCanvas()->drawPicture(pic); |
219 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | 219 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); |
220 fTexture.reset(SkRef(image->getTexture())); | 220 fTexture.reset(SkRef(image->getTexture())); |
221 } | 221 } |
222 protected: | 222 protected: |
223 GrTexture* onGenerateTexture(GrContext* ctx, const GrTextureParams& params, | 223 GrTexture* onGenerateTexture(GrContext* ctx, const SkIRect* subset) override
{ |
224 const SkIRect* subset) override { | |
225 if (ctx) { | 224 if (ctx) { |
226 SkASSERT(ctx == fCtx.get()); | 225 SkASSERT(ctx == fCtx.get()); |
227 } | 226 } |
228 | 227 |
229 if (!subset) { | 228 if (!subset) { |
230 return SkRef(fTexture.get()); | 229 return SkRef(fTexture.get()); |
231 } | 230 } |
232 // need to copy the subset into a new texture | 231 // need to copy the subset into a new texture |
233 GrSurfaceDesc desc = fTexture->desc(); | 232 GrSurfaceDesc desc = fTexture->desc(); |
234 desc.fWidth = subset->width(); | 233 desc.fWidth = subset->width(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 }; | 370 }; |
372 DEF_GM( return new ImageCacheratorGM("picture", make_pic_generator); ) | 371 DEF_GM( return new ImageCacheratorGM("picture", make_pic_generator); ) |
373 DEF_GM( return new ImageCacheratorGM("raster", make_ras_generator); ) | 372 DEF_GM( return new ImageCacheratorGM("raster", make_ras_generator); ) |
374 DEF_GM( return new ImageCacheratorGM("ctable", make_ctable_generator); ) | 373 DEF_GM( return new ImageCacheratorGM("ctable", make_ctable_generator); ) |
375 #if SK_SUPPORT_GPU | 374 #if SK_SUPPORT_GPU |
376 DEF_GM( return new ImageCacheratorGM("texture", make_tex_generator); ) | 375 DEF_GM( return new ImageCacheratorGM("texture", make_tex_generator); ) |
377 #endif | 376 #endif |
378 | 377 |
379 | 378 |
380 | 379 |
OLD | NEW |