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 #ifndef GrTypesPriv_DEFINED | 8 #ifndef GrTypesPriv_DEFINED |
9 #define GrTypesPriv_DEFINED | 9 #define GrTypesPriv_DEFINED |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 // Default precision is medium. This is because on OpenGL ES 2 highp support
is not | 65 // Default precision is medium. This is because on OpenGL ES 2 highp support
is not |
66 // guaranteed. On (non-ES) OpenGL the specifiers have no effect on precision
. | 66 // guaranteed. On (non-ES) OpenGL the specifiers have no effect on precision
. |
67 kDefault_GrSLPrecision = kMedium_GrSLPrecision, | 67 kDefault_GrSLPrecision = kMedium_GrSLPrecision, |
68 | 68 |
69 kLast_GrSLPrecision = kHigh_GrSLPrecision | 69 kLast_GrSLPrecision = kHigh_GrSLPrecision |
70 }; | 70 }; |
71 | 71 |
72 static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1; | 72 static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1; |
73 | 73 |
| 74 static inline GrSLPrecision GrPixelConfigPrecision(GrPixelConfig config) { |
| 75 static const GrSLPrecision precisions[] = { |
| 76 kLow_GrSLPrecision, // kUnknown_GrPixelConfig |
| 77 kLow_GrSLPrecision, // kAlpha_8_GrPixelConfig |
| 78 kLow_GrSLPrecision, // kIndex_8_GrPixelConfig |
| 79 kLow_GrSLPrecision, // kRGB_565_GrPixelConfig |
| 80 kLow_GrSLPrecision, // kRGBA_4444_GrPixelConfig |
| 81 kLow_GrSLPrecision, // kRGBA_8888_GrPixelConfig |
| 82 kLow_GrSLPrecision, // kBGRA_8888_GrPixelConfig |
| 83 kLow_GrSLPrecision, // kSRGBA_8888_GrPixelConfig |
| 84 kLow_GrSLPrecision, // kSBGRA_8888_GrPixelConfig |
| 85 kLow_GrSLPrecision, // kETC1_GrPixelConfig |
| 86 kLow_GrSLPrecision, // kLATC_GrPixelConfig |
| 87 kLow_GrSLPrecision, // kR11_EAC_GrPixelConfig |
| 88 kLow_GrSLPrecision, // kASTC_12x12_GrPixelConfig |
| 89 kHigh_GrSLPrecision, // kRGBA_float_GrPixelConfig |
| 90 kMedium_GrSLPrecision, // kAlpha_half_GrPixelConfig |
| 91 kMedium_GrSLPrecision, // kRGBA_half_GrPixelConfig |
| 92 }; |
| 93 |
| 94 SkASSERT(config >= 0 && config <= kLast_GrPixelConfig); |
| 95 return precisions[config]; |
| 96 |
| 97 GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig); |
| 98 GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig); |
| 99 GR_STATIC_ASSERT(2 == kIndex_8_GrPixelConfig); |
| 100 GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig); |
| 101 GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig); |
| 102 GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig); |
| 103 GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig); |
| 104 GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig); |
| 105 GR_STATIC_ASSERT(8 == kSBGRA_8888_GrPixelConfig); |
| 106 GR_STATIC_ASSERT(9 == kETC1_GrPixelConfig); |
| 107 GR_STATIC_ASSERT(10 == kLATC_GrPixelConfig); |
| 108 GR_STATIC_ASSERT(11 == kR11_EAC_GrPixelConfig); |
| 109 GR_STATIC_ASSERT(12 == kASTC_12x12_GrPixelConfig); |
| 110 GR_STATIC_ASSERT(13 == kRGBA_float_GrPixelConfig); |
| 111 GR_STATIC_ASSERT(14 == kAlpha_half_GrPixelConfig); |
| 112 GR_STATIC_ASSERT(15 == kRGBA_half_GrPixelConfig); |
| 113 GR_STATIC_ASSERT(SK_ARRAY_COUNT(precisions) == kGrPixelConfigCnt); |
| 114 } |
| 115 |
74 /** | 116 /** |
75 * Gets the vector size of the SLType. Returns -1 for void, matrices, and sample
rs. | 117 * Gets the vector size of the SLType. Returns -1 for void, matrices, and sample
rs. |
76 */ | 118 */ |
77 static inline int GrSLTypeVectorCount(GrSLType type) { | 119 static inline int GrSLTypeVectorCount(GrSLType type) { |
78 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); | 120 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); |
79 static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1, 1, 1,
1 }; | 121 static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1, 1, 1,
1 }; |
80 return kCounts[type]; | 122 return kCounts[type]; |
81 | 123 |
82 GR_STATIC_ASSERT(0 == kVoid_GrSLType); | 124 GR_STATIC_ASSERT(0 == kVoid_GrSLType); |
83 GR_STATIC_ASSERT(1 == kFloat_GrSLType); | 125 GR_STATIC_ASSERT(1 == kFloat_GrSLType); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 // Takes a pointer to a GrCaps, and will suppress prints if required | 484 // Takes a pointer to a GrCaps, and will suppress prints if required |
443 #define GrCapsDebugf(caps, ...) \ | 485 #define GrCapsDebugf(caps, ...) \ |
444 if (!caps->suppressPrints()) { \ | 486 if (!caps->suppressPrints()) { \ |
445 SkDebugf(__VA_ARGS__); \ | 487 SkDebugf(__VA_ARGS__); \ |
446 } | 488 } |
447 #else | 489 #else |
448 #define GrCapsDebugf(caps, ...) | 490 #define GrCapsDebugf(caps, ...) |
449 #endif | 491 #endif |
450 | 492 |
451 #endif | 493 #endif |
OLD | NEW |