Remove GrGLProcessor and create GrGLSLTextureSampler class.
authoregdaniel <egdaniel@google.com>
Thu, 29 Oct 2015 14:57:01 +0000 (07:57 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 29 Oct 2015 14:57:02 +0000 (07:57 -0700)
Part ??? of separating glsl and gl

BUG=skia:

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

26 files changed:
gm/dcshader.cpp
gyp/gpu.gypi
src/core/SkLightingShader.cpp
src/effects/SkBlurMaskFilter.cpp
src/gpu/GrOvalRenderer.cpp
src/gpu/GrPathProcessor.cpp
src/gpu/batches/GrAAConvexPathRenderer.cpp
src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
src/gpu/effects/GrTextureDomain.cpp
src/gpu/effects/GrTextureDomain.h
src/gpu/gl/GrGLFragmentProcessor.cpp
src/gpu/gl/GrGLFragmentProcessor.h
src/gpu/gl/GrGLGeometryProcessor.cpp
src/gpu/gl/GrGLPrimitiveProcessor.h
src/gpu/gl/GrGLProcessor.h [deleted file]
src/gpu/gl/GrGLProgram.h
src/gpu/gl/GrGLXferProcessor.h
src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
src/gpu/gl/builders/GrGLProgramBuilder.cpp
src/gpu/gl/builders/GrGLProgramBuilder.h
src/gpu/gl/builders/GrGLShaderBuilder.cpp
src/gpu/gl/builders/GrGLShaderBuilder.h
src/gpu/glsl/GrGLSLProcessorTypes.h [new file with mode: 0644]
src/gpu/glsl/GrGLSLProgramDataManager.h
src/gpu/glsl/GrGLSLTextureSampler.h [new file with mode: 0644]

index e161f4d..d7eb3b5 100644 (file)
@@ -11,7 +11,6 @@
 #include "GrFragmentProcessor.h"
 #include "GrCoordTransform.h"
 #include "effects/GrXfermodeFragmentProcessor.h"
-#include "gl/GrGLProcessor.h"
 #include "gl/builders/GrGLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #include "Resources.h"
index 43841d3..5016598 100644 (file)
       '<(skia_src_path)/gpu/gl/GrGLPathRendering.h',
       '<(skia_src_path)/gpu/gl/GrGLPrimitiveProcessor.cpp',
       '<(skia_src_path)/gpu/gl/GrGLPrimitiveProcessor.h',
-      '<(skia_src_path)/gpu/gl/GrGLProcessor.h',
       '<(skia_src_path)/gpu/gl/GrGLProgram.cpp',
       '<(skia_src_path)/gpu/gl/GrGLProgram.h',
       '<(skia_src_path)/gpu/gl/GrGLProgramDesc.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/GrGLSLProcessorTypes.h',
       '<(skia_src_path)/gpu/glsl/GrGLSLProgramDataManager.h',
       '<(skia_src_path)/gpu/glsl/GrGLSLShaderVar.h',
+      '<(skia_src_path)/gpu/glsl/GrGLSLTextureSampler.h',
 
       # Sk files
       '<(skia_include_path)/gpu/SkGr.h',
index 4c8ed3b..d3d6a28 100644 (file)
@@ -130,7 +130,6 @@ private:
 #include "GrCoordTransform.h"
 #include "GrFragmentProcessor.h"
 #include "GrTextureAccess.h"
-#include "gl/GrGLProcessor.h"
 #include "gl/builders/GrGLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #include "SkGr.h"
index 8c47e03..5a25e54 100644 (file)
@@ -30,6 +30,7 @@
 #include "gl/GrGLFragmentProcessor.h"
 #include "gl/builders/GrGLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLTextureSampler.h"
 #endif
 
 SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) {
@@ -696,7 +697,7 @@ private:
 };
 
 void OutputRectBlurProfileLookup(GrGLFragmentBuilder* fsBuilder,
-                                 const GrGLShaderBuilder::TextureSampler& sampler,
+                                 const GrGLSLTextureSampler& sampler,
                                  const char *output,
                                  const char *profileSize, const char *loc,
                                  const char *blurred_width,
index a647e62..b0a7f3a 100644 (file)
@@ -22,7 +22,6 @@
 #include "batches/GrVertexBatch.h"
 #include "effects/GrRRectEffect.h"
 #include "gl/GrGLUtil.h"
-#include "gl/GrGLProcessor.h"
 #include "gl/GrGLGeometryProcessor.h"
 #include "gl/builders/GrGLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
index e4050a9..9728e59 100644 (file)
@@ -8,8 +8,8 @@
 #include "GrPathProcessor.h"
 
 #include "gl/GrGLGpu.h"
-
 #include "glsl/GrGLSLCaps.h"
+#include "glsl/GrGLSLProcessorTypes.h"
 
 class GrGLPathProcessor : public GrGLPrimitiveProcessor {
 public:
@@ -65,7 +65,7 @@ public:
                         pb->addSeparableVarying(strVaryingName.c_str(), &v).toIndex();
                 fInstalledTransforms[i][t].fType = varyingType;
 
-                SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCoords,
+                SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLSLTransformedCoords,
                                        (SkString(v.fsIn()), varyingType));
             }
         }
index cb015f8..02f4143 100644 (file)
@@ -25,7 +25,6 @@
 #include "SkString.h"
 #include "SkTraceEvent.h"
 #include "batches/GrVertexBatch.h"
-#include "gl/GrGLProcessor.h"
 #include "gl/GrGLGeometryProcessor.h"
 #include "gl/builders/GrGLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
index a7e9824..4585c10 100644 (file)
@@ -24,7 +24,6 @@
 #include "SkTraceEvent.h"
 #include "SkPathPriv.h"
 #include "batches/GrVertexBatch.h"
-#include "gl/GrGLProcessor.h"
 #include "gl/GrGLGeometryProcessor.h"
 #include "gl/builders/GrGLProgramBuilder.h"
 
index 760fd57..29d5fc9 100644 (file)
@@ -13,6 +13,7 @@
 #include "gl/GrGLFragmentProcessor.h"
 #include "gl/builders/GrGLProgramBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLTextureSampler.h"
 
 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index)
     : fIndex(index) {
@@ -45,7 +46,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder,
                                               const GrTextureDomain& textureDomain,
                                               const char* outColor,
                                               const SkString& inCoords,
-                                              const GrGLProcessor::TextureSampler sampler,
+                                              const GrGLSLTextureSampler& sampler,
                                               const char* inModulateColor) {
     SkASSERT((Mode)-1 == fMode || textureDomain.mode() == fMode);
     SkDEBUGCODE(fMode = textureDomain.mode();)
index 0b93ac8..bbe988c 100644 (file)
@@ -15,6 +15,7 @@
 class GrGLProgramBuilder;
 class GrGLShaderBuilder;
 class GrInvariantOutput;
+class GrGLSLTextureSampler;
 struct SkRect;
 
 /**
@@ -88,10 +89,10 @@ public:
     }
 
     /**
-     * A GrGLProcessor subclass that corresponds to a GrProcessor subclass that uses GrTextureDomain
-     * should include this helper. It generates the texture domain GLSL, produces the part of the
-     * effect key that reflects the texture domain code, and performs the uniform uploads necessary
-     * for texture domains.
+     * A GrGLFragmentProcessor subclass that corresponds to a GrProcessor subclass that uses
+     * GrTextureDomain should include this helper. It generates the texture domain GLSL, produces
+     * the part of the effect key that reflects the texture domain code, and performs the uniform
+     * uploads necessary for texture domains.
      */
     class GLDomain {
     public:
@@ -103,8 +104,8 @@ public:
         }
 
         /**
-         * Call this from GrGLProcessor::emitCode() to sample the texture W.R.T. the domain and
-         * mode.
+         * Call this from GrGLFragmentProcessor::emitCode() to sample the texture W.R.T. the domain
+         * and mode.
          *
          * @param outcolor  name of vec4 variable to hold the sampled color.
          * @param inCoords  name of vec2 variable containing the coords to be used with the domain.
@@ -116,12 +117,13 @@ public:
                            const GrTextureDomain& textureDomain,
                            const char* outColor,
                            const SkString& inCoords,
-                           const GrGLProcessor::TextureSampler sampler,
+                           const GrGLSLTextureSampler& sampler,
                            const char* inModulateColor = nullptr);
 
         /**
-         * Call this from GrGLProcessor::setData() to upload uniforms necessary for the texture
-         * domain. The rectangle is automatically adjusted to account for the texture's origin.
+         * Call this from GrGLFragmentProcessor::setData() to upload uniforms necessary for the
+         * texture domain. The rectangle is automatically adjusted to account for the texture's
+         * origin.
          */
         void setData(const GrGLSLProgramDataManager& pdman, const GrTextureDomain& textureDomain,
                      GrSurfaceOrigin textureOrigin);
@@ -131,8 +133,8 @@ public:
         };
 
         /**
-         * GrGLProcessor::GenKey() must call this and include the returned value in it's computed
-         * key. The returned will be limited to the lower kDomainKeyBits bits.
+         * GrGLFragmentProcessor::GenKey() must call this and include the returned value in it's
+         * computed key. The returned will be limited to the lower kDomainKeyBits bits.
          */
         static uint32_t DomainKey(const GrTextureDomain& domain) {
             GR_STATIC_ASSERT(kModeCount <= 4);
index 5f30262..dcc6cb1 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "GrGLFragmentProcessor.h"
 #include "GrFragmentProcessor.h"
+#include "GrProcessor.h"
 #include "builders/GrGLFragmentShaderBuilder.h"
 #include "builders/GrGLProgramBuilder.h"
 
@@ -79,7 +80,7 @@ void GrGLFragmentProcessor::internalEmitChild(int childIndex, const char* inputC
         firstCoordAt += args.fFp.childProcessor(i).numTransforms();
         firstSamplerAt += args.fFp.childProcessor(i).numTextures();
     }
-    TransformedCoordsArray childCoords;
+    GrGLSLTransformedCoordsArray childCoords;
     TextureSamplerArray childSamplers;
     if (childProc.numTransforms() > 0) {
         childCoords.push_back_n(childProc.numTransforms(), &args.fCoords[firstCoordAt]);
index 00bd063..2a78bbd 100644 (file)
@@ -8,9 +8,12 @@
 #ifndef GrGLFragmentProcessor_DEFINED
 #define GrGLFragmentProcessor_DEFINED
 
-#include "GrGLProcessor.h"
+#include "glsl/GrGLSLProcessorTypes.h"
 #include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLTextureSampler.h"
 
+class GrProcessor;
+class GrProcessorKeyBuilder;
 class GrGLFPBuilder;
 class GrGLSLCaps;
 
@@ -25,8 +28,7 @@ public:
     }
 
     typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
-    typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray;
-    typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
+    typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray;
 
     /** Called when the program stage should insert its code into the shaders. The code in each
         shader will be in its own block ({}) and so locally scoped names will not collide across
@@ -52,7 +54,7 @@ public:
                  const GrFragmentProcessor& fp,
                  const char* outputColor,
                  const char* inputColor,
-                 const TransformedCoordsArray& coords,
+                 const GrGLSLTransformedCoordsArray& coords,
                  const TextureSamplerArray& samplers)
             : fBuilder(builder)
             , fFp(fp)
@@ -64,7 +66,7 @@ public:
         const GrFragmentProcessor& fFp;
         const char* fOutputColor;
         const char* fInputColor;
-        const TransformedCoordsArray& fCoords;
+        const GrGLSLTransformedCoordsArray& fCoords;
         const TextureSamplerArray& fSamplers;
     };
 
@@ -109,7 +111,6 @@ private:
     SkTArray<GrGLFragmentProcessor*, true> fChildProcessors;
 
     friend class GrFragmentProcessor;
-    typedef GrGLProcessor INHERITED;
 };
 
 #endif
index 8998af4..ff45742 100644 (file)
@@ -8,6 +8,7 @@
 #include "GrGLGeometryProcessor.h"
 
 #include "builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLProcessorTypes.h"
 
 void GrGLGeometryProcessor::emitCode(EmitArgs& args) {
     GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
@@ -56,7 +57,7 @@ void GrGLGeometryProcessor::emitTransforms(GrGLGPBuilder* pb,
             pb->addVarying(strVaryingName.c_str(), &v, precision);
 
             SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingType);
-            SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCoords,
+            SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLSLTransformedCoords,
                                    (SkString(v.fsIn()), varyingType));
 
             // varying = matrix * coords (logically)
@@ -112,7 +113,7 @@ void GrGLGeometryProcessor::emitTransforms(GrGLGPBuilder* pb,
             vb->codeAppendf("%s = %s;", v.vsOut(), localCoords);
 
             SkNEW_APPEND_TO_TARRAY(&(*tout)[i],
-                                   GrGLProcessor::TransformedCoords,
+                                   GrGLSLTransformedCoords,
                                    (SkString(v.fsIn()), varyingType));
         }
     }
index cff9640..6d4c195 100644 (file)
@@ -9,8 +9,9 @@
 #define GrGLPrimitiveProcessor_DEFINED
 
 #include "GrPrimitiveProcessor.h"
-#include "GrGLProcessor.h"
+#include "glsl/GrGLSLProcessorTypes.h"
 #include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLTextureSampler.h"
 
 class GrBatchTracker;
 class GrPrimitiveProcessor;
@@ -21,11 +22,11 @@ public:
     virtual ~GrGLPrimitiveProcessor() {}
 
     typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
-    typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
+    typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray;
 
     typedef SkSTArray<2, const GrCoordTransform*, true> ProcCoords;
     typedef SkSTArray<8, ProcCoords> TransformsIn;
-    typedef SkSTArray<8, GrGLProcessor::TransformedCoordsArray> TransformsOut;
+    typedef SkSTArray<8, GrGLSLTransformedCoordsArray> TransformsOut;
 
     struct EmitArgs {
         EmitArgs(GrGLGPBuilder* pb,
@@ -78,9 +79,9 @@ protected:
 
     struct Transform {
         Transform() : fType(kVoid_GrSLType) { fCurrentValue = SkMatrix::InvalidMatrix(); }
-        GrGLSLProgramDataManager::UniformHandle fHandle;
-        SkMatrix                                fCurrentValue;
-        GrSLType                                fType;
+        UniformHandle  fHandle;
+        SkMatrix       fCurrentValue;
+        GrSLType       fType;
     };
 
     SkSTArray<8, SkSTArray<2, Transform, true> > fInstalledTransforms;
diff --git a/src/gpu/gl/GrGLProcessor.h b/src/gpu/gl/GrGLProcessor.h
deleted file mode 100644 (file)
index c389ce4..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGLProcessor_DEFINED
-#define GrGLProcessor_DEFINED
-
-#include "GrProcessor.h"
-#include "GrShaderVar.h"
-#include "GrTextureAccess.h"
-#include "glsl/GrGLSLProgramDataManager.h"
-
-/** @file
-    This file contains specializations for OpenGL of the shader stages declared in
-    include/gpu/GrProcessor.h. Objects of type GrGLProcessor are responsible for emitting the
-    GLSL code that implements a GrProcessor and for uploading uniforms at draw time. If they don't
-    always emit the same GLSL code, they must have a function:
-        static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*)
-    that is used to implement a program cache. When two GrProcessors produce the same key this means
-    that their GrGLProcessors would emit the same GLSL code.
-
-    The GrGLProcessor subclass must also have a constructor of the form:
-        ProcessorSubclass::ProcessorSubclass(const GrBackendProcessorFactory&, const GrProcessor&)
-
-    These objects are created by the factory object returned by the GrProcessor::getFactory().
-*/
-// TODO delete this and make TextureSampler its own thing
-class GrGLProcessor {
-public:
-    typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
-
-    /**
-     * Passed to GrGLProcessors so they can add transformed coordinates to their shader code.
-     */
-    typedef GrShaderVar TransformedCoords;
-    typedef SkTArray<GrShaderVar> TransformedCoordsArray;
-
-    /**
-     * Passed to GrGLProcessors so they can add texture reads to their shader code.
-     */
-    class TextureSampler {
-    public:
-        TextureSampler(UniformHandle uniform, const GrTextureAccess& access)
-            : fSamplerUniform(uniform)
-            , fConfigComponentMask(GrPixelConfigComponentMask(access.getTexture()->config())) {
-            SkASSERT(0 != fConfigComponentMask);
-            memcpy(fSwizzle, access.getSwizzle(), 5);
-        }
-
-        // bitfield of GrColorComponentFlags present in the texture's config.
-        uint32_t configComponentMask() const { return fConfigComponentMask; }
-        // this is .abcd
-        const char* swizzle() const { return fSwizzle; }
-
-    private:
-        UniformHandle fSamplerUniform;
-        uint32_t      fConfigComponentMask;
-        char          fSwizzle[5];
-
-        friend class GrGLShaderBuilder;
-    };
-
-    typedef SkTArray<TextureSampler> TextureSamplerArray;
-};
-
-#endif
index dc64a70..117d5a2 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "builders/GrGLProgramBuilder.h"
 
-class GrGLProcessor;
 class GrGLInstalledProcessors;
 class GrGLProgramBuilder;
 class GrPipeline;
@@ -89,7 +88,7 @@ public:
     };
 
     /**
-     * This function uploads uniforms, calls each GrGLProcessor's setData, and retrieves the
+     * This function uploads uniforms, calls each GrGL*Processor's setData, and retrieves the
      * textures that need to be bound on each unit. It is the caller's responsibility to ensure
      * the program is bound before calling, and to bind the outgoing textures to their respective
      * units upon return. (Each index in the array corresponds to its matching GL texture unit.)
index bf16cf4..d461997 100644 (file)
@@ -8,8 +8,8 @@
 #ifndef GrGLXferProcessor_DEFINED
 #define GrGLXferProcessor_DEFINED
 
-#include "GrGLProcessor.h"
 #include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLTextureSampler.h"
 
 class GrGLXPBuilder;
 class GrXferProcessor;
@@ -19,7 +19,7 @@ public:
     GrGLXferProcessor() {}
     virtual ~GrGLXferProcessor() {}
 
-    typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
+    typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray;
     struct EmitArgs {
         EmitArgs(GrGLXPBuilder* pb,
                  const GrXferProcessor& xp,
@@ -83,7 +83,5 @@ private:
 
     GrGLSLProgramDataManager::UniformHandle fDstTopLeftUni;
     GrGLSLProgramDataManager::UniformHandle fDstScaleUni;
-
-    typedef GrGLProcessor INHERITED;
 };
 #endif
index 7309854..6f04958 100644 (file)
@@ -118,8 +118,8 @@ bool GrGLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
     }
 }
 
-SkString GrGLFragmentShaderBuilder::ensureFSCoords2D(
-        const GrGLProcessor::TransformedCoordsArray& coords, int index) {
+SkString GrGLFragmentShaderBuilder::ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords,
+                                                     int index) {
     if (kVec3f_GrSLType != coords[index].getType()) {
         SkASSERT(kVec2f_GrSLType == coords[index].getType());
         return coords[index].getName();
index 4f17b68..ed92703 100644 (file)
@@ -10,6 +10,8 @@
 
 #include "GrGLShaderBuilder.h"
 
+#include "glsl/GrGLSLProcessorTypes.h"
+
 class GrGLVarying;
 
 /*
@@ -42,8 +44,7 @@ public:
      * 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 GrGLProcessor::TransformedCoordsArray& coords,
-                                      int index) = 0;
+    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
@@ -127,7 +128,7 @@ public:
 
     // true public interface, defined explicitly in the abstract interfaces above
     bool enableFeature(GLSLFeature) override;
-    virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArray& coords,
+    virtual SkString ensureFSCoords2D(const GrGLSLTransformedCoordsArray& coords,
                                       int index) override;
     const char* fragmentPosition() override;
     const char* dstColor() override;
index b74a867..2afd3c4 100644 (file)
@@ -20,6 +20,7 @@
 #include "gl/GrGLXferProcessor.h"
 #include "glsl/GrGLSLCaps.h"
 #include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLTextureSampler.h"
 
 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X)
 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X)
@@ -279,7 +280,7 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrFragmentProcessor& fp,
 
     ifp->fGLProc.reset(fp.createGLInstance());
 
-    SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures());
+    SkSTArray<4, GrGLSLTextureSampler> samplers(fp.numTextures());
     this->emitSamplers(fp, &samplers, ifp);
 
     GrGLFragmentProcessor::EmitArgs args(this, fp, outColor, inColor, fOutCoords[index], samplers);
@@ -299,7 +300,7 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp,
 
     fGeometryProcessor->fGLProc.reset(gp.createGLInstance(*fGpu->glCaps().glslCaps()));
 
-    SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures());
+    SkSTArray<4, GrGLSLTextureSampler> samplers(gp.numTextures());
     this->emitSamplers(gp, &samplers, fGeometryProcessor);
 
     GrGLGeometryProcessor::EmitArgs args(this, gp, outColor, outCoverage, samplers,
@@ -335,7 +336,7 @@ void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp,
     openBrace.printf("{ // Xfer Processor: %s\n", xp.name());
     fFS.codeAppend(openBrace.c_str());
 
-    SkSTArray<4, GrGLProcessor::TextureSampler> samplers(xp.numTextures());
+    SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures());
     this->emitSamplers(xp, &samplers, fXferProcessor);
 
     GrGLXferProcessor::EmitArgs args(this, xp, colorIn.c_str(), coverageIn.c_str(),
@@ -363,7 +364,7 @@ void GrGLProgramBuilder::verify(const GrFragmentProcessor& fp) {
 
 template <class Proc>
 void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor,
-                                      GrGLProcessor::TextureSamplerArray* outSamplers,
+                                      GrGLSLTextureSampler::TextureSamplerArray* outSamplers,
                                       GrGLInstalledProc<Proc>* ip) {
     SkDEBUGCODE(ip->fSamplersIdx = fSamplerUniforms.count();)
     int numTextures = processor.numTextures();
@@ -374,7 +375,7 @@ void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor,
         localSamplerUniforms[t] = this->addUniform(GrGLProgramBuilder::kFragment_Visibility,
                                                    kSampler2D_GrSLType, kDefault_GrSLPrecision,
                                                    name.c_str());
-        SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLProcessor::TextureSampler,
+        SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLSLTextureSampler,
                                (localSamplerUniforms[t], processor.textureAccess(t)));
     }
 }
index 7690b39..4745440 100644 (file)
@@ -12,6 +12,7 @@
 #include "GrGLGeometryShaderBuilder.h"
 #include "GrGLVertexShaderBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLTextureSampler.h"
 #include "../GrGLPrimitiveProcessor.h"
 #include "../GrGLXferProcessor.h"
 #include "../../GrPipeline.h"
@@ -330,7 +331,7 @@ protected:
     void verify(const GrFragmentProcessor&);
     template <class Proc>
     void emitSamplers(const GrProcessor&,
-                      GrGLProcessor::TextureSamplerArray* outSamplers,
+                      GrGLSLTextureSampler::TextureSamplerArray* outSamplers,
                       GrGLInstalledProc<Proc>*);
 
     GrGLProgram* finalize();
index a3cc452..991ac91 100644 (file)
@@ -13,6 +13,7 @@
 #include "gl/GrGLGpu.h"
 #include "glsl/GrGLSLCaps.h"
 #include "glsl/GrGLSLShaderVar.h"
+#include "glsl/GrGLSLTextureSampler.h"
 
 namespace {
 void append_texture_lookup(SkString* out,
@@ -95,7 +96,7 @@ void GrGLShaderBuilder::emitFunction(GrSLType returnType,
 }
 
 void GrGLShaderBuilder::appendTextureLookup(SkString* out,
-                                            const TextureSampler& sampler,
+                                            const GrGLSLTextureSampler& sampler,
                                             const char* coordName,
                                             GrSLType varyingType) const {
     append_texture_lookup(out,
@@ -107,14 +108,14 @@ void GrGLShaderBuilder::appendTextureLookup(SkString* out,
                           varyingType);
 }
 
-void GrGLShaderBuilder::appendTextureLookup(const TextureSampler& sampler,
+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 TextureSampler& sampler,
+                                                       const GrGLSLTextureSampler& sampler,
                                                        const char* coordName,
                                                        GrSLType varyingType) {
     SkString lookup;
index b9bc72c..b5efbf4 100644 (file)
 class GrGLCaps;
 class GrGLContextInfo;
 class GrGLProgramBuilder;
+class GrGLSLTextureSampler;
 
 /**
   base class for all shaders builders
 */
 class GrGLShaderBuilder {
 public:
-    typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray;
-    typedef GrGLProcessor::TextureSampler TextureSampler;
-
     GrGLShaderBuilder(GrGLProgramBuilder* program);
 
     void addInput(const GrGLSLShaderVar& input) { fInputs.push_back(input); }
@@ -45,24 +43,25 @@ public:
      */
     /** 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 TextureSampler. */
+        order of the result depends on the GrTextureAccess associated with the GrGLSLTextureSampler.
+        */
     void appendTextureLookup(SkString* out,
-                             const TextureSampler&,
+                             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 TextureSampler&,
+    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 TextureSampler must both be vec4 or
-        float. If modulation is "" or nullptr it this function acts as though appendTextureLookup were
-        called. */
+        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 TextureSampler&,
+                                        const GrGLSLTextureSampler&,
                                         const char* coordName,
                                         GrSLType coordType = kVec2f_GrSLType);
 
diff --git a/src/gpu/glsl/GrGLSLProcessorTypes.h b/src/gpu/glsl/GrGLSLProcessorTypes.h
new file mode 100644 (file)
index 0000000..6410e5e
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLSLProcessorTypes_DEFINED
+#define GrGLSLProcessorTypes_DEFINED
+
+#include "GrShaderVar.h"
+
+/**
+ * These are meant to only be used by GrGLSL*Processors so they can add transformed coordinates
+ * to their shader code.
+ */
+typedef GrShaderVar GrGLSLTransformedCoords;
+typedef SkTArray<GrShaderVar> GrGLSLTransformedCoordsArray;
+
+#endif
index 29513f0..2009fea 100644 (file)
@@ -10,6 +10,8 @@
 
 #include "SkTypes.h"
 
+class SkMatrix;
+
 /** Manages the resources used by a shader program.
  * The resources are objects the program uses to communicate with the
  * application code.
diff --git a/src/gpu/glsl/GrGLSLTextureSampler.h b/src/gpu/glsl/GrGLSLTextureSampler.h
new file mode 100644 (file)
index 0000000..2f14cd1
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLSLTextureSampler_DEFINED
+#define GrGLSLTextureSampler_DEFINED
+
+#include "GrShaderVar.h"
+#include "GrTextureAccess.h"
+#include "glsl/GrGLSLProgramDataManager.h"
+
+class GrGLSLTextureSampler {
+public:
+    typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
+    typedef SkTArray<GrGLSLTextureSampler> TextureSamplerArray;
+
+    GrGLSLTextureSampler(UniformHandle uniform, const GrTextureAccess& access)
+        : fSamplerUniform(uniform)
+        , fConfigComponentMask(GrPixelConfigComponentMask(access.getTexture()->config())) {
+        SkASSERT(0 != fConfigComponentMask);
+        memcpy(fSwizzle, access.getSwizzle(), 5);
+    }
+
+    // bitfield of GrColorComponentFlags present in the texture's config.
+    uint32_t configComponentMask() const { return fConfigComponentMask; }
+    // this is .abcd
+    const char* swizzle() const { return fSwizzle; }
+
+private:
+    UniformHandle fSamplerUniform;
+    uint32_t      fConfigComponentMask;
+    char          fSwizzle[5];
+
+    friend class GrGLShaderBuilder;
+};
+
+#endif