| 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 {
|
| + public:
|
| + LockResult() : fUnlockProc(NULL), fUnlockContext(NULL) {
|
| + SkDEBUGCODE(fIsLocked = false;)
|
| + }
|
| +
|
| + const SkPixmap& pixmap() const { return fPixmap; }
|
| +
|
| + SkDEBUGCODE(bool isLocked() const { return fIsLocked; })
|
| + void unlock();
|
| +
|
| + 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 {
|
|
|