aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-04-11 15:50:02 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-12 00:12:00 +0000
commita00f34774712598cdee89b6a6fbdedb68cb9c193 (patch)
tree508121d63ad1a36a566084b117a7abdb4f29e70e /include
parent921ebe5b736b068182ce5de1ab0e36add06d5e2c (diff)
switch over to no lockPixels in pixelref
Bug: skia:6481 Change-Id: I7c32d2e6dcd4c9cd8aa761ac5c4794c916eb650a Reviewed-on: https://skia-review.googlesource.com/13193 Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/core/SkMallocPixelRef.h14
-rw-r--r--include/core/SkPixelRef.h17
2 files changed, 21 insertions, 10 deletions
diff --git a/include/core/SkMallocPixelRef.h b/include/core/SkMallocPixelRef.h
index 2e4c4e69eb..a62da0e46b 100644
--- a/include/core/SkMallocPixelRef.h
+++ b/include/core/SkMallocPixelRef.h
@@ -98,16 +98,13 @@ public:
SkData* data);
#endif
- void* getAddr() const { return fStorage; }
-
protected:
- // The ownPixels version of this constructor is deprecated.
- SkMallocPixelRef(const SkImageInfo&, void* addr, size_t rb, SkColorTable*,
- bool ownPixels);
~SkMallocPixelRef() override;
+#ifdef SK_SUPPORT_LEGACY_NO_ADDR_PIXELREF
bool onNewLockPixels(LockRec*) override;
void onUnlockPixels() override;
+#endif
size_t getAllocatedSizeInBytes() const override;
private:
@@ -117,11 +114,8 @@ private:
size_t rowBytes,
sk_sp<SkColorTable>);
- void* fStorage;
- sk_sp<SkColorTable> fCTable;
- size_t fRB;
- ReleaseProc fReleaseProc;
- void* fReleaseProcContext;
+ ReleaseProc fReleaseProc;
+ void* fReleaseProcContext;
SkMallocPixelRef(const SkImageInfo&, void* addr, size_t rb, sk_sp<SkColorTable>,
ReleaseProc proc, void* context);
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index 5987ee59fb..9cad27979d 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -35,7 +35,11 @@ class SkDiscardableMemory;
*/
class SK_API SkPixelRef : public SkRefCnt {
public:
+#ifdef SK_SUPPORT_LEGACY_NO_ADDR_PIXELREF
explicit SkPixelRef(const SkImageInfo&);
+#endif
+ explicit SkPixelRef(const SkImageInfo&, void* addr, size_t rowBytes,
+ sk_sp<SkColorTable> = nullptr);
virtual ~SkPixelRef();
const SkImageInfo& info() const {
@@ -209,6 +213,7 @@ public:
virtual SkDiscardableMemory* diagnostic_only_getDiscardable() const { return NULL; }
protected:
+#ifdef SK_SUPPORT_LEGACY_NO_ADDR_PIXELREF
/**
* On success, returns true and fills out the LockRec for the pixels. On
* failure returns false and ignores the LockRec parameter.
@@ -227,6 +232,15 @@ protected:
* method need not do that.
*/
virtual void onUnlockPixels() = 0;
+#else
+ bool onNewLockPixels(LockRec*) {
+ SkASSERT(false); // should never be called
+ return true;
+ }
+ void onUnlockPixels() {
+ SkASSERT(false); // should never be called
+ }
+#endif
// default impl does nothing.
virtual void onNotifyPixelsChanged();
@@ -246,16 +260,19 @@ protected:
*/
SkBaseMutex* mutex() const { return &fMutex; }
+#ifdef SK_SUPPORT_LEGACY_NO_ADDR_PIXELREF
// only call from constructor. Flags this to always be locked, removing
// the need to grab the mutex and call onLockPixels/onUnlockPixels.
// Performance tweak to avoid those calls (esp. in multi-thread use case).
void setPreLocked(void*, size_t rowBytes, SkColorTable*);
+#endif
private:
mutable SkMutex fMutex;
// 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;