Allow client to force an SkImage snapshot to be unique (and uniquely own its backing store).
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1686163002
Review URL: https://codereview.chromium.org/1686163002
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index fed13a2..711dfda6 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -164,9 +164,13 @@
}
SkImage* SkSurface::newImageSnapshot(Budgeted budgeted) {
- SkImage* image = asSB(this)->getCachedImage(budgeted);
- SkSafeRef(image); // the caller will call unref() to balance this
- return image;
+ // the caller will call unref() to balance this
+ return asSB(this)->refCachedImage(budgeted, kNo_ForceUnique);
+}
+
+SkImage* SkSurface::newImageSnapshot(Budgeted budgeted, ForceUnique unique) {
+ // the caller will call unref() to balance this
+ return asSB(this)->refCachedImage(budgeted, unique);
}
SkSurface* SkSurface::newSurface(const SkImageInfo& info) {