Add rowBytesAsPixels and shiftPerPixel to SkPixmap
This is intended to make it easier to manipulate SkBitmaps and SkPixmaps in a parallel manner (e.g., in https://codereview.chromium.org/1819393002/ (Switch SkMorphologyImageFilter over to new onFilterImage interface)) GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1826233002 Review URL: https://codereview.chromium.org/1826233002
This commit is contained in:
parent
41c409634c
commit
3b5bea9d57
@ -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); }
|
||||
|
Loading…
Reference in New Issue
Block a user