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

Unified Diff: src/image/SkImage.cpp

Issue 1266883002: unify pixelref and image ID space, so we can share IDs when we share pixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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/SkPixelRef.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 081785f4b36856c590a8527e8c89afc24517e1cd..a17f336c9c0d9f0d8a9f3b07a76c920e1adabf04 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -11,6 +11,7 @@
#include "SkImageGenerator.h"
#include "SkImagePriv.h"
#include "SkImage_Base.h"
+#include "SkNextID.h"
#include "SkPixelRef.h"
#include "SkReadPixelsRec.h"
#include "SkString.h"
@@ -22,15 +23,13 @@
#include "SkImage_Gpu.h"
#endif
-uint32_t SkImage::NextUniqueID() {
- static int32_t gUniqueID;
-
- // never return 0;
- uint32_t id;
- do {
- id = sk_atomic_inc(&gUniqueID) + 1;
- } while (0 == id);
- return id;
+SkImage::SkImage(int width, int height, uint32_t uniqueID)
+ : fWidth(width)
+ , fHeight(height)
+ , fUniqueID(kNeedNewImageUniqueID == uniqueID ? SkNextID::ImageID() : uniqueID)
+{
+ SkASSERT(width > 0);
+ SkASSERT(height > 0);
}
const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const {
@@ -248,8 +247,8 @@ SkImage* SkImage::NewFromBitmap(const SkBitmap& bm) {
unrefCopy.reset(tex);
}
const SkImageInfo info = bm.info();
- return SkNEW_ARGS(SkImage_Gpu, (info.width(), info.height(), info.alphaType(),
- tex, 0, SkSurface::kNo_Budgeted));
+ return SkNEW_ARGS(SkImage_Gpu, (info.width(), info.height(), bm.getGenerationID(),
+ info.alphaType(), tex, 0, SkSurface::kNo_Budgeted));
}
#endif
« no previous file with comments | « src/core/SkPixelRef.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698