remove dead code for getSize, getSafeSize, etc.

Bug: skia:
Change-Id: I7dcdfaa539040b95e5b62174ccd22a94212980e0
Reviewed-on: https://skia-review.googlesource.com/59442
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2017-10-13 09:43:04 -04:00 committed by Skia Commit-Bot
parent ea878b9a6b
commit 3bd0fece5f
4 changed files with 2 additions and 102 deletions

View File

@ -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.
*/

View File

@ -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().

View File

@ -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); }

View File

@ -38,36 +38,6 @@ sk_sp<SkPixelRef> SkMallocPixelRef::MakeDirect(const SkImageInfo& info,
sk_sp<SkPixelRef> 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<SkPixelRef> SkMallocPixelRef::MakeUsing(void*(*allocProc)(size_t),
return nullptr;
}
}
#endif
void* addr = allocProc(size);
if (nullptr == addr) {
return nullptr;