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

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

Issue 426553011: Make GrGLProgram be available to GrGLProgramDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix win warning 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLProgram.cpp ('k') | src/gpu/gl/GrGLProgramDataManager.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLProgramDataManager.h
diff --git a/src/gpu/gl/GrGLProgramDataManager.h b/src/gpu/gl/GrGLProgramDataManager.h
index ebbcf54782c1b6a9cbf4301e0af343980e0cc087..8ef4a41fbc0158fb2e8bce6ca4aa8ec30233c77f 100644
--- a/src/gpu/gl/GrGLProgramDataManager.h
+++ b/src/gpu/gl/GrGLProgramDataManager.h
@@ -16,6 +16,8 @@
class GrGpuGL;
class SkMatrix;
+class GrGLProgram;
+class GrGLShaderBuilder;
/** Manages the resources used by a shader program.
* The resources are objects the program uses to communicate with the
@@ -26,31 +28,33 @@ public:
// Opaque handle to a uniform
class UniformHandle {
public:
+ /** Creates a reference to an unifrom of a GrGLShaderBuilder.
+ * The ref can be used to set the uniform with corresponding the GrGLProgramDataManager.*/
static UniformHandle CreateFromUniformIndex(int i);
- bool isValid() const { return 0 != fValue; }
+ bool isValid() const { return -1 != fValue; }
bool operator==(const UniformHandle& other) const { return other.fValue == fValue; }
UniformHandle()
- : fValue(0) {
+ : fValue(-1) {
}
private:
UniformHandle(int value)
- : fValue(~value) {
+ : fValue(value) {
SkASSERT(isValid());
}
- int toUniformIndex() const { SkASSERT(isValid()); return ~fValue; }
+ int toProgramDataIndex() const { SkASSERT(isValid()); return fValue; }
+ int toShaderBuilderIndex() const { return toProgramDataIndex(); }
int fValue;
- friend class GrGLProgramDataManager; // For accessing toUniformIndex().
+ friend class GrGLProgramDataManager; // For accessing toProgramDataIndex().
+ friend class GrGLShaderBuilder; // For accessing toShaderBuilderIndex().
};
- GrGLProgramDataManager(GrGpuGL* gpu);
-
- UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::kNonArray);
+ GrGLProgramDataManager(GrGpuGL*, GrGLProgram*, const GrGLShaderBuilder&);
/** Functions for uploading uniform values. The varities ending in v can be used to upload to an
* array of uniforms. arrayCount must be <= the array count of the uniform.
@@ -74,32 +78,6 @@ public:
// convenience method for uploading a SkMatrix to a 3x3 matrix uniform
void setSkMatrix(UniformHandle, const SkMatrix&) const;
- struct BuilderUniform {
- GrGLShaderVar fVariable;
- uint32_t fVisibility;
- };
- // This uses an allocator rather than array so that the GrGLShaderVars don't move in memory
- // after they are inserted. Users of GrGLShaderBuilder get refs to the vars and ptrs to their
- // name strings. Otherwise, we'd have to hand out copies.
- typedef GrTAllocator<BuilderUniform> BuilderUniformArray;
-
- /**
- * Called by the GrGLShaderBuilder to know if the manager is using
- * BindUniformLocation. In that case getUniformLocations must be called
- * before the program is linked.
- */
- bool isUsingBindUniform() const { return fUsingBindUniform; }
-
- /**
- * Called by the GrGLShaderBuilder to get GL locations for all uniforms.
- */
- void getUniformLocations(GrGLuint programID, const BuilderUniformArray& uniforms);
-
- /**
- * Called by the GrGLShaderBuilder to access the array by the handle (index).
- */
- const BuilderUniform& getBuilderUniform(const BuilderUniformArray&, GrGLProgramDataManager::UniformHandle) const;
-
private:
enum {
kUnusedUniform = -1,
@@ -108,11 +86,12 @@ private:
struct Uniform {
GrGLint fVSLocation;
GrGLint fFSLocation;
- GrSLType fType;
- int fArrayCount;
+ SkDEBUGCODE(
+ GrSLType fType;
+ int fArrayCount;
+ );
};
- bool fUsingBindUniform;
SkTArray<Uniform, true> fUniforms;
GrGpuGL* fGpu;
« 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