| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkImageInfo_DEFINED | 8 #ifndef SkImageInfo_DEFINED |
| 9 #define SkImageInfo_DEFINED | 9 #define SkImageInfo_DEFINED |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 static inline size_t SkColorTypeMinRowBytes(SkColorType ct, int width) { | 106 static inline size_t SkColorTypeMinRowBytes(SkColorType ct, int width) { |
| 107 return width * SkColorTypeBytesPerPixel(ct); | 107 return width * SkColorTypeBytesPerPixel(ct); |
| 108 } | 108 } |
| 109 | 109 |
| 110 static inline bool SkColorTypeIsValid(unsigned value) { | 110 static inline bool SkColorTypeIsValid(unsigned value) { |
| 111 return value <= kLastEnum_SkColorType; | 111 return value <= kLastEnum_SkColorType; |
| 112 } | 112 } |
| 113 | 113 |
| 114 static inline size_t SkColorTypeComputeOffset(SkColorType ct, int x, int y, size
_t rowBytes) { |
| 115 int shift = 0; |
| 116 switch (SkColorTypeBytesPerPixel(ct)) { |
| 117 case 4: shift = 2; break; |
| 118 case 2: shift = 1; break; |
| 119 case 1: shift = 0; break; |
| 120 default: return 0; |
| 121 } |
| 122 return y * rowBytes + (x << shift); |
| 123 } |
| 124 |
| 114 /////////////////////////////////////////////////////////////////////////////// | 125 /////////////////////////////////////////////////////////////////////////////// |
| 115 | 126 |
| 116 /** | 127 /** |
| 117 * Return true if alphaType is supported by colorType. If there is a canonical | 128 * Return true if alphaType is supported by colorType. If there is a canonical |
| 118 * alphaType for this colorType, return it in canonical. | 129 * alphaType for this colorType, return it in canonical. |
| 119 */ | 130 */ |
| 120 bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, | 131 bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, |
| 121 SkAlphaType* canonical = NULL); | 132 SkAlphaType* canonical = NULL); |
| 122 | 133 |
| 123 /////////////////////////////////////////////////////////////////////////////// | 134 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 251 } |
| 241 | 252 |
| 242 uint64_t minRowBytes64() const { | 253 uint64_t minRowBytes64() const { |
| 243 return sk_64_mul(fWidth, this->bytesPerPixel()); | 254 return sk_64_mul(fWidth, this->bytesPerPixel()); |
| 244 } | 255 } |
| 245 | 256 |
| 246 size_t minRowBytes() const { | 257 size_t minRowBytes() const { |
| 247 return (size_t)this->minRowBytes64(); | 258 return (size_t)this->minRowBytes64(); |
| 248 } | 259 } |
| 249 | 260 |
| 261 size_t computeOffset(int x, int y, size_t rowBytes) const { |
| 262 SkASSERT((unsigned)x < (unsigned)fWidth); |
| 263 SkASSERT((unsigned)y < (unsigned)fHeight); |
| 264 return SkColorTypeComputeOffset(fColorType, x, y, rowBytes); |
| 265 } |
| 266 |
| 250 bool operator==(const SkImageInfo& other) const { | 267 bool operator==(const SkImageInfo& other) const { |
| 251 return 0 == memcmp(this, &other, sizeof(other)); | 268 return 0 == memcmp(this, &other, sizeof(other)); |
| 252 } | 269 } |
| 253 bool operator!=(const SkImageInfo& other) const { | 270 bool operator!=(const SkImageInfo& other) const { |
| 254 return 0 != memcmp(this, &other, sizeof(other)); | 271 return 0 != memcmp(this, &other, sizeof(other)); |
| 255 } | 272 } |
| 256 | 273 |
| 257 void unflatten(SkReadBuffer&); | 274 void unflatten(SkReadBuffer&); |
| 258 void flatten(SkWriteBuffer&) const; | 275 void flatten(SkWriteBuffer&) const; |
| 259 | 276 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 , fHeight(height) | 308 , fHeight(height) |
| 292 , fColorType(ct) | 309 , fColorType(ct) |
| 293 , fAlphaType(at) | 310 , fAlphaType(at) |
| 294 , fProfileType(pt) | 311 , fProfileType(pt) |
| 295 {} | 312 {} |
| 296 | 313 |
| 297 SkColorProfileType fProfileType; | 314 SkColorProfileType fProfileType; |
| 298 }; | 315 }; |
| 299 | 316 |
| 300 #endif | 317 #endif |
| OLD | NEW |