aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLProgram.h
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-13 16:03:51 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-13 16:03:51 +0000
commit6a51dcbf81cff6d92996ab3f4c7457478e441896 (patch)
tree34448546ebbe9095235e96a53cfa604a724fdcd6 /src/gpu/gl/GrGLProgram.h
parent1eeef1646d230cd352778a2b0f67725a60028595 (diff)
Attempt to reland r7713 with fix.
git-svn-id: http://skia.googlecode.com/svn/trunk@7719 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl/GrGLProgram.h')
-rw-r--r--src/gpu/gl/GrGLProgram.h37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index fd5e8e4b8e..5d02ba2a9c 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -74,6 +74,11 @@ public:
const Desc& getDesc() { return fDesc; }
/**
+ * Gets the GL program ID for this program.
+ */
+ GrGLuint programID() const { return fProgramID; }
+
+ /**
* Attribute indices. These should not overlap.
*/
static int PositionAttributeIdx() { return 0; }
@@ -99,6 +104,25 @@ public:
};
/**
+ * The GrDrawState's view matrix along with the aspects of the render target determine the
+ * matrix sent to GL. The size of the render target affects the GL matrix because we must
+ * convert from Skia device coords to GL's normalized coords. Also the origin of the render
+ * target may require us to perform a mirror-flip.
+ */
+ struct MatrixState {
+ SkMatrix fViewMatrix;
+ SkISize fRenderTargetSize;
+ GrSurfaceOrigin fRenderTargetOrigin;
+
+ MatrixState() { this->invalidate(); }
+ void invalidate() {
+ fViewMatrix = SkMatrix::InvalidMatrix();
+ fRenderTargetSize.fWidth = -1; // just make the first value compared illegal.
+ fRenderTargetOrigin = (GrSurfaceOrigin) -1;
+ }
+ };
+
+ /**
* This function uploads uniforms and calls each GrGLEffect's setData. It is called before a
* draw occurs using the program after the program has already been bound. It also uses the
* GrGpuGL object to bind the textures required by the GrGLEffects.
@@ -174,6 +198,7 @@ public:
friend class GrGLProgram;
};
+
private:
GrGLProgram(const GrGLContextInfo& gl,
const Desc& desc,
@@ -220,6 +245,9 @@ private:
// per-vertex coverages.
void setCoverage(const GrDrawState&, GrColor coverage, SharedGLState*);
+ // Helper for setData() that sets the view matrix and loads the render target height uniform
+ void setMatrixAndRenderTargetHeight(const GrDrawState&);
+
typedef SkSTArray<4, UniformHandle, true> SamplerUniSArray;
struct UniformHandles {
@@ -247,17 +275,12 @@ private:
GrGLuint fGShaderID;
GrGLuint fFShaderID;
GrGLuint fProgramID;
- // The matrix sent to GL is determined by the client's matrix,
- // the size of the viewport, and the origin of the render target.
- SkMatrix fViewMatrix;
- SkISize fViewportSize;
- GrSurfaceOrigin fOrigin;
// these reflect the current values of uniforms (GL uniform values travel with program)
+ MatrixState fMatrixState;
GrColor fColor;
GrColor fCoverage;
GrColor fColorFilterColor;
- int fRTHeight;
GrGLEffect* fEffects[GrDrawState::kNumStages];
@@ -267,8 +290,6 @@ private:
GrGLUniformManager fUniformManager;
UniformHandles fUniformHandles;
- friend class GrGpuGL; // TODO: remove this by adding getters and moving functionality.
-
typedef GrRefCnt INHERITED;
};