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

Side by Side Diff: include/gpu/GrTypes.h

Issue 762553006: Fix assert in GrMaskFormatBytesPerPixel. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add bikeshed improvements Created 6 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 10
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 kLastPublicGrBlendCoeff = kIConstA_GrBlendCoeff, 221 kLastPublicGrBlendCoeff = kIConstA_GrBlendCoeff,
222 }; 222 };
223 static const int kPublicGrBlendCoeffCount = kLastPublicGrBlendCoeff + 1; 223 static const int kPublicGrBlendCoeffCount = kLastPublicGrBlendCoeff + 1;
224 224
225 /** 225 /**
226 * Formats for masks, used by the font cache. 226 * Formats for masks, used by the font cache.
227 * Important that these are 0-based. 227 * Important that these are 0-based.
228 */ 228 */
229 enum GrMaskFormat { 229 enum GrMaskFormat {
230 kA8_GrMaskFormat, //!< 1-byte per pixel 230 kA8_GrMaskFormat, //!< 1-byte per pixel
231 kA565_GrMaskFormat, //!< 2-bytes per pixel 231 kA565_GrMaskFormat, //!< 2-bytes per pixel, RGB represent 3-channel LCD cov erage
232 kARGB_GrMaskFormat, //!< 4-bytes per pixel, color format 232 kARGB_GrMaskFormat, //!< 4-bytes per pixel, color format
233 233
234 kLast_GrMaskFormat = kARGB_GrMaskFormat 234 kLast_GrMaskFormat = kARGB_GrMaskFormat
235 }; 235 };
236 static const int kMaskFormatCount = kLast_GrMaskFormat + 1; 236 static const int kMaskFormatCount = kLast_GrMaskFormat + 1;
237 237
238 /** 238 /**
239 * Return the number of bytes-per-pixel for the specified mask format. 239 * Return the number of bytes-per-pixel for the specified mask format.
240 */ 240 */
241 static inline int GrMaskFormatBytesPerPixel(GrMaskFormat format) { 241 static inline int GrMaskFormatBytesPerPixel(GrMaskFormat format) {
242 SkASSERT((unsigned)format <= 3); 242 SkASSERT((unsigned)format < kMaskFormatCount);
243 // kA8 (0) -> 1 243 // kA8 (0) -> 1
244 // kA565 (1) -> 2 244 // kA565 (1) -> 2
245 // kARGB (3) -> 4 245 // kARGB (2) -> 4
246 static const int sBytesPerPixel[] = { 1, 2, 4 }; 246 static const int sBytesPerPixel[] = { 1, 2, 4 };
247 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(sBytesPerPixel) == kMaskFormatCount, array_ size_mismatch); 247 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(sBytesPerPixel) == kMaskFormatCount, array_ size_mismatch);
248 SK_COMPILE_ASSERT(kA8_GrMaskFormat == 0, enum_order_dependency);
249 SK_COMPILE_ASSERT(kA565_GrMaskFormat == 1, enum_order_dependency);
250 SK_COMPILE_ASSERT(kARGB_GrMaskFormat == 2, enum_order_dependency);
248 251
249 return sBytesPerPixel[(int) format]; 252 return sBytesPerPixel[(int) format];
250 } 253 }
251 254
252 /** 255 /**
253 * Pixel configurations. 256 * Pixel configurations.
254 */ 257 */
255 enum GrPixelConfig { 258 enum GrPixelConfig {
256 kUnknown_GrPixelConfig, 259 kUnknown_GrPixelConfig,
257 kAlpha_8_GrPixelConfig, 260 kAlpha_8_GrPixelConfig,
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 public: 716 public:
714 GrAutoMalloc() : INHERITED() {} 717 GrAutoMalloc() : INHERITED() {}
715 explicit GrAutoMalloc(size_t size) : INHERITED(size) {} 718 explicit GrAutoMalloc(size_t size) : INHERITED(size) {}
716 virtual ~GrAutoMalloc() {} 719 virtual ~GrAutoMalloc() {}
717 private: 720 private:
718 typedef GrAutoMallocBaseType INHERITED; 721 typedef GrAutoMallocBaseType INHERITED;
719 }; 722 };
720 723
721 #undef GrAutoMallocBaseType 724 #undef GrAutoMallocBaseType
722 #endif 725 #endif
OLDNEW
« 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