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

Side by Side Diff: src/gpu/gl/GrGLProgramDataManager.h

Issue 365853002: Rename GrGLUniformManager to GrGLProgramResourceManager (Closed) Base URL: https://skia.googlesource.com/skia.git@02-path-program-fragment
Patch Set: rebase Created 6 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
« no previous file with comments | « src/gpu/gl/GrGLProgram.cpp ('k') | src/gpu/gl/GrGLProgramDataManager.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrGLUniformManager_DEFINED 8 #ifndef GrGLProgramDataManager_DEFINED
9 #define GrGLUniformManager_DEFINED 9 #define GrGLProgramDataManager_DEFINED
10 10
11 #include "gl/GrGLShaderVar.h" 11 #include "gl/GrGLShaderVar.h"
12 #include "gl/GrGLSL.h" 12 #include "gl/GrGLSL.h"
13 #include "GrAllocator.h" 13 #include "GrAllocator.h"
14 14
15 #include "SkTArray.h" 15 #include "SkTArray.h"
16 16
17 class GrGpuGL; 17 class GrGpuGL;
18 class SkMatrix; 18 class SkMatrix;
19 19
20 /** Manages a program's uniforms. 20 /** Manages the resources used by a shader program.
21 */ 21 * The resources are objects the program uses to communicate with the
22 class GrGLUniformManager : public SkRefCnt { 22 * application code.
23 */
24 class GrGLProgramDataManager : public SkRefCnt {
23 public: 25 public:
24 // Opaque handle to a uniform 26 // Opaque handle to a uniform
25 class UniformHandle { 27 class UniformHandle {
26 public: 28 public:
27 static UniformHandle CreateFromUniformIndex(int i); 29 static UniformHandle CreateFromUniformIndex(int i);
28 30
29 bool isValid() const { return 0 != fValue; } 31 bool isValid() const { return 0 != fValue; }
30 32
31 bool operator==(const UniformHandle& other) const { return other.fValue == fValue; } 33 bool operator==(const UniformHandle& other) const { return other.fValue == fValue; }
32 34
33 UniformHandle() 35 UniformHandle()
34 : fValue(0) { 36 : fValue(0) {
35 } 37 }
36 38
37 private: 39 private:
38 UniformHandle(int value) 40 UniformHandle(int value)
39 : fValue(~value) { 41 : fValue(~value) {
40 SkASSERT(isValid()); 42 SkASSERT(isValid());
41 } 43 }
42 44
43 int toUniformIndex() const { SkASSERT(isValid()); return ~fValue; } 45 int toUniformIndex() const { SkASSERT(isValid()); return ~fValue; }
44 46
45 int fValue; 47 int fValue;
46 friend class GrGLUniformManager; // For accessing toUniformIndex(). 48 friend class GrGLProgramDataManager; // For accessing toUniformIndex().
47 }; 49 };
48 50
49 GrGLUniformManager(GrGpuGL* gpu); 51 GrGLProgramDataManager(GrGpuGL* gpu);
50 52
51 UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::k NonArray); 53 UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::k NonArray);
52 54
53 /** Functions for uploading uniform values. The varities ending in v can be used to upload to an 55 /** Functions for uploading uniform values. The varities ending in v can be used to upload to an
54 * array of uniforms. arrayCount must be <= the array count of the uniform. 56 * array of uniforms. arrayCount must be <= the array count of the uniform.
55 */ 57 */
56 void setSampler(UniformHandle, GrGLint texUnit) const; 58 void setSampler(UniformHandle, GrGLint texUnit) const;
57 void set1f(UniformHandle, GrGLfloat v0) const; 59 void set1f(UniformHandle, GrGLfloat v0) const;
58 void set1fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; 60 void set1fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
59 void set2f(UniformHandle, GrGLfloat, GrGLfloat) const; 61 void set2f(UniformHandle, GrGLfloat, GrGLfloat) const;
(...skipping 29 matching lines...) Expand all
89 bool isUsingBindUniform() const { return fUsingBindUniform; } 91 bool isUsingBindUniform() const { return fUsingBindUniform; }
90 92
91 /** 93 /**
92 * Called by the GrGLShaderBuilder to get GL locations for all uniforms. 94 * Called by the GrGLShaderBuilder to get GL locations for all uniforms.
93 */ 95 */
94 void getUniformLocations(GrGLuint programID, const BuilderUniformArray& unif orms); 96 void getUniformLocations(GrGLuint programID, const BuilderUniformArray& unif orms);
95 97
96 /** 98 /**
97 * Called by the GrGLShaderBuilder to access the array by the handle (index) . 99 * Called by the GrGLShaderBuilder to access the array by the handle (index) .
98 */ 100 */
99 const BuilderUniform& getBuilderUniform(const BuilderUniformArray&, GrGLUnif ormManager::UniformHandle) const; 101 const BuilderUniform& getBuilderUniform(const BuilderUniformArray&, GrGLProg ramDataManager::UniformHandle) const;
100 102
101 private: 103 private:
102 enum { 104 enum {
103 kUnusedUniform = -1, 105 kUnusedUniform = -1,
104 }; 106 };
105 107
106 struct Uniform { 108 struct Uniform {
107 GrGLint fVSLocation; 109 GrGLint fVSLocation;
108 GrGLint fFSLocation; 110 GrGLint fFSLocation;
109 GrSLType fType; 111 GrSLType fType;
110 int fArrayCount; 112 int fArrayCount;
111 }; 113 };
112 114
113 bool fUsingBindUniform; 115 bool fUsingBindUniform;
114 SkTArray<Uniform, true> fUniforms; 116 SkTArray<Uniform, true> fUniforms;
115 GrGpuGL* fGpu; 117 GrGpuGL* fGpu;
116 118
117 typedef SkRefCnt INHERITED; 119 typedef SkRefCnt INHERITED;
118 }; 120 };
119 121
120 #endif 122 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgram.cpp ('k') | src/gpu/gl/GrGLProgramDataManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698