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 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1000 void GrDrawTarget::initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* d esc) { | 1000 void GrDrawTarget::initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* d esc) { |
1001 // Make the dst of the copy be a render target because the default copySurfa ce draws to the dst. | 1001 // Make the dst of the copy be a render target because the default copySurfa ce draws to the dst. |
1002 desc->fOrigin = kDefault_GrSurfaceOrigin; | 1002 desc->fOrigin = kDefault_GrSurfaceOrigin; |
1003 desc->fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; | 1003 desc->fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; |
1004 desc->fConfig = src->config(); | 1004 desc->fConfig = src->config(); |
1005 } | 1005 } |
1006 | 1006 |
1007 /////////////////////////////////////////////////////////////////////////////// | 1007 /////////////////////////////////////////////////////////////////////////////// |
1008 | 1008 |
1009 void GrDrawTargetCaps::reset() { | 1009 void GrDrawTargetCaps::reset() { |
1010 f8BitPaletteSupport = false; | |
1011 fMipMapSupport = false; | 1010 fMipMapSupport = false; |
1012 fNPOTTextureTileSupport = false; | 1011 fNPOTTextureTileSupport = false; |
1013 fTwoSidedStencilSupport = false; | 1012 fTwoSidedStencilSupport = false; |
1014 fStencilWrapOpsSupport = false; | 1013 fStencilWrapOpsSupport = false; |
1015 fHWAALineSupport = false; | 1014 fHWAALineSupport = false; |
1016 fShaderDerivativeSupport = false; | 1015 fShaderDerivativeSupport = false; |
1017 fGeometryShaderSupport = false; | 1016 fGeometryShaderSupport = false; |
1018 fDualSourceBlendingSupport = false; | 1017 fDualSourceBlendingSupport = false; |
1019 fPathRenderingSupport = false; | 1018 fPathRenderingSupport = false; |
1020 fDstReadInShaderSupport = false; | 1019 fDstReadInShaderSupport = false; |
1021 fDiscardRenderTargetSupport = false; | 1020 fDiscardRenderTargetSupport = false; |
1022 fReuseScratchTextures = true; | 1021 fReuseScratchTextures = true; |
1023 fGpuTracingSupport = false; | 1022 fGpuTracingSupport = false; |
1024 | 1023 |
1025 fMapBufferFlags = kNone_MapFlags; | 1024 fMapBufferFlags = kNone_MapFlags; |
1026 | 1025 |
1027 fMaxRenderTargetSize = 0; | 1026 fMaxRenderTargetSize = 0; |
1028 fMaxTextureSize = 0; | 1027 fMaxTextureSize = 0; |
1029 fMaxSampleCount = 0; | 1028 fMaxSampleCount = 0; |
1030 | 1029 |
1031 memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport)); | 1030 memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport)); |
1032 memset(fCompressedFormatSupport, 0, sizeof(fCompressedFormatSupport)); | 1031 memset(fConfigTextureSupport, 0, sizeof(fConfigTextureSupport)); |
1033 } | 1032 } |
1034 | 1033 |
1035 GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) { | 1034 GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) { |
1036 f8BitPaletteSupport = other.f8BitPaletteSupport; | |
1037 fMipMapSupport = other.fMipMapSupport; | 1035 fMipMapSupport = other.fMipMapSupport; |
1038 fNPOTTextureTileSupport = other.fNPOTTextureTileSupport; | 1036 fNPOTTextureTileSupport = other.fNPOTTextureTileSupport; |
1039 fTwoSidedStencilSupport = other.fTwoSidedStencilSupport; | 1037 fTwoSidedStencilSupport = other.fTwoSidedStencilSupport; |
1040 fStencilWrapOpsSupport = other.fStencilWrapOpsSupport; | 1038 fStencilWrapOpsSupport = other.fStencilWrapOpsSupport; |
1041 fHWAALineSupport = other.fHWAALineSupport; | 1039 fHWAALineSupport = other.fHWAALineSupport; |
1042 fShaderDerivativeSupport = other.fShaderDerivativeSupport; | 1040 fShaderDerivativeSupport = other.fShaderDerivativeSupport; |
1043 fGeometryShaderSupport = other.fGeometryShaderSupport; | 1041 fGeometryShaderSupport = other.fGeometryShaderSupport; |
1044 fDualSourceBlendingSupport = other.fDualSourceBlendingSupport; | 1042 fDualSourceBlendingSupport = other.fDualSourceBlendingSupport; |
1045 fPathRenderingSupport = other.fPathRenderingSupport; | 1043 fPathRenderingSupport = other.fPathRenderingSupport; |
1046 fDstReadInShaderSupport = other.fDstReadInShaderSupport; | 1044 fDstReadInShaderSupport = other.fDstReadInShaderSupport; |
1047 fDiscardRenderTargetSupport = other.fDiscardRenderTargetSupport; | 1045 fDiscardRenderTargetSupport = other.fDiscardRenderTargetSupport; |
1048 fReuseScratchTextures = other.fReuseScratchTextures; | 1046 fReuseScratchTextures = other.fReuseScratchTextures; |
1049 fGpuTracingSupport = other.fGpuTracingSupport; | 1047 fGpuTracingSupport = other.fGpuTracingSupport; |
1050 | 1048 |
1051 fMapBufferFlags = other.fMapBufferFlags; | 1049 fMapBufferFlags = other.fMapBufferFlags; |
1052 | 1050 |
1053 fMaxRenderTargetSize = other.fMaxRenderTargetSize; | 1051 fMaxRenderTargetSize = other.fMaxRenderTargetSize; |
1054 fMaxTextureSize = other.fMaxTextureSize; | 1052 fMaxTextureSize = other.fMaxTextureSize; |
1055 fMaxSampleCount = other.fMaxSampleCount; | 1053 fMaxSampleCount = other.fMaxSampleCount; |
1056 | 1054 |
1057 memcpy(fConfigRenderSupport, other.fConfigRenderSupport, sizeof(fConfigRende rSupport)); | 1055 memcpy(fConfigRenderSupport, other.fConfigRenderSupport, sizeof(fConfigRende rSupport)); |
1058 memcpy(fCompressedFormatSupport, other.fCompressedFormatSupport, | 1056 memcpy(fConfigTextureSupport, other.fConfigTextureSupport, sizeof(fConfigTex tureSupport)); |
1059 sizeof(fCompressedFormatSupport)); | |
1060 | 1057 |
1061 return *this; | 1058 return *this; |
1062 } | 1059 } |
1063 | 1060 |
1064 static SkString map_flags_to_string(uint32_t flags) { | 1061 static SkString map_flags_to_string(uint32_t flags) { |
1065 SkString str; | 1062 SkString str; |
1066 if (GrDrawTargetCaps::kNone_MapFlags == flags) { | 1063 if (GrDrawTargetCaps::kNone_MapFlags == flags) { |
1067 str = "none"; | 1064 str = "none"; |
1068 } else { | 1065 } else { |
1069 SkASSERT(GrDrawTargetCaps::kCanMap_MapFlag & flags); | 1066 SkASSERT(GrDrawTargetCaps::kCanMap_MapFlag & flags); |
1070 SkDEBUGCODE(flags &= ~GrDrawTargetCaps::kCanMap_MapFlag); | 1067 SkDEBUGCODE(flags &= ~GrDrawTargetCaps::kCanMap_MapFlag); |
1071 str = "can_map"; | 1068 str = "can_map"; |
1072 | 1069 |
1073 if (GrDrawTargetCaps::kSubset_MapFlag & flags) { | 1070 if (GrDrawTargetCaps::kSubset_MapFlag & flags) { |
1074 str.append(" partial"); | 1071 str.append(" partial"); |
1075 } else { | 1072 } else { |
1076 str.append(" full"); | 1073 str.append(" full"); |
1077 } | 1074 } |
1078 SkDEBUGCODE(flags &= ~GrDrawTargetCaps::kSubset_MapFlag); | 1075 SkDEBUGCODE(flags &= ~GrDrawTargetCaps::kSubset_MapFlag); |
1079 } | 1076 } |
1080 SkASSERT(0 == flags); // Make sure we handled all the flags. | 1077 SkASSERT(0 == flags); // Make sure we handled all the flags. |
1081 return str; | 1078 return str; |
1082 } | 1079 } |
1083 | 1080 |
1084 SkString GrDrawTargetCaps::dump() const { | 1081 SkString GrDrawTargetCaps::dump() const { |
1085 SkString r; | 1082 SkString r; |
1086 static const char* gNY[] = {"NO", "YES"}; | 1083 static const char* gNY[] = {"NO", "YES"}; |
1087 r.appendf("8 Bit Palette Support : %s\n", gNY[f8BitPaletteSupport]); | |
1088 r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]); | 1084 r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]); |
1089 r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport ]); | 1085 r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport ]); |
1090 r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport ]); | 1086 r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport ]); |
1091 r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport] ); | 1087 r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport] ); |
1092 r.appendf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]); | 1088 r.appendf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]); |
1093 r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSuppor t]); | 1089 r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSuppor t]); |
1094 r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport] ); | 1090 r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport] ); |
1095 r.appendf("Dual Source Blending Support : %s\n", gNY[fDualSourceBlendingSupp ort]); | 1091 r.appendf("Dual Source Blending Support : %s\n", gNY[fDualSourceBlendingSupp ort]); |
1096 r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]) ; | 1092 r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]) ; |
1097 r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport ]); | 1093 r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport ]); |
1098 r.appendf("Discard Render Target Support: %s\n", gNY[fDiscardRenderTargetSup port]); | 1094 r.appendf("Discard Render Target Support: %s\n", gNY[fDiscardRenderTargetSup port]); |
1099 r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]) ; | 1095 r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]) ; |
1100 r.appendf("Gpu Tracing Support : %s\n", gNY[fGpuTracingSupport]); | 1096 r.appendf("Gpu Tracing Support : %s\n", gNY[fGpuTracingSupport]); |
1101 r.appendf("Max Texture Size : %d\n", fMaxTextureSize); | 1097 r.appendf("Max Texture Size : %d\n", fMaxTextureSize); |
1102 r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize); | 1098 r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize); |
1103 r.appendf("Max Sample Count : %d\n", fMaxSampleCount); | 1099 r.appendf("Max Sample Count : %d\n", fMaxSampleCount); |
1104 | 1100 |
1105 r.appendf("Map Buffer Support : %s\n", map_flags_to_string(fMapBuf ferFlags).c_str()); | 1101 r.appendf("Map Buffer Support : %s\n", map_flags_to_string(fMapBuf ferFlags).c_str()); |
1106 | 1102 |
1107 static const char* kConfigNames[] = { | 1103 static const char* kConfigNames[] = { |
1108 "Unknown", // kUnknown_GrPixelConfig | 1104 "Unknown", // kUnknown_GrPixelConfig |
1109 "Alpha8", // kAlpha_8_GrPixelConfig, | 1105 "Alpha8", // kAlpha_8_GrPixelConfig, |
1110 "Index8", // kIndex_8_GrPixelConfig, | 1106 "Index8", // kIndex_8_GrPixelConfig, |
1111 "RGB565", // kRGB_565_GrPixelConfig, | 1107 "RGB565", // kRGB_565_GrPixelConfig, |
1112 "RGBA444", // kRGBA_4444_GrPixelConfig, | 1108 "RGBA444", // kRGBA_4444_GrPixelConfig, |
1113 "RGBA8888", // kRGBA_8888_GrPixelConfig, | 1109 "RGBA8888", // kRGBA_8888_GrPixelConfig, |
1114 "BGRA8888", // kBGRA_8888_GrPixelConfig, | 1110 "BGRA8888", // kBGRA_8888_GrPixelConfig, |
1111 "ETC1", // kETC1_GrPixelConfig, | |
1112 "LATC", // kLATC_GrPixelConfig, | |
1115 }; | 1113 }; |
1116 GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig); | 1114 GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig); |
1117 GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig); | 1115 GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig); |
1118 GR_STATIC_ASSERT(2 == kIndex_8_GrPixelConfig); | 1116 GR_STATIC_ASSERT(2 == kIndex_8_GrPixelConfig); |
1119 GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig); | 1117 GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig); |
1120 GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig); | 1118 GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig); |
1121 GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig); | 1119 GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig); |
1122 GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig); | 1120 GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig); |
1121 GR_STATIC_ASSERT(7 == kETC1_GrPixelConfig); | |
1122 GR_STATIC_ASSERT(8 == kLATC_GrPixelConfig); | |
1123 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kConfigNames) == kGrPixelConfigCnt); | 1123 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kConfigNames) == kGrPixelConfigCnt); |
1124 | 1124 |
1125 SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][0]); | 1125 SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][0]); |
1126 SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][1]); | 1126 SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][1]); |
1127 | |
1127 for (size_t i = 0; i < SK_ARRAY_COUNT(kConfigNames); ++i) { | 1128 for (size_t i = 0; i < SK_ARRAY_COUNT(kConfigNames); ++i) { |
1128 if (i != kUnknown_GrPixelConfig) { | 1129 if (i != kUnknown_GrPixelConfig) { |
1129 r.appendf("%s is renderable: %s, with MSAA: %s\n", | 1130 r.appendf("%s is renderable: %s, with MSAA: %s\n", |
1130 kConfigNames[i], | 1131 kConfigNames[i], |
1131 gNY[fConfigRenderSupport[i][0]], | 1132 gNY[fConfigRenderSupport[i][0]], |
1132 gNY[fConfigRenderSupport[i][1]]); | 1133 gNY[fConfigRenderSupport[i][1]]); |
1133 } | 1134 } |
1134 } | 1135 } |
1135 | 1136 |
1136 static const char* kCompressedFormatNames[] = { | 1137 SkASSERT(!fConfigTextureSupport[kUnknown_GrPixelConfig]); |
1137 "ETC1", // kETC1_GrCompressedFormat | |
1138 "ETC2", // kETC2_GrCompressedFormat, | |
1139 "DXT1", // kDXT1_GrCompressedFormat, | |
1140 }; | |
1141 GR_STATIC_ASSERT(0 == kETC1_GrCompressedFormat); | |
1142 GR_STATIC_ASSERT(1 == kETC2_GrCompressedFormat); | |
1143 GR_STATIC_ASSERT(2 == kDXT1_GrCompressedFormat); | |
1144 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCompressedFormatNames) == kGrCompressedForm atCount); | |
1145 | 1138 |
robertphillips
2014/05/29 20:08:43
Can we just start the loop at 1 ?
krajcevski
2014/05/29 20:31:28
Done.
| |
1146 for (size_t i = 0; i < SK_ARRAY_COUNT(kCompressedFormatNames); ++i) { | 1139 for (size_t i = 0; i < SK_ARRAY_COUNT(kConfigNames); ++i) { |
1147 r.appendf("%s Compressed Texture Support: %s\n", | 1140 if (i != kUnknown_GrPixelConfig) { |
1148 kCompressedFormatNames[i], | 1141 r.appendf("%s is uploadable to a texture: %s\n", |
1149 gNY[fCompressedFormatSupport[i]]); | 1142 kConfigNames[i], |
1143 gNY[fConfigTextureSupport[i]]); | |
1144 } | |
1150 } | 1145 } |
1151 | 1146 |
1152 return r; | 1147 return r; |
1153 } | 1148 } |
OLD | NEW |