| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 #ifndef GrDrawTargetCaps_DEFINED | 8 #ifndef GrDrawTargetCaps_DEFINED |
| 9 #define GrDrawTargetCaps_DEFINED | 9 #define GrDrawTargetCaps_DEFINED |
| 10 | 10 |
| 11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
| 12 #include "GrTypesPriv.h" |
| 13 #include "GrShaderVar.h" |
| 12 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
| 13 #include "SkString.h" | 15 #include "SkString.h" |
| 14 | 16 |
| 15 /** | 17 /** |
| 16 * Represents the draw target capabilities. | 18 * Represents the draw target capabilities. |
| 17 */ | 19 */ |
| 18 class GrDrawTargetCaps : public SkRefCnt { | 20 class GrDrawTargetCaps : public SkRefCnt { |
| 19 public: | 21 public: |
| 20 SK_DECLARE_INST_COUNT(GrDrawTargetCaps) | 22 SK_DECLARE_INST_COUNT(GrDrawTargetCaps) |
| 21 | 23 |
| 24 /** Info about shader variable precision within a given shader stage. That i
s, this info |
| 25 is relevant to a float (or vecNf) variable declared with a GrShaderVar::
Precision |
| 26 in a given GrShaderType. The info here is hoisted from the OpenGL spec.
*/ |
| 27 struct PrecisionInfo { |
| 28 PrecisionInfo() { |
| 29 fLogRangeLow = 0; |
| 30 fLogRangeHigh = 0; |
| 31 fBits = 0; |
| 32 } |
| 33 |
| 34 /** Is this precision level allowed in the shader stage? */ |
| 35 bool supported() const { return 0 != fBits; } |
| 36 |
| 37 bool operator==(const PrecisionInfo& that) const { |
| 38 return fLogRangeLow == that.fLogRangeLow && fLogRangeHigh == that.fL
ogRangeHigh && |
| 39 fBits == that.fBits; |
| 40 } |
| 41 bool operator!=(const PrecisionInfo& that) const { return !(*this == tha
t); } |
| 42 |
| 43 /** floor(log2(|min_value|)) */ |
| 44 int fLogRangeLow; |
| 45 /** floor(log2(|max_value|)) */ |
| 46 int fLogRangeHigh; |
| 47 /** Number of bits of precision. As defined in OpenGL (with names modifi
ed to reflect this |
| 48 struct) : |
| 49 """ |
| 50 If the smallest representable value greater than 1 is 1 + e, the
n fBits will |
| 51 contain floor(log2(e)), and every value in the range [2^fLogRang
eLow, |
| 52 2^fLogRangeHigh] can be represented to at least one part in 2^fB
its. |
| 53 """ |
| 54 */ |
| 55 int fBits; |
| 56 }; |
| 57 |
| 58 |
| 22 GrDrawTargetCaps() : fUniqueID(CreateUniqueID()) { | 59 GrDrawTargetCaps() : fUniqueID(CreateUniqueID()) { |
| 23 this->reset(); | 60 this->reset(); |
| 24 } | 61 } |
| 25 GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED(), fUniqueID(Cre
ateUniqueID()) { | 62 GrDrawTargetCaps(const GrDrawTargetCaps& other) : INHERITED(), fUniqueID(Cre
ateUniqueID()) { |
| 26 *this = other; | 63 *this = other; |
| 27 } | 64 } |
| 28 GrDrawTargetCaps& operator= (const GrDrawTargetCaps&); | 65 GrDrawTargetCaps& operator= (const GrDrawTargetCaps&); |
| 29 | 66 |
| 30 virtual void reset(); | 67 virtual void reset(); |
| 31 virtual SkString dump() const; | 68 virtual SkString dump() const; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 SkASSERT(kGrPixelConfigCnt > config); | 114 SkASSERT(kGrPixelConfigCnt > config); |
| 78 return fConfigRenderSupport[config][withMSAA]; | 115 return fConfigRenderSupport[config][withMSAA]; |
| 79 } | 116 } |
| 80 | 117 |
| 81 bool isConfigTexturable(GrPixelConfig config) const { | 118 bool isConfigTexturable(GrPixelConfig config) const { |
| 82 SkASSERT(kGrPixelConfigCnt > config); | 119 SkASSERT(kGrPixelConfigCnt > config); |
| 83 return fConfigTextureSupport[config]; | 120 return fConfigTextureSupport[config]; |
| 84 } | 121 } |
| 85 | 122 |
| 86 /** | 123 /** |
| 124 * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrS
LType, etc in a |
| 125 * given shader type. If the shader type is not supported or the precision l
evel is not |
| 126 * supported in that shader type then the returned struct will report false
when supported() is |
| 127 * called. |
| 128 */ |
| 129 const PrecisionInfo& getFloatShaderPrecisionInfo(GrShaderType shaderType, |
| 130 GrShaderVar::Precision prec
ision) const { |
| 131 return fFloatPrecisions[shaderType][precision]; |
| 132 }; |
| 133 |
| 134 /** |
| 135 * Is there any difference between the float shader variable precision types
? If this is true |
| 136 * then unless the shader type is not supported, any call to getFloatShaderP
recisionInfo() would |
| 137 * report the same info for all precisions in all shader types. |
| 138 */ |
| 139 bool floatPrecisionVaries() const { return fShaderPrecisionVaries; } |
| 140 |
| 141 /** |
| 87 * Gets an id that is unique for this GrDrawTargetCaps object. It is static
in that it does | 142 * Gets an id that is unique for this GrDrawTargetCaps object. It is static
in that it does |
| 88 * not change when the content of the GrDrawTargetCaps object changes. This
will never return | 143 * not change when the content of the GrDrawTargetCaps object changes. This
will never return |
| 89 * 0. | 144 * 0. |
| 90 */ | 145 */ |
| 91 uint32_t getUniqueID() const { return fUniqueID; } | 146 uint32_t getUniqueID() const { return fUniqueID; } |
| 92 | 147 |
| 93 protected: | 148 protected: |
| 94 bool fNPOTTextureTileSupport : 1; | 149 bool fNPOTTextureTileSupport : 1; |
| 95 bool fMipMapSupport : 1; | 150 bool fMipMapSupport : 1; |
| 96 bool fTwoSidedStencilSupport : 1; | 151 bool fTwoSidedStencilSupport : 1; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 112 uint32_t fMapBufferFlags; | 167 uint32_t fMapBufferFlags; |
| 113 | 168 |
| 114 int fMaxRenderTargetSize; | 169 int fMaxRenderTargetSize; |
| 115 int fMaxTextureSize; | 170 int fMaxTextureSize; |
| 116 int fMaxSampleCount; | 171 int fMaxSampleCount; |
| 117 | 172 |
| 118 // The first entry for each config is without msaa and the second is with. | 173 // The first entry for each config is without msaa and the second is with. |
| 119 bool fConfigRenderSupport[kGrPixelConfigCnt][2]; | 174 bool fConfigRenderSupport[kGrPixelConfigCnt][2]; |
| 120 bool fConfigTextureSupport[kGrPixelConfigCnt]; | 175 bool fConfigTextureSupport[kGrPixelConfigCnt]; |
| 121 | 176 |
| 177 bool fShaderPrecisionVaries; |
| 178 PrecisionInfo fFloatPrecisions[kGrShaderTypeCount][GrShaderVar::kPrecisionCo
unt]; |
| 179 |
| 122 private: | 180 private: |
| 123 static uint32_t CreateUniqueID(); | 181 static uint32_t CreateUniqueID(); |
| 124 | 182 |
| 125 const uint32_t fUniqueID; | 183 const uint32_t fUniqueID; |
| 126 | 184 |
| 127 typedef SkRefCnt INHERITED; | 185 typedef SkRefCnt INHERITED; |
| 128 }; | 186 }; |
| 129 | 187 |
| 130 #endif | 188 #endif |
| OLD | NEW |