diff options
author | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-24 17:44:30 +0000 |
---|---|---|
committer | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-24 17:44:30 +0000 |
commit | 5259814305e3290dea3b197301f7824a14c5fa6f (patch) | |
tree | 7f04020f99f01833c1d8e63b910c8490b0ae0e34 /src/gpu/gl/GrGLShaderBuilder.h | |
parent | 3fd979874c5bd233a8f731fb68fca87f84712a52 (diff) |
Move swizzle & modulation computation, non-virtual functions onto
GrGLShaderBuilder. This lets us access all the default computations
when there's no GrCustomStage specified, and means that GrGLProgramStage
is effectively an interface class, all of whose functions can/should
be overriden.
http://codereview.appspot.com/6242051/
git-svn-id: http://skia.googlecode.com/svn/trunk@4045 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl/GrGLShaderBuilder.h')
-rw-r--r-- | src/gpu/gl/GrGLShaderBuilder.h | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/src/gpu/gl/GrGLShaderBuilder.h b/src/gpu/gl/GrGLShaderBuilder.h index 6a7e279748..889219d876 100644 --- a/src/gpu/gl/GrGLShaderBuilder.h +++ b/src/gpu/gl/GrGLShaderBuilder.h @@ -37,6 +37,38 @@ public: const char** vsOutName = NULL, const char** fsInName = NULL); + void computeSwizzle(uint32_t configFlags); + void computeModulate(const char* fsInColor); + + void emitTextureSetup(); + + /** texture2D(samplerName, coordName), with projection + if necessary; if coordName is not specified, + uses fSampleCoords. */ + void emitTextureLookup(const char* samplerName, + const char* coordName = NULL); + + /** sets outColor to results of texture lookup, with + swizzle, and/or modulate as necessary */ + void emitDefaultFetch(const char* outColor, + const char* samplerName); + + // TODO: needs a better name + enum SamplerMode { + kDefault_SamplerMode, + kProj_SamplerMode, + kExplicitDivide_SamplerMode // must do an explicit divide + }; + + // TODO: computing this requires information about fetch mode + // && coord mapping, as well as StageDesc::fOptFlags - proably + // need to set up default value and have some custom stages + // override as necessary? + void setSamplerMode(SamplerMode samplerMode) { + fSamplerMode = samplerMode; + } + + GrStringBuilder fHeader; // VS+FS, GLSL version, etc VarArray fVSUnis; VarArray fVSAttrs; @@ -53,16 +85,26 @@ public: GrStringBuilder fFSCode; bool fUsesGS; - /// Per-stage settings + /// Per-stage settings - only valid while we're inside + /// GrGLProgram::genStageCode(). //@{ - int fVaryingDims; + int fVaryingDims; static const int fCoordDims = 2; +protected: + + SamplerMode fSamplerMode; + +public: + /// True if fSampleCoords is an expression; false if it's a bare /// variable name - bool fComplexCoord; - GrStringBuilder fSampleCoords; + bool fComplexCoord; + GrStringBuilder fSampleCoords; + + GrStringBuilder fSwizzle; + GrStringBuilder fModulate; //@} |