diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index b9300d984a..dcf0b0ea54 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -143,36 +143,10 @@ public: /** * Returns the size (in bytes) of the bitmap's image buffer. - * If the calculation overflows, or if the height is 0, this returns 0. + * If the calculation overflows, this returns max_size_t. */ size_t computeByteSize() const { return fInfo.computeByteSize(fRowBytes); } -#ifdef SK_SUPPORT_LEGACY_SAFESIZE64 - size_t getSize() const { return fInfo.height() * fRowBytes; } - - /** Return the number of bytes from the pointer returned by getPixels() - to the end of the allocated space in the buffer. Required in - cases where extractSubset has been called. - */ - size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); } - - /** - * Return the full size of the bitmap, in bytes. - */ - int64_t computeSize64() const { - return sk_64_mul(fInfo.height(), fRowBytes); - } - - /** - * Return the number of bytes from the pointer returned by getPixels() - * to the end of the allocated space in the buffer. This may be smaller - * than computeSize64() if there is any rowbytes padding beyond the width. - */ - int64_t computeSafeSize64() const { - return fInfo.getSafeSize64(fRowBytes); - } -#endif - /** Returns true if this bitmap is marked as immutable, meaning that the contents of its pixels will not change for the lifetime of the bitmap. */ diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h index c2880909fc..5d2b74af39 100644 --- a/include/core/SkImageInfo.h +++ b/include/core/SkImageInfo.h @@ -300,23 +300,6 @@ public: void unflatten(SkReadBuffer&); void flatten(SkWriteBuffer&) const; -#ifdef SK_SUPPORT_LEGACY_SAFESIZE64 - int64_t getSafeSize64(size_t rowBytes) const { - if (0 == fHeight) { - return 0; - } - return sk_64_mul(fHeight - 1, rowBytes) + sk_64_mul(fWidth, this->bytesPerPixel()); - } - - size_t getSafeSize(size_t rowBytes) const { - int64_t size = this->getSafeSize64(rowBytes); - if (!sk_64_isS32(size)) { - return 0; - } - return sk_64_asS32(size); - } -#endif - /** * Returns the size (in bytes) of the image buffer that this info needs, given the specified * rowBytes. The rowBytes must be >= this->minRowBytes(). diff --git a/include/core/SkPixmap.h b/include/core/SkPixmap.h index f304bde933..3b9f10e073 100644 --- a/include/core/SkPixmap.h +++ b/include/core/SkPixmap.h @@ -206,34 +206,9 @@ public: */ int shiftPerPixel() const { return fInfo.shiftPerPixel(); } -#ifdef SK_SUPPORT_LEGACY_SAFESIZE64 - /** Returns conservative memory required for pixel storage. - Includes unused memory on last row when rowBytesAsPixels() exceeds width(). - - @return conservative pixel storage size - */ - uint64_t getSize64() const { return sk_64_mul(fInfo.height(), fRowBytes); } - - /** Returns minimum memory required for pixel storage. - Does not include unused memory on last row when rowBytesAsPixels() exceeds width(). - - @return exact pixel storage size - */ - uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); } - - /** Returns minimum memory required for pixel storage. - Does not include unused memory on last row when rowBytesAsPixels() exceeds width(). - Returns zero if value is does not fit in a signed 32-bit integer. - The largest value than can be returned is 2,147,483,647. - - @return exact pixel storage size if size fits in signed 32 bits - */ - size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); } -#endif - /** * Returns the size (in bytes) of the pixmap's image buffer. - * If the calculation overflows, or if the height is 0, this returns 0. + * If the calculation overflows, this returns max_size_t. */ size_t computeByteSize() const { return fInfo.computeByteSize(fRowBytes); } diff --git a/src/core/SkMallocPixelRef.cpp b/src/core/SkMallocPixelRef.cpp index 4a34d39170..6e402c98f7 100644 --- a/src/core/SkMallocPixelRef.cpp +++ b/src/core/SkMallocPixelRef.cpp @@ -38,36 +38,6 @@ sk_sp SkMallocPixelRef::MakeDirect(const SkImageInfo& info, sk_sp SkMallocPixelRef::MakeUsing(void*(*allocProc)(size_t), const SkImageInfo& info, size_t requestedRowBytes) { -#ifdef SK_SUPPORT_LEGACY_SAFESIZE64 - if (!is_valid(info)) { - return nullptr; - } - - // only want to permit 31bits of rowBytes - int64_t minRB = (int64_t)info.minRowBytes64(); - if (minRB < 0 || !sk_64_isS32(minRB)) { - return nullptr; // allocation will be too large - } - if (requestedRowBytes > 0 && (int32_t)requestedRowBytes < minRB) { - return nullptr; // cannot meet requested rowbytes - } - - int32_t rowBytes; - if (requestedRowBytes) { - rowBytes = SkToS32(requestedRowBytes); - } else { - rowBytes = minRB; - } - - int64_t bigSize = (int64_t)info.height() * rowBytes; - if (!sk_64_isS32(bigSize)) { - return nullptr; - } - - size_t size = sk_64_asS32(bigSize); - SkASSERT(size >= info.getSafeSize(rowBytes)); - SkASSERT(info.getSafeSize(rowBytes) == info.computeByteSize(rowBytes)); -#else size_t rowBytes = requestedRowBytes; if (rowBytes == 0) { rowBytes = info.minRowBytes(); @@ -84,8 +54,6 @@ sk_sp SkMallocPixelRef::MakeUsing(void*(*allocProc)(size_t), return nullptr; } } -#endif - void* addr = allocProc(size); if (nullptr == addr) { return nullptr;