summaryrefslogtreecommitdiff
path: root/include/vcl/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'include/vcl/opengl')
-rw-r--r--include/vcl/opengl/OpenGLContext.hxx18
-rw-r--r--include/vcl/opengl/OpenGLHelper.hxx6
2 files changed, 16 insertions, 8 deletions
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index ecc503829051..b2aaa173ea3a 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -55,10 +55,13 @@ class NSOpenGLView;
#include <vcl/window.hxx>
#include <tools/gen.hxx>
#include <vcl/syschild.hxx>
+#include <rtl/crc.h>
#include <rtl/ref.hxx>
#include <map>
+#include <memory>
#include <set>
+#include <unordered_map>
class OpenGLFramebuffer;
class OpenGLProgram;
@@ -271,15 +274,16 @@ private:
OpenGLFramebuffer* mpFirstFramebuffer;
OpenGLFramebuffer* mpLastFramebuffer;
- struct ProgramKey
+ struct ProgramHash
{
- ProgramKey( const OUString& vertexShader, const OUString& fragmentShader, const OString& preamble );
- bool operator< ( const ProgramKey& other ) const;
- OUString vertexShader;
- OUString fragmentShader;
- OString preamble;
+ size_t operator()( const rtl::OString& aDigest ) const
+ {
+ return (size_t)( rtl_crc32( 0, aDigest.getStr(), aDigest.getLength() ) );
+ }
};
- std::map<ProgramKey, std::shared_ptr<OpenGLProgram> > maPrograms;
+
+ typedef std::unordered_map< rtl::OString, std::shared_ptr<OpenGLProgram>, ProgramHash > ProgramCollection;
+ ProgramCollection maPrograms;
OpenGLProgram* mpCurrentProgram;
#ifdef DBG_UTIL
std::set<SalGraphicsImpl*> maParents;
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index a4729a7633ab..50783f278eb9 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -39,7 +39,11 @@ struct VCL_DLLPUBLIC OpenGLHelper
{
OpenGLHelper() SAL_DELETED_FUNCTION; // Should not be instantiated
- static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OString& preamble = "" );
+public:
+
+ static rtl::OString GetDigest(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const rtl::OString& preamble = "" );
+
+ static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const rtl::OString& preamble = "", const rtl::OString& rDigest = "" );
/**
* The caller is responsible for allocate the memory for the RGBA buffer, before call