| Index: src/gpu/gl/GrGLUniform.h
|
| diff --git a/src/gpu/gl/GrGLUniform.h b/src/gpu/gl/GrGLUniform.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b0f5de4ab434536cd58ef2547536fb30bb0b3fce
|
| --- /dev/null
|
| +++ b/src/gpu/gl/GrGLUniform.h
|
| @@ -0,0 +1,74 @@
|
| +/*
|
| + * 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 GrGLUniform_DEFINED
|
| +#define GrGLUniform_DEFINED
|
| +
|
| +#include "gl/GrGLShaderVar.h"
|
| +#include "gl/GrGLSL.h"
|
| +#include "GrAllocator.h"
|
| +
|
| +#include "SkTArray.h"
|
| +
|
| +class GrGLContext;
|
| +class SkMatrix;
|
| +
|
| +/** Wrapper for a uniform in a program.
|
| +*/
|
| +class GrGLUniform {
|
| + enum {
|
| + kUnusedUniform = -1,
|
| + };
|
| +
|
| +public:
|
| + GrGLUniform()
|
| + : fVSLocation(kUnusedUniform)
|
| + , fFSLocation(kUnusedUniform) {
|
| + }
|
| +
|
| +#if GR_DEBUG
|
| + void initType(int arrayCount, GrSLType type) {
|
| + GrAssert(GrGLShaderVar::kNonArray == arrayCount || arrayCount > 0);
|
| + fArrayCount = arrayCount;
|
| + fType = type;
|
| + }
|
| +#endif
|
| +
|
| + void initLocations(const GrGLContext& context, GrGLuint programID, const char* name, uint32_t visibility);
|
| +
|
| + /** Functions for uploading uniform values. The varities ending in v can be used to upload to an
|
| + * array of uniforms. offset + arrayCount must be <= the array count of the uniform.
|
| + */
|
| + void setSampler(const GrGLContext&, GrGLint texUnit) const;
|
| + void set1f(const GrGLContext&, GrGLfloat v0) const;
|
| + void set1fv(const GrGLContext&, int offset, int arrayCount, const GrGLfloat v[]) const;
|
| + void set2f(const GrGLContext&, GrGLfloat, GrGLfloat) const;
|
| + void set2fv(const GrGLContext&, int offset, int arrayCount, const GrGLfloat v[]) const;
|
| + void set3f(const GrGLContext&, GrGLfloat, GrGLfloat, GrGLfloat) const;
|
| + void set3fv(const GrGLContext&, int offset, int arrayCount, const GrGLfloat v[]) const;
|
| + void set4f(const GrGLContext&, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const;
|
| + void set4fv(const GrGLContext&, int offset, int arrayCount, const GrGLfloat v[]) const;
|
| + // matrices are column-major, the first three upload a single matrix, the latter three upload
|
| + // arrayCount matrices into a uniform array.
|
| + void setMatrix3f(const GrGLContext&, const GrGLfloat matrix[]) const;
|
| + void setMatrix4f(const GrGLContext&, const GrGLfloat matrix[]) const;
|
| + void setMatrix3fv(const GrGLContext&, int offset, int arrayCount, const GrGLfloat matrices[]) const;
|
| + void setMatrix4fv(const GrGLContext&, int offset, int arrayCount, const GrGLfloat matrices[]) const;
|
| +
|
| + // convenience method for uploading a SkMatrix to a 3x3 matrix uniform
|
| + void setSkMatrix(const GrGLContext&, const SkMatrix&) const;
|
| +
|
| +private:
|
| + GrGLint fVSLocation;
|
| + GrGLint fFSLocation;
|
| +#if GR_DEBUG
|
| + int fArrayCount;
|
| + GrSLType fType;
|
| +#endif
|
| +};
|
| +
|
| +#endif
|
|
|