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 | |
17 namespace skiagm { | 12 namespace skiagm { |
18 | 13 |
19 /** | 14 /** |
20 * The complete list of error types we might encounter in GM. | 15 * The complete list of error types we might encounter in GM. |
21 */ | 16 */ |
22 enum ErrorType { | 17 enum ErrorType { |
23 // Even though kNoGpuContext_ErrorType only occurs when SK_SUPPORT_GPU | 18 #if 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). | |
27 kNoGpuContext_ErrorType, | 19 kNoGpuContext_ErrorType, |
28 | 20 #endif |
29 kImageMismatch_ErrorType, | 21 kImageMismatch_ErrorType, |
30 kMissingExpectations_ErrorType, | 22 kMissingExpectations_ErrorType, |
31 kWritingReferenceImage_ErrorType, | 23 kWritingReferenceImage_ErrorType, |
32 kLast_ErrorType = kWritingReferenceImage_ErrorType | 24 kLast_ErrorType = kWritingReferenceImage_ErrorType |
33 }; | 25 }; |
34 | 26 |
35 /** | 27 /** |
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 /** | |
55 * A combination of 0 or more ErrorTypes. | 28 * A combination of 0 or more ErrorTypes. |
56 */ | 29 */ |
57 class ErrorCombination { | 30 class ErrorCombination { |
58 public: | 31 public: |
59 ErrorCombination() : fBitfield(0) {} | 32 ErrorCombination() : fBitfield(0) {} |
60 ErrorCombination(const ErrorType type) : fBitfield(1 << type) {} | 33 ErrorCombination(const ErrorType type) : fBitfield(1 << type) {} |
61 | 34 |
62 /** | 35 /** |
63 * Returns true iff there are NO errors. | 36 * Returns true iff there are NO errors. |
64 */ | 37 */ |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 return retval; | 80 return retval; |
108 } | 81 } |
109 | 82 |
110 private: | 83 private: |
111 int fBitfield; | 84 int fBitfield; |
112 }; | 85 }; |
113 | 86 |
114 // No errors at all. | 87 // No errors at all. |
115 const static ErrorCombination kEmpty_ErrorCombination; | 88 const static ErrorCombination kEmpty_ErrorCombination; |
116 } | 89 } |
117 | |
118 #endif // ifndef gm_error_DEFINED | |
OLD | NEW |