Chromium Code Reviews| 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 { |