diff options
-rw-r--r-- | include/core/SkBitmap.h | 104 | ||||
-rw-r--r-- | include/core/SkMallocPixelRef.h | 28 | ||||
-rw-r--r-- | include/core/SkPixelRef.h | 11 | ||||
-rw-r--r-- | include/core/SkPixmap.h | 14 | ||||
-rw-r--r-- | src/core/SkAutoPixmapStorage.h | 6 | ||||
-rw-r--r-- | src/core/SkBitmap.cpp | 10 | ||||
-rw-r--r-- | src/core/SkPixelRef.cpp | 26 |
7 files changed, 8 insertions, 191 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index 6b48613db9..65b797bde8 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -9,9 +9,6 @@ #define SkBitmap_DEFINED #include "SkColor.h" -#ifdef SK_SUPPORT_LEGACY_COLORTABLE -#include "SkColorTable.h" -#endif #include "SkImageInfo.h" #include "SkPixmap.h" #include "SkPoint.h" @@ -245,8 +242,7 @@ public: /** * Allocate the bitmap's pixels to match the requested image info. If the Factory - * is non-null, call it to allcoate the pixelref. If the ImageInfo requires - * a colortable, then ColorTable must be non-null. + * is non-null, call it to allcoate the pixelref. * * On failure, the bitmap will be set to empty and return false. */ @@ -257,16 +253,6 @@ public: } } -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info, sk_sp<SkColorTable>, - uint32_t flags = 0) { - return this->tryAllocPixelsFlags(info, flags); - } - void allocPixels(const SkImageInfo& info, sk_sp<SkColorTable>, uint32_t flags = 0) { - this->allocPixels(info, flags); - } -#endif - /** * Allocate the bitmap's pixels to match the requested image info and * rowBytes. If the request cannot be met (e.g. the info is invalid or @@ -303,13 +289,6 @@ public: this->allocPixels(info); } -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - // TEMPORARY -- remove after updating Android BitmapTests.cpp:35 - void allocPixels(const SkImageInfo& info, std::nullptr_t, SkColorTable*) { - this->allocPixels(info); - } -#endif - /** * Install a pixelref that wraps the specified pixels and rowBytes, and * optional ReleaseProc and context. When the pixels are no longer @@ -332,17 +311,9 @@ public: return this->installPixels(info, pixels, rowBytes, nullptr, nullptr); } -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - bool installPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkColorTable*, - void (*releaseProc)(void* addr, void* context), void* context) { - return this->installPixels(info, pixels, rowBytes, releaseProc, context); - } -#endif - /** - * Call installPixels with no ReleaseProc specified. This means - * that the caller must ensure that the specified pixels and - * colortable are valid for the lifetime of the created bitmap + * Call installPixels with no ReleaseProc specified. This means that the caller must ensure + * that the specified pixels are valid for the lifetime of the created bitmap * (and its pixelRef). */ bool installPixels(const SkPixmap&); @@ -358,11 +329,7 @@ public: will automatically release any pixelref previously installed. Only call this if you are handling ownership/lifetime of the pixel memory. - If the bitmap retains a reference to the colortable (assuming it is - not null) it will take care of incrementing the reference count. - @param pixels Address for the pixels, managed by the caller. - @param ctable ColorTable (or null) that matches the specified pixels */ void setPixels(void* p); @@ -371,11 +338,6 @@ public: If this is called multiple times, a new pixelref object will be created each time. - If the bitmap retains a reference to the colortable (assuming it is - not null) it will take care of incrementing the reference count. - - @param ctable ColorTable (or null) to use with the pixels that will - be allocated. Only used if colortype == kIndex_8_SkColorType @return true if the allocation succeeds. If not the pixelref field of the bitmap will be unchanged. */ @@ -392,16 +354,9 @@ public: If this is called multiple times, a new pixelref object will be created each time. - If the bitmap retains a reference to the colortable (assuming it is - not null) it will take care of incrementing the reference count. - @param allocator The Allocator to use to create a pixelref that can manage the pixel memory for the current ImageInfo. If allocator is NULL, the standard HeapAllocator will be used. - @param ctable ColorTable (or null) to use with the pixels that will - be allocated. Only used if colortype == kIndex_8_SkColorType. - If it is non-null and the colortype is not indexed, it will - be ignored. @return true if the allocation succeeds. If not the pixelref field of the bitmap will be unchanged. */ @@ -413,25 +368,6 @@ public: } } -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - void setPixels(void* p, SkColorTable*) { - this->setPixels(p); - } - bool SK_WARN_UNUSED_RESULT tryAllocPixels(SkColorTable*) { - return this->tryAllocPixels(); - } - - void allocPixels(SkColorTable*) { - this->allocPixels(); - } - bool SK_WARN_UNUSED_RESULT tryAllocPixels(Allocator* allocator, SkColorTable*) { - return this->tryAllocPixels(allocator); - } - void allocPixels(Allocator* allocator, SkColorTable*) { - this->allocPixels(allocator); - } -#endif - /** * Return the current pixelref object or NULL if there is none. This does * not affect the refcount of the pixelref. @@ -460,22 +396,12 @@ public: void setPixelRef(sk_sp<SkPixelRef>, int dx, int dy); /** 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. + it has non-null pixels). */ bool readyToDraw() const { return this->getPixels() != NULL; } - /** Return the bitmap's colortable, if it uses one (i.e. colorType is - Index_8). - Otherwise returns NULL. Does not affect the colortable's - reference count. - */ -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - SkColorTable* getColorTable() const { return nullptr; } -#endif - /** Returns a non-zero, unique value corresponding to the pixels in our pixelref. Each time the pixels are changed (and notifyPixelsChanged is called), a different generation ID will be returned. Finally, if @@ -571,14 +497,6 @@ public: */ inline uint8_t* getAddr8(int x, int y) const; - /** Returns the color corresponding to the pixel specified by x,y for - * colortable based bitmaps. - * In debug build, this asserts that the pixels are allocated, - * that the colortype is indexed, and that the colortable is allocated, - * however none of these checks are performed in the release build. - */ - inline SkPMColor getIndex8Color(int x, int y) const; - /** Set dst to be a setset of this bitmap. If possible, it will share the pixel memory, and just point into a subset of it. However, if the colortype does not support this, a local copy will be made and associated with @@ -692,15 +610,9 @@ public: public: /** Allocate the pixel memory for the bitmap, given its dimensions and colortype. Return true on success, where success means either setPixels - or setPixelRef was called. If the colortype requires a colortable, - it also must be installed via setColorTable. If false is returned, - the bitmap and colortable should be left unchanged. + or setPixelRef was called. */ -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - virtual bool allocPixelRef(SkBitmap*, SkColorTable*) = 0; -#else virtual bool allocPixelRef(SkBitmap*) = 0; -#endif private: typedef SkRefCnt INHERITED; }; @@ -711,11 +623,7 @@ public: */ class HeapAllocator : public Allocator { public: -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - bool allocPixelRef(SkBitmap*, SkColorTable*) override; -#else bool allocPixelRef(SkBitmap*) override; -#endif }; SK_TO_STRING_NONVIRT() @@ -739,7 +647,7 @@ private: uint32_t fRowBytes; uint8_t fFlags; - /* Unreference any pixelrefs or colortables + /* Unreference any pixelrefs */ void freePixels(); void updatePixelsFromRef(); diff --git a/include/core/SkMallocPixelRef.h b/include/core/SkMallocPixelRef.h index 07a5483e25..dce3c0ecbb 100644 --- a/include/core/SkMallocPixelRef.h +++ b/include/core/SkMallocPixelRef.h @@ -9,9 +9,6 @@ #define SkMallocPixelRef_DEFINED #include "SkPixelRef.h" -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - #include "SkData.h" -#endif /** We explicitly use the same allocator for our pixels that SkMask does, so that we can freely assign memory allocated by one class to the other. @@ -71,31 +68,6 @@ public: */ static sk_sp<SkPixelRef> MakeWithData(const SkImageInfo&, size_t rowBytes, sk_sp<SkData> data); -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - static sk_sp<SkPixelRef> MakeDirect(const SkImageInfo& info, void* addr, - size_t rowBytes, sk_sp<SkColorTable>) { - return MakeDirect(info, addr, rowBytes); - } - static sk_sp<SkPixelRef> MakeAllocate(const SkImageInfo& info, size_t rb, sk_sp<SkColorTable>) { - return MakeAllocate(info, rb); - } - static sk_sp<SkPixelRef> MakeZeroed(const SkImageInfo& info, size_t rb, sk_sp<SkColorTable>) { - return MakeZeroed(info, rb); - } - static sk_sp<SkPixelRef> MakeWithProc(const SkImageInfo& info, - size_t rowBytes, sk_sp<SkColorTable>, - void* addr, ReleaseProc proc, - void* context) { - return MakeWithProc(info, rowBytes, addr, proc, context); - } - static sk_sp<SkPixelRef> MakeWithData(const SkImageInfo& info, - size_t rowBytes, - sk_sp<SkColorTable>, - sk_sp<SkData> data) { - return MakeWithData(info, rowBytes, data); - } -#endif - protected: ~SkMallocPixelRef() override; diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h index 25a8d52540..b14cbdf20e 100644 --- a/include/core/SkPixelRef.h +++ b/include/core/SkPixelRef.h @@ -19,9 +19,6 @@ #include "SkSize.h" #include "SkString.h" -#ifdef SK_SUPPORT_LEGACY_COLORTABLE -class SkColorTable; -#endif struct SkIRect; class GrTexture; @@ -102,19 +99,11 @@ public: virtual SkDiscardableMemory* diagnostic_only_getDiscardable() const { return NULL; } -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - SkPixelRef(int width, int height, void* addr, size_t rowBytes, sk_sp<SkColorTable>); - SkColorTable* colorTable() const { return nullptr; } -#endif protected: // default impl does nothing. virtual void onNotifyPixelsChanged(); -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - void android_only_reset(int width, int height, size_t rowBytes, sk_sp<SkColorTable>); -#else void android_only_reset(int width, int height, size_t rowBytes); -#endif private: int fWidth; diff --git a/include/core/SkPixmap.h b/include/core/SkPixmap.h index 1ea011b348..c703386d1f 100644 --- a/include/core/SkPixmap.h +++ b/include/core/SkPixmap.h @@ -12,9 +12,6 @@ #include "SkFilterQuality.h" #include "SkImageInfo.h" -#ifdef SK_SUPPORT_LEGACY_COLORTABLE -class SkColorTable; -#endif class SkData; struct SkMask; @@ -210,17 +207,6 @@ public: bool erase(SkColor color) const { return this->erase(color, this->bounds()); } bool erase(const SkColor4f&, const SkIRect* subset = nullptr) const; -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes, SkColorTable*) - : fPixels(addr), fRowBytes(rowBytes), fInfo(info) - {} - void reset(const SkImageInfo& info, const void* addr, size_t rowBytes, - SkColorTable*) { - this->reset(info, addr, rowBytes); - } - SkColorTable* ctable() const { return nullptr; } -#endif - private: const void* fPixels; size_t fRowBytes; diff --git a/src/core/SkAutoPixmapStorage.h b/src/core/SkAutoPixmapStorage.h index 0aece1b9ea..08866443d4 100644 --- a/src/core/SkAutoPixmapStorage.h +++ b/src/core/SkAutoPixmapStorage.h @@ -70,12 +70,6 @@ public: return this->INHERITED::reset(mask); } -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - void reset(const SkImageInfo& info, const void* addr, size_t rb, SkColorTable*) { - this->freeStorage(); - this->INHERITED::reset(info, addr, rb); - } -#endif private: void* fStorage; diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp index 4877d64e46..e96e968fbf 100644 --- a/src/core/SkBitmap.cpp +++ b/src/core/SkBitmap.cpp @@ -233,11 +233,7 @@ bool SkBitmap::tryAllocPixels(Allocator* allocator) { if (nullptr == allocator) { allocator = &stdalloc; } -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - return allocator->allocPixelRef(this, nullptr); -#else return allocator->allocPixelRef(this); -#endif } /////////////////////////////////////////////////////////////////////////////// @@ -358,11 +354,7 @@ void SkBitmap::notifyPixelsChanged() const { /** We explicitly use the same allocator for our pixels that SkMask does, so that we can freely assign memory allocated by one class to the other. */ -bool SkBitmap::HeapAllocator::allocPixelRef(SkBitmap* dst -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - , SkColorTable* -#endif - ) { +bool SkBitmap::HeapAllocator::allocPixelRef(SkBitmap* dst) { const SkImageInfo info = dst->info(); if (kUnknown_SkColorType == info.colorType()) { // SkDebugf("unsupported config for info %d\n", dst->config()); diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp index 189b70e2f3..d5e9360cdc 100644 --- a/src/core/SkPixelRef.cpp +++ b/src/core/SkPixelRef.cpp @@ -48,26 +48,6 @@ SkPixelRef::SkPixelRef(int width, int height, void* pixels, size_t rowBytes) fAddedToCache.store(false); } -#ifdef SK_SUPPORT_LEGACY_COLORTABLE -SkPixelRef::SkPixelRef(int width, int height, void* pixels, size_t rowBytes, sk_sp<SkColorTable>) - : fWidth(width) - , fHeight(height) - , fPixels(pixels) - , fRowBytes(rowBytes) -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK - , fStableID(SkNextID::ImageID()) -#endif -{ -#ifdef SK_TRACE_PIXELREF_LIFETIME - SkDebugf(" pixelref %d\n", sk_atomic_inc(&gInstCounter)); -#endif - - this->needsNewGenID(); - fMutability = kMutable; - fAddedToCache.store(false); -} -#endif - SkPixelRef::~SkPixelRef() { #ifdef SK_TRACE_PIXELREF_LIFETIME SkDebugf("~pixelref %d\n", sk_atomic_dec(&gInstCounter) - 1); @@ -76,11 +56,7 @@ SkPixelRef::~SkPixelRef() { } // This is undefined if there are clients in-flight trying to use us -void SkPixelRef::android_only_reset(int width, int height, size_t rowBytes -#ifdef SK_SUPPORT_LEGACY_COLORTABLE - , sk_sp<SkColorTable> ctable -#endif - ) { +void SkPixelRef::android_only_reset(int width, int height, size_t rowBytes) { fWidth = width; fHeight = height; fRowBytes = rowBytes; |