From 4b6feefa51405e1313de62e1a19c4c213e79c22f Mon Sep 17 00:00:00 2001 From: Louis-Francis Ratté-Boulianne Date: Tue, 18 Nov 2014 12:34:53 -0500 Subject: vcl: Add support for backend-dependent blending of bitmaps (mask and alpha) Change-Id: Iba64eb42965c86ca5655b9a105ef3f397e033ecf --- vcl/inc/generic/genpspgraphics.h | 6 ++++++ vcl/inc/headless/svpgdi.hxx | 5 +++++ vcl/inc/openglgdiimpl.hxx | 17 +++++++++++++++++ vcl/inc/quartz/salgdi.h | 8 ++++++++ vcl/inc/salgdi.hxx | 24 ++++++++++++++++++++++++ vcl/inc/salgdiimpl.hxx | 10 ++++++++++ vcl/inc/unx/salgdi.h | 8 ++++++++ vcl/inc/win/salgdi.h | 8 ++++++++ 8 files changed, 86 insertions(+) (limited to 'vcl/inc') diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h index 382a69300e41..18a434fa67b5 100644 --- a/vcl/inc/generic/genpspgraphics.h +++ b/vcl/inc/generic/genpspgraphics.h @@ -180,6 +180,12 @@ public: virtual bool drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uIntPtr nSize ) SAL_OVERRIDE; + virtual bool blendBitmap( const SalTwoRect&, + const SalBitmap& rBitmap ) SAL_OVERRIDE; + virtual bool blendAlphaBitmap( const SalTwoRect&, + const SalBitmap& rSrcBitmap, + const SalBitmap& rMaskBitmap, + const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE; virtual bool drawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE; diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 4da3ffa1a59b..9ae3d0539796 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -124,6 +124,11 @@ protected: vcl::Region m_aClipRegion; protected: + virtual bool blendBitmap( const SalTwoRect&, const SalBitmap& rBitmap ) SAL_OVERRIDE; + virtual bool blendAlphaBitmap( const SalTwoRect&, + const SalBitmap& rSrcBitmap, + const SalBitmap& rMaskBitmap, + const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE; virtual bool drawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE; virtual bool drawTransformedBitmap( const basegfx::B2DPoint& rNull, diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 5e4af511ef77..b26e10ce7ae0 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -71,6 +71,11 @@ protected: GLuint mnMaskedSamplerUniform; GLuint mnMaskSamplerUniform; + GLuint mnBlendedTextureProgram; + GLuint mnBlendedTextureUniform; + GLuint mnBlendedMaskUniform; + GLuint mnBlendedAlphaUniform; + GLuint mnMaskProgram; GLuint mnMaskUniform; GLuint mnMaskColorUniform; @@ -92,6 +97,7 @@ protected: bool CreateTextureProgram( void ); bool CreateTransformedTextureProgram( void ); bool CreateMaskedTextureProgram( void ); + bool CreateBlendedTextureProgram( void ); bool CreateTransformedMaskedTextureProgram( void ); bool CreateMaskProgram( void ); bool CreateLinearGradientProgram( void ); @@ -119,6 +125,7 @@ public: void DrawTransformedTexture( OpenGLTexture& rTexture, OpenGLTexture& rMask, const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX, const basegfx::B2DPoint& rY ); void DrawAlphaTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted = false, bool pPremultiplied = false ); void DrawTextureWithMask( OpenGLTexture& rTexture, OpenGLTexture& rMask, const SalTwoRect& rPosAry ); + void DrawBlendedTexture( OpenGLTexture& rTexture, OpenGLTexture& rMask, OpenGLTexture& rAlpha, const SalTwoRect& rPosAry ); void DrawMask( OpenGLTexture& rTexture, SalColor nMaskColor, const SalTwoRect& rPosAry ); void DrawLinearGradient( const Gradient& rGradient, const Rectangle& rRect ); void DrawAxialGradient( const Gradient& rGradient, const Rectangle& rRect ); @@ -232,6 +239,16 @@ public: // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics void DoCopyBits(const SalTwoRect& rPosAry, OpenGLSalGraphicsImpl &rSrcImpl); + virtual bool blendBitmap( + const SalTwoRect&, + const SalBitmap& rBitmap ) SAL_OVERRIDE; + + virtual bool blendAlphaBitmap( + const SalTwoRect&, + const SalBitmap& rSrcBitmap, + const SalBitmap& rMaskBitmap, + const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE; + virtual void drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) SAL_OVERRIDE; virtual void drawBitmap( diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index d25b09373ff3..9a5d4da8ab05 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -268,6 +268,14 @@ public: virtual bool drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize ) SAL_OVERRIDE; + virtual bool blendBitmap( const SalTwoRect&, + const SalBitmap& rBitmap ) SAL_OVERRIDE; + + virtual bool blendAlphaBitmap( const SalTwoRect&, + const SalBitmap& rSrcBitmap, + const SalBitmap& rMaskBitmap, + const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE; + virtual bool drawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE; diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index 95920a050157..ff6271c8d88c 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -399,6 +399,18 @@ public: Rectangle &rNativeContentRegion, const OutputDevice *pOutDev ); + bool BlendBitmap( + const SalTwoRect& rPosAry, + const SalBitmap& rSalBitmap, + const OutputDevice *pOutDev ); + + bool BlendAlphaBitmap( + const SalTwoRect& rPosAry, + const SalBitmap& rSalSrcBitmap, + const SalBitmap& rSalMaskBitmap, + const SalBitmap& rSalAlphaBitmap, + const OutputDevice *pOutDev ); + bool DrawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, @@ -541,6 +553,18 @@ protected: Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion ); + /** Blend the bitmap with the current buffer */ + virtual bool blendBitmap( + const SalTwoRect&, + const SalBitmap& rBitmap ) = 0; + + /** Draw the bitmap by blending using the mask and alpha channel */ + virtual bool blendAlphaBitmap( + const SalTwoRect&, + const SalBitmap& rSrcBitmap, + const SalBitmap& rMaskBitmap, + const SalBitmap& rAlphaBitmap ) = 0; + /** Render bitmap with alpha channel @param rSourceBitmap diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx index 09ea28fdc92b..2fd7f56df28e 100644 --- a/vcl/inc/salgdiimpl.hxx +++ b/vcl/inc/salgdiimpl.hxx @@ -164,6 +164,16 @@ public: void* pPtr, sal_uLong nSize ) = 0; + virtual bool blendBitmap( + const SalTwoRect&, + const SalBitmap& rBitmap ) = 0; + + virtual bool blendAlphaBitmap( + const SalTwoRect&, + const SalBitmap& rSrcBitmap, + const SalBitmap& rMaskBitmap, + const SalBitmap& rAlphaBitmap ) = 0; + /** Render bitmap with alpha channel @param rSourceBitmap diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index 5caf7b944840..97f9d60c8dde 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -249,6 +249,14 @@ public: virtual bool drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uIntPtr nSize ) SAL_OVERRIDE; + virtual bool blendBitmap( const SalTwoRect&, + const SalBitmap& rBitmap ) SAL_OVERRIDE; + + virtual bool blendAlphaBitmap( const SalTwoRect&, + const SalBitmap& rSrcBitmap, + const SalBitmap& rMaskBitmap, + const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE; + virtual bool drawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE; diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 8d88784c805f..1af78077584c 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -312,6 +312,14 @@ protected: const ImplControlValue& aValue, const OUString& aCaption, Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion ); + virtual bool blendBitmap( const SalTwoRect&, + const SalBitmap& rBitmap ) SAL_OVERRIDE; + + virtual bool blendAlphaBitmap( const SalTwoRect&, + const SalBitmap& rSrcBitmap, + const SalBitmap& rMaskBitmap, + const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE; + virtual bool drawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap ); -- cgit