diff options
author | Louis-Francis Ratté-Boulianne <lfrb@collabora.com> | 2014-11-03 22:51:15 -0500 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-11-10 07:58:57 +0100 |
commit | d8d9948b61819d302254014e04f14353a06a4c7a (patch) | |
tree | aa12cb836623b9956fe0f223860636cbe86a471f /vcl | |
parent | 037a6a4a3874256a18bbe06a4db9ec2b324e4da9 (diff) |
vcl: Allow SalBitmap implementation to do scaling
Change-Id: If4431fb276c9c2629acbc95aeff2ef7c4a683d86
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/headless/svpbmp.cxx | 5 | ||||
-rw-r--r-- | vcl/inc/headless/svpbmp.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/impbmp.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/opengl/salbmp.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/openglgdiimpl.hxx | 10 | ||||
-rw-r--r-- | vcl/inc/quartz/salbmp.h | 2 | ||||
-rw-r--r-- | vcl/inc/salbmp.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/salbmp.h | 2 | ||||
-rw-r--r-- | vcl/inc/win/salbmp.h | 2 | ||||
-rw-r--r-- | vcl/opengl/gdiimpl.cxx | 24 | ||||
-rw-r--r-- | vcl/opengl/salbmp.cxx | 36 | ||||
-rw-r--r-- | vcl/quartz/salbmp.cxx | 5 | ||||
-rw-r--r-- | vcl/source/gdi/bitmap3.cxx | 7 | ||||
-rw-r--r-- | vcl/source/gdi/impbmp.cxx | 5 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salbmp.cxx | 5 | ||||
-rw-r--r-- | vcl/win/source/gdi/salbmp.cxx | 5 |
16 files changed, 94 insertions, 25 deletions
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 3920aea25f2d..b5fcc241d75d 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -339,6 +339,11 @@ bool SvpSalBitmap::GetSystemData( BitmapSystemData& ) return false; } +bool SvpSalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/, sal_uInt32 /*nScaleFlag*/ ) +{ + return false; +} + sal_uInt32 SvpSalBitmap::getBitCountFromScanlineFormat( basebmp::Format nFormat ) { sal_uInt32 nBitCount = 1; diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx index aecf79c29ef7..3a0da2e9f100 100644 --- a/vcl/inc/headless/svpbmp.hxx +++ b/vcl/inc/headless/svpbmp.hxx @@ -58,6 +58,8 @@ public: virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) SAL_OVERRIDE; virtual bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE; + virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE; + static sal_uInt32 getBitCountFromScanlineFormat( basebmp::Format nFormat ); }; diff --git a/vcl/inc/impbmp.hxx b/vcl/inc/impbmp.hxx index c0eb805090f8..f6663c5c45d5 100644 --- a/vcl/inc/impbmp.hxx +++ b/vcl/inc/impbmp.hxx @@ -60,6 +60,9 @@ public: inline void ImplSetChecksum( sal_uLong nChecksum ) { mnChecksum = nChecksum; } inline sal_uLong ImplGetChecksum() const { return mnChecksum; } + + + bool ImplScale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ); }; #endif // INCLUDED_VCL_INC_IMPBMP_HXX diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx index 5661e565b733..74c0fda4e9cb 100644 --- a/vcl/inc/opengl/salbmp.hxx +++ b/vcl/inc/opengl/salbmp.hxx @@ -44,6 +44,8 @@ private: sal_uInt16 mnBytesPerRow; int mnWidth; int mnHeight; + int mnTexWidth; + int mnTexHeight; public: OpenGLSalBitmap(); @@ -70,6 +72,8 @@ public: bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE; + bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE; + public: bool Create( OpenGLContext& rContext, long nX, long nY, long nWidth, long nHeight ); diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 6643546d081f..e8b89478925b 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -73,11 +73,11 @@ private: void DrawConvexPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); void DrawRect( long nX, long nY, long nWidth, long nHeight ); void DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); - void DrawPolyPolygon( const basegfx::B2DPolyPolygon& pPolyPolygon ); - void DrawTextureRect( const SalTwoRect& pPosAry ); - void DrawTexture( GLuint nTexture, const SalTwoRect& pPosAry ); - void DrawTextureWithMask( GLuint nTexture, GLuint nMask, const SalTwoRect& pPosAry ); - void DrawMask( GLuint nMask, SalColor nMaskColor, const SalTwoRect& pPosAry ); + void DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon ); + void DrawTextureRect( const Size& rSize, const SalTwoRect& rPosAry ); + void DrawTexture( GLuint nTexture, const Size& rSize, const SalTwoRect& rPosAry ); + void DrawTextureWithMask( GLuint nTexture, GLuint nMask, const SalTwoRect& rPosAry ); + void DrawMask( GLuint nMask, SalColor nMaskColor, const SalTwoRect& rPosAry ); public: diff --git a/vcl/inc/quartz/salbmp.h b/vcl/inc/quartz/salbmp.h index cd944319f818..0bde5adba211 100644 --- a/vcl/inc/quartz/salbmp.h +++ b/vcl/inc/quartz/salbmp.h @@ -79,6 +79,8 @@ public: bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE; + bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE; + private: // quartz helper bool CreateContext(); diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx index d279715c0dd0..227cc3f6f57b 100644 --- a/vcl/inc/salbmp.hxx +++ b/vcl/inc/salbmp.hxx @@ -54,6 +54,8 @@ public: virtual BitmapBuffer* AcquireBuffer( bool bReadOnly ) = 0; virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) = 0; virtual bool GetSystemData( BitmapSystemData& rData ) = 0; + + virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) = 0; }; #endif diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h index f6cadaab8145..f3f08313e585 100644 --- a/vcl/inc/unx/salbmp.h +++ b/vcl/inc/unx/salbmp.h @@ -145,6 +145,8 @@ public: virtual BitmapBuffer* AcquireBuffer( bool bReadOnly ) SAL_OVERRIDE; virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) SAL_OVERRIDE; virtual bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE; + + virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE; }; // - ImplSalDDB - diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h index 0962facb7e0c..90382363b3e5 100644 --- a/vcl/inc/win/salbmp.h +++ b/vcl/inc/win/salbmp.h @@ -96,6 +96,8 @@ public: virtual BitmapBuffer* AcquireBuffer( bool bReadOnly ); virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ); virtual bool GetSystemData( BitmapSystemData& rData ); + + virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ); }; #endif // INCLUDED_VCL_INC_WIN_SALBMP_H diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index d79bce0623d2..4ee5f955a73e 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -380,19 +380,24 @@ void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& pPol glDisableVertexAttribArray( GL_ATTRIB_POS ); } -void OpenGLSalGraphicsImpl::DrawTextureRect( const SalTwoRect& pPosAry ) +void OpenGLSalGraphicsImpl::DrawTextureRect( const Size& rSize, const SalTwoRect& rPosAry ) { - GLushort aTexCoord[8]; + GLfloat aTexCoord[8]; + + aTexCoord[0] = aTexCoord[2] = rPosAry.mnSrcX / (double) rSize.Width(); + aTexCoord[4] = aTexCoord[6] = (rPosAry.mnSrcX + rPosAry.mnSrcWidth) / (double) rSize.Width(); + aTexCoord[3] = aTexCoord[5] = rPosAry.mnSrcY / (double) rSize.Height(); + aTexCoord[1] = aTexCoord[7] = (rPosAry.mnSrcY + rPosAry.mnSrcHeight) / (double) rSize.Height(); glEnableVertexAttribArray( GL_ATTRIB_TEX ); - glVertexAttribPointer( GL_ATTRIB_TEX, 2, GL_UNSIGNED_SHORT, GL_FALSE, 0, aTexCoord ); + glVertexAttribPointer( GL_ATTRIB_TEX, 2, GL_FLOAT, GL_FALSE, 0, aTexCoord ); - DrawRect( pPosAry.mnDestX, pPosAry.mnDestY, pPosAry.mnDestWidth, pPosAry.mnDestHeight ); + DrawRect( rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight ); glDisableVertexAttribArray( GL_ATTRIB_TEX ); } -void OpenGLSalGraphicsImpl::DrawTexture( GLuint nTexture, const SalTwoRect& pPosAry ) +void OpenGLSalGraphicsImpl::DrawTexture( GLuint nTexture, const Size& rSize, const SalTwoRect& pPosAry ) { if( mnTextureProgram == 0 ) { @@ -405,7 +410,7 @@ void OpenGLSalGraphicsImpl::DrawTexture( GLuint nTexture, const SalTwoRect& pPos glActiveTexture( GL_TEXTURE0 ); glBindTexture( GL_TEXTURE_2D, nTexture ); - DrawTextureRect( pPosAry ); + DrawTextureRect( rSize, pPosAry ); glBindTexture( GL_TEXTURE_2D, 0 ); glUseProgram( 0 ); @@ -427,7 +432,7 @@ void OpenGLSalGraphicsImpl::DrawTextureWithMask( GLuint nTexture, GLuint nMask, glActiveTexture( GL_TEXTURE1 ); glBindTexture( GL_TEXTURE_2D, nMask ); - DrawTextureRect( pPosAry ); + //DrawTextureRect( pPosAry ); glActiveTexture( GL_TEXTURE1 ); glBindTexture( GL_TEXTURE_2D, 0 ); @@ -450,7 +455,7 @@ void OpenGLSalGraphicsImpl::DrawMask( GLuint nMask, SalColor nMaskColor, const S glActiveTexture( GL_TEXTURE0 ); glBindTexture( GL_TEXTURE_2D, nMask ); - DrawTextureRect( pPosAry ); + //DrawTextureRect( pPosAry ); glActiveTexture( GL_TEXTURE0 ); glBindTexture( GL_TEXTURE_2D, 0 ); @@ -665,10 +670,11 @@ void OpenGLSalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry, const SalBitm { const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap); GLuint nTexture = rBitmap.GetTexture( maContext ); + const Size aSize = rSalBitmap.GetSize(); SAL_INFO( "vcl.opengl", "::drawBitmap" ); maContext.makeCurrent(); - DrawTexture( nTexture, rPosAry ); + DrawTexture( nTexture, aSize, rPosAry ); } void OpenGLSalGraphicsImpl::drawBitmap( diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index 5edeed8b0208..391600a9e07b 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -40,6 +40,8 @@ OpenGLSalBitmap::OpenGLSalBitmap() , mnBytesPerRow(0) , mnWidth(0) , mnHeight(0) +, mnTexWidth(0) +, mnTexHeight(0) { } @@ -56,8 +58,8 @@ bool OpenGLSalBitmap::Create( OpenGLContext& rContext, long nX, long nY, long nW mpContext = &rContext; mpContext->makeCurrent(); - mnWidth = nWidth; - mnHeight = nHeight; + mnWidth = mnTexWidth = nWidth; + mnHeight = mnTexHeight = nHeight; // TODO Check the framebuffer configuration mnBits = 32; @@ -79,8 +81,8 @@ bool OpenGLSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapP return false; maPalette = rBitmapPalette; mnBits = nBits; - mnWidth = rSize.Width(); - mnHeight = rSize.Height(); + mnWidth = mnTexWidth = rSize.Width(); + mnHeight = mnTexHeight = rSize.Height(); return false; } @@ -101,6 +103,8 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount if( isValidBitCount( nNewBitCount ) ) { mnBits = nNewBitCount; + mnTexWidth = rSourceBitmap.mnTexWidth; + mnTexHeight = rSourceBitmap.mnTexHeight; mnWidth = rSourceBitmap.mnWidth; mnHeight = rSourceBitmap.mnHeight; maPalette = rSourceBitmap.maPalette; @@ -330,7 +334,7 @@ GLuint OpenGLSalBitmap::CreateTexture() else { // convert to 32 bits RGBA using palette - pData = new sal_uInt8[ mnHeight * (mnWidth << 2) ]; + pData = new sal_uInt8[ mnTexHeight * (mnTexWidth << 2) ]; bAllocated = true; nFormat = GL_RGBA; nType = GL_UNSIGNED_BYTE; @@ -339,12 +343,12 @@ GLuint OpenGLSalBitmap::CreateTexture() sal_uInt8* pSrcData = maUserBuffer.get(); sal_uInt8* pDstData = pData; - sal_uInt32 nY = mnHeight; + sal_uInt32 nY = mnTexHeight; while( nY-- ) { pSrcFormat->StartLine( pSrcData ); - sal_uInt32 nX = mnWidth; + sal_uInt32 nX = mnTexWidth; while( nX-- ) { const BitmapColor& c = pSrcFormat->ReadPixel(); @@ -416,18 +420,20 @@ bool OpenGLSalBitmap::ReadTexture() GLuint nFramebufferId, nRenderbufferDepthId, nRenderbufferColorId; sal_uInt8* pData = maUserBuffer.get(); + // TODO Check mnTexWidth and mnTexHeight + mpContext->makeCurrent(); - OpenGLHelper::createFramebuffer( mnWidth, mnHeight, nFramebufferId, + OpenGLHelper::createFramebuffer( mnTexWidth, mnTexHeight, nFramebufferId, nRenderbufferDepthId, nRenderbufferColorId, true ); glBindFramebuffer( GL_FRAMEBUFFER, nFramebufferId ); aPosAry.mnSrcX = aPosAry.mnDestX = 0; aPosAry.mnSrcY = aPosAry.mnDestY = 0; - aPosAry.mnSrcWidth = aPosAry.mnDestWidth = mnWidth; - aPosAry.mnSrcHeight = aPosAry.mnDestHeight = mnHeight; + aPosAry.mnSrcWidth = aPosAry.mnDestWidth = mnTexWidth; + aPosAry.mnSrcHeight = aPosAry.mnDestHeight = mnTexHeight; DrawTexture( mnTexture, aPosAry ); - glReadPixels( 0, 0, mnWidth, mnHeight, GL_RGBA, GL_UNSIGNED_BYTE, pData ); + glReadPixels( 0, 0, mnTexWidth, mnTexHeight, GL_RGBA, GL_UNSIGNED_BYTE, pData ); glBindFramebuffer( GL_FRAMEBUFFER, 0 ); glDeleteFramebuffers( 1, &nFramebufferId ); @@ -518,4 +524,12 @@ bool OpenGLSalBitmap::GetSystemData( BitmapSystemData& /*rData*/ ) #endif } +bool OpenGLSalBitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) +{ + SAL_INFO( "vcl.opengl", "::Scale" ); + mnWidth *= rScaleX; + mnHeight *= rScaleY; + return true; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx index a9805100d907..c4cf2b00a011 100644 --- a/vcl/quartz/salbmp.cxx +++ b/vcl/quartz/salbmp.cxx @@ -963,4 +963,9 @@ bool QuartzSalBitmap::GetSystemData( BitmapSystemData& rData ) return bRet; } +bool QuartzSalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/, sal_uInt32 /*nScaleFlag*/ ) +{ + return false; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index 588dd0a2d50c..657c3ac2d863 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -27,6 +27,7 @@ #include <boost/scoped_array.hpp> +#include <impbmp.hxx> #include <impoct.hxx> #include <impvect.hxx> @@ -873,6 +874,12 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nSc bRetval = true; } + if( mpImpBmp && mpImpBmp->ImplScale( rScaleX, rScaleY, nScaleFlag ) ) + { + // implementation specific scaling + return true; + } + //fdo#33455 // //If we start with a 1 bit image, then after scaling it in any mode except diff --git a/vcl/source/gdi/impbmp.cxx b/vcl/source/gdi/impbmp.cxx index 005a45e6e9aa..1ee75d42b442 100644 --- a/vcl/source/gdi/impbmp.cxx +++ b/vcl/source/gdi/impbmp.cxx @@ -86,4 +86,9 @@ void ImpBitmap::ImplReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) mnChecksum = 0; } +bool ImpBitmap::ImplScale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) +{ + return mpSalBitmap->Scale( rScaleX, rScaleY, nScaleFlag ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx index 8468b4d94ee6..9078de6358a8 100644 --- a/vcl/unx/generic/gdi/salbmp.cxx +++ b/vcl/unx/generic/gdi/salbmp.cxx @@ -860,6 +860,11 @@ bool X11SalBitmap::GetSystemData( BitmapSystemData& rData ) return false; } +bool X11SalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/, sal_uInt32 /*nScaleFlag*/ ) +{ + return false; +} + // - ImplSalDDB - ImplSalDDB::ImplSalDDB( XImage* pImage, Drawable aDrawable, diff --git a/vcl/win/source/gdi/salbmp.cxx b/vcl/win/source/gdi/salbmp.cxx index 912144401069..0f8906c84bc0 100644 --- a/vcl/win/source/gdi/salbmp.cxx +++ b/vcl/win/source/gdi/salbmp.cxx @@ -1076,4 +1076,9 @@ bool WinSalBitmap::GetSystemData( BitmapSystemData& rData ) return bRet; } +bool WinSalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/, sal_uInt32 /*nScaleFlag*/ ) +{ + return false; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |