summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 ||