summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToma┼ż Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-07-31 16:31:29 +0900
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-08-07 09:34:42 +0000
commit22421a4083529e852fc6d290c2cc8c7611e9150b (patch)
treec5d8b2b38b301f65f84bc139f182c5136848a126
parentc02d01ba71f5290beac991d5ddafe1309b428ebf (diff)
opengl: when scaling, create a new texture with equal settings
Change-Id: Id0258fe0db89aa06b91233ae2052f018d606cc74 (cherry picked from commit 6d9ddfb9c7a946e9b9cc58ae2cebcf3a21a5bf22) Reviewed-on: https://gerrit.libreoffice.org/17558 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--vcl/inc/opengl/salbmp.hxx2
-rw-r--r--vcl/opengl/scale.cxx52
2 files changed, 49 insertions, 5 deletions
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index 3df78c8b2051..15ff571756b1 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -106,6 +106,8 @@ private:
bool ImplScaleConvolution( const double& rScaleX, const double& rScaleY, const Kernel& aKernel );
bool ImplScaleArea( double rScaleX, double rScaleY );
+ bool getFormatAndType(GLenum& nFormat, GLenum& nType);
+
public:
bool ImplScale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag );
diff --git a/vcl/opengl/scale.cxx b/vcl/opengl/scale.cxx
index a479a11f6619..fcb42737d568 100644
--- a/vcl/opengl/scale.cxx
+++ b/vcl/opengl/scale.cxx
@@ -43,6 +43,31 @@ public:
void GetSize( Size& rSize ) const SAL_OVERRIDE;
};
+bool OpenGLSalBitmap::getFormatAndType(GLenum& nFormat, GLenum& nType)
+{
+ switch(mnBits)
+ {
+ case 8:
+ nFormat = GL_LUMINANCE;
+ nType = GL_UNSIGNED_BYTE;
+ break;
+ case 16:
+ nFormat = GL_RGB;
+ nType = GL_UNSIGNED_SHORT_5_6_5;
+ break;
+ case 24:
+ nFormat = GL_RGB;
+ nType = GL_UNSIGNED_BYTE;
+ break;
+ case 32:
+ default:
+ nFormat = GL_RGBA;
+ nType = GL_UNSIGNED_BYTE;
+ break;
+ }
+ return true;
+}
+
bool OpenGLSalBitmap::ImplScaleFilter(
const double& rScaleX,
const double& rScaleY,
@@ -59,7 +84,11 @@ bool OpenGLSalBitmap::ImplScaleFilter(
if( !pProgram )
return false;
- OpenGLTexture aNewTex = OpenGLTexture( nNewWidth, nNewHeight );
+ GLenum nFormat;
+ GLenum nType;
+ getFormatAndType(nFormat, nType);
+
+ OpenGLTexture aNewTex = OpenGLTexture(nNewWidth, nNewHeight, nFormat, nType, nullptr);
pFramebuffer = mpContext->AcquireFramebuffer( aNewTex );
pProgram->SetTexture( "sampler", maTexture );
@@ -138,10 +167,15 @@ bool OpenGLSalBitmap::ImplScaleConvolution(
if( pProgram == 0 )
return false;
+ GLenum nFormat;
+ GLenum nType;
+ getFormatAndType(nFormat, nType);
+
// horizontal scaling in scratch texture
if( mnWidth != nNewWidth )
{
- OpenGLTexture aScratchTex = OpenGLTexture( nNewWidth, mnHeight );
+ OpenGLTexture aScratchTex = OpenGLTexture(nNewWidth, mnHeight, nFormat, nType, nullptr);
+
pFramebuffer = mpContext->AcquireFramebuffer( aScratchTex );
for( sal_uInt32 i = 0; i < 16; i++ )
@@ -163,7 +197,8 @@ bool OpenGLSalBitmap::ImplScaleConvolution(
// vertical scaling in final texture
if( mnHeight != nNewHeight )
{
- OpenGLTexture aScratchTex = OpenGLTexture( nNewWidth, nNewHeight );
+ OpenGLTexture aScratchTex = OpenGLTexture(nNewWidth, nNewHeight, nFormat, nType, nullptr);
+
pFramebuffer = mpContext->AcquireFramebuffer( aScratchTex );
for( sal_uInt32 i = 0; i < 16; i++ )
@@ -223,7 +258,12 @@ bool OpenGLSalBitmap::ImplScaleArea( double rScaleX, double rScaleY )
if( pProgram == 0 )
return false;
- OpenGLTexture aScratchTex = OpenGLTexture( nNewWidth, nNewHeight );
+ GLenum nFormat;
+ GLenum nType;
+ getFormatAndType(nFormat, nType);
+
+ OpenGLTexture aScratchTex = OpenGLTexture(nNewWidth, nNewHeight, nFormat, nType, nullptr);
+
OpenGLFramebuffer* pFramebuffer = mpContext->AcquireFramebuffer( aScratchTex );
// NOTE: This setup is also done in OpenGLSalGraphicsImpl::DrawTransformedTexture().
@@ -325,7 +365,9 @@ void ScaleOp::GetSize( Size& rSize ) const
bool OpenGLSalBitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag )
{
- SAL_INFO( "vcl.opengl", "::Scale " << static_cast<int>(nScaleFlag) );
+ SAL_INFO("vcl.opengl", "::Scale " << int(nScaleFlag)
+ << " from " << mnWidth << "x" << mnHeight
+ << " to " << (mnWidth * rScaleX) << "x" << (mnHeight * rScaleY) );
if( nScaleFlag == BmpScaleFlag::Fast ||
nScaleFlag == BmpScaleFlag::BiLinear ||