Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2283)

Unified Diff: src/gpu/gl/GrGLUniform.h

Issue 23018003: Rename GrGLUniformManager to GrGLUniform and ref GrGLUniforms directly Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.cpp ('k') | src/gpu/gl/GrGLUniform.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.cpp ('k') | src/gpu/gl/GrGLUniform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698