diff options
author | 2017-05-02 11:41:30 -0400 | |
---|---|---|
committer | 2017-05-04 12:54:10 +0000 | |
commit | bc6e5ff7cfbacc28659c0aecbe9f2989cad80336 (patch) | |
tree | 8e77e072573b08d229ca7f1254afd579c9d8e1e4 /src/core | |
parent | b59a9da7eba4ea5f3101b87deae3d67395c58a7e (diff) |
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>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkPixelRef.cpp | 69 |
1 files changed, 4 insertions, 65 deletions
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp index 7d8b12d2ff..4583c18978 100644 --- a/src/core/SkPixelRef.cpp +++ b/src/core/SkPixelRef.cpp @@ -30,51 +30,10 @@ uint32_t SkNextID::ImageID() { static int32_t gInstCounter; #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, sk_sp<SkColorTable> ctable) - : fInfo(SkImageInfo::MakeUnknown(width, height)) + : fWidth(width) + , fHeight(height) , fCTable(std::move(ctable)) , fPixels(pixels) , fRowBytes(rowBytes) @@ -100,25 +59,11 @@ SkPixelRef::~SkPixelRef() { #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 void SkPixelRef::android_only_reset(int width, int height, size_t rowBytes, sk_sp<SkColorTable> ctable) { - *const_cast<SkImageInfo*>(&fInfo) = fInfo.makeWH(width, height); + fWidth = width; + fHeight = height; fRowBytes = rowBytes; fCTable = std::move(ctable); // note: we do not change fPixels @@ -187,12 +132,6 @@ void SkPixelRef::notifyPixelsChanged() { this->onNotifyPixelsChanged(); } -#ifdef SK_SUPPORT_LEGACY_PIXELREF_API -void SkPixelRef::changeAlphaType(SkAlphaType at) { - *const_cast<SkImageInfo*>(&fInfo) = fInfo.makeAlphaType(at); -} -#endif - void SkPixelRef::setImmutable() { fMutability = kImmutable; } |