diff options
author | 2011-03-18 20:41:44 +0000 | |
---|---|---|
committer | 2011-03-18 20:41:44 +0000 | |
commit | b65e0cb8ad8a690498142d2b0097be250b0c7dfb (patch) | |
tree | dd81992aab148d882048a8a2ca337a7a6a406a75 /gpu/src/GrGpuGLShaders2.cpp | |
parent | 0f31ca79bde088e6caac219734c35c1ae3e9e8b9 (diff) |
Remove the compile-time selection of the GL implementation based on the
GR_SUPPORT_GLDESKTOP family of macros.
Support for the platform is configured dynamically, by querying the
fBindingsExported member of active GrGLInterface instance.
Review: http://codereview.appspot.com/4298048/
git-svn-id: http://skia.googlecode.com/svn/trunk@960 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/src/GrGpuGLShaders2.cpp')
-rw-r--r-- | gpu/src/GrGpuGLShaders2.cpp | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/gpu/src/GrGpuGLShaders2.cpp b/gpu/src/GrGpuGLShaders2.cpp index 972d8a3f7a..a56e511fca 100644 --- a/gpu/src/GrGpuGLShaders2.cpp +++ b/gpu/src/GrGpuGLShaders2.cpp @@ -17,8 +17,6 @@ #include "GrGLConfig.h" -#if GR_SUPPORT_GLES2 || GR_SUPPORT_GLDESKTOP - #include "GrGpuGLShaders2.h" #include "GrGpuVertex.h" #include "GrMemory.h" @@ -31,15 +29,6 @@ #define SKIP_CACHE_CHECK true -#if GR_SUPPORT_GLES2 - #define GR_PRECISION "mediump" - const char GR_SHADER_PRECISION[] = "precision mediump float;\n"; -#else - #define GR_PRECISION "" - const char GR_SHADER_PRECISION[] = ""; -#endif - - #define POS_ATTR_LOCATION 0 #define TEX_ATTR_LOCATION(X) (1 + X) #define COL_ATTR_LOCATION (2 + GrDrawTarget::kMaxTexCoords) @@ -51,6 +40,26 @@ #define GR_UINT32_MAX static_cast<uint32_t>(-1) +namespace { + +const char* GrPrecision() { + if (GR_GL_SUPPORT_ES2) { + return "mediump"; + } else { + return ""; + } +} + +const char* GrShaderPrecision() { + if (GR_GL_SUPPORT_ES2) { + return "precision mediump float;\n"; + } else { + return ""; + } +} + +} // namespace + struct GrGpuGLShaders2::StageUniLocations { GrGLint fTextureMatrixUni; GrGLint fSamplerUni; @@ -501,11 +510,15 @@ void GrGpuGLShaders2::GenStageCode(int stageNum, if (StageDesc::kRadial2Gradient_CoordMapping == desc.fCoordMapping) { - segments->fVSUnis += "uniform " GR_PRECISION " float "; + segments->fVSUnis += "uniform "; + segments->fVSUnis += GrPrecision(); + segments->fVSUnis += " float "; segments->fVSUnis += radial2ParamsName; segments->fVSUnis += "[6];\n"; - segments->fFSUnis += "uniform " GR_PRECISION " float "; + segments->fFSUnis += "uniform "; + segments->fFSUnis += GrPrecision(); + segments->fFSUnis += " float "; segments->fFSUnis += radial2ParamsName; segments->fFSUnis += "[6];\n"; locations->fRadial2Uni = 1; @@ -821,9 +834,9 @@ void GrGpuGLShaders2::GenProgram(const ProgramDesc& desc, stringCnt = 0; - if (GR_ARRAY_COUNT(GR_SHADER_PRECISION) > 1) { - strings[stringCnt] = GR_SHADER_PRECISION; - lengths[stringCnt] = GR_ARRAY_COUNT(GR_SHADER_PRECISION) - 1; + if (strlen(GrShaderPrecision()) > 1) { + strings[stringCnt] = GrShaderPrecision(); + lengths[stringCnt] = strlen(GrShaderPrecision()); ++stringCnt; } if (segments.fFSUnis.length()) { @@ -844,7 +857,7 @@ void GrGpuGLShaders2::GenProgram(const ProgramDesc& desc, #if PRINT_SHADERS GrPrintf("%s%s%s%s\n", - GR_SHADER_PRECISION, + GrShaderPrecision(), segments.fFSUnis.cstr(), segments.fVaryings.cstr(), segments.fFSCode.cstr()); @@ -1401,6 +1414,3 @@ void GrGpuGLShaders2::setupGeometry(int* startVertex, fHWGeometryState.fVertexLayout = fGeometrySrc.fVertexLayout; fHWGeometryState.fArrayPtrsDirty = false; } -#endif - - |