Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: include/core/SkPixmap.h

Issue 1826233002: Add rowBytesAsPixels and shiftPerPixel to SkPixmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add cast Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPixmap.h
diff --git a/include/core/SkPixmap.h b/include/core/SkPixmap.h
index 3a7abdf13451f712f4e47f10a81d44c713d4f8ce..5f90273a97dacfba6217e820217546c78d8b73a8 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); }
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698