Move GrGLSL.h from include/private to src/gpu/glsl.
Nothing public was including this and it was included unnecessarily in many places.
Change-Id: Iee960b3e67981ab41af7442cc43391f2f57eb551
Reviewed-on: https://skia-review.googlesource.com/135787
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/gn/gpu.gni b/gn/gpu.gni
index bf448ce..ba45a9b 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -35,7 +35,6 @@
"$_include/private/GrColor.h",
"$_include/private/GrCCClipPath.h",
"$_include/private/GrCCPerOpListPaths.h",
- "$_include/private/GrGLSL.h",
"$_include/private/GrOpList.h",
"$_include/private/GrSingleOwner.h",
"$_include/private/GrRenderTargetProxy.h",
@@ -483,6 +482,7 @@
# GLSL
"$_src/gpu/glsl/GrGLSL.cpp",
+ "$_src/gpu/glsl/GrGLSL.h",
"$_src/gpu/glsl/GrGLSLBlend.cpp",
"$_src/gpu/glsl/GrGLSLBlend.h",
"$_src/gpu/glsl/GrGLSLColorSpaceXformHelper.h",
diff --git a/include/private/GrGLSL.h b/include/private/GrGLSL.h
deleted file mode 100644
index 23a5754..0000000
--- a/include/private/GrGLSL.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGLSL_DEFINED
-#define GrGLSL_DEFINED
-
-#include "GrTypesPriv.h"
-#include "SkString.h"
-
-class GrShaderCaps;
-
-// Limited set of GLSL versions we build shaders for. Caller should round
-// down the GLSL version to one of these enums.
-enum GrGLSLGeneration {
- /**
- * Desktop GLSL 1.10 and ES2 shading language (based on desktop GLSL 1.20)
- */
- k110_GrGLSLGeneration,
- /**
- * Desktop GLSL 1.30
- */
- k130_GrGLSLGeneration,
- /**
- * Desktop GLSL 1.40
- */
- k140_GrGLSLGeneration,
- /**
- * Desktop GLSL 1.50
- */
- k150_GrGLSLGeneration,
- /**
- * Desktop GLSL 3.30, and ES GLSL 3.00
- */
- k330_GrGLSLGeneration,
- /**
- * Desktop GLSL 4.00
- */
- k400_GrGLSLGeneration,
- /**
- * Desktop GLSL 4.20
- */
- k420_GrGLSLGeneration,
- /**
- * ES GLSL 3.10 only TODO Make GLSLCap objects to make this more granular
- */
- k310es_GrGLSLGeneration,
- /**
- * ES GLSL 3.20
- */
- k320es_GrGLSLGeneration,
-};
-
-bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration);
-
-/**
- * Adds a line of GLSL code to declare the default precision for float types.
- */
-void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision,
- const GrShaderCaps&,
- SkString* out);
-
-/**
- * Converts a GrSLPrecision to its corresponding GLSL precision qualifier.
- */
-static inline const char* GrGLSLPrecisionString(GrSLPrecision p) {
- switch (p) {
- case kLow_GrSLPrecision:
- return "lowp";
- case kMedium_GrSLPrecision:
- return "mediump";
- case kHigh_GrSLPrecision:
- return "highp";
- case kDefault_GrSLPrecision:
- return "";
- default:
- SK_ABORT("Unexpected precision type.");
- return "";
- }
-}
-
-/**
- * Converts a GrSLType to a string containing the name of the equivalent GLSL type.
- */
-const char* GrGLSLTypeString(const GrShaderCaps* shaderCaps, GrSLType t);
-
-#endif
diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp
index 064c16d..659dbbc 100644
--- a/src/effects/imagefilters/SkLightingImageFilter.cpp
+++ b/src/effects/imagefilters/SkLightingImageFilter.cpp
@@ -32,7 +32,6 @@
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
-#include "../private/GrGLSL.h"
class GrGLDiffuseLightingEffect;
class GrGLSpecularLightingEffect;
diff --git a/src/effects/imagefilters/SkMagnifierImageFilter.cpp b/src/effects/imagefilters/SkMagnifierImageFilter.cpp
index 40624ab..88d7862 100644
--- a/src/effects/imagefilters/SkMagnifierImageFilter.cpp
+++ b/src/effects/imagefilters/SkMagnifierImageFilter.cpp
@@ -19,7 +19,6 @@
////////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
-#include "../private/GrGLSL.h"
#include "GrColorSpaceXform.h"
#include "GrContext.h"
#include "GrCoordTransform.h"
diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
index 8b3e76c..6fe4e09 100644
--- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp
+++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
@@ -19,7 +19,6 @@
#include "SkWriteBuffer.h"
#if SK_SUPPORT_GPU
-#include "../private/GrGLSL.h"
#include "GrContext.h"
#include "GrCoordTransform.h"
#include "GrFixedClip.h"
diff --git a/src/gpu/GrShaderCaps.h b/src/gpu/GrShaderCaps.h
index 3e85b6c..9143946 100644
--- a/src/gpu/GrShaderCaps.h
+++ b/src/gpu/GrShaderCaps.h
@@ -8,8 +8,10 @@
#ifndef GrShaderCaps_DEFINED
#define GrShaderCaps_DEFINED
-#include "../private/GrGLSL.h"
#include "../private/GrSwizzle.h"
+#include "GrTypesPriv.h"
+#include "SkRefCnt.h"
+#include "glsl/GrGLSL.h"
namespace SkSL {
class ShaderCapsFactory;
diff --git a/src/gpu/GrShaderVar.cpp b/src/gpu/GrShaderVar.cpp
index 4d6c658..61cd3c9 100644
--- a/src/gpu/GrShaderVar.cpp
+++ b/src/gpu/GrShaderVar.cpp
@@ -35,6 +35,23 @@
SK_ABORT("Unknown io type.");
}
+// Converts a GrSLPrecision to its corresponding GLSL precision qualifier. TODO: Remove this as we
+// shouldn't need it with SkSL.
+static inline const char* glsl_precision_string(GrSLPrecision p) {
+ switch (p) {
+ case kLow_GrSLPrecision:
+ return "lowp";
+ case kMedium_GrSLPrecision:
+ return "mediump";
+ case kHigh_GrSLPrecision:
+ return "highp";
+ case kDefault_GrSLPrecision:
+ return "";
+ }
+ SK_ABORT("Unexpected precision type.");
+ return "";
+}
+
void GrShaderVar::appendDecl(const GrShaderCaps* shaderCaps, SkString* out) const {
SkASSERT(kDefault_GrSLPrecision == fPrecision || GrSLTypeTemporarilyAcceptsPrecision(fType));
SkString layout = fLayoutQualifier;
@@ -49,7 +66,7 @@
GrSLType effectiveType = this->getType();
if (shaderCaps->usesPrecisionModifiers() && GrSLTypeAcceptsPrecision(effectiveType)) {
// Desktop GLSL has added precision qualifiers but they don't do anything.
- out->appendf("%s ", GrGLSLPrecisionString(fPrecision));
+ out->appendf("%s ", glsl_precision_string(fPrecision));
}
if (this->isArray()) {
if (this->isUnsizedArray()) {
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index c2cedf2..803f290 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -11,7 +11,6 @@
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
-#include "../private/GrGLSL.h"
class GrGLBicubicEffect : public GrGLSLFragmentProcessor {
public:
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 753d34e..f98ed47 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -13,7 +13,6 @@
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
-#include "../private/GrGLSL.h"
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index c546f8c..bfd3f86 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -9,7 +9,6 @@
#include "GrTexture.h"
#include "GrTextureProxy.h"
-#include "../private/GrGLSL.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index cd1ef1a..ec2126d 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -12,7 +12,6 @@
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
-#include "../private/GrGLSL.h"
class GrGLMatrixConvolutionEffect : public GrGLSLFragmentProcessor {
public:
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 4f9b63f..4f33ef4 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -305,7 +305,7 @@
if (kGL_GrGLStandard == standard) {
shaderCaps->fDualSourceBlendingSupport = (ctxInfo.version() >= GR_GL_VER(3, 3) ||
ctxInfo.hasExtension("GL_ARB_blend_func_extended")) &&
- GrGLSLSupportsNamedFragmentShaderOutputs(ctxInfo.glslGeneration());
+ ctxInfo.glslGeneration() >= k130_GrGLSLGeneration;
shaderCaps->fShaderDerivativeSupport = true;
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 1596dfd..7380146 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -10,14 +10,12 @@
#define GrGLCaps_DEFINED
#include <functional>
-
#include "GrCaps.h"
#include "GrGLStencilAttachment.h"
#include "GrSwizzle.h"
#include "SkChecksum.h"
#include "SkTHash.h"
#include "SkTArray.h"
-#include "../private/GrGLSL.h"
class GrGLContextInfo;
class GrGLRenderTarget;
diff --git a/src/gpu/gl/GrGLContext.h b/src/gpu/gl/GrGLContext.h
index 998a5f5..4ed76e6 100644
--- a/src/gpu/gl/GrGLContext.h
+++ b/src/gpu/gl/GrGLContext.h
@@ -9,10 +9,11 @@
#ifndef GrGLContext_DEFINED
#define GrGLContext_DEFINED
-#include "gl/GrGLExtensions.h"
-#include "gl/GrGLInterface.h"
#include "GrGLCaps.h"
#include "GrGLUtil.h"
+#include "gl/GrGLExtensions.h"
+#include "gl/GrGLInterface.h"
+#include "glsl/GrGLSL.h"
struct GrContextOptions;
namespace SkSL {
diff --git a/src/gpu/gl/GrGLGLSL.cpp b/src/gpu/gl/GrGLGLSL.cpp
index ab92358..4050d36 100644
--- a/src/gpu/gl/GrGLGLSL.cpp
+++ b/src/gpu/gl/GrGLGLSL.cpp
@@ -5,10 +5,8 @@
* found in the LICENSE file.
*/
-#include "GrGLContext.h"
+#include "GrGLGLSL.h"
#include "GrGLUtil.h"
-#include "SkString.h"
-#include "../private/GrGLSL.h"
bool GrGLGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) {
SkASSERT(generation);
diff --git a/src/gpu/gl/GrGLGLSL.h b/src/gpu/gl/GrGLGLSL.h
index 88bb273..48bea7f 100644
--- a/src/gpu/gl/GrGLGLSL.h
+++ b/src/gpu/gl/GrGLGLSL.h
@@ -5,21 +5,16 @@
* found in the LICENSE file.
*/
-#ifndef GrGLInitGLSL_DEFINED
-#define GrGLInitGLSL_DEFINED
+#ifndef GrGLGLSL_DEFINED
+#define GrGLGLSL_DEFINED
-#include "gl/GrGLInterface.h"
-#include "GrColor.h"
-#include "GrTypesPriv.h"
-#include "SkString.h"
-#include "../private/GrGLSL.h"
+#include "glsl/GrGLSL.h"
-class GrGLContextInfo;
+struct GrGLInterface;
/**
* Gets the most recent GLSL Generation compatible with the OpenGL context.
*/
bool GrGLGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation);
-
#endif
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index be53222..40d1c3b 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -6,8 +6,6 @@
*/
#include "GrGLGpu.h"
-
-#include "../private/GrGLSL.h"
#include "GrBackendSemaphore.h"
#include "GrBackendSurface.h"
#include "GrFixedClip.h"
diff --git a/src/gpu/glsl/GrGLSL.cpp b/src/gpu/glsl/GrGLSL.cpp
index 4791a0e..67fe299 100644
--- a/src/gpu/glsl/GrGLSL.cpp
+++ b/src/gpu/glsl/GrGLSL.cpp
@@ -5,26 +5,8 @@
* found in the LICENSE file.
*/
+#include "GrGLSL.h"
#include "GrShaderCaps.h"
-#include "SkString.h"
-#include "../private/GrGLSL.h"
-
-bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration gen) {
- switch (gen) {
- case k110_GrGLSLGeneration:
- return false;
- case k130_GrGLSLGeneration:
- case k140_GrGLSLGeneration:
- case k150_GrGLSLGeneration:
- case k330_GrGLSLGeneration:
- case k400_GrGLSLGeneration:
- case k420_GrGLSLGeneration:
- case k310es_GrGLSLGeneration:
- case k320es_GrGLSLGeneration:
- return true;
- }
- return false;
-}
const char* GrGLSLTypeString(const GrShaderCaps* shaderCaps, GrSLType t) {
switch (t) {
@@ -111,23 +93,3 @@
SK_ABORT("Unknown shader var type.");
return ""; // suppress warning
}
-
-void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision p,
- const GrShaderCaps& shaderCaps,
- SkString* out) {
- if (shaderCaps.usesPrecisionModifiers()) {
- switch (p) {
- case kHigh_GrSLPrecision:
- out->append("precision highp float;\n");
- break;
- case kMedium_GrSLPrecision:
- out->append("precision mediump float;\n");
- break;
- case kLow_GrSLPrecision:
- out->append("precision lowp float;\n");
- break;
- default:
- SK_ABORT("Unknown precision value.");
- }
- }
-}
diff --git a/src/gpu/glsl/GrGLSL.h b/src/gpu/glsl/GrGLSL.h
new file mode 100644
index 0000000..743eef1
--- /dev/null
+++ b/src/gpu/glsl/GrGLSL.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLSL_DEFINED
+#define GrGLSL_DEFINED
+
+#include "GrTypesPriv.h"
+
+class GrShaderCaps;
+
+// Limited set of GLSL versions we build shaders for. Caller should round
+// down the GLSL version to one of these enums.
+enum GrGLSLGeneration {
+ /**
+ * Desktop GLSL 1.10 and ES2 shading language (based on desktop GLSL 1.20)
+ */
+ k110_GrGLSLGeneration,
+ /**
+ * Desktop GLSL 1.30
+ */
+ k130_GrGLSLGeneration,
+ /**
+ * Desktop GLSL 1.40
+ */
+ k140_GrGLSLGeneration,
+ /**
+ * Desktop GLSL 1.50
+ */
+ k150_GrGLSLGeneration,
+ /**
+ * Desktop GLSL 3.30, and ES GLSL 3.00
+ */
+ k330_GrGLSLGeneration,
+ /**
+ * Desktop GLSL 4.00
+ */
+ k400_GrGLSLGeneration,
+ /**
+ * Desktop GLSL 4.20
+ */
+ k420_GrGLSLGeneration,
+ /**
+ * ES GLSL 3.10 only TODO Make GLSLCap objects to make this more granular
+ */
+ k310es_GrGLSLGeneration,
+ /**
+ * ES GLSL 3.20
+ */
+ k320es_GrGLSLGeneration,
+};
+
+const char* GrGLSLTypeString(const GrShaderCaps*, GrSLType);
+
+#endif
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
index 895d344..788fd70 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
@@ -13,7 +13,6 @@
#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLUniformHandler.h"
#include "glsl/GrGLSLVarying.h"
-#include "../private/GrGLSL.h"
const char* GrGLSLFragmentShaderBuilder::kDstColorName = "_dstColor";