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 | 9 |
10 | 10 |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 fCompressedTexSubImageSupport = false; | 1004 fCompressedTexSubImageSupport = false; |
1005 | 1005 |
1006 fUseDrawInsteadOfClear = false; | 1006 fUseDrawInsteadOfClear = false; |
1007 | 1007 |
1008 fMapBufferFlags = kNone_MapFlags; | 1008 fMapBufferFlags = kNone_MapFlags; |
1009 | 1009 |
1010 fMaxRenderTargetSize = 0; | 1010 fMaxRenderTargetSize = 0; |
1011 fMaxTextureSize = 0; | 1011 fMaxTextureSize = 0; |
1012 fMaxSampleCount = 0; | 1012 fMaxSampleCount = 0; |
1013 | 1013 |
| 1014 fShaderPrecisionVaries = false; |
| 1015 |
1014 memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport)); | 1016 memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport)); |
1015 memset(fConfigTextureSupport, 0, sizeof(fConfigTextureSupport)); | 1017 memset(fConfigTextureSupport, 0, sizeof(fConfigTextureSupport)); |
1016 } | 1018 } |
1017 | 1019 |
1018 GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) { | 1020 GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) { |
1019 fMipMapSupport = other.fMipMapSupport; | 1021 fMipMapSupport = other.fMipMapSupport; |
1020 fNPOTTextureTileSupport = other.fNPOTTextureTileSupport; | 1022 fNPOTTextureTileSupport = other.fNPOTTextureTileSupport; |
1021 fTwoSidedStencilSupport = other.fTwoSidedStencilSupport; | 1023 fTwoSidedStencilSupport = other.fTwoSidedStencilSupport; |
1022 fStencilWrapOpsSupport = other.fStencilWrapOpsSupport; | 1024 fStencilWrapOpsSupport = other.fStencilWrapOpsSupport; |
1023 fHWAALineSupport = other.fHWAALineSupport; | 1025 fHWAALineSupport = other.fHWAALineSupport; |
(...skipping 11 matching lines...) Expand all Loading... |
1035 | 1037 |
1036 fMapBufferFlags = other.fMapBufferFlags; | 1038 fMapBufferFlags = other.fMapBufferFlags; |
1037 | 1039 |
1038 fMaxRenderTargetSize = other.fMaxRenderTargetSize; | 1040 fMaxRenderTargetSize = other.fMaxRenderTargetSize; |
1039 fMaxTextureSize = other.fMaxTextureSize; | 1041 fMaxTextureSize = other.fMaxTextureSize; |
1040 fMaxSampleCount = other.fMaxSampleCount; | 1042 fMaxSampleCount = other.fMaxSampleCount; |
1041 | 1043 |
1042 memcpy(fConfigRenderSupport, other.fConfigRenderSupport, sizeof(fConfigRende
rSupport)); | 1044 memcpy(fConfigRenderSupport, other.fConfigRenderSupport, sizeof(fConfigRende
rSupport)); |
1043 memcpy(fConfigTextureSupport, other.fConfigTextureSupport, sizeof(fConfigTex
tureSupport)); | 1045 memcpy(fConfigTextureSupport, other.fConfigTextureSupport, sizeof(fConfigTex
tureSupport)); |
1044 | 1046 |
| 1047 fShaderPrecisionVaries = other.fShaderPrecisionVaries; |
| 1048 for (int s = 0; s < kGrShaderTypeCount; ++s) { |
| 1049 for (int p = 0; p < GrShaderVar::kPrecisionCount; ++p) { |
| 1050 fFloatPrecisions[s][p] = other.fFloatPrecisions[s][p]; |
| 1051 } |
| 1052 } |
1045 return *this; | 1053 return *this; |
1046 } | 1054 } |
1047 | 1055 |
1048 static SkString map_flags_to_string(uint32_t flags) { | 1056 static SkString map_flags_to_string(uint32_t flags) { |
1049 SkString str; | 1057 SkString str; |
1050 if (GrDrawTargetCaps::kNone_MapFlags == flags) { | 1058 if (GrDrawTargetCaps::kNone_MapFlags == flags) { |
1051 str = "none"; | 1059 str = "none"; |
1052 } else { | 1060 } else { |
1053 SkASSERT(GrDrawTargetCaps::kCanMap_MapFlag & flags); | 1061 SkASSERT(GrDrawTargetCaps::kCanMap_MapFlag & flags); |
1054 SkDEBUGCODE(flags &= ~GrDrawTargetCaps::kCanMap_MapFlag); | 1062 SkDEBUGCODE(flags &= ~GrDrawTargetCaps::kCanMap_MapFlag); |
1055 str = "can_map"; | 1063 str = "can_map"; |
1056 | 1064 |
1057 if (GrDrawTargetCaps::kSubset_MapFlag & flags) { | 1065 if (GrDrawTargetCaps::kSubset_MapFlag & flags) { |
1058 str.append(" partial"); | 1066 str.append(" partial"); |
1059 } else { | 1067 } else { |
1060 str.append(" full"); | 1068 str.append(" full"); |
1061 } | 1069 } |
1062 SkDEBUGCODE(flags &= ~GrDrawTargetCaps::kSubset_MapFlag); | 1070 SkDEBUGCODE(flags &= ~GrDrawTargetCaps::kSubset_MapFlag); |
1063 } | 1071 } |
1064 SkASSERT(0 == flags); // Make sure we handled all the flags. | 1072 SkASSERT(0 == flags); // Make sure we handled all the flags. |
1065 return str; | 1073 return str; |
1066 } | 1074 } |
1067 | 1075 |
| 1076 static const char* shader_type_to_string(GrShaderType type) { |
| 1077 switch (type) { |
| 1078 case kVertex_GrShaderType: |
| 1079 return "vertex"; |
| 1080 case kGeometry_GrShaderType: |
| 1081 return "geometry"; |
| 1082 case kFragment_GrShaderType: |
| 1083 return "fragment"; |
| 1084 } |
| 1085 return ""; |
| 1086 } |
| 1087 |
| 1088 static const char* precision_to_string(GrShaderVar::Precision p) { |
| 1089 switch (p) { |
| 1090 case GrShaderVar::kLow_Precision: |
| 1091 return "low"; |
| 1092 case GrShaderVar::kMedium_Precision: |
| 1093 return "medium"; |
| 1094 case GrShaderVar::kHigh_Precision: |
| 1095 return "high"; |
| 1096 } |
| 1097 return ""; |
| 1098 } |
| 1099 |
1068 SkString GrDrawTargetCaps::dump() const { | 1100 SkString GrDrawTargetCaps::dump() const { |
1069 SkString r; | 1101 SkString r; |
1070 static const char* gNY[] = {"NO", "YES"}; | 1102 static const char* gNY[] = {"NO", "YES"}; |
1071 r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]); | 1103 r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]); |
1072 r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileS
upport]); | 1104 r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileS
upport]); |
1073 r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilS
upport]); | 1105 r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilS
upport]); |
1074 r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSu
pport]); | 1106 r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSu
pport]); |
1075 r.appendf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]
); | 1107 r.appendf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]
); |
1076 r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivative
Support]); | 1108 r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivative
Support]); |
1077 r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSu
pport]); | 1109 r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSu
pport]); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 } | 1165 } |
1134 | 1166 |
1135 SkASSERT(!fConfigTextureSupport[kUnknown_GrPixelConfig]); | 1167 SkASSERT(!fConfigTextureSupport[kUnknown_GrPixelConfig]); |
1136 | 1168 |
1137 for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) { | 1169 for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) { |
1138 r.appendf("%s is uploadable to a texture: %s\n", | 1170 r.appendf("%s is uploadable to a texture: %s\n", |
1139 kConfigNames[i], | 1171 kConfigNames[i], |
1140 gNY[fConfigTextureSupport[i]]); | 1172 gNY[fConfigTextureSupport[i]]); |
1141 } | 1173 } |
1142 | 1174 |
| 1175 r.appendf("Shader Float Precisions (varies: %s):\n", gNY[fShaderPrecisionVar
ies]); |
| 1176 |
| 1177 for (int s = 0; s < kGrShaderTypeCount; ++s) { |
| 1178 GrShaderType shaderType = static_cast<GrShaderType>(s); |
| 1179 r.appendf("\t%s:\n", shader_type_to_string(shaderType)); |
| 1180 for (int p = 0; p < GrShaderVar::kPrecisionCount; ++p) { |
| 1181 if (fFloatPrecisions[s][p].supported()) { |
| 1182 GrShaderVar::Precision precision = static_cast<GrShaderVar::Prec
ision>(p); |
| 1183 r.appendf("\t\t%s: log_low: %d log_high: %d bits: %d\n", |
| 1184 precision_to_string(precision), |
| 1185 fFloatPrecisions[s][p].fLogRangeLow, |
| 1186 fFloatPrecisions[s][p].fLogRangeHigh, |
| 1187 fFloatPrecisions[s][p].fBits); |
| 1188 } |
| 1189 } |
| 1190 } |
| 1191 |
1143 return r; | 1192 return r; |
1144 } | 1193 } |
1145 | 1194 |
1146 uint32_t GrDrawTargetCaps::CreateUniqueID() { | 1195 uint32_t GrDrawTargetCaps::CreateUniqueID() { |
1147 static int32_t gUniqueID = SK_InvalidUniqueID; | 1196 static int32_t gUniqueID = SK_InvalidUniqueID; |
1148 uint32_t id; | 1197 uint32_t id; |
1149 do { | 1198 do { |
1150 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 1199 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
1151 } while (id == SK_InvalidUniqueID); | 1200 } while (id == SK_InvalidUniqueID); |
1152 return id; | 1201 return id; |
1153 } | 1202 } |
1154 | 1203 |
1155 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 1204 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
1156 | 1205 |
1157 bool GrClipTarget::setupClip(const SkRect* devBounds, | 1206 bool GrClipTarget::setupClip(const SkRect* devBounds, |
1158 GrDrawState::AutoRestoreEffects* are, | 1207 GrDrawState::AutoRestoreEffects* are, |
1159 GrDrawState::AutoRestoreStencil* ars, | 1208 GrDrawState::AutoRestoreStencil* ars, |
1160 GrDrawState* ds, | 1209 GrDrawState* ds, |
1161 GrClipMaskManager::ScissorState* scissorState) { | 1210 GrClipMaskManager::ScissorState* scissorState) { |
1162 return fClipMaskManager.setupClipping(ds, | 1211 return fClipMaskManager.setupClipping(ds, |
1163 are, | 1212 are, |
1164 ars, | 1213 ars, |
1165 scissorState, | 1214 scissorState, |
1166 this->getClip(), | 1215 this->getClip(), |
1167 devBounds); | 1216 devBounds); |
1168 } | 1217 } |
OLD | NEW |