Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: src/gpu/gl/GrGLCaps.cpp

Issue 1153813002: Remove init from GrGLContextInfo and caps classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 8
9 #include "GrGLCaps.h" 9 #include "GrGLCaps.h"
10 10
11 #include "GrGLContext.h" 11 #include "GrGLContext.h"
12 #include "SkTSearch.h" 12 #include "SkTSearch.h"
13 #include "SkTSort.h" 13 #include "SkTSort.h"
14 14
15 GrGLCaps::GrGLCaps() { 15 GrGLCaps::GrGLCaps(const GrGLContextInfo& ctxInfo, const GrGLInterface* glInterf ace) {
16 this->reset();
17 }
18
19 void GrGLCaps::reset() {
20 INHERITED::reset();
21
22 fVerifiedColorConfigs.reset(); 16 fVerifiedColorConfigs.reset();
23 fStencilFormats.reset(); 17 fStencilFormats.reset();
24 fStencilVerifiedColorConfigs.reset(); 18 fStencilVerifiedColorConfigs.reset();
25 fMSFBOType = kNone_MSFBOType; 19 fMSFBOType = kNone_MSFBOType;
26 fInvalidateFBType = kNone_InvalidateFBType; 20 fInvalidateFBType = kNone_InvalidateFBType;
27 fLATCAlias = kLATC_LATCAlias; 21 fLATCAlias = kLATC_LATCAlias;
28 fMapBufferType = kNone_MapBufferType; 22 fMapBufferType = kNone_MapBufferType;
29 fMaxFragmentUniformVectors = 0; 23 fMaxFragmentUniformVectors = 0;
30 fMaxVertexAttributes = 0; 24 fMaxVertexAttributes = 0;
31 fMaxFragmentTextureUnits = 0; 25 fMaxFragmentTextureUnits = 0;
(...skipping 12 matching lines...) Expand all
44 fFragCoordsConventionSupport = false; 38 fFragCoordsConventionSupport = false;
45 fVertexArrayObjectSupport = false; 39 fVertexArrayObjectSupport = false;
46 fES2CompatibilitySupport = false; 40 fES2CompatibilitySupport = false;
47 fMultisampleDisableSupport = false; 41 fMultisampleDisableSupport = false;
48 fUseNonVBOVertexAndIndexDynamicData = false; 42 fUseNonVBOVertexAndIndexDynamicData = false;
49 fIsCoreProfile = false; 43 fIsCoreProfile = false;
50 fFullClearIsFree = false; 44 fFullClearIsFree = false;
51 45
52 fReadPixelsSupportedCache.reset(); 46 fReadPixelsSupportedCache.reset();
53 47
54 fShaderCaps.reset(SkNEW(GrGLSLCaps)); 48 this->init(ctxInfo, glInterface);
55 49
50 fShaderCaps.reset(SkNEW_ARGS(GrGLSLCaps, (ctxInfo, glInterface, *this)));
56 } 51 }
57 52
58 GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrCaps() { 53 void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
59 *this = caps;
60 }
61
62 GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) {
63 INHERITED::operator=(caps);
64 fVerifiedColorConfigs = caps.fVerifiedColorConfigs;
65 fStencilFormats = caps.fStencilFormats;
66 fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs;
67 fLATCAlias = caps.fLATCAlias;
68 fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors;
69 fMaxVertexAttributes = caps.fMaxVertexAttributes;
70 fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits;
71 fMSFBOType = caps.fMSFBOType;
72 fInvalidateFBType = caps.fInvalidateFBType;
73 fMapBufferType = caps.fMapBufferType;
74 fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport;
75 fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat;
76 fTextureSwizzleSupport = caps.fTextureSwizzleSupport;
77 fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport;
78 fUnpackFlipYSupport = caps.fUnpackFlipYSupport;
79 fPackRowLengthSupport = caps.fPackRowLengthSupport;
80 fPackFlipYSupport = caps.fPackFlipYSupport;
81 fTextureUsageSupport = caps.fTextureUsageSupport;
82 fTexStorageSupport = caps.fTexStorageSupport;
83 fTextureRedSupport = caps.fTextureRedSupport;
84 fImagingSupport = caps.fImagingSupport;
85 fTwoFormatLimit = caps.fTwoFormatLimit;
86 fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport;
87 fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport;
88 fES2CompatibilitySupport = caps.fES2CompatibilitySupport;
89 fMultisampleDisableSupport = caps.fMultisampleDisableSupport;
90 fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicDa ta;
91 fIsCoreProfile = caps.fIsCoreProfile;
92 fFullClearIsFree = caps.fFullClearIsFree;
93
94 *(reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get())) =
95 *(reinterpret_cast<GrGLSLCaps*>(caps.f ShaderCaps.get()));
96
97 return *this;
98 }
99
100 bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
101
102 this->reset();
103 if (!ctxInfo.isInitialized()) {
104 return false;
105 }
106
107 GrGLStandard standard = ctxInfo.standard(); 54 GrGLStandard standard = ctxInfo.standard();
108 GrGLVersion version = ctxInfo.version(); 55 GrGLVersion version = ctxInfo.version();
109 56
110 /************************************************************************** 57 /**************************************************************************
111 * Caps specific to GrGLCaps 58 * Caps specific to GrGLCaps
112 **************************************************************************/ 59 **************************************************************************/
113 60
114 if (kGLES_GrGLStandard == standard) { 61 if (kGLES_GrGLStandard == standard) {
115 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, 62 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS,
116 &fMaxFragmentUniformVectors); 63 &fMaxFragmentUniformVectors);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } else { 315 } else {
369 SkASSERT(ctxInfo.hasExtension("GL_EXT_framebuffer_object")); 316 SkASSERT(ctxInfo.hasExtension("GL_EXT_framebuffer_object"));
370 } 317 }
371 } else { 318 } else {
372 // ES 3.0 supports mixed size FBO attachments, 2.0 does not. 319 // ES 3.0 supports mixed size FBO attachments, 2.0 does not.
373 fOversizedStencilSupport = ctxInfo.version() >= GR_GL_VER(3, 0); 320 fOversizedStencilSupport = ctxInfo.version() >= GR_GL_VER(3, 0);
374 } 321 }
375 322
376 this->initConfigTexturableTable(ctxInfo, gli); 323 this->initConfigTexturableTable(ctxInfo, gli);
377 this->initConfigRenderableTable(ctxInfo); 324 this->initConfigRenderableTable(ctxInfo);
378
379 reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get())->init(ctxInfo, gli, *this);
380
381 return true;
382 } 325 }
383 326
384 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) { 327 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
385 // OpenGL < 3.0 328 // OpenGL < 3.0
386 // no support for render targets unless the GL_ARB_framebuffer_object 329 // no support for render targets unless the GL_ARB_framebuffer_object
387 // extension is supported (in which case we get ALPHA, RED, RG, RGB, 330 // extension is supported (in which case we get ALPHA, RED, RG, RGB,
388 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we 331 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
389 // probably don't get R8 in this case. 332 // probably don't get R8 in this case.
390 333
391 // OpenGL 3.0 334 // OpenGL 3.0
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); 884 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
942 r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ? "YES" : "NO")); 885 r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ? "YES" : "NO"));
943 r.appendf("Use non-VBO for dynamic data: %s\n", 886 r.appendf("Use non-VBO for dynamic data: %s\n",
944 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); 887 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
945 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO ")); 888 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO "));
946 return r; 889 return r;
947 } 890 }
948 891
949 //////////////////////////////////////////////////////////////////////////////// //////////// 892 //////////////////////////////////////////////////////////////////////////////// ////////////
950 893
951 GrGLSLCaps::GrGLSLCaps() { 894 GrGLSLCaps::GrGLSLCaps(const GrGLContextInfo& ctxInfo,
952 this->reset(); 895 const GrGLInterface* gli,
953 } 896 const GrGLCaps& glCaps) {
954
955
956 void GrGLSLCaps::reset() {
957 INHERITED::reset();
958
959 fDropsTileOnZeroDivide = false; 897 fDropsTileOnZeroDivide = false;
960 fFBFetchSupport = false; 898 fFBFetchSupport = false;
961 fFBFetchNeedsCustomOutput = false; 899 fFBFetchNeedsCustomOutput = false;
962 fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction; 900 fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction;
963 fFBFetchColorName = NULL; 901 fFBFetchColorName = NULL;
964 fFBFetchExtensionString = NULL; 902 fFBFetchExtensionString = NULL;
903 this->init(ctxInfo, gli, glCaps);
965 } 904 }
966 905
967 GrGLSLCaps::GrGLSLCaps(const GrGLSLCaps& caps) : GrShaderCaps() { 906 void GrGLSLCaps::init(const GrGLContextInfo& ctxInfo,
968 *this = caps;
969 }
970
971 GrGLSLCaps& GrGLSLCaps::operator= (const GrGLSLCaps& caps) {
972 INHERITED::operator=(caps);
973 fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide;
974 fFBFetchSupport = caps.fFBFetchSupport;
975 fFBFetchNeedsCustomOutput = caps.fFBFetchNeedsCustomOutput;
976 fAdvBlendEqInteraction = caps.fAdvBlendEqInteraction;
977 fFBFetchColorName = caps.fFBFetchColorName;
978 fFBFetchExtensionString = caps.fFBFetchExtensionString;
979
980 return *this;
981 }
982
983 bool GrGLSLCaps::init(const GrGLContextInfo& ctxInfo,
984 const GrGLInterface* gli, 907 const GrGLInterface* gli,
985 const GrGLCaps& glCaps) { 908 const GrGLCaps& glCaps) {
986 this->reset();
987 if (!ctxInfo.isInitialized()) {
988 return false;
989 }
990
991 GrGLStandard standard = ctxInfo.standard(); 909 GrGLStandard standard = ctxInfo.standard();
992 GrGLVersion version = ctxInfo.version(); 910 GrGLVersion version = ctxInfo.version();
993 911
994 /************************************************************************** 912 /**************************************************************************
995 * Caps specific to GrGLSLCaps 913 * Caps specific to GrGLSLCaps
996 **************************************************************************/ 914 **************************************************************************/
997 915
998 if (kGLES_GrGLStandard == standard) { 916 if (kGLES_GrGLStandard == standard) {
999 if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) { 917 if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) {
1000 fFBFetchNeedsCustomOutput = (version >= GR_GL_VER(3, 0)); 918 fFBFetchNeedsCustomOutput = (version >= GR_GL_VER(3, 0));
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 : "GL_NV_blend_equation_advanced")) { 992 : "GL_NV_blend_equation_advanced")) {
1075 fAdvBlendEqInteraction = kAutomatic_AdvBlendEqInteraction; 993 fAdvBlendEqInteraction = kAutomatic_AdvBlendEqInteraction;
1076 } else { 994 } else {
1077 fAdvBlendEqInteraction = kGeneralEnable_AdvBlendEqInteraction; 995 fAdvBlendEqInteraction = kGeneralEnable_AdvBlendEqInteraction;
1078 // TODO: Use the following on any platform where "blend_support_all_ equations" is slow. 996 // TODO: Use the following on any platform where "blend_support_all_ equations" is slow.
1079 //fAdvBlendEqInteraction = kSpecificEnables_AdvBlendEqInteraction; 997 //fAdvBlendEqInteraction = kSpecificEnables_AdvBlendEqInteraction;
1080 } 998 }
1081 } 999 }
1082 1000
1083 this->initShaderPrecisionTable(ctxInfo, gli); 1001 this->initShaderPrecisionTable(ctxInfo, gli);
1084
1085 return true;
1086 } 1002 }
1087 1003
1088 SkString GrGLSLCaps::dump() const { 1004 SkString GrGLSLCaps::dump() const {
1089 SkString r = INHERITED::dump(); 1005 SkString r = INHERITED::dump();
1090 1006
1091 static const char* kAdvBlendEqInteractionStr[] = { 1007 static const char* kAdvBlendEqInteractionStr[] = {
1092 "Not Supported", 1008 "Not Supported",
1093 "Automatic", 1009 "Automatic",
1094 "General Enable", 1010 "General Enable",
1095 "Specific Enables", 1011 "Specific Enables",
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 if (fGeometryShaderSupport) { 1102 if (fGeometryShaderSupport) {
1187 for (int p = 0; p < kGrSLPrecisionCount; ++p) { 1103 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
1188 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVert ex_GrShaderType][p]; 1104 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVert ex_GrShaderType][p];
1189 } 1105 }
1190 } 1106 }
1191 } 1107 }
1192 1108
1193 1109
1194 1110
1195 1111
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698