Finish removal of SkImageInfo from SkPixelRef
authorMatt Sarett <msarett@google.com>
Tue, 2 May 2017 15:41:30 +0000 (11:41 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Thu, 4 May 2017 12:54:10 +0000 (12:54 +0000)
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>

gn/android_framework_defines.gni
include/core/SkPixelRef.h
src/core/SkPixelRef.cpp

index bc49f4b..67c6a2d 100644 (file)
@@ -9,7 +9,6 @@ android_framework_defines = [
   "SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS",
   "SK_SUPPORT_LEGACY_GRADIENT_DITHERING",
   "SK_SUPPORT_LEGACY_DRAWFILTER",
-  "SK_SUPPORT_LEGACY_PIXELREF_API",
   "SK_IGNORE_GPU_DITHER",
   "SK_SUPPORT_LEGACY_SHADER_ISABITMAP",
   "SK_SUPPORT_LEGACY_EMBOSSMASKFILTER",
index bf46098..4613209 100644 (file)
@@ -32,43 +32,13 @@ class SkDiscardableMemory;
 */
 class SK_API SkPixelRef : public SkRefCnt {
 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() override;
 
-    int width() const { return fInfo.width(); }
-    int height() const { return fInfo.height(); }
+    int width() const { return fWidth; }
+    int height() const { return fHeight; }
     void* pixels() const { return fPixels; }
     SkColorTable* colorTable() const { return fCTable.get(); }
     size_t rowBytes() const { return fRowBytes; }
@@ -143,9 +113,8 @@ protected:
 #endif
 
 private:
-    // TODO (msarett): After we remove legacy APIs, we should replace |fInfo| with just a width
-    //                 and height.
-    const SkImageInfo   fInfo;
+    int                 fWidth;
+    int                 fHeight;
     sk_sp<SkColorTable> fCTable;
     void*               fPixels;
     size_t              fRowBytes;
index 7d8b12d..4583c18 100644 (file)
@@ -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;
 }