[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - 15 commits - basegfx/source vcl/inc vcl/opengl vcl/source vcl/win vcl/workben
Markus Mohrhard
markus.mohrhard at googlemail.com
Sun Nov 9 00:59:49 PST 2014
basegfx/source/polygon/b2dpolypolygoncutter.cxx | 2
vcl/inc/impbmp.hxx | 7
vcl/inc/openglgdiimpl.hxx | 3
vcl/opengl/gdiimpl.cxx | 246 ++++++++++++++++++------
vcl/opengl/maskedTextureFragmentShader.glsl | 9
vcl/opengl/salbmp.cxx | 4
vcl/opengl/solidFragmentShader.glsl | 2
vcl/source/gdi/bitmap.cxx | 3
vcl/source/gdi/impbmp.cxx | 7
vcl/source/opengl/OpenGLContext.cxx | 8
vcl/source/outdev/bitmap.cxx | 3
vcl/source/outdev/polygon.cxx | 2
vcl/win/source/gdi/gdiimpl.cxx | 4
vcl/win/source/gdi/gdiimpl.hxx | 2
vcl/workben/vcldemo.cxx | 2
15 files changed, 225 insertions(+), 79 deletions(-)
New commits:
commit d22fe8b313ef3bb0af7231632ee5543b84109d87
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Nov 9 08:50:41 2014 +0100
remove that method also in the windows backend
Change-Id: I578d842614fdc227459a3aaf889e062499b8bdbf
diff --git a/vcl/win/source/gdi/gdiimpl.cxx b/vcl/win/source/gdi/gdiimpl.cxx
index de9b6e3..453033f 100644
--- a/vcl/win/source/gdi/gdiimpl.cxx
+++ b/vcl/win/source/gdi/gdiimpl.cxx
@@ -294,10 +294,6 @@ WinSalGraphicsImpl::~WinSalGraphicsImpl()
}
-void WinSalGraphicsImpl::Init(SalFrame* /*pFrame*/)
-{
-}
-
void WinSalGraphicsImpl::freeResources()
{
}
diff --git a/vcl/win/source/gdi/gdiimpl.hxx b/vcl/win/source/gdi/gdiimpl.hxx
index ebef9ea..2a0780f 100644
--- a/vcl/win/source/gdi/gdiimpl.hxx
+++ b/vcl/win/source/gdi/gdiimpl.hxx
@@ -52,8 +52,6 @@ public:
virtual ~WinSalGraphicsImpl();
- virtual void Init(SalFrame* pFrame) SAL_OVERRIDE;
-
virtual void freeResources() SAL_OVERRIDE;
virtual bool setClipRegion( const vcl::Region& ) SAL_OVERRIDE;
commit 198c656097aacc48f41aa3d1011d499cbedefc8c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Nov 9 08:43:44 2014 +0100
fix windows compile errors in OpenGLContext
Change-Id: Ic1a072d340d9115a6fc110bc9f71532739985d48
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 5508dfd..1062a87 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -42,9 +42,11 @@ OpenGLContext::OpenGLContext():
mbInitialized(false),
mbRequestLegacyContext(false),
mbUseDoubleBufferedRendering(true),
- mbRequestVirtualDevice(false),
- mbPixmap(false)
+ mbRequestVirtualDevice(false)
{
+#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
+ mbPixmap = false;
+#endif
}
OpenGLContext::~OpenGLContext()
@@ -803,6 +805,8 @@ bool OpenGLContext::ImplInit()
return false;
}
+ RECT clientRect;
+ GetClientRect(WindowFromDC(m_aGLWin.hDC), &clientRect);
m_aGLWin.Width = clientRect.right - clientRect.left;
m_aGLWin.Height = clientRect.bottom - clientRect.top;
commit 5c3ac0d843d92d014353c90ed51f54d82b68d49d
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Sat Nov 8 23:05:32 2014 -0500
vcl: Re-enable features in vcldemo
Change-Id: If2a17b2c5609b7529d9aa5091ced280dd5ac4176
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index cae3fb0b..daa877f 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -25,10 +25,10 @@
#include <vcl/virdev.hxx>
#include <vcl/graphicfilter.hxx>
-#if 0
# define FIXME_ALPHA_WORKING
# define FIXME_ROUNDED_RECT_WORKING
# define FIXME_DRAW_TRANSPARENT_WORKING
+#if 0
#endif
using namespace css;
commit 10dbdbf948884dc6f6ac9559d456642b50a6d2b9
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Sat Nov 8 23:04:46 2014 -0500
vcl: Add support for styled lines rendering with OpenGL
Change-Id: Id6117e79d3aec6524598f068500249c9cd286ece
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index d0b1afb..7094727 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -22,9 +22,12 @@
#include <vcl/gradient.hxx>
#include <salframe.hxx>
#include "salvd.hxx"
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <basegfx/polygon/b2dlinegeometry.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/polygon/b2dpolygontriangulator.hxx>
#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+#include <basegfx/polygon/b2dtrapezoid.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
#include "opengl/salbmp.hxx"
@@ -648,13 +651,84 @@ bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rP
}
bool OpenGLSalGraphicsImpl::drawPolyLine(
- const ::basegfx::B2DPolygon&,
- double /*fTransparency*/,
- const ::basegfx::B2DVector& /*rLineWidths*/,
- basegfx::B2DLineJoin,
- com::sun::star::drawing::LineCap)
-{
- return false;
+ const ::basegfx::B2DPolygon& rPolygon,
+ double fTransparency,
+ const ::basegfx::B2DVector& rLineWidth,
+ basegfx::B2DLineJoin eLineJoin,
+ com::sun::star::drawing::LineCap eLineCap)
+{
+ SAL_INFO( "vcl.opengl", "::drawPolyLine trans " << fTransparency );
+ if( mnLineColor == SALCOLOR_NONE )
+ return true;
+
+ const bool bIsHairline = (rLineWidth.getX() == rLineWidth.getY()) && (rLineWidth.getX() <= 1.2);
+
+ // #i101491#
+ if( !bIsHairline && (rPolygon.count() > 1000) )
+ {
+ // the used basegfx::tools::createAreaGeometry is simply too
+ // expensive with very big polygons; fallback to caller (who
+ // should use ImplLineConverter normally)
+ // AW: ImplLineConverter had to be removed since it does not even
+ // know LineJoins, so the fallback will now prepare the line geometry
+ // the same way.
+ return false;
+ }
+
+ // #i11575#desc5#b adjust B2D tesselation result to raster positions
+ basegfx::B2DPolygon aPolygon = rPolygon;
+ const double fHalfWidth = 0.5 * rLineWidth.getX();
+
+ // #i122456# This is probably thought to happen to align hairlines to pixel positions, so
+ // it should be a 0.5 translation, not more. It will definitely go wrong with fat lines
+ aPolygon.transform( basegfx::tools::createTranslateB2DHomMatrix(0.5, 0.5) );
+
+ // shortcut for hairline drawing to improve performance
+ //bool bDrawnOk = true;
+ if( bIsHairline )
+ {
+ // hairlines can benefit from a simplified tesselation
+ // e.g. for hairlines the linejoin style can be ignored
+ /*basegfx::B2DTrapezoidVector aB2DTrapVector;
+ basegfx::tools::createLineTrapezoidFromB2DPolygon( aB2DTrapVector, aPolygon, rLineWidth.getX() );
+
+ // draw tesselation result
+ const int nTrapCount = aB2DTrapVector.size();
+ if( nTrapCount > 0 )
+ bDrawnOk = drawFilledTrapezoids( &aB2DTrapVector[0], nTrapCount, fTransparency );
+
+ return bDrawnOk;*/
+ }
+
+ // get the area polygon for the line polygon
+ if( (rLineWidth.getX() != rLineWidth.getY())
+ && !basegfx::fTools::equalZero( rLineWidth.getY() ) )
+ {
+ // prepare for createAreaGeometry() with anisotropic linewidth
+ aPolygon.transform( basegfx::tools::createScaleB2DHomMatrix(1.0, rLineWidth.getX() / rLineWidth.getY()));
+ }
+
+ // create the area-polygon for the line
+ const basegfx::B2DPolyPolygon aAreaPolyPoly( basegfx::tools::createAreaGeometry(aPolygon, fHalfWidth, eLineJoin, eLineCap) );
+
+ if( (rLineWidth.getX() != rLineWidth.getY())
+ && !basegfx::fTools::equalZero( rLineWidth.getX() ) )
+ {
+ // postprocess createAreaGeometry() for anisotropic linewidth
+ aPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(1.0, rLineWidth.getY() / rLineWidth.getX()));
+ }
+
+ maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
+ BeginSolid( mnLineColor, fTransparency );
+ for( sal_uInt32 i = 0; i < aAreaPolyPoly.count(); i++ )
+ {
+ const ::basegfx::B2DPolyPolygon aOnePoly( aAreaPolyPoly.getB2DPolygon( i ) );
+ DrawPolyPolygon( aOnePoly );
+ }
+ EndSolid();
+
+ return true;
}
bool OpenGLSalGraphicsImpl::drawPolyLineBezier(
commit 659ed2b09c3d6ac566d4136366615ee155684d9c
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Sat Nov 8 23:03:37 2014 -0500
vcl: Fix rendering of polypolygons and self-intersecting polygons with OpenGL
Change-Id: I04ed5999360eb43e2a8e2c82a3ecd9b958b16fe0
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 0e30f6a..d0b1afb 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -24,6 +24,7 @@
#include "salvd.hxx"
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/polygon/b2dpolygontriangulator.hxx>
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
#include "opengl/salbmp.hxx"
@@ -354,54 +355,39 @@ void OpenGLSalGraphicsImpl::DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPt
if( ::basegfx::tools::isConvex( aPolygon ) )
{
if( nPoints > 2L )
- {
DrawConvexPolygon( nPoints, pPtAry );
- }
}
else
{
- const ::basegfx::B2DPolygon& aResult(
- ::basegfx::triangulator::triangulate( aPolygon ) );
- std::vector<GLfloat> aVertices(aResult.count() * 2);
- sal_uInt32 j( 0 );
-
- float nHeight = GetHeight();
- float nWidth = GetWidth();
- for( sal_uInt32 i = 0; i < aResult.count(); i++ )
- {
- const ::basegfx::B2DPoint& rPt( aResult.getB2DPoint(i) );
- aVertices[j++] = 2 * rPt.getX() / nWidth - 1.0f;
- aVertices[j++] = 1.0f - 2 * rPt.getY() / nHeight;
- }
-
- glEnableVertexAttribArray( GL_ATTRIB_POS );
- glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, &aVertices[0] );
- glDrawArrays( GL_TRIANGLES, 0, aResult.count() );
- glDisableVertexAttribArray( GL_ATTRIB_POS );
+ const ::basegfx::B2DPolyPolygon aPolyPolygon( aPolygon );
+ DrawPolyPolygon( aPolyPolygon );
}
}
-void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& pPolyPolygon )
+void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon )
{
sal_uInt32 i, j;
- ::std::vector< GLushort > pVertices;
+ ::std::vector< GLfloat > pVertices;
+ GLfloat nWidth = GetWidth();
+ GLfloat nHeight = GetHeight();
+ const ::basegfx::B2DPolyPolygon& aSimplePolyPolygon = ::basegfx::tools::solveCrossovers( rPolyPolygon );
- for( i = 0; i < pPolyPolygon.count(); i++ )
+ for( i = 0; i < aSimplePolyPolygon.count(); i++ )
{
- const basegfx::B2DPolygon& pPolygon( pPolyPolygon.getB2DPolygon( i ) );
+ const basegfx::B2DPolygon& rPolygon( aSimplePolyPolygon.getB2DPolygon( i ) );
const ::basegfx::B2DPolygon& aResult(
- ::basegfx::triangulator::triangulate( pPolygon ) );
+ ::basegfx::triangulator::triangulate( rPolygon ) );
for( j = 0; j < aResult.count(); j++ )
{
const ::basegfx::B2DPoint& rPt( aResult.getB2DPoint( j ) );
- pVertices.push_back( rPt.getX() );
- pVertices.push_back( rPt.getY() );
+ pVertices.push_back( 2 * rPt.getX() / nWidth - 1.0f );
+ pVertices.push_back( 1.0f - 2 * rPt.getY() / nHeight );
}
}
glEnableVertexAttribArray( GL_ATTRIB_POS );
- glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_UNSIGNED_SHORT, GL_FALSE, 0, pVertices.data() );
+ glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, pVertices.data() );
glDrawArrays( GL_TRIANGLES, 0, pVertices.size() / 2 );
glDisableVertexAttribArray( GL_ATTRIB_POS );
}
commit 172777b1390c7ef209dea60f3de9fde07bf71135
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Sat Nov 8 23:01:27 2014 -0500
vcl: Add support for alpha mask rendering with OpenGL
Change-Id: I755c2132f143d5ebd69e53bb4d9ae45121ada22a
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 9368a10..34c2607 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -76,7 +76,7 @@ protected:
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 DrawTextureWithMask( GLuint nTexture, GLuint nMask, const Size& rSize, const SalTwoRect& rPosAry );
void DrawMask( GLuint nMask, SalColor nMaskColor, const SalTwoRect& rPosAry );
protected:
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 74f7252..0e30f6a 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -444,7 +444,7 @@ void OpenGLSalGraphicsImpl::DrawTexture( GLuint nTexture, const Size& rSize, con
glUseProgram( 0 );
}
-void OpenGLSalGraphicsImpl::DrawTextureWithMask( GLuint nTexture, GLuint nMask, const SalTwoRect& /*pPosAry*/ )
+void OpenGLSalGraphicsImpl::DrawTextureWithMask( GLuint nTexture, GLuint nMask, const Size& rSize, const SalTwoRect& pPosAry )
{
if( mnMaskedTextureProgram == 0 )
{
@@ -460,7 +460,10 @@ void OpenGLSalGraphicsImpl::DrawTextureWithMask( GLuint nTexture, GLuint nMask,
glActiveTexture( GL_TEXTURE1 );
glBindTexture( GL_TEXTURE_2D, nMask );
- //DrawTextureRect( pPosAry );
+ glEnable( GL_BLEND );
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ DrawTextureRect( rSize, pPosAry );
+ glDisable( GL_BLEND );
glActiveTexture( GL_TEXTURE1 );
glBindTexture( GL_TEXTURE_2D, 0 );
@@ -758,9 +761,10 @@ void OpenGLSalGraphicsImpl::drawBitmap(
const GLuint nTexture( rBitmap.GetTexture( maContext ) );
const GLuint nMask( rMask.GetTexture( maContext ) );
- SAL_INFO( "vcl.opengl", "::drawBitmap" );
+ SAL_INFO( "vcl.opengl", "::drawBitmap with MASK" );
maContext.makeCurrent();
- DrawTextureWithMask( nTexture, nMask, rPosAry );
+ glViewport( 0, 0, GetWidth(), GetHeight() );
+ DrawTextureWithMask( nTexture, nMask, rBitmap.GetSize(), rPosAry );
}
void OpenGLSalGraphicsImpl::drawMask(
@@ -881,8 +885,10 @@ bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
const GLuint nTexture( rBitmap.GetTexture( maContext ) );
const GLuint nAlpha( rAlpha.GetTexture( maContext ) );
+ SAL_INFO( "vcl.opengl", "::drawAlphaBitmap" );
maContext.makeCurrent();
- DrawTextureWithMask( nTexture, nAlpha, rPosAry );
+ glViewport( 0, 0, GetWidth(), GetHeight() );
+ DrawTextureWithMask( nTexture, nAlpha, rBitmap.GetSize(), rPosAry );
return true;
}
diff --git a/vcl/opengl/maskedTextureFragmentShader.glsl b/vcl/opengl/maskedTextureFragmentShader.glsl
index 8f8148a..badf91e 100644
--- a/vcl/opengl/maskedTextureFragmentShader.glsl
+++ b/vcl/opengl/maskedTextureFragmentShader.glsl
@@ -13,10 +13,11 @@ uniform sampler2D sampler;
uniform sampler2D mask;
void main() {
- vec4 texel0, texel1;
- texel0 = texture2D(sampler, tex_coord);
- texel1 = texture2D(mask, tex_coord);
- gl_FragColor = texel0 * texel1.a;
+ vec4 texel0, texel1;
+ texel0 = texture2D(sampler, tex_coord);
+ texel1 = texture2D(mask, tex_coord);
+ gl_FragColor = texel0;
+ gl_FragColor.a = texel1.r;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit ac5e9539ec1af6d0540000ba8ec797e68019072e
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Sat Nov 8 23:00:16 2014 -0500
vcl: Fix some viewport issues when rendering with OpenGL
Change-Id: I99a76baeac07c1d9ec44ed492caa1d3416eb43ac
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index a9a6884..74f7252 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -498,6 +498,7 @@ void OpenGLSalGraphicsImpl::drawPixel( long nX, long nY )
if( mnLineColor != SALCOLOR_NONE )
{
maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
BeginSolid( mnLineColor );
DrawPoint( nX, nY );
EndSolid();
@@ -510,6 +511,7 @@ void OpenGLSalGraphicsImpl::drawPixel( long nX, long nY, SalColor nSalColor )
if( nSalColor != SALCOLOR_NONE )
{
maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
BeginSolid( nSalColor );
DrawPoint( nX, nY );
EndSolid();
@@ -522,6 +524,7 @@ void OpenGLSalGraphicsImpl::drawLine( long nX1, long nY1, long nX2, long nY2 )
if( mnLineColor != SALCOLOR_NONE )
{
maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
BeginSolid( mnLineColor );
DrawLine( nX1, nY1, nX2, nY2 );
EndSolid();
@@ -560,6 +563,7 @@ void OpenGLSalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pP
{
SAL_INFO( "vcl.opengl", "::drawPolyLine" );
maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
if( mnLineColor != SALCOLOR_NONE && nPoints > 1 )
{
@@ -587,6 +591,7 @@ void OpenGLSalGraphicsImpl::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPt
}
maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
if( mnFillColor != SALCOLOR_NONE )
{
@@ -610,6 +615,7 @@ void OpenGLSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32*
return;
maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
if( mnFillColor != SALCOLOR_NONE )
{
@@ -767,6 +773,7 @@ void OpenGLSalGraphicsImpl::drawMask(
SAL_INFO( "vcl.opengl", "::drawMask" );
maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
DrawMask( nTexture, nMaskColor, rPosAry );
}
@@ -788,6 +795,7 @@ SalColor OpenGLSalGraphicsImpl::getPixel( long nX, long nY )
char pixel[3];
maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
glReadPixels( nX, nY, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel);
return MAKE_SALCOLOR( pixel[0], pixel[1], pixel[2] );
}
@@ -803,6 +811,7 @@ void OpenGLSalGraphicsImpl::invert(
// * SAL_INVERT_TRACKFRAME (dash-line rectangle?)
maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
if( nFlags & SAL_INVERT_TRACKFRAME )
{
@@ -823,6 +832,7 @@ void OpenGLSalGraphicsImpl::invert(
void OpenGLSalGraphicsImpl::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags )
{
maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
if( nFlags & SAL_INVERT_TRACKFRAME )
{
commit 45b14cdf3d57f0e813aefd75fe3455a1536b310c
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Sat Nov 8 22:59:09 2014 -0500
vcl: Fix pixel drawing with OpenGL
Change-Id: If23255d2a78445d2c28ada00778c95e28cbd0683
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 27347a8..a9a6884 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -268,10 +268,10 @@ void OpenGLSalGraphicsImpl::EndInvert( void )
void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY )
{
- GLushort pPoint[2];
+ GLfloat pPoint[2];
- pPoint[0] = nX;
- pPoint[1] = GetHeight() - nY;
+ pPoint[0] = 2 * nX / GetWidth() - 1.0f;
+ pPoint[1] = 2 * (GetHeight() - nY) / GetHeight() - 1.0f;
glEnableVertexAttribArray( GL_ATTRIB_POS );
glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_UNSIGNED_SHORT, GL_FALSE, 0, pPoint );
commit 5a6c596f14fc760e68125b453c5772f82eef18d8
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Sat Nov 8 22:55:58 2014 -0500
vcl: Disable clipping in OpenGL for now because it's broken with VDev
Change-Id: Ia1e5de6674e642f428da58164001e8619cd99530
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 55b6a93..27347a8 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -60,25 +60,38 @@ bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
{
const basegfx::B2DPolyPolygon aClip( rClip.GetAsB2DPolyPolygon() );
- /*glEnable(GL_STENCIL_TEST);
+ SAL_INFO( "vcl.opengl", "::setClipRegion" );
+
+ /*maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
+
+ glEnable( GL_STENCIL_TEST );
glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
- glDepthMask( GL_FALSE );
glStencilMask( 0xFF );
glStencilFunc( GL_NEVER, 1, 0xFF );
glStencilOp( GL_REPLACE, GL_KEEP, GL_KEEP );
glClear( GL_STENCIL_BUFFER_BIT );
+ BeginSolid( SALCOLOR_NONE );
DrawPolyPolygon( aClip );
+ EndSolid();
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glDepthMask( GL_TRUE );
+ glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
glStencilMask( 0x00 );
- glStencilFunc(GL_EQUAL, 1, 0xFF);*/
+ glStencilFunc( GL_EQUAL, 1, 0xFF );*/
return true;
}
+// set the clip region to empty
+void OpenGLSalGraphicsImpl::ResetClipRegion()
+{
+ SAL_INFO( "vcl.opengl", "::ResetClipRegion" );
+ maContext.makeCurrent();
+ glDisable(GL_STENCIL_TEST);
+}
+
// get the depth of the device
sal_uInt16 OpenGLSalGraphicsImpl::GetBitCount() const
{
@@ -91,12 +104,6 @@ long OpenGLSalGraphicsImpl::GetGraphicsWidth() const
return GetWidth();
}
-// set the clip region to empty
-void OpenGLSalGraphicsImpl::ResetClipRegion()
-{
- glDisable(GL_STENCIL_TEST);
-}
-
// set the line color to transparent (= don't draw lines)
void OpenGLSalGraphicsImpl::SetLineColor()
{
commit f9d52bddefbee6d8bd35912c24049e4b13aedde3
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Sat Nov 8 22:55:06 2014 -0500
vcl: Add support for transparent polygon drawing with OpenGL
Change-Id: Iaa7cdcf4742d8148507c69c222bff417b9f9426c
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index b05a520..9368a10 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -61,6 +61,7 @@ protected:
bool CreateMaskProgram( void );
void BeginSolid( SalColor nColor, sal_uInt8 nTransparency );
+ void BeginSolid( SalColor nColor, double fTransparency );
void BeginSolid( SalColor nColor );
void EndSolid( void );
void BeginInvert( void );
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 9288260..55b6a93 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -40,6 +40,13 @@
((float) SALCOLOR_BLUE( nColor )) / 255, \
(100 - nTransparency) * (1.0 / 100) )
+#define glUniformColorf(nUniform, nColor, fTransparency) \
+ glUniform4f( nUniform, \
+ ((float) SALCOLOR_RED( nColor )) / 255, \
+ ((float) SALCOLOR_GREEN( nColor )) / 255, \
+ ((float) SALCOLOR_BLUE( nColor )) / 255, \
+ (1.0f - fTransparency) )
+
OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl()
{
}
@@ -202,18 +209,41 @@ void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor, sal_uInt8 nTransparency
return;
}
+ if( nTransparency > 0 )
+ {
+ glEnable( GL_BLEND );
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ }
glUseProgram( mnSolidProgram );
glUniformColor( mnColorUniform, nColor, nTransparency );
}
+void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor, double fTransparency )
+{
+ if( mnSolidProgram == 0 )
+ {
+ if( !CreateSolidProgram() )
+ return;
+ }
+
+ if( fTransparency > 0.0f )
+ {
+ glEnable( GL_BLEND );
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ }
+ glUseProgram( mnSolidProgram );
+ glUniformColorf( mnColorUniform, nColor, fTransparency );
+}
+
void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor )
{
- BeginSolid( nColor, 0 );
+ BeginSolid( nColor, 0.0f );
}
void OpenGLSalGraphicsImpl::EndSolid( void )
{
glUseProgram( 0 );
+ glDisable( GL_BLEND );
}
void OpenGLSalGraphicsImpl::BeginInvert( void )
@@ -592,9 +622,27 @@ void OpenGLSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32*
}
}
-bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double /*fTransparency*/ )
+bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPolygon, double fTransparency )
{
- return false;
+ SAL_INFO( "vcl.opengl", "::drawPolyPolygon trans " << fTransparency );
+ if( rPolyPolygon.count() <= 0 )
+ return true;
+
+ maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
+
+ if( mnFillColor != SALCOLOR_NONE )
+ {
+ BeginSolid( mnFillColor, fTransparency );
+ for( sal_uInt32 i = 0; i < rPolyPolygon.count(); i++ )
+ {
+ const ::basegfx::B2DPolyPolygon aOnePoly( rPolyPolygon.getB2DPolygon( i ) );
+ DrawPolyPolygon( aOnePoly );
+ }
+ EndSolid();
+ }
+
+ return true;
}
bool OpenGLSalGraphicsImpl::drawPolyLine(
@@ -843,6 +891,7 @@ bool OpenGLSalGraphicsImpl::drawAlphaRect(
long nWidth, long nHeight,
sal_uInt8 nTransparency )
{
+ SAL_INFO( "vcl.opengl", "::drawAlphaRect" );
if( mnFillColor != SALCOLOR_NONE && nTransparency < 100 )
{
BeginSolid( mnFillColor, nTransparency );
diff --git a/vcl/opengl/solidFragmentShader.glsl b/vcl/opengl/solidFragmentShader.glsl
index 94d0de0..af75336 100644
--- a/vcl/opengl/solidFragmentShader.glsl
+++ b/vcl/opengl/solidFragmentShader.glsl
@@ -11,7 +11,7 @@
uniform vec4 color;
void main() {
- gl_FragColor = color;
+ gl_FragColor = color;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/polygon.cxx b/vcl/source/outdev/polygon.cxx
index 39c2b68..03fa168 100644
--- a/vcl/source/outdev/polygon.cxx
+++ b/vcl/source/outdev/polygon.cxx
@@ -231,7 +231,7 @@ void OutputDevice::DrawPolygon( const Polygon& rPoly )
// Caution: This method is nearly the same as
// OutputDevice::DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly, double fTransparency),
-// so when changes are made here do not forget to make change sthere, too
+// so when changes are made here do not forget to make changes there, too
void OutputDevice::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rB2DPolyPoly )
{
commit 1e2bde00345eee9dded48ede7775f73edf8729af
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sun Nov 9 03:10:44 2014 +0100
one more case of these insane memory alloc/release cycles
Change-Id: I57bfbc46e77785a770226868a8750a74f380ddb4
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index 5f6477a..ccd914d 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -60,8 +60,7 @@ Bitmap::Bitmap( const Bitmap& rBitmap ) :
Bitmap::Bitmap( SalBitmap* pSalBitmap )
{
- mpImpBmp = new ImpBitmap();
- mpImpBmp->ImplSetSalBitmap( pSalBitmap );
+ mpImpBmp = new ImpBitmap(pSalBitmap);
maPrefMapMode = MapMode( MAP_PIXEL );
maPrefSize = mpImpBmp->ImplGetSize();
}
commit 07440431186d05c0e96017997cf0df6be2623645
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sun Nov 9 03:06:35 2014 +0100
prevent insane memory allocation
We release the memory in the next call again.
Change-Id: I9cd974f2c1b2381d0a895bea52a8654143862971
diff --git a/vcl/inc/impbmp.hxx b/vcl/inc/impbmp.hxx
index f6663c5..bbe8064 100644
--- a/vcl/inc/impbmp.hxx
+++ b/vcl/inc/impbmp.hxx
@@ -38,6 +38,13 @@ private:
public:
ImpBitmap();
+ /**
+ * takes ownership
+ * same as Sequence:
+ * pBmp = new ImpBitmap;
+ * pBmp->ImplSetSalBitmap(pBitmap);
+ */
+ ImpBitmap(SalBitmap* pBitmap);
~ImpBitmap();
void ImplSetSalBitmap( SalBitmap* pSalBitmap );
diff --git a/vcl/source/gdi/impbmp.cxx b/vcl/source/gdi/impbmp.cxx
index 1ee75d4..633cff2 100644
--- a/vcl/source/gdi/impbmp.cxx
+++ b/vcl/source/gdi/impbmp.cxx
@@ -31,6 +31,13 @@ ImpBitmap::ImpBitmap() :
{
}
+ImpBitmap::ImpBitmap(SalBitmap* pBitmap) :
+ mnRefCount ( 1 ),
+ mnChecksum ( 0 ),
+ mpSalBitmap ( pBitmap )
+{
+}
+
ImpBitmap::~ImpBitmap()
{
delete mpSalBitmap;
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index a191b8b..20e6367 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -457,8 +457,7 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const
if( pSalBmp )
{
- ImpBitmap* pImpBmp = new ImpBitmap;
- pImpBmp->ImplSetSalBitmap( pSalBmp );
+ ImpBitmap* pImpBmp = new ImpBitmap(pSalBmp);
aBmp.ImplSetImpBitmap( pImpBmp );
}
}
commit 6ef1ece2cdf5390d37877414f913a63ca994cb48
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Sun Nov 9 02:49:12 2014 +0100
don't delete texture before we were able to read it back
Change-Id: Id59983add682ea3f0e6e9e440b1700817bbc6867
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 40be728..564426c 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -167,7 +167,6 @@ void OpenGLSalBitmap::Destroy()
bool OpenGLSalBitmap::AllocateUserData()
{
- Destroy();
SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::AllocateUserData" );
if( mnWidth && mnHeight )
commit e94421aae7fa75e53159096f1143ccc00d90e3d8
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Sat Nov 8 20:13:28 2014 -0500
vcl: Fix getBitmap operation
Change-Id: Id78065081bbde97738afd0f4da09b502afe468f4
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 0736773..40be728 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -71,6 +71,7 @@ bool OpenGLSalBitmap::Create( OpenGLContext& rContext, long nX, long nY, long nW
maPalette = aEmptyPalette;
mpTexture.reset( new OpenGLTexture( nX, nY, nWidth, nHeight ) );
+ mbDirtyTexture = false;
return true;
}
@@ -107,6 +108,7 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount
if( isValidBitCount( nNewBitCount ) )
{
+ // TODO: lfrb: What about the pending operations?!
mnBits = nNewBitCount;
mnBytesPerRow = rSourceBitmap.mnBytesPerRow;
mnWidth = rSourceBitmap.mnWidth;
@@ -116,6 +118,7 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount
maPalette = rSourceBitmap.maPalette;
mpContext = rSourceBitmap.mpContext;
mpTexture = rSourceBitmap.mpTexture;
+ mbDirtyTexture = false;
maUserBuffer = rSourceBitmap.maUserBuffer;
// TODO Copy buffer data if the bitcount and palette are the same
commit c77257fc200f82b21fe61dd644ad655351116921
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Sat Nov 8 19:32:14 2014 -0500
basegfx: Solve crossovers even if there is only one polygon in the polypolygon
Change-Id: If4fcb8a2c6ac40a4d694522ce4ed020bcb4466b8
diff --git a/basegfx/source/polygon/b2dpolypolygoncutter.cxx b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
index aaad335..d9eea58 100644
--- a/basegfx/source/polygon/b2dpolypolygoncutter.cxx
+++ b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
@@ -688,7 +688,7 @@ namespace basegfx
B2DPolyPolygon solveCrossovers(const B2DPolyPolygon& rCandidate)
{
- if(rCandidate.count() > 1L)
+ if(rCandidate.count() > 0L)
{
solver aSolver(rCandidate);
return aSolver.getB2DPolyPolygon();
More information about the Libreoffice-commits
mailing list