diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-05-12 13:37:11 +0900 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-05-25 15:34:08 +0000 |
commit | 28d2b668c0476bd8dc198656b46c01de6e8c9921 (patch) | |
tree | 8f4b82d01eb0a364f80f61dc66a96ada03d29e5a /vcl/inc | |
parent | a4ca886a6c0febac630761f4e7f685fc96a083ca (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.
(cherry picked from commit e480b2cf3e362760de8e35cbb950104e47ebe7ec)
Change-Id: I530b4b948af8a962669a3751e1a95ff3986ffec9
Reviewed-on: https://gerrit.libreoffice.org/25359
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/opengl/RenderState.hxx | 27 | ||||
-rw-r--r-- | vcl/inc/opengl/program.hxx | 5 |
2 files changed, 32 insertions, 0 deletions
diff --git a/vcl/inc/opengl/RenderState.hxx b/vcl/inc/opengl/RenderState.hxx index ac215a8d97c1..2930ff1bd656 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 ); |