aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2015-10-29 07:57:01 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-29 07:57:02 -0700
commit7dc4bd06fca73a97dcf3ad4a7425597160f1edfc (patch)
treee257695fd2e59d57bb226d754a8c2c374f6360d7
parentcc92b4a7eca78dcec23d14ccd4ecf5889c35caa1 (diff)
Remove GrGLProcessor and create GrGLSLTextureSampler class.
Part ??? of separating glsl and gl BUG=skia: Review URL: https://codereview.chromium.org/1425013003
-rw-r--r--gm/dcshader.cpp1
-rw-r--r--gyp/gpu.gypi3
-rw-r--r--src/core/SkLightingShader.cpp1
-rw-r--r--src/effects/SkBlurMaskFilter.cpp3
-rw-r--r--src/gpu/GrOvalRenderer.cpp1
-rw-r--r--src/gpu/GrPathProcessor.cpp4
-rw-r--r--src/gpu/batches/GrAAConvexPathRenderer.cpp1
-rw-r--r--src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp1
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp3
-rw-r--r--src/gpu/effects/GrTextureDomain.h24
-rw-r--r--src/gpu/gl/GrGLFragmentProcessor.cpp3
-rw-r--r--src/gpu/gl/GrGLFragmentProcessor.h13
-rw-r--r--src/gpu/gl/GrGLGeometryProcessor.cpp5
-rw-r--r--src/gpu/gl/GrGLPrimitiveProcessor.h13
-rw-r--r--src/gpu/gl/GrGLProcessor.h69
-rw-r--r--src/gpu/gl/GrGLProgram.h3
-rw-r--r--src/gpu/gl/GrGLXferProcessor.h6
-rw-r--r--src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp4
-rw-r--r--src/gpu/gl/builders/GrGLFragmentShaderBuilder.h7
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp11
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.h3
-rw-r--r--src/gpu/gl/builders/GrGLShaderBuilder.cpp7
-rw-r--r--src/gpu/gl/builders/GrGLShaderBuilder.h19
-rw-r--r--src/gpu/glsl/GrGLSLProcessorTypes.h20
-rw-r--r--src/gpu/glsl/GrGLSLProgramDataManager.h2
-rw-r--r--src/gpu/glsl/GrGLSLTextureSampler.h40
26 files changed, 132 insertions, 135 deletions
diff --git a/gm/dcshader.cpp b/gm/dcshader.cpp
index e161f4da58..d7eb3b518f 100644
--- a/gm/dcshader.cpp
+++ b/gm/dcshader.cpp
@@ -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"
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index 43841d3de2..5016598802 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -323,7 +323,6 @@
'<(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',
@@ -368,8 +367,10 @@
'<(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',
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index 4c8ed3bb1d..d3d6a2849f 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -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"
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 8c47e0349c..5a25e54b41 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -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,
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index a647e62af0..b0a7f3adff 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -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"
diff --git a/src/gpu/GrPathProcessor.cpp b/src/gpu/GrPathProcessor.cpp
index e4050a9e92..9728e59106 100644
--- a/src/gpu/GrPathProcessor.cpp
+++ b/src/gpu/GrPathProcessor.cpp
@@ -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));
}
}
diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp
index cb015f80ff..02f4143967 100644
--- a/src/gpu/batches/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp
@@ -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"
diff --git a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
index a7e98249e2..4585c10214 100644
--- a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
@@ -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"
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 760fd57507..29d5fc9453 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -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();)
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index 0b93ac859f..bbe988cf1b 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -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);
diff --git a/src/gpu/gl/GrGLFragmentProcessor.cpp b/src/gpu/gl/GrGLFragmentProcessor.cpp
index 5f30262508..dcc6cb10dc 100644
--- a/src/gpu/gl/GrGLFragmentProcessor.cpp
+++ b/src/gpu/gl/GrGLFragmentProcessor.cpp
@@ -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]);
diff --git a/src/gpu/gl/GrGLFragmentProcessor.h b/src/gpu/gl/GrGLFragmentProcessor.h
index 00bd063d8e..2a78bbdee0 100644
--- a/src/gpu/gl/GrGLFragmentProcessor.h
+++ b/src/gpu/gl/GrGLFragmentProcessor.h
@@ -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
diff --git a/src/gpu/gl/GrGLGeometryProcessor.cpp b/src/gpu/gl/GrGLGeometryProcessor.cpp
index 8998af4d65..ff4574229d 100644
--- a/src/gpu/gl/GrGLGeometryProcessor.cpp
+++ b/src/gpu/gl/GrGLGeometryProcessor.cpp
@@ -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));
}
}
diff --git a/src/gpu/gl/GrGLPrimitiveProcessor.h b/src/gpu/gl/GrGLPrimitiveProcessor.h
index cff964037d..6d4c195fd7 100644
--- a/src/gpu/gl/GrGLPrimitiveProcessor.h
+++ b/src/gpu/gl/GrGLPrimitiveProcessor.h
@@ -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
index c389ce4bfa..0000000000
--- a/src/gpu/gl/GrGLProcessor.h
+++ /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
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index dc64a70d26..117d5a2a53 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -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.)
diff --git a/src/gpu/gl/GrGLXferProcessor.h b/src/gpu/gl/GrGLXferProcessor.h
index bf16cf4d36..d4619974cd 100644
--- a/src/gpu/gl/GrGLXferProcessor.h
+++ b/src/gpu/gl/GrGLXferProcessor.h
@@ -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
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
index 73098547a8..6f049588f6 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
@@ -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();
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
index 4f17b68ae6..ed92703a01 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
@@ -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;
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index b74a8673cd..2afd3c4ab4 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -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)));
}
}
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index 7690b39a8b..474544060b 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -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();
diff --git a/src/gpu/gl/builders/GrGLShaderBuilder.cpp b/src/gpu/gl/builders/GrGLShaderBuilder.cpp
index a3cc452e70..991ac91176 100644
--- a/src/gpu/gl/builders/GrGLShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLShaderBuilder.cpp
@@ -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;
diff --git a/src/gpu/gl/builders/GrGLShaderBuilder.h b/src/gpu/gl/builders/GrGLShaderBuilder.h
index b9bc72cc06..b5efbf4f89 100644
--- a/src/gpu/gl/builders/GrGLShaderBuilder.h
+++ b/src/gpu/gl/builders/GrGLShaderBuilder.h
@@ -19,15 +19,13 @@
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
index 0000000000..6410e5eee1
--- /dev/null
+++ b/src/gpu/glsl/GrGLSLProcessorTypes.h
@@ -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
diff --git a/src/gpu/glsl/GrGLSLProgramDataManager.h b/src/gpu/glsl/GrGLSLProgramDataManager.h
index 29513f08b0..2009feab13 100644
--- a/src/gpu/glsl/GrGLSLProgramDataManager.h
+++ b/src/gpu/glsl/GrGLSLProgramDataManager.h
@@ -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
index 0000000000..2f14cd1013
--- /dev/null
+++ b/src/gpu/glsl/GrGLSLTextureSampler.h
@@ -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