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

Side by Side Diff: src/gpu/gl/GrGLUniformManager.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLUniformHandle.h ('k') | src/gpu/gl/GrGLUniformManager.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef GrGLUniformManager_DEFINED
9 #define GrGLUniformManager_DEFINED
10
11 #include "gl/GrGLShaderVar.h"
12 #include "gl/GrGLSL.h"
13 #include "GrAllocator.h"
14
15 #include "SkTArray.h"
16
17 class GrGLContext;
18 class SkMatrix;
19
20 /** Manages a program's uniforms.
21 */
22 class GrGLUniformManager {
23 public:
24 // Opaque handle to a uniform
25 typedef int UniformHandle;
26 static const UniformHandle kInvalidUniformHandle = 0;
27
28 GrGLUniformManager(const GrGLContext& context) : fContext(context) {}
29
30 UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::k NonArray);
31
32 /** Functions for uploading uniform values. The varities ending in v can be used to upload to an
33 * array of uniforms. offset + arrayCount must be <= the array count of the uniform.
34 */
35 void setSampler(UniformHandle, GrGLint texUnit) const;
36 void set1f(UniformHandle, GrGLfloat v0) const;
37 void set1fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[]) const;
38 void set2f(UniformHandle, GrGLfloat, GrGLfloat) const;
39 void set2fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[]) const;
40 void set3f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat) const;
41 void set3fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[]) const;
42 void set4f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const;
43 void set4fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[]) const;
44 // matrices are column-major, the first three upload a single matrix, the la tter three upload
45 // arrayCount matrices into a uniform array.
46 void setMatrix3f(UniformHandle, const GrGLfloat matrix[]) const;
47 void setMatrix4f(UniformHandle, const GrGLfloat matrix[]) const;
48 void setMatrix3fv(UniformHandle, int offset, int arrayCount, const GrGLfloat matrices[]) const;
49 void setMatrix4fv(UniformHandle, int offset, int arrayCount, const GrGLfloat matrices[]) const;
50
51 // convenience method for uploading a SkMatrix to a 3x3 matrix uniform
52 void setSkMatrix(UniformHandle, const SkMatrix&) const;
53
54 struct BuilderUniform {
55 GrGLShaderVar fVariable;
56 uint32_t fVisibility;
57 };
58 // This uses an allocator rather than array so that the GrGLShaderVars don't move in memory
59 // after they are inserted. Users of GrGLShaderBuilder get refs to the vars and ptrs to their
60 // name strings. Otherwise, we'd have to hand out copies.
61 typedef GrTAllocator<BuilderUniform> BuilderUniformArray;
62
63 /**
64 * Called by the GrGLShaderBuilder to get GL locations for all uniforms.
65 */
66 void getUniformLocations(GrGLuint programID, const BuilderUniformArray& unif orms);
67
68 private:
69 enum {
70 kUnusedUniform = -1,
71 };
72
73 struct Uniform {
74 GrGLint fVSLocation;
75 GrGLint fFSLocation;
76 GrSLType fType;
77 int fArrayCount;
78 };
79
80 SkTArray<Uniform, true> fUniforms;
81 const GrGLContext& fContext;
82 };
83
84 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLUniformHandle.h ('k') | src/gpu/gl/GrGLUniformManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698