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

Side by Side Diff: gm/image_pict.cpp

Issue 1352883004: Purge cached resources on SkImage destruction. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review comments Created 5 years, 3 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 | src/core/SkBitmapProvider.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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 SkASSERT(fCache->uniqueID() == genID); 296 SkASSERT(fCache->uniqueID() == genID);
297 SkASSERT(fCacheSubset->uniqueID() != genID); 297 SkASSERT(fCacheSubset->uniqueID() != genID);
298 SkASSERT(fCacheSubset->uniqueID() != genSubsetID); 298 SkASSERT(fCacheSubset->uniqueID() != genSubsetID);
299 299
300 SkASSERT(fCache->info().dimensions() == SkISize::Make(100, 100)); 300 SkASSERT(fCache->info().dimensions() == SkISize::Make(100, 100));
301 SkASSERT(fCacheSubset->info().dimensions() == SkISize::Make(50, 50)); 301 SkASSERT(fCacheSubset->info().dimensions() == SkISize::Make(50, 50));
302 } 302 }
303 303
304 static void draw_as_bitmap(SkCanvas* canvas, SkImageCacherator* cache, SkSca lar x, SkScalar y) { 304 static void draw_as_bitmap(SkCanvas* canvas, SkImageCacherator* cache, SkSca lar x, SkScalar y) {
305 SkBitmap bitmap; 305 SkBitmap bitmap;
306 cache->lockAsBitmap(&bitmap); 306 cache->lockAsBitmap(&bitmap, nullptr);
307 canvas->drawBitmap(bitmap, x, y); 307 canvas->drawBitmap(bitmap, x, y);
308 } 308 }
309 309
310 static void draw_as_tex(SkCanvas* canvas, SkImageCacherator* cache, SkScalar x, SkScalar y) { 310 static void draw_as_tex(SkCanvas* canvas, SkImageCacherator* cache, SkScalar x, SkScalar y) {
311 #if SK_SUPPORT_GPU 311 #if SK_SUPPORT_GPU
312 SkAutoTUnref<GrTexture> texture(cache->lockAsTexture(canvas->getGrContex t(), 312 SkAutoTUnref<GrTexture> texture(cache->lockAsTexture(canvas->getGrContex t(),
313 kUntiled_SkImageUsa geType)); 313 kUntiled_SkImageUsa geType,
314 nullptr));
314 if (!texture) { 315 if (!texture) {
315 // show placeholder if we have no texture 316 // show placeholder if we have no texture
316 SkPaint paint; 317 SkPaint paint;
317 paint.setStyle(SkPaint::kStroke_Style); 318 paint.setStyle(SkPaint::kStroke_Style);
318 SkRect r = SkRect::MakeXYWH(x, y, SkIntToScalar(cache->info().width( )), 319 SkRect r = SkRect::MakeXYWH(x, y, SkIntToScalar(cache->info().width( )),
319 SkIntToScalar(cache->info().width())); 320 SkIntToScalar(cache->info().width()));
320 canvas->drawRect(r, paint); 321 canvas->drawRect(r, paint);
321 canvas->drawLine(r.left(), r.top(), r.right(), r.bottom(), paint); 322 canvas->drawLine(r.left(), r.top(), r.right(), r.bottom(), paint);
322 canvas->drawLine(r.left(), r.bottom(), r.right(), r.top(), paint); 323 canvas->drawLine(r.left(), r.bottom(), r.right(), r.top(), paint);
323 return; 324 return;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 }; 370 };
370 DEF_GM( return new ImageCacheratorGM("picture", make_pic_generator); ) 371 DEF_GM( return new ImageCacheratorGM("picture", make_pic_generator); )
371 DEF_GM( return new ImageCacheratorGM("raster", make_ras_generator); ) 372 DEF_GM( return new ImageCacheratorGM("raster", make_ras_generator); )
372 DEF_GM( return new ImageCacheratorGM("ctable", make_ctable_generator); ) 373 DEF_GM( return new ImageCacheratorGM("ctable", make_ctable_generator); )
373 #if SK_SUPPORT_GPU 374 #if SK_SUPPORT_GPU
374 DEF_GM( return new ImageCacheratorGM("texture", make_tex_generator); ) 375 DEF_GM( return new ImageCacheratorGM("texture", make_tex_generator); )
375 #endif 376 #endif
376 377
377 378
378 379
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmapProvider.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698