class GrGpuGL;
class SkMatrix;
class GrGLProgram;
-class GrGLShaderBuilder;
+class GrGLProgramBuilder;
/** Manages the resources used by a shader program.
* The resources are objects the program uses to communicate with the
class GrGLProgramDataManager : public SkRefCnt {
public:
// Opaque handle to a uniform
- class UniformHandle {
+ class ShaderResourceHandle {
public:
- /** Creates a reference to an unifrom of a GrGLShaderBuilder.
- * The ref can be used to set the uniform with corresponding the GrGLProgramDataManager.*/
- static UniformHandle CreateFromUniformIndex(int i);
-
bool isValid() const { return -1 != fValue; }
-
- bool operator==(const UniformHandle& other) const { return other.fValue == fValue; }
-
- UniformHandle()
+ ShaderResourceHandle()
: fValue(-1) {
}
-
- private:
- UniformHandle(int value)
+ protected:
+ ShaderResourceHandle(int value)
: fValue(value) {
SkASSERT(isValid());
}
+ int fValue;
+ };
+ class UniformHandle : public ShaderResourceHandle {
+ public:
+ /** Creates a reference to an unifrom of a GrGLShaderBuilder.
+ * The ref can be used to set the uniform with corresponding the GrGLProgramDataManager.*/
+ static UniformHandle CreateFromUniformIndex(int i);
+ UniformHandle() { }
+ bool operator==(const UniformHandle& other) const { return other.fValue == fValue; }
+ private:
+ UniformHandle(int value) : ShaderResourceHandle(value) { }
int toProgramDataIndex() const { SkASSERT(isValid()); return fValue; }
int toShaderBuilderIndex() const { return toProgramDataIndex(); }
- int fValue;
friend class GrGLProgramDataManager; // For accessing toProgramDataIndex().
- friend class GrGLShaderBuilder; // For accessing toShaderBuilderIndex().
+ friend class GrGLProgramBuilder; // For accessing toShaderBuilderIndex().
};
- GrGLProgramDataManager(GrGpuGL*, GrGLProgram*, const GrGLShaderBuilder&);
+ class VaryingHandle : public ShaderResourceHandle {
+ public:
+ /** Creates a reference to a varying in separable varyings of a GrGLShaderBuilder.
+ * The ref can be used to set the varying with the corresponding GrGLProgramDataManager.*/
+ static VaryingHandle CreateFromSeparableVaryingIndex(int i) {
+ return VaryingHandle(i);
+ }
+ VaryingHandle() { }
+ bool operator==(const VaryingHandle& other) const { return other.fValue == fValue; }
+ private:
+ VaryingHandle(int value) : ShaderResourceHandle(value) { }
+ int toProgramDataIndex() const { SkASSERT(isValid()); return fValue; }
+ friend class GrGLProgramDataManager; // For accessing toProgramDataIndex().
+ };
+
+ GrGLProgramDataManager(GrGpuGL*, GrGLProgram*, const GrGLProgramBuilder&);
/** Functions for uploading uniform values. The varities ending in v can be used to upload to an
* array of uniforms. arrayCount must be <= the array count of the uniform.
// convenience method for uploading a SkMatrix to a 3x3 matrix uniform
void setSkMatrix(UniformHandle, const SkMatrix&) const;
+ void setProgramPathFragmentInputTransform(VaryingHandle i,
+ unsigned components,
+ const SkMatrix& matrix) const;
+
private:
enum {
kUnusedUniform = -1,
int fArrayCount;
);
};
+ struct Varying {
+ GrGLint fLocation;
+ SkDEBUGCODE(
+ GrSLType fType;
+ );
+ };
SkTArray<Uniform, true> fUniforms;
+ SkTArray<Varying, true> fVaryings;
GrGpuGL* fGpu;
+ GrGLProgram* fProgram;
typedef SkRefCnt INHERITED;
};