Kaydet (Commit) 498a40f3 authored tarafından Chris Sherlock's avatar Chris Sherlock

vcl: Refactor OutputDevice::TryDrawPolyLineDirect()

I've renamed TryDrawPolyLineDirect() to DrawPolyLineDirect() and also
renamed TryDrawPolyLineDirectNoAACheck() to drawPolyLineDirectNoAACheck().
However, at the same time I feel that there is no need to call on
drawPolyLineDirectNoAACheck in most instances, because DrawPolyLineDirect
does an AA check before it can continue anyway. There is one instance where
constantly checking the AA check is inefficient because it's in a loop, in
that case then we call directly on drawPolyLineDirectNoAACheck, but this is
the only case it is necessary.

Change-Id: Ie0320bfc45b5c0e1ac6ce35912da3e2897af9429
Reviewed-on: https://gerrit.libreoffice.org/12190Reviewed-by: 's avatarChris Sherlock <chris.sherlock79@gmail.com>
Tested-by: 's avatarChris Sherlock <chris.sherlock79@gmail.com>
üst cd44a728
...@@ -173,10 +173,7 @@ namespace drawinglayer ...@@ -173,10 +173,7 @@ namespace drawinglayer
aLocalPolygon.transform(maCurrentTransformation); aLocalPolygon.transform(maCurrentTransformation);
// try drawing; if it did not work, use standard fallback // try drawing; if it did not work, use standard fallback
if(mpOutputDevice->TryDrawPolyLineDirect( if(mpOutputDevice->DrawPolyLineDirect( aLocalPolygon, 0.0, fTransparency))
aLocalPolygon,
0.0,
fTransparency))
{ {
return true; return true;
} }
...@@ -258,7 +255,7 @@ namespace drawinglayer ...@@ -258,7 +255,7 @@ namespace drawinglayer
{ {
bHasPoints = true; bHasPoints = true;
if(mpOutputDevice->TryDrawPolyLineDirect( if(mpOutputDevice->DrawPolyLineDirect(
aSingle, aSingle,
fLineWidth, fLineWidth,
fTransparency, fTransparency,
......
...@@ -726,7 +726,7 @@ public: ...@@ -726,7 +726,7 @@ public:
void DrawPolyLine( const Polygon& rPoly, void DrawPolyLine( const Polygon& rPoly,
const LineInfo& rLineInfo ); const LineInfo& rLineInfo );
bool TryDrawPolyLineDirect( 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,
...@@ -742,7 +742,7 @@ private: ...@@ -742,7 +742,7 @@ private:
// #i101491# // #i101491#
// Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool. Contains no AA check. // Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool. Contains no AA check.
SAL_DLLPRIVATE bool TryDrawPolyLineDirectNoAACheck( SAL_DLLPRIVATE bool drawPolyLineDirectNoAACheck(
const basegfx::B2DPolygon& rB2DPolygon, const basegfx::B2DPolygon& rB2DPolygon,
double fLineWidth = 0.0, double fLineWidth = 0.0,
double fTransparency = 0.0, double fTransparency = 0.0,
......
...@@ -52,15 +52,8 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly ) ...@@ -52,15 +52,8 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly )
if ( mbInitLineColor ) if ( mbInitLineColor )
InitLineColor(); InitLineColor();
const bool bTryAA( (mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) &&
mpGraphics->supportsOperation(OutDevSupport_B2DDraw) &&
ROP_OVERPAINT == GetRasterOp() &&
IsLineColor());
// use b2dpolygon drawing if possible // use b2dpolygon drawing if possible
if(bTryAA) if ( DrawPolyLineDirect( rPoly.getB2DPolygon() ) )
{
if ( TryDrawPolyLineDirectNoAACheck( rPoly.getB2DPolygon() ) )
{ {
basegfx::B2DPolygon aB2DPolyLine(rPoly.getB2DPolygon()); basegfx::B2DPolygon aB2DPolyLine(rPoly.getB2DPolygon());
const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation(); const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation();
...@@ -80,7 +73,6 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly ) ...@@ -80,7 +73,6 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly )
return; return;
} }
} }
}
Polygon aPoly = ImplLogicToDevicePixel( rPoly ); Polygon aPoly = ImplLogicToDevicePixel( rPoly );
const SalPoint* pPtAry = (const SalPoint*)aPoly.GetConstPointAry(); const SalPoint* pPtAry = (const SalPoint*)aPoly.GetConstPointAry();
...@@ -162,17 +154,9 @@ void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon, ...@@ -162,17 +154,9 @@ void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon,
if( mbInitLineColor ) if( mbInitLineColor )
InitLineColor(); InitLineColor();
const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) &&
mpGraphics->supportsOperation(OutDevSupport_B2DDraw) &&
ROP_OVERPAINT == GetRasterOp() &&
IsLineColor());
// use b2dpolygon drawing if possible // use b2dpolygon drawing if possible
if(bTryAA) if ( DrawPolyLineDirect(rB2DPolygon, fLineWidth, 0.0, eLineJoin, eLineCap) )
{
if ( TryDrawPolyLineDirectNoAACheck(rB2DPolygon, fLineWidth, 0.0, eLineJoin, eLineCap) )
return; return;
}
// #i101491# // #i101491#
// no output yet; fallback to geometry decomposition and use filled polygon paint // no output yet; fallback to geometry decomposition and use filled polygon paint
...@@ -208,13 +192,18 @@ void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon, ...@@ -208,13 +192,18 @@ void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon,
SetFillColor(aOldFillColor); SetFillColor(aOldFillColor);
InitFillColor(); InitFillColor();
const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) &&
mpGraphics->supportsOperation(OutDevSupport_B2DDraw) &&
ROP_OVERPAINT == GetRasterOp() &&
IsLineColor());
if(bTryAA) if(bTryAA)
{ {
// when AA it is necessary to also paint the filled polygon's outline // when AA it is necessary to also paint the filled polygon's outline
// to avoid optical gaps // to avoid optical gaps
for(sal_uInt32 a(0); a < aAreaPolyPolygon.count(); a++) for(sal_uInt32 a(0); a < aAreaPolyPolygon.count(); a++)
{ {
TryDrawPolyLineDirectNoAACheck(aAreaPolyPolygon.getB2DPolygon(a)); drawPolyLineDirectNoAACheck(aAreaPolyPolygon.getB2DPolygon(a));
} }
} }
} }
...@@ -278,7 +267,7 @@ void OutputDevice::drawPolyLine(const Polygon& rPoly, const LineInfo& rLineInfo) ...@@ -278,7 +267,7 @@ void OutputDevice::drawPolyLine(const Polygon& rPoly, const LineInfo& rLineInfo)
mpAlphaVDev->DrawPolyLine( rPoly, rLineInfo ); mpAlphaVDev->DrawPolyLine( rPoly, rLineInfo );
} }
bool OutputDevice::TryDrawPolyLineDirectNoAACheck( const basegfx::B2DPolygon& rB2DPolygon, bool OutputDevice::drawPolyLineDirectNoAACheck( const basegfx::B2DPolygon& rB2DPolygon,
double fLineWidth, double fLineWidth,
double fTransparency, double fTransparency,
basegfx::B2DLineJoin eLineJoin, basegfx::B2DLineJoin eLineJoin,
...@@ -316,7 +305,7 @@ bool OutputDevice::TryDrawPolyLineDirectNoAACheck( const basegfx::B2DPolygon& rB ...@@ -316,7 +305,7 @@ bool OutputDevice::TryDrawPolyLineDirectNoAACheck( const basegfx::B2DPolygon& rB
this); this);
} }
bool OutputDevice::TryDrawPolyLineDirect( 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,
...@@ -346,7 +335,7 @@ bool OutputDevice::TryDrawPolyLineDirect( const basegfx::B2DPolygon& rB2DPolygon ...@@ -346,7 +335,7 @@ bool OutputDevice::TryDrawPolyLineDirect( const basegfx::B2DPolygon& rB2DPolygon
if(bTryAA) if(bTryAA)
{ {
if(TryDrawPolyLineDirectNoAACheck(rB2DPolygon, fLineWidth, fTransparency, eLineJoin, eLineCap)) if(drawPolyLineDirectNoAACheck(rB2DPolygon, fLineWidth, fTransparency, eLineJoin, eLineCap))
{ {
// 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