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

Side by Side Diff: gm/image_pict.cpp

Issue 1404433002: Remove image usage type enum. Use GrTextureParams instead. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix no gpu build Created 5 years, 2 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 | gm/texturedomaineffect.cpp » ('j') | 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 "SkImage.h" 10 #include "SkImage.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, SkImageUsageType, const SkIRect * subset) override { 223 GrTexture* onGenerateTexture(GrContext* ctx, const GrTextureParams& params,
224 const SkIRect* subset) override {
224 if (ctx) { 225 if (ctx) {
225 SkASSERT(ctx == fCtx.get()); 226 SkASSERT(ctx == fCtx.get());
226 } 227 }
227 228
228 if (!subset) { 229 if (!subset) {
229 return SkRef(fTexture.get()); 230 return SkRef(fTexture.get());
230 } 231 }
231 // need to copy the subset into a new texture 232 // need to copy the subset into a new texture
232 GrSurfaceDesc desc = fTexture->desc(); 233 GrSurfaceDesc desc = fTexture->desc();
233 desc.fWidth = subset->width(); 234 desc.fWidth = subset->width();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 304
304 static void draw_as_bitmap(SkCanvas* canvas, SkImageCacherator* cache, SkSca lar x, SkScalar y) { 305 static void draw_as_bitmap(SkCanvas* canvas, SkImageCacherator* cache, SkSca lar x, SkScalar y) {
305 SkBitmap bitmap; 306 SkBitmap bitmap;
306 cache->lockAsBitmap(&bitmap, nullptr); 307 cache->lockAsBitmap(&bitmap, nullptr);
307 canvas->drawBitmap(bitmap, x, y); 308 canvas->drawBitmap(bitmap, x, y);
308 } 309 }
309 310
310 static void draw_as_tex(SkCanvas* canvas, SkImageCacherator* cache, SkScalar x, SkScalar y) { 311 static void draw_as_tex(SkCanvas* canvas, SkImageCacherator* cache, SkScalar x, SkScalar y) {
311 #if SK_SUPPORT_GPU 312 #if SK_SUPPORT_GPU
312 SkAutoTUnref<GrTexture> texture(cache->lockAsTexture(canvas->getGrContex t(), 313 SkAutoTUnref<GrTexture> texture(cache->lockAsTexture(canvas->getGrContex t(),
313 kUntiled_SkImageUsa geType, 314 GrTextureParams::Cl ampBilerp(),
314 nullptr)); 315 nullptr));
315 if (!texture) { 316 if (!texture) {
316 // show placeholder if we have no texture 317 // show placeholder if we have no texture
317 SkPaint paint; 318 SkPaint paint;
318 paint.setStyle(SkPaint::kStroke_Style); 319 paint.setStyle(SkPaint::kStroke_Style);
319 SkRect r = SkRect::MakeXYWH(x, y, SkIntToScalar(cache->info().width( )), 320 SkRect r = SkRect::MakeXYWH(x, y, SkIntToScalar(cache->info().width( )),
320 SkIntToScalar(cache->info().width())); 321 SkIntToScalar(cache->info().width()));
321 canvas->drawRect(r, paint); 322 canvas->drawRect(r, paint);
322 canvas->drawLine(r.left(), r.top(), r.right(), r.bottom(), paint); 323 canvas->drawLine(r.left(), r.top(), r.right(), r.bottom(), paint);
323 canvas->drawLine(r.left(), r.bottom(), r.right(), r.top(), paint); 324 canvas->drawLine(r.left(), r.bottom(), r.right(), r.top(), paint);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 }; 371 };
371 DEF_GM( return new ImageCacheratorGM("picture", make_pic_generator); ) 372 DEF_GM( return new ImageCacheratorGM("picture", make_pic_generator); )
372 DEF_GM( return new ImageCacheratorGM("raster", make_ras_generator); ) 373 DEF_GM( return new ImageCacheratorGM("raster", make_ras_generator); )
373 DEF_GM( return new ImageCacheratorGM("ctable", make_ctable_generator); ) 374 DEF_GM( return new ImageCacheratorGM("ctable", make_ctable_generator); )
374 #if SK_SUPPORT_GPU 375 #if SK_SUPPORT_GPU
375 DEF_GM( return new ImageCacheratorGM("texture", make_tex_generator); ) 376 DEF_GM( return new ImageCacheratorGM("texture", make_tex_generator); )
376 #endif 377 #endif
377 378
378 379
379 380
OLDNEW
« no previous file with comments | « no previous file | gm/texturedomaineffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698