aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkImageInfo.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-05-22 08:06:21 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-22 08:06:22 -0700
commit92fc2ae58331662ec411a048686cb4801e0a909a (patch)
tree8b49c125bd366e77fcdff77788e6965912758dc9 /include/core/SkImageInfo.h
parenteb1cb5c5b50febad115d859faca91d2d6af3fff2 (diff)
add SkPixmap and external locking to bitmaps
Diffstat (limited to 'include/core/SkImageInfo.h')
-rw-r--r--include/core/SkImageInfo.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h
index 01318fd1aa..daa50dcdb2 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));
}