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

Unified Diff: include/core/SkImageInfo.h

Issue 1074983003: add SkPixmap and external locking to bitmaps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 7 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
Index: include/core/SkImageInfo.h
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h
index 01318fd1aa95e5b64f445bcf952a2b8adadc4a88..daa50dcdb22a28fae6d4182dbe595471a0786e44 100644
--- a/include/core/SkImageInfo.h
+++ b/include/core/SkImageInfo.h
@@ -111,6 +111,17 @@ static inline bool SkColorTypeIsValid(unsigned value) {
return value <= kLastEnum_SkColorType;
}
+static inline size_t SkColorTypeComputeOffset(SkColorType ct, int x, int y, size_t rowBytes) {
+ int shift = 0;
+ switch (SkColorTypeBytesPerPixel(ct)) {
+ case 4: shift = 2; break;
+ case 2: shift = 1; break;
+ case 1: shift = 0; break;
+ default: return 0;
+ }
+ return y * rowBytes + (x << shift);
+}
+
///////////////////////////////////////////////////////////////////////////////
/**
@@ -247,6 +258,12 @@ public:
return (size_t)this->minRowBytes64();
}
+ size_t computeOffset(int x, int y, size_t rowBytes) const {
+ SkASSERT((unsigned)x < (unsigned)fWidth);
+ SkASSERT((unsigned)y < (unsigned)fHeight);
+ return SkColorTypeComputeOffset(fColorType, x, y, rowBytes);
+ }
+
bool operator==(const SkImageInfo& other) const {
return 0 == memcmp(this, &other, sizeof(other));
}
« no previous file with comments | « include/core/SkBitmap.h ('k') | include/core/SkPixelRef.h » ('j') | include/core/SkPixmap.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698