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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkImageCacherator.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage.cpp
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 654b848fce22073ba274c57cbe0768c3464093dc..6f4655758e36cb7b50a565f514655cb51921db75 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -6,6 +6,7 @@
*/
#include "SkBitmap.h"
+#include "SkBitmapCache.h"
#include "SkCanvas.h"
#include "SkData.h"
#include "SkImageGenerator.h"
@@ -210,6 +211,22 @@ static bool raster_canvas_supports(const SkImageInfo& info) {
return false;
}
+static SkSurfaceProps copy_or_safe_defaults(const SkSurfaceProps* props) {
+ return props ? *props : SkSurfaceProps(0, kUnknown_SkPixelGeometry);
+}
+
+SkImage_Base::SkImage_Base(int width, int height, uint32_t uniqueID, const SkSurfaceProps* props)
+ : INHERITED(width, height, uniqueID)
+ , fProps(copy_or_safe_defaults(props))
+ , fAddedToCache(false)
+{ }
+
+SkImage_Base::~SkImage_Base() {
+ if (fAddedToCache.load()) {
+ SkNotifyBitmapGenIDIsStale(this->uniqueID());
+ }
+}
+
bool SkImage_Base::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
int srcX, int srcY) const {
if (!raster_canvas_supports(dstInfo)) {
« 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