summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-04-27 11:44:48 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-04-29 16:05:53 +0200
commitb71d9a6d15cfb8a50afdea5ac064f40d84c561f8 (patch)
tree3a9bd3205754d28f411257e0207295a781451d6d /vcl
parent5d4e450a7d64d3dc1caf34544dbfa35f4641d5c3 (diff)
do not apply line dashing in drawinglayer (tdf#136957)
basegfx::utils::applyLineDashing() is not as good as the actual VCL backend dashing, and there are some rounding errors because of all the canvas transformation matrices or whatever, which leads to the drawing problem. So use LineInfo to carry the dashing information. As a part of this change, also make LineInfo use doubles instead of ints. The use of transformation matrices means that the values may be fractional and less than one. Change-Id: Ia5ac7d266cab344b7137052c81fbd96c1ce28003 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114710 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/filter/idxf/dxfvec.cxx6
-rw-r--r--vcl/source/gdi/lineinfo.cxx55
-rw-r--r--vcl/source/outdev/polyline.cxx8
3 files changed, 40 insertions, 29 deletions
diff --git a/vcl/source/filter/idxf/dxfvec.cxx b/vcl/source/filter/idxf/dxfvec.cxx
index fb1ff647d591..58b4d1f6e200 100644
--- a/vcl/source/filter/idxf/dxfvec.cxx
+++ b/vcl/source/filter/idxf/dxfvec.cxx
@@ -207,10 +207,10 @@ LineInfo DXFTransform::Transform(const DXFLineInfo& aDXFLineInfo) const
aLineInfo.SetStyle( aDXFLineInfo.eStyle );
aLineInfo.SetWidth( 0 );
aLineInfo.SetDashCount( static_cast< sal_uInt16 >( aDXFLineInfo.nDashCount ) );
- aLineInfo.SetDashLen( static_cast<sal_Int32>(aDXFLineInfo.fDashLen * scale + 0.5) );
+ aLineInfo.SetDashLen( aDXFLineInfo.fDashLen * scale );
aLineInfo.SetDotCount( static_cast< sal_uInt16 >( aDXFLineInfo.nDotCount ) );
- aLineInfo.SetDotLen( static_cast<sal_Int32>(aDXFLineInfo.fDotLen * scale + 0.5) );
- aLineInfo.SetDistance( static_cast<sal_Int32>(aDXFLineInfo.fDistance * scale + 0.5) );
+ aLineInfo.SetDotLen( aDXFLineInfo.fDotLen * scale );
+ aLineInfo.SetDistance( aDXFLineInfo.fDistance * scale );
if ( aLineInfo.GetDashCount() > 0 && aLineInfo.GetDashLen() == 0 )
aLineInfo.SetDashLen(1);
diff --git a/vcl/source/gdi/lineinfo.cxx b/vcl/source/gdi/lineinfo.cxx
index 94c1d1b05569..345eeb21a678 100644
--- a/vcl/source/gdi/lineinfo.cxx
+++ b/vcl/source/gdi/lineinfo.cxx
@@ -53,7 +53,7 @@ inline bool ImplLineInfo::operator==( const ImplLineInfo& rB ) const
}
-LineInfo::LineInfo( LineStyle eStyle, sal_Int32 nWidth ) : mpImplLineInfo()
+LineInfo::LineInfo( LineStyle eStyle, double nWidth ) : mpImplLineInfo()
{
mpImplLineInfo->meStyle = eStyle;
mpImplLineInfo->mnWidth = nWidth;
@@ -79,7 +79,7 @@ void LineInfo::SetStyle( LineStyle eStyle )
mpImplLineInfo->meStyle = eStyle;
}
-void LineInfo::SetWidth( sal_Int32 nWidth )
+void LineInfo::SetWidth( double nWidth )
{
mpImplLineInfo->mnWidth = nWidth;
}
@@ -89,7 +89,7 @@ void LineInfo::SetDashCount( sal_uInt16 nDashCount )
mpImplLineInfo->mnDashCount = nDashCount;
}
-void LineInfo::SetDashLen( sal_Int32 nDashLen )
+void LineInfo::SetDashLen( double nDashLen )
{
mpImplLineInfo->mnDashLen = nDashLen;
}
@@ -99,31 +99,24 @@ void LineInfo::SetDotCount( sal_uInt16 nDotCount )
mpImplLineInfo->mnDotCount = nDotCount;
}
-void LineInfo::SetDotLen( sal_Int32 nDotLen )
+void LineInfo::SetDotLen( double nDotLen )
{
mpImplLineInfo->mnDotLen = nDotLen;
}
-void LineInfo::SetDistance( sal_Int32 nDistance )
+void LineInfo::SetDistance( double nDistance )
{
mpImplLineInfo->mnDistance = nDistance;
}
void LineInfo::SetLineJoin(basegfx::B2DLineJoin eLineJoin)
{
-
- if(eLineJoin != mpImplLineInfo->meLineJoin)
- {
- mpImplLineInfo->meLineJoin = eLineJoin;
- }
+ mpImplLineInfo->meLineJoin = eLineJoin;
}
void LineInfo::SetLineCap(css::drawing::LineCap eLineCap)
{
- if(eLineCap != mpImplLineInfo->meLineCap)
- {
- mpImplLineInfo->meLineCap = eLineCap;
- }
+ mpImplLineInfo->meLineCap = eLineCap;
}
bool LineInfo::IsDefault() const
@@ -139,7 +132,8 @@ SvStream& ReadLineInfo( SvStream& rIStm, LineInfo& rLineInfo )
sal_uInt16 nTmp16(0);
sal_Int32 nTmp32(0);
- rIStm.ReadUInt16( nTmp16 ); rLineInfo.mpImplLineInfo->meStyle = static_cast<LineStyle>(nTmp16);
+ rIStm.ReadUInt16( nTmp16 );
+ rLineInfo.mpImplLineInfo->meStyle = static_cast<LineStyle>(nTmp16);
rIStm.ReadInt32( nTmp32 );
rLineInfo.mpImplLineInfo->mnWidth = nTmp32;
@@ -157,13 +151,24 @@ SvStream& ReadLineInfo( SvStream& rIStm, LineInfo& rLineInfo )
if( aCompat.GetVersion() >= 3 )
{
// version 3
- rIStm.ReadUInt16( nTmp16 ); rLineInfo.mpImplLineInfo->meLineJoin = static_cast<basegfx::B2DLineJoin>(nTmp16);
+ rIStm.ReadUInt16( nTmp16 );
+ rLineInfo.mpImplLineInfo->meLineJoin = static_cast<basegfx::B2DLineJoin>(nTmp16);
}
if( aCompat.GetVersion() >= 4 )
{
// version 4
- rIStm.ReadUInt16( nTmp16 ); rLineInfo.mpImplLineInfo->meLineCap = static_cast<css::drawing::LineCap>(nTmp16);
+ rIStm.ReadUInt16( nTmp16 );
+ rLineInfo.mpImplLineInfo->meLineCap = static_cast<css::drawing::LineCap>(nTmp16);
+ }
+
+ if( aCompat.GetVersion() >= 5 )
+ {
+ // version 5
+ rIStm.ReadDouble( rLineInfo.mpImplLineInfo->mnWidth );
+ rIStm.ReadDouble( rLineInfo.mpImplLineInfo->mnDashLen );
+ rIStm.ReadDouble( rLineInfo.mpImplLineInfo->mnDotLen );
+ rIStm.ReadDouble( rLineInfo.mpImplLineInfo->mnDistance );
}
return rIStm;
@@ -171,18 +176,18 @@ SvStream& ReadLineInfo( SvStream& rIStm, LineInfo& rLineInfo )
SvStream& WriteLineInfo( SvStream& rOStm, const LineInfo& rLineInfo )
{
- VersionCompatWrite aCompat( rOStm, 4 );
+ VersionCompatWrite aCompat( rOStm, 5 );
// version 1
rOStm.WriteUInt16( static_cast<sal_uInt16>(rLineInfo.mpImplLineInfo->meStyle) )
- .WriteInt32( rLineInfo.mpImplLineInfo->mnWidth );
+ .WriteInt32( basegfx::fround( rLineInfo.mpImplLineInfo->mnWidth ));
// since version2
rOStm.WriteUInt16( rLineInfo.mpImplLineInfo->mnDashCount )
- .WriteInt32( rLineInfo.mpImplLineInfo->mnDashLen );
+ .WriteInt32( basegfx::fround( rLineInfo.mpImplLineInfo->mnDashLen ));
rOStm.WriteUInt16( rLineInfo.mpImplLineInfo->mnDotCount )
- .WriteInt32( rLineInfo.mpImplLineInfo->mnDotLen );
- rOStm.WriteInt32( rLineInfo.mpImplLineInfo->mnDistance );
+ .WriteInt32( basegfx::fround( rLineInfo.mpImplLineInfo->mnDotLen ));
+ rOStm.WriteInt32( basegfx::fround( rLineInfo.mpImplLineInfo->mnDistance ));
// since version3
rOStm.WriteUInt16( static_cast<sal_uInt16>(rLineInfo.mpImplLineInfo->meLineJoin) );
@@ -190,6 +195,12 @@ SvStream& WriteLineInfo( SvStream& rOStm, const LineInfo& rLineInfo )
// since version4
rOStm.WriteUInt16( static_cast<sal_uInt16>(rLineInfo.mpImplLineInfo->meLineCap) );
+ // since version5
+ rOStm.WriteDouble( rLineInfo.mpImplLineInfo->mnWidth );
+ rOStm.WriteDouble( rLineInfo.mpImplLineInfo->mnDashLen );
+ rOStm.WriteDouble( rLineInfo.mpImplLineInfo->mnDotLen );
+ rOStm.WriteDouble( rLineInfo.mpImplLineInfo->mnDistance );
+
return rOStm;
}
diff --git a/vcl/source/outdev/polyline.cxx b/vcl/source/outdev/polyline.cxx
index 5da5ccdd8033..e3ec909c733b 100644
--- a/vcl/source/outdev/polyline.cxx
+++ b/vcl/source/outdev/polyline.cxx
@@ -122,7 +122,7 @@ void OutputDevice::DrawPolyLine( const tools::Polygon& rPoly, const LineInfo& rL
{
DrawPolyLine(
rPoly.getB2DPolygon(),
- static_cast< double >(rLineInfo.GetWidth()),
+ rLineInfo.GetWidth(),
rLineInfo.GetLineJoin(),
rLineInfo.GetLineCap(),
basegfx::deg2rad(15.0) /* default fMiterMinimumAngle, value not available in LineInfo */);
@@ -147,7 +147,7 @@ void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon,
{
LineInfo aLineInfo;
if( fLineWidth != 0.0 )
- aLineInfo.SetWidth( static_cast<tools::Long>(fLineWidth+0.5) );
+ aLineInfo.SetWidth( fLineWidth );
const tools::Polygon aToolsPolygon( rB2DPolygon );
mpMetaFile->AddAction( new MetaPolyLineAction( aToolsPolygon, aLineInfo ) );
@@ -235,7 +235,7 @@ void OutputDevice::DrawPolyLine( const basegfx::B2DPolygon& rB2DPolygon,
const tools::Polygon aToolsPolygon( rB2DPolygon );
LineInfo aLineInfo;
if( fLineWidth != 0.0 )
- aLineInfo.SetWidth( static_cast<tools::Long>(fLineWidth+0.5) );
+ aLineInfo.SetWidth( fLineWidth );
drawPolyLine( aToolsPolygon, aLineInfo );
}
@@ -310,7 +310,7 @@ bool OutputDevice::DrawPolyLineDirect(
{
LineInfo aLineInfo;
if( fLineWidth != 0.0 )
- aLineInfo.SetWidth( static_cast<tools::Long>(fLineWidth+0.5) );
+ aLineInfo.SetWidth( fLineWidth );
// Transport known information, might be needed
aLineInfo.SetLineJoin(eLineJoin);
aLineInfo.SetLineCap(eLineCap);