Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2013 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 /* | |
| 9 * Error codes used by gmmain.cpp. | |
| 10 */ | |
| 11 | |
| 12 namespace skiagm { | |
| 13 | |
| 14 /** | |
| 15 * The complete list of error types we might encounter in GM. | |
| 16 */ | |
| 17 enum ErrorType { | |
| 18 kNoGpuContext_ErrorType, | |
|
borenet
2013/03/22 13:53:29
Should this be wrapped in a #ifdef SK_SUPPORT_GPU?
epoger
2013/03/22 14:31:23
Done.
| |
| 19 kImageMismatch_ErrorType, | |
| 20 kMissingExpectations_ErrorType, | |
| 21 kWritingReferenceImage_ErrorType, | |
| 22 kLast_ErrorType = kWritingReferenceImage_ErrorType | |
| 23 }; | |
| 24 | |
| 25 /** | |
| 26 * A combination of 0 or more ErrorTypes. | |
| 27 */ | |
| 28 class ErrorCombination { | |
| 29 public: | |
| 30 ErrorCombination() : fBitfield(0) {} | |
| 31 ErrorCombination(const ErrorType type) : fBitfield(1 << type) {} | |
| 32 | |
| 33 /** | |
| 34 * Returns true iff there are NO errors. | |
| 35 */ | |
| 36 bool isEmpty() const { | |
| 37 return (0 == this->fBitfield); | |
| 38 } | |
| 39 | |
| 40 /** | |
| 41 * Adds this ErrorType to this ErrorCombination. | |
| 42 */ | |
| 43 void add(const ErrorType type) { | |
| 44 this->fBitfield |= (1 << type); | |
| 45 } | |
| 46 | |
| 47 /** | |
| 48 * Adds all ErrorTypes in "other" to this ErrorCombination. | |
| 49 */ | |
| 50 void add(const ErrorCombination other) { | |
| 51 this->fBitfield |= other.fBitfield; | |
| 52 } | |
| 53 | |
| 54 /** | |
| 55 * Returns true iff this ErrorCombination includes this ErrorType. | |
| 56 */ | |
| 57 bool includes(const ErrorType type) const { | |
| 58 return !(0 == (this->fBitfield & (1 << type))); | |
| 59 } | |
| 60 | |
| 61 /** | |
| 62 * Returns a new ErrorCombination, which includes the union of all | |
| 63 * ErrorTypes in two ErrorCombination objects (this and other). | |
| 64 */ | |
| 65 ErrorCombination plus(const ErrorCombination& other) const { | |
| 66 ErrorCombination retval; | |
| 67 retval.fBitfield = this->fBitfield | other.fBitfield; | |
| 68 return retval; | |
| 69 } | |
| 70 | |
| 71 /** | |
| 72 * Returns a new ErrorCombination, which is a copy of "this" | |
| 73 * but with all ErrorTypes in "other" removed. | |
| 74 */ | |
| 75 ErrorCombination minus(const ErrorCombination& other) const { | |
| 76 ErrorCombination retval; | |
| 77 retval.fBitfield = this->fBitfield & ~(other.fBitfield); | |
| 78 return retval; | |
| 79 } | |
| 80 | |
| 81 private: | |
| 82 int fBitfield; | |
| 83 }; | |
| 84 | |
| 85 // No errors at all. | |
| 86 const static ErrorCombination kEmpty_ErrorCombination; | |
| 87 } | |
| OLD | NEW |