[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - vcl/inc vcl/opengl vcl/unx vcl/win
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/inc/openglgdiimpl.hxx|1 vcl/opengl/gdiimpl.cxx | 67 +++ vcl/opengl/linearGradientFragmentShader.glsl |2 3 files changed, 69 insertions(+), 1 deletion(-) New commits: commit fdbc95ee2a80b3660802cea5ac40e2032d78e15f Author: Louis-Francis Ratté-Boulianne l...@collabora.com Date: Fri Nov 14 01:16:28 2014 -0500 vcl: Implement axial gradients in OpenGL backend Change-Id: I93b8c3c076c79d992d467b01ca5f5eca1ed626d3 diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 65ec12e..fa88a2a 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -108,6 +108,7 @@ public: 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 DrawAxialGradient( const Gradient rGradient, const Rectangle rRect ); void DrawRadialGradient( const Gradient rGradient, const Rectangle rRect ); public: diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 0c47f33..09e80f8 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -772,6 +772,68 @@ void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient rGradient, const CHECK_GL_ERROR(); } +void OpenGLSalGraphicsImpl::DrawAxialGradient( const Gradient rGradient, const Rectangle rRect ) +{ +if( mnLinearGradientProgram == 0 ) +{ +if( !CreateLinearGradientProgram() ) +return; +} + +glUseProgram( mnLinearGradientProgram ); + +Color aStartCol = rGradient.GetStartColor(); +Color aEndCol = rGradient.GetEndColor(); +long nFactor = rGradient.GetStartIntensity(); +glUniformColorIntensity( mnLinearGradientStartColorUniform, aStartCol, nFactor ); +nFactor = rGradient.GetEndIntensity(); +glUniformColorIntensity( mnLinearGradientEndColorUniform, aEndCol, nFactor ); + +/** + * Draw two rectangles with linear gradient. + * + * 1 *---* 2 + *| /| + *| / | Points 0 and 3 have start color + * 0 |/__| 3 Points 1, 2, 4 and 5 have end color + *|\ | + *| \ | + *| \| + * 5 *---* 4 + * + */ + +Rectangle aRect; +Point aCenter; +rGradient.GetBoundRect( rRect, aRect, aCenter ); + +// determine points 0 and 3 +Point aPt0( aRect.Left(), (aRect.Top() + aRect.Bottom() + 1) / 2 ); +Point aPt3( aRect.Right(), (aRect.Top() + aRect.Bottom() + 1) / 2 ); + +Polygon aPoly( 7 ); +aPoly.SetPoint( aPt0,0 ); +aPoly.SetPoint( aRect.TopLeft(), 1 ); +aPoly.SetPoint( aRect.TopRight(),2 ); +aPoly.SetPoint( aPt3,3 ); +aPoly.SetPoint( aRect.BottomRight(), 4 ); +aPoly.SetPoint( aRect.BottomLeft(), 5 ); +aPoly.SetPoint( aPt0,6 ); +aPoly.Rotate( aCenter, rGradient.GetAngle() % 3600 ); + +GLfloat aTexCoord[12] = { 0, 1, 1, 0, 2, 0, 3, 1, 4, 0, 5, 0 }; +GLfloat fMin = 1.0 - 100.0 / (100.0 - rGradient.GetBorder()); +aTexCoord[3] = aTexCoord[5] = aTexCoord[9] = aTexCoord[11] = fMin; +glEnableVertexAttribArray( GL_ATTRIB_TEX ); +glVertexAttribPointer( GL_ATTRIB_TEX, 2, GL_FLOAT, GL_FALSE, 0, aTexCoord ); + +DrawConvexPolygon( aPoly ); + +glDisableVertexAttribArray( GL_ATTRIB_TEX ); +glUseProgram( 0 ); +CHECK_GL_ERROR(); +} + void OpenGLSalGraphicsImpl::DrawRadialGradient( const Gradient rGradient, const Rectangle rRect ) { if( mnRadialGradientProgram == 0 ) @@ -1365,6 +1427,7 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon rPolyPoly, return true; if( rGradient.GetStyle() != GradientStyle_LINEAR +rGradient.GetStyle() != GradientStyle_AXIAL rGradient.GetStyle() != GradientStyle_RADIAL ) return false; @@ -1402,6 +1465,10 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon rPolyPoly, { DrawLinearGradient( rGradient, aBoundRect ); } +else if( rGradient.GetStyle() == GradientStyle_AXIAL ) +{ +DrawAxialGradient( rGradient, aBoundRect ); +} else if( rGradient.GetStyle() == GradientStyle_RADIAL ) { DrawRadialGradient( rGradient, aBoundRect ); diff --git a/vcl/opengl/linearGradientFragmentShader.glsl b/vcl/opengl/linearGradientFragmentShader.glsl index 7b84c06..bd1137c 100644 --- a/vcl/opengl/linearGradientFragmentShader.glsl +++ b/vcl/opengl/linearGradientFragmentShader.glsl @@ -16,7 +16,7 @@ varying vec2 tex_coord; void main(void) { -gl_FragColor = mix(start_color, end_color, +gl_FragColor = mix(end_color, start_color, clamp(tex_coord.t, 0.0, 1.0)); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org
[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - vcl/inc vcl/opengl
vcl/inc/openglgdiimpl.hxx |1 + vcl/opengl/gdiimpl.cxx| 21 + 2 files changed, 22 insertions(+) New commits: commit 9754b88b627b7391e3daf75a67f280014a7eab03 Author: Jan Holesovsky ke...@collabora.com Date: Tue Nov 11 10:24:37 2014 +0100 windows opengl: We need a constructor for OpenGLSalGraphicsImpl. Otherwise we a get random value in mnSolidProgram, and we never initialize that. Change-Id: Ic648a1f6755021da25f5b9da306cf600a3f0c739 diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 56938b9..6f920e5 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -101,6 +101,7 @@ protected: public: +OpenGLSalGraphicsImpl(); virtual ~OpenGLSalGraphicsImpl (); OpenGLContext GetOpenGLContext() { return maContext; } diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 85252ef..5856fb8 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -51,6 +51,26 @@ ((float) SALCOLOR_BLUE( nColor )) / 255, \ (1.0f - fTransparency) ) +OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl() +: mpFrame(NULL) +, mbOffscreen(false) +, mnFramebufferId(0) +, mpOffscreenTex(NULL) +, mnLineColor(SALCOLOR_NONE) +, mnFillColor(SALCOLOR_NONE) +, mnSolidProgram(0) +, mnColorUniform(0) +, mnTextureProgram(0) +, mnSamplerUniform(0) +, mnMaskedTextureProgram(0) +, mnMaskedSamplerUniform(0) +, mnMaskSamplerUniform(0) +, mnMaskProgram(0) +, mnMaskUniform(0) +, mnMaskColorUniform(0) +{ +} + OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl() { } @@ -209,6 +229,7 @@ void OpenGLSalGraphicsImpl::SetOffscreen( bool bOffscreen ) bool OpenGLSalGraphicsImpl::CreateSolidProgram( void ) { +SAL_INFO( vcl.opengl, ::CreateSolidProgram ); mnSolidProgram = OpenGLHelper::LoadShaders( solidVertexShader, solidFragmentShader ); if( mnSolidProgram == 0 ) return false; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - vcl/inc vcl/opengl vcl/Package_opengl.mk
vcl/Package_opengl.mk|1 vcl/inc/openglgdiimpl.hxx|9 ++ vcl/opengl/gdiimpl.cxx | 111 ++- vcl/opengl/linearGradientFragmentShader.glsl | 23 + 4 files changed, 142 insertions(+), 2 deletions(-) New commits: commit 2e9e71ca3ece1cba70b6b12d0aa0d67bb0b89caf Author: Louis-Francis Ratté-Boulianne l...@collabora.com Date: Tue Nov 11 05:13:40 2014 -0500 vcl: Add initial support for linear gradient with OpenGL Change-Id: Iccc12c94bfd68387dfc0161a5fde4f595edda0e1 diff --git a/vcl/Package_opengl.mk b/vcl/Package_opengl.mk index 79dabb7..da40d71 100644 --- a/vcl/Package_opengl.mk +++ b/vcl/Package_opengl.mk @@ -11,6 +11,7 @@ $(eval $(call gb_Package_Package,vcl_opengl_shader,$(SRCDIR)/vcl/opengl)) $(eval $(call gb_Package_add_files,vcl_opengl_shader,$(LIBO_ETC_FOLDER)/opengl,\ convolutionFragmentShader.glsl \ + linearGradientFragmentShader.glsl \ maskFragmentShader.glsl \ maskVertexShader.glsl \ maskedTextureFragmentShader.glsl \ diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 6f920e5..c9e8b68 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -25,6 +25,7 @@ #include opengl/texture.hxx +#include tools/poly.hxx #include vcl/opengl/OpenGLContext.hxx class SalFrame; @@ -59,10 +60,16 @@ protected: GLuint mnMaskUniform; GLuint mnMaskColorUniform; +GLuint mnLinearGradientProgram; +GLuint mnLinearGradientStartColorUniform; +GLuint mnLinearGradientEndColorUniform; +GLuint mnLinearGradientTransformUniform; + bool CreateSolidProgram( void ); bool CreateTextureProgram( void ); bool CreateMaskedTextureProgram( void ); bool CreateMaskProgram( void ); +bool CreateLinearGradientProgram( void ); void BeginSolid( SalColor nColor, sal_uInt8 nTransparency ); void BeginSolid( SalColor nColor, double fTransparency ); @@ -75,6 +82,7 @@ protected: void DrawLine( long nX1, long nY1, long nX2, long nY2 ); void DrawLines( sal_uInt32 nPoints, const SalPoint* pPtAry, bool bClose ); void DrawConvexPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); +void DrawConvexPolygon( const Polygon rPolygon ); void DrawRect( long nX, long nY, long nWidth, long nHeight ); void DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); void DrawPolyPolygon( const basegfx::B2DPolyPolygon rPolyPolygon ); @@ -82,6 +90,7 @@ protected: void DrawTexture( GLuint nTexture, const Size rSize, const SalTwoRect rPosAry ); void DrawTextureWithMask( GLuint nTexture, GLuint nMask, const Size rSize, const SalTwoRect rPosAry ); void DrawMask( GLuint nMask, SalColor nMaskColor, const SalTwoRect rPosAry ); +void DrawLinearGradient( const Gradient rGradient, const Rectangle rRect ); protected: // get the width of the device diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 5856fb8..b00fa41 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -51,6 +51,13 @@ ((float) SALCOLOR_BLUE( nColor )) / 255, \ (1.0f - fTransparency) ) +#define glUniformColorIntensity(nUniform, aColor, nFactor) \ +glUniform4f( nUniform, \ + ((float) aColor.GetRed()) * nFactor / 25500.0, \ + ((float) aColor.GetGreen()) * nFactor / 25500.0, \ + ((float) aColor.GetBlue()) * nFactor / 25500.0, \ + 1.0f ) + OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl() : mpFrame(NULL) , mbOffscreen(false) @@ -278,6 +285,20 @@ bool OpenGLSalGraphicsImpl::CreateMaskProgram( void ) return true; } +bool OpenGLSalGraphicsImpl::CreateLinearGradientProgram( void ) +{ +mnLinearGradientProgram = OpenGLHelper::LoadShaders( textureVertexShader, linearGradientFragmentShader ); +if( mnLinearGradientProgram == 0 ) +return false; + +glBindAttribLocation( mnTextureProgram, GL_ATTRIB_POS, position ); +glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, tex_coord_in ); +mnLinearGradientStartColorUniform = glGetUniformLocation( mnLinearGradientProgram, start_color ); +mnLinearGradientEndColorUniform = glGetUniformLocation( mnLinearGradientProgram, end_color ); +mnLinearGradientTransformUniform = glGetUniformLocation( mnLinearGradientProgram, transform ); +return true; +} + void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor, sal_uInt8 nTransparency ) { if( mnSolidProgram == 0 ) @@ -403,6 +424,25 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin glDisableVertexAttribArray( GL_ATTRIB_POS ); } +void OpenGLSalGraphicsImpl::DrawConvexPolygon( const Polygon rPolygon ) +{ +sal_uInt16 nPoints = rPolygon.GetSize() - 1; +std::vectorGLfloat aVertices(nPoints * 2); +sal_uInt32 i, j; + +for(
[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - vcl/inc vcl/opengl
vcl/inc/openglgdiimpl.hxx |4 ++-- vcl/opengl/gdiimpl.cxx | 19 ++- vcl/opengl/x11/gdiimpl.cxx | 33 +++-- 3 files changed, 47 insertions(+), 9 deletions(-) New commits: commit 9ce55489da514d2769227c7b9904da1fdf216f21 Author: Louis-Francis Ratté-Boulianne l...@collabora.com Date: Tue Nov 11 13:43:56 2014 -0500 vcl: Read back OpenGL FBO to create offscreen X11 pixmap Change-Id: I330e7d62bf31b4a90b5866d9531f073f7c69c92a diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index c9e8b68..535bc72 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -86,8 +86,8 @@ protected: void DrawRect( long nX, long nY, long nWidth, long nHeight ); void DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); 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 DrawTextureRect( const Size rSize, const SalTwoRect rPosAry, bool bInverted = false ); +void DrawTexture( GLuint nTexture, const Size rSize, const SalTwoRect rPosAry, bool bInverted = false ); void DrawTextureWithMask( GLuint nTexture, GLuint nMask, const Size rSize, const SalTwoRect rPosAry ); void DrawMask( GLuint nMask, SalColor nMaskColor, const SalTwoRect rPosAry ); void DrawLinearGradient( const Gradient rGradient, const Rectangle rRect ); diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 7d76819..752741e 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -503,14 +503,23 @@ void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon rPol glDisableVertexAttribArray( GL_ATTRIB_POS ); } -void OpenGLSalGraphicsImpl::DrawTextureRect( const Size rSize, const SalTwoRect rPosAry ) +void OpenGLSalGraphicsImpl::DrawTextureRect( const Size rSize, const SalTwoRect rPosAry, bool bInverted ) { 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] = (rSize.Height() - rPosAry.mnSrcY) / (double) rSize.Height(); -aTexCoord[1] = aTexCoord[7] = (rSize.Height() - rPosAry.mnSrcY - rPosAry.mnSrcHeight) / (double) rSize.Height(); + +if( !bInverted ) +{ +aTexCoord[3] = aTexCoord[5] = (rSize.Height() - rPosAry.mnSrcY) / (double) rSize.Height(); +aTexCoord[1] = aTexCoord[7] = (rSize.Height() - rPosAry.mnSrcY - rPosAry.mnSrcHeight) / (double) rSize.Height(); +} +else +{ +aTexCoord[1] = aTexCoord[7] = (rSize.Height() - rPosAry.mnSrcY) / (double) rSize.Height(); +aTexCoord[3] = aTexCoord[5] = (rSize.Height() - rPosAry.mnSrcY - rPosAry.mnSrcHeight) / (double) rSize.Height(); +} glEnableVertexAttribArray( GL_ATTRIB_TEX ); glVertexAttribPointer( GL_ATTRIB_TEX, 2, GL_FLOAT, GL_FALSE, 0, aTexCoord ); @@ -520,7 +529,7 @@ void OpenGLSalGraphicsImpl::DrawTextureRect( const Size rSize, const SalTwoRect glDisableVertexAttribArray( GL_ATTRIB_TEX ); } -void OpenGLSalGraphicsImpl::DrawTexture( GLuint nTexture, const Size rSize, const SalTwoRect pPosAry ) +void OpenGLSalGraphicsImpl::DrawTexture( GLuint nTexture, const Size rSize, const SalTwoRect pPosAry, bool bInverted ) { if( mnTextureProgram == 0 ) { @@ -534,7 +543,7 @@ void OpenGLSalGraphicsImpl::DrawTexture( GLuint nTexture, const Size rSize, con CHECK_GL_ERROR(); glBindTexture( GL_TEXTURE_2D, nTexture ); -DrawTextureRect( rSize, pPosAry ); +DrawTextureRect( rSize, pPosAry, bInverted ); CHECK_GL_ERROR(); glBindTexture( GL_TEXTURE_2D, 0 ); diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx index 6e803bd..13b7049 100644 --- a/vcl/opengl/x11/gdiimpl.cxx +++ b/vcl/opengl/x11/gdiimpl.cxx @@ -83,9 +83,38 @@ X11Pixmap* X11OpenGLSalGraphicsImpl::GetPixmapFromScreen( const Rectangle rRect { Display* pDisplay = mrParent.GetXDisplay(); SalX11Screen nScreen = mrParent.GetScreenNumber(); +XVisualInfo aVisualInfo; +X11Pixmap* pPixmap; +XImage* pImage; +sal_uInt8* pData; SAL_INFO( vcl.opengl, GetPixmapFromScreen ); -return new X11Pixmap( pDisplay, nScreen, rRect.GetWidth(), rRect.GetHeight(), 24 ); +// TODO: lfrb: Use context depth +pPixmap = new X11Pixmap( pDisplay, nScreen, rRect.GetWidth(), rRect.GetHeight(), 24 ); + +if( !OpenGLHelper::GetVisualInfo( pDisplay, nScreen.getXScreen(), aVisualInfo ) ) +return pPixmap; + +// make sure everything is synced up before reading back +maContext.makeCurrent(); +glXWaitX(); + +// TODO: lfrb: What if offscreen? +pData = new sal_uInt8[rRect.GetWidth() * rRect.GetHeight() * 4]; +glPixelStorei( GL_PACK_ALIGNMENT, 1 ); +
[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - vcl/inc vcl/opengl vcl/Package_opengl.mk
vcl/Package_opengl.mk|1 vcl/inc/openglgdiimpl.hxx|9 +- vcl/opengl/gdiimpl.cxx | 118 ++- vcl/opengl/radialGradientFragmentShader.glsl | 23 + 4 files changed, 132 insertions(+), 19 deletions(-) New commits: commit f0565838389b4a0495450c3aa2ff09b0ca91e143 Author: Louis-Francis Ratté-Boulianne l...@collabora.com Date: Tue Nov 11 15:54:03 2014 -0500 vcl: Add support for radial gradients in OpenGL backend Change-Id: Ie47fb18ae7d5286fe7559c7dffbc54b0856d4d8e diff --git a/vcl/Package_opengl.mk b/vcl/Package_opengl.mk index da40d71..18c56fc 100644 --- a/vcl/Package_opengl.mk +++ b/vcl/Package_opengl.mk @@ -16,6 +16,7 @@ $(eval $(call gb_Package_add_files,vcl_opengl_shader,$(LIBO_ETC_FOLDER)/opengl,\ maskVertexShader.glsl \ maskedTextureFragmentShader.glsl \ maskedTextureVertexShader.glsl \ + radialGradientFragmentShader.glsl \ solidFragmentShader.glsl \ solidVertexShader.glsl \ textureFragmentShader.glsl \ diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 535bc72..f80c969 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -63,13 +63,18 @@ protected: GLuint mnLinearGradientProgram; GLuint mnLinearGradientStartColorUniform; GLuint mnLinearGradientEndColorUniform; -GLuint mnLinearGradientTransformUniform; + +GLuint mnRadialGradientProgram; +GLuint mnRadialGradientStartColorUniform; +GLuint mnRadialGradientEndColorUniform; +GLuint mnRadialGradientCenterUniform; bool CreateSolidProgram( void ); bool CreateTextureProgram( void ); bool CreateMaskedTextureProgram( void ); bool CreateMaskProgram( void ); bool CreateLinearGradientProgram( void ); +bool CreateRadialGradientProgram( void ); void BeginSolid( SalColor nColor, sal_uInt8 nTransparency ); void BeginSolid( SalColor nColor, double fTransparency ); @@ -84,6 +89,7 @@ protected: void DrawConvexPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); void DrawConvexPolygon( const Polygon rPolygon ); void DrawRect( long nX, long nY, long nWidth, long nHeight ); +void DrawRect( const Rectangle rRect ); void DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ); void DrawPolyPolygon( const basegfx::B2DPolyPolygon rPolyPolygon ); void DrawTextureRect( const Size rSize, const SalTwoRect rPosAry, bool bInverted = false ); @@ -91,6 +97,7 @@ protected: void DrawTextureWithMask( GLuint nTexture, GLuint nMask, const Size rSize, const SalTwoRect rPosAry ); void DrawMask( GLuint nMask, SalColor nMaskColor, const SalTwoRect rPosAry ); void DrawLinearGradient( const Gradient rGradient, const Rectangle rRect ); +void DrawRadialGradient( const Gradient rGradient, const Rectangle rRect ); protected: // get the width of the device diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 752741e..777cfa3 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -75,6 +75,13 @@ OpenGLSalGraphicsImpl::OpenGLSalGraphicsImpl() , mnMaskProgram(0) , mnMaskUniform(0) , mnMaskColorUniform(0) +, mnLinearGradientProgram(0) +, mnLinearGradientStartColorUniform(0) +, mnLinearGradientEndColorUniform(0) +, mnRadialGradientProgram(0) +, mnRadialGradientStartColorUniform(0) +, mnRadialGradientEndColorUniform(0) +, mnRadialGradientCenterUniform(0) { } @@ -295,7 +302,20 @@ bool OpenGLSalGraphicsImpl::CreateLinearGradientProgram( void ) glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, tex_coord_in ); mnLinearGradientStartColorUniform = glGetUniformLocation( mnLinearGradientProgram, start_color ); mnLinearGradientEndColorUniform = glGetUniformLocation( mnLinearGradientProgram, end_color ); -mnLinearGradientTransformUniform = glGetUniformLocation( mnLinearGradientProgram, transform ); +return true; +} + +bool OpenGLSalGraphicsImpl::CreateRadialGradientProgram( void ) +{ +mnRadialGradientProgram = OpenGLHelper::LoadShaders( textureVertexShader, radialGradientFragmentShader ); +if( mnRadialGradientProgram == 0 ) +return false; + +glBindAttribLocation( mnTextureProgram, GL_ATTRIB_POS, position ); +glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, tex_coord_in ); +mnRadialGradientStartColorUniform = glGetUniformLocation( mnRadialGradientProgram, start_color ); +mnRadialGradientEndColorUniform = glGetUniformLocation( mnRadialGradientProgram, end_color ); +mnRadialGradientCenterUniform = glGetUniformLocation( mnRadialGradientProgram, center ); return true; } @@ -455,6 +475,18 @@ void OpenGLSalGraphicsImpl::DrawRect( long nX, long nY, long nWidth, long nHeigh DrawConvexPolygon( 4, aPoints ); } +void OpenGLSalGraphicsImpl::DrawRect( const Rectangle rRect ) +{ +long nX1( rRect.Left()
[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - vcl/inc vcl/opengl vcl/unx
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