Move all ShaderBuilder files to GLSL
authoregdaniel <egdaniel@google.com>
Wed, 11 Nov 2015 21:06:05 +0000 (13:06 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 11 Nov 2015 21:06:05 +0000 (13:06 -0800)
BUG=skia:

Review URL: https://codereview.chromium.org/1438003003

74 files changed:
experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
gm/dcshader.cpp
gyp/gpu.gypi
src/core/SkLightingShader.cpp
src/effects/GrCircleBlurFragmentProcessor.cpp
src/effects/SkAlphaThresholdFilter.cpp
src/effects/SkArithmeticMode_gpu.cpp
src/effects/SkBlurMaskFilter.cpp
src/effects/SkColorCubeFilter.cpp
src/effects/SkColorMatrixFilter.cpp
src/effects/SkDisplacementMapEffect.cpp
src/effects/SkLightingImageFilter.cpp
src/effects/SkLumaColorFilter.cpp
src/effects/SkMagnifierImageFilter.cpp
src/effects/SkMorphologyImageFilter.cpp
src/effects/SkPerlinNoiseShader.cpp
src/effects/SkTableColorFilter.cpp
src/effects/gradients/SkGradientShader.cpp
src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
src/gpu/GrDefaultGeoProcFactory.cpp
src/gpu/GrFragmentProcessor.cpp
src/gpu/GrOvalRenderer.cpp
src/gpu/GrPathProcessor.cpp
src/gpu/batches/GrAAConvexPathRenderer.cpp
src/gpu/effects/GrBezierEffect.cpp
src/gpu/effects/GrBicubicEffect.cpp
src/gpu/effects/GrBitmapTextGeoProc.cpp
src/gpu/effects/GrConfigConversionEffect.cpp
src/gpu/effects/GrConstColorProcessor.cpp
src/gpu/effects/GrConvexPolyEffect.cpp
src/gpu/effects/GrConvolutionEffect.cpp
src/gpu/effects/GrCoverageSetOpXP.cpp
src/gpu/effects/GrCustomXfermode.cpp
src/gpu/effects/GrDashingEffect.cpp
src/gpu/effects/GrDisableColorXP.cpp
src/gpu/effects/GrDistanceFieldGeoProc.cpp
src/gpu/effects/GrDitherEffect.cpp
src/gpu/effects/GrMatrixConvolutionEffect.cpp
src/gpu/effects/GrOvalEffect.cpp
src/gpu/effects/GrPorterDuffXferProcessor.cpp
src/gpu/effects/GrRRectEffect.cpp
src/gpu/effects/GrSimpleTextureEffect.cpp
src/gpu/effects/GrTextureDomain.cpp
src/gpu/effects/GrTextureDomain.h
src/gpu/effects/GrXfermodeFragmentProcessor.cpp
src/gpu/effects/GrYUVtoRGBEffect.cpp
src/gpu/gl/GrGLFragmentProcessor.cpp
src/gpu/gl/GrGLGeometryProcessor.cpp
src/gpu/gl/GrGLPrimitiveProcessor.cpp
src/gpu/gl/GrGLProgramDesc.cpp
src/gpu/gl/GrGLSLBlend.cpp
src/gpu/gl/GrGLSLBlend.h
src/gpu/gl/GrGLXferProcessor.cpp
src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp [deleted file]
src/gpu/gl/builders/GrGLFragmentShaderBuilder.h [deleted file]
src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp [deleted file]
src/gpu/gl/builders/GrGLGeometryShaderBuilder.h [deleted file]
src/gpu/gl/builders/GrGLProgramBuilder.cpp
src/gpu/gl/builders/GrGLProgramBuilder.h
src/gpu/gl/builders/GrGLShaderBuilder.cpp [deleted file]
src/gpu/gl/builders/GrGLShaderBuilder.h [deleted file]
src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp [deleted file]
src/gpu/gl/builders/GrGLVertexShaderBuilder.h [deleted file]
src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp [new file with mode: 0644]
src/gpu/glsl/GrGLSLFragmentShaderBuilder.h [new file with mode: 0644]
src/gpu/glsl/GrGLSLGeometryShaderBuilder.cpp [new file with mode: 0644]
src/gpu/glsl/GrGLSLGeometryShaderBuilder.h [new file with mode: 0644]
src/gpu/glsl/GrGLSLProgramBuilder.h
src/gpu/glsl/GrGLSLShaderBuilder.cpp [new file with mode: 0644]
src/gpu/glsl/GrGLSLShaderBuilder.h [new file with mode: 0644]
src/gpu/glsl/GrGLSLTextureSampler.h
src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp [new file with mode: 0644]
src/gpu/glsl/GrGLSLVertexShaderBuilder.h [new file with mode: 0644]
tests/GLProgramsTest.cpp

index bbfb8cf5830bf9748213551b28cb67b366d734be..6504df262977075e74a2c7f956b2abed65d02ad2 100644 (file)
@@ -21,7 +21,8 @@
 #include "SkGr.h"
 #include "effects/GrConstColorProcessor.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #endif
 
@@ -756,17 +757,17 @@ GrGLPerlinNoise2::GrGLPerlinNoise2(const GrProcessor& processor)
 }
 
 void GrGLPerlinNoise2::emitCode(EmitArgs& args) {
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString vCoords = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
 
-    fBaseFrequencyUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fBaseFrequencyUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                             kVec2f_GrSLType, kDefault_GrSLPrecision,
                                             "baseFrequency");
     const char* baseFrequencyUni = args.fBuilder->getUniformCStr(fBaseFrequencyUni);
 
     const char* stitchDataUni = nullptr;
     if (fStitchTiles) {
-        fStitchDataUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fStitchDataUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                              kVec2f_GrSLType, kDefault_GrSLPrecision,
                                              "stitchData");
         stitchDataUni = args.fBuilder->getUniformCStr(fStitchDataUni);
@@ -1005,7 +1006,7 @@ void GrGLPerlinNoise2::emitCode(EmitArgs& args) {
 }
 
 void GrGLPerlinNoise2::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
-                             GrProcessorKeyBuilder* b) {
+                              GrProcessorKeyBuilder* b) {
     const GrPerlinNoise2Effect& turbulence = processor.cast<GrPerlinNoise2Effect>();
 
     uint32_t key = turbulence.numOctaves();
@@ -1169,20 +1170,20 @@ GrGLImprovedPerlinNoise::GrGLImprovedPerlinNoise(const GrProcessor& processor)
 }
 
 void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString vCoords = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
 
-    fBaseFrequencyUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fBaseFrequencyUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                             kVec2f_GrSLType, kDefault_GrSLPrecision,
                                             "baseFrequency");
     const char* baseFrequencyUni = args.fBuilder->getUniformCStr(fBaseFrequencyUni);
 
-    fOctavesUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fOctavesUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                       kFloat_GrSLType, kDefault_GrSLPrecision,
                                       "octaves");
     const char* octavesUni = args.fBuilder->getUniformCStr(fOctavesUni);
 
-    fZUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fZUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                       kFloat_GrSLType, kDefault_GrSLPrecision,
                                       "z");
     const char* zUni = args.fBuilder->getUniformCStr(fZUni);
index d1a9d4ca6fdcc7bbf77537c9c65a81fad9baef47..828c8dcf51618a6de69a8b48095d56436de18015 100644 (file)
@@ -12,7 +12,8 @@
 #include "GrCoordTransform.h"
 #include "effects/GrXfermodeFragmentProcessor.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #include "Resources.h"
 #include "SkReadBuffer.h"
@@ -66,7 +67,7 @@ public:
     GrGLFragmentProcessor* onCreateGLInstance() const override {
         class DCGLFP : public GrGLFragmentProcessor {
             void emitCode(EmitArgs& args) override {
-                GrGLFragmentBuilder* fpb = args.fBuilder->getFragmentShaderBuilder();
+                GrGLSLFragmentBuilder* fpb = args.fBuilder->getFragmentShaderBuilder();
                 fpb->codeAppendf("vec2 c = %s;", fpb->ensureFSCoords2D(args.fCoords, 0).c_str());
                 fpb->codeAppend("vec2 r = mod(c, vec2(20.0));");
                 fpb->codeAppend("vec4 color = vec4(0.5*sin(c.x / 15.0) + 0.5,"
index 1f1b6a37fd5306df092cd869f3baaf887d837ff9..960e857a48b082347579829ad3d96586bbfed2b7 100644 (file)
       # Files for building GLSL shaders
       '<(skia_src_path)/gpu/gl/builders/GrGLProgramBuilder.cpp',
       '<(skia_src_path)/gpu/gl/builders/GrGLProgramBuilder.h',
-      '<(skia_src_path)/gpu/gl/builders/GrGLShaderBuilder.cpp',
-      '<(skia_src_path)/gpu/gl/builders/GrGLShaderBuilder.h',
       '<(skia_src_path)/gpu/gl/builders/GrGLShaderStringBuilder.cpp',
       '<(skia_src_path)/gpu/gl/builders/GrGLShaderStringBuilder.h',
       '<(skia_src_path)/gpu/gl/builders/GrGLSLPrettyPrint.cpp',
-      '<(skia_src_path)/gpu/gl/builders/GrGLVertexShaderBuilder.cpp',
-      '<(skia_src_path)/gpu/gl/builders/GrGLVertexShaderBuilder.h',
-      '<(skia_src_path)/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp',
-      '<(skia_src_path)/gpu/gl/builders/GrGLFragmentShaderBuilder.h',
-      '<(skia_src_path)/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp',
-      '<(skia_src_path)/gpu/gl/builders/GrGLGeometryShaderBuilder.h',
 
       # GLSL
       '<(skia_src_path)/gpu/glsl/GrGLSL.cpp',
       '<(skia_src_path)/gpu/glsl/GrGLSL_impl.h',
       '<(skia_src_path)/gpu/glsl/GrGLSLCaps.cpp',
       '<(skia_src_path)/gpu/glsl/GrGLSLCaps.h',
+      '<(skia_src_path)/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp',
+      '<(skia_src_path)/gpu/glsl/GrGLSLFragmentShaderBuilder.h',
+      '<(skia_src_path)/gpu/glsl/GrGLSLGeometryShaderBuilder.cpp',
+      '<(skia_src_path)/gpu/glsl/GrGLSLGeometryShaderBuilder.h',
       '<(skia_src_path)/gpu/glsl/GrGLSLProcessorTypes.h',
       '<(skia_src_path)/gpu/glsl/GrGLSLProgramBuilder.cpp',
       '<(skia_src_path)/gpu/glsl/GrGLSLProgramBuilder.h',
       '<(skia_src_path)/gpu/glsl/GrGLSLProgramDataManager.h',
+      '<(skia_src_path)/gpu/glsl/GrGLSLShaderBuilder.cpp',
+      '<(skia_src_path)/gpu/glsl/GrGLSLShaderBuilder.h',
       '<(skia_src_path)/gpu/glsl/GrGLSLShaderVar.h',
       '<(skia_src_path)/gpu/glsl/GrGLSLTextureSampler.h',
+      '<(skia_src_path)/gpu/glsl/GrGLSLVertexShaderBuilder.cpp',
+      '<(skia_src_path)/gpu/glsl/GrGLSLVertexShaderBuilder.h',
 
       # Sk files
       '<(skia_include_path)/gpu/SkGr.h',
index 2d7000aeface77a39c2be5b73d618e5db7624400..a1a09b7491570d349296ce1ae679c715214b38e9 100644 (file)
@@ -131,7 +131,8 @@ private:
 #include "GrFragmentProcessor.h"
 #include "GrTextureAccess.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #include "SkGr.h"
 #include "SkGrPriv.h"
@@ -178,26 +179,26 @@ public:
 
         void emitCode(EmitArgs& args) override {
 
-            GrGLFragmentBuilder* fpb = args.fBuilder->getFragmentShaderBuilder();
+            GrGLSLFragmentBuilder* fpb = args.fBuilder->getFragmentShaderBuilder();
 
             // add uniforms
             const char* lightDirUniName = nullptr;
-            fLightDirUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+            fLightDirUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                                      kVec3f_GrSLType, kDefault_GrSLPrecision,
                                                      "LightDir", &lightDirUniName);
 
             const char* lightColorUniName = nullptr;
-            fLightColorUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+            fLightColorUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                                        kVec3f_GrSLType, kDefault_GrSLPrecision,
                                                        "LightColor", &lightColorUniName);
 
             const char* ambientColorUniName = nullptr;
-            fAmbientColorUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+            fAmbientColorUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                                          kVec3f_GrSLType, kDefault_GrSLPrecision,
                                                          "AmbientColor", &ambientColorUniName);
 
             const char* xformUniName = nullptr;
-            fXformUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+            fXformUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                                   kVec2f_GrSLType, kDefault_GrSLPrecision,
                                                   "Xform", &xformUniName);
 
index e5887329ae1018982f6d015e2550f8354ca7f6e0..7776b630d018dc1255a7a8568654bfdcd6fb6884 100644 (file)
@@ -14,7 +14,8 @@
 #include "GrTextureProvider.h"
 
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 class GrGLCircleBlurFragmentProcessor : public GrGLFragmentProcessor {
@@ -39,13 +40,13 @@ void GrGLCircleBlurFragmentProcessor::emitCode(EmitArgs& args) {
     // x,y  - the center of the circle
     // z    - the distance at which the intensity starts falling off (e.g., the start of the table)
     // w    - the size of the profile texture
-    fDataUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fDataUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                              kVec4f_GrSLType,
                                              kDefault_GrSLPrecision,
                                              "data",
                                              &dataName);
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     const char *fragmentPos = fsBuilder->fragmentPosition();
 
     if (args.fInputColor) {
index 495c62f3a44a0923e569c7db5d206a564f83eaef..167489b68974ca4dd703d773d28b7f9b0d885217 100644 (file)
@@ -58,7 +58,8 @@ SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region,
 #include "SkGr.h"
 
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 class AlphaThresholdEffect : public GrFragmentProcessor {
@@ -138,16 +139,14 @@ private:
 };
 
 void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) {
-    fInnerThresholdVar = args.fBuilder->addUniform(
-        GrGLProgramBuilder::kFragment_Visibility,
-        kFloat_GrSLType, kDefault_GrSLPrecision,
-        "inner_threshold");
-    fOuterThresholdVar = args.fBuilder->addUniform(
-        GrGLProgramBuilder::kFragment_Visibility,
-        kFloat_GrSLType, kDefault_GrSLPrecision,
-        "outer_threshold");
-
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    fInnerThresholdVar = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                                   kFloat_GrSLType, kDefault_GrSLPrecision,
+                                                   "inner_threshold");
+    fOuterThresholdVar = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                                   kFloat_GrSLType, kDefault_GrSLPrecision,
+                                                   "outer_threshold");
+
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
     SkString maskCoords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 1);
 
@@ -205,7 +204,7 @@ const GrFragmentProcessor* AlphaThresholdEffect::TestCreate(GrProcessorTestData*
 ///////////////////////////////////////////////////////////////////////////////
 
 void AlphaThresholdEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                             GrProcessorKeyBuilder* b) const {
+                                               GrProcessorKeyBuilder* b) const {
     GrGLAlphaThresholdEffect::GenKey(*this, caps, b);
 }
 
index 7ceaffafc30566cb987cee2d26e2cc0e913fff9f..ebc8293b208db98b7a40edb927201b005defa4ff 100644 (file)
 #include "GrTexture.h"
 #include "gl/GrGLCaps.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "gl/GrGLXferProcessor.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 static const bool gUseUnpremul = false;
 
-static void add_arithmetic_code(GrGLFragmentBuilder* fsBuilder,
+static void add_arithmetic_code(GrGLSLFragmentBuilder* fsBuilder,
                                 const char* srcColor,
                                 const char* dstColor,
                                 const char* outputColor,
@@ -60,11 +62,11 @@ public:
     ~GLArithmeticFP() override {}
 
     void emitCode(EmitArgs& args) override {
-        GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+        GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
         SkString dstColor("dstColor");
         this->emitChild(0, nullptr, &dstColor, args);
 
-        fKUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fKUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                           kVec4f_GrSLType, kDefault_GrSLPrecision,
                                           "k");
         const char* kUni = args.fBuilder->getUniformCStr(fKUni);
@@ -208,9 +210,9 @@ public:
 private:
     void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb, const char* srcColor, const char* dstColor,
                                  const char* outColor, const GrXferProcessor& proc) override {
-        GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
+        GrGLSLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
 
-        fKUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fKUni = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                kVec4f_GrSLType, kDefault_GrSLPrecision,
                                "k");
         const char* kUni = pb->getUniformCStr(fKUni);
index 13c7d45a0e049338587c0686f7ca1a30c0a250a6..2ec5b90a409ba8a8338e35e6de63a38a2a3f2ac2 100644 (file)
@@ -28,7 +28,8 @@
 #include "SkDraw.h"
 #include "effects/GrSimpleTextureEffect.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #include "glsl/GrGLSLTextureSampler.h"
 #endif
@@ -696,7 +697,7 @@ private:
     typedef GrGLFragmentProcessor INHERITED;
 };
 
-void OutputRectBlurProfileLookup(GrGLFragmentBuilder* fsBuilder,
+void OutputRectBlurProfileLookup(GrGLSLFragmentBuilder* fsBuilder,
                                  const GrGLSLTextureSampler& sampler,
                                  const char *output,
                                  const char *profileSize, const char *loc,
@@ -725,18 +726,18 @@ void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
 
     const char* precisionString = GrGLSLShaderVar::PrecisionString(args.fBuilder->glslCaps(),
                                                                    fPrecision);
-    fProxyRectUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fProxyRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                             kVec4f_GrSLType,
                                             fPrecision,
                                             "proxyRect",
                                             &rectName);
-    fProfileSizeUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fProfileSizeUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                             kFloat_GrSLType,
                                             kDefault_GrSLPrecision,
                                             "profileSize",
                                             &profileSizeName);
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     const char *fragmentPos = fsBuilder->fragmentPosition();
 
     if (args.fInputColor) {
@@ -816,7 +817,7 @@ GrRectBlurEffect::GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *b
 }
 
 void GrRectBlurEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                         GrProcessorKeyBuilder* b) const {
+                                           GrProcessorKeyBuilder* b) const {
     GrGLRectBlurEffect::GenKey(fPrecision, b);
 }
 
@@ -1066,23 +1067,23 @@ void GrGLRRectBlurEffect::emitCode(EmitArgs& args) {
     // The proxy rect has left, top, right, and bottom edges correspond to
     // components x, y, z, and w, respectively.
 
-    fProxyRectUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                            kVec4f_GrSLType,
-                                            kDefault_GrSLPrecision,
-                                            "proxyRect",
-                                            &rectName);
-    fCornerRadiusUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                               kFloat_GrSLType,
-                                               kDefault_GrSLPrecision,
-                                               "cornerRadius",
-                                               &cornerRadiusName);
-    fBlurRadiusUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                             kFloat_GrSLType,
-                                              kDefault_GrSLPrecision,
-                                              "blurRadius",
-                                              &blurRadiusName);
-
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    fProxyRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                                  kVec4f_GrSLType,
+                                                  kDefault_GrSLPrecision,
+                                                  "proxyRect",
+                                                  &rectName);
+    fCornerRadiusUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                                     kFloat_GrSLType,
+                                                     kDefault_GrSLPrecision,
+                                                     "cornerRadius",
+                                                     &cornerRadiusName);
+    fBlurRadiusUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                                   kFloat_GrSLType,
+                                                   kDefault_GrSLPrecision,
+                                                   "blurRadius",
+                                                   &blurRadiusName);
+
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     const char* fragmentPos = fsBuilder->fragmentPosition();
 
     // warp the fragment position to the appropriate part of the 9patch blur texture
index 3010287ef713fb16edb1bd0f6323b935a02c219d..3abda5fe48b49527a3d8312350c745b25e127b14 100644 (file)
@@ -19,7 +19,8 @@
 #include "GrTexturePriv.h"
 #include "SkGr.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #endif
 
@@ -244,11 +245,11 @@ void GrColorCubeEffect::GLProcessor::emitCode(EmitArgs& args) {
         args.fInputColor = "vec4(1)";
     }
 
-    fColorCubeSizeUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fColorCubeSizeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                             kFloat_GrSLType, kDefault_GrSLPrecision,
                                             "Size");
     const char* colorCubeSizeUni = args.fBuilder->getUniformCStr(fColorCubeSizeUni);
-    fColorCubeInvSizeUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fColorCubeInvSizeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                                kFloat_GrSLType, kDefault_GrSLPrecision,
                                                "InvSize");
     const char* colorCubeInvSizeUni = args.fBuilder->getUniformCStr(fColorCubeInvSizeUni);
@@ -262,7 +263,7 @@ void GrColorCubeEffect::GLProcessor::emitCode(EmitArgs& args) {
     // Note: if implemented using texture3D in OpenGL ES older than OpenGL ES 3.0,
     //       the shader might need "#extension GL_OES_texture_3D : enable".
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
 
     // Unpremultiply color
     fsBuilder->codeAppendf("\tfloat %s = max(%s.a, 0.00001);\n", nonZeroAlpha, args.fInputColor);
index ef8fb116d69888fa9ccadcc4beb50b3b6db79944..fd3200e2cd191b8e1edc3bf44dc47435a115f524 100644 (file)
@@ -386,7 +386,8 @@ SkColorFilter* SkColorMatrixFilter::newComposed(const SkColorFilter* innerFilter
 #include "GrFragmentProcessor.h"
 #include "GrInvariantOutput.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 class ColorMatrixEffect : public GrFragmentProcessor {
@@ -407,10 +408,10 @@ public:
         GLProcessor(const GrProcessor&) {}
 
         virtual void emitCode(EmitArgs& args) override {
-            fMatrixHandle = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+            fMatrixHandle = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                                 kMat44f_GrSLType, kDefault_GrSLPrecision,
                                                 "ColorMatrix");
-            fVectorHandle = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+            fVectorHandle = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                                 kVec4f_GrSLType, kDefault_GrSLPrecision,
                                                 "ColorMatrixVector");
 
@@ -418,7 +419,7 @@ public:
                 // could optimize this case, but we aren't for now.
                 args.fInputColor = "vec4(1)";
             }
-            GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+            GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
             // The max() is to guard against 0 / 0 during unpremul when the incoming color is
             // transparent black.
             fsBuilder->codeAppendf("\tfloat nonZeroAlpha = max(%s.a, 0.00001);\n",
index 776083c079a7634b6631d9c0a7eac5c939cae4a1..b9411b2e12c7652162ce9c19981b9c3c14c3b321 100644 (file)
@@ -18,7 +18,8 @@
 #include "GrInvariantOutput.h"
 #include "effects/GrTextureDomain.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #endif
 
@@ -547,8 +548,8 @@ GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() {
 void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
     const GrTextureDomain& domain = args.fFp.cast<GrDisplacementMapEffect>().domain();
 
-    fScaleUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                    kVec2f_GrSLType, kDefault_GrSLPrecision, "Scale");
+    fScaleUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                          kVec2f_GrSLType, kDefault_GrSLPrecision, "Scale");
     const char* scaleUni = args.fBuilder->getUniformCStr(fScaleUni);
     const char* dColor = "dColor";
     const char* cCoords = "cCoords";
@@ -556,7 +557,7 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
                                    // a number smaller than that to approximate 0, but
                                    // leave room for 32-bit float GPU rounding errors.
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     fsBuilder->codeAppendf("\t\tvec4 %s = ", dColor);
     fsBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_str(),
                                    args.fCoords[0].getType());
index 6121c3c6f18ce5a48eae486cf44093c459bac411..1f120c04666ee788abcb7aca1f5a710bf1d2cab2 100644 (file)
@@ -22,7 +22,8 @@
 #include "GrPaint.h"
 #include "effects/GrSingleTextureEffect.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 class GrGLDiffuseLightingEffect;
@@ -1614,7 +1615,7 @@ bool GrDiffuseLightingEffect::onIsEqual(const GrFragmentProcessor& sBase) const
 }
 
 void GrDiffuseLightingEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                                GrProcessorKeyBuilder* b) const {
+                                                  GrProcessorKeyBuilder* b) const {
     GrGLDiffuseLightingEffect::GenKey(*this, caps, b);
 }
 
@@ -1651,10 +1652,10 @@ GrGLLightingEffect::~GrGLLightingEffect() {
 }
 
 void GrGLLightingEffect::emitCode(EmitArgs& args) {
-    fImageIncrementUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fImageIncrementUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                               kVec2f_GrSLType, kDefault_GrSLPrecision,
                                              "ImageIncrement");
-    fSurfaceScaleUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fSurfaceScaleUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                            kFloat_GrSLType, kDefault_GrSLPrecision,
                                            "SurfaceScale");
     fLight->emitLightColorUniform(args.fBuilder);
@@ -1670,7 +1671,7 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
         GrGLSLShaderVar("scale", kFloat_GrSLType),
     };
     SkString sobelFuncName;
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
 
     fsBuilder->emitFunction(kFloat_GrSLType,
@@ -1765,7 +1766,7 @@ GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrProcessor& proc)
 
 void GrGLDiffuseLightingEffect::emitLightFunc(GrGLSLFPBuilder* builder, SkString* funcName) {
     const char* kd;
-    fKDUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fKDUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                  kFloat_GrSLType, kDefault_GrSLPrecision,
                                  "KD", &kd);
 
@@ -1815,7 +1816,7 @@ bool GrSpecularLightingEffect::onIsEqual(const GrFragmentProcessor& sBase) const
 }
 
 void GrSpecularLightingEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                                GrProcessorKeyBuilder* b) const {
+                                                   GrProcessorKeyBuilder* b) const {
     GrGLSpecularLightingEffect::GenKey(*this, caps, b);
 }
 
@@ -1849,9 +1850,9 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLSLFPBuilder* builder, SkStrin
     const char* ks;
     const char* shininess;
 
-    fKSUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fKSUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                  kFloat_GrSLType, kDefault_GrSLPrecision, "KS", &ks);
-    fShininessUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fShininessUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                         kFloat_GrSLType,
                                         kDefault_GrSLPrecision,
                                         "Shininess",
@@ -1885,7 +1886,7 @@ void GrGLSpecularLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman
 
 ///////////////////////////////////////////////////////////////////////////////
 void GrGLLight::emitLightColorUniform(GrGLSLFPBuilder* builder) {
-    fColorUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fColorUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                     kVec3f_GrSLType, kDefault_GrSLPrecision,
                                     "LightColor");
 }
@@ -1912,7 +1913,7 @@ void GrGLDistantLight::setData(const GrGLSLProgramDataManager& pdman,
 
 void GrGLDistantLight::emitSurfaceToLight(GrGLSLFPBuilder* builder, const char* z) {
     const char* dir;
-    fDirectionUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fDirectionUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                         kVec3f_GrSLType, kDefault_GrSLPrecision,
                                         "LightDirection", &dir);
     builder->getFragmentShaderBuilder()->codeAppend(dir);
@@ -1930,10 +1931,10 @@ void GrGLPointLight::setData(const GrGLSLProgramDataManager& pdman,
 
 void GrGLPointLight::emitSurfaceToLight(GrGLSLFPBuilder* builder, const char* z) {
     const char* loc;
-    fLocationUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fLocationUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                        kVec3f_GrSLType, kDefault_GrSLPrecision,
                                        "LightLocation", &loc);
-    GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
     fsBuilder->codeAppendf("normalize(%s - vec3(%s.xy, %s))",
             loc, fsBuilder->fragmentPosition(), z);
 }
@@ -1955,11 +1956,11 @@ void GrGLSpotLight::setData(const GrGLSLProgramDataManager& pdman,
 
 void GrGLSpotLight::emitSurfaceToLight(GrGLSLFPBuilder* builder, const char* z) {
     const char* location;
-    fLocationUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fLocationUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                        kVec3f_GrSLType, kDefault_GrSLPrecision,
                                        "LightLocation", &location);
 
-    GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
     fsBuilder->codeAppendf("normalize(%s - vec3(%s.xy, %s))",
             location, fsBuilder->fragmentPosition(), z);
 }
@@ -1974,19 +1975,19 @@ void GrGLSpotLight::emitLightColor(GrGLSLFPBuilder* builder,
     const char* cosOuter;
     const char* coneScale;
     const char* s;
-    fExponentUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fExponentUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                        kFloat_GrSLType, kDefault_GrSLPrecision,
                                        "Exponent", &exponent);
-    fCosInnerConeAngleUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fCosInnerConeAngleUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                                 kFloat_GrSLType, kDefault_GrSLPrecision,
                                                 "CosInnerConeAngle", &cosInner);
-    fCosOuterConeAngleUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fCosOuterConeAngleUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                                 kFloat_GrSLType, kDefault_GrSLPrecision,
                                                 "CosOuterConeAngle", &cosOuter);
-    fConeScaleUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fConeScaleUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                         kFloat_GrSLType, kDefault_GrSLPrecision,
                                         "ConeScale", &coneScale);
-    fSUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fSUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                 kVec3f_GrSLType, kDefault_GrSLPrecision, "S", &s);
 
     static const GrGLSLShaderVar gLightColorArgs[] = {
@@ -2003,7 +2004,7 @@ void GrGLSpotLight::emitLightColor(GrGLSLFPBuilder* builder,
                            color, cosOuter, coneScale);
     lightColorBody.appendf("\t}\n");
     lightColorBody.appendf("\treturn %s;\n", color);
-    GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
     fsBuilder->emitFunction(kVec3f_GrSLType,
                             "lightColor",
                             SK_ARRAY_COUNT(gLightColorArgs),
index 03db0bb78bef50dc78affad1a7046ac69f8247f8..bdedf3b8b7059c020409d9beeadf2d0217461dbb 100644 (file)
@@ -14,7 +14,8 @@
 #include "GrContext.h"
 #include "GrInvariantOutput.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #endif
 
 void SkLumaColorFilter::filterSpan(const SkPMColor src[], int count,
@@ -71,7 +72,7 @@ public:
                 args.fInputColor = "vec4(1)";
             }
 
-            GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+            GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
             fsBuilder->codeAppendf("\tfloat luma = dot(vec3(%f, %f, %f), %s.rgb);\n",
                                    SK_ITU_BT709_LUM_COEFF_R,
                                    SK_ITU_BT709_LUM_COEFF_G,
index c7d3d5ae2d1a48ceefa471ca09fb22498ea54ca6..2d90c4478139d27dbc0192633c7a5c3d33f6f764 100644 (file)
@@ -19,7 +19,8 @@
 #include "effects/GrSingleTextureEffect.h"
 #include "gl/GrGLFragmentProcessor.h"
 #include "gl/GrGLTexture.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 class GrMagnifierEffect : public GrSingleTextureEffect {
@@ -121,23 +122,19 @@ GrGLMagnifierEffect::GrGLMagnifierEffect(const GrProcessor&) {
 
 void GrGLMagnifierEffect::emitCode(EmitArgs& args) {
     fOffsetVar = args.fBuilder->addUniform(
-        GrGLProgramBuilder::kFragment_Visibility |
-        GrGLProgramBuilder::kVertex_Visibility,
+        GrGLSLProgramBuilder::kFragment_Visibility,
         kVec2f_GrSLType, kDefault_GrSLPrecision, "Offset");
     fInvZoomVar = args.fBuilder->addUniform(
-        GrGLProgramBuilder::kFragment_Visibility |
-        GrGLProgramBuilder::kVertex_Visibility,
+        GrGLSLProgramBuilder::kFragment_Visibility,
         kVec2f_GrSLType, kDefault_GrSLPrecision, "InvZoom");
     fInvInsetVar = args.fBuilder->addUniform(
-        GrGLProgramBuilder::kFragment_Visibility |
-        GrGLProgramBuilder::kVertex_Visibility,
+        GrGLSLProgramBuilder::kFragment_Visibility,
         kVec2f_GrSLType, kDefault_GrSLPrecision, "InvInset");
     fBoundsVar = args.fBuilder->addUniform(
-        GrGLProgramBuilder::kFragment_Visibility |
-        GrGLProgramBuilder::kVertex_Visibility,
+        GrGLSLProgramBuilder::kFragment_Visibility,
         kVec4f_GrSLType, kDefault_GrSLPrecision, "Bounds");
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
     fsBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
     fsBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n",
index 94210872c3a06781a6c64329058a17f671c98cbd..1d465edcb5246d9a144bcce9b57cfdfe326128a3 100644 (file)
@@ -20,7 +20,8 @@
 #include "GrTexture.h"
 #include "effects/Gr1DKernelEffect.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #endif
 
@@ -287,16 +288,16 @@ GrGLMorphologyEffect::GrGLMorphologyEffect(const GrProcessor& proc) {
 }
 
 void GrGLMorphologyEffect::emitCode(EmitArgs& args) {
-    fPixelSizeUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fPixelSizeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                             kFloat_GrSLType, kDefault_GrSLPrecision,
                                             "PixelSize");
     const char* pixelSizeInc = args.fBuilder->getUniformCStr(fPixelSizeUni);
-    fRangeUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fRangeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                             kVec2f_GrSLType, kDefault_GrSLPrecision,
                                             "Range");
     const char* range = args.fBuilder->getUniformCStr(fRangeUni);
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
     const char* func;
     switch (fType) {
index 0c455693c3a3f3b5a8385544de2c06f5171667fc..045f3beff2845ec55fa9fd0c47d4d1fc590d9cac 100644 (file)
@@ -21,7 +21,8 @@
 #include "SkGr.h"
 #include "effects/GrConstColorProcessor.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #endif
 
@@ -620,17 +621,17 @@ GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor)
 }
 
 void GrGLPerlinNoise::emitCode(EmitArgs& args) {
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString vCoords = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
 
-    fBaseFrequencyUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fBaseFrequencyUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                             kVec2f_GrSLType, kDefault_GrSLPrecision,
                                             "baseFrequency");
     const char* baseFrequencyUni = args.fBuilder->getUniformCStr(fBaseFrequencyUni);
 
     const char* stitchDataUni = nullptr;
     if (fStitchTiles) {
-        fStitchDataUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fStitchDataUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                              kVec2f_GrSLType, kDefault_GrSLPrecision,
                                              "stitchData");
         stitchDataUni = args.fBuilder->getUniformCStr(fStitchDataUni);
index 7b997001e442fb986e8e4e4ef8e6b6fce16e0e41..872fdfddc231891325ee7990f76bbb942bf3946e 100644 (file)
@@ -336,7 +336,8 @@ SkColorFilter* SkTable_ColorFilter::newComposed(const SkColorFilter* innerFilter
 #include "SkGr.h"
 #include "effects/GrTextureStripAtlas.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 class ColorTableEffect : public GrFragmentProcessor {
@@ -419,7 +420,7 @@ void GLColorTableEffect::emitCode(EmitArgs& args) {
                                                 "yoffsets", &yoffsets);
     static const float kColorScaleFactor = 255.0f / 256.0f;
     static const float kColorOffsetFactor = 1.0f / 512.0f;
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     if (nullptr == args.fInputColor) {
         // the input color is solid white (all ones).
         static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor;
@@ -501,7 +502,7 @@ ColorTableEffect::~ColorTableEffect() {
 }
 
 void ColorTableEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                         GrProcessorKeyBuilder* b) const {
+                                           GrProcessorKeyBuilder* b) const {
     GLColorTableEffect::GenKey(*this, caps, b);
 }
 
index 9909f310ababbe7aca43e86d27679b3f2870577e..f11d0787b9916198cfd7841972dff27c17fcaa6d 100644 (file)
@@ -909,7 +909,8 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
 #include "effects/GrTextureStripAtlas.h"
 #include "GrInvariantOutput.h"
 #include "gl/GrGLContext.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #include "SkGr.h"
 
@@ -922,26 +923,26 @@ GrGLGradientEffect::~GrGLGradientEffect() { }
 void GrGLGradientEffect::emitUniforms(GrGLSLFPBuilder* builder, const GrGradientEffect& ge) {
 
     if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()) { // 2 Color case
-        fColorStartUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fColorStartUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                              kVec4f_GrSLType, kDefault_GrSLPrecision,
                                             "GradientStartColor");
-        fColorEndUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fColorEndUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                            kVec4f_GrSLType, kDefault_GrSLPrecision,
                                            "GradientEndColor");
 
     } else if (SkGradientShaderBase::kThree_GpuColorType == ge.getColorType()) { // 3 Color Case
-        fColorStartUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fColorStartUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                              kVec4f_GrSLType,  kDefault_GrSLPrecision,
                                              "GradientStartColor");
-        fColorMidUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fColorMidUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                            kVec4f_GrSLType, kDefault_GrSLPrecision,
                                            "GradientMidColor");
-        fColorEndUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fColorEndUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                            kVec4f_GrSLType, kDefault_GrSLPrecision,
                                            "GradientEndColor");
 
     } else { // if not a fast case
-        fFSYUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fFSYUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                       kFloat_GrSLType, kDefault_GrSLPrecision,
                                       "GradientYCoordFS");
     }
@@ -1031,7 +1032,7 @@ void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder,
                                    const char* outputColor,
                                    const char* inputColor,
                                    const TextureSamplerArray& samplers) {
-    GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
     if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()){
         fsBuilder->codeAppendf("\tvec4 colorTemp = mix(%s, %s, clamp(%s, 0.0, 1.0));\n",
                                builder->getUniformVariable(fColorStartUni).c_str(),
index b5716b1de00331355e066e9859450ea5620ef4c7..dec3e96bdb704d21cd89e930ff68078153a48397 100644 (file)
@@ -12,7 +12,8 @@
 
 #if SK_SUPPORT_GPU
 #include "GrPaint.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 // For brevity
 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
@@ -169,7 +170,7 @@ private:
 };
 
 void Edge2PtConicalEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                             GrProcessorKeyBuilder* b) const {
+                                               GrProcessorKeyBuilder* b) const {
     GLEdge2PtConicalEffect::GenKey(*this, caps, b);
 }
 
@@ -223,7 +224,7 @@ GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&)
 void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
     const Edge2PtConicalEffect& ge = args.fFp.cast<Edge2PtConicalEffect>();
     this->emitUniforms(args.fBuilder, ge);
-    fParamUni = args.fBuilder->addUniformArray(GrGLProgramBuilder::kFragment_Visibility,
+    fParamUni = args.fBuilder->addUniformArray(GrGLSLProgramBuilder::kFragment_Visibility,
                                          kFloat_GrSLType, kDefault_GrSLPrecision,
                                          "Conical2FSParams", 3);
 
@@ -241,7 +242,7 @@ void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
     SkASSERT(args.fCoords[0].getType() == args.fCoords[1].getType());
     const char* coords2D;
     SkString bVar;
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     if (kVec3f_GrSLType == args.fCoords[0].getType()) {
         fsBuilder->codeAppendf("\tvec3 interpolants = vec3(%s.xy / %s.z, %s.x / %s.z);\n",
                                args.fCoords[0].c_str(), args.fCoords[0].c_str(),
@@ -446,7 +447,7 @@ private:
 };
 
 void FocalOutside2PtConicalEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                                     GrProcessorKeyBuilder* b) const {
+                                                       GrProcessorKeyBuilder* b) const {
     GLFocalOutside2PtConicalEffect::GenKey(*this, caps, b);
 }
 
@@ -499,7 +500,7 @@ GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor
 void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) {
     const FocalOutside2PtConicalEffect& ge = args.fFp.cast<FocalOutside2PtConicalEffect>();
     this->emitUniforms(args.fBuilder, ge);
-    fParamUni = args.fBuilder->addUniformArray(GrGLProgramBuilder::kFragment_Visibility,
+    fParamUni = args.fBuilder->addUniformArray(GrGLSLProgramBuilder::kFragment_Visibility,
                                          kFloat_GrSLType, kDefault_GrSLPrecision,
                                          "Conical2FSParams", 2);
     SkString tName("t");
@@ -510,7 +511,7 @@ void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) {
     args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
 
     // if we have a vec3 from being in perspective, convert it to a vec2 first
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString coords2DString = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
     const char* coords2D = coords2DString.c_str();
 
@@ -650,7 +651,7 @@ private:
 };
 
 void FocalInside2PtConicalEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                               GrProcessorKeyBuilder* b) const {
+                                                      GrProcessorKeyBuilder* b) const {
     GLFocalInside2PtConicalEffect::GenKey(*this, caps, b);
 }
 
@@ -702,9 +703,9 @@ GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&)
 void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
     const FocalInside2PtConicalEffect& ge = args.fFp.cast<FocalInside2PtConicalEffect>();
     this->emitUniforms(args.fBuilder, ge);
-    fFocalUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                    kFloat_GrSLType, kDefault_GrSLPrecision,
-                                    "Conical2FSParams");
+    fFocalUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                          kFloat_GrSLType, kDefault_GrSLPrecision,
+                                          "Conical2FSParams");
     SkString tName("t");
 
     // this is the distance along x-axis from the end center to focal point in
@@ -712,7 +713,7 @@ void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
     GrGLSLShaderVar focal = args.fBuilder->getUniformVariable(fFocalUni);
 
     // if we have a vec3 from being in perspective, convert it to a vec2 first
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString coords2DString = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
     const char* coords2D = coords2DString.c_str();
 
@@ -892,7 +893,7 @@ private:
 };
 
 void CircleInside2PtConicalEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                                     GrProcessorKeyBuilder* b) const {
+                                                       GrProcessorKeyBuilder* b) const {
     GLCircleInside2PtConicalEffect::GenKey(*this, caps, b);
 }
 
@@ -947,12 +948,12 @@ GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor
 void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) {
     const CircleInside2PtConicalEffect& ge = args.fFp.cast<CircleInside2PtConicalEffect>();
     this->emitUniforms(args.fBuilder, ge);
-    fCenterUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                     kVec2f_GrSLType, kDefault_GrSLPrecision,
-                                     "Conical2FSCenter");
-    fParamUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                    kVec3f_GrSLType, kDefault_GrSLPrecision,
-                                    "Conical2FSParams");
+    fCenterUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                           kVec2f_GrSLType, kDefault_GrSLPrecision,
+                                           "Conical2FSCenter");
+    fParamUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                          kVec3f_GrSLType, kDefault_GrSLPrecision,
+                                          "Conical2FSParams");
     SkString tName("t");
 
     GrGLSLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni);
@@ -962,7 +963,7 @@ void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) {
     GrGLSLShaderVar params = args.fBuilder->getUniformVariable(fParamUni);
 
     // if we have a vec3 from being in perspective, convert it to a vec2 first
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString coords2DString = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
     const char* coords2D = coords2DString.c_str();
 
@@ -1117,7 +1118,7 @@ private:
 };
 
 void CircleOutside2PtConicalEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                                      GrProcessorKeyBuilder* b) const {
+                                                        GrProcessorKeyBuilder* b) const {
     GLCircleOutside2PtConicalEffect::GenKey(*this, caps, b);
 }
 
@@ -1177,12 +1178,12 @@ GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess
 void GLCircleOutside2PtConicalEffect::emitCode(EmitArgs& args) {
     const CircleOutside2PtConicalEffect& ge = args.fFp.cast<CircleOutside2PtConicalEffect>();
     this->emitUniforms(args.fBuilder, ge);
-    fCenterUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                     kVec2f_GrSLType, kDefault_GrSLPrecision,
-                                     "Conical2FSCenter");
-    fParamUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                    kVec4f_GrSLType, kDefault_GrSLPrecision,
-                                    "Conical2FSParams");
+    fCenterUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                           kVec2f_GrSLType, kDefault_GrSLPrecision,
+                                           "Conical2FSCenter");
+    fParamUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                          kVec4f_GrSLType, kDefault_GrSLPrecision,
+                                          "Conical2FSParams");
     SkString tName("t");
 
     GrGLSLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni);
@@ -1192,7 +1193,7 @@ void GLCircleOutside2PtConicalEffect::emitCode(EmitArgs& args) {
     GrGLSLShaderVar params = args.fBuilder->getUniformVariable(fParamUni);
 
     // if we have a vec3 from being in perspective, convert it to a vec2 first
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString coords2DString = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
     const char* coords2D = coords2DString.c_str();
 
index b1cedd2c2d15f52db39e5a02053ad019e6f9ce64..6c73c361ca7c7d21cebe3c52c88591d5d7fb1aa2 100644 (file)
@@ -10,7 +10,9 @@
 #include "GrInvariantOutput.h"
 #include "gl/GrGLGeometryProcessor.h"
 #include "gl/GrGLUtil.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
+#include "glsl/GrGLSLVertexShaderBuilder.h"
 
 /*
  * The default Geometry Processor simply takes position and multiplies it by the uniform view
@@ -62,8 +64,8 @@ public:
         void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
             const DefaultGeoProc& gp = args.fGP.cast<DefaultGeoProc>();
             GrGLSLGPBuilder* pb = args.fPB;
-            GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
-            GrGLFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder();
+            GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
+            GrGLSLFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder();
 
             // emit attributes
             vsBuilder->emitAttributes(gp);
@@ -105,7 +107,7 @@ public:
                     fs->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
                 } else {
                     const char* fragCoverage;
-                    fCoverageUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+                    fCoverageUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                                       kFloat_GrSLType,
                                                       kDefault_GrSLPrecision,
                                                       "Coverage",
index ec5aaac3ee6918a414bd27086ea2c8f565a24219..9b5677ae8fe4d5b701585ed857963b996f3ca00e 100644 (file)
@@ -9,7 +9,8 @@
 #include "GrFragmentProcessor.h"
 #include "GrCoordTransform.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #include "effects/GrConstColorProcessor.h"
 #include "effects/GrXfermodeFragmentProcessor.h"
@@ -152,7 +153,7 @@ const GrFragmentProcessor* GrFragmentProcessor::MulOutputByInputUnpremulColor(
                 GLFP() {}
 
                 void emitCode(EmitArgs& args) override {
-                    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+                    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
                     this->emitChild(0, nullptr, args);
                     fsBuilder->codeAppendf("%s.rgb *= %s.rgb;", args.fOutputColor,
                                                                 args.fInputColor);
@@ -225,7 +226,7 @@ const GrFragmentProcessor* GrFragmentProcessor::OverrideInput(const GrFragmentPr
                 GLFP() : fHaveSetColor(false) {}
                 void emitCode(EmitArgs& args) override {
                     const char* colorName;
-                    fColorUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+                    fColorUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                                           kVec4f_GrSLType, kDefault_GrSLPrecision,
                                                           "Color", &colorName);
                     this->emitChild(0, colorName, args);
index 4f51c03a4e75df73cc2c9f5cbbefcba886c34faf..c5d807c8e8081d89932cfff9bf689935f9c6b64d 100644 (file)
 #include "effects/GrRRectEffect.h"
 #include "gl/GrGLUtil.h"
 #include "gl/GrGLGeometryProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLVertexShaderBuilder.h"
 
 // TODO(joshualitt) - Break this file up during GrBatch post implementation cleanup
 
@@ -96,7 +98,7 @@ public:
         void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
             const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>();
             GrGLSLGPBuilder* pb = args.fPB;
-            GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+            GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
 
             // emit attributes
             vsBuilder->emitAttributes(ce);
@@ -117,7 +119,7 @@ public:
             this->emitTransforms(args.fPB, gpArgs->fPositionVar, ce.inPosition()->fName,
                                  ce.localMatrix(), args.fTransformsIn, args.fTransformsOut);
 
-            GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+            GrGLSLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
             fsBuilder->codeAppendf("float d = length(%s.xy);", v.fsIn());
             fsBuilder->codeAppendf("float edgeAlpha = clamp(%s.z * (1.0 - d), 0.0, 1.0);", v.fsIn());
             if (ce.isStroked()) {
@@ -244,7 +246,7 @@ public:
         void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
             const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>();
             GrGLSLGPBuilder* pb = args.fPB;
-            GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+            GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
 
             // emit attributes
             vsBuilder->emitAttributes(ee);
@@ -272,7 +274,7 @@ public:
                                  ee.localMatrix(), args.fTransformsIn, args.fTransformsOut);
 
             // for outer curve
-            GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+            GrGLSLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
             fsBuilder->codeAppendf("vec2 scaledOffset = %s*%s.xy;", ellipseOffsets.fsIn(),
                                    ellipseRadii.fsIn());
             fsBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;");
@@ -419,7 +421,7 @@ public:
         void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
             const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>();
             GrGLSLGPBuilder* pb = args.fPB;
-            GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+            GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
 
             // emit attributes
             vsBuilder->emitAttributes(ee);
@@ -447,9 +449,9 @@ public:
             this->emitTransforms(args.fPB, gpArgs->fPositionVar, ee.inPosition()->fName,
                                  args.fTransformsIn, args.fTransformsOut);
 
-            GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+            GrGLSLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
             SkAssertResult(fsBuilder->enableFeature(
-                    GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+                    GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
             // for outer curve
             fsBuilder->codeAppendf("vec2 scaledOffset = %s.xy;", offsets0.fsIn());
             fsBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;");
index 6a78568078371a2b20c277c691cd2f105595f810..b83172d46ed527a89cf52c36d28a9d5fbebcb2bb 100644 (file)
@@ -9,7 +9,9 @@
 
 #include "gl/GrGLGpu.h"
 #include "glsl/GrGLSLCaps.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
 #include "glsl/GrGLSLProcessorTypes.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 
 class GrGLPathProcessor : public GrGLPrimitiveProcessor {
 public:
@@ -24,7 +26,7 @@ public:
 
     void emitCode(EmitArgs& args) override {
         GrGLSLGPBuilder* pb = args.fPB;
-        GrGLFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder();
+        GrGLSLFragmentBuilder* fs = args.fPB->getFragmentShaderBuilder();
         const GrPathProcessor& pathProc = args.fGP.cast<GrPathProcessor>();
 
         // emit transforms
@@ -33,7 +35,7 @@ public:
         // Setup uniform color
         if (pathProc.opts().readsColor()) {
             const char* stagedLocalVarName;
-            fColorUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+            fColorUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                            kVec4f_GrSLType,
                                            kDefault_GrSLPrecision,
                                            "Color",
index d30053b21c74f86d1ec2a4ec9b677cf1ad894be2..f0f475e31a6183cb9e557a241bcc9be07d4f97ee 100644 (file)
@@ -26,7 +26,7 @@
 #include "SkTraceEvent.h"
 #include "batches/GrVertexBatch.h"
 #include "gl/GrGLGeometryProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 GrAAConvexPathRenderer::GrAAConvexPathRenderer() {
@@ -549,7 +549,7 @@ public:
         void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
             const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>();
             GrGLSLGPBuilder* pb = args.fPB;
-            GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
+            GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
 
             // emit attributes
             vsBuilder->emitAttributes(qe);
@@ -570,10 +570,10 @@ public:
             this->emitTransforms(args.fPB, gpArgs->fPositionVar, qe.inPosition()->fName,
                                  qe.localMatrix(), args.fTransformsIn, args.fTransformsOut);
 
-            GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+            GrGLSLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
 
             SkAssertResult(fsBuilder->enableFeature(
-                    GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+                    GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
             fsBuilder->codeAppendf("float edgeAlpha;");
 
             // keep the derivative instructions outside the conditional
index 1cf5e18faba18da908f52da20109a336c85d821d..febf18fbd2919b201b547b66fa6d5dc5c3d692d7 100644 (file)
@@ -10,7 +10,7 @@
 #include "gl/GrGLFragmentProcessor.h"
 #include "gl/GrGLGeometryProcessor.h"
 #include "gl/GrGLUtil.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 class GrGLConicEffect : public GrGLGeometryProcessor {
@@ -74,7 +74,7 @@ GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor)
 
 void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
     GrGLSLGPBuilder* pb = args.fPB;
-    GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+    GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
     const GrConicEffect& gp = args.fGP.cast<GrConicEffect>();
 
     // emit attributes
@@ -96,13 +96,13 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
     this->emitTransforms(pb, gpArgs->fPositionVar, gp.inPosition()->fName, gp.localMatrix(),
                          args.fTransformsIn, args.fTransformsOut);
 
-    GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
     fsBuilder->codeAppend("float edgeAlpha;");
 
     switch (fEdgeType) {
         case kHairlineAA_GrProcessorEdgeType: {
             SkAssertResult(fsBuilder->enableFeature(
-                    GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+                    GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
             fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", v.fsIn());
             fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", v.fsIn());
             fsBuilder->codeAppendf("float dfdx ="
@@ -124,7 +124,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
         }
         case kFillAA_GrProcessorEdgeType: {
             SkAssertResult(fsBuilder->enableFeature(
-                    GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+                    GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
             fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", v.fsIn());
             fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", v.fsIn());
             fsBuilder->codeAppendf("float dfdx ="
@@ -156,7 +156,7 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
     // TODO should we really be doing this?
     if (gp.coverageScale() != 0xff) {
         const char* coverageScale;
-        fCoverageScaleUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fCoverageScaleUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                                kFloat_GrSLType,
                                                kDefault_GrSLPrecision,
                                                "Coverage",
@@ -290,7 +290,7 @@ GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor)
 
 void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
     GrGLSLGPBuilder* pb = args.fPB;
-    GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+    GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
     const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>();
 
     // emit attributes
@@ -312,13 +312,13 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
     this->emitTransforms(pb, gpArgs->fPositionVar, gp.inPosition()->fName, gp.localMatrix(),
                          args.fTransformsIn, args.fTransformsOut);
 
-    GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
     fsBuilder->codeAppendf("float edgeAlpha;");
 
     switch (fEdgeType) {
         case kHairlineAA_GrProcessorEdgeType: {
             SkAssertResult(fsBuilder->enableFeature(
-                    GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+                    GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
             fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn());
             fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn());
             fsBuilder->codeAppendf("vec2 gF = vec2(2.0 * %s.x * duvdx.x - duvdx.y,"
@@ -333,7 +333,7 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
         }
         case kFillAA_GrProcessorEdgeType: {
             SkAssertResult(fsBuilder->enableFeature(
-                    GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+                    GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
             fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn());
             fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn());
             fsBuilder->codeAppendf("vec2 gF = vec2(2.0 * %s.x * duvdx.x - duvdx.y,"
@@ -357,7 +357,7 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
 
     if (0xff != gp.coverageScale()) {
         const char* coverageScale;
-        fCoverageScaleUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fCoverageScaleUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                           kFloat_GrSLType,
                                           kDefault_GrSLPrecision,
                                           "Coverage",
@@ -477,7 +477,7 @@ GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor)
 }
 
 void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
-    GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+    GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
     const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>();
 
     // emit attributes
@@ -500,7 +500,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
     this->emitTransforms(args.fPB, gpArgs->fPositionVar, gp.inPosition()->fName, args.fTransformsIn,
                          args.fTransformsOut);
 
-    GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
 
     GrGLSLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
     GrGLSLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
@@ -523,7 +523,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
     switch (fEdgeType) {
         case kHairlineAA_GrProcessorEdgeType: {
             SkAssertResult(fsBuilder->enableFeature(
-                    GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+                    GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
             fsBuilder->codeAppendf("%s = dFdx(%s.xyz);", dklmdx.c_str(), v.fsIn());
             fsBuilder->codeAppendf("%s = dFdy(%s.xyz);", dklmdy.c_str(), v.fsIn());
             fsBuilder->codeAppendf("%s = 3.0 * %s.x * %s.x * %s.x - %s.y * %s.z - %s.z * %s.y;",
@@ -549,7 +549,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
         }
         case kFillAA_GrProcessorEdgeType: {
             SkAssertResult(fsBuilder->enableFeature(
-                    GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+                    GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
             fsBuilder->codeAppendf("%s = dFdx(%s.xyz);", dklmdx.c_str(), v.fsIn());
             fsBuilder->codeAppendf("%s = dFdy(%s.xyz);", dklmdy.c_str(), v.fsIn());
             fsBuilder->codeAppendf("%s ="
index a6ed1909d7cab8609e1cae752290ec71aebe1015..2857641edcfb708be45ccfdfcaad05277ca5db56 100644 (file)
@@ -7,7 +7,8 @@
 
 #include "GrBicubicEffect.h"
 #include "GrInvariantOutput.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 #define DS(x) SkDoubleToScalar(x)
@@ -51,10 +52,10 @@ GrGLBicubicEffect::GrGLBicubicEffect(const GrProcessor&) {
 void GrGLBicubicEffect::emitCode(EmitArgs& args) {
     const GrTextureDomain& domain = args.fFp.cast<GrBicubicEffect>().domain();
 
-    fCoefficientsUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fCoefficientsUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                            kMat44f_GrSLType, kDefault_GrSLPrecision,
                                            "Coefficients");
-    fImageIncrementUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fImageIncrementUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                              kVec2f_GrSLType, kDefault_GrSLPrecision,
                                              "ImageIncrement");
 
@@ -71,7 +72,7 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
         GrGLSLShaderVar("c2",            kVec4f_GrSLType),
         GrGLSLShaderVar("c3",            kVec4f_GrSLType),
     };
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
     fsBuilder->emitFunction(kVec4f_GrSLType,
                             "cubicBlend",
index c1a9dae60a8f7f4e641a155712fee9cd574c501b..21dd5e72652f6d2522e871a89ec393886077844f 100644 (file)
 #include "gl/GrGLFragmentProcessor.h"
 #include "gl/GrGLTexture.h"
 #include "gl/GrGLGeometryProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLVertexShaderBuilder.h"
 
 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor {
 public:
@@ -22,7 +24,7 @@ public:
         const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
 
         GrGLSLGPBuilder* pb = args.fPB;
-        GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
+        GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
 
         // emit attributes
         vsBuilder->emitAttributes(cte);
@@ -57,7 +59,7 @@ public:
         this->emitTransforms(args.fPB, gpArgs->fPositionVar, cte.inPosition()->fName,
                              cte.localMatrix(), args.fTransformsIn, args.fTransformsOut);
 
-        GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
+        GrGLSLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
         if (cte.maskFormat() == kARGB_GrMaskFormat) {
             fsBuilder->codeAppendf("%s = ", args.fOutputColor);
             fsBuilder->appendTextureLookupAndModulate(args.fOutputColor,
index 5f51f6a2c7b01a2f4c32a45ca5cf77ee690b98a5..160773d81ecdd05844fc1bf137ed59f978d61721 100644 (file)
@@ -12,7 +12,8 @@
 #include "GrSimpleTextureEffect.h"
 #include "SkMatrix.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 
 class GrGLConfigConversionEffect : public GrGLFragmentProcessor {
 public:
@@ -29,7 +30,7 @@ public:
         SkString tmpDecl;
         tmpVar.appendDecl(args.fBuilder->glslCaps(), &tmpDecl);
 
-        GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+        GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
 
         fsBuilder->codeAppendf("%s;", tmpDecl.c_str());
 
@@ -142,7 +143,7 @@ const GrFragmentProcessor* GrConfigConversionEffect::TestCreate(GrProcessorTestD
 ///////////////////////////////////////////////////////////////////////////////
 
 void GrConfigConversionEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                                 GrProcessorKeyBuilder* b) const {
+                                                   GrProcessorKeyBuilder* b) const {
     GrGLConfigConversionEffect::GenKey(*this, caps, b);
 }
 
index a290b84971a07dea4da4debe3f87af36a9cfe048..5440dd31250bf293c6572f5c19a3ebc9e3c93b6a 100644 (file)
@@ -7,7 +7,8 @@
 
 #include "effects/GrConstColorProcessor.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 class GLConstColorProcessor : public GrGLFragmentProcessor {
@@ -15,9 +16,9 @@ public:
     GLConstColorProcessor() : fPrevColor(GrColor_ILLEGAL) {}
 
     void emitCode(EmitArgs& args) override {
-        GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+        GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
         const char* colorUni;
-        fColorUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fColorUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                             kVec4f_GrSLType, kMedium_GrSLPrecision, "constantColor",
                                             &colorUni);
         GrConstColorProcessor::InputMode mode = args.fFp.cast<GrConstColorProcessor>().inputMode();
index 714c68a9cef15c4611dab183a85f58bb19f0549b..c373b041fea6b186b74c08084bdb1dd52819cba9 100644 (file)
@@ -10,7 +10,8 @@
 #include "SkPathPriv.h"
 #include "gl/GrGLContext.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 //////////////////////////////////////////////////////////////////////////////
@@ -105,13 +106,13 @@ void GLAARectEffect::emitCode(EmitArgs& args) {
     const char *rectName;
     // The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bottom - 0.5),
     // respectively.
-    fRectUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                        kVec4f_GrSLType,
                                        kDefault_GrSLPrecision,
                                        "rect",
                                        &rectName);
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     const char* fragmentPos = fsBuilder->fragmentPosition();
     if (GrProcessorEdgeTypeIsAA(aare.getEdgeType())) {
         // The amount of coverage removed in x and y by the edges is computed as a pair of negative
@@ -191,13 +192,13 @@ void GrGLConvexPolyEffect::emitCode(EmitArgs& args) {
     const GrConvexPolyEffect& cpe = args.fFp.cast<GrConvexPolyEffect>();
 
     const char *edgeArrayName;
-    fEdgeUniform = args.fBuilder->addUniformArray(GrGLProgramBuilder::kFragment_Visibility,
+    fEdgeUniform = args.fBuilder->addUniformArray(GrGLSLProgramBuilder::kFragment_Visibility,
                                             kVec3f_GrSLType,
                                              kDefault_GrSLPrecision,
                                              "edges",
                                             cpe.getEdgeCount(),
                                             &edgeArrayName);
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     fsBuilder->codeAppend("\t\tfloat alpha = 1.0;\n");
     fsBuilder->codeAppend("\t\tfloat edge;\n");
     const char* fragmentPos = fsBuilder->fragmentPosition();
@@ -304,7 +305,7 @@ void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) cons
 }
 
 void GrConvexPolyEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                           GrProcessorKeyBuilder* b) const {
+                                             GrProcessorKeyBuilder* b) const {
     GrGLConvexPolyEffect::GenKey(*this, caps, b);
 }
 
index 96d1578f08932e990ffc8419da91d0d4925cbb68..5367b279021b0d0bd74770e61c4bf1aff97a02ee 100644 (file)
@@ -8,7 +8,8 @@
 #include "GrConvolutionEffect.h"
 #include "gl/GrGLFragmentProcessor.h"
 #include "gl/GrGLTexture.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 // For brevity
@@ -48,19 +49,19 @@ GrGLConvolutionEffect::GrGLConvolutionEffect(const GrProcessor& processor) {
 }
 
 void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
-    fImageIncrementUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fImageIncrementUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                              kVec2f_GrSLType, kDefault_GrSLPrecision,
                                              "ImageIncrement");
     if (this->useBounds()) {
-        fBoundsUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fBoundsUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                          kVec2f_GrSLType, kDefault_GrSLPrecision,
                                          "Bounds");
     }
-    fKernelUni = args.fBuilder->addUniformArray(GrGLProgramBuilder::kFragment_Visibility,
+    fKernelUni = args.fBuilder->addUniformArray(GrGLSLProgramBuilder::kFragment_Visibility,
                                           kFloat_GrSLType, kDefault_GrSLPrecision,
                                           "Kernel", this->width());
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
 
     fsBuilder->codeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", args.fOutputColor);
index b3fe0965c79511bd58582eaaa70b5dce0a170182..5c876d5cff959334bc9cc94d6ea0d5a7c98e0295 100644 (file)
@@ -12,8 +12,8 @@
 #include "GrProcessor.h"
 #include "GrProcOptInfo.h"
 #include "gl/GrGLXferProcessor.h"
-#include "gl/builders/GrGLFragmentShaderBuilder.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
 
 class CoverageSetOpXP : public GrXferProcessor {
 public:
@@ -72,7 +72,7 @@ public:
 private:
     void emitOutputsForBlendState(const EmitArgs& args) override {
         const CoverageSetOpXP& xp = args.fXP.cast<CoverageSetOpXP>();
-        GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+        GrGLSLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
 
         if (xp.invertCoverage()) {
             fsBuilder->codeAppendf("%s = 1.0 - %s;", args.fOutputPrimary, args.fInputCoverage);
index abcd9a5b1273022dac94ccc27100aaaf8757feb6..574310c49cac3c7281a69037532a384cd02ef08d 100644 (file)
@@ -20,8 +20,9 @@
 #include "gl/GrGLSLBlend.h"
 #include "gl/GrGLFragmentProcessor.h"
 #include "gl/GrGLProgramDataManager.h"
-#include "gl/builders/GrGLProgramBuilder.h"
 #include "glsl/GrGLSLCaps.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 bool GrCustomXfermode::IsSupportedMode(SkXfermode::Mode mode) {
@@ -147,7 +148,7 @@ private:
         const CustomXP& xp = args.fXP.cast<CustomXP>();
         SkASSERT(xp.hasHWBlendEquation());
 
-        GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+        GrGLSLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
         fsBuilder->enableAdvancedBlendEquationIfNeeded(xp.hwBlendEquation());
 
         // Apply coverage by multiplying it into the src color before blending. Mixed samples will
@@ -165,7 +166,7 @@ private:
         const CustomXP& xp = proc.cast<CustomXP>();
         SkASSERT(!xp.hasHWBlendEquation());
 
-        GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
+        GrGLSLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
         GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.mode());
     }
 
index b724082800dd3bdc1824ad134b15581cc49e24b5..3fa3014a9d5d88ee2915cf6de07ba059df9d1a9c 100644 (file)
 #include "batches/GrVertexBatch.h"
 #include "gl/GrGLGeometryProcessor.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLVertexShaderBuilder.h"
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -851,7 +853,7 @@ GLDashingCircleEffect::GLDashingCircleEffect() {
 void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
     const DashingCircleEffect& dce = args.fGP.cast<DashingCircleEffect>();
     GrGLSLGPBuilder* pb = args.fPB;
-    GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+    GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
 
     // emit attributes
     vsBuilder->emitAttributes(dce);
@@ -879,7 +881,7 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
                          args.fTransformsIn, args.fTransformsOut);
 
     // transforms all points so that we can compare them to our test circle
-    GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
     fsBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
                            dashParams.fsIn(), dashParams.fsIn(), dashParams.fsIn(),
                            dashParams.fsIn());
@@ -1056,7 +1058,7 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
     const DashingLineEffect& de = args.fGP.cast<DashingLineEffect>();
     GrGLSLGPBuilder* pb = args.fPB;
 
-    GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+    GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
 
     // emit attributes
     vsBuilder->emitAttributes(de);
@@ -1086,7 +1088,7 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
                          args.fTransformsIn, args.fTransformsOut);
 
     // transforms all points so that we can compare them to our test rect
-    GrGLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
     fsBuilder->codeAppendf("float xShifted = %s.x - floor(%s.x / %s.z) * %s.z;",
                            inDashParams.fsIn(), inDashParams.fsIn(), inDashParams.fsIn(),
                            inDashParams.fsIn());
index 0f3382f8fdb08731fa27feb2c6b36d74df4fa655..963b0dd1f21de4a4b15c812206f019e288f65856 100644 (file)
@@ -8,8 +8,8 @@
 #include "effects/GrDisableColorXP.h"
 #include "GrProcessor.h"
 #include "gl/GrGLXferProcessor.h"
-#include "gl/builders/GrGLFragmentShaderBuilder.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 /**
@@ -63,7 +63,7 @@ private:
         // This emit code should be empty. However, on the nexus 6 there is a driver bug where if
         // you do not give gl_FragColor a value, the gl context is lost and we end up drawing
         // nothing. So this fix just sets the gl_FragColor arbitrarily to 0.
-        GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+        GrGLSLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
         fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary);
     }
 
index 41e1aea7ef4957cbc4644476b0ceb9d9808e811f..90a08986866662dbbdd5ebbd6b1d0e4fbc17d124 100644 (file)
 #include "gl/GrGLFragmentProcessor.h"
 #include "gl/GrGLTexture.h"
 #include "gl/GrGLGeometryProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLVertexShaderBuilder.h"
 
 // Assuming a radius of a little less than the diagonal of the fragment
 #define SK_DistanceFieldAAFactor     "0.65"
@@ -34,11 +36,11 @@ public:
         const GrDistanceFieldA8TextGeoProc& dfTexEffect =
                 args.fGP.cast<GrDistanceFieldA8TextGeoProc>();
         GrGLSLGPBuilder* pb = args.fPB;
-        GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
+        GrGLSLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
         SkAssertResult(fsBuilder->enableFeature(
-                GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+                GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
 
-        GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
+        GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
 
         // emit attributes
         vsBuilder->emitAttributes(dfTexEffect);
@@ -47,7 +49,7 @@ public:
         // adjust based on gamma
         const char* distanceAdjustUniName = nullptr;
         // width, height, 1/(3*width)
-        fDistanceAdjustUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fDistanceAdjustUni = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
             kFloat_GrSLType, kDefault_GrSLPrecision,
             "DistanceAdjust", &distanceAdjustUniName);
 #endif
@@ -285,11 +287,11 @@ public:
         const GrDistanceFieldPathGeoProc& dfTexEffect = args.fGP.cast<GrDistanceFieldPathGeoProc>();
 
         GrGLSLGPBuilder* pb = args.fPB;
-        GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
+        GrGLSLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
         SkAssertResult(fsBuilder->enableFeature(
-                                     GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+                                     GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
 
-        GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
+        GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
 
         // emit attributes
         vsBuilder->emitAttributes(dfTexEffect);
@@ -316,7 +318,7 @@ public:
                              args.fTransformsIn, args.fTransformsOut);
 
         const char* textureSizeUniName = nullptr;
-        fTextureSizeUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fTextureSizeUni = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                          kVec2f_GrSLType, kDefault_GrSLPrecision,
                                          "TextureSize", &textureSizeUniName);
 
@@ -501,7 +503,7 @@ public:
                 args.fGP.cast<GrDistanceFieldLCDTextGeoProc>();
         GrGLSLGPBuilder* pb = args.fPB;
 
-        GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
+        GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
 
         // emit attributes
         vsBuilder->emitAttributes(dfTexEffect);
@@ -541,10 +543,10 @@ public:
                                dfTexEffect.inTextureCoords()->fName);
 
         // add frag shader code
-        GrGLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
+        GrGLSLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
 
         SkAssertResult(fsBuilder->enableFeature(
-                GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+                GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
 
         // create LCD offset adjusted by inverse of transform
         // Use highp to work around aliasing issues
@@ -595,7 +597,7 @@ public:
 
         // adjust width based on gamma
         const char* distanceAdjustUniName = nullptr;
-        fDistanceAdjustUni = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fDistanceAdjustUni = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
             kVec3f_GrSLType, kDefault_GrSLPrecision,
             "DistanceAdjust", &distanceAdjustUniName);
         fsBuilder->codeAppendf("distance -= %s;", distanceAdjustUniName);
index bab0f32dd87559ba1d920e823d75149995d2d00d..fb02da5544ce61d0ffa30e815c647ac9a2ef5478 100644 (file)
@@ -10,7 +10,8 @@
 #include "GrInvariantOutput.h"
 #include "SkRect.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -72,7 +73,7 @@ GLDitherEffect::GLDitherEffect(const GrProcessor&) {
 }
 
 void GLDitherEffect::emitCode(EmitArgs& args) {
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     // Generate a random number based on the fragment position. For this
     // random number generator, we use the "GLSL rand" function
     // that seems to be floating around on the internet. It works under
@@ -92,7 +93,7 @@ void GLDitherEffect::emitCode(EmitArgs& args) {
 //////////////////////////////////////////////////////////////////////////////
 
 void DitherEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                     GrProcessorKeyBuilder* b) const {
+                                       GrProcessorKeyBuilder* b) const {
     GLDitherEffect::GenKey(*this, caps, b);
 }
 
index af09db5090829c6041344969f20322f62f194ec2..358f8082f22bf5ab22f763aefc6cebe7dcd86d6c 100644 (file)
@@ -65,7 +65,7 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
     int kWidth = fKernelSize.width();
     int kHeight = fKernelSize.height();
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
     fsBuilder->codeAppend("vec4 sum = vec4(0, 0, 0, 0);");
     fsBuilder->codeAppendf("vec2 coord = %s - %s * %s;", coords2D.c_str(), kernelOffset,
@@ -74,7 +74,7 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
 
     for (int y = 0; y < kHeight; y++) {
         for (int x = 0; x < kWidth; x++) {
-            GrGLShaderBuilder::ShaderBlock block(fsBuilder);
+            GrGLSLShaderBuilder::ShaderBlock block(fsBuilder);
             fsBuilder->codeAppendf("float k = %s[%d * %d + %d];", kernel, y, kWidth, x);
             SkString coord;
             coord.printf("coord + vec2(%d, %d) * %s", x, y, imgInc);
index 1bc6589a3eecdcc53ac0029749a2f620d00cd387..d34edbb7268393693dbc4630db5c41bf2da65574 100644 (file)
@@ -11,7 +11,8 @@
 #include "GrInvariantOutput.h"
 #include "SkRect.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 //////////////////////////////////////////////////////////////////////////////
@@ -118,12 +119,12 @@ void GLCircleEffect::emitCode(EmitArgs& args) {
     const char *circleName;
     // The circle uniform is (center.x, center.y, radius + 0.5, 1 / (radius + 0.5)) for regular
     // fills and (..., radius - 0.5, 1 / (radius - 0.5)) for inverse fills.
-    fCircleUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fCircleUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                          kVec4f_GrSLType, kDefault_GrSLPrecision,
                                          "circle",
                                          &circleName);
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     const char* fragmentPos = fsBuilder->fragmentPosition();
 
     SkASSERT(kHairlineAA_GrProcessorEdgeType != ce.getEdgeType());
@@ -290,12 +291,12 @@ void GLEllipseEffect::emitCode(EmitArgs& args) {
     const char *ellipseName;
     // The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2)
     // The last two terms can underflow on mediump, so we use highp.
-    fEllipseUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fEllipseUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                          kVec4f_GrSLType, kHigh_GrSLPrecision,
                                          "ellipse",
                                          &ellipseName);
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     const char* fragmentPos = fsBuilder->fragmentPosition();
 
     // d is the offset to the ellipse center
index 28663805c1f45790b6cbdbebf2c055ba70b82a8a..650a1e7622fae6010aeaf4af87950a75763788bf 100644 (file)
@@ -15,8 +15,8 @@
 #include "GrXferProcessor.h"
 #include "gl/GrGLSLBlend.h"
 #include "gl/GrGLXferProcessor.h"
-#include "gl/builders/GrGLFragmentShaderBuilder.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 /**
@@ -381,7 +381,8 @@ private:
 
 ///////////////////////////////////////////////////////////////////////////////
 
-static void append_color_output(const PorterDuffXferProcessor& xp, GrGLXPFragmentBuilder* fsBuilder,
+static void append_color_output(const PorterDuffXferProcessor& xp,
+                                GrGLSLXPFragmentBuilder* fsBuilder,
                                 BlendFormula::OutputType outputType, const char* output,
                                 const char* inColor, const char* inCoverage) {
     switch (outputType) {
@@ -440,7 +441,7 @@ public:
 private:
     void emitOutputsForBlendState(const EmitArgs& args) override {
         const PorterDuffXferProcessor& xp = args.fXP.cast<PorterDuffXferProcessor>();
-        GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+        GrGLSLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
 
         BlendFormula blendFormula = xp.getBlendFormula();
         if (blendFormula.hasSecondaryOutput()) {
@@ -546,7 +547,7 @@ private:
     void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb, const char* srcColor, const char* dstColor,
                                  const char* outColor, const GrXferProcessor& proc) override {
         const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>();
-        GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
+        GrGLSLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
 
         GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.getXfermode());
     }
@@ -559,7 +560,7 @@ private:
 ///////////////////////////////////////////////////////////////////////////////
 
 void ShaderPDXferProcessor::onGetGLProcessorKey(const GrGLSLCaps&,
-                                                  GrProcessorKeyBuilder* b) const {
+                                                GrProcessorKeyBuilder* b) const {
     GLShaderPDXferProcessor::GenKey(*this, b);
 }
 
@@ -624,7 +625,7 @@ public:
 
 private:
     void emitOutputsForBlendState(const EmitArgs& args) override {
-        GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+        GrGLSLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
         fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputPrimary, args.fInputColor,
                                args.fInputCoverage);
     }
index aeab0e4dbf5eff8bafed3b5c56de81690ef6600c..398edccb64b51a0d3d2b921c525bbb26ca0b3df7 100644 (file)
@@ -13,7 +13,8 @@
 #include "GrOvalEffect.h"
 #include "SkRRect.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 // The effects defined here only handle rrect radii >= kRadiusMin.
@@ -155,16 +156,16 @@ void GLCircularRRectEffect::emitCode(EmitArgs& args) {
     // edges correspond to components x, y, z, and w, respectively. When a side of the rrect has
     // only rectangular corners, that side's value corresponds to the rect edge's value outset by
     // half a pixel.
-    fInnerRectUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                            kVec4f_GrSLType, kDefault_GrSLPrecision,
-                                            "innerRect",
-                                            &rectName);
-    fRadiusPlusHalfUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                                 kFloat_GrSLType, kDefault_GrSLPrecision,
-                                                 "radiusPlusHalf",
-                                                 &radiusPlusHalfName);
-
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    fInnerRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                                  kVec4f_GrSLType, kDefault_GrSLPrecision,
+                                                  "innerRect",
+                                                  &rectName);
+    fRadiusPlusHalfUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                                       kFloat_GrSLType, kDefault_GrSLPrecision,
+                                                       "radiusPlusHalf",
+                                                       &radiusPlusHalfName);
+
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     const char* fragmentPos = fsBuilder->fragmentPosition();
     // At each quarter-circle corner we compute a vector that is the offset of the fragment position
     // from the circle center. The vector is pinned in x and y to be in the quarter-plane relevant
@@ -364,7 +365,7 @@ void GLCircularRRectEffect::onSetData(const GrGLSLProgramDataManager& pdman,
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void CircularRRectEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                            GrProcessorKeyBuilder* b) const {
+                                              GrProcessorKeyBuilder* b) const {
     GLCircularRRectEffect::GenKey(*this, caps, b);
 }
 
@@ -497,12 +498,12 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
     const EllipticalRRectEffect& erre = args.fFp.cast<EllipticalRRectEffect>();
     const char *rectName;
     // The inner rect is the rrect bounds inset by the x/y radii
-    fInnerRectUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    fInnerRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                             kVec4f_GrSLType, kDefault_GrSLPrecision,
                                             "innerRect",
                                             &rectName);
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     const char* fragmentPos = fsBuilder->fragmentPosition();
     // At each quarter-ellipse corner we compute a vector that is the offset of the fragment pos
     // to the ellipse center. The vector is pinned in x and y to be in the quarter-plane relevant
@@ -522,10 +523,11 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
     switch (erre.getRRect().getType()) {
         case SkRRect::kSimple_Type: {
             const char *invRadiiXYSqdName;
-            fInvRadiiSqdUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                                      kVec2f_GrSLType, kHigh_GrSLPrecision,
-                                                      "invRadiiXY",
-                                                      &invRadiiXYSqdName);
+            fInvRadiiSqdUniform = args.fBuilder->addUniform(
+                                                         GrGLSLProgramBuilder::kFragment_Visibility,
+                                                         kVec2f_GrSLType, kHigh_GrSLPrecision,
+                                                         "invRadiiXY",
+                                                         &invRadiiXYSqdName);
             fsBuilder->codeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n");
             // Z is the x/y offsets divided by squared radii.
             fsBuilder->codeAppendf("\t\tvec2 Z = dxy * %s;\n", invRadiiXYSqdName);
@@ -533,10 +535,11 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
         }
         case SkRRect::kNinePatch_Type: {
             const char *invRadiiLTRBSqdName;
-            fInvRadiiSqdUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                                      kVec4f_GrSLType, kHigh_GrSLPrecision,
-                                                      "invRadiiLTRB",
-                                                      &invRadiiLTRBSqdName);
+            fInvRadiiSqdUniform = args.fBuilder->addUniform(
+                                                         GrGLSLProgramBuilder::kFragment_Visibility,
+                                                         kVec4f_GrSLType, kHigh_GrSLPrecision,
+                                                         "invRadiiLTRB",
+                                                         &invRadiiLTRBSqdName);
             fsBuilder->codeAppend("\t\tvec2 dxy = max(max(dxy0, dxy1), 0.0);\n");
             // Z is the x/y offsets divided by squared radii. We only care about the (at most) one
             // corner where both the x and y offsets are positive, hence the maxes. (The inverse
@@ -613,7 +616,7 @@ void GLEllipticalRRectEffect::onSetData(const GrGLSLProgramDataManager& pdman,
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
 void EllipticalRRectEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                              GrProcessorKeyBuilder* b) const {
+                                                GrProcessorKeyBuilder* b) const {
     GLEllipticalRRectEffect::GenKey(*this, caps, b);
 }
 
index 89b354632a23a672789f79317328c24568802561..c1bc6dff306769ccff0014e2b93d6fecb33378ad 100644 (file)
 #include "gl/GrGLCaps.h"
 #include "gl/GrGLFragmentProcessor.h"
 #include "gl/GrGLTexture.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 
 class GrGLSimpleTextureEffect : public GrGLFragmentProcessor {
 public:
     GrGLSimpleTextureEffect(const GrProcessor&) {}
 
     virtual void emitCode(EmitArgs& args) override {
-        GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+        GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
         fsBuilder->codeAppendf("\t%s = ", args.fOutputColor);
         fsBuilder->appendTextureLookupAndModulate(args.fInputColor,
                                                   args.fSamplers[0],
@@ -38,7 +39,7 @@ void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
 }
 
 void GrSimpleTextureEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
-                                              GrProcessorKeyBuilder* b) const {
+                                                GrProcessorKeyBuilder* b) const {
     GrGLSimpleTextureEffect::GenKey(*this, caps, b);
 }
 
index b6458dc1f218cc4529ddd702480ee722c0c45029..cd89a59ac875a96f3b82ab053da85cbe87a91eaf 100644 (file)
@@ -42,7 +42,7 @@ GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index)
 
 //////////////////////////////////////////////////////////////////////////////
 
-void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder,
+void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
                                               const GrTextureDomain& textureDomain,
                                               const char* outColor,
                                               const SkString& inCoords,
@@ -86,7 +86,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder,
         }
         case kDecal_Mode: {
             // Add a block since we're going to declare variables.
-            GrGLShaderBuilder::ShaderBlock block(builder);
+            GrGLSLShaderBuilder::ShaderBlock block(builder);
 
             const char* domain = fDomainName.c_str();
             if (!program->glslCaps()->canUseAnyFunctionInShader()) {
@@ -196,7 +196,7 @@ void GrGLTextureDomainEffect::emitCode(EmitArgs& args) {
     const GrTextureDomainEffect& textureDomainEffect = args.fFp.cast<GrTextureDomainEffect>();
     const GrTextureDomain& domain = textureDomainEffect.textureDomain();
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
     fGLDomain.sampleTexture(fsBuilder, domain, args.fOutputColor, coords2D, args.fSamplers[0],
                             args.fInputColor);
index bbe988cf1b545f7bf393fddc197b6fb56d33c0f6..874cdbc0801a43817644354d476e8b1f6a452222 100644 (file)
@@ -13,7 +13,7 @@
 #include "glsl/GrGLSLProgramDataManager.h"
 
 class GrGLProgramBuilder;
-class GrGLShaderBuilder;
+class GrGLSLShaderBuilder;
 class GrInvariantOutput;
 class GrGLSLTextureSampler;
 struct SkRect;
@@ -113,7 +113,7 @@ public:
          * @param inModulateColor   if non-nullptr the sampled color will be modulated with this
          *                          expression before being written to outColor.
          */
-        void sampleTexture(GrGLShaderBuilder* builder,
+        void sampleTexture(GrGLSLShaderBuilder* builder,
                            const GrTextureDomain& textureDomain,
                            const char* outColor,
                            const SkString& inCoords,
index 73343e75c4c531c3b41ed71f2ee1a849b0a8cc76..0dbb6eb5346b98542fad49ed4d2567a946f4de6f 100644 (file)
@@ -11,7 +11,8 @@
 #include "effects/GrConstColorProcessor.h"
 #include "gl/GrGLFragmentProcessor.h"
 #include "gl/GrGLSLBlend.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "SkGrPriv.h"
 
 class ComposeTwoFragmentProcessor : public GrFragmentProcessor {
@@ -88,7 +89,7 @@ GrGLFragmentProcessor* ComposeTwoFragmentProcessor::onCreateGLInstance() const{
 
 void GLComposeTwoFragmentProcessor::emitCode(EmitArgs& args) {
 
-    GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
     const ComposeTwoFragmentProcessor& cs = args.fFp.cast<ComposeTwoFragmentProcessor>();
 
     const char* inputColor = nullptr;
@@ -218,7 +219,7 @@ public:
     GLComposeOneFragmentProcessor(const GrProcessor& processor) {}
 
     void emitCode(EmitArgs& args) override {
-        GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+        GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
         SkXfermode::Mode mode = args.fFp.cast<ComposeOneFragmentProcessor>().mode();
         ComposeOneFragmentProcessor::Child child =
             args.fFp.cast<ComposeOneFragmentProcessor>().child();
index 39a974348bd4b548000c581e35eeb8af4a78b519..daf1ca379604b566a29af7f049ae8eee28d3be9b 100644 (file)
@@ -11,7 +11,8 @@
 #include "GrInvariantOutput.h"
 #include "GrProcessor.h"
 #include "gl/GrGLFragmentProcessor.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 namespace {
@@ -63,12 +64,12 @@ public:
         GLProcessor(const GrProcessor&) {}
 
         virtual void emitCode(EmitArgs& args) override {
-            GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+            GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
 
             const char* yuvMatrix   = nullptr;
-            fMatrixUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
-                                             kMat44f_GrSLType, kDefault_GrSLPrecision,
-                                             "YUVMatrix", &yuvMatrix);
+            fMatrixUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                                   kMat44f_GrSLType, kDefault_GrSLPrecision,
+                                                   "YUVMatrix", &yuvMatrix);
             fsBuilder->codeAppendf("\t%s = vec4(\n\t\t", args.fOutputColor);
             fsBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_str(),
                                            args.fCoords[0].getType());
index dcc6cb10dc19460f0c10be7269b4ea4bbfbf8c82..1d6f5992e4527015f561f241b7601ab2a103a935 100644 (file)
@@ -8,8 +8,8 @@
 #include "GrGLFragmentProcessor.h"
 #include "GrFragmentProcessor.h"
 #include "GrProcessor.h"
-#include "builders/GrGLFragmentShaderBuilder.h"
-#include "builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 
 void GrGLFragmentProcessor::setData(const GrGLSLProgramDataManager& pdman,
                                     const GrFragmentProcessor& processor) {
@@ -28,7 +28,7 @@ void GrGLFragmentProcessor::emitChild(int childIndex, const char* inputColor,
                                       SkString* outputColor, EmitArgs& args) {
 
     SkASSERT(outputColor);
-    GrGLFragmentBuilder* fb = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fb = args.fBuilder->getFragmentShaderBuilder();
     outputColor->append(fb->getMangleString());
     fb->codeAppendf("vec4 %s;", outputColor->c_str());
     this->internalEmitChild(childIndex, inputColor, outputColor->c_str(), args);
@@ -36,7 +36,7 @@ void GrGLFragmentProcessor::emitChild(int childIndex, const char* inputColor,
 
 void GrGLFragmentProcessor::internalEmitChild(int childIndex, const char* inputColor,
                                                const char* outputColor, EmitArgs& args) {
-    GrGLFragmentBuilder* fb = args.fBuilder->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fb = args.fBuilder->getFragmentShaderBuilder();
 
     fb->onBeforeChildProcEmitCode();  // call first so mangleString is updated
 
index c01e305679858a7cc6353de0b3be1ac0e41d645e..de4a5a3263619a8e11fe7734e75a36b7ea632bf1 100644 (file)
@@ -7,11 +7,13 @@
 
 #include "GrGLGeometryProcessor.h"
 
-#include "builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
 #include "glsl/GrGLSLProcessorTypes.h"
+#include "glsl/GrGLSLProgramBuilder.h"
+#include "glsl/GrGLSLVertexShaderBuilder.h"
 
 void GrGLGeometryProcessor::emitCode(EmitArgs& args) {
-    GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
+    GrGLSLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
     GrGPArgs gpArgs;
     this->onEmitCode(args, &gpArgs);
     vsBuilder->transformToNormalizedDeviceSpace(gpArgs.fPositionVar);
@@ -23,7 +25,7 @@ void GrGLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb,
                                            const SkMatrix& localMatrix,
                                            const TransformsIn& tin,
                                            TransformsOut* tout) {
-    GrGLVertexBuilder* vb = pb->getVertexShaderBuilder();
+    GrGLSLVertexBuilder* vb = pb->getVertexShaderBuilder();
     tout->push_back_n(tin.count());
     fInstalledTransforms.push_back_n(tin.count());
     for (int i = 0; i < tin.count(); i++) {
@@ -45,7 +47,7 @@ void GrGLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb,
 
             const char* uniName;
             fInstalledTransforms[i][t].fHandle =
-                    pb->addUniform(GrGLProgramBuilder::kVertex_Visibility,
+                    pb->addUniform(GrGLSLProgramBuilder::kVertex_Visibility,
                                    kMat33f_GrSLType, precision,
                                    strUniName.c_str(),
                                    &uniName).toIndex();
@@ -94,7 +96,7 @@ void GrGLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb,
                                            const char* localCoords,
                                            const TransformsIn& tin,
                                            TransformsOut* tout) {
-    GrGLVertexBuilder* vb = pb->getVertexShaderBuilder();
+    GrGLSLVertexBuilder* vb = pb->getVertexShaderBuilder();
     tout->push_back_n(tin.count());
     for (int i = 0; i < tin.count(); i++) {
         const ProcCoords& coordTransforms = tin[i];
@@ -122,7 +124,7 @@ void GrGLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb,
 void GrGLGeometryProcessor::setupPosition(GrGLSLGPBuilder* pb,
                                           GrGPArgs* gpArgs,
                                           const char* posName) {
-    GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
+    GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
     gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
     vsBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
 }
@@ -132,13 +134,13 @@ void GrGLGeometryProcessor::setupPosition(GrGLSLGPBuilder* pb,
                                           const char* posName,
                                           const SkMatrix& mat,
                                           UniformHandle* viewMatrixUniform) {
-    GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
+    GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
     if (mat.isIdentity()) {
         gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
         vsBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
     } else {
         const char* viewMatrixName;
-        *viewMatrixUniform = pb->addUniform(GrGLProgramBuilder::kVertex_Visibility,
+        *viewMatrixUniform = pb->addUniform(GrGLSLProgramBuilder::kVertex_Visibility,
                                             kMat33f_GrSLType, kHigh_GrSLPrecision,
                                             "uViewM",
                                             &viewMatrixName);
index 35fa23531219d2fe38dcb0f78140d1eb2ffbde3b..66d3892559dc16dde862f3e11f691deac8746d0b 100644 (file)
@@ -7,7 +7,8 @@
 
 #include "GrGLPrimitiveProcessor.h"
 
-#include "builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
 
 SkMatrix GrGLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatrix,
                                                     const GrCoordTransform& coordTransform) {
@@ -34,10 +35,10 @@ SkMatrix GrGLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatrix,
 void GrGLPrimitiveProcessor::setupUniformColor(GrGLSLGPBuilder* pb,
                                                const char* outputName,
                                                UniformHandle* colorUniform) {
-    GrGLFragmentBuilder* fs = pb->getFragmentShaderBuilder();
+    GrGLSLFragmentBuilder* fs = pb->getFragmentShaderBuilder();
     SkASSERT(colorUniform);
     const char* stagedLocalVarName;
-    *colorUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+    *colorUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                    kVec4f_GrSLType,
                                    kDefault_GrSLPrecision,
                                    "Color",
index 8ff25575c602c92c0cca0a31491428d6ae7151eb..2255dbde51e76f28a05181c7dd8f74d7bad96199 100644 (file)
@@ -11,7 +11,7 @@
 #include "GrGLGpu.h"
 #include "GrPipeline.h"
 #include "SkChecksum.h"
-#include "gl/builders/GrGLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
 
 /**
  * Do we need to either map r,g,b->a or a->r. configComponentMask indicates which channels are
@@ -146,7 +146,7 @@ bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc,
 
     if (pipeline.readsFragPosition()) {
         header->fFragPosKey =
-                GrGLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRenderTarget());
+                GrGLSLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRenderTarget());
     } else {
         header->fFragPosKey = 0;
     }
index 6a057c622e81fa22fcedef01b8daf828f4807d20..3c83068fc19aa8785f01c5118ae79e59070d7eed 100644 (file)
@@ -5,13 +5,13 @@
  * found in the LICENSE file.
  */
 #include "GrGLSLBlend.h"
-#include "gl/builders/GrGLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
 
 //////////////////////////////////////////////////////////////////////////////
 //  Advanced (non-coeff) blend helpers
 //////////////////////////////////////////////////////////////////////////////
 
-static void hard_light(GrGLFragmentBuilder* fsBuilder,
+static void hard_light(GrGLSLFragmentBuilder* fsBuilder,
                        const char* final,
                        const char* src,
                        const char* dst) {
@@ -32,7 +32,7 @@ static void hard_light(GrGLFragmentBuilder* fsBuilder,
 }
 
 // Does one component of color-dodge
-static void color_dodge_component(GrGLFragmentBuilder* fsBuilder,
+static void color_dodge_component(GrGLSLFragmentBuilder* fsBuilder,
                                   const char* final,
                                   const char* src,
                                   const char* dst,
@@ -56,7 +56,7 @@ static void color_dodge_component(GrGLFragmentBuilder* fsBuilder,
 }
 
 // Does one component of color-burn
-static void color_burn_component(GrGLFragmentBuilder* fsBuilder,
+static void color_burn_component(GrGLSLFragmentBuilder* fsBuilder,
                                  const char* final,
                                  const char* src,
                                  const char* dst,
@@ -77,7 +77,7 @@ static void color_burn_component(GrGLFragmentBuilder* fsBuilder,
 }
 
 // Does one component of soft-light. Caller should have already checked that dst alpha > 0.
-static void soft_light_component_pos_dst_alpha(GrGLFragmentBuilder* fsBuilder,
+static void soft_light_component_pos_dst_alpha(GrGLSLFragmentBuilder* fsBuilder,
                                                const char* final,
                                                const char* src,
                                                const char* dst,
@@ -119,7 +119,7 @@ static void soft_light_component_pos_dst_alpha(GrGLFragmentBuilder* fsBuilder,
 // hue and saturation of the first color, the luminosity of the second color, and the input
 // alpha. It has this signature:
 //      vec3 set_luminance(vec3 hueSatColor, float alpha, vec3 lumColor).
-static void add_lum_function(GrGLFragmentBuilder* fsBuilder, SkString* setLumFunction) {
+static void add_lum_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setLumFunction) {
     // Emit a helper that gets the luminance of a color.
     SkString getFunction;
     GrGLSLShaderVar getLumArgs[] = {
@@ -164,7 +164,7 @@ static void add_lum_function(GrGLFragmentBuilder* fsBuilder, SkString* setLumFun
 // Adds a function that creates a color with the hue and luminosity of one input color and
 // the saturation of another color. It will have this signature:
 //      float set_saturation(vec3 hueLumColor, vec3 satColor)
-static void add_sat_function(GrGLFragmentBuilder* fsBuilder, SkString* setSatFunction) {
+static void add_sat_function(GrGLSLFragmentBuilder* fsBuilder, SkString* setSatFunction) {
     // Emit a helper that gets the saturation of a color
     SkString getFunction;
     GrGLSLShaderVar getSatArgs[] = { GrGLSLShaderVar("color", kVec3f_GrSLType) };
@@ -235,7 +235,7 @@ static void add_sat_function(GrGLFragmentBuilder* fsBuilder, SkString* setSatFun
                             setSatFunction);
 }
 
-static void emit_advanced_xfermode_code(GrGLFragmentBuilder* fsBuilder, const char* srcColor,
+static void emit_advanced_xfermode_code(GrGLSLFragmentBuilder* fsBuilder, const char* srcColor,
                                         const char* dstColor, const char* outputColor,
                                         SkXfermode::Mode mode) {
     SkASSERT(srcColor);
@@ -368,7 +368,7 @@ static void emit_advanced_xfermode_code(GrGLFragmentBuilder* fsBuilder, const ch
 //  Porter-Duff blend helper
 //////////////////////////////////////////////////////////////////////////////
 
-static bool append_porterduff_term(GrGLFragmentBuilder* fsBuilder, SkXfermode::Coeff coeff,
+static bool append_porterduff_term(GrGLSLFragmentBuilder* fsBuilder, SkXfermode::Coeff coeff,
                                    const char* colorName, const char* srcColorName,
                                    const char* dstColorName, bool hasPrevious) {
     if (SkXfermode::kZero_Coeff == coeff) {
@@ -414,7 +414,7 @@ static bool append_porterduff_term(GrGLFragmentBuilder* fsBuilder, SkXfermode::C
 
 //////////////////////////////////////////////////////////////////////////////
 
-void GrGLSLBlend::AppendMode(GrGLFragmentBuilder* fsBuilder, const char* srcColor,
+void GrGLSLBlend::AppendMode(GrGLSLFragmentBuilder* fsBuilder, const char* srcColor,
                              const char* dstColor, const char* outColor,
                              SkXfermode::Mode mode) {
 
index b763f450d87c6c5f7939bc7f63da190c52720263..25ae37b1c1c41c2cfe2b67600fd74dbcc095bed7 100644 (file)
 
 #include "SkXfermode.h"
 
-class GrGLFragmentBuilder;
+class GrGLSLFragmentBuilder;
 
 namespace GrGLSLBlend {
     /*
      * Appends GLSL code to fsBuilder that assigns a specified blend of the srcColor and dstColor
      * variables to the outColor variable.
      */
-    void AppendMode(GrGLFragmentBuilder* fsBuilder, const char* srcColor,
+    void AppendMode(GrGLSLFragmentBuilder* fsBuilder, const char* srcColor,
                     const char* dstColor, const char* outColor, SkXfermode::Mode mode);
 };
 
index 528d354bfcffa6831453591b18fa9358cf83332e..bf333bb3178fc4efce33836db58e75ee660e258b 100644 (file)
@@ -8,8 +8,8 @@
 #include "gl/GrGLXferProcessor.h"
 
 #include "GrXferProcessor.h"
-#include "gl/builders/GrGLFragmentShaderBuilder.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 
 void GrGLXferProcessor::emitCode(const EmitArgs& args) {
@@ -18,7 +18,7 @@ void GrGLXferProcessor::emitCode(const EmitArgs& args) {
         return;
     }
 
-    GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
+    GrGLSLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
     const char* dstColor = fsBuilder->dstColor();
 
     if (args.fXP.getDstTexture()) {
@@ -35,12 +35,12 @@ void GrGLXferProcessor::emitCode(const EmitArgs& args) {
         const char* dstTopLeftName;
         const char* dstCoordScaleName;
 
-        fDstTopLeftUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fDstTopLeftUni = args.fPB->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                               kVec2f_GrSLType,
                                               kDefault_GrSLPrecision,
                                               "DstTextureUpperLeft",
                                               &dstTopLeftName);
-        fDstScaleUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Visibility,
+        fDstScaleUni = args.fPB->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
                                             kVec2f_GrSLType,
                                             kDefault_GrSLPrecision,
                                             "DstTextureCoordScale",
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
deleted file mode 100644 (file)
index c464ffd..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrGLFragmentShaderBuilder.h"
-#include "GrRenderTarget.h"
-#include "glsl/GrGLSL.h"
-#include "glsl/GrGLSLCaps.h"
-#include "glsl/GrGLSLProgramBuilder.h"
-
-const char* GrGLFragmentShaderBuilder::kDstTextureColorName = "_dstColor";
-
-static const char* specific_layout_qualifier_name(GrBlendEquation equation) {
-    SkASSERT(GrBlendEquationIsAdvanced(equation));
-
-    static const char* kLayoutQualifierNames[] = {
-        "blend_support_screen",
-        "blend_support_overlay",
-        "blend_support_darken",
-        "blend_support_lighten",
-        "blend_support_colordodge",
-        "blend_support_colorburn",
-        "blend_support_hardlight",
-        "blend_support_softlight",
-        "blend_support_difference",
-        "blend_support_exclusion",
-        "blend_support_multiply",
-        "blend_support_hsl_hue",
-        "blend_support_hsl_saturation",
-        "blend_support_hsl_color",
-        "blend_support_hsl_luminosity"
-    };
-    return kLayoutQualifierNames[equation - kFirstAdvancedGrBlendEquation];
-
-    GR_STATIC_ASSERT(0 == kScreen_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(1 == kOverlay_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(2 == kDarken_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(3 == kLighten_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(4 == kColorDodge_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(5 == kColorBurn_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(6 == kHardLight_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(7 == kSoftLight_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(8 == kDifference_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(9 == kExclusion_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(10 == kMultiply_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(11 == kHSLHue_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(12 == kHSLSaturation_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(13 == kHSLColor_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(14 == kHSLLuminosity_GrBlendEquation - kFirstAdvancedGrBlendEquation);
-    GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayoutQualifierNames) ==
-                     kGrBlendEquationCnt - kFirstAdvancedGrBlendEquation);
-}
-
-GrGLFragmentShaderBuilder::FragPosKey
-GrGLFragmentShaderBuilder::KeyForFragmentPosition(const GrRenderTarget* dst) {
-    if (kTopLeft_GrSurfaceOrigin == dst->origin()) {
-        return kTopLeftFragPosRead_FragPosKey;
-    } else {
-        return kBottomLeftFragPosRead_FragPosKey;
-    }
-}
-
-GrGLFragmentShaderBuilder::GrGLFragmentShaderBuilder(GrGLSLProgramBuilder* program,
-                                                     uint8_t fragPosKey)
-    : INHERITED(program)
-    , fSetupFragPosition(false)
-    , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == fragPosKey)
-    , fCustomColorOutputIndex(-1)
-    , fHasReadDstColor(false)
-    , fHasReadFragmentPosition(false) {
-}
-
-bool GrGLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
-    switch (feature) {
-        case kStandardDerivatives_GLSLFeature: {
-            if (!fProgramBuilder->glslCaps()->shaderDerivativeSupport()) {
-                return false;
-            }
-            const char* extension = fProgramBuilder->glslCaps()->shaderDerivativeExtensionString();
-            if (extension) {
-                this->addFeature(1 << kStandardDerivatives_GLSLFeature, extension);
-            }
-            return true;
-        }
-        default:
-            SkFAIL("Unexpected GLSLFeature requested.");
-            return false;
-    }
-}
-
-SkString GrGLFragmentShaderBuilder::ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords,
-                                                     int index) {
-    if (kVec3f_GrSLType != coords[index].getType()) {
-        SkASSERT(kVec2f_GrSLType == coords[index].getType());
-        return coords[index].getName();
-    }
-
-    SkString coords2D("coords2D");
-    if (0 != index) {
-        coords2D.appendf("_%i", index);
-    }
-    this->codeAppendf("\tvec2 %s = %s.xy / %s.z;",
-                      coords2D.c_str(), coords[index].c_str(), coords[index].c_str());
-    return coords2D;
-}
-
-const char* GrGLFragmentShaderBuilder::fragmentPosition() {
-    fHasReadFragmentPosition = true;
-
-    const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
-    // We only declare "gl_FragCoord" when we're in the case where we want to use layout qualifiers
-    // to reverse y. Otherwise it isn't necessary and whether the "in" qualifier appears in the
-    // declaration varies in earlier GLSL specs. So it is simpler to omit it.
-    if (fTopLeftFragPosRead) {
-        fSetupFragPosition = true;
-        return "gl_FragCoord";
-    } else if (const char* extension = glslCaps->fragCoordConventionsExtensionString()) {
-        if (!fSetupFragPosition) {
-            if (glslCaps->generation() < k150_GrGLSLGeneration) {
-                this->addFeature(1 << kFragCoordConventions_GLSLPrivateFeature,
-                                 extension);
-            }
-            fInputs.push_back().set(kVec4f_GrSLType,
-                                    GrGLSLShaderVar::kIn_TypeModifier,
-                                    "gl_FragCoord",
-                                    kDefault_GrSLPrecision,
-                                    GrGLSLShaderVar::kUpperLeft_Origin);
-            fSetupFragPosition = true;
-        }
-        return "gl_FragCoord";
-    } else {
-        static const char* kTempName = "tmpXYFragCoord";
-        static const char* kCoordName = "fragCoordYDown";
-        if (!fSetupFragPosition) {
-            SkASSERT(!fProgramBuilder->fUniformHandles.fRTHeightUni.isValid());
-            const char* rtHeightName;
-
-            fProgramBuilder->fUniformHandles.fRTHeightUni =
-                    fProgramBuilder->addFragPosUniform(GrGLSLProgramBuilder::kFragment_Visibility,
-                                                       kFloat_GrSLType,
-                                                       kDefault_GrSLPrecision,
-                                                       "RTHeight",
-                                                       &rtHeightName);
-
-            // The Adreno compiler seems to be very touchy about access to "gl_FragCoord".
-            // Accessing glFragCoord.zw can cause a program to fail to link. Additionally,
-            // depending on the surrounding code, accessing .xy with a uniform involved can
-            // do the same thing. Copying gl_FragCoord.xy into a temp vec2 beforehand 
-            // (and only accessing .xy) seems to "fix" things.
-            this->codePrependf("\tvec4 %s = vec4(%s.x, %s - %s.y, 1.0, 1.0);\n",
-                               kCoordName, kTempName, rtHeightName, kTempName);
-            this->codePrependf("vec2 %s = gl_FragCoord.xy;", kTempName);
-            fSetupFragPosition = true;
-        }
-        SkASSERT(fProgramBuilder->fUniformHandles.fRTHeightUni.isValid());
-        return kCoordName;
-    }
-}
-
-const char* GrGLFragmentShaderBuilder::dstColor() {
-    fHasReadDstColor = true;
-
-    const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
-    if (glslCaps->fbFetchSupport()) {
-        this->addFeature(1 << (GrGLFragmentShaderBuilder::kLastGLSLPrivateFeature + 1),
-                         glslCaps->fbFetchExtensionString());
-
-        // Some versions of this extension string require declaring custom color output on ES 3.0+
-        const char* fbFetchColorName = glslCaps->fbFetchColorName();
-        if (glslCaps->fbFetchNeedsCustomOutput()) {
-            this->enableCustomOutput();
-            fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOut_TypeModifier);
-            fbFetchColorName = DeclaredColorOutputName();
-        }
-        return fbFetchColorName;
-    } else {
-        return kDstTextureColorName;
-    } 
-}
-
-void GrGLFragmentShaderBuilder::enableAdvancedBlendEquationIfNeeded(GrBlendEquation equation) {
-    SkASSERT(GrBlendEquationIsAdvanced(equation));
-
-    const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
-    if (!caps.mustEnableAdvBlendEqs()) {
-        return;
-    }
-
-    this->addFeature(1 << kBlendEquationAdvanced_GLSLPrivateFeature,
-                     "GL_KHR_blend_equation_advanced");
-    if (caps.mustEnableSpecificAdvBlendEqs()) {
-        this->addLayoutQualifier(specific_layout_qualifier_name(equation), kOut_InterfaceQualifier);
-    } else {
-        this->addLayoutQualifier("blend_support_all_equations", kOut_InterfaceQualifier);
-    }
-}
-
-void GrGLFragmentShaderBuilder::enableCustomOutput() {
-    if (!fHasCustomColorOutput) {
-        fHasCustomColorOutput = true;
-        fCustomColorOutputIndex = fOutputs.count();
-        fOutputs.push_back().set(kVec4f_GrSLType,
-                                 GrGLSLShaderVar::kOut_TypeModifier,
-                                 DeclaredColorOutputName());
-    }
-}
-
-void GrGLFragmentShaderBuilder::enableSecondaryOutput() {
-    SkASSERT(!fHasSecondaryOutput);
-    fHasSecondaryOutput = true;
-    const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
-    if (const char* extension = caps.secondaryOutputExtensionString()) {
-        this->addFeature(1 << kBlendFuncExtended_GLSLPrivateFeature, extension);
-    }
-
-    // If the primary output is declared, we must declare also the secondary output
-    // and vice versa, since it is not allowed to use a built-in gl_FragColor and a custom
-    // output. The condition also co-incides with the condition in whici GLES SL 2.0
-    // requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a custom output.
-    if (caps.mustDeclareFragmentShaderOutput()) {
-        fOutputs.push_back().set(kVec4f_GrSLType, GrGLSLShaderVar::kOut_TypeModifier,
-                                 DeclaredSecondaryColorOutputName());
-    }
-}
-
-const char* GrGLFragmentShaderBuilder::getPrimaryColorOutputName() const {
-    return fHasCustomColorOutput ? DeclaredColorOutputName() : "gl_FragColor";
-}
-
-const char* GrGLFragmentShaderBuilder::getSecondaryColorOutputName() const {
-    const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
-    return caps.mustDeclareFragmentShaderOutput() ? DeclaredSecondaryColorOutputName()
-                                                  : "gl_SecondaryFragColorEXT";
-}
-
-void GrGLFragmentShaderBuilder::onFinalize() {
-    GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision,
-                                                 *fProgramBuilder->glslCaps(),
-                                                 &this->precisionQualifier());
-}
-
-void GrGLFragmentShaderBuilder::addVarying(GrGLSLVarying* v, GrSLPrecision fsPrec) {
-    v->fFsIn = v->fVsOut;
-    if (v->fGsOut) {
-        v->fFsIn = v->fGsOut;
-    }
-    fInputs.push_back().set(v->fType, GrGLSLShaderVar::kVaryingIn_TypeModifier, v->fFsIn, fsPrec);
-}
-
-void GrGLFragmentBuilder::onBeforeChildProcEmitCode() {
-    SkASSERT(fSubstageIndices.count() >= 1);
-    fSubstageIndices.push_back(0);
-    // second-to-last value in the fSubstageIndices stack is the index of the child proc
-    // at that level which is currently emitting code.
-    fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2]);
-}
-
-void GrGLFragmentBuilder::onAfterChildProcEmitCode() {
-    SkASSERT(fSubstageIndices.count() >= 2);
-    fSubstageIndices.pop_back();
-    fSubstageIndices.back()++;
-    int removeAt = fMangleString.findLastOf('_');
-    fMangleString.remove(removeAt, fMangleString.size() - removeAt);
-}
-
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
deleted file mode 100644 (file)
index 16cc8cf..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGLFragmentShaderBuilder_DEFINED
-#define GrGLFragmentShaderBuilder_DEFINED
-
-#include "GrGLShaderBuilder.h"
-
-#include "glsl/GrGLSLProcessorTypes.h"
-
-class GrRenderTarget;
-class GrGLSLVarying;
-
-/*
- * This base class encapsulates the functionality which the GP uses to build fragment shaders
- */
-class GrGLFragmentBuilder : public GrGLShaderBuilder {
-public:
-    GrGLFragmentBuilder(GrGLSLProgramBuilder* program)
-        : INHERITED(program)
-        , fHasCustomColorOutput(false)
-        , fHasSecondaryOutput(false) {
-        fSubstageIndices.push_back(0);
-    }
-    virtual ~GrGLFragmentBuilder() {}
-    /**
-     * Use of these features may require a GLSL extension to be enabled. Shaders may not compile
-     * if code is added that uses one of these features without calling enableFeature()
-     */
-    enum GLSLFeature {
-        kStandardDerivatives_GLSLFeature = 0,
-        kLastGLSLFeature = kStandardDerivatives_GLSLFeature
-    };
-
-    /**
-     * If the feature is supported then true is returned and any necessary #extension declarations
-     * are added to the shaders. If the feature is not supported then false will be returned.
-     */
-    virtual bool enableFeature(GLSLFeature) = 0;
-
-    /**
-     * This returns a variable name to access the 2D, perspective correct version of the coords in
-     * the fragment shader. If the coordinates at index are 3-dimensional, it immediately emits a
-     * perspective divide into the fragment shader (xy / z) to convert them to 2D.
-     */
-    virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords, int index) = 0;
-
-
-    /** Returns a variable name that represents the position of the fragment in the FS. The position
-        is in device space (e.g. 0,0 is the top left and pixel centers are at half-integers). */
-    virtual const char* fragmentPosition() = 0;
-
-    /**
-     * Fragment procs with child procs should call these functions before/after calling emitCode
-     * on a child proc.
-     */
-    void onBeforeChildProcEmitCode();
-    void onAfterChildProcEmitCode();
-
-    const SkString& getMangleString() const { return fMangleString; }
-
-    bool hasCustomColorOutput() const { return fHasCustomColorOutput; }
-    bool hasSecondaryOutput() const { return fHasSecondaryOutput; }
-
-protected:
-    bool fHasCustomColorOutput;
-    bool fHasSecondaryOutput;
-
-private:
-    /*
-     * State that tracks which child proc in the proc tree is currently emitting code.  This is
-     * used to update the fMangleString, which is used to mangle the names of uniforms and functions
-     * emitted by the proc.  fSubstageIndices is a stack: its count indicates how many levels deep
-     * we are in the tree, and its second-to-last value is the index of the child proc at that
-     * level which is currently emitting code. For example, if fSubstageIndices = [3, 1, 2, 0], that
-     * means we're currently emitting code for the base proc's 3rd child's 1st child's 2nd child.
-     */
-    SkTArray<int> fSubstageIndices;
-
-    /*
-     * The mangle string is used to mangle the names of uniforms/functions emitted by the child
-     * procs so no duplicate uniforms/functions appear in the generated shader program. The mangle
-     * string is simply based on fSubstageIndices. For example, if fSubstageIndices = [3, 1, 2, 0],
-     * then the manglestring will be "_c3_c1_c2", and any uniform/function emitted by that proc will
-     * have "_c3_c1_c2" appended to its name, which can be interpreted as "base proc's 3rd child's
-     * 1st child's 2nd child".
-     */
-    SkString fMangleString;
-
-    friend class GrGLPathProcessor;
-
-    typedef GrGLShaderBuilder INHERITED;
-};
-
-/*
- * Fragment processor's, in addition to all of the above, may need to use dst color so they use
- * this builder to create their shader.  Because this is the only shader builder the FP sees, we
- * just call it FPShaderBuilder
- */
-class GrGLXPFragmentBuilder : public GrGLFragmentBuilder {
-public:
-    GrGLXPFragmentBuilder(GrGLSLProgramBuilder* program) : INHERITED(program) {}
-
-    /** Returns the variable name that holds the color of the destination pixel. This may be nullptr if
-        no effect advertised that it will read the destination. */
-    virtual const char* dstColor() = 0;
-
-    /** Adds any necessary layout qualifiers in order to legalize the supplied blend equation with
-        this shader. It is only legal to call this method with an advanced blend equation, and only
-        if these equations are supported. */
-    virtual void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) = 0;
-
-private:
-    typedef GrGLFragmentBuilder INHERITED;
-};
-
-// TODO rename to Fragment Builder
-class GrGLFragmentShaderBuilder : public GrGLXPFragmentBuilder {
-public:
-    typedef uint8_t FragPosKey;
-
-    /** Returns a key for reading the fragment location. This should only be called if there is an
-       effect that will requires the fragment position. If the fragment position is not required,
-       the key is 0. */
-    static FragPosKey KeyForFragmentPosition(const GrRenderTarget* dst);
-
-    GrGLFragmentShaderBuilder(GrGLSLProgramBuilder* program, uint8_t fragPosKey);
-
-    // true public interface, defined explicitly in the abstract interfaces above
-    bool enableFeature(GLSLFeature) override;
-    virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords,
-                                      int index) override;
-    const char* fragmentPosition() override;
-    const char* dstColor() override;
-
-    void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override;
-
-private:
-    // Private public interface, used by GrGLProgramBuilder to build a fragment shader
-    void enableCustomOutput();
-    void enableSecondaryOutput();
-    const char* getPrimaryColorOutputName() const;
-    const char* getSecondaryColorOutputName() const;
-
-    // As GLProcessors emit code, there are some conditions we need to verify.  We use the below
-    // state to track this.  The reset call is called per processor emitted.
-    bool hasReadDstColor() const { return fHasReadDstColor; }
-    bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; }
-    void reset() {
-        fHasReadDstColor = false;
-        fHasReadFragmentPosition = false;
-    }
-
-    static const char* DeclaredColorOutputName() { return "fsColorOut"; }
-    static const char* DeclaredSecondaryColorOutputName() { return "fsSecondaryColorOut"; }
-
-    /*
-     * An internal call for GrGLProgramBuilder to use to add varyings to the vertex shader
-     */
-    void addVarying(GrGLSLVarying*, GrSLPrecision);
-
-    void onFinalize() override;
-
-    /**
-     * Features that should only be enabled by GrGLFragmentShaderBuilder itself.
-     */
-    enum GLSLPrivateFeature {
-        kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1,
-        kBlendEquationAdvanced_GLSLPrivateFeature,
-        kBlendFuncExtended_GLSLPrivateFeature,
-        kLastGLSLPrivateFeature = kBlendFuncExtended_GLSLPrivateFeature
-    };
-
-    // Interpretation of FragPosKey when generating code
-    enum {
-        kNoFragPosRead_FragPosKey           = 0,  // The fragment positition will not be needed.
-        kTopLeftFragPosRead_FragPosKey      = 0x1,// Read frag pos relative to top-left.
-        kBottomLeftFragPosRead_FragPosKey   = 0x2,// Read frag pos relative to bottom-left.
-    };
-
-    static const char* kDstTextureColorName;
-
-    bool fSetupFragPosition;
-    bool fTopLeftFragPosRead;
-    int  fCustomColorOutputIndex;
-
-    // some state to verify shaders and effects are consistent, this is reset between effects by
-    // the program creator
-    bool fHasReadDstColor;
-    bool fHasReadFragmentPosition;
-
-    friend class GrGLProgramBuilder;
-
-    typedef GrGLXPFragmentBuilder INHERITED;
-};
-
-#endif
diff --git a/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp b/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp
deleted file mode 100644 (file)
index 420c513..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrGLGeometryShaderBuilder.h"
-#include "GrGLProgramBuilder.h"
-#include "../GrGLGpu.h"
-
-GrGLGeometryBuilder::GrGLGeometryBuilder(GrGLSLProgramBuilder* program)
-    : INHERITED(program) {
-
-}
-
-void GrGLGeometryBuilder::addVarying(const char* name, GrSLPrecision precision, GrGLSLVarying* v) {
-    // if we have a GS take each varying in as an array
-    // and output as non-array.
-    if (v->vsVarying()) {
-        fInputs.push_back();
-        fInputs.back().setType(v->fType);
-        fInputs.back().setTypeModifier(GrGLSLShaderVar::kVaryingIn_TypeModifier);
-        fInputs.back().setPrecision(precision);
-        fInputs.back().setUnsizedArray();
-        *fInputs.back().accessName() = v->fVsOut;
-        v->fGsIn = v->fVsOut;
-    }
-
-    if (v->fsVarying()) {
-        fOutputs.push_back();
-        fOutputs.back().setType(v->fType);
-        fOutputs.back().setTypeModifier(GrGLSLShaderVar::kVaryingOut_TypeModifier);
-        fOutputs.back().setPrecision(precision);
-        fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'g', name);
-        v->fGsOut = fOutputs.back().getName().c_str();
-    }
-}
-
diff --git a/src/gpu/gl/builders/GrGLGeometryShaderBuilder.h b/src/gpu/gl/builders/GrGLGeometryShaderBuilder.h
deleted file mode 100644 (file)
index e807646..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGLGeometryShaderBuilder_DEFINED
-#define GrGLGeometryShaderBuilder_DEFINED
-
-#include "GrGLShaderBuilder.h"
-
-class GrGLSLVarying;
-
-class GrGLGeometryBuilder : public GrGLShaderBuilder {
-public:
-    GrGLGeometryBuilder(GrGLSLProgramBuilder* program);
-
-private:
-    /*
-     * an internal call for GrGLFullProgramBuilder to add varyings
-     */
-    void addVarying(const char* name, GrSLPrecision precision, GrGLSLVarying*);
-
-    void onFinalize() override {}
-
-    friend class GrGLProgramBuilder;
-
-    typedef GrGLShaderBuilder INHERITED;
-};
-
-#endif
index d336ff1f0d9ae4ac14c930efb3da05b065cc18ea..67ba08339b89387c8a84dd53f4c05d9e14df24e2 100644 (file)
@@ -356,7 +356,7 @@ void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor,
     }
 }
 
-bool GrGLProgramBuilder::compileAndAttachShaders(GrGLShaderBuilder& shader,
+bool GrGLProgramBuilder::compileAndAttachShaders(GrGLSLShaderBuilder& shader,
                                                  GrGLuint programId,
                                                  GrGLenum type,
                                                  SkTDArray<GrGLuint>* shaderIds) {
@@ -442,11 +442,11 @@ void GrGLProgramBuilder::bindProgramResourceLocations(GrGLuint programID) {
     const GrGLCaps& caps = this->gpu()->glCaps();
     if (fFS.hasCustomColorOutput() && caps.bindFragDataLocationSupport()) {
         GL_CALL(BindFragDataLocation(programID, 0,
-                                     GrGLFragmentShaderBuilder::DeclaredColorOutputName()));
+                                     GrGLSLFragmentShaderBuilder::DeclaredColorOutputName()));
     }
     if (fFS.hasSecondaryOutput() && caps.glslCaps()->mustDeclareFragmentShaderOutput()) {
         GL_CALL(BindFragDataLocationIndexed(programID, 0, 1,
-                                    GrGLFragmentShaderBuilder::DeclaredSecondaryColorOutputName()));
+                                  GrGLSLFragmentShaderBuilder::DeclaredSecondaryColorOutputName()));
     }
 
     // handle NVPR separable varyings
index c524f59e01910ac9bd0e78ded54872609a5528a3..21724c19f2383c0104328e3cbcb21230403ac3c7 100644 (file)
 
 class GrFragmentProcessor;
 class GrGLContextInfo;
-class GrGLShaderBuilder;
+class GrGLSLShaderBuilder;
 class GrGLSLCaps;
 
-// Enough precision to represent 1 / 2048 accurately in printf
-#define GR_SIGNIFICANT_POW2_DECIMAL_DIG 11
-
 /**
  * The below struct represent processors installed in programs.
  */
@@ -135,7 +132,7 @@ private:
                       GrGLSLTextureSampler::TextureSamplerArray* outSamplers,
                       GrGLInstalledProc<Proc>*);
 
-    bool compileAndAttachShaders(GrGLShaderBuilder& shader,
+    bool compileAndAttachShaders(GrGLSLShaderBuilder& shader,
                                  GrGLuint programId,
                                  GrGLenum type,
                                  SkTDArray<GrGLuint>* shaderIds); 
@@ -184,10 +181,10 @@ private:
     SkTArray<UniformHandle> fSamplerUniforms;
     SeparableVaryingInfoArray fSeparableVaryingInfos;
 
-    friend class GrGLShaderBuilder;
-    friend class GrGLVertexBuilder;
-    friend class GrGLFragmentShaderBuilder;
-    friend class GrGLGeometryBuilder;
+    friend class GrGLSLShaderBuilder;
+    friend class GrGLSLVertexBuilder;
+    friend class GrGLSLFragmentShaderBuilder;
+    friend class GrGLSLGeometryBuilder;
 
    typedef GrGLSLProgramBuilder INHERITED; 
 };
diff --git a/src/gpu/gl/builders/GrGLShaderBuilder.cpp b/src/gpu/gl/builders/GrGLShaderBuilder.cpp
deleted file mode 100644 (file)
index ed5c3d4..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrGLShaderBuilder.h"
-#include "glsl/GrGLSLCaps.h"
-#include "glsl/GrGLSLShaderVar.h"
-#include "glsl/GrGLSLTextureSampler.h"
-#include "glsl/GrGLSLProgramBuilder.h"
-
-static void map_swizzle(const char* swizzleMap, const char* swizzle, char* mangledSwizzle) {
-    int i;
-    for (i = 0; '\0' != swizzle[i]; ++i) {
-        switch (swizzle[i]) {
-            case 'r':
-                mangledSwizzle[i] = swizzleMap[0];
-                break;
-            case 'g':
-                mangledSwizzle[i] = swizzleMap[1];
-                break;
-            case 'b':
-                mangledSwizzle[i] = swizzleMap[2];
-                break;
-            case 'a':
-                mangledSwizzle[i] = swizzleMap[3];
-                break;
-            default:
-                SkFAIL("Unsupported swizzle");
-        }
-    }
-    mangledSwizzle[i] ='\0';
-}
-
-static void append_texture_lookup(SkString* out,
-                                  const GrGLSLCaps* glslCaps,
-                                  const char* samplerName,
-                                  const char* coordName,
-                                  GrPixelConfig config,
-                                  const char* swizzle,
-                                  GrSLType varyingType = kVec2f_GrSLType) {
-    SkASSERT(coordName);
-
-    out->appendf("%s(%s, %s)",
-                 GrGLSLTexture2DFunctionName(varyingType, glslCaps->generation()),
-                 samplerName,
-                 coordName);
-
-    char mangledSwizzle[5];
-
-    // This refers to any swizzling we may need to get from some backend internal format to the
-    // format used in GrPixelConfig. Some backends will automatically do the sizzling for us.
-    if (glslCaps->mustSwizzleInShader()) {
-        const char* swizzleMap = glslCaps->getSwizzleMap(config);
-        // if the map is simply 'rgba' then we don't need to do any manual swizzling to get us to
-        // a GrPixelConfig format.
-        if (memcmp(swizzleMap, "rgba", 4)) {
-            // Manually 'swizzle' the swizzle using our mapping
-            map_swizzle(swizzleMap, swizzle, mangledSwizzle);
-            swizzle = mangledSwizzle;
-        }
-    }
-
-    // For shader prettiness we omit the swizzle rather than appending ".rgba".
-    if (memcmp(swizzle, "rgba", 4)) {
-        out->appendf(".%s", swizzle);
-    }
-}
-
-GrGLShaderBuilder::GrGLShaderBuilder(GrGLSLProgramBuilder* program)
-    : fProgramBuilder(program)
-    , fInputs(GrGLSLProgramBuilder::kVarsPerBlock)
-    , fOutputs(GrGLSLProgramBuilder::kVarsPerBlock)
-    , fFeaturesAddedMask(0)
-    , fCodeIndex(kCode)
-    , fFinalized(false) {
-    // We push back some dummy pointers which will later become our header
-    for (int i = 0; i <= kCode; i++) {
-        fShaderStrings.push_back();
-        fCompilerStrings.push_back(nullptr);
-        fCompilerStringLengths.push_back(0);
-    }
-
-    this->main() = "void main() {";
-}
-
-void GrGLShaderBuilder::declAppend(const GrGLSLShaderVar& var) {
-    SkString tempDecl;
-    var.appendDecl(fProgramBuilder->glslCaps(), &tempDecl);
-    this->codeAppendf("%s;", tempDecl.c_str());
-}
-
-void GrGLShaderBuilder::emitFunction(GrSLType returnType,
-                                     const char* name,
-                                     int argCnt,
-                                     const GrGLSLShaderVar* args,
-                                     const char* body,
-                                     SkString* outName) {
-    this->functions().append(GrGLSLTypeString(returnType));
-    fProgramBuilder->nameVariable(outName, '\0', name);
-    this->functions().appendf(" %s", outName->c_str());
-    this->functions().append("(");
-    for (int i = 0; i < argCnt; ++i) {
-        args[i].appendDecl(fProgramBuilder->glslCaps(), &this->functions());
-        if (i < argCnt - 1) {
-            this->functions().append(", ");
-        }
-    }
-    this->functions().append(") {\n");
-    this->functions().append(body);
-    this->functions().append("}\n\n");
-}
-
-void GrGLShaderBuilder::appendTextureLookup(SkString* out,
-                                            const GrGLSLTextureSampler& sampler,
-                                            const char* coordName,
-                                            GrSLType varyingType) const {
-    append_texture_lookup(out,
-                          fProgramBuilder->glslCaps(),
-                          fProgramBuilder->getUniformCStr(sampler.fSamplerUniform),
-                          coordName,
-                          sampler.config(),
-                          sampler.swizzle(),
-                          varyingType);
-}
-
-void GrGLShaderBuilder::appendTextureLookup(const GrGLSLTextureSampler& sampler,
-                                            const char* coordName,
-                                            GrSLType varyingType) {
-    this->appendTextureLookup(&this->code(), sampler, coordName, varyingType);
-}
-
-void GrGLShaderBuilder::appendTextureLookupAndModulate(const char* modulation,
-                                                       const GrGLSLTextureSampler& sampler,
-                                                       const char* coordName,
-                                                       GrSLType varyingType) {
-    SkString lookup;
-    this->appendTextureLookup(&lookup, sampler, coordName, varyingType);
-    this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str());
-}
-
-void GrGLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionName) {
-    if (!(featureBit & fFeaturesAddedMask)) {
-        this->extensions().appendf("#extension %s: require\n", extensionName);
-        fFeaturesAddedMask |= featureBit;
-    }
-}
-
-void GrGLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const {
-    for (int i = 0; i < vars.count(); ++i) {
-        vars[i].appendDecl(fProgramBuilder->glslCaps(), out);
-        out->append(";\n");
-    }
-}
-
-void GrGLShaderBuilder::addLayoutQualifier(const char* param, InterfaceQualifier interface) {
-    SkASSERT(fProgramBuilder->glslCaps()->generation() >= k330_GrGLSLGeneration ||
-             fProgramBuilder->glslCaps()->mustEnableAdvBlendEqs());
-    fLayoutParams[interface].push_back() = param;
-}
-
-void GrGLShaderBuilder::compileAndAppendLayoutQualifiers() {
-    static const char* interfaceQualifierNames[] = {
-        "out"
-    };
-
-    for (int interface = 0; interface <= kLastInterfaceQualifier; ++interface) {
-        const SkTArray<SkString>& params = fLayoutParams[interface];
-        if (params.empty()) {
-            continue;
-        }
-        this->layoutQualifiers().appendf("layout(%s", params[0].c_str());
-        for (int i = 1; i < params.count(); ++i) {
-            this->layoutQualifiers().appendf(", %s", params[i].c_str());
-        }
-        this->layoutQualifiers().appendf(") %s;\n", interfaceQualifierNames[interface]);
-    }
-
-    GR_STATIC_ASSERT(0 == GrGLShaderBuilder::kOut_InterfaceQualifier);
-    GR_STATIC_ASSERT(SK_ARRAY_COUNT(interfaceQualifierNames) == kLastInterfaceQualifier + 1);
-}
-
-void GrGLShaderBuilder::finalize(uint32_t visibility) {
-    SkASSERT(!fFinalized);
-    this->versionDecl() = fProgramBuilder->glslCaps()->versionDeclString();
-    this->compileAndAppendLayoutQualifiers();
-    SkASSERT(visibility);
-    fProgramBuilder->appendUniformDecls((GrGLSLProgramBuilder::ShaderVisibility) visibility,
-                                        &this->uniforms());
-    this->appendDecls(fInputs, &this->inputs());
-    // We should not have any outputs in the fragment shader when using version 1.10
-    SkASSERT(GrGLSLProgramBuilder::kFragment_Visibility != visibility ||
-             k110_GrGLSLGeneration != fProgramBuilder->glslCaps()->generation() ||
-             fOutputs.empty());
-    this->appendDecls(fOutputs, &this->outputs());
-    this->onFinalize();
-    // append the 'footer' to code
-    this->code().append("}");
-
-    for (int i = 0; i <= fCodeIndex; i++) {
-        fCompilerStrings[i] = fShaderStrings[i].c_str();
-        fCompilerStringLengths[i] = (int)fShaderStrings[i].size();
-    }
-
-    fFinalized = true;
-}
-
diff --git a/src/gpu/gl/builders/GrGLShaderBuilder.h b/src/gpu/gl/builders/GrGLShaderBuilder.h
deleted file mode 100644 (file)
index 2978db3..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGLShaderBuilder_DEFINED
-#define GrGLShaderBuilder_DEFINED
-
-#include "GrAllocator.h"
-#include "glsl/GrGLSLShaderVar.h"
-#include "SkTDArray.h"
-
-#include <stdarg.h>
-
-class GrGLSLProgramBuilder;
-class GrGLSLTextureSampler;
-
-/**
-  base class for all shaders builders
-*/
-class GrGLShaderBuilder {
-public:
-    GrGLShaderBuilder(GrGLSLProgramBuilder* program);
-    virtual ~GrGLShaderBuilder() {}
-
-    void addInput(const GrGLSLShaderVar& input) { fInputs.push_back(input); }
-    void addOutput(const GrGLSLShaderVar& output) { fOutputs.push_back(output); }
-
-    /*
-     * We put texture lookups in the base class because it is TECHNICALLY possible to do texture
-     * lookups in any kind of shader.  However, for the time being using these calls on non-fragment
-     * shaders will result in a shader compilation error as texture sampler uniforms are only
-     * visible to the fragment shader.  It would not be hard to change this behavior, if someone
-     * actually wants to do texture lookups in a non-fragment shader
-     *
-     * TODO if append texture lookup is used on a non-fragment shader, sampler uniforms should be
-     * made visible to that shaders
-     */
-    /** Appends a 2D texture sample with projection if necessary. coordType must either be Vec2f or
-        Vec3f. The latter is interpreted as projective texture coords. The vec length and swizzle
-        order of the result depends on the GrTextureAccess associated with the GrGLSLTextureSampler.
-        */
-    void appendTextureLookup(SkString* out,
-                             const GrGLSLTextureSampler&,
-                             const char* coordName,
-                             GrSLType coordType = kVec2f_GrSLType) const;
-
-    /** Version of above that appends the result to the fragment shader code instead.*/
-    void appendTextureLookup(const GrGLSLTextureSampler&,
-                             const char* coordName,
-                             GrSLType coordType = kVec2f_GrSLType);
-
-
-    /** Does the work of appendTextureLookup and modulates the result by modulation. The result is
-        always a vec4. modulation and the swizzle specified by GrGLSLTextureSampler must both be
-        vec4 or float. If modulation is "" or nullptr it this function acts as though
-        appendTextureLookup were called. */
-    void appendTextureLookupAndModulate(const char* modulation,
-                                        const GrGLSLTextureSampler&,
-                                        const char* coordName,
-                                        GrSLType coordType = kVec2f_GrSLType);
-
-    /**
-    * Called by GrGLProcessors to add code to one of the shaders.
-    */
-    void codeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
-       va_list args;
-       va_start(args, format);
-       this->code().appendVAList(format, args);
-       va_end(args);
-    }
-
-    void codeAppend(const char* str) { this->code().append(str); }
-
-    void codePrependf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
-       va_list args;
-       va_start(args, format);
-       this->code().prependVAList(format, args);
-       va_end(args);
-    }
-
-    /**
-     * Appends a variable declaration to one of the shaders
-     */
-    void declAppend(const GrGLSLShaderVar& var);
-
-    /** Emits a helper function outside of main() in the fragment shader. */
-    void emitFunction(GrSLType returnType,
-                      const char* name,
-                      int argCnt,
-                      const GrGLSLShaderVar* args,
-                      const char* body,
-                      SkString* outName);
-
-    /*
-     * Combines the various parts of the shader to create a single finalized shader string.
-     */
-    void finalize(uint32_t visibility);
-
-    /*
-     * Get parent builder for adding uniforms
-     */
-    GrGLSLProgramBuilder* getProgramBuilder() { return fProgramBuilder; }
-
-    /**
-     * Helper for begining and ending a block in the shader code.
-     */
-    class ShaderBlock {
-    public:
-        ShaderBlock(GrGLShaderBuilder* builder) : fBuilder(builder) {
-            SkASSERT(builder);
-            fBuilder->codeAppend("{");
-        }
-
-        ~ShaderBlock() {
-            fBuilder->codeAppend("}");
-        }
-    private:
-        GrGLShaderBuilder* fBuilder;
-    };
-
-protected:
-    typedef GrTAllocator<GrGLSLShaderVar> VarArray;
-    void appendDecls(const VarArray& vars, SkString* out) const;
-
-    /*
-     * A general function which enables an extension in a shader if the feature bit is not present
-     */
-    void addFeature(uint32_t featureBit, const char* extensionName);
-
-    enum InterfaceQualifier {
-        kOut_InterfaceQualifier,
-        kLastInterfaceQualifier = kOut_InterfaceQualifier
-    };
-
-    /*
-     * A low level function to build default layout qualifiers.
-     *
-     *   e.g. layout(param1, param2, ...) out;
-     *
-     * GLSL allows default layout qualifiers for in, out, and uniform.
-     */
-    void addLayoutQualifier(const char* param, InterfaceQualifier);
-
-    void compileAndAppendLayoutQualifiers();
-
-    void nextStage() {
-        fShaderStrings.push_back();
-        fCompilerStrings.push_back(this->code().c_str());
-        fCompilerStringLengths.push_back((int)this->code().size());
-        fCodeIndex++;
-    }
-
-    SkString& versionDecl() { return fShaderStrings[kVersionDecl]; }
-    SkString& extensions() { return fShaderStrings[kExtensions]; }
-    SkString& precisionQualifier() { return fShaderStrings[kPrecisionQualifier]; }
-    SkString& layoutQualifiers() { return fShaderStrings[kLayoutQualifiers]; }
-    SkString& uniforms() { return fShaderStrings[kUniforms]; }
-    SkString& inputs() { return fShaderStrings[kInputs]; }
-    SkString& outputs() { return fShaderStrings[kOutputs]; }
-    SkString& functions() { return fShaderStrings[kFunctions]; }
-    SkString& main() { return fShaderStrings[kMain]; }
-    SkString& code() { return fShaderStrings[fCodeIndex]; }
-
-    virtual void onFinalize() = 0;
-
-    enum {
-        kVersionDecl,
-        kExtensions,
-        kPrecisionQualifier,
-        kLayoutQualifiers,
-        kUniforms,
-        kInputs,
-        kOutputs,
-        kFunctions,
-        kMain,
-        kCode,
-    };
-
-    GrGLSLProgramBuilder* fProgramBuilder;
-    SkSTArray<kCode, const char*, true> fCompilerStrings;
-    SkSTArray<kCode, int, true> fCompilerStringLengths;
-    SkSTArray<kCode, SkString> fShaderStrings;
-    SkString fCode;
-    SkString fFunctions;
-    SkString fExtensions;
-
-    VarArray fInputs;
-    VarArray fOutputs;
-    uint32_t fFeaturesAddedMask;
-    SkSTArray<1, SkString> fLayoutParams[kLastInterfaceQualifier + 1];
-    int fCodeIndex;
-    bool fFinalized;
-
-    friend class GrGLProgramBuilder;
-    friend class GrGLPathProgramBuilder; // to access fInputs.
-};
-#endif
diff --git a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
deleted file mode 100644 (file)
index c4054e2..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrGLVertexShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
-
-GrGLVertexBuilder::GrGLVertexBuilder(GrGLSLProgramBuilder* program)
-    : INHERITED(program)
-    , fRtAdjustName(nullptr) {
-}
-
-void GrGLVertexBuilder::addVarying(const char* name, GrSLPrecision precision, GrGLSLVarying* v) {
-    fOutputs.push_back();
-    fOutputs.back().setType(v->fType);
-    fOutputs.back().setTypeModifier(GrGLSLShaderVar::kVaryingOut_TypeModifier);
-    fOutputs.back().setPrecision(precision);
-    fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'v', name);
-    v->fVsOut = fOutputs.back().getName().c_str();
-}
-
-void GrGLVertexBuilder::emitAttributes(const GrGeometryProcessor& gp) {
-    int vaCount = gp.numAttribs();
-    for (int i = 0; i < vaCount; i++) {
-        this->addAttribute(&gp.getAttrib(i));
-    }
-    return;
-}
-
-void GrGLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& posVar) {
-    SkASSERT(!fRtAdjustName);
-
-    GrSLPrecision precision = kDefault_GrSLPrecision;
-    if (fProgramBuilder->glslCaps()->forceHighPrecisionNDSTransform()) {
-        precision = kHigh_GrSLPrecision;
-    }
-
-    // setup RT Uniform
-    fProgramBuilder->fUniformHandles.fRTAdjustmentUni =
-            fProgramBuilder->addUniform(GrGLSLProgramBuilder::kVertex_Visibility,
-                                        kVec4f_GrSLType, precision,
-                                        fProgramBuilder->rtAdjustment(),
-                                        &fRtAdjustName);
-    if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters) {
-        if (kVec3f_GrSLType == posVar.getType()) {
-            const char* p = posVar.c_str();
-            this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p);
-        } else {
-            SkASSERT(kVec2f_GrSLType == posVar.getType());
-            this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str());
-        }
-        this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);"
-                          "gl_Position = vec4(_posTmp.x * %s.x + %s.y,"
-                                             "_posTmp.y * %s.z + %s.w, 0, 1);}",
-                          fRtAdjustName, fRtAdjustName, fRtAdjustName, fRtAdjustName);
-    } else if (kVec3f_GrSLType == posVar.getType()) {
-        this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
-                          posVar.c_str(), fRtAdjustName,
-                          posVar.c_str(), fRtAdjustName,
-                          posVar.c_str());
-    } else {
-        SkASSERT(kVec2f_GrSLType == posVar.getType());
-        this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
-                          posVar.c_str(), fRtAdjustName, fRtAdjustName,
-                          posVar.c_str(), fRtAdjustName, fRtAdjustName);
-    }
-    // We could have the GrGeometryProcessor do this, but its just easier to have it performed
-    // here. If we ever need to set variable pointsize, then we can reinvestigate
-    this->codeAppend("gl_PointSize = 1.0;");
-}
-
-bool GrGLVertexBuilder::addAttribute(const GrShaderVar& var) {
-    SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier());
-    for (int i = 0; i < fInputs.count(); ++i) {
-        const GrGLSLShaderVar& attr = fInputs[i];
-        // if attribute already added, don't add it again
-        if (attr.getName().equals(var.getName())) {
-            return false;
-        }
-    }
-    fInputs.push_back(var);
-    return true;
-}
-
diff --git a/src/gpu/gl/builders/GrGLVertexShaderBuilder.h b/src/gpu/gl/builders/GrGLVertexShaderBuilder.h
deleted file mode 100644 (file)
index 4662c40..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGLVertexShader_DEFINED
-#define GrGLVertexShader_DEFINED
-
-#include "GrGLShaderBuilder.h"
-#include "GrGeometryProcessor.h"
-
-class GrGLSLVarying;
-
-class GrGLVertexBuilder : public GrGLShaderBuilder {
-public:
-    GrGLVertexBuilder(GrGLSLProgramBuilder* program);
-
-    void transformToNormalizedDeviceSpace(const GrShaderVar& posVar);
-    void emitAttributes(const GrGeometryProcessor& gp);
-
-    void addAttribute(const GrGeometryProcessor::Attribute* attr) {
-        this->addAttribute(GrShaderVar(attr->fName,
-                                       GrVertexAttribTypeToSLType(attr->fType),
-                                       GrShaderVar::kAttribute_TypeModifier,
-                                       GrShaderVar::kNonArray,
-                                       attr->fPrecision));
-    }
-
-private:
-    /*
-     * Internal call for GrGLProgramBuilder.addVarying
-     */
-    void addVarying(const char* name, GrSLPrecision, GrGLSLVarying*);
-
-    // an internal call which checks for uniquness of a var before adding it to the list of inputs
-    bool addAttribute(const GrShaderVar& var);
-
-    void onFinalize() override {}
-    
-    const char* fRtAdjustName;
-
-    friend class GrGLProgramBuilder;
-
-    typedef GrGLShaderBuilder INHERITED;
-};
-
-#endif
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
new file mode 100644 (file)
index 0000000..5a3e09d
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrGLSLFragmentShaderBuilder.h"
+#include "GrRenderTarget.h"
+#include "glsl/GrGLSL.h"
+#include "glsl/GrGLSLCaps.h"
+#include "glsl/GrGLSLProgramBuilder.h"
+
+const char* GrGLSLFragmentShaderBuilder::kDstTextureColorName = "_dstColor";
+
+static const char* specific_layout_qualifier_name(GrBlendEquation equation) {
+    SkASSERT(GrBlendEquationIsAdvanced(equation));
+
+    static const char* kLayoutQualifierNames[] = {
+        "blend_support_screen",
+        "blend_support_overlay",
+        "blend_support_darken",
+        "blend_support_lighten",
+        "blend_support_colordodge",
+        "blend_support_colorburn",
+        "blend_support_hardlight",
+        "blend_support_softlight",
+        "blend_support_difference",
+        "blend_support_exclusion",
+        "blend_support_multiply",
+        "blend_support_hsl_hue",
+        "blend_support_hsl_saturation",
+        "blend_support_hsl_color",
+        "blend_support_hsl_luminosity"
+    };
+    return kLayoutQualifierNames[equation - kFirstAdvancedGrBlendEquation];
+
+    GR_STATIC_ASSERT(0 == kScreen_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(1 == kOverlay_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(2 == kDarken_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(3 == kLighten_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(4 == kColorDodge_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(5 == kColorBurn_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(6 == kHardLight_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(7 == kSoftLight_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(8 == kDifference_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(9 == kExclusion_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(10 == kMultiply_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(11 == kHSLHue_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(12 == kHSLSaturation_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(13 == kHSLColor_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(14 == kHSLLuminosity_GrBlendEquation - kFirstAdvancedGrBlendEquation);
+    GR_STATIC_ASSERT(SK_ARRAY_COUNT(kLayoutQualifierNames) ==
+                     kGrBlendEquationCnt - kFirstAdvancedGrBlendEquation);
+}
+
+GrGLSLFragmentShaderBuilder::FragPosKey
+GrGLSLFragmentShaderBuilder::KeyForFragmentPosition(const GrRenderTarget* dst) {
+    if (kTopLeft_GrSurfaceOrigin == dst->origin()) {
+        return kTopLeftFragPosRead_FragPosKey;
+    } else {
+        return kBottomLeftFragPosRead_FragPosKey;
+    }
+}
+
+GrGLSLFragmentShaderBuilder::GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* program,
+                                                         uint8_t fragPosKey)
+    : INHERITED(program)
+    , fSetupFragPosition(false)
+    , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == fragPosKey)
+    , fCustomColorOutputIndex(-1)
+    , fHasReadDstColor(false)
+    , fHasReadFragmentPosition(false) {
+}
+
+bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
+    switch (feature) {
+        case kStandardDerivatives_GLSLFeature: {
+            if (!fProgramBuilder->glslCaps()->shaderDerivativeSupport()) {
+                return false;
+            }
+            const char* extension = fProgramBuilder->glslCaps()->shaderDerivativeExtensionString();
+            if (extension) {
+                this->addFeature(1 << kStandardDerivatives_GLSLFeature, extension);
+            }
+            return true;
+        }
+        default:
+            SkFAIL("Unexpected GLSLFeature requested.");
+            return false;
+    }
+}
+
+SkString GrGLSLFragmentShaderBuilder::ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords,
+                                                       int index) {
+    if (kVec3f_GrSLType != coords[index].getType()) {
+        SkASSERT(kVec2f_GrSLType == coords[index].getType());
+        return coords[index].getName();
+    }
+
+    SkString coords2D("coords2D");
+    if (0 != index) {
+        coords2D.appendf("_%i", index);
+    }
+    this->codeAppendf("\tvec2 %s = %s.xy / %s.z;",
+                      coords2D.c_str(), coords[index].c_str(), coords[index].c_str());
+    return coords2D;
+}
+
+const char* GrGLSLFragmentShaderBuilder::fragmentPosition() {
+    fHasReadFragmentPosition = true;
+
+    const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
+    // We only declare "gl_FragCoord" when we're in the case where we want to use layout qualifiers
+    // to reverse y. Otherwise it isn't necessary and whether the "in" qualifier appears in the
+    // declaration varies in earlier GLSL specs. So it is simpler to omit it.
+    if (fTopLeftFragPosRead) {
+        fSetupFragPosition = true;
+        return "gl_FragCoord";
+    } else if (const char* extension = glslCaps->fragCoordConventionsExtensionString()) {
+        if (!fSetupFragPosition) {
+            if (glslCaps->generation() < k150_GrGLSLGeneration) {
+                this->addFeature(1 << kFragCoordConventions_GLSLPrivateFeature,
+                                 extension);
+            }
+            fInputs.push_back().set(kVec4f_GrSLType,
+                                    GrGLSLShaderVar::kIn_TypeModifier,
+                                    "gl_FragCoord",
+                                    kDefault_GrSLPrecision,
+                                    GrGLSLShaderVar::kUpperLeft_Origin);
+            fSetupFragPosition = true;
+        }
+        return "gl_FragCoord";
+    } else {
+        static const char* kTempName = "tmpXYFragCoord";
+        static const char* kCoordName = "fragCoordYDown";
+        if (!fSetupFragPosition) {
+            SkASSERT(!fProgramBuilder->fUniformHandles.fRTHeightUni.isValid());
+            const char* rtHeightName;
+
+            fProgramBuilder->fUniformHandles.fRTHeightUni =
+                    fProgramBuilder->addFragPosUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+                                                       kFloat_GrSLType,
+                                                       kDefault_GrSLPrecision,
+                                                       "RTHeight",
+                                                       &rtHeightName);
+
+            // The Adreno compiler seems to be very touchy about access to "gl_FragCoord".
+            // Accessing glFragCoord.zw can cause a program to fail to link. Additionally,
+            // depending on the surrounding code, accessing .xy with a uniform involved can
+            // do the same thing. Copying gl_FragCoord.xy into a temp vec2 beforehand 
+            // (and only accessing .xy) seems to "fix" things.
+            this->codePrependf("\tvec4 %s = vec4(%s.x, %s - %s.y, 1.0, 1.0);\n",
+                               kCoordName, kTempName, rtHeightName, kTempName);
+            this->codePrependf("vec2 %s = gl_FragCoord.xy;", kTempName);
+            fSetupFragPosition = true;
+        }
+        SkASSERT(fProgramBuilder->fUniformHandles.fRTHeightUni.isValid());
+        return kCoordName;
+    }
+}
+
+const char* GrGLSLFragmentShaderBuilder::dstColor() {
+    fHasReadDstColor = true;
+
+    const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
+    if (glslCaps->fbFetchSupport()) {
+        this->addFeature(1 << (GrGLSLFragmentShaderBuilder::kLastGLSLPrivateFeature + 1),
+                         glslCaps->fbFetchExtensionString());
+
+        // Some versions of this extension string require declaring custom color output on ES 3.0+
+        const char* fbFetchColorName = glslCaps->fbFetchColorName();
+        if (glslCaps->fbFetchNeedsCustomOutput()) {
+            this->enableCustomOutput();
+            fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOut_TypeModifier);
+            fbFetchColorName = DeclaredColorOutputName();
+        }
+        return fbFetchColorName;
+    } else {
+        return kDstTextureColorName;
+    } 
+}
+
+void GrGLSLFragmentShaderBuilder::enableAdvancedBlendEquationIfNeeded(GrBlendEquation equation) {
+    SkASSERT(GrBlendEquationIsAdvanced(equation));
+
+    const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
+    if (!caps.mustEnableAdvBlendEqs()) {
+        return;
+    }
+
+    this->addFeature(1 << kBlendEquationAdvanced_GLSLPrivateFeature,
+                     "GL_KHR_blend_equation_advanced");
+    if (caps.mustEnableSpecificAdvBlendEqs()) {
+        this->addLayoutQualifier(specific_layout_qualifier_name(equation), kOut_InterfaceQualifier);
+    } else {
+        this->addLayoutQualifier("blend_support_all_equations", kOut_InterfaceQualifier);
+    }
+}
+
+void GrGLSLFragmentShaderBuilder::enableCustomOutput() {
+    if (!fHasCustomColorOutput) {
+        fHasCustomColorOutput = true;
+        fCustomColorOutputIndex = fOutputs.count();
+        fOutputs.push_back().set(kVec4f_GrSLType,
+                                 GrGLSLShaderVar::kOut_TypeModifier,
+                                 DeclaredColorOutputName());
+    }
+}
+
+void GrGLSLFragmentShaderBuilder::enableSecondaryOutput() {
+    SkASSERT(!fHasSecondaryOutput);
+    fHasSecondaryOutput = true;
+    const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
+    if (const char* extension = caps.secondaryOutputExtensionString()) {
+        this->addFeature(1 << kBlendFuncExtended_GLSLPrivateFeature, extension);
+    }
+
+    // If the primary output is declared, we must declare also the secondary output
+    // and vice versa, since it is not allowed to use a built-in gl_FragColor and a custom
+    // output. The condition also co-incides with the condition in whici GLES SL 2.0
+    // requires the built-in gl_SecondaryFragColorEXT, where as 3.0 requires a custom output.
+    if (caps.mustDeclareFragmentShaderOutput()) {
+        fOutputs.push_back().set(kVec4f_GrSLType, GrGLSLShaderVar::kOut_TypeModifier,
+                                 DeclaredSecondaryColorOutputName());
+    }
+}
+
+const char* GrGLSLFragmentShaderBuilder::getPrimaryColorOutputName() const {
+    return fHasCustomColorOutput ? DeclaredColorOutputName() : "gl_FragColor";
+}
+
+const char* GrGLSLFragmentShaderBuilder::getSecondaryColorOutputName() const {
+    const GrGLSLCaps& caps = *fProgramBuilder->glslCaps();
+    return caps.mustDeclareFragmentShaderOutput() ? DeclaredSecondaryColorOutputName()
+                                                  : "gl_SecondaryFragColorEXT";
+}
+
+void GrGLSLFragmentShaderBuilder::onFinalize() {
+    GrGLSLAppendDefaultFloatPrecisionDeclaration(kDefault_GrSLPrecision,
+                                                 *fProgramBuilder->glslCaps(),
+                                                 &this->precisionQualifier());
+}
+
+void GrGLSLFragmentShaderBuilder::addVarying(GrGLSLVarying* v, GrSLPrecision fsPrec) {
+    v->fFsIn = v->fVsOut;
+    if (v->fGsOut) {
+        v->fFsIn = v->fGsOut;
+    }
+    fInputs.push_back().set(v->fType, GrGLSLShaderVar::kVaryingIn_TypeModifier, v->fFsIn, fsPrec);
+}
+
+void GrGLSLFragmentBuilder::onBeforeChildProcEmitCode() {
+    SkASSERT(fSubstageIndices.count() >= 1);
+    fSubstageIndices.push_back(0);
+    // second-to-last value in the fSubstageIndices stack is the index of the child proc
+    // at that level which is currently emitting code.
+    fMangleString.appendf("_c%d", fSubstageIndices[fSubstageIndices.count() - 2]);
+}
+
+void GrGLSLFragmentBuilder::onAfterChildProcEmitCode() {
+    SkASSERT(fSubstageIndices.count() >= 2);
+    fSubstageIndices.pop_back();
+    fSubstageIndices.back()++;
+    int removeAt = fMangleString.findLastOf('_');
+    fMangleString.remove(removeAt, fMangleString.size() - removeAt);
+}
+
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
new file mode 100644 (file)
index 0000000..b98f702
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLSLFragmentShaderBuilder_DEFINED
+#define GrGLSLFragmentShaderBuilder_DEFINED
+
+#include "GrGLSLShaderBuilder.h"
+
+#include "glsl/GrGLSLProcessorTypes.h"
+
+class GrRenderTarget;
+class GrGLSLVarying;
+
+/*
+ * This base class encapsulates the functionality which the GP uses to build fragment shaders
+ */
+class GrGLSLFragmentBuilder : public GrGLSLShaderBuilder {
+public:
+    GrGLSLFragmentBuilder(GrGLSLProgramBuilder* program)
+        : INHERITED(program)
+        , fHasCustomColorOutput(false)
+        , fHasSecondaryOutput(false) {
+        fSubstageIndices.push_back(0);
+    }
+    virtual ~GrGLSLFragmentBuilder() {}
+    /**
+     * Use of these features may require a GLSL extension to be enabled. Shaders may not compile
+     * if code is added that uses one of these features without calling enableFeature()
+     */
+    enum GLSLFeature {
+        kStandardDerivatives_GLSLFeature = 0,
+        kLastGLSLFeature = kStandardDerivatives_GLSLFeature
+    };
+
+    /**
+     * If the feature is supported then true is returned and any necessary #extension declarations
+     * are added to the shaders. If the feature is not supported then false will be returned.
+     */
+    virtual bool enableFeature(GLSLFeature) = 0;
+
+    /**
+     * This returns a variable name to access the 2D, perspective correct version of the coords in
+     * the fragment shader. If the coordinates at index are 3-dimensional, it immediately emits a
+     * perspective divide into the fragment shader (xy / z) to convert them to 2D.
+     */
+    virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords, int index) = 0;
+
+
+    /** Returns a variable name that represents the position of the fragment in the FS. The position
+        is in device space (e.g. 0,0 is the top left and pixel centers are at half-integers). */
+    virtual const char* fragmentPosition() = 0;
+
+    /**
+     * Fragment procs with child procs should call these functions before/after calling emitCode
+     * on a child proc.
+     */
+    void onBeforeChildProcEmitCode();
+    void onAfterChildProcEmitCode();
+
+    const SkString& getMangleString() const { return fMangleString; }
+
+    bool hasCustomColorOutput() const { return fHasCustomColorOutput; }
+    bool hasSecondaryOutput() const { return fHasSecondaryOutput; }
+
+protected:
+    bool fHasCustomColorOutput;
+    bool fHasSecondaryOutput;
+
+private:
+    /*
+     * State that tracks which child proc in the proc tree is currently emitting code.  This is
+     * used to update the fMangleString, which is used to mangle the names of uniforms and functions
+     * emitted by the proc.  fSubstageIndices is a stack: its count indicates how many levels deep
+     * we are in the tree, and its second-to-last value is the index of the child proc at that
+     * level which is currently emitting code. For example, if fSubstageIndices = [3, 1, 2, 0], that
+     * means we're currently emitting code for the base proc's 3rd child's 1st child's 2nd child.
+     */
+    SkTArray<int> fSubstageIndices;
+
+    /*
+     * The mangle string is used to mangle the names of uniforms/functions emitted by the child
+     * procs so no duplicate uniforms/functions appear in the generated shader program. The mangle
+     * string is simply based on fSubstageIndices. For example, if fSubstageIndices = [3, 1, 2, 0],
+     * then the manglestring will be "_c3_c1_c2", and any uniform/function emitted by that proc will
+     * have "_c3_c1_c2" appended to its name, which can be interpreted as "base proc's 3rd child's
+     * 1st child's 2nd child".
+     */
+    SkString fMangleString;
+
+    friend class GrGLPathProcessor;
+
+    typedef GrGLSLShaderBuilder INHERITED;
+};
+
+/*
+ * Fragment processor's, in addition to all of the above, may need to use dst color so they use
+ * this builder to create their shader.  Because this is the only shader builder the FP sees, we
+ * just call it FPShaderBuilder
+ */
+class GrGLSLXPFragmentBuilder : public GrGLSLFragmentBuilder {
+public:
+    GrGLSLXPFragmentBuilder(GrGLSLProgramBuilder* program) : INHERITED(program) {}
+
+    /** Returns the variable name that holds the color of the destination pixel. This may be nullptr if
+        no effect advertised that it will read the destination. */
+    virtual const char* dstColor() = 0;
+
+    /** Adds any necessary layout qualifiers in order to legalize the supplied blend equation with
+        this shader. It is only legal to call this method with an advanced blend equation, and only
+        if these equations are supported. */
+    virtual void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) = 0;
+
+private:
+    typedef GrGLSLFragmentBuilder INHERITED;
+};
+
+// TODO rename to Fragment Builder
+class GrGLSLFragmentShaderBuilder : public GrGLSLXPFragmentBuilder {
+public:
+    typedef uint8_t FragPosKey;
+
+    /** Returns a key for reading the fragment location. This should only be called if there is an
+       effect that will requires the fragment position. If the fragment position is not required,
+       the key is 0. */
+    static FragPosKey KeyForFragmentPosition(const GrRenderTarget* dst);
+
+    GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* program, uint8_t fragPosKey);
+
+    // true public interface, defined explicitly in the abstract interfaces above
+    bool enableFeature(GLSLFeature) override;
+    virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords,
+                                      int index) override;
+    const char* fragmentPosition() override;
+    const char* dstColor() override;
+
+    void enableAdvancedBlendEquationIfNeeded(GrBlendEquation) override;
+
+private:
+    // Private public interface, used by GrGLProgramBuilder to build a fragment shader
+    void enableCustomOutput();
+    void enableSecondaryOutput();
+    const char* getPrimaryColorOutputName() const;
+    const char* getSecondaryColorOutputName() const;
+
+    // As GLProcessors emit code, there are some conditions we need to verify.  We use the below
+    // state to track this.  The reset call is called per processor emitted.
+    bool hasReadDstColor() const { return fHasReadDstColor; }
+    bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; }
+    void reset() {
+        fHasReadDstColor = false;
+        fHasReadFragmentPosition = false;
+    }
+
+    static const char* DeclaredColorOutputName() { return "fsColorOut"; }
+    static const char* DeclaredSecondaryColorOutputName() { return "fsSecondaryColorOut"; }
+
+    /*
+     * An internal call for GrGLProgramBuilder to use to add varyings to the vertex shader
+     */
+    void addVarying(GrGLSLVarying*, GrSLPrecision);
+
+    void onFinalize() override;
+
+    /**
+     * Features that should only be enabled by GrGLSLFragmentShaderBuilder itself.
+     */
+    enum GLSLPrivateFeature {
+        kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1,
+        kBlendEquationAdvanced_GLSLPrivateFeature,
+        kBlendFuncExtended_GLSLPrivateFeature,
+        kLastGLSLPrivateFeature = kBlendFuncExtended_GLSLPrivateFeature
+    };
+
+    // Interpretation of FragPosKey when generating code
+    enum {
+        kNoFragPosRead_FragPosKey           = 0,  // The fragment positition will not be needed.
+        kTopLeftFragPosRead_FragPosKey      = 0x1,// Read frag pos relative to top-left.
+        kBottomLeftFragPosRead_FragPosKey   = 0x2,// Read frag pos relative to bottom-left.
+    };
+
+    static const char* kDstTextureColorName;
+
+    bool fSetupFragPosition;
+    bool fTopLeftFragPosRead;
+    int  fCustomColorOutputIndex;
+
+    // some state to verify shaders and effects are consistent, this is reset between effects by
+    // the program creator
+    bool fHasReadDstColor;
+    bool fHasReadFragmentPosition;
+
+    friend class GrGLProgramBuilder;
+
+    typedef GrGLSLXPFragmentBuilder INHERITED;
+};
+
+#endif
diff --git a/src/gpu/glsl/GrGLSLGeometryShaderBuilder.cpp b/src/gpu/glsl/GrGLSLGeometryShaderBuilder.cpp
new file mode 100644 (file)
index 0000000..275972b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrGLSLGeometryShaderBuilder.h"
+#include "GrGLSLProgramBuilder.h"
+
+GrGLSLGeometryBuilder::GrGLSLGeometryBuilder(GrGLSLProgramBuilder* program)
+    : INHERITED(program) {
+
+}
+
+void GrGLSLGeometryBuilder::addVarying(const char* name,
+                                       GrSLPrecision precision,
+                                       GrGLSLVarying* v) {
+    // if we have a GS take each varying in as an array
+    // and output as non-array.
+    if (v->vsVarying()) {
+        fInputs.push_back();
+        fInputs.back().setType(v->fType);
+        fInputs.back().setTypeModifier(GrGLSLShaderVar::kVaryingIn_TypeModifier);
+        fInputs.back().setPrecision(precision);
+        fInputs.back().setUnsizedArray();
+        *fInputs.back().accessName() = v->fVsOut;
+        v->fGsIn = v->fVsOut;
+    }
+
+    if (v->fsVarying()) {
+        fOutputs.push_back();
+        fOutputs.back().setType(v->fType);
+        fOutputs.back().setTypeModifier(GrGLSLShaderVar::kVaryingOut_TypeModifier);
+        fOutputs.back().setPrecision(precision);
+        fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'g', name);
+        v->fGsOut = fOutputs.back().getName().c_str();
+    }
+}
+
diff --git a/src/gpu/glsl/GrGLSLGeometryShaderBuilder.h b/src/gpu/glsl/GrGLSLGeometryShaderBuilder.h
new file mode 100644 (file)
index 0000000..ca24c79
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLSLGeometryShaderBuilder_DEFINED
+#define GrGLSLGeometryShaderBuilder_DEFINED
+
+#include "GrGLSLShaderBuilder.h"
+
+class GrGLSLVarying;
+
+class GrGLSLGeometryBuilder : public GrGLSLShaderBuilder {
+public:
+    GrGLSLGeometryBuilder(GrGLSLProgramBuilder* program);
+
+private:
+    /*
+     * an internal call for GrGLFullProgramBuilder to add varyings
+     */
+    void addVarying(const char* name, GrSLPrecision precision, GrGLSLVarying*);
+
+    void onFinalize() override {}
+
+    friend class GrGLProgramBuilder;
+
+    typedef GrGLSLShaderBuilder INHERITED;
+};
+
+#endif
index f783a40db43e03203dafee8f469d7e03861688a5..568fe8ae10c04f982519611d23a982447a53aa53 100644 (file)
 
 #include "GrGeometryProcessor.h"
 #include "GrGpu.h"
-#include "gl/builders/GrGLFragmentShaderBuilder.h"
-#include "gl/builders/GrGLGeometryShaderBuilder.h"
-#include "gl/builders/GrGLVertexShaderBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLGeometryShaderBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLVertexShaderBuilder.h"
 
 class GrGLSLCaps;
 class GrGLSLShaderVar;
 
+// Enough precision to represent 1 / 2048 accurately in printf
+#define GR_SIGNIFICANT_POW2_DECIMAL_DIG 11
+
 class GrGLSLUniformBuilder {
 public:
     enum ShaderVisibility {
@@ -111,10 +114,10 @@ private:
     const char* fGsOut;
     const char* fFsIn;
 
-    friend class GrGLVertexBuilder;
-    friend class GrGLGeometryBuilder;
-    friend class GrGLXferBuilder;
-    friend class GrGLFragmentShaderBuilder;
+    friend class GrGLSLVertexBuilder;
+    friend class GrGLSLGeometryBuilder;
+    friend class GrGLSLXferBuilder;
+    friend class GrGLSLFragmentShaderBuilder;
 };
 
 struct GrGLSLVertToFrag : public GrGLSLVarying {
@@ -163,8 +166,8 @@ public:
         GrSLPrecision fsPrecision = kDefault_GrSLPrecision) = 0;
 
     // TODO rename getFragmentBuilder
-    virtual GrGLFragmentBuilder* getFragmentShaderBuilder() = 0;
-    virtual GrGLVertexBuilder* getVertexShaderBuilder() = 0;
+    virtual GrGLSLFragmentBuilder* getFragmentShaderBuilder() = 0;
+    virtual GrGLSLVertexBuilder* getVertexShaderBuilder() = 0;
 
     /*
      * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
@@ -175,7 +178,7 @@ public:
 /* a specializations for FPs. Lets the user add uniforms and FS code */
 class GrGLSLFPBuilder : public virtual GrGLSLUniformBuilder {
 public:
-    virtual GrGLFragmentBuilder* getFragmentShaderBuilder() = 0;
+    virtual GrGLSLFragmentBuilder* getFragmentShaderBuilder() = 0;
 
     /*
      * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
@@ -185,7 +188,7 @@ public:
 /* a specializations for XPs. Lets the user add uniforms and FS code */
 class GrGLSLXPBuilder : public virtual GrGLSLUniformBuilder {
 public:
-    virtual GrGLXPFragmentBuilder* getFragmentShaderBuilder() = 0;
+    virtual GrGLSLXPFragmentBuilder* getFragmentShaderBuilder() = 0;
 
     /*
      * *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
@@ -198,8 +201,8 @@ class GrGLSLProgramBuilder : public GrGLSLGPBuilder,
 public:
     typedef GrGpu::DrawArgs DrawArgs;
 
-    GrGLXPFragmentBuilder* getFragmentShaderBuilder() override { return &fFS; }
-    GrGLVertexBuilder* getVertexShaderBuilder() override { return &fVS; }
+    GrGLSLXPFragmentBuilder* getFragmentShaderBuilder() override { return &fFS; }
+    GrGLSLVertexBuilder* getVertexShaderBuilder() override { return &fVS; }
 
     // Handles for program uniforms (other than per-effect uniforms)
     struct BuiltinUniformHandles {
@@ -240,9 +243,9 @@ protected:
     // number of each input/output type in a single allocation block, used by many builders
     static const int kVarsPerBlock;
 
-    GrGLVertexBuilder fVS;
-    GrGLGeometryBuilder fGS;
-    GrGLFragmentShaderBuilder fFS;
+    GrGLSLVertexBuilder fVS;
+    GrGLSLGeometryBuilder fGS;
+    GrGLSLFragmentShaderBuilder fFS;
     int fStageIndex;
 
     BuiltinUniformHandles fUniformHandles;
@@ -252,10 +255,10 @@ protected:
 private:
     virtual void onAppendUniformDecls(ShaderVisibility visibility, SkString* out) const = 0;
 
-    friend class GrGLShaderBuilder;
-    friend class GrGLVertexBuilder;
-    friend class GrGLFragmentShaderBuilder;
-    friend class GrGLGeometryBuilder;
+    friend class GrGLSLShaderBuilder;
+    friend class GrGLSLVertexBuilder;
+    friend class GrGLSLFragmentShaderBuilder;
+    friend class GrGLSLGeometryBuilder;
 };
 
 #endif
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.cpp b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
new file mode 100644 (file)
index 0000000..d4d16fc
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "glsl/GrGLSLShaderBuilder.h"
+#include "glsl/GrGLSLCaps.h"
+#include "glsl/GrGLSLShaderVar.h"
+#include "glsl/GrGLSLTextureSampler.h"
+#include "glsl/GrGLSLProgramBuilder.h"
+
+static void map_swizzle(const char* swizzleMap, const char* swizzle, char* mangledSwizzle) {
+    int i;
+    for (i = 0; '\0' != swizzle[i]; ++i) {
+        switch (swizzle[i]) {
+            case 'r':
+                mangledSwizzle[i] = swizzleMap[0];
+                break;
+            case 'g':
+                mangledSwizzle[i] = swizzleMap[1];
+                break;
+            case 'b':
+                mangledSwizzle[i] = swizzleMap[2];
+                break;
+            case 'a':
+                mangledSwizzle[i] = swizzleMap[3];
+                break;
+            default:
+                SkFAIL("Unsupported swizzle");
+        }
+    }
+    mangledSwizzle[i] ='\0';
+}
+
+static void append_texture_lookup(SkString* out,
+                                  const GrGLSLCaps* glslCaps,
+                                  const char* samplerName,
+                                  const char* coordName,
+                                  GrPixelConfig config,
+                                  const char* swizzle,
+                                  GrSLType varyingType = kVec2f_GrSLType) {
+    SkASSERT(coordName);
+
+    out->appendf("%s(%s, %s)",
+                 GrGLSLTexture2DFunctionName(varyingType, glslCaps->generation()),
+                 samplerName,
+                 coordName);
+
+    char mangledSwizzle[5];
+
+    // This refers to any swizzling we may need to get from some backend internal format to the
+    // format used in GrPixelConfig. Some backends will automatically do the sizzling for us.
+    if (glslCaps->mustSwizzleInShader()) {
+        const char* swizzleMap = glslCaps->getSwizzleMap(config);
+        // if the map is simply 'rgba' then we don't need to do any manual swizzling to get us to
+        // a GrPixelConfig format.
+        if (memcmp(swizzleMap, "rgba", 4)) {
+            // Manually 'swizzle' the swizzle using our mapping
+            map_swizzle(swizzleMap, swizzle, mangledSwizzle);
+            swizzle = mangledSwizzle;
+        }
+    }
+
+    // For shader prettiness we omit the swizzle rather than appending ".rgba".
+    if (memcmp(swizzle, "rgba", 4)) {
+        out->appendf(".%s", swizzle);
+    }
+}
+
+GrGLSLShaderBuilder::GrGLSLShaderBuilder(GrGLSLProgramBuilder* program)
+    : fProgramBuilder(program)
+    , fInputs(GrGLSLProgramBuilder::kVarsPerBlock)
+    , fOutputs(GrGLSLProgramBuilder::kVarsPerBlock)
+    , fFeaturesAddedMask(0)
+    , fCodeIndex(kCode)
+    , fFinalized(false) {
+    // We push back some dummy pointers which will later become our header
+    for (int i = 0; i <= kCode; i++) {
+        fShaderStrings.push_back();
+        fCompilerStrings.push_back(nullptr);
+        fCompilerStringLengths.push_back(0);
+    }
+
+    this->main() = "void main() {";
+}
+
+void GrGLSLShaderBuilder::declAppend(const GrGLSLShaderVar& var) {
+    SkString tempDecl;
+    var.appendDecl(fProgramBuilder->glslCaps(), &tempDecl);
+    this->codeAppendf("%s;", tempDecl.c_str());
+}
+
+void GrGLSLShaderBuilder::emitFunction(GrSLType returnType,
+                                       const char* name,
+                                       int argCnt,
+                                       const GrGLSLShaderVar* args,
+                                       const char* body,
+                                       SkString* outName) {
+    this->functions().append(GrGLSLTypeString(returnType));
+    fProgramBuilder->nameVariable(outName, '\0', name);
+    this->functions().appendf(" %s", outName->c_str());
+    this->functions().append("(");
+    for (int i = 0; i < argCnt; ++i) {
+        args[i].appendDecl(fProgramBuilder->glslCaps(), &this->functions());
+        if (i < argCnt - 1) {
+            this->functions().append(", ");
+        }
+    }
+    this->functions().append(") {\n");
+    this->functions().append(body);
+    this->functions().append("}\n\n");
+}
+
+void GrGLSLShaderBuilder::appendTextureLookup(SkString* out,
+                                              const GrGLSLTextureSampler& sampler,
+                                              const char* coordName,
+                                              GrSLType varyingType) const {
+    append_texture_lookup(out,
+                          fProgramBuilder->glslCaps(),
+                          fProgramBuilder->getUniformCStr(sampler.fSamplerUniform),
+                          coordName,
+                          sampler.config(),
+                          sampler.swizzle(),
+                          varyingType);
+}
+
+void GrGLSLShaderBuilder::appendTextureLookup(const GrGLSLTextureSampler& sampler,
+                                              const char* coordName,
+                                              GrSLType varyingType) {
+    this->appendTextureLookup(&this->code(), sampler, coordName, varyingType);
+}
+
+void GrGLSLShaderBuilder::appendTextureLookupAndModulate(const char* modulation,
+                                                         const GrGLSLTextureSampler& sampler,
+                                                         const char* coordName,
+                                                         GrSLType varyingType) {
+    SkString lookup;
+    this->appendTextureLookup(&lookup, sampler, coordName, varyingType);
+    this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str());
+}
+
+void GrGLSLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionName) {
+    if (!(featureBit & fFeaturesAddedMask)) {
+        this->extensions().appendf("#extension %s: require\n", extensionName);
+        fFeaturesAddedMask |= featureBit;
+    }
+}
+
+void GrGLSLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const {
+    for (int i = 0; i < vars.count(); ++i) {
+        vars[i].appendDecl(fProgramBuilder->glslCaps(), out);
+        out->append(";\n");
+    }
+}
+
+void GrGLSLShaderBuilder::addLayoutQualifier(const char* param, InterfaceQualifier interface) {
+    SkASSERT(fProgramBuilder->glslCaps()->generation() >= k330_GrGLSLGeneration ||
+             fProgramBuilder->glslCaps()->mustEnableAdvBlendEqs());
+    fLayoutParams[interface].push_back() = param;
+}
+
+void GrGLSLShaderBuilder::compileAndAppendLayoutQualifiers() {
+    static const char* interfaceQualifierNames[] = {
+        "out"
+    };
+
+    for (int interface = 0; interface <= kLastInterfaceQualifier; ++interface) {
+        const SkTArray<SkString>& params = fLayoutParams[interface];
+        if (params.empty()) {
+            continue;
+        }
+        this->layoutQualifiers().appendf("layout(%s", params[0].c_str());
+        for (int i = 1; i < params.count(); ++i) {
+            this->layoutQualifiers().appendf(", %s", params[i].c_str());
+        }
+        this->layoutQualifiers().appendf(") %s;\n", interfaceQualifierNames[interface]);
+    }
+
+    GR_STATIC_ASSERT(0 == GrGLSLShaderBuilder::kOut_InterfaceQualifier);
+    GR_STATIC_ASSERT(SK_ARRAY_COUNT(interfaceQualifierNames) == kLastInterfaceQualifier + 1);
+}
+
+void GrGLSLShaderBuilder::finalize(uint32_t visibility) {
+    SkASSERT(!fFinalized);
+    this->versionDecl() = fProgramBuilder->glslCaps()->versionDeclString();
+    this->compileAndAppendLayoutQualifiers();
+    SkASSERT(visibility);
+    fProgramBuilder->appendUniformDecls((GrGLSLProgramBuilder::ShaderVisibility) visibility,
+                                        &this->uniforms());
+    this->appendDecls(fInputs, &this->inputs());
+    // We should not have any outputs in the fragment shader when using version 1.10
+    SkASSERT(GrGLSLProgramBuilder::kFragment_Visibility != visibility ||
+             k110_GrGLSLGeneration != fProgramBuilder->glslCaps()->generation() ||
+             fOutputs.empty());
+    this->appendDecls(fOutputs, &this->outputs());
+    this->onFinalize();
+    // append the 'footer' to code
+    this->code().append("}");
+
+    for (int i = 0; i <= fCodeIndex; i++) {
+        fCompilerStrings[i] = fShaderStrings[i].c_str();
+        fCompilerStringLengths[i] = (int)fShaderStrings[i].size();
+    }
+
+    fFinalized = true;
+}
+
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.h b/src/gpu/glsl/GrGLSLShaderBuilder.h
new file mode 100644 (file)
index 0000000..8927303
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLSLShaderBuilder_DEFINED
+#define GrGLSLShaderBuilder_DEFINED
+
+#include "GrAllocator.h"
+#include "glsl/GrGLSLShaderVar.h"
+#include "SkTDArray.h"
+
+#include <stdarg.h>
+
+class GrGLSLProgramBuilder;
+class GrGLSLTextureSampler;
+
+/**
+  base class for all shaders builders
+*/
+class GrGLSLShaderBuilder {
+public:
+    GrGLSLShaderBuilder(GrGLSLProgramBuilder* program);
+    virtual ~GrGLSLShaderBuilder() {}
+
+    void addInput(const GrGLSLShaderVar& input) { fInputs.push_back(input); }
+    void addOutput(const GrGLSLShaderVar& output) { fOutputs.push_back(output); }
+
+    /*
+     * We put texture lookups in the base class because it is TECHNICALLY possible to do texture
+     * lookups in any kind of shader.  However, for the time being using these calls on non-fragment
+     * shaders will result in a shader compilation error as texture sampler uniforms are only
+     * visible to the fragment shader.  It would not be hard to change this behavior, if someone
+     * actually wants to do texture lookups in a non-fragment shader
+     *
+     * TODO if append texture lookup is used on a non-fragment shader, sampler uniforms should be
+     * made visible to that shaders
+     */
+    /** Appends a 2D texture sample with projection if necessary. coordType must either be Vec2f or
+        Vec3f. The latter is interpreted as projective texture coords. The vec length and swizzle
+        order of the result depends on the GrTextureAccess associated with the GrGLSLTextureSampler.
+        */
+    void appendTextureLookup(SkString* out,
+                             const GrGLSLTextureSampler&,
+                             const char* coordName,
+                             GrSLType coordType = kVec2f_GrSLType) const;
+
+    /** Version of above that appends the result to the fragment shader code instead.*/
+    void appendTextureLookup(const GrGLSLTextureSampler&,
+                             const char* coordName,
+                             GrSLType coordType = kVec2f_GrSLType);
+
+
+    /** Does the work of appendTextureLookup and modulates the result by modulation. The result is
+        always a vec4. modulation and the swizzle specified by GrGLSLTextureSampler must both be
+        vec4 or float. If modulation is "" or nullptr it this function acts as though
+        appendTextureLookup were called. */
+    void appendTextureLookupAndModulate(const char* modulation,
+                                        const GrGLSLTextureSampler&,
+                                        const char* coordName,
+                                        GrSLType coordType = kVec2f_GrSLType);
+
+    /**
+    * Called by GrGLProcessors to add code to one of the shaders.
+    */
+    void codeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
+       va_list args;
+       va_start(args, format);
+       this->code().appendVAList(format, args);
+       va_end(args);
+    }
+
+    void codeAppend(const char* str) { this->code().append(str); }
+
+    void codePrependf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
+       va_list args;
+       va_start(args, format);
+       this->code().prependVAList(format, args);
+       va_end(args);
+    }
+
+    /**
+     * Appends a variable declaration to one of the shaders
+     */
+    void declAppend(const GrGLSLShaderVar& var);
+
+    /** Emits a helper function outside of main() in the fragment shader. */
+    void emitFunction(GrSLType returnType,
+                      const char* name,
+                      int argCnt,
+                      const GrGLSLShaderVar* args,
+                      const char* body,
+                      SkString* outName);
+
+    /*
+     * Combines the various parts of the shader to create a single finalized shader string.
+     */
+    void finalize(uint32_t visibility);
+
+    /*
+     * Get parent builder for adding uniforms
+     */
+    GrGLSLProgramBuilder* getProgramBuilder() { return fProgramBuilder; }
+
+    /**
+     * Helper for begining and ending a block in the shader code.
+     */
+    class ShaderBlock {
+    public:
+        ShaderBlock(GrGLSLShaderBuilder* builder) : fBuilder(builder) {
+            SkASSERT(builder);
+            fBuilder->codeAppend("{");
+        }
+
+        ~ShaderBlock() {
+            fBuilder->codeAppend("}");
+        }
+    private:
+        GrGLSLShaderBuilder* fBuilder;
+    };
+
+protected:
+    typedef GrTAllocator<GrGLSLShaderVar> VarArray;
+    void appendDecls(const VarArray& vars, SkString* out) const;
+
+    /*
+     * A general function which enables an extension in a shader if the feature bit is not present
+     */
+    void addFeature(uint32_t featureBit, const char* extensionName);
+
+    enum InterfaceQualifier {
+        kOut_InterfaceQualifier,
+        kLastInterfaceQualifier = kOut_InterfaceQualifier
+    };
+
+    /*
+     * A low level function to build default layout qualifiers.
+     *
+     *   e.g. layout(param1, param2, ...) out;
+     *
+     * GLSL allows default layout qualifiers for in, out, and uniform.
+     */
+    void addLayoutQualifier(const char* param, InterfaceQualifier);
+
+    void compileAndAppendLayoutQualifiers();
+
+    void nextStage() {
+        fShaderStrings.push_back();
+        fCompilerStrings.push_back(this->code().c_str());
+        fCompilerStringLengths.push_back((int)this->code().size());
+        fCodeIndex++;
+    }
+
+    SkString& versionDecl() { return fShaderStrings[kVersionDecl]; }
+    SkString& extensions() { return fShaderStrings[kExtensions]; }
+    SkString& precisionQualifier() { return fShaderStrings[kPrecisionQualifier]; }
+    SkString& layoutQualifiers() { return fShaderStrings[kLayoutQualifiers]; }
+    SkString& uniforms() { return fShaderStrings[kUniforms]; }
+    SkString& inputs() { return fShaderStrings[kInputs]; }
+    SkString& outputs() { return fShaderStrings[kOutputs]; }
+    SkString& functions() { return fShaderStrings[kFunctions]; }
+    SkString& main() { return fShaderStrings[kMain]; }
+    SkString& code() { return fShaderStrings[fCodeIndex]; }
+
+    virtual void onFinalize() = 0;
+
+    enum {
+        kVersionDecl,
+        kExtensions,
+        kPrecisionQualifier,
+        kLayoutQualifiers,
+        kUniforms,
+        kInputs,
+        kOutputs,
+        kFunctions,
+        kMain,
+        kCode,
+    };
+
+    GrGLSLProgramBuilder* fProgramBuilder;
+    SkSTArray<kCode, const char*, true> fCompilerStrings;
+    SkSTArray<kCode, int, true> fCompilerStringLengths;
+    SkSTArray<kCode, SkString> fShaderStrings;
+    SkString fCode;
+    SkString fFunctions;
+    SkString fExtensions;
+
+    VarArray fInputs;
+    VarArray fOutputs;
+    uint32_t fFeaturesAddedMask;
+    SkSTArray<1, SkString> fLayoutParams[kLastInterfaceQualifier + 1];
+    int fCodeIndex;
+    bool fFinalized;
+
+    friend class GrGLProgramBuilder;
+    friend class GrGLPathProgramBuilder; // to access fInputs.
+};
+#endif
index 2de0431f580e60a177c26fedeb3dc0463d660df2..a4fbf550f25039dad0ed20d013b6a86abe8b0551 100644 (file)
@@ -33,7 +33,7 @@ private:
     GrPixelConfig fConfig;
     char          fSwizzle[5];
 
-    friend class GrGLShaderBuilder;
+    friend class GrGLSLShaderBuilder;
 };
 
 #endif
diff --git a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
new file mode 100644 (file)
index 0000000..1f68d0e
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrGLSLVertexShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
+
+GrGLSLVertexBuilder::GrGLSLVertexBuilder(GrGLSLProgramBuilder* program)
+    : INHERITED(program)
+    , fRtAdjustName(nullptr) {
+}
+
+void GrGLSLVertexBuilder::addVarying(const char* name, GrSLPrecision precision, GrGLSLVarying* v) {
+    fOutputs.push_back();
+    fOutputs.back().setType(v->fType);
+    fOutputs.back().setTypeModifier(GrGLSLShaderVar::kVaryingOut_TypeModifier);
+    fOutputs.back().setPrecision(precision);
+    fProgramBuilder->nameVariable(fOutputs.back().accessName(), 'v', name);
+    v->fVsOut = fOutputs.back().getName().c_str();
+}
+
+void GrGLSLVertexBuilder::emitAttributes(const GrGeometryProcessor& gp) {
+    int vaCount = gp.numAttribs();
+    for (int i = 0; i < vaCount; i++) {
+        this->addAttribute(&gp.getAttrib(i));
+    }
+    return;
+}
+
+void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& posVar) {
+    SkASSERT(!fRtAdjustName);
+
+    GrSLPrecision precision = kDefault_GrSLPrecision;
+    if (fProgramBuilder->glslCaps()->forceHighPrecisionNDSTransform()) {
+        precision = kHigh_GrSLPrecision;
+    }
+
+    // setup RT Uniform
+    fProgramBuilder->fUniformHandles.fRTAdjustmentUni =
+            fProgramBuilder->addUniform(GrGLSLProgramBuilder::kVertex_Visibility,
+                                        kVec4f_GrSLType, precision,
+                                        fProgramBuilder->rtAdjustment(),
+                                        &fRtAdjustName);
+    if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters) {
+        if (kVec3f_GrSLType == posVar.getType()) {
+            const char* p = posVar.c_str();
+            this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p);
+        } else {
+            SkASSERT(kVec2f_GrSLType == posVar.getType());
+            this->codeAppendf("{vec2 _posTmp = %s;", posVar.c_str());
+        }
+        this->codeAppendf("_posTmp = floor(_posTmp) + vec2(0.5, 0.5);"
+                          "gl_Position = vec4(_posTmp.x * %s.x + %s.y,"
+                                             "_posTmp.y * %s.z + %s.w, 0, 1);}",
+                          fRtAdjustName, fRtAdjustName, fRtAdjustName, fRtAdjustName);
+    } else if (kVec3f_GrSLType == posVar.getType()) {
+        this->codeAppendf("gl_Position = vec4(dot(%s.xz, %s.xy), dot(%s.yz, %s.zw), 0, %s.z);",
+                          posVar.c_str(), fRtAdjustName,
+                          posVar.c_str(), fRtAdjustName,
+                          posVar.c_str());
+    } else {
+        SkASSERT(kVec2f_GrSLType == posVar.getType());
+        this->codeAppendf("gl_Position = vec4(%s.x * %s.x + %s.y, %s.y * %s.z + %s.w, 0, 1);",
+                          posVar.c_str(), fRtAdjustName, fRtAdjustName,
+                          posVar.c_str(), fRtAdjustName, fRtAdjustName);
+    }
+    // We could have the GrGeometryProcessor do this, but its just easier to have it performed
+    // here. If we ever need to set variable pointsize, then we can reinvestigate
+    this->codeAppend("gl_PointSize = 1.0;");
+}
+
+bool GrGLSLVertexBuilder::addAttribute(const GrShaderVar& var) {
+    SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier());
+    for (int i = 0; i < fInputs.count(); ++i) {
+        const GrGLSLShaderVar& attr = fInputs[i];
+        // if attribute already added, don't add it again
+        if (attr.getName().equals(var.getName())) {
+            return false;
+        }
+    }
+    fInputs.push_back(var);
+    return true;
+}
+
diff --git a/src/gpu/glsl/GrGLSLVertexShaderBuilder.h b/src/gpu/glsl/GrGLSLVertexShaderBuilder.h
new file mode 100644 (file)
index 0000000..92edd9a
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLSLVertexShader_DEFINED
+#define GrGLSLVertexShader_DEFINED
+
+#include "GrGLSLShaderBuilder.h"
+#include "GrGeometryProcessor.h"
+
+class GrGLSLVarying;
+
+class GrGLSLVertexBuilder : public GrGLSLShaderBuilder {
+public:
+    GrGLSLVertexBuilder(GrGLSLProgramBuilder* program);
+
+    void transformToNormalizedDeviceSpace(const GrShaderVar& posVar);
+    void emitAttributes(const GrGeometryProcessor& gp);
+
+    void addAttribute(const GrGeometryProcessor::Attribute* attr) {
+        this->addAttribute(GrShaderVar(attr->fName,
+                                       GrVertexAttribTypeToSLType(attr->fType),
+                                       GrShaderVar::kAttribute_TypeModifier,
+                                       GrShaderVar::kNonArray,
+                                       attr->fPrecision));
+    }
+
+private:
+    /*
+     * Internal call for GrGLProgramBuilder.addVarying
+     */
+    void addVarying(const char* name, GrSLPrecision, GrGLSLVarying*);
+
+    // an internal call which checks for uniquness of a var before adding it to the list of inputs
+    bool addAttribute(const GrShaderVar& var);
+
+    void onFinalize() override {}
+    
+    const char* fRtAdjustName;
+
+    friend class GrGLProgramBuilder;
+
+    typedef GrGLSLShaderBuilder INHERITED;
+};
+
+#endif
index da84066af889d2e57da46800cb60f15654c5bdde..dedd00959c50b47099ecae43c12e4eec7ebccd92 100644 (file)
@@ -33,8 +33,8 @@
 
 #include "gl/GrGLFragmentProcessor.h"
 #include "gl/GrGLGpu.h"
-#include "gl/GrGLPathRendering.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
+#include "glsl/GrGLSLProgramBuilder.h"
 
 /*
  * A dummy processor which just tries to insert a massive key and verify that it can retrieve the
@@ -48,7 +48,7 @@ public:
 
     virtual void emitCode(EmitArgs& args) override {
         // pass through
-        GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
+        GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder();
         if (args.fInputColor) {
             fsBuilder->codeAppendf("%s = %s;\n", args.fOutputColor, args.fInputColor);
         } else {