summaryrefslogtreecommitdiff
path: root/vcl/inc/opengl
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-28 14:56:08 -0500
committerJan Holesovsky <kendy@collabora.com>2014-12-02 15:47:33 +0100
commit5933c72dd39d597037528f8473fa2bf67e59a757 (patch)
tree69e6b55c32f6c5fdb68109be9757db3177835e7f /vcl/inc/opengl
parent44239d8002792c1f6d9373db46382ac9f4d27466 (diff)
vcl: Only load OpenGL shaders once for each context
Change-Id: Idbf9026c5e64ef41d4c913153dfddf36923ff7de
Diffstat (limited to 'vcl/inc/opengl')
-rw-r--r--vcl/inc/opengl/program.hxx72
-rw-r--r--vcl/inc/opengl/salbmp.hxx11
-rw-r--r--vcl/inc/opengl/texture.hxx1
3 files changed, 73 insertions, 11 deletions
diff --git a/vcl/inc/opengl/program.hxx b/vcl/inc/opengl/program.hxx
new file mode 100644
index 000000000000..4b2b26ffb95e
--- /dev/null
+++ b/vcl/inc/opengl/program.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_VCL_INC_OPENGL_PROGRAM_H
+#define INCLUDED_VCL_INC_OPENGL_PROGRAM_H
+
+#include <GL/glew.h>
+#include <vcl/dllapi.h>
+
+#include <basegfx/point/b2dpoint.hxx>
+#include <rtl/ustring.hxx>
+#include <tools/color.hxx>
+#include <opengl/texture.hxx>
+
+#include <boost/unordered_map.hpp>
+
+typedef boost::unordered_map< OString, GLuint, OStringHash > UniformCache;
+typedef std::list< OpenGLTexture > TextureList;
+
+class VCL_PLUGIN_PUBLIC OpenGLProgram
+{
+private:
+ GLuint mnId;
+ UniformCache maUniformLocations;
+ sal_uInt32 mnEnabledAttribs;
+ GLuint mnAttribIndex;
+ GLuint mnPositionAttrib;
+ GLuint mnTexCoordAttrib;
+ GLuint mnAlphaCoordAttrib;
+ TextureList maTextures;
+ bool mbBlending;
+
+public:
+ OpenGLProgram();
+ ~OpenGLProgram();
+
+ bool Load( const OUString& rVertexShader, const OUString& rFragmentShader );
+ bool Use();
+ bool Clean();
+
+ void SetVertices( const GLvoid* pData );
+ void SetTextureCoord( const GLvoid* pData );
+ void SetAlphaCoord( const GLvoid* pData );
+
+ void SetUniform2f( const OString& rName, GLfloat v1, GLfloat v2 );
+ void SetUniform1fv( const OString& rName, GLsizei nCount, GLfloat* aValues );
+ void SetUniform2fv( const OString& rName, GLsizei nCount, GLfloat* aValues );
+ void SetColor( const OString& rName, SalColor nColor, sal_uInt8 nTransparency );
+ void SetColorf( const OString& rName, SalColor nColor, double fTransparency );
+ void SetColorWithIntensity( const OString& rName, const Color& rColor, long nFactor );
+ void SetTexture( const OString& rName, OpenGLTexture& rTexture );
+ void SetTransform( const OString& rName, const OpenGLTexture& rTexture,
+ const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX,
+ const basegfx::B2DPoint& rY );
+ void SetBlendMode( GLenum nSFactor, GLenum nDFactor );
+
+ bool DrawTexture( OpenGLTexture& rTexture );
+
+protected:
+ void SetVertexAttrib( GLuint& rAttrib, const OString& rName, const GLvoid* pData );
+ GLuint GetUniformLocation( const OString& rName );
+};
+
+#endif // INCLUDED_VCL_INC_OPENGL_PROGRAM_H
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index bc232b123380..6938a22a1846 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -99,17 +99,6 @@ private:
private:
- GLuint ImplGetTextureProgram();
- GLuint mnTexProgram;
- GLuint mnTexSamplerUniform;
-
- GLuint ImplGetConvolutionProgram();
- GLuint mnConvProgram;
- GLuint mnConvSamplerUniform;
- GLuint mnConvKernelUniform;
- GLuint mnConvKernelSizeUniform;
- GLuint mnConvOffsetsUniform;
-
bool ImplScaleFilter( const double& rScaleX, const double& rScaleY, GLenum nFilter );
void ImplCreateKernel( const double& fScale, const Kernel& rKernel, GLfloat*& pWeights, sal_uInt32& aKernelSize );
bool ImplScaleConvolution( const double& rScaleX, const double& rScaleY, const Kernel& aKernel );
diff --git a/vcl/inc/opengl/texture.hxx b/vcl/inc/opengl/texture.hxx
index ad4738a6948d..3d99526d2646 100644
--- a/vcl/inc/opengl/texture.hxx
+++ b/vcl/inc/opengl/texture.hxx
@@ -65,6 +65,7 @@ public:
int GetWidth() const;
int GetHeight() const;
void GetCoord( GLfloat* pCoord, const SalTwoRect& rPosAry, bool bInverted=false ) const;
+ void GetWholeCoord( GLfloat* pCoord ) const;
void Bind();
void Unbind();