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

Side by Side Diff: src/image/SkImage.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 | « src/core/SkImageCacherator.cpp ('k') | src/image/SkImage_Base.h » ('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 2012 Google Inc. 2 * Copyright 2012 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapCache.h"
9 #include "SkCanvas.h" 10 #include "SkCanvas.h"
10 #include "SkData.h" 11 #include "SkData.h"
11 #include "SkImageGenerator.h" 12 #include "SkImageGenerator.h"
12 #include "SkImagePriv.h" 13 #include "SkImagePriv.h"
13 #include "SkImage_Base.h" 14 #include "SkImage_Base.h"
14 #include "SkNextID.h" 15 #include "SkNextID.h"
15 #include "SkPixelRef.h" 16 #include "SkPixelRef.h"
16 #include "SkPixelSerializer.h" 17 #include "SkPixelSerializer.h"
17 #include "SkReadPixelsRec.h" 18 #include "SkReadPixelsRec.h"
18 #include "SkString.h" 19 #include "SkString.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 case kRGB_565_SkColorType: 204 case kRGB_565_SkColorType:
204 return true; 205 return true;
205 case kAlpha_8_SkColorType: 206 case kAlpha_8_SkColorType:
206 return true; 207 return true;
207 default: 208 default:
208 break; 209 break;
209 } 210 }
210 return false; 211 return false;
211 } 212 }
212 213
214 static SkSurfaceProps copy_or_safe_defaults(const SkSurfaceProps* props) {
215 return props ? *props : SkSurfaceProps(0, kUnknown_SkPixelGeometry);
216 }
217
218 SkImage_Base::SkImage_Base(int width, int height, uint32_t uniqueID, const SkSur faceProps* props)
219 : INHERITED(width, height, uniqueID)
220 , fProps(copy_or_safe_defaults(props))
221 , fAddedToCache(false)
222 { }
223
224 SkImage_Base::~SkImage_Base() {
225 if (fAddedToCache.load()) {
226 SkNotifyBitmapGenIDIsStale(this->uniqueID());
227 }
228 }
229
213 bool SkImage_Base::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, siz e_t dstRowBytes, 230 bool SkImage_Base::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, siz e_t dstRowBytes,
214 int srcX, int srcY) const { 231 int srcX, int srcY) const {
215 if (!raster_canvas_supports(dstInfo)) { 232 if (!raster_canvas_supports(dstInfo)) {
216 return false; 233 return false;
217 } 234 }
218 235
219 SkBitmap bm; 236 SkBitmap bm;
220 bm.installPixels(dstInfo, dstPixels, dstRowBytes); 237 bm.installPixels(dstInfo, dstPixels, dstRowBytes);
221 SkCanvas canvas(bm); 238 SkCanvas canvas(bm);
222 239
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 365
349 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType) { 366 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType) {
350 return nullptr; 367 return nullptr;
351 } 368 }
352 369
353 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) { 370 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) {
354 return nullptr; 371 return nullptr;
355 } 372 }
356 373
357 #endif 374 #endif
OLDNEW
« no previous file with comments | « src/core/SkImageCacherator.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698