summaryrefslogtreecommitdiff
path: root/vcl/inc
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-05-12 13:37:11 +0900
committerTomaž Vajngerl <quikee@gmail.com>2016-05-19 02:47:57 +0000
commite480b2cf3e362760de8e35cbb950104e47ebe7ec (patch)
tree0d6cff1c68d392466104bcd48f056e8c300d26d6 /vcl/inc
parentbd3ed061de068a03a7c75f093c9a9bd7b6f3ba57 (diff)
opengl: track the state of blend, DrawArrays on OpenGLProgram
This adds tracking of GL_BLEND and glBlendFunc which are usually set when setting up the current draw call on OpenGLProgram with SetBlendFunc method. Until now the final draw call (glDrawArrays) was called outside of OpenGLProgram. This is a problem because we need to know if we did call SetBlendFunc or not between when we used or reused the current program. So we added DrawArrays to OpenGLProgram and refactored all draw calls in OpenGLSalGraphicsImpl to use this. From now on glDrawArrays should not be called directly but always through OpenGLProgram. Change-Id: I530b4b948af8a962669a3751e1a95ff3986ffec9 Reviewed-on: https://gerrit.libreoffice.org/25083 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/inc')
-rw-r--r--vcl/inc/opengl/RenderState.hxx27
-rw-r--r--vcl/inc/opengl/program.hxx5
2 files changed, 32 insertions, 0 deletions
diff --git a/vcl/inc/opengl/RenderState.hxx b/vcl/inc/opengl/RenderState.hxx
index 0a039a7a3d3a..f84dba70fea9 100644
--- a/vcl/inc/opengl/RenderState.hxx
+++ b/vcl/inc/opengl/RenderState.hxx
@@ -117,11 +117,36 @@ public:
static std::string className() { return std::string("StencilState"); }
};
+class BlendState : public GenericCapabilityState<GL_BLEND, BlendState>
+{
+ GLenum mnSourceMode;
+ GLenum mnDestinationMode;
+public:
+ BlendState()
+ : mnSourceMode(GL_ZERO)
+ , mnDestinationMode(GL_ZERO)
+ {}
+
+ static std::string className() { return std::string("BlendState"); }
+
+ void func(GLenum nSource, GLenum nDestination)
+ {
+ if (mnSourceMode != nSource || mnDestinationMode != nDestination)
+ {
+ glBlendFunc(nSource, nDestination);
+ CHECK_GL_ERROR();
+ mnSourceMode = nSource;
+ mnDestinationMode = nDestination;
+ }
+ }
+};
+
class RenderState
{
TextureState maTexture;
ScissorState maScissor;
StencilState maStencil;
+ BlendState maBlend;
Rectangle maCurrentViewport;
@@ -142,12 +167,14 @@ public:
TextureState& texture() { return maTexture; }
ScissorState& scissor() { return maScissor; }
StencilState& stencil() { return maStencil; }
+ BlendState& blend() { return maBlend; }
void sync()
{
VCL_GL_INFO("RenderState::sync");
maScissor.sync();
maStencil.sync();
+ maBlend.sync();
}
};
diff --git a/vcl/inc/opengl/program.hxx b/vcl/inc/opengl/program.hxx
index 780cba72380f..5944c72be127 100644
--- a/vcl/inc/opengl/program.hxx
+++ b/vcl/inc/opengl/program.hxx
@@ -51,9 +51,12 @@ public:
OpenGLProgram();
~OpenGLProgram();
+ GLuint Id() { return mnId; }
+
bool Load( const OUString& rVertexShader, const OUString& rFragmentShader,
const rtl::OString& preamble = "", const rtl::OString& rDigest = "" );
bool Use();
+ void Reuse();
bool Clean();
void SetVertices( const GLvoid* pData );
@@ -81,6 +84,8 @@ public:
bool DrawTexture( const OpenGLTexture& rTexture );
+ void DrawArrays(GLenum GLenum, std::vector<GLfloat>& aVertices);
+
protected:
void SetVertexAttrib( GLuint& rAttrib, const OString& rName, const GLvoid* pData, GLint nSize = 2 );
GLuint GetUniformLocation( const OString& rName );