diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2015-09-13 12:15:13 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-09-16 14:19:46 +0100 |
commit | 697917f7152b4ab5d95eadeac52d615403ea1737 (patch) | |
tree | 34742b1195e403e6f5eb6d295bf9a94ca9942578 /include | |
parent | 50902f4d3bca92aefe0a3b663c3d175b60ecb25f (diff) |
tdf#93814: Added support for caching shader program binaries.
Reviewed-on: https://gerrit.libreoffice.org/18555
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Conflicts:
include/vcl/opengl/OpenGLContext.hxx
include/vcl/opengl/OpenGLHelper.hxx
vcl/inc/opengl/win/WinDeviceInfo.hxx
vcl/source/opengl/OpenGLContext.cxx
Change-Id: I21c844b47282f6b3eec443933a86421a074e24df
Diffstat (limited to 'include')
-rw-r--r-- | include/vcl/opengl/OpenGLContext.hxx | 18 | ||||
-rw-r--r-- | include/vcl/opengl/OpenGLHelper.hxx | 7 |
2 files changed, 17 insertions, 8 deletions
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx index 98f9c61079d2..3e91f6f61a2c 100644 --- a/include/vcl/opengl/OpenGLContext.hxx +++ b/include/vcl/opengl/OpenGLContext.hxx @@ -56,9 +56,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; @@ -276,15 +280,15 @@ 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, boost::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 646a2d39254e..788b056723d2 100644 --- a/include/vcl/opengl/OpenGLHelper.hxx +++ b/include/vcl/opengl/OpenGLHelper.hxx @@ -36,8 +36,13 @@ class VCL_DLLPUBLIC OpenGLHelper { + OpenGLHelper() SAL_DELETED_FUNCTION; // Should not be instantiated + public: - static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OString& preamble = "" ); + + 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 |