[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - vcl/inc vcl/opengl vcl/unx vcl/win

2014-11-13 Thread Louis-Francis Ratté-Boulianne
 vcl/inc/openglgdiimpl.hxx|4 +-
 vcl/opengl/gdiimpl.cxx   |   16 ++--
 vcl/unx/generic/gdi/openglx11cairotextrender.cxx |   45 +--
 vcl/win/source/gdi/winlayout.cxx |6 +--
 4 files changed, 29 insertions(+), 42 deletions(-)

New commits:
commit eefe932a05e2d8744242a1a715c4cd963f796646
Author: Louis-Francis Ratté-Boulianne l...@collabora.com
Date:   Thu Nov 13 22:24:35 2014 -0500

vcl: Add DrawAlphaTexture to directly render Cairo surface

Change-Id: I7aa824578b14999d0ef667a5bcfccd731f1d3b64

diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 0d91d48..65ec12e 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -85,6 +85,7 @@ protected:
 bool CreateLinearGradientProgram( void );
 bool CreateRadialGradientProgram( void );
 
+public:
 void BeginSolid( SalColor nColor, sal_uInt8 nTransparency );
 void BeginSolid( SalColor nColor, double fTransparency );
 void BeginSolid( SalColor nColor );
@@ -103,12 +104,13 @@ protected:
 void DrawPolyPolygon( const basegfx::B2DPolyPolygon rPolyPolygon );
 void DrawTextureRect( OpenGLTexture rTexture, const SalTwoRect rPosAry, 
bool bInverted = false );
 void DrawTexture( OpenGLTexture rTexture, const SalTwoRect rPosAry, bool 
bInverted = false );
+void DrawAlphaTexture( OpenGLTexture rTexture, const SalTwoRect rPosAry, 
bool bInverted = false, bool pPremultiplied = false );
 void DrawTextureWithMask( OpenGLTexture rTexture, OpenGLTexture rMask, 
const SalTwoRect rPosAry );
 void DrawMask( OpenGLTexture rTexture, SalColor nMaskColor, const 
SalTwoRect rPosAry );
 void DrawLinearGradient( const Gradient rGradient, const Rectangle rRect 
);
 void DrawRadialGradient( const Gradient rGradient, const Rectangle rRect 
);
 
-protected:
+public:
 // get the width of the device
 virtual GLfloat GetWidth() const = 0;
 
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index d05b08b..0c47f33 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -670,6 +670,17 @@ void OpenGLSalGraphicsImpl::DrawTexture( OpenGLTexture 
rTexture, const SalTwoRe
 CHECK_GL_ERROR();
 }
 
+void OpenGLSalGraphicsImpl::DrawAlphaTexture( OpenGLTexture rTexture, const 
SalTwoRect rPosAry, bool bInverted, bool bPremultiplied )
+{
+glEnable( GL_BLEND );
+if( bPremultiplied )
+glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
+else
+glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+DrawTexture( rTexture, rPosAry, bInverted );
+glDisable( GL_BLEND );
+}
+
 void OpenGLSalGraphicsImpl::DrawTextureWithMask( OpenGLTexture rTexture, 
OpenGLTexture rMask, const SalTwoRect pPosAry )
 {
 if( mnMaskedTextureProgram == 0 )
@@ -1301,10 +1312,7 @@ bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
 
 SAL_INFO( vcl.opengl, ::drawAlphaBitmap );
 PreDraw();
-glEnable( GL_BLEND );
-glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
-DrawTexture( rTexture, rPosAry );
-glDisable( GL_BLEND );
+DrawAlphaTexture( rTexture, rPosAry );
 PostDraw();
 
 CHECK_GL_ERROR();
diff --git a/vcl/unx/generic/gdi/openglx11cairotextrender.cxx 
b/vcl/unx/generic/gdi/openglx11cairotextrender.cxx
index 36a76b0..38a7213 100644
--- a/vcl/unx/generic/gdi/openglx11cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/openglx11cairotextrender.cxx
@@ -9,6 +9,7 @@
 
 #include openglx11cairotextrender.hxx
 
+#include openglgdiimpl.hxx
 #include salbmp.hxx
 #include vcl/salbtype.hxx
 
@@ -33,40 +34,8 @@ void OpenGLX11CairoTextRender::drawSurface(cairo_t* cr)
 cairo_surface_t* pSurface = cairo_get_target(cr);
 int nWidth = cairo_image_surface_get_width( pSurface );
 int nHeight = cairo_image_surface_get_height( pSurface );
-SalBitmap* pBitmap = ImplGetSVData()-mpDefInst-CreateSalBitmap();
-pBitmap-Create(Size(nWidth, nHeight), 32, BitmapPalette());
-
 cairo_surface_flush( pSurface );
-BitmapBuffer* pBuffer = pBitmap-AcquireBuffer(false);
 unsigned char *pSrc = cairo_image_surface_get_data( pSurface );
-unsigned int nSrcStride = cairo_image_surface_get_stride( pSurface );
-unsigned int nDestStride = pBuffer-mnScanlineSize;
-for( unsigned long y = 0; y  (unsigned long) nHeight; y++ )
-{
-// Cairo surface is y-inverse
-sal_uInt32 *pSrcPix = (sal_uInt32 *)(pSrc + nSrcStride * (nHeight - y 
- 1));
-sal_uInt32 *pDestPix = (sal_uInt32 *)(pBuffer-mpBits + nDestStride * 
y);
-for( unsigned long x = 0; x  (unsigned long) nWidth; x++ )
-{
-sal_uInt8 nAlpha = (*pSrcPix  24);
-sal_uInt8 nR = (*pSrcPix  16)  0xff;
-sal_uInt8 nG = (*pSrcPix  8)  0xff;
-sal_uInt8 nB = *pSrcPix  0xff;
-if( nAlpha != 0  nAlpha != 255 )
-{
-// Cairo uses pre-multiplied alpha - we do not = re-multiply
-nR = 

[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - vcl/inc vcl/opengl vcl/unx

2014-11-10 Thread Louis-Francis Ratté-Boulianne
 vcl/inc/openglgdiimpl.hxx|5 ++
 vcl/inc/salgdiimpl.hxx   |5 ++
 vcl/inc/unx/salgdi.h |4 +
 vcl/opengl/gdiimpl.cxx   |   17 +++
 vcl/unx/generic/gdi/gdiimpl.cxx  |6 ++
 vcl/unx/generic/gdi/gdiimpl.hxx  |4 +
 vcl/unx/generic/gdi/openglx11cairotextrender.cxx |   53 +++
 vcl/unx/generic/gdi/salgdi2.cxx  |6 ++
 8 files changed, 91 insertions(+), 9 deletions(-)

New commits:
commit 6fad1cfc18b084ac2974fc07c81208b1d4ab631a
Author: Louis-Francis Ratté-Boulianne l...@collabora.com
Date:   Mon Nov 10 23:30:02 2014 -0500

vcl: Fix text rendering with OpenGL

Change-Id: I7784fa81cb6f9a3d6437b2b628c37e7895c84733

diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 5a11952..56938b9 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -242,6 +242,11 @@ public:
 const SalBitmap rSourceBitmap,
 const SalBitmap rAlphaBitmap ) SAL_OVERRIDE;
 
+/** Render 32-bits bitmap with alpha channel */
+virtual bool drawAlphaBitmap(
+const SalTwoRect,
+const SalBitmap rBitmap ) SAL_OVERRIDE;
+
 /** draw transformed bitmap (maybe with alpha) where Null, X, Y define the 
coordinate system */
 virtual bool drawTransformedBitmap(
 const basegfx::B2DPoint rNull,
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index 5d49952..4b4b735 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -181,6 +181,11 @@ public:
 const SalBitmap rSourceBitmap,
 const SalBitmap rAlphaBitmap ) = 0;
 
+/** Render 32-bits bitmap with alpha channel */
+virtual bool drawAlphaBitmap(
+const SalTwoRect,
+const SalBitmap rBitmap ) = 0;
+
 /** draw transformed bitmap (maybe with alpha) where Null, X, Y define the 
coordinate system */
 virtual bool drawTransformedBitmap(
 const basegfx::B2DPoint rNull,
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index c288292..d532668 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -252,6 +252,10 @@ public:
 virtual booldrawAlphaBitmap( const SalTwoRect,
  const SalBitmap rSourceBitmap,
  const SalBitmap rAlphaBitmap ) 
SAL_OVERRIDE;
+
+virtual booldrawAlphaBitmap( const SalTwoRect,
+ const SalBitmap rBitmap );
+
 virtual bool drawTransformedBitmap(
 const basegfx::B2DPoint rNull,
 const basegfx::B2DPoint rX,
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 6413283..8c06769 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1007,6 +1007,23 @@ bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
 return true;
 }
 
+bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
+const SalTwoRect rPosAry,
+const SalBitmap rSalBitmap )
+{
+const OpenGLSalBitmap rBitmap = static_castconst 
OpenGLSalBitmap(rSalBitmap);
+const GLuint nTexture( rBitmap.GetTexture( maContext ) );
+
+SAL_INFO( vcl.opengl, ::drawAlphaBitmap );
+PreDraw();
+glEnable( GL_BLEND );
+glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+DrawTexture( nTexture, rBitmap.GetSize(), rPosAry );
+glDisable( GL_BLEND );
+PostDraw();
+return true;
+}
+
 /** draw transformed bitmap (maybe with alpha) where Null, X, Y define the 
coordinate system */
 bool OpenGLSalGraphicsImpl::drawTransformedBitmap(
 const basegfx::B2DPoint /*rNull*/,
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index 172ebd6..0f210b3 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -955,6 +955,12 @@ bool X11SalGraphicsImpl::drawAlphaBitmap( const 
SalTwoRect rTR,
 return true;
 }
 
+bool X11SalGraphicsImpl::drawAlphaBitmap( const SalTwoRect /*rTR*/,
+const SalBitmap /*rBitmap*/ )
+{
+return false;
+}
+
 bool X11SalGraphicsImpl::drawTransformedBitmap(
 const basegfx::B2DPoint rNull,
 const basegfx::B2DPoint rX,
diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx
index 252fe35..e6bfa86 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -242,6 +242,10 @@ public:
 const SalBitmap rSourceBitmap,
 const SalBitmap rAlphaBitmap ) SAL_OVERRIDE;
 
+virtual bool drawAlphaBitmap(
+const SalTwoRect,
+const SalBitmap rBitmap ) SAL_OVERRIDE;
+
 /** draw transformed bitmap (maybe with alpha) where Null, X, Y define the 
coordinate system */
 virtual bool drawTransformedBitmap(
 const basegfx::B2DPoint rNull,
diff --git