guard references to SkColorTable
Bug: skia:6828
Change-Id: I0c8c78e70b118f51cb59dc45675e4ddcd4776108
Reviewed-on: https://skia-review.googlesource.com/24260
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index ad9752d..cf8d4ba 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1506,9 +1506,9 @@
SkAlphaType alphaType = kPremul_SkAlphaType;
(void)SkColorTypeValidateAlphaType(fColorType, alphaType, &alphaType);
- dst->allocPixels(SkImageInfo::Make(size.width(), size.height(),
- fColorType, alphaType, fColorSpace),
- nullptr/*colortable*/, SkBitmap::kZeroPixels_AllocFlag);
+ dst->allocPixelsFlags(SkImageInfo::Make(size.width(), size.height(),
+ fColorType, alphaType, fColorSpace),
+ SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(*dst);
return src.draw(&canvas);
}
diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp
index d6109b3..e030979 100644
--- a/fuzz/fuzz.cpp
+++ b/fuzz/fuzz.cpp
@@ -209,7 +209,7 @@
SkCodec::Options options;
options.fZeroInitialized = SkCodec::kYes_ZeroInitialized;
- if (!bitmap.tryAllocPixels(decodeInfo, nullptr, SkBitmap::kZeroPixels_AllocFlag)) {
+ if (!bitmap.tryAllocPixelsFlags(decodeInfo, SkBitmap::kZeroPixels_AllocFlag)) {
SkDebugf("[terminated] Could not allocate memory. Image might be too large (%d x %d)",
decodeInfo.width(), decodeInfo.height());
return;
diff --git a/gm/composeshader.cpp b/gm/composeshader.cpp
index a6210c9..3806993 100644
--- a/gm/composeshader.cpp
+++ b/gm/composeshader.cpp
@@ -243,10 +243,10 @@
SkImageInfo imageInfo = SkImageInfo::Make(width, height,
SkColorType::kN32_SkColorType, kPremul_SkAlphaType);
skBitmap.installPixels(imageInfo, dst32Storage.begin(), width * sizeof(int32_t),
- nullptr, nullptr, nullptr);
+ nullptr, nullptr);
imageInfo = SkImageInfo::Make(width, height,
SkColorType::kAlpha_8_SkColorType, kPremul_SkAlphaType);
- skMask.installPixels(imageInfo, dst8Storage.begin(), width, nullptr, nullptr, nullptr);
+ skMask.installPixels(imageInfo, dst8Storage.begin(), width, nullptr, nullptr);
sk_sp<SkImage> skSrc = SkImage::MakeFromBitmap(skBitmap);
sk_sp<SkImage> skMaskImage = SkImage::MakeFromBitmap(skMask);
paint.setShader(
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 0009641..6b48613 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -9,7 +9,9 @@
#define SkBitmap_DEFINED
#include "SkColor.h"
+#ifdef SK_SUPPORT_LEGACY_COLORTABLE
#include "SkColorTable.h"
+#endif
#include "SkImageInfo.h"
#include "SkPixmap.h"
#include "SkPoint.h"
@@ -240,6 +242,7 @@
enum AllocFlags {
kZeroPixels_AllocFlag = 1 << 0,
};
+
/**
* 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
@@ -247,14 +250,23 @@
*
* On failure, the bitmap will be set to empty and return false.
*/
- bool SK_WARN_UNUSED_RESULT tryAllocPixels(const SkImageInfo& info, sk_sp<SkColorTable> ctable,
- uint32_t flags = 0);
- void allocPixels(const SkImageInfo& info, sk_sp<SkColorTable>, uint32_t flags = 0) {
- if (!this->tryAllocPixels(info, nullptr, flags)) {
+ bool SK_WARN_UNUSED_RESULT tryAllocPixelsFlags(const SkImageInfo& info, uint32_t flags);
+ void allocPixelsFlags(const SkImageInfo& info, uint32_t flags) {
+ if (!this->tryAllocPixelsFlags(info, flags)) {
sk_throw();
}
}
+#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
@@ -291,10 +303,12 @@
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
@@ -306,7 +320,7 @@
* If specified, the releaseProc will always be called, even on failure. It is also possible
* for success but the releaseProc is immediately called (e.g. valid Info but NULL pixels).
*/
- bool installPixels(const SkImageInfo&, void* pixels, size_t rowBytes, SkColorTable*,
+ bool installPixels(const SkImageInfo&, void* pixels, size_t rowBytes,
void (*releaseProc)(void* addr, void* context), void* context);
/**
@@ -315,9 +329,16 @@
* of the created bitmap (and its pixelRef).
*/
bool installPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
- return this->installPixels(info, pixels, rowBytes, NULL, NULL, NULL);
+ 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
@@ -343,7 +364,7 @@
@param pixels Address for the pixels, managed by the caller.
@param ctable ColorTable (or null) that matches the specified pixels
*/
- void setPixels(void* p, SkColorTable* ctable = NULL);
+ void setPixels(void* p);
/** Use the standard HeapAllocator to create the pixelref that manages the
pixel memory. It will be sized based on the current ImageInfo.
@@ -358,12 +379,12 @@
@return true if the allocation succeeds. If not the pixelref field of
the bitmap will be unchanged.
*/
- bool SK_WARN_UNUSED_RESULT tryAllocPixels(SkColorTable* = NULL) {
- return this->tryAllocPixels(nullptr, nullptr);
+ bool SK_WARN_UNUSED_RESULT tryAllocPixels() {
+ return this->tryAllocPixels((Allocator*)nullptr);
}
- void allocPixels(SkColorTable* = NULL) {
- this->allocPixels(nullptr, nullptr);
+ void allocPixels() {
+ this->allocPixels((Allocator*)nullptr);
}
/** Use the specified Allocator to create the pixelref that manages the
@@ -384,14 +405,33 @@
@return true if the allocation succeeds. If not the pixelref field of
the bitmap will be unchanged.
*/
- bool SK_WARN_UNUSED_RESULT tryAllocPixels(Allocator* allocator, SkColorTable* ctable);
+ bool SK_WARN_UNUSED_RESULT tryAllocPixels(Allocator* allocator);
- void allocPixels(Allocator* allocator, SkColorTable*) {
- if (!this->tryAllocPixels(allocator, nullptr)) {
+ void allocPixels(Allocator* allocator) {
+ if (!this->tryAllocPixels(allocator)) {
sk_throw();
}
}
+#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.
@@ -432,7 +472,9 @@
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
@@ -654,7 +696,11 @@
it also must be installed via setColorTable. If false is returned,
the bitmap and colortable should be left unchanged.
*/
+#ifdef SK_SUPPORT_LEGACY_COLORTABLE
virtual bool allocPixelRef(SkBitmap*, SkColorTable*) = 0;
+#else
+ virtual bool allocPixelRef(SkBitmap*) = 0;
+#endif
private:
typedef SkRefCnt INHERITED;
};
@@ -665,7 +711,11 @@
*/
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()
diff --git a/include/core/SkMallocPixelRef.h b/include/core/SkMallocPixelRef.h
index e6d9727..07a5483 100644
--- a/include/core/SkMallocPixelRef.h
+++ b/include/core/SkMallocPixelRef.h
@@ -5,11 +5,13 @@
* found in the LICENSE file.
*/
-
#ifndef SkMallocPixelRef_DEFINED
#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.
@@ -24,8 +26,7 @@
*
* Returns NULL on failure.
*/
- static sk_sp<SkPixelRef> MakeDirect(const SkImageInfo&, void* addr,
- size_t rowBytes, sk_sp<SkColorTable>);
+ static sk_sp<SkPixelRef> MakeDirect(const SkImageInfo&, void* addr, size_t rowBytes);
/**
* Return a new SkMallocPixelRef, automatically allocating storage for the
@@ -37,12 +38,12 @@
*
* Returns NULL on failure.
*/
- static sk_sp<SkPixelRef> MakeAllocate(const SkImageInfo&, size_t rowBytes, sk_sp<SkColorTable>);
+ static sk_sp<SkPixelRef> MakeAllocate(const SkImageInfo&, size_t rowBytes);
/**
* Identical to MakeAllocate, except all pixel bytes are zeroed.
*/
- static sk_sp<SkPixelRef> MakeZeroed(const SkImageInfo&, size_t rowBytes, sk_sp<SkColorTable>);
+ static sk_sp<SkPixelRef> MakeZeroed(const SkImageInfo&, size_t rowBytes);
/**
* Return a new SkMallocPixelRef with the provided pixel storage,
@@ -57,10 +58,8 @@
* Returns NULL on failure.
*/
typedef void (*ReleaseProc)(void* addr, void* context);
- static sk_sp<SkPixelRef> MakeWithProc(const SkImageInfo& info,
- size_t rowBytes, sk_sp<SkColorTable>,
- void* addr, ReleaseProc proc,
- void* context);
+ static sk_sp<SkPixelRef> MakeWithProc(const SkImageInfo& info, size_t rowBytes, void* addr,
+ ReleaseProc proc, void* context);
/**
* Return a new SkMallocPixelRef that will use the provided
@@ -70,10 +69,32 @@
*
* Returns NULL on failure.
*/
+ 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);
+ sk_sp<SkData> data) {
+ return MakeWithData(info, rowBytes, data);
+ }
+#endif
protected:
~SkMallocPixelRef() override;
@@ -82,14 +103,12 @@
// Uses alloc to implement NewAllocate or NewZeroed.
static sk_sp<SkPixelRef> MakeUsing(void*(*alloc)(size_t),
const SkImageInfo&,
- size_t rowBytes,
- sk_sp<SkColorTable>);
+ size_t rowBytes);
ReleaseProc fReleaseProc;
void* fReleaseProcContext;
- SkMallocPixelRef(const SkImageInfo&, void* addr, size_t rb, sk_sp<SkColorTable>,
- ReleaseProc proc, void* context);
+ SkMallocPixelRef(const SkImageInfo&, void* addr, size_t rb, ReleaseProc proc, void* context);
typedef SkPixelRef INHERITED;
};
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index 5055c04..de8c648 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -19,7 +19,9 @@
#include "SkSize.h"
#include "SkString.h"
+#ifdef SK_SUPPORT_LEGACY_COLORTABLE
class SkColorTable;
+#endif
struct SkIRect;
class GrTexture;
@@ -32,15 +34,12 @@
*/
class SK_API SkPixelRef : public SkRefCnt {
public:
-
- SkPixelRef(int width, int height, void* addr, size_t rowBytes, sk_sp<SkColorTable> = nullptr);
-
+ SkPixelRef(int width, int height, void* addr, size_t rowBytes);
~SkPixelRef() override;
int width() const { return fWidth; }
int height() const { return fHeight; }
void* pixels() const { return fPixels; }
- SkColorTable* colorTable() const { return nullptr; }
size_t rowBytes() const { return fRowBytes; }
/** Returns a non-zero, unique value corresponding to the pixels in this
@@ -103,13 +102,21 @@
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_BUILD_FOR_ANDROID_FRAMEWORK
// This is undefined if there are clients in-flight trying to use us
+#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
#endif
private:
diff --git a/include/core/SkPixmap.h b/include/core/SkPixmap.h
index b21df6e..1ea011b 100644
--- a/include/core/SkPixmap.h
+++ b/include/core/SkPixmap.h
@@ -12,7 +12,9 @@
#include "SkFilterQuality.h"
#include "SkImageInfo.h"
+#ifdef SK_SUPPORT_LEGACY_COLORTABLE
class SkColorTable;
+#endif
class SkData;
struct SkMask;
@@ -26,15 +28,14 @@
: fPixels(NULL), fRowBytes(0), fInfo(SkImageInfo::MakeUnknown(0, 0))
{}
- SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes, SkColorTable* = NULL)
+ SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes)
: fPixels(addr), fRowBytes(rowBytes), fInfo(info)
{}
void reset();
- void reset(const SkImageInfo& info, const void* addr, size_t rowBytes,
- SkColorTable* ctable = NULL);
+ void reset(const SkImageInfo& info, const void* addr, size_t rowBytes);
void reset(const SkImageInfo& info) {
- this->reset(info, NULL, 0, NULL);
+ this->reset(info, NULL, 0);
}
// overrides the colorspace in the SkImageInfo of the pixmap
@@ -57,7 +58,6 @@
const SkImageInfo& info() const { return fInfo; }
size_t rowBytes() const { return fRowBytes; }
const void* addr() const { return fPixels; }
- SkColorTable* ctable() const { return nullptr; }
int width() const { return fInfo.width(); }
int height() const { return fInfo.height(); }
@@ -210,6 +210,17 @@
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/public.bzl b/public.bzl
index e01424e..85a8b9c 100644
--- a/public.bzl
+++ b/public.bzl
@@ -663,6 +663,7 @@
# Required for building dm.
"GR_TEST_UTILS",
# Staging flags for API changes
+ "SK_SUPPORT_LEGACY_COLORTABLE",
# Should remove after we update golden images
"SK_WEBP_ENCODER_USE_DEFAULT_METHOD",
# Temporarily Disable analytic AA for Google3
diff --git a/src/android/SkBitmapRegionCodec.cpp b/src/android/SkBitmapRegionCodec.cpp
index 8944951..e2ab423 100644
--- a/src/android/SkBitmapRegionCodec.cpp
+++ b/src/android/SkBitmapRegionCodec.cpp
@@ -82,7 +82,7 @@
outInfo = outInfo.makeColorType(kAlpha_8_SkColorType).makeAlphaType(kPremul_SkAlphaType);
}
bitmap->setInfo(outInfo);
- if (!bitmap->tryAllocPixels(allocator, nullptr)) {
+ if (!bitmap->tryAllocPixels(allocator)) {
SkCodecPrintf("Error: Could not allocate pixels.\n");
return false;
}
diff --git a/src/core/SkAutoPixmapStorage.cpp b/src/core/SkAutoPixmapStorage.cpp
index 5ad1939..b41bc90 100644
--- a/src/core/SkAutoPixmapStorage.cpp
+++ b/src/core/SkAutoPixmapStorage.cpp
@@ -16,7 +16,7 @@
SkAutoPixmapStorage& SkAutoPixmapStorage::operator=(SkAutoPixmapStorage&& other) {
this->fStorage = other.fStorage;
- this->INHERITED::reset(other.info(), this->fStorage, other.rowBytes(), other.ctable());
+ this->INHERITED::reset(other.info(), this->fStorage, other.rowBytes());
other.fStorage = nullptr;
other.INHERITED::reset();
diff --git a/src/core/SkAutoPixmapStorage.h b/src/core/SkAutoPixmapStorage.h
index 6342a41..0aece1b 100644
--- a/src/core/SkAutoPixmapStorage.h
+++ b/src/core/SkAutoPixmapStorage.h
@@ -57,9 +57,9 @@
this->freeStorage();
this->INHERITED::reset();
}
- void reset(const SkImageInfo& info, const void* addr, size_t rb, SkColorTable* ctable = NULL) {
+ void reset(const SkImageInfo& info, const void* addr, size_t rb) {
this->freeStorage();
- this->INHERITED::reset(info, addr, rb, ctable);
+ this->INHERITED::reset(info, addr, rb);
}
void reset(const SkImageInfo& info) {
this->freeStorage();
@@ -70,6 +70,12 @@
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 298b178..4877d64 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -8,6 +8,7 @@
#include "SkAtomics.h"
#include "SkBitmap.h"
#include "SkColorPriv.h"
+#include "SkColorTable.h"
#include "SkConvertPixels.h"
#include "SkData.h"
#include "SkFilterQuality.h"
@@ -208,7 +209,7 @@
SkDEBUGCODE(this->validate();)
}
-void SkBitmap::setPixels(void* p, SkColorTable* ctable) {
+void SkBitmap::setPixels(void* p) {
if (nullptr == p) {
this->setPixelRef(nullptr, 0, 0);
return;
@@ -219,20 +220,24 @@
return;
}
- this->setPixelRef(SkMallocPixelRef::MakeDirect(fInfo, p, fRowBytes, sk_ref_sp(ctable)), 0, 0);
+ this->setPixelRef(SkMallocPixelRef::MakeDirect(fInfo, p, fRowBytes), 0, 0);
if (!fPixelRef) {
return;
}
SkDEBUGCODE(this->validate();)
}
-bool SkBitmap::tryAllocPixels(Allocator* allocator, SkColorTable* ctable) {
+bool SkBitmap::tryAllocPixels(Allocator* allocator) {
HeapAllocator stdalloc;
if (nullptr == allocator) {
allocator = &stdalloc;
}
- return allocator->allocPixelRef(this, ctable);
+#ifdef SK_SUPPORT_LEGACY_COLORTABLE
+ return allocator->allocPixelRef(this, nullptr);
+#else
+ return allocator->allocPixelRef(this);
+#endif
}
///////////////////////////////////////////////////////////////////////////////
@@ -247,7 +252,7 @@
// setInfo may have computed a valid rowbytes if 0 were passed in
rowBytes = this->rowBytes();
- sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeAllocate(correctedInfo, rowBytes, nullptr);
+ sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeAllocate(correctedInfo, rowBytes);
if (!pr) {
return reset_return_false(this);
}
@@ -259,8 +264,7 @@
return true;
}
-bool SkBitmap::tryAllocPixels(const SkImageInfo& requestedInfo, sk_sp<SkColorTable> ctable,
- uint32_t allocFlags) {
+bool SkBitmap::tryAllocPixelsFlags(const SkImageInfo& requestedInfo, uint32_t allocFlags) {
if (!this->setInfo(requestedInfo)) {
return reset_return_false(this);
}
@@ -269,8 +273,8 @@
const SkImageInfo& correctedInfo = this->info();
sk_sp<SkPixelRef> pr = (allocFlags & kZeroPixels_AllocFlag) ?
- SkMallocPixelRef::MakeZeroed(correctedInfo, correctedInfo.minRowBytes(), ctable) :
- SkMallocPixelRef::MakeAllocate(correctedInfo, correctedInfo.minRowBytes(), ctable);
+ SkMallocPixelRef::MakeZeroed(correctedInfo, correctedInfo.minRowBytes()) :
+ SkMallocPixelRef::MakeAllocate(correctedInfo, correctedInfo.minRowBytes());
if (!pr) {
return reset_return_false(this);
}
@@ -289,8 +293,7 @@
}
bool SkBitmap::installPixels(const SkImageInfo& requestedInfo, void* pixels, size_t rb,
- SkColorTable* ct, void (*releaseProc)(void* addr, void* context),
- void* context) {
+ void (*releaseProc)(void* addr, void* context), void* context) {
if (!this->setInfo(requestedInfo, rb)) {
invoke_release_proc(releaseProc, pixels, context);
this->reset();
@@ -304,8 +307,8 @@
// setInfo may have corrected info (e.g. 565 is always opaque).
const SkImageInfo& correctedInfo = this->info();
- sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeWithProc(correctedInfo, rb, sk_ref_sp(ct),
- pixels, releaseProc, context);
+ sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeWithProc(correctedInfo, rb, pixels,
+ releaseProc, context);
if (!pr) {
this->reset();
return false;
@@ -317,8 +320,7 @@
}
bool SkBitmap::installPixels(const SkPixmap& pixmap) {
- return this->installPixels(pixmap.info(), pixmap.writable_addr(),
- pixmap.rowBytes(), pixmap.ctable(),
+ return this->installPixels(pixmap.info(), pixmap.writable_addr(), pixmap.rowBytes(),
nullptr, nullptr);
}
@@ -356,15 +358,18 @@
/** 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,
- SkColorTable* ctable) {
+bool SkBitmap::HeapAllocator::allocPixelRef(SkBitmap* dst
+#ifdef SK_SUPPORT_LEGACY_COLORTABLE
+ , SkColorTable*
+#endif
+ ) {
const SkImageInfo info = dst->info();
if (kUnknown_SkColorType == info.colorType()) {
// SkDebugf("unsupported config for info %d\n", dst->config());
return false;
}
- sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeAllocate(info, dst->rowBytes(), sk_ref_sp(ctable));
+ sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeAllocate(info, dst->rowBytes());
if (!pr) {
return false;
}
@@ -526,7 +531,7 @@
void* dstPixels = this->getAddr(rec.fX, rec.fY);
const SkImageInfo dstInfo = fInfo.makeWH(rec.fInfo.width(), rec.fInfo.height());
SkConvertPixels(dstInfo, dstPixels, this->rowBytes(), rec.fInfo, rec.fPixels, rec.fRowBytes,
- src.ctable(), behavior);
+ nullptr, behavior);
return true;
}
@@ -545,7 +550,7 @@
return false;
}
SkConvertPixels(SkImageInfo::MakeA8(pmap.width(), pmap.height()), alpha, alphaRowBytes,
- pmap.info(), pmap.addr(), pmap.rowBytes(), pmap.ctable(),
+ pmap.info(), pmap.addr(), pmap.rowBytes(), nullptr,
SkTransferFunctionBehavior::kRespect);
return true;
}
@@ -578,7 +583,7 @@
} else {
NO_FILTER_CASE:
tmpBitmap.setInfo(SkImageInfo::MakeA8(this->width(), this->height()), srcM.fRowBytes);
- if (!tmpBitmap.tryAllocPixels(allocator, nullptr)) {
+ if (!tmpBitmap.tryAllocPixels(allocator)) {
// Allocation of pixels for alpha bitmap failed.
SkDebugf("extractAlpha failed to allocate (%d,%d) alpha bitmap\n",
tmpBitmap.width(), tmpBitmap.height());
@@ -602,7 +607,7 @@
tmpBitmap.setInfo(SkImageInfo::MakeA8(dstM.fBounds.width(), dstM.fBounds.height()),
dstM.fRowBytes);
- if (!tmpBitmap.tryAllocPixels(allocator, nullptr)) {
+ if (!tmpBitmap.tryAllocPixels(allocator)) {
// Allocation of pixels for alpha bitmap failed.
SkDebugf("extractAlpha failed to allocate (%d,%d) alpha bitmap\n",
tmpBitmap.width(), tmpBitmap.height());
@@ -702,9 +707,8 @@
SkASSERT(srcRow == dstRow); // first row does not need to be moved
}
- sk_sp<SkColorTable> ctable;
if (buffer->readBool()) {
- ctable = SkColorTable::Create(*buffer);
+ sk_sp<SkColorTable> ctable = SkColorTable::Create(*buffer);
if (!ctable) {
return false;
}
@@ -729,7 +733,7 @@
}
sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeWithData(info, info.minRowBytes(),
- std::move(ctable), std::move(data));
+ std::move(data));
if (!pr) {
return false;
}
@@ -814,7 +818,7 @@
bool SkBitmap::peekPixels(SkPixmap* pmap) const {
if (fPixels) {
if (pmap) {
- pmap->reset(fInfo, fPixels, fRowBytes, this->getColorTable());
+ pmap->reset(fInfo, fPixels, fRowBytes);
}
return true;
}
diff --git a/src/core/SkBitmapCache.cpp b/src/core/SkBitmapCache.cpp
index 50553a0..b876764 100644
--- a/src/core/SkBitmapCache.cpp
+++ b/src/core/SkBitmapCache.cpp
@@ -225,8 +225,7 @@
SkASSERT(fDM->data());
}
- bitmap->installPixels(fInfo, fDM ? fDM->data() : fMalloc, fRowBytes, nullptr,
- ReleaseProc, this);
+ bitmap->installPixels(fInfo, fDM ? fDM->data() : fMalloc, fRowBytes, ReleaseProc, this);
SkBitmapCache_setImmutableWithID(bitmap->pixelRef(), fPrUniqueID);
REC_TRACE(" Rec: [%d] install new pr\n", fPrUniqueID);
diff --git a/src/core/SkBitmapController.cpp b/src/core/SkBitmapController.cpp
index d44f89c..d3e47ae 100644
--- a/src/core/SkBitmapController.cpp
+++ b/src/core/SkBitmapController.cpp
@@ -252,8 +252,7 @@
// fResultBitmap.getPixels() may be null, but our caller knows to check fPixmap.addr()
// and will destroy us if it is nullptr.
- fPixmap.reset(fResultBitmap.info(), fResultBitmap.getPixels(), fResultBitmap.rowBytes(),
- fResultBitmap.getColorTable());
+ fPixmap.reset(fResultBitmap.info(), fResultBitmap.getPixels(), fResultBitmap.rowBytes());
}
SkBitmapController::State* SkDefaultBitmapController::onRequestBitmap(const SkBitmapProvider& bm,
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 28278a9..defe824 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -121,7 +121,7 @@
} else {
// This bitmap has transparency, so we'll zero the pixels (to transparent).
// We use the flag as a faster alloc-then-eraseColor(SK_ColorTRANSPARENT).
- if (!bitmap.tryAllocPixels(info, nullptr/*colortable*/, SkBitmap::kZeroPixels_AllocFlag)) {
+ if (!bitmap.tryAllocPixelsFlags(info, SkBitmap::kZeroPixels_AllocFlag)) {
return nullptr;
}
}
@@ -152,8 +152,7 @@
bool SkBitmapDevice::onPeekPixels(SkPixmap* pmap) {
const SkImageInfo info = fBitmap.info();
if (fBitmap.getPixels() && (kUnknown_SkColorType != info.colorType())) {
- SkColorTable* ctable = nullptr;
- pmap->reset(fBitmap.info(), fBitmap.getPixels(), fBitmap.rowBytes(), ctable);
+ pmap->reset(fBitmap.info(), fBitmap.getPixels(), fBitmap.rowBytes());
return true;
}
return false;
diff --git a/src/core/SkBitmapScaler.cpp b/src/core/SkBitmapScaler.cpp
index c803da7..9e82b92 100644
--- a/src/core/SkBitmapScaler.cpp
+++ b/src/core/SkBitmapScaler.cpp
@@ -241,7 +241,7 @@
// this could be scaling in sRGB.
result.setInfo(SkImageInfo::MakeN32(destWidth, destHeight, source.alphaType(),
sk_ref_sp(source.info().colorSpace())));
- result.allocPixels(allocator, nullptr);
+ result.allocPixels(allocator);
SkPixmap resultPM;
if (!result.peekPixels(&resultPM) || !Resize(resultPM, source, method)) {
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 05b3f1a..dab5be4 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -2974,8 +2974,7 @@
static bool install(SkBitmap* bm, const SkImageInfo& info,
const SkRasterHandleAllocator::Rec& rec) {
- return bm->installPixels(info, rec.fPixels, rec.fRowBytes, nullptr,
- rec.fReleaseProc, rec.fReleaseCtx);
+ return bm->installPixels(info, rec.fPixels, rec.fRowBytes, rec.fReleaseProc, rec.fReleaseCtx);
}
SkRasterHandleAllocator::Handle SkRasterHandleAllocator::allocBitmap(const SkImageInfo& info,
diff --git a/src/core/SkMallocPixelRef.cpp b/src/core/SkMallocPixelRef.cpp
index bda14bb..6928f38 100644
--- a/src/core/SkMallocPixelRef.cpp
+++ b/src/core/SkMallocPixelRef.cpp
@@ -15,45 +15,30 @@
sk_free(ptr);
}
-static bool is_valid(const SkImageInfo& info, SkColorTable* ctable) {
+static bool is_valid(const SkImageInfo& info) {
if (info.width() < 0 || info.height() < 0 ||
(unsigned)info.colorType() > (unsigned)kLastEnum_SkColorType ||
(unsigned)info.alphaType() > (unsigned)kLastEnum_SkAlphaType)
{
return false;
}
-
- // these seem like good checks, but currently we have (at least) tests
- // that expect the pixelref to succeed even when there is a mismatch
- // with colortables. fix?
-#if 0
- if (kIndex8_SkColorType == info.fColorType && nullptr == ctable) {
- return false;
- }
- if (kIndex8_SkColorType != info.fColorType && ctable) {
- return false;
- }
-#endif
return true;
}
sk_sp<SkPixelRef> SkMallocPixelRef::MakeDirect(const SkImageInfo& info,
void* addr,
- size_t rowBytes,
- sk_sp<SkColorTable> ctable) {
- if (!is_valid(info, ctable.get())) {
+ size_t rowBytes) {
+ if (!is_valid(info)) {
return nullptr;
}
- return sk_sp<SkPixelRef>(new SkMallocPixelRef(info, addr, rowBytes, std::move(ctable),
- nullptr, nullptr));
+ return sk_sp<SkPixelRef>(new SkMallocPixelRef(info, addr, rowBytes, nullptr, nullptr));
}
sk_sp<SkPixelRef> SkMallocPixelRef::MakeUsing(void*(*alloc)(size_t),
const SkImageInfo& info,
- size_t requestedRowBytes,
- sk_sp<SkColorTable> ctable) {
- if (!is_valid(info, ctable.get())) {
+ size_t requestedRowBytes) {
+ if (!is_valid(info)) {
return nullptr;
}
@@ -85,21 +70,19 @@
return nullptr;
}
- return sk_sp<SkPixelRef>(new SkMallocPixelRef(info, addr, rowBytes, std::move(ctable),
+ return sk_sp<SkPixelRef>(new SkMallocPixelRef(info, addr, rowBytes,
sk_free_releaseproc, nullptr));
}
sk_sp<SkPixelRef> SkMallocPixelRef::MakeAllocate(const SkImageInfo& info,
- size_t rowBytes,
- sk_sp<SkColorTable> ctable) {
+ size_t rowBytes) {
auto sk_malloc_nothrow = [](size_t size) { return sk_malloc_flags(size, 0); };
- return MakeUsing(sk_malloc_nothrow, info, rowBytes, std::move(ctable));
+ return MakeUsing(sk_malloc_nothrow, info, rowBytes);
}
sk_sp<SkPixelRef> SkMallocPixelRef::MakeZeroed(const SkImageInfo& info,
- size_t rowBytes,
- sk_sp<SkColorTable> ctable) {
- return MakeUsing(sk_calloc, info, rowBytes, std::move(ctable));
+ size_t rowBytes) {
+ return MakeUsing(sk_calloc, info, rowBytes);
}
static void sk_data_releaseproc(void*, void* dataPtr) {
@@ -108,26 +91,23 @@
sk_sp<SkPixelRef> SkMallocPixelRef::MakeWithProc(const SkImageInfo& info,
size_t rowBytes,
- sk_sp<SkColorTable> ctable,
void* addr,
SkMallocPixelRef::ReleaseProc proc,
void* context) {
- if (!is_valid(info, ctable.get())) {
+ if (!is_valid(info)) {
if (proc) {
proc(addr, context);
}
return nullptr;
}
- return sk_sp<SkPixelRef>(new SkMallocPixelRef(info, addr, rowBytes, std::move(ctable),
- proc, context));
+ return sk_sp<SkPixelRef>(new SkMallocPixelRef(info, addr, rowBytes, proc, context));
}
sk_sp<SkPixelRef> SkMallocPixelRef::MakeWithData(const SkImageInfo& info,
size_t rowBytes,
- sk_sp<SkColorTable> ctable,
sk_sp<SkData> data) {
SkASSERT(data != nullptr);
- if (!is_valid(info, ctable.get())) {
+ if (!is_valid(info)) {
return nullptr;
}
if ((rowBytes < info.minRowBytes()) || (data->size() < info.getSafeSize(rowBytes))) {
@@ -135,7 +115,7 @@
}
// must get this address before we call release
void* pixels = const_cast<void*>(data->data());
- SkPixelRef* pr = new SkMallocPixelRef(info, pixels, rowBytes, std::move(ctable),
+ SkPixelRef* pr = new SkMallocPixelRef(info, pixels, rowBytes,
sk_data_releaseproc, data.release());
pr->setImmutable(); // since we were created with (immutable) data
return sk_sp<SkPixelRef>(pr);
@@ -143,16 +123,11 @@
///////////////////////////////////////////////////////////////////////////////
-static sk_sp<SkColorTable> sanitize(const SkImageInfo& info, sk_sp<SkColorTable> ctable) {
- ctable.reset(nullptr);
- return ctable;
-}
-
SkMallocPixelRef::SkMallocPixelRef(const SkImageInfo& info, void* storage,
- size_t rowBytes, sk_sp<SkColorTable> ctable,
+ size_t rowBytes,
SkMallocPixelRef::ReleaseProc proc,
void* context)
- : INHERITED(info.width(), info.height(), storage, rowBytes, sanitize(info, std::move(ctable)))
+ : INHERITED(info.width(), info.height(), storage, rowBytes)
, fReleaseProc(proc)
, fReleaseProcContext(context)
{}
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index 8e35848..e044286 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -30,6 +30,25 @@
static int32_t gInstCounter;
#endif
+SkPixelRef::SkPixelRef(int width, int height, void* pixels, size_t rowBytes)
+ : 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);
+}
+
+#ifdef SK_SUPPORT_LEGACY_COLORTABLE
SkPixelRef::SkPixelRef(int width, int height, void* pixels, size_t rowBytes, sk_sp<SkColorTable>)
: fWidth(width)
, fHeight(height)
@@ -47,6 +66,7 @@
fMutability = kMutable;
fAddedToCache.store(false);
}
+#endif
SkPixelRef::~SkPixelRef() {
#ifdef SK_TRACE_PIXELREF_LIFETIME
diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp
index 3d35ff5..9bc0e23 100644
--- a/src/core/SkPixmap.cpp
+++ b/src/core/SkPixmap.cpp
@@ -28,7 +28,7 @@
fInfo = SkImageInfo::MakeUnknown();
}
-void SkPixmap::reset(const SkImageInfo& info, const void* addr, size_t rowBytes, SkColorTable*) {
+void SkPixmap::reset(const SkImageInfo& info, const void* addr, size_t rowBytes) {
if (addr) {
SkASSERT(info.validRowBytes(rowBytes));
}
@@ -40,7 +40,7 @@
bool SkPixmap::reset(const SkMask& src) {
if (SkMask::kA8_Format == src.fFormat) {
this->reset(SkImageInfo::MakeA8(src.fBounds.width(), src.fBounds.height()),
- src.fImage, src.fRowBytes, nullptr);
+ src.fImage, src.fRowBytes);
return true;
}
this->reset();
@@ -86,7 +86,7 @@
const void* srcPixels = this->addr(rec.fX, rec.fY);
const SkImageInfo srcInfo = fInfo.makeWH(rec.fInfo.width(), rec.fInfo.height());
SkConvertPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, srcInfo, srcPixels, this->rowBytes(),
- this->ctable(), behavior);
+ nullptr, behavior);
return true;
}
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index 3e812d4..a1b1988 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -105,7 +105,7 @@
return nullptr;
}
- sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeZeroed(info, 0, nullptr);
+ sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeZeroed(info, 0);
if (!pr) {
return nullptr;
}
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 9bd3f2b..b37a607 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -95,7 +95,7 @@
// destination (claim they're linear):
SkImageInfo linSrcInfo = SkImageInfo::Make(pixmap.width(), pixmap.height(),
pixmap.colorType(), pixmap.alphaType());
- SkPixmap linSrcPixmap(linSrcInfo, pixmap.addr(), pixmap.rowBytes(), pixmap.ctable());
+ SkPixmap linSrcPixmap(linSrcInfo, pixmap.addr(), pixmap.rowBytes());
SkImageInfo dstInfo = SkImageInfo::Make(pixmap.width(), pixmap.height(),
kN32_SkColorType, kPremul_SkAlphaType,
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index fa507fe..5dd7943 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -680,8 +680,7 @@
SkAutoPixmapStorage pixmap;
SkImageInfo info;
size_t pixelSize = 0;
- if (!isScaled && this->peekPixels(&pixmap) && !pixmap.ctable() &&
- pixmap.info().colorType() == dstColorType) {
+ if (!isScaled && this->peekPixels(&pixmap) && pixmap.info().colorType() == dstColorType) {
info = pixmap.info();
pixelSize = SkAlign8(pixmap.getSafeSize());
if (!dstColorSpace) {
@@ -723,7 +722,6 @@
return 0;
}
}
- SkASSERT(!decodePixmap.ctable());
if (decodeInfo.colorType() != info.colorType()) {
pixmap.alloc(info);
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index eef8161..5b6ebf0 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -37,8 +37,7 @@
class SkImage_Raster : public SkImage_Base {
public:
- static bool ValidArgs(const Info& info, size_t rowBytes, bool hasColorTable,
- size_t* minSize) {
+ static bool ValidArgs(const Info& info, size_t rowBytes, size_t* minSize) {
const int maxDimension = SK_MaxS32 >> 2;
if (info.width() <= 0 || info.height() <= 0) {
@@ -72,7 +71,7 @@
return true;
}
- SkImage_Raster(const SkImageInfo&, sk_sp<SkData>, size_t rb, SkColorTable*,
+ SkImage_Raster(const SkImageInfo&, sk_sp<SkData>, size_t rb,
uint32_t id = kNeedNewImageUniqueID);
~SkImage_Raster() override;
@@ -139,13 +138,12 @@
data->unref();
}
-SkImage_Raster::SkImage_Raster(const Info& info, sk_sp<SkData> data, size_t rowBytes,
- SkColorTable* ctable, uint32_t id)
+SkImage_Raster::SkImage_Raster(const Info& info, sk_sp<SkData> data, size_t rowBytes, uint32_t id)
: INHERITED(info.width(), info.height(), id)
{
void* addr = const_cast<void*>(data->data());
- fBitmap.installPixels(info, addr, rowBytes, ctable, release_data, data.release());
+ fBitmap.installPixels(info, addr, rowBytes, release_data, data.release());
fBitmap.setImmutable();
}
@@ -258,15 +256,13 @@
sk_sp<SkImage> MakeRasterCopyPriv(const SkPixmap& pmap, uint32_t id) {
size_t size;
- if (!SkImage_Raster::ValidArgs(pmap.info(), pmap.rowBytes(),
- pmap.ctable() != nullptr, &size) || !pmap.addr()) {
+ if (!SkImage_Raster::ValidArgs(pmap.info(), pmap.rowBytes(), &size) || !pmap.addr()) {
return nullptr;
}
// Here we actually make a copy of the caller's pixel data
sk_sp<SkData> data(SkData::MakeWithCopy(pmap.addr(), size));
- return sk_make_sp<SkImage_Raster>(pmap.info(), std::move(data), pmap.rowBytes(), pmap.ctable(),
- id);
+ return sk_make_sp<SkImage_Raster>(pmap.info(), std::move(data), pmap.rowBytes(), id);
}
sk_sp<SkImage> SkImage::MakeRasterCopy(const SkPixmap& pmap) {
@@ -276,7 +272,7 @@
sk_sp<SkImage> SkImage::MakeRasterData(const SkImageInfo& info, sk_sp<SkData> data,
size_t rowBytes) {
size_t size;
- if (!SkImage_Raster::ValidArgs(info, rowBytes, false, &size) || !data) {
+ if (!SkImage_Raster::ValidArgs(info, rowBytes, &size) || !data) {
return nullptr;
}
@@ -285,21 +281,18 @@
return nullptr;
}
- SkColorTable* ctable = nullptr;
- return sk_make_sp<SkImage_Raster>(info, std::move(data), rowBytes, ctable);
+ return sk_make_sp<SkImage_Raster>(info, std::move(data), rowBytes);
}
sk_sp<SkImage> SkImage::MakeFromRaster(const SkPixmap& pmap, RasterReleaseProc proc,
ReleaseContext ctx) {
size_t size;
- if (!SkImage_Raster::ValidArgs(pmap.info(), pmap.rowBytes(), pmap.ctable(), &size) ||
- !pmap.addr())
- {
+ if (!SkImage_Raster::ValidArgs(pmap.info(), pmap.rowBytes(), &size) || !pmap.addr()) {
return nullptr;
}
sk_sp<SkData> data(SkData::MakeWithProc(pmap.addr(), size, proc, ctx));
- return sk_make_sp<SkImage_Raster>(pmap.info(), std::move(data), pmap.rowBytes(), pmap.ctable());
+ return sk_make_sp<SkImage_Raster>(pmap.info(), std::move(data), pmap.rowBytes());
}
sk_sp<SkImage> SkMakeImageFromRasterBitmapPriv(const SkBitmap& bm, SkCopyPixelsMode cpm,
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index 688e234..51b9487 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -99,7 +99,7 @@
const SkSurfaceProps* props)
: INHERITED(info, props)
{
- fBitmap.installPixels(info, pixels, rb, nullptr, releaseProc, context);
+ fBitmap.installPixels(info, pixels, rb, releaseProc, context);
fRowBytes = 0; // don't need to track the rowbytes
fWeOwnThePixels = false; // We are "Direct"
}
@@ -203,7 +203,7 @@
return nullptr;
}
- sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeZeroed(info, rowBytes, nullptr);
+ sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeZeroed(info, rowBytes);
if (!pr) {
return nullptr;
}
diff --git a/src/images/SkJpegEncoder.cpp b/src/images/SkJpegEncoder.cpp
index 2e79a9f..fe228fe 100644
--- a/src/images/SkJpegEncoder.cpp
+++ b/src/images/SkJpegEncoder.cpp
@@ -229,12 +229,11 @@
}
const void* srcRow = fSrc.addr(0, fCurrRow);
- const SkPMColor* colors = fSrc.ctable() ? fSrc.ctable()->readColors() : nullptr;
for (int i = 0; i < numRows; i++) {
JSAMPLE* jpegSrcRow = (JSAMPLE*) srcRow;
if (fEncoderMgr->proc()) {
fEncoderMgr->proc()((char*)fStorage.get(), (const char*)srcRow, fSrc.width(),
- fEncoderMgr->cinfo()->input_components, colors);
+ fEncoderMgr->cinfo()->input_components, nullptr);
jpegSrcRow = fStorage.get();
}
diff --git a/src/images/SkPngEncoder.cpp b/src/images/SkPngEncoder.cpp
index 0b9ef03..748953f 100644
--- a/src/images/SkPngEncoder.cpp
+++ b/src/images/SkPngEncoder.cpp
@@ -9,6 +9,7 @@
#ifdef SK_HAS_PNG_LIBRARY
+#include "SkColorTable.h"
#include "SkImageEncoderFns.h"
#include "SkImageInfoPriv.h"
#include "SkStream.h"
@@ -51,8 +52,6 @@
static std::unique_ptr<SkPngEncoderMgr> Make(SkWStream* stream);
bool setHeader(const SkImageInfo& srcInfo, const SkPngEncoder::Options& options);
- bool setPalette(const SkImageInfo& srcInfo, SkColorTable* colorTable,
- SkTransferFunctionBehavior);
bool setColorSpace(const SkImageInfo& info);
bool writeInfo(const SkImageInfo& srcInfo);
void chooseProc(const SkImageInfo& srcInfo, SkTransferFunctionBehavior unpremulBehavior);
@@ -261,14 +260,6 @@
}
}
-bool SkPngEncoderMgr::setPalette(const SkImageInfo& srcInfo, SkColorTable* colorTable,
- SkTransferFunctionBehavior unpremulBehavior) {
- if (setjmp(png_jmpbuf(fPngPtr))) {
- return false;
- }
- return true;
-}
-
static void set_icc(png_structp png_ptr, png_infop info_ptr, const SkImageInfo& info) {
sk_sp<SkData> icc = icc_from_color_space(info);
if (!icc) {
@@ -337,10 +328,6 @@
return nullptr;
}
- if (!encoderMgr->setPalette(src.info(), src.ctable(), options.fUnpremulBehavior)) {
- return nullptr;
- }
-
if (!encoderMgr->setColorSpace(src.info())) {
return nullptr;
}
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index 02cc2fd..5eca3a4 100644
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -9,7 +9,6 @@
#include "SkBitmapController.h"
#include "SkBitmapProcShader.h"
#include "SkBitmapProvider.h"
-#include "SkColorTable.h"
#include "SkEmptyShader.h"
#include "SkImage_Base.h"
#include "SkImageShader.h"
@@ -303,7 +302,7 @@
auto gather = alloc->make<SkJumper_GatherCtx>();
gather->pixels = pm.addr();
- gather->ctable = pm.ctable() ? pm.ctable()->readColors() : nullptr;
+ gather->ctable = nullptr; // TODO: remove this field
gather->stride = pm.rowBytesAsPixels();
auto limit_x = alloc->make<SkJumper_TileCtx>(),
diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp
index 6377018..17eb700 100644
--- a/src/shaders/gradients/SkGradientShader.cpp
+++ b/src/shaders/gradients/SkGradientShader.cpp
@@ -730,7 +730,7 @@
const SkImageInfo info = SkImageInfo::MakeN32Premul(kCache32Count, kNumberOfDitherRows);
SkASSERT(nullptr == cache->fCache32PixelRef);
- cache->fCache32PixelRef = SkMallocPixelRef::MakeAllocate(info, 0, nullptr);
+ cache->fCache32PixelRef = SkMallocPixelRef::MakeAllocate(info, 0);
cache->fCache32 = (SkPMColor*)cache->fCache32PixelRef->pixels();
if (cache->fShader.fColorCount == 2) {
Build32bitCache(cache->fCache32, cache->fShader.fOrigColors[0],
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp
index d5da4be..09e44ce 100644
--- a/tests/BitmapCopyTest.cpp
+++ b/tests/BitmapCopyTest.cpp
@@ -13,11 +13,7 @@
static void init_src(const SkBitmap& bitmap) {
if (bitmap.getPixels()) {
- if (bitmap.getColorTable()) {
- sk_bzero(bitmap.getPixels(), bitmap.getSize());
- } else {
- bitmap.eraseColor(SK_ColorWHITE);
- }
+ bitmap.eraseColor(SK_ColorWHITE);
}
}
@@ -114,12 +110,6 @@
REPORTER_ASSERT(reporter, copy.width() == W);
REPORTER_ASSERT(reporter, copy.height() == 2);
-
- if (gPairs[i].fColorType == gPairs[j].fColorType) {
- // they should both have, or both not-have, a colortable
- bool hasCT = subset.getColorTable() != nullptr;
- REPORTER_ASSERT(reporter, (copy.getColorTable() != nullptr) == hasCT);
- }
}
}
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp
index e0a7f78..ddc770f 100644
--- a/tests/BitmapTest.cpp
+++ b/tests/BitmapTest.cpp
@@ -33,7 +33,6 @@
REPORTER_ASSERT(reporter, pmap.info() == bm.info());
REPORTER_ASSERT(reporter, pmap.addr() == bm.getPixels());
REPORTER_ASSERT(reporter, pmap.rowBytes() == bm.rowBytes());
- REPORTER_ASSERT(reporter, pmap.ctable() == bm.getColorTable());
}
// https://code.google.com/p/chromium/issues/detail?id=446164
@@ -45,7 +44,7 @@
SkBitmap bm;
REPORTER_ASSERT(reporter, !bm.tryAllocPixels(info));
- sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeAllocate(info, info.minRowBytes(), nullptr);
+ sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeAllocate(info, info.minRowBytes());
REPORTER_ASSERT(reporter, !pr);
}
diff --git a/tests/MallocPixelRefTest.cpp b/tests/MallocPixelRefTest.cpp
index 096e3e6..957c8b3 100644
--- a/tests/MallocPixelRefTest.cpp
+++ b/tests/MallocPixelRefTest.cpp
@@ -26,7 +26,7 @@
SkImageInfo info = SkImageInfo::MakeN32Premul(10, 13);
{
sk_sp<SkPixelRef> pr(
- SkMallocPixelRef::MakeAllocate(info, info.minRowBytes() - 1, nullptr));
+ SkMallocPixelRef::MakeAllocate(info, info.minRowBytes() - 1));
// rowbytes too small.
REPORTER_ASSERT(reporter, nullptr == pr.get());
}
@@ -35,7 +35,7 @@
size_t size = info.getSafeSize(rowBytes);
sk_sp<SkData> data(SkData::MakeUninitialized(size));
sk_sp<SkPixelRef> pr(
- SkMallocPixelRef::MakeWithData(info, rowBytes, nullptr, data));
+ SkMallocPixelRef::MakeWithData(info, rowBytes, data));
// rowbytes too small.
REPORTER_ASSERT(reporter, nullptr == pr.get());
}
@@ -44,7 +44,7 @@
size_t size = info.getSafeSize(rowBytes) - 1;
sk_sp<SkData> data(SkData::MakeUninitialized(size));
sk_sp<SkPixelRef> pr(
- SkMallocPixelRef::MakeWithData(info, rowBytes, nullptr, data));
+ SkMallocPixelRef::MakeWithData(info, rowBytes, data));
// data too small.
REPORTER_ASSERT(reporter, nullptr == pr.get());
}
@@ -53,21 +53,20 @@
{
SkAutoMalloc memory(size);
sk_sp<SkPixelRef> pr(
- SkMallocPixelRef::MakeDirect(info, memory.get(), rowBytes, nullptr));
+ SkMallocPixelRef::MakeDirect(info, memory.get(), rowBytes));
REPORTER_ASSERT(reporter, pr.get() != nullptr);
REPORTER_ASSERT(reporter, memory.get() == pr->pixels());
}
{
sk_sp<SkPixelRef> pr(
- SkMallocPixelRef::MakeAllocate(info, rowBytes, nullptr));
+ SkMallocPixelRef::MakeAllocate(info, rowBytes));
REPORTER_ASSERT(reporter, pr.get() != nullptr);
REPORTER_ASSERT(reporter, pr->pixels());
}
{
void* addr = static_cast<void*>(new uint8_t[size]);
sk_sp<SkPixelRef> pr(
- SkMallocPixelRef::MakeWithProc(info, rowBytes, nullptr, addr,
- delete_uint8_proc, nullptr));
+ SkMallocPixelRef::MakeWithProc(info, rowBytes, addr, delete_uint8_proc, nullptr));
REPORTER_ASSERT(reporter, pr.get() != nullptr);
REPORTER_ASSERT(reporter, addr == pr->pixels());
}
@@ -75,7 +74,7 @@
int x = 0;
SkAutoMalloc memory(size);
sk_sp<SkPixelRef> pr(
- SkMallocPixelRef::MakeWithProc(info, rowBytes, nullptr,
+ SkMallocPixelRef::MakeWithProc(info, rowBytes,
memory.get(), set_to_one_proc,
static_cast<void*>(&x)));
REPORTER_ASSERT(reporter, pr.get() != nullptr);
@@ -89,7 +88,7 @@
int x = 0;
SkAutoMalloc memory(size);
sk_sp<SkPixelRef> pr(
- SkMallocPixelRef::MakeWithProc(SkImageInfo::MakeN32Premul(-1, -1), rowBytes, nullptr,
+ SkMallocPixelRef::MakeWithProc(SkImageInfo::MakeN32Premul(-1, -1), rowBytes,
memory.get(), set_to_one_proc,
static_cast<void*>(&x)));
REPORTER_ASSERT(reporter, pr.get() == nullptr);
@@ -100,7 +99,7 @@
void* addr = static_cast<void*>(new uint8_t[size]);
REPORTER_ASSERT(reporter, addr != nullptr);
sk_sp<SkPixelRef> pr(
- SkMallocPixelRef::MakeWithProc(info, rowBytes, nullptr, addr,
+ SkMallocPixelRef::MakeWithProc(info, rowBytes, addr,
delete_uint8_proc, nullptr));
REPORTER_ASSERT(reporter, addr == pr->pixels());
}
@@ -108,7 +107,7 @@
sk_sp<SkData> data(SkData::MakeUninitialized(size));
SkData* dataPtr = data.get();
REPORTER_ASSERT(reporter, dataPtr->unique());
- sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeWithData(info, rowBytes, nullptr, data);
+ sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeWithData(info, rowBytes, data);
REPORTER_ASSERT(reporter, !(dataPtr->unique()));
data.reset(nullptr);
REPORTER_ASSERT(reporter, dataPtr->unique());
diff --git a/tests/PixelRefTest.cpp b/tests/PixelRefTest.cpp
index 683e249..c978d81 100644
--- a/tests/PixelRefTest.cpp
+++ b/tests/PixelRefTest.cpp
@@ -23,21 +23,21 @@
info = SkImageInfo::MakeN32Premul(0, 0);
release_counter = 1;
- success = bm.installPixels(info, nullptr, 0, nullptr, decrement_counter_proc, &release_counter);
+ success = bm.installPixels(info, nullptr, 0, decrement_counter_proc, &release_counter);
REPORTER_ASSERT(reporter, true == success);
bm.reset();
REPORTER_ASSERT(reporter, 0 == release_counter);
info = SkImageInfo::MakeN32Premul(10, 10);
release_counter = 1;
- success = bm.installPixels(info, nullptr, 0, nullptr, decrement_counter_proc, &release_counter);
+ success = bm.installPixels(info, nullptr, 0, decrement_counter_proc, &release_counter);
REPORTER_ASSERT(reporter, true == success);
bm.reset();
REPORTER_ASSERT(reporter, 0 == release_counter);
info = SkImageInfo::MakeN32Premul(-10, -10);
release_counter = 1;
- success = bm.installPixels(info, nullptr, 0, nullptr, decrement_counter_proc, &release_counter);
+ success = bm.installPixels(info, nullptr, 0, decrement_counter_proc, &release_counter);
REPORTER_ASSERT(reporter, false == success);
bm.reset();
REPORTER_ASSERT(reporter, 0 == release_counter);
@@ -69,7 +69,7 @@
DEF_TEST(PixelRef_GenIDChange, r) {
SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
- sk_sp<SkPixelRef> pixelRef = SkMallocPixelRef::MakeAllocate(info, 0, nullptr);
+ sk_sp<SkPixelRef> pixelRef = SkMallocPixelRef::MakeAllocate(info, 0);
// Register a listener.
int count = 0;
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index e26e134..3aec3e6 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -264,7 +264,7 @@
if (!bm->setInfo(info, rowBytes)) {
return false;
}
- sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeAllocate(info, rowBytes, nullptr);
+ sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeAllocate(info, rowBytes);
bm->setPixelRef(std::move(pr), 0, 0);
return true;
}
diff --git a/tools/debugger/SkDrawCommand.h b/tools/debugger/SkDrawCommand.h
index 1b3d9ab..654cbdd 100644
--- a/tools/debugger/SkDrawCommand.h
+++ b/tools/debugger/SkDrawCommand.h
@@ -10,6 +10,7 @@
#include "SkBitmap.h"
#include "SkCanvas.h"
+#include "SkFlattenable.h"
#include "SkTLazy.h"
#include "SkPath.h"
#include "SkRegion.h"