Kaydet (Commit) 886eadd0 authored tarafından Chris Sherlock's avatar Chris Sherlock

vcl: merge DrawPolyLineDirect() and drawPolyLineDirectNoAACheck()

I've merged these two functions, I just added a new function parameter to switch on and off
the AA check, this function parameter defaults to false so DrawPolyLineDirect needs to do the
AA check each time. If bBypassAACheck is set to true, then we automatically enable AA.

Change-Id: Id2d9b2036a41716590f7b87f658f5bb210964392
Reviewed-on: https://gerrit.libreoffice.org/12191Reviewed-by: 's avatarChris Sherlock <chris.sherlock79@gmail.com>
Tested-by: 's avatarChris Sherlock <chris.sherlock79@gmail.com>
üst c5245175
...@@ -726,12 +726,15 @@ public: ...@@ -726,12 +726,15 @@ public:
void DrawPolyLine( const Polygon& rPoly, void DrawPolyLine( const Polygon& rPoly,
const LineInfo& rLineInfo ); const LineInfo& rLineInfo );
// #i101491#
// Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool.
bool DrawPolyLineDirect( bool DrawPolyLineDirect(
const basegfx::B2DPolygon& rB2DPolygon, const basegfx::B2DPolygon& rB2DPolygon,
double fLineWidth = 0.0, double fLineWidth = 0.0,
double fTransparency = 0.0, double fTransparency = 0.0,
basegfx::B2DLineJoin eLineJoin = basegfx::B2DLINEJOIN_NONE, basegfx::B2DLineJoin eLineJoin = basegfx::B2DLINEJOIN_NONE,
css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT); css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT,
bool bBypassAACheck = false );
private: private:
// #i101491# // #i101491#
...@@ -739,15 +742,6 @@ private: ...@@ -739,15 +742,6 @@ private:
// switched on. Advantage is that line geometry is only temporarily used for paint // switched on. Advantage is that line geometry is only temporarily used for paint
SAL_DLLPRIVATE void drawPolyLine(const Polygon& rPoly, const LineInfo& rLineInfo); SAL_DLLPRIVATE void drawPolyLine(const Polygon& rPoly, const LineInfo& rLineInfo);
// #i101491#
// Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool. Contains no AA check.
SAL_DLLPRIVATE bool drawPolyLineDirectNoAACheck(
const basegfx::B2DPolygon& rB2DPolygon,
double fLineWidth = 0.0,
double fTransparency = 0.0,
basegfx::B2DLineJoin eLineJoin = basegfx::B2DLINEJOIN_NONE,
css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT);
///@} ///@}
......
...@@ -197,14 +197,11 @@ void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon, ...@@ -197,14 +197,11 @@ void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon,
ROP_OVERPAINT == GetRasterOp() && ROP_OVERPAINT == GetRasterOp() &&
IsLineColor()); IsLineColor());
if(bTryAA) // when AA it is necessary to also paint the filled polygon's outline
// to avoid optical gaps
for(sal_uInt32 a(0); a < aAreaPolyPolygon.count(); a++)
{ {
// when AA it is necessary to also paint the filled polygon's outline DrawPolyLineDirect( aAreaPolyPolygon.getB2DPolygon(a), 0.0, 0.0, basegfx::B2DLINEJOIN_NONE, css::drawing::LineCap_BUTT, bTryAA );
// to avoid optical gaps
for(sal_uInt32 a(0); a < aAreaPolyPolygon.count(); a++)
{
drawPolyLineDirectNoAACheck(aAreaPolyPolygon.getB2DPolygon(a));
}
} }
} }
else else
...@@ -267,49 +264,12 @@ void OutputDevice::drawPolyLine(const Polygon& rPoly, const LineInfo& rLineInfo) ...@@ -267,49 +264,12 @@ void OutputDevice::drawPolyLine(const Polygon& rPoly, const LineInfo& rLineInfo)
mpAlphaVDev->DrawPolyLine( rPoly, rLineInfo ); mpAlphaVDev->DrawPolyLine( rPoly, rLineInfo );
} }
bool OutputDevice::drawPolyLineDirectNoAACheck( const basegfx::B2DPolygon& rB2DPolygon,
double fLineWidth,
double fTransparency,
basegfx::B2DLineJoin eLineJoin,
css::drawing::LineCap eLineCap)
{
const basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation();
basegfx::B2DVector aB2DLineWidth(1.0, 1.0);
// transform the line width if used
if( fLineWidth != 0.0 )
{
aB2DLineWidth = aTransform * ::basegfx::B2DVector( fLineWidth, 0.0 );
}
// transform the polygon
basegfx::B2DPolygon aB2DPolygon(rB2DPolygon);
aB2DPolygon.transform(aTransform);
if((mnAntialiasing & ANTIALIASING_PIXELSNAPHAIRLINE) &&
aB2DPolygon.count() < 1000)
{
// #i98289#, #i101491#
// better to remove doubles on device coordinates. Also assume from a given amount
// of points that the single edges are not long enough to smooth
aB2DPolygon.removeDoublePoints();
aB2DPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolygon);
}
// draw the polyline
return mpGraphics->DrawPolyLine( aB2DPolygon,
fTransparency,
aB2DLineWidth,
eLineJoin,
eLineCap,
this);
}
bool OutputDevice::DrawPolyLineDirect( const basegfx::B2DPolygon& rB2DPolygon, bool OutputDevice::DrawPolyLineDirect( const basegfx::B2DPolygon& rB2DPolygon,
double fLineWidth, double fLineWidth,
double fTransparency, double fTransparency,
basegfx::B2DLineJoin eLineJoin, basegfx::B2DLineJoin eLineJoin,
css::drawing::LineCap eLineCap) css::drawing::LineCap eLineCap,
bool bBypassAACheck )
{ {
// AW: Do NOT paint empty PolyPolygons // AW: Do NOT paint empty PolyPolygons
if(!rB2DPolygon.count()) if(!rB2DPolygon.count())
...@@ -328,14 +288,46 @@ bool OutputDevice::DrawPolyLineDirect( const basegfx::B2DPolygon& rB2DPolygon, ...@@ -328,14 +288,46 @@ bool OutputDevice::DrawPolyLineDirect( const basegfx::B2DPolygon& rB2DPolygon,
if( mbInitLineColor ) if( mbInitLineColor )
InitLineColor(); InitLineColor();
const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && const bool bTryAA( bBypassAACheck ||
((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) &&
mpGraphics->supportsOperation(OutDevSupport_B2DDraw) && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) &&
ROP_OVERPAINT == GetRasterOp() && ROP_OVERPAINT == GetRasterOp() &&
IsLineColor()); IsLineColor()));
if(bTryAA) if(bTryAA)
{ {
if(drawPolyLineDirectNoAACheck(rB2DPolygon, fLineWidth, fTransparency, eLineJoin, eLineCap)) const basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation();
basegfx::B2DVector aB2DLineWidth(1.0, 1.0);
// transform the line width if used
if( fLineWidth != 0.0 )
{
aB2DLineWidth = aTransform * ::basegfx::B2DVector( fLineWidth, 0.0 );
}
// transform the polygon
basegfx::B2DPolygon aB2DPolygon(rB2DPolygon);
aB2DPolygon.transform(aTransform);
if((mnAntialiasing & ANTIALIASING_PIXELSNAPHAIRLINE) &&
aB2DPolygon.count() < 1000)
{
// #i98289#, #i101491#
// better to remove doubles on device coordinates. Also assume from a given amount
// of points that the single edges are not long enough to smooth
aB2DPolygon.removeDoublePoints();
aB2DPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolygon);
}
// draw the polyline
bool bDrawSuccess = mpGraphics->DrawPolyLine( aB2DPolygon,
fTransparency,
aB2DLineWidth,
eLineJoin,
eLineCap,
this );
if( bDrawSuccess )
{ {
// worked, add metafile action (if recorded) and return true // worked, add metafile action (if recorded) and return true
if( mpMetaFile ) if( mpMetaFile )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment