From 97bf7c6cc7c756109e75dc11641300e28e8b3d1f Mon Sep 17 00:00:00 2001 From: Lubosz Sarnecki Date: Thu, 20 Aug 2015 16:22:43 +0200 Subject: vcl OpenGL program: Cache mvp matrix to reduce ~200 api calls per frame. (cherry picked from commit e3cd97ce0b2e153b8b6812cc66f2e7d33504a7da) Conflicts: vcl/opengl/program.cxx Change-Id: I86ae50bd8d2148e86a6c8fc0821d3e2bc29a0cd4 --- vcl/opengl/program.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'vcl/opengl/program.cxx') diff --git a/vcl/opengl/program.cxx b/vcl/opengl/program.cxx index ede054816d5f..b1d3cfe8291d 100644 --- a/vcl/opengl/program.cxx +++ b/vcl/opengl/program.cxx @@ -22,7 +22,10 @@ OpenGLProgram::OpenGLProgram() : mnTexCoordAttrib( SAL_MAX_UINT32 ), mnAlphaCoordAttrib( SAL_MAX_UINT32 ), mnMaskCoordAttrib( SAL_MAX_UINT32 ), - mbBlending( false ) + mbBlending( false ), + mfLastWidth(0.0), + mfLastHeight(0.0), + mfLastPixelOffset(0.0) { } @@ -247,6 +250,14 @@ void OpenGLProgram::SetTransform( void OpenGLProgram::ApplyMatrix(float fWidth, float fHeight, float fPixelOffset) { + + if (mfLastWidth == fWidth && mfLastHeight == fHeight && mfLastPixelOffset == fPixelOffset) + return; + + mfLastWidth = fWidth; + mfLastHeight = fHeight; + mfLastPixelOffset = fPixelOffset; + OString sProjectionMatrix("mvp"); GLuint nUniform = GetUniformLocation(sProjectionMatrix); -- cgit