Finish removal of SkImageInfo from SkPixelRef
All of the clients are updated. We don't need this anymore. Bug: skia:6535 Change-Id: I1399a08b7dda8f29c4f4016a1de50ee8310c1fef Reviewed-on: https://skia-review.googlesource.com/15106 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
This commit is contained in:
parent
b59a9da7eb
commit
bc6e5ff7cf
@ -9,7 +9,6 @@ android_framework_defines = [
|
|||||||
"SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS",
|
"SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS",
|
||||||
"SK_SUPPORT_LEGACY_GRADIENT_DITHERING",
|
"SK_SUPPORT_LEGACY_GRADIENT_DITHERING",
|
||||||
"SK_SUPPORT_LEGACY_DRAWFILTER",
|
"SK_SUPPORT_LEGACY_DRAWFILTER",
|
||||||
"SK_SUPPORT_LEGACY_PIXELREF_API",
|
|
||||||
"SK_IGNORE_GPU_DITHER",
|
"SK_IGNORE_GPU_DITHER",
|
||||||
"SK_SUPPORT_LEGACY_SHADER_ISABITMAP",
|
"SK_SUPPORT_LEGACY_SHADER_ISABITMAP",
|
||||||
"SK_SUPPORT_LEGACY_EMBOSSMASKFILTER",
|
"SK_SUPPORT_LEGACY_EMBOSSMASKFILTER",
|
||||||
|
@ -32,43 +32,13 @@ class SkDiscardableMemory;
|
|||||||
*/
|
*/
|
||||||
class SK_API SkPixelRef : public SkRefCnt {
|
class SK_API SkPixelRef : public SkRefCnt {
|
||||||
public:
|
public:
|
||||||
#ifdef SK_SUPPORT_LEGACY_PIXELREF_API
|
|
||||||
SkPixelRef(const SkImageInfo&, void* addr, size_t rowBytes, sk_sp<SkColorTable> = nullptr);
|
|
||||||
|
|
||||||
const SkImageInfo& info() const {
|
|
||||||
return fInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
|
||||||
// This is undefined if there are clients in-flight trying to use us
|
|
||||||
void android_only_reset(const SkImageInfo&, size_t rowBytes, sk_sp<SkColorTable>);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change the info's AlphaType. Note that this does not automatically
|
|
||||||
* invalidate the generation ID. If the pixel values themselves have
|
|
||||||
* changed, then you must explicitly call notifyPixelsChanged() as well.
|
|
||||||
*/
|
|
||||||
void changeAlphaType(SkAlphaType at);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the size (in bytes) of the internally allocated memory.
|
|
||||||
* This should be implemented in all serializable SkPixelRef derived classes.
|
|
||||||
* SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflow this value,
|
|
||||||
* otherwise the rendering code may attempt to read memory out of bounds.
|
|
||||||
*
|
|
||||||
* @return default impl returns 0.
|
|
||||||
*/
|
|
||||||
virtual size_t getAllocatedSizeInBytes() const { return 0; }
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SkPixelRef(int width, int height, void* addr, size_t rowBytes, sk_sp<SkColorTable> = nullptr);
|
SkPixelRef(int width, int height, void* addr, size_t rowBytes, sk_sp<SkColorTable> = nullptr);
|
||||||
|
|
||||||
~SkPixelRef() override;
|
~SkPixelRef() override;
|
||||||
|
|
||||||
int width() const { return fInfo.width(); }
|
int width() const { return fWidth; }
|
||||||
int height() const { return fInfo.height(); }
|
int height() const { return fHeight; }
|
||||||
void* pixels() const { return fPixels; }
|
void* pixels() const { return fPixels; }
|
||||||
SkColorTable* colorTable() const { return fCTable.get(); }
|
SkColorTable* colorTable() const { return fCTable.get(); }
|
||||||
size_t rowBytes() const { return fRowBytes; }
|
size_t rowBytes() const { return fRowBytes; }
|
||||||
@ -143,9 +113,8 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// TODO (msarett): After we remove legacy APIs, we should replace |fInfo| with just a width
|
int fWidth;
|
||||||
// and height.
|
int fHeight;
|
||||||
const SkImageInfo fInfo;
|
|
||||||
sk_sp<SkColorTable> fCTable;
|
sk_sp<SkColorTable> fCTable;
|
||||||
void* fPixels;
|
void* fPixels;
|
||||||
size_t fRowBytes;
|
size_t fRowBytes;
|
||||||
|
@ -30,51 +30,10 @@ uint32_t SkNextID::ImageID() {
|
|||||||
static int32_t gInstCounter;
|
static int32_t gInstCounter;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SK_SUPPORT_LEGACY_PIXELREF_API
|
|
||||||
|
|
||||||
static SkImageInfo validate_info(const SkImageInfo& info) {
|
|
||||||
SkAlphaType newAlphaType = info.alphaType();
|
|
||||||
SkAssertResult(SkColorTypeValidateAlphaType(info.colorType(), info.alphaType(), &newAlphaType));
|
|
||||||
return info.makeAlphaType(newAlphaType);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void validate_pixels_ctable(const SkImageInfo& info, const SkColorTable* ctable) {
|
|
||||||
if (info.isEmpty()) {
|
|
||||||
return; // can't require ctable if the dimensions are empty
|
|
||||||
}
|
|
||||||
if (kIndex_8_SkColorType == info.colorType()) {
|
|
||||||
SkASSERT(ctable);
|
|
||||||
} else {
|
|
||||||
SkASSERT(nullptr == ctable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SkPixelRef::SkPixelRef(const SkImageInfo& info, void* pixels, size_t rowBytes,
|
|
||||||
sk_sp<SkColorTable> ctable)
|
|
||||||
: fInfo(validate_info(info))
|
|
||||||
, fCTable(std::move(ctable))
|
|
||||||
, fPixels(pixels)
|
|
||||||
, fRowBytes(rowBytes)
|
|
||||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
|
||||||
, fStableID(SkNextID::ImageID())
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
validate_pixels_ctable(fInfo, fCTable.get());
|
|
||||||
SkASSERT(rowBytes >= info.minRowBytes());
|
|
||||||
#ifdef SK_TRACE_PIXELREF_LIFETIME
|
|
||||||
SkDebugf(" pixelref %d\n", sk_atomic_inc(&gInstCounter));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
this->needsNewGenID();
|
|
||||||
fMutability = kMutable;
|
|
||||||
fAddedToCache.store(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SkPixelRef::SkPixelRef(int width, int height, void* pixels, size_t rowBytes,
|
SkPixelRef::SkPixelRef(int width, int height, void* pixels, size_t rowBytes,
|
||||||
sk_sp<SkColorTable> ctable)
|
sk_sp<SkColorTable> ctable)
|
||||||
: fInfo(SkImageInfo::MakeUnknown(width, height))
|
: fWidth(width)
|
||||||
|
, fHeight(height)
|
||||||
, fCTable(std::move(ctable))
|
, fCTable(std::move(ctable))
|
||||||
, fPixels(pixels)
|
, fPixels(pixels)
|
||||||
, fRowBytes(rowBytes)
|
, fRowBytes(rowBytes)
|
||||||
@ -100,25 +59,11 @@ SkPixelRef::~SkPixelRef() {
|
|||||||
|
|
||||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||||
|
|
||||||
#ifdef SK_SUPPORT_LEGACY_PIXELREF_API
|
|
||||||
// This is undefined if there are clients in-flight trying to use us
|
|
||||||
void SkPixelRef::android_only_reset(const SkImageInfo& info, size_t rowBytes,
|
|
||||||
sk_sp<SkColorTable> ctable) {
|
|
||||||
*const_cast<SkImageInfo*>(&fInfo) = info;
|
|
||||||
fRowBytes = rowBytes;
|
|
||||||
fCTable = std::move(ctable);
|
|
||||||
// note: we do not change fPixels
|
|
||||||
|
|
||||||
// conservative, since its possible the "new" settings are the same as the old.
|
|
||||||
this->notifyPixelsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This is undefined if there are clients in-flight trying to use us
|
// 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,
|
void SkPixelRef::android_only_reset(int width, int height, size_t rowBytes,
|
||||||
sk_sp<SkColorTable> ctable) {
|
sk_sp<SkColorTable> ctable) {
|
||||||
*const_cast<SkImageInfo*>(&fInfo) = fInfo.makeWH(width, height);
|
fWidth = width;
|
||||||
|
fHeight = height;
|
||||||
fRowBytes = rowBytes;
|
fRowBytes = rowBytes;
|
||||||
fCTable = std::move(ctable);
|
fCTable = std::move(ctable);
|
||||||
// note: we do not change fPixels
|
// note: we do not change fPixels
|
||||||
@ -187,12 +132,6 @@ void SkPixelRef::notifyPixelsChanged() {
|
|||||||
this->onNotifyPixelsChanged();
|
this->onNotifyPixelsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SK_SUPPORT_LEGACY_PIXELREF_API
|
|
||||||
void SkPixelRef::changeAlphaType(SkAlphaType at) {
|
|
||||||
*const_cast<SkImageInfo*>(&fInfo) = fInfo.makeAlphaType(at);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void SkPixelRef::setImmutable() {
|
void SkPixelRef::setImmutable() {
|
||||||
fMutability = kImmutable;
|
fMutability = kImmutable;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user