| 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));
|
| }
|
|
|