| Index: src/gpu/gl/GrGLShaderVar.h
|
| diff --git a/src/gpu/gl/GrGLShaderVar.h b/src/gpu/gl/GrGLShaderVar.h
|
| index 68c4bbd23a332bc1c2edd7305874d9c4c90df9a6..8e7e36e232045426b54030c26e4ccc1715b1c1ab 100644
|
| --- a/src/gpu/gl/GrGLShaderVar.h
|
| +++ b/src/gpu/gl/GrGLShaderVar.h
|
| @@ -10,43 +10,15 @@
|
|
|
| #include "GrGLContext.h"
|
| #include "GrGLSL.h"
|
| -#include "SkString.h"
|
| +#include "GrShaderVar.h"
|
|
|
| #define USE_UNIFORM_FLOAT_ARRAYS true
|
|
|
| /**
|
| * Represents a variable in a shader
|
| */
|
| -class GrGLShaderVar {
|
| +class GrGLShaderVar : public GrShaderVar {
|
| public:
|
| -
|
| - /**
|
| - * Early versions of GLSL have Varying and Attribute; those are later
|
| - * deprecated, but we still need to know whether a Varying variable
|
| - * should be treated as In or Out.
|
| - */
|
| - enum TypeModifier {
|
| - kNone_TypeModifier,
|
| - kOut_TypeModifier,
|
| - kIn_TypeModifier,
|
| - kInOut_TypeModifier,
|
| - kUniform_TypeModifier,
|
| - kAttribute_TypeModifier,
|
| - kVaryingIn_TypeModifier,
|
| - kVaryingOut_TypeModifier
|
| - };
|
| -
|
| - enum Precision {
|
| - kLow_Precision, // lowp
|
| - kMedium_Precision, // mediump
|
| - kHigh_Precision, // highp
|
| - kDefault_Precision, // Default for the current context. We make
|
| - // fragment shaders default to mediump on ES2
|
| - // because highp support is not guaranteed (and
|
| - // we haven't been motivated to test for it).
|
| - // Otherwise, highp.
|
| - };
|
| -
|
| /**
|
| * See GL_ARB_fragment_coord_conventions.
|
| */
|
| @@ -58,36 +30,43 @@ public:
|
| /**
|
| * Defaults to a float with no precision specifier
|
| */
|
| - GrGLShaderVar() {
|
| - fType = kFloat_GrSLType;
|
| - fTypeModifier = kNone_TypeModifier;
|
| - fCount = kNonArray;
|
| - fPrecision = kDefault_Precision;
|
| - fOrigin = kDefault_Origin;
|
| - fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
|
| + GrGLShaderVar()
|
| + : GrShaderVar()
|
| + , fOrigin(kDefault_Origin)
|
| + , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
| }
|
|
|
| GrGLShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray,
|
| - Precision precision = kDefault_Precision) {
|
| + Precision precision = kDefault_Precision)
|
| + : GrShaderVar(name, type, arrayCount, precision)
|
| + , fOrigin(kDefault_Origin)
|
| + , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
| SkASSERT(kVoid_GrSLType != type);
|
| - fType = type;
|
| - fTypeModifier = kNone_TypeModifier;
|
| - fCount = arrayCount;
|
| - fPrecision = precision;
|
| fOrigin = kDefault_Origin;
|
| fUseUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS;
|
| - fName = name;
|
| + }
|
| +
|
| + GrGLShaderVar(const char* name, GrSLType type, TypeModifier typeModifier,
|
| + int arrayCount = kNonArray, Precision precision = kDefault_Precision)
|
| + : GrShaderVar(name, type, typeModifier, arrayCount, precision)
|
| + , fOrigin(kDefault_Origin)
|
| + , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
| + SkASSERT(kVoid_GrSLType != type);
|
| + }
|
| +
|
| + GrGLShaderVar(const GrShaderVar& var)
|
| + : GrShaderVar(var)
|
| + , fOrigin(kDefault_Origin)
|
| + , fUseUniformFloatArrays(USE_UNIFORM_FLOAT_ARRAYS) {
|
| + SkASSERT(kVoid_GrSLType != var.getType());
|
| }
|
|
|
| GrGLShaderVar(const GrGLShaderVar& var)
|
| - : fType(var.fType)
|
| - , fTypeModifier(var.fTypeModifier)
|
| - , fName(var.fName)
|
| - , fCount(var.fCount)
|
| - , fPrecision(var.fPrecision)
|
| + : GrShaderVar(var.c_str(), var.getType(), var.getTypeModifier(),
|
| + var.getArrayCount(), var.getPrecision())
|
| , fOrigin(var.fOrigin)
|
| , fUseUniformFloatArrays(var.fUseUniformFloatArrays) {
|
| - SkASSERT(kVoid_GrSLType != var.fType);
|
| + SkASSERT(kVoid_GrSLType != var.getType());
|
| }
|
|
|
| /**
|
| @@ -108,11 +87,7 @@ public:
|
| Origin origin = kDefault_Origin,
|
| bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
| SkASSERT(kVoid_GrSLType != type);
|
| - fType = type;
|
| - fTypeModifier = typeModifier;
|
| - fName = name;
|
| - fCount = kNonArray;
|
| - fPrecision = precision;
|
| + INHERITED::set(type, typeModifier, name, precision);
|
| fOrigin = origin;
|
| fUseUniformFloatArrays = useUniformFloatArrays;
|
| }
|
| @@ -127,11 +102,7 @@ public:
|
| Origin origin = kDefault_Origin,
|
| bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
| SkASSERT(kVoid_GrSLType != type);
|
| - fType = type;
|
| - fTypeModifier = typeModifier;
|
| - fName = name;
|
| - fCount = kNonArray;
|
| - fPrecision = precision;
|
| + INHERITED::set(type, typeModifier, name, precision);
|
| fOrigin = origin;
|
| fUseUniformFloatArrays = useUniformFloatArrays;
|
| }
|
| @@ -147,11 +118,7 @@ public:
|
| Origin origin = kDefault_Origin,
|
| bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
| SkASSERT(kVoid_GrSLType != type);
|
| - fType = type;
|
| - fTypeModifier = typeModifier;
|
| - fName = name;
|
| - fCount = count;
|
| - fPrecision = precision;
|
| + INHERITED::set(type, typeModifier, name, count, precision);
|
| fOrigin = origin;
|
| fUseUniformFloatArrays = useUniformFloatArrays;
|
| }
|
| @@ -167,83 +134,12 @@ public:
|
| Origin origin = kDefault_Origin,
|
| bool useUniformFloatArrays = USE_UNIFORM_FLOAT_ARRAYS) {
|
| SkASSERT(kVoid_GrSLType != type);
|
| - fType = type;
|
| - fTypeModifier = typeModifier;
|
| - fName = name;
|
| - fCount = count;
|
| - fPrecision = precision;
|
| + INHERITED::set(type, typeModifier, name, count, precision);
|
| fOrigin = origin;
|
| fUseUniformFloatArrays = useUniformFloatArrays;
|
| }
|
|
|
| /**
|
| - * Is the var an array.
|
| - */
|
| - bool isArray() const { return kNonArray != fCount; }
|
| - /**
|
| - * Is this an unsized array, (i.e. declared with []).
|
| - */
|
| - bool isUnsizedArray() const { return kUnsizedArray == fCount; }
|
| - /**
|
| - * Get the array length of the var.
|
| - */
|
| - int getArrayCount() const { return fCount; }
|
| - /**
|
| - * Set the array length of the var
|
| - */
|
| - void setArrayCount(int count) { fCount = count; }
|
| - /**
|
| - * Set to be a non-array.
|
| - */
|
| - void setNonArray() { fCount = kNonArray; }
|
| - /**
|
| - * Set to be an unsized array.
|
| - */
|
| - void setUnsizedArray() { fCount = kUnsizedArray; }
|
| -
|
| - /**
|
| - * Access the var name as a writable string
|
| - */
|
| - SkString* accessName() { return &fName; }
|
| - /**
|
| - * Set the var name
|
| - */
|
| - void setName(const SkString& n) { fName = n; }
|
| - void setName(const char* n) { fName = n; }
|
| -
|
| - /**
|
| - * Get the var name.
|
| - */
|
| - const SkString& getName() const { return fName; }
|
| -
|
| - /**
|
| - * Shortcut for this->getName().c_str();
|
| - */
|
| - const char* c_str() const { return this->getName().c_str(); }
|
| -
|
| - /**
|
| - * Get the type of the var
|
| - */
|
| - GrSLType getType() const { return fType; }
|
| - /**
|
| - * Set the type of the var
|
| - */
|
| - void setType(GrSLType type) { fType = type; }
|
| -
|
| - TypeModifier getTypeModifier() const { return fTypeModifier; }
|
| - void setTypeModifier(TypeModifier type) { fTypeModifier = type; }
|
| -
|
| - /**
|
| - * Get the precision of the var
|
| - */
|
| - Precision getPrecision() const { return fPrecision; }
|
| -
|
| - /**
|
| - * Set the precision of the var
|
| - */
|
| - void setPrecision(Precision p) { fPrecision = p; }
|
| -
|
| - /**
|
| * Get the origin of the var
|
| */
|
| Origin getOrigin() const { return fOrigin; }
|
| @@ -346,15 +242,12 @@ private:
|
| }
|
| }
|
|
|
| - GrSLType fType;
|
| - TypeModifier fTypeModifier;
|
| - SkString fName;
|
| - int fCount;
|
| - Precision fPrecision;
|
| Origin fOrigin;
|
| /// Work around driver bugs on some hardware that don't correctly
|
| /// support uniform float []
|
| bool fUseUniformFloatArrays;
|
| +
|
| + typedef GrShaderVar INHERITED;
|
| };
|
|
|
| #endif
|
|
|