summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-12 12:53:09 -0500
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-11-13 07:54:17 +0100
commit9ac5aa94665da9c6b9188716345e79ade00dd0cc (patch)
treeac4b456c07b1f8c08f2c429ee24844c62dbe2cb6
parentdc189f79e844c7208220c0903309852a09c8b1c1 (diff)
vcl: Use new size when scaling with filter in OpenGL backend
Change-Id: Ib5d12b0e57b537bbd1798121e80cd517d9c8f751
-rw-r--r--vcl/inc/opengl/salbmp.hxx2
-rw-r--r--vcl/opengl/scale.cxx15
2 files changed, 12 insertions, 5 deletions
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index 77ac90bbbc55..c1f0cdb817ad 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -106,7 +106,7 @@ private:
GLuint mnConvKernelSizeUniform;
GLuint mnConvOffsetsUniform;
- bool ImplScaleFilter( GLenum nFilter );
+ 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/opengl/scale.cxx b/vcl/opengl/scale.cxx
index da7378639218..d1b85a52d532 100644
--- a/vcl/opengl/scale.cxx
+++ b/vcl/opengl/scale.cxx
@@ -81,12 +81,17 @@ GLuint OpenGLSalBitmap::ImplGetConvolutionProgram()
return mnConvProgram;
}
-bool OpenGLSalBitmap::ImplScaleFilter( GLenum nFilter )
+bool OpenGLSalBitmap::ImplScaleFilter(
+ const double& rScaleX,
+ const double& rScaleY,
+ GLenum nFilter )
{
OpenGLTexture* pNewTex;
GLuint nProgram;
GLuint nFramebufferId;
GLenum nOldFilter;
+ int nNewWidth( mnWidth * rScaleX );
+ int nNewHeight( mnHeight * rScaleY );
nProgram = ImplGetTextureProgram();
if( nProgram == 0 )
@@ -97,7 +102,7 @@ bool OpenGLSalBitmap::ImplScaleFilter( GLenum nFilter )
glUseProgram( nProgram );
glUniform1i( mnTexSamplerUniform, 0 );
- pNewTex = new OpenGLTexture( mnWidth, mnHeight );
+ pNewTex = new OpenGLTexture( nNewWidth, nNewHeight );
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pNewTex->Id(), 0 );
mpTexture->Bind();
@@ -111,6 +116,8 @@ bool OpenGLSalBitmap::ImplScaleFilter( GLenum nFilter )
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
glDeleteFramebuffers( 1, &nFramebufferId );
+ mnWidth = nNewWidth;
+ mnHeight = nNewHeight;
mpTexture.reset( pNewTex );
CHECK_GL_ERROR();
@@ -241,11 +248,11 @@ bool OpenGLSalBitmap::ImplScale( const double& rScaleX, const double& rScaleY, s
if( nScaleFlag == BMP_SCALE_FAST )
{
- return ImplScaleFilter( GL_NEAREST );
+ return ImplScaleFilter( rScaleX, rScaleY, GL_NEAREST );
}
if( nScaleFlag == BMP_SCALE_BILINEAR )
{
- return ImplScaleFilter( GL_LINEAR );
+ return ImplScaleFilter( rScaleX, rScaleY, GL_LINEAR );
}
else if( nScaleFlag == BMP_SCALE_SUPER )
{