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 /* | 8 /* |
9 * Error codes used by gmmain.cpp. | 9 * Error codes used by gmmain.cpp. |
10 */ | 10 */ |
11 | 11 |
| 12 #ifndef gm_error_DEFINED |
| 13 #define gm_error_DEFINED |
| 14 |
| 15 #include "gm.h" |
| 16 |
12 namespace skiagm { | 17 namespace skiagm { |
13 | 18 |
14 /** | 19 /** |
15 * The complete list of error types we might encounter in GM. | 20 * The complete list of error types we might encounter in GM. |
16 */ | 21 */ |
17 enum ErrorType { | 22 enum ErrorType { |
18 #if SK_SUPPORT_GPU | 23 // Even though kNoGpuContext_ErrorType only occurs when SK_SUPPORT_GPU |
| 24 // is turned on, we always include this type in our enum so that |
| 25 // reports will be consistent whether SK_SUPPORT_GPU is turned on |
| 26 // or off (as long as the number of these errors is 0). |
19 kNoGpuContext_ErrorType, | 27 kNoGpuContext_ErrorType, |
20 #endif | 28 |
21 kImageMismatch_ErrorType, | 29 kImageMismatch_ErrorType, |
22 kMissingExpectations_ErrorType, | 30 kMissingExpectations_ErrorType, |
23 kWritingReferenceImage_ErrorType, | 31 kWritingReferenceImage_ErrorType, |
24 kLast_ErrorType = kWritingReferenceImage_ErrorType | 32 kLast_ErrorType = kWritingReferenceImage_ErrorType |
25 }; | 33 }; |
26 | 34 |
27 /** | 35 /** |
| 36 * Returns the name of the given ErrorType. |
| 37 */ |
| 38 const char *getErrorTypeName(ErrorType type) { |
| 39 switch(type) { |
| 40 case kNoGpuContext_ErrorType: |
| 41 return "NoGpuContext"; |
| 42 case kImageMismatch_ErrorType: |
| 43 return "ImageMismatch"; |
| 44 case kMissingExpectations_ErrorType: |
| 45 return "MissingExpectations"; |
| 46 case kWritingReferenceImage_ErrorType: |
| 47 return "WritingReferenceImage"; |
| 48 } |
| 49 // control should never reach here |
| 50 SkDEBUGFAIL("getErrorTypeName() called with unknown type"); |
| 51 return "Unknown"; |
| 52 } |
| 53 |
| 54 /** |
28 * A combination of 0 or more ErrorTypes. | 55 * A combination of 0 or more ErrorTypes. |
29 */ | 56 */ |
30 class ErrorCombination { | 57 class ErrorCombination { |
31 public: | 58 public: |
32 ErrorCombination() : fBitfield(0) {} | 59 ErrorCombination() : fBitfield(0) {} |
33 ErrorCombination(const ErrorType type) : fBitfield(1 << type) {} | 60 ErrorCombination(const ErrorType type) : fBitfield(1 << type) {} |
34 | 61 |
35 /** | 62 /** |
36 * Returns true iff there are NO errors. | 63 * Returns true iff there are NO errors. |
37 */ | 64 */ |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 return retval; | 107 return retval; |
81 } | 108 } |
82 | 109 |
83 private: | 110 private: |
84 int fBitfield; | 111 int fBitfield; |
85 }; | 112 }; |
86 | 113 |
87 // No errors at all. | 114 // No errors at all. |
88 const static ErrorCombination kEmpty_ErrorCombination; | 115 const static ErrorCombination kEmpty_ErrorCombination; |
89 } | 116 } |
| 117 |
| 118 #endif // ifndef gm_error_DEFINED |
OLD | NEW |