summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2015-01-18 19:00:32 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-01-19 15:04:23 +0000
commit11771ca280430bd06071f6bf6976470392a604f1 (patch)
tree6912739aa26aebc8737911d611fd9fe7a1ee1071
parent9bd4b1c7eb400cd478907f75b66443787e674aca (diff)
fix opengl hairline special casing
Apparently polygons can consist of curves too. Change-Id: Ie35861e6d182e4bd4ac0523e78a90618c96f09a6 Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--vcl/inc/openglgdiimpl.hxx6
-rw-r--r--vcl/opengl/gdiimpl.cxx57
2 files changed, 56 insertions, 7 deletions
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 4b504693f685..ce49e96c2123 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -35,6 +35,11 @@
class SalFrame;
class SalVirtualDevice;
+namespace basegfx
+{
+class B2DTrapezoid;
+};
+
class VCL_PLUGIN_PUBLIC OpenGLSalGraphicsImpl : public SalGraphicsImpl
{
protected:
@@ -84,6 +89,7 @@ public:
void DrawEdgeAA( double nX1, double nY1, double nX2, double nY2 );
void DrawConvexPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry, bool blockAA = false );
void DrawConvexPolygon( const Polygon& rPolygon, bool blockAA = false );
+ void DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoid );
void DrawRect( long nX, long nY, long nWidth, long nHeight );
void DrawRect( const Rectangle& rRect );
void DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry );
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 80800bfaa4cc..ed2a948c3872 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -716,6 +716,47 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( const Polygon& rPolygon, bool blo
}
}
+void OpenGLSalGraphicsImpl::DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoid )
+{
+ const basegfx::B2DPolygon& rPolygon = trapezoid.getB2DPolygon();
+ sal_uInt16 nPoints = rPolygon.count();
+ std::vector<GLfloat> aVertices(nPoints * 2);
+ sal_uInt32 i, j;
+
+ for( i = 0, j = 0; i < nPoints; i++, j += 2 )
+ {
+ const basegfx::B2DPoint& rPt = rPolygon.getB2DPoint( i );
+ aVertices[j] = (2 * rPt.getX()) / GetWidth() - 1.0;
+ aVertices[j+1] = 1.0 - (2 * rPt.getY() / GetHeight());
+ }
+
+ mpProgram->SetVertices( &aVertices[0] );
+ glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
+
+ if( mrParent.getAntiAliasB2DDraw())
+ {
+ // Make the edges antialiased by drawing the edge lines again with AA.
+ // TODO: If transparent drawing is set up, drawing the lines themselves twice
+ // may be a problem, if that is a real problem, the polygon areas itself needs to be
+ // masked out for this or something.
+#ifdef DBG_UTIL
+ assert( mProgramIsSolidColor );
+#endif
+ SalColor lastSolidColor = mProgramSolidColor;
+ double lastSolidTransparency = mProgramSolidTransparency;
+ if( UseSolidAA( lastSolidColor, lastSolidTransparency ))
+ {
+ for( i = 0; i < nPoints; ++i )
+ {
+ const basegfx::B2DPoint& rPt1 = rPolygon.getB2DPoint( i );
+ const basegfx::B2DPoint& rPt2 = rPolygon.getB2DPoint(( i + 1 ) % nPoints );
+ DrawEdgeAA( rPt1.getX(), rPt1.getY(), rPt2.getX(), rPt2.getY());
+ }
+ UseSolid( lastSolidColor, lastSolidTransparency );
+ }
+ }
+}
+
void OpenGLSalGraphicsImpl::DrawRect( long nX, long nY, long nWidth, long nHeight )
{
long nX1( nX );
@@ -1243,17 +1284,19 @@ bool OpenGLSalGraphicsImpl::drawPolyLine(
if( bIsHairline )
{
// hairlines can be drawn in a simpler way (the linejoin and linecap styles can be ignored)
- PreDraw();
- if( UseSolidAA( mnLineColor, fTransparency ))
+ basegfx::B2DTrapezoidVector aB2DTrapVector;
+ basegfx::tools::createLineTrapezoidFromB2DPolygon( aB2DTrapVector, aPolygon, rLineWidth.getX() );
+ // draw tesselation result
+ if( aB2DTrapVector.size())
{
- for( sal_uInt32 j = 0; j < rPolygon.count() - 1; j++ )
+ PreDraw();
+ if( UseSolid( mnLineColor, fTransparency ))
{
- const ::basegfx::B2DPoint& rPt1( rPolygon.getB2DPoint( j ) );
- const ::basegfx::B2DPoint& rPt2( rPolygon.getB2DPoint(( j + 1 )) );
- DrawLineAA( rPt1.getX(), rPt1.getY(), rPt2.getX(), rPt2.getY());
+ for( size_t i = 0; i < aB2DTrapVector.size(); ++i )
+ DrawTrapezoid( aB2DTrapVector[ i ] );
}
+ PostDraw();
}
- PostDraw();
return true;
}