| OLD | NEW |
| 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 #ifndef GrTypes_DEFINED | 9 #ifndef GrTypes_DEFINED |
| 10 #define GrTypes_DEFINED | 10 #define GrTypes_DEFINED |
| 11 | 11 |
| 12 #include "SkTypes.h" | 12 #include "SkTypes.h" |
| 13 #include "GrConfig.h" | 13 #include "GrConfig.h" |
| 14 #include "SkMath.h" | 14 #include "SkMath.h" |
| 15 | 15 |
| 16 //#define SK_SUPPORT_LEGACY_GRTYPES | |
| 17 | |
| 18 //////////////////////////////////////////////////////////////////////////////// | 16 //////////////////////////////////////////////////////////////////////////////// |
| 19 | 17 |
| 20 /** | 18 /** |
| 21 * Defines overloaded bitwise operators to make it easier to use an enum as a | 19 * Defines overloaded bitwise operators to make it easier to use an enum as a |
| 22 * bitfield. | 20 * bitfield. |
| 23 */ | 21 */ |
| 24 #define GR_MAKE_BITFIELD_OPS(X) \ | 22 #define GR_MAKE_BITFIELD_OPS(X) \ |
| 25 inline X operator | (X a, X b) { \ | 23 inline X operator | (X a, X b) { \ |
| 26 return (X) (+a | +b); \ | 24 return (X) (+a | +b); \ |
| 27 } \ | 25 } \ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 43 \ | 41 \ |
| 44 friend X operator & (X a, X b); \ | 42 friend X operator & (X a, X b); \ |
| 45 \ | 43 \ |
| 46 template <typename T> \ | 44 template <typename T> \ |
| 47 friend X operator & (T a, X b); \ | 45 friend X operator & (T a, X b); \ |
| 48 \ | 46 \ |
| 49 template <typename T> \ | 47 template <typename T> \ |
| 50 friend X operator & (X a, T b); \ | 48 friend X operator & (X a, T b); \ |
| 51 //////////////////////////////////////////////////////////////////////////////// | 49 //////////////////////////////////////////////////////////////////////////////// |
| 52 | 50 |
| 53 #ifdef SK_SUPPORT_LEGACY_GRTYPES | |
| 54 | |
| 55 /** | |
| 56 * Macro to round n up to the next multiple of 4, or return it unchanged if | |
| 57 * n is already a multiple of 4 | |
| 58 */ | |
| 59 #define GrALIGN4(n) SkAlign4(n) | |
| 60 #define GrIsALIGN4(n) SkIsAlign4(n) | |
| 61 | |
| 62 template <typename T> const T& GrMin(const T& a, const T& b) { | |
| 63 return (a < b) ? a : b; | |
| 64 } | |
| 65 | |
| 66 template <typename T> const T& GrMax(const T& a, const T& b) { | |
| 67 return (b < a) ? a : b; | |
| 68 } | |
| 69 | |
| 70 /** | |
| 71 * 16.16 fixed point type | |
| 72 */ | |
| 73 typedef int32_t GrFixed; | |
| 74 | |
| 75 #ifdef SK_DEBUG | |
| 76 | |
| 77 static inline int16_t GrToS16(intptr_t x) { | |
| 78 SkASSERT((int16_t)x == x); | |
| 79 return (int16_t)x; | |
| 80 } | |
| 81 | |
| 82 #else | |
| 83 | |
| 84 #define GrToS16(x) x | |
| 85 | |
| 86 #endif | |
| 87 | |
| 88 #endif | |
| 89 | |
| 90 // compile time versions of min/max | 51 // compile time versions of min/max |
| 91 #define GR_CT_MAX(a, b) (((b) < (a)) ? (a) : (b)) | 52 #define GR_CT_MAX(a, b) (((b) < (a)) ? (a) : (b)) |
| 92 #define GR_CT_MIN(a, b) (((b) < (a)) ? (b) : (a)) | 53 #define GR_CT_MIN(a, b) (((b) < (a)) ? (b) : (a)) |
| 93 | 54 |
| 94 /** | 55 /** |
| 95 * divide, rounding up | 56 * divide, rounding up |
| 96 */ | 57 */ |
| 97 static inline int32_t GrIDivRoundUp(int x, int y) { | 58 static inline int32_t GrIDivRoundUp(int x, int y) { |
| 98 SkASSERT(y > 0); | 59 SkASSERT(y > 0); |
| 99 return (x + (y-1)) / y; | 60 return (x + (y-1)) / y; |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 public: | 684 public: |
| 724 GrAutoMalloc() : INHERITED() {} | 685 GrAutoMalloc() : INHERITED() {} |
| 725 explicit GrAutoMalloc(size_t size) : INHERITED(size) {} | 686 explicit GrAutoMalloc(size_t size) : INHERITED(size) {} |
| 726 virtual ~GrAutoMalloc() {} | 687 virtual ~GrAutoMalloc() {} |
| 727 private: | 688 private: |
| 728 typedef GrAutoMallocBaseType INHERITED; | 689 typedef GrAutoMallocBaseType INHERITED; |
| 729 }; | 690 }; |
| 730 | 691 |
| 731 #undef GrAutoMallocBaseType | 692 #undef GrAutoMallocBaseType |
| 732 #endif | 693 #endif |
| OLD | NEW |