diff options
author | Mike Reed <reed@google.com> | 2017-04-17 11:02:51 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-17 15:33:36 +0000 |
commit | 4edb5d219eb99aa1e8fbe5e37260d3b34314e54b (patch) | |
tree | 5e9fedc4e0e59db2467a19fe7d4f36030d0d6694 /include/core/SkPixelRef.h | |
parent | 12e946b4bfdf598bffb276776ea6e25439e25265 (diff) |
hide lockpixels api behind flag
guarded by SK_SUPPORT_OBSOLETE_LOCKPIXELS
needs https://codereview.chromium.org/2820873002/# to land first
Bug: skia:6481
Change-Id: I1c39902cbf6fe99f622adfa8192733b95f7fea09
Change-Id: I1c39902cbf6fe99f622adfa8192733b95f7fea09
Reviewed-on: https://skia-review.googlesource.com/13580
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'include/core/SkPixelRef.h')
-rw-r--r-- | include/core/SkPixelRef.h | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h index 0e66f25d31..56e0caf7c8 100644 --- a/include/core/SkPixelRef.h +++ b/include/core/SkPixelRef.h @@ -32,22 +32,18 @@ class SkDiscardableMemory; */ class SK_API SkPixelRef : public SkRefCnt { public: - explicit SkPixelRef(const SkImageInfo&, void* addr, size_t rowBytes, - sk_sp<SkColorTable> = nullptr); - virtual ~SkPixelRef(); + SkPixelRef(const SkImageInfo&, void* addr, size_t rowBytes, sk_sp<SkColorTable> = nullptr); + ~SkPixelRef() override; const SkImageInfo& info() const { return fInfo; } - void* pixels() const { return fRec.fPixels; } - SkColorTable* colorTable() const { return fRec.fColorTable; } - size_t rowBytes() const { return fRec.fRowBytes; } + void* pixels() const { return fPixels; } + SkColorTable* colorTable() const { return fCTable.get(); } + size_t rowBytes() const { return fRowBytes; } - /** - * To access the actual pixels of a pixelref, it must be "locked". - * Calling lockPixels returns a LockRec struct (on success). - */ +#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS struct LockRec { LockRec() : fPixels(NULL), fColorTable(NULL) {} @@ -72,6 +68,33 @@ public: */ bool lockPixels(LockRec* rec); + struct LockRequest { + SkISize fSize; + SkFilterQuality fQuality; + }; + + struct LockResult { + LockResult() : fPixels(NULL), fCTable(NULL) {} + + void (*fUnlockProc)(void* ctx); + void* fUnlockContext; + + const void* fPixels; + SkColorTable* fCTable; // should be NULL unless colortype is kIndex8 + size_t fRowBytes; + SkISize fSize; + + void unlock() { + if (fUnlockProc) { + fUnlockProc(fUnlockContext); + fUnlockProc = NULL; // can't unlock twice! + } + } + }; + + bool requestLock(const LockRequest&, LockResult*); +#endif + /** Returns a non-zero, unique value corresponding to the pixels in this pixelref. Each time the pixels are changed (and notifyPixelsChanged is @@ -116,32 +139,6 @@ public: */ void setImmutable(); - struct LockRequest { - SkISize fSize; - SkFilterQuality fQuality; - }; - - struct LockResult { - LockResult() : fPixels(NULL), fCTable(NULL) {} - - void (*fUnlockProc)(void* ctx); - void* fUnlockContext; - - const void* fPixels; - SkColorTable* fCTable; // should be NULL unless colortype is kIndex8 - size_t fRowBytes; - SkISize fSize; - - void unlock() { - if (fUnlockProc) { - fUnlockProc(fUnlockContext); - fUnlockProc = NULL; // can't unlock twice! - } - } - }; - - bool requestLock(const LockRequest&, LockResult*); - // Register a listener that may be called the next time our generation ID changes. // // We'll only call the listener if we're confident that we are the only SkPixelRef with this @@ -188,10 +185,9 @@ protected: private: // mostly const. fInfo.fAlpahType can be changed at runtime. const SkImageInfo fInfo; - sk_sp<SkColorTable> fCTable; // duplicated in LockRec, will unify later - - // LockRec is only valid if we're in a locked state (isLocked()) - LockRec fRec; + sk_sp<SkColorTable> fCTable; + void* fPixels; + size_t fRowBytes; // Bottom bit indicates the Gen ID is unique. bool genIDIsUnique() const { return SkToBool(fTaggedGenID.load() & 1); } @@ -212,9 +208,6 @@ private: kImmutable, // Once set to this state, it never leaves. } fMutability : 8; // easily fits inside a byte - // only ever set in constructor, const after that - bool fPreLocked; - void needsNewGenID(); void callGenIDChangeListeners(); @@ -222,7 +215,6 @@ private: void restoreMutability(); friend class SkSurface_Raster; // For the two methods above. - bool isPreLocked() const { return fPreLocked; } friend class SkImage_Raster; friend class SkSpecialImage_Raster; |