From ad8b5dc69cd613cc8974999f9e7c94a19eb01fec Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Thu, 20 Apr 2017 10:32:02 -0400 Subject: [PATCH] remove vestigle code for lockpixels Bug: skia:6481 Change-Id: Icfd53981b8588fbea74fca2e3be58bc6f13ef923 Reviewed-on: https://skia-review.googlesource.com/13968 Reviewed-by: Matt Sarett Commit-Queue: Mike Reed --- include/core/SkBitmap.h | 13 ---------- include/core/SkPixelRef.h | 53 --------------------------------------- include/core/SkPixmap.h | 50 ------------------------------------ public.bzl | 2 -- src/core/SkBitmap.cpp | 31 ----------------------- src/core/SkPixelRef.cpp | 31 ----------------------- src/core/SkPixmap.cpp | 12 --------- 7 files changed, 192 deletions(-) diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index e19f45232e..8818829a41 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -419,12 +419,6 @@ public: */ void setPixelRef(sk_sp, int dx, int dy); -#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS - void lockPixels() const {} - void unlockPixels() const {} - bool requestLock(SkAutoPixmapUnlock* result) const; -#endif - /** 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. @@ -756,13 +750,6 @@ private: friend class SkBinaryWriteBuffer; // rawpixels }; -#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS -class SkAutoLockPixels : SkNoncopyable { -public: - SkAutoLockPixels(const SkBitmap&, bool = true) {} -}; -#endif - /////////////////////////////////////////////////////////////////////////////// inline uint32_t* SkBitmap::getAddr32(int x, int y) const { diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h index 56e0caf7c8..e9225fd01f 100644 --- a/include/core/SkPixelRef.h +++ b/include/core/SkPixelRef.h @@ -43,59 +43,6 @@ public: SkColorTable* colorTable() const { return fCTable.get(); } size_t rowBytes() const { return fRowBytes; } -#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS - struct LockRec { - LockRec() : fPixels(NULL), fColorTable(NULL) {} - - void* fPixels; - SkColorTable* fColorTable; - size_t fRowBytes; - - void zero() { sk_bzero(this, sizeof(*this)); } - - bool isZero() const { - return NULL == fPixels && NULL == fColorTable && 0 == fRowBytes; - } - }; - - bool lockPixels() { return true; } - void unlockPixels() {} - - /** - * Call to access the pixel memory. On success, return true and fill out - * the specified rec. On failure, return false and ignore the rec parameter. - * Balance this with a call to unlockPixels(). - */ - 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 called), a different generation ID will be returned. diff --git a/include/core/SkPixmap.h b/include/core/SkPixmap.h index d028124222..af8618b4de 100644 --- a/include/core/SkPixmap.h +++ b/include/core/SkPixmap.h @@ -219,54 +219,4 @@ private: SkImageInfo fInfo; }; -///////////////////////////////////////////////////////////////////////////////////////////// - -#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS -class SK_API SkAutoPixmapUnlock : ::SkNoncopyable { -public: - SkAutoPixmapUnlock() : fUnlockProc(NULL), fIsLocked(false) {} - SkAutoPixmapUnlock(const SkPixmap& pm, void (*unlock)(void*), void* ctx) - : fUnlockProc(unlock), fUnlockContext(ctx), fPixmap(pm), fIsLocked(true) - {} - ~SkAutoPixmapUnlock() { this->unlock(); } - - /** - * Return the currently locked pixmap. Undefined if it has been unlocked. - */ - const SkPixmap& pixmap() const { - SkASSERT(this->isLocked()); - return fPixmap; - } - - bool isLocked() const { return fIsLocked; } - - /** - * Unlocks the pixmap. Can safely be called more than once as it will only call the underlying - * unlock-proc once. - */ - void unlock() { - if (fUnlockProc) { - SkASSERT(fIsLocked); - fUnlockProc(fUnlockContext); - fUnlockProc = NULL; - fIsLocked = false; - } - } - - /** - * If there is a currently locked pixmap, unlock it, then copy the specified pixmap - * and (optional) unlock proc/context. - */ - void reset(const SkPixmap& pm, void (*unlock)(void*), void* ctx); - -private: - void (*fUnlockProc)(void*); - void* fUnlockContext; - SkPixmap fPixmap; - bool fIsLocked; - - friend class SkBitmap; -}; -#endif - #endif diff --git a/public.bzl b/public.bzl index 1b5df5463f..01d70f7bcd 100644 --- a/public.bzl +++ b/public.bzl @@ -656,8 +656,6 @@ DEFINES_ALL = [ # Staging flags for API changes # Temporarily Disable analytic AA for Google3 "SK_NO_ANALYTIC_AA", - "SK_SUPPORT_LEGACY_CANVAS_READPIXELS", - "SK_SUPPORT_OBSOLETE_LOCKPIXELS", ] ################################################################################ diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index 7e3b2c97b3..8f131d15f5 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -994,37 +994,6 @@ void SkBitmap::toString(SkString* str) const { /////////////////////////////////////////////////////////////////////////////// -#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS -bool SkBitmap::requestLock(SkAutoPixmapUnlock* result) const { - SkASSERT(result); - - SkPixelRef* pr = fPixelRef.get(); - if (nullptr == pr) { - return false; - } - - // We have to lock the whole thing (using the pixelref's dimensions) until the api supports - // a partial lock (with offset/origin). Hence we can't use our fInfo. - SkPixelRef::LockRequest req = { pr->info().dimensions(), kNone_SkFilterQuality }; - SkPixelRef::LockResult res; - if (pr->requestLock(req, &res)) { - SkASSERT(res.fPixels); - // The bitmap may be a subset of the pixelref's dimensions - SkASSERT(fPixelRefOrigin.x() + fInfo.width() <= res.fSize.width()); - SkASSERT(fPixelRefOrigin.y() + fInfo.height() <= res.fSize.height()); - const void* addr = (const char*)res.fPixels + SkColorTypeComputeOffset(fInfo.colorType(), - fPixelRefOrigin.x(), - fPixelRefOrigin.y(), - res.fRowBytes); - - result->reset(SkPixmap(this->info(), addr, res.fRowBytes, res.fCTable), - res.fUnlockProc, res.fUnlockContext); - return true; - } - return false; -} -#endif - bool SkBitmap::peekPixels(SkPixmap* pmap) const { if (fPixels) { if (pmap) { diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp index 5b562b1ea6..5834b66936 100644 --- a/src/core/SkPixelRef.cpp +++ b/src/core/SkPixelRef.cpp @@ -110,37 +110,6 @@ void SkPixelRef::cloneGenID(const SkPixelRef& that) { SkASSERT(!that. genIDIsUnique()); } -#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS -bool SkPixelRef::lockPixels(LockRec* rec) { - if (fPixels) { - rec->fPixels = fPixels; - rec->fRowBytes = fRowBytes; - rec->fColorTable = fCTable.get(); - return true; - } - return false; -} - -bool SkPixelRef::requestLock(const LockRequest& request, LockResult* result) { - SkASSERT(result); - if (request.fSize.isEmpty()) { - return false; - } - // until we support subsets, we have to check this... - if (request.fSize.width() != fInfo.width() || request.fSize.height() != fInfo.height()) { - return false; - } - - result->fUnlockProc = nullptr; - result->fUnlockContext = nullptr; - result->fCTable = fCTable.get(); - result->fPixels = fPixels; - result->fRowBytes = fRowBytes; - result->fSize.set(fInfo.width(), fInfo.height()); - return true; -} -#endif - uint32_t SkPixelRef::getGenerationID() const { uint32_t id = fTaggedGenID.load(); if (0 == id) { diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp index 4d482181a5..02090b77c6 100644 --- a/src/core/SkPixmap.cpp +++ b/src/core/SkPixmap.cpp @@ -20,18 +20,6 @@ #include "SkSurface.h" #include "SkUtils.h" -#ifdef SK_SUPPORT_OBSOLETE_LOCKPIXELS -void SkAutoPixmapUnlock::reset(const SkPixmap& pm, void (*unlock)(void*), void* ctx) { - SkASSERT(pm.addr() != nullptr); - - this->unlock(); - fPixmap = pm; - fUnlockProc = unlock; - fUnlockContext = ctx; - fIsLocked = true; -} -#endif - ///////////////////////////////////////////////////////////////////////////////////////////////// void SkPixmap::reset() {