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

Unified Diff: include/core/SkBitmap.h

Issue 1074983003: add SkPixmap and external locking to bitmaps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | include/core/SkImageInfo.h » ('j') | include/core/SkImageInfo.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkBitmap.h
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index dbaca621af93192c184188910f5f22077062927e..7baa33e5c3da9456e0b4a4fdf30c5f98e4851c73 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -11,6 +11,7 @@
#include "SkColor.h"
#include "SkColorTable.h"
#include "SkImageInfo.h"
+#include "SkPixmap.h"
#include "SkPoint.h"
#include "SkRefCnt.h"
@@ -428,6 +429,34 @@ public:
*/
bool lockPixelsAreWritable() const;
+ class LockResult {
scroggo 2015/05/19 20:11:41 inherit from SkNoncopyable?
reed1 2015/05/21 20:59:34 Done.
+ public:
+ LockResult() : fUnlockProc(NULL), fUnlockContext(NULL) {
+ SkDEBUGCODE(fIsLocked = false;)
+ }
+
+ const SkPixmap& pixmap() const { return fPixmap; }
+
+ SkDEBUGCODE(bool isLocked() const { return fIsLocked; })
+ void unlock();
scroggo 2015/05/19 20:11:42 Should this get called by a destructor, if it wasn
reed1 2015/05/21 20:59:34 Done.
+
+ private:
+ LockResult(const SkPixmap& pm, void (*unlock)(void*), void* ctx)
+ : fUnlockProc(unlock), fUnlockContext(ctx), fPixmap(pm)
+ {
+ SkDEBUGCODE(fIsLocked = true;)
+ }
+
+ void (*fUnlockProc)(void*);
+ void* fUnlockContext;
+ SkPixmap fPixmap;
+ SkDEBUGCODE(bool fIsLocked;)
+
+ friend class SkBitmap;
+ };
+
+ bool requestLock(LockResult* result) const;
+
/** Call this to be sure that the bitmap is valid enough to be drawn (i.e.
it has non-null pixels, and if required by its colortype, it has a
non-null colortable. Returns true if all of the above are met.
@@ -783,6 +812,14 @@ private:
//TODO(mtklein): uncomment when 71713004 lands and Chromium's fixed.
//#define SkAutoLockPixels(...) SK_REQUIRE_LOCAL_VAR(SkAutoLockPixels)
+class SkAutoBitmapLockResult : public SkBitmap::LockResult {
+public:
+ SkAutoBitmapLockResult() {}
+ ~SkAutoBitmapLockResult() {
+ this->unlock();
+ }
+};
+
///////////////////////////////////////////////////////////////////////////////
inline uint32_t* SkBitmap::getAddr32(int x, int y) const {
« no previous file with comments | « no previous file | include/core/SkImageInfo.h » ('j') | include/core/SkImageInfo.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698