OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 GrTypes_DEFINED | 8 #ifndef GrTypes_DEFINED |
9 #define GrTypes_DEFINED | 9 #define GrTypes_DEFINED |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 friend X operator | (X a, X b); \ | 42 friend X operator | (X a, X b); \ |
43 friend X& operator |= (X& a, X b); \ | 43 friend X& operator |= (X& a, X b); \ |
44 \ | 44 \ |
45 friend X operator & (X a, X b); \ | 45 friend X operator & (X a, X b); \ |
46 \ | 46 \ |
47 template <typename T> \ | 47 template <typename T> \ |
48 friend X operator & (T a, X b); \ | 48 friend X operator & (T a, X b); \ |
49 \ | 49 \ |
50 template <typename T> \ | 50 template <typename T> \ |
51 friend X operator & (X a, T b); \ | 51 friend X operator & (X a, T b); \ |
| 52 |
| 53 /** |
| 54 * Defines bitwise operators that make it possible to use an enum class as a |
| 55 * very basic bitfield. |
| 56 */ |
| 57 #define GR_MAKE_BITFIELD_CLASS_OPS(X) \ |
| 58 inline X operator | (X a, X b) { \ |
| 59 return (X) ((int)a | (int)b); \ |
| 60 } \ |
| 61 inline X& operator |= (X& a, X b) { \ |
| 62 return (a = a | b); \ |
| 63 } \ |
| 64 inline bool operator & (X a, X b) { \ |
| 65 return SkToBool((int)a & (int)b); \ |
| 66 } |
| 67 |
| 68 #define GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(X) \ |
| 69 friend X operator | (X a, X b); \ |
| 70 friend X& operator |= (X& a, X b); \ |
| 71 friend bool operator & (X a, X b); |
| 72 |
52 //////////////////////////////////////////////////////////////////////////////// | 73 //////////////////////////////////////////////////////////////////////////////// |
53 | 74 |
54 // compile time versions of min/max | 75 // compile time versions of min/max |
55 #define GR_CT_MAX(a, b) (((b) < (a)) ? (a) : (b)) | 76 #define GR_CT_MAX(a, b) (((b) < (a)) ? (a) : (b)) |
56 #define GR_CT_MIN(a, b) (((b) < (a)) ? (b) : (a)) | 77 #define GR_CT_MIN(a, b) (((b) < (a)) ? (b) : (a)) |
57 | 78 |
58 /** | 79 /** |
59 * divide, rounding up | 80 * divide, rounding up |
60 */ | 81 */ |
61 static inline int32_t GrIDivRoundUp(int x, int y) { | 82 static inline int32_t GrIDivRoundUp(int x, int y) { |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 return 4 * width * height; | 656 return 4 * width * height; |
636 } | 657 } |
637 } | 658 } |
638 | 659 |
639 /** | 660 /** |
640 * This value translates to reseting all the context state for any backend. | 661 * This value translates to reseting all the context state for any backend. |
641 */ | 662 */ |
642 static const uint32_t kAll_GrBackendState = 0xffffffff; | 663 static const uint32_t kAll_GrBackendState = 0xffffffff; |
643 | 664 |
644 #endif | 665 #endif |
OLD | NEW |