diff --git a/include/core/SkPixmap.h b/include/core/SkPixmap.h index 3a7abdf134..5f90273a97 100644 --- a/include/core/SkPixmap.h +++ b/include/core/SkPixmap.h @@ -71,6 +71,17 @@ public: SkIRect bounds() const { return SkIRect::MakeWH(this->width(), this->height()); } + /** + * Return the rowbytes expressed as a number of pixels (like width and height). + */ + int rowBytesAsPixels() const { return int(fRowBytes >> this->shiftPerPixel()); } + + /** + * Return the shift amount per pixel (i.e. 0 for 1-byte per pixel, 1 for 2-bytes per pixel + * colortypes, 2 for 4-bytes per pixel colortypes). Return 0 for kUnknown_SkColorType. + */ + int shiftPerPixel() const { return fInfo.bytesPerPixel() >> 1; } + uint64_t getSize64() const { return sk_64_mul(fInfo.height(), fRowBytes); } uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); } size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); }