diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2022-04-22 16:46:39 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-04-25 11:13:56 +0200 |
commit | c6fab8b3c25de948372f13e1faf59f71724bff6b (patch) | |
tree | 042e950bafae4cf4fed56e166db9b22fb22d7f26 /drawinglayer | |
parent | 4e833598f83aedec6aec46be8acf178e6b051638 (diff) |
tdf#55058 tdf#143875 EMF+ Don't change line weight while rotating
Previously when TranfromationMatrix was used with rotation,
the line weight and dashed line shapes were changed.
In worst case if angle was larger than 90 degrees,
the lines just disappear.
This patch fixes that. The line looks exactly after rotation
(with TranfromationMatrix).
The tests were updated (added some additional rotation),
to prove that now it is working correctly.
Change-Id: Ic2382fa8d1b711a6bf06c94b2d0b9da9e7d396f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133329
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
(cherry picked from commit abe3a06c45c0803a5c8bcf16e0e586fd72781c93)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133285
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/tools/emfphelperdata.cxx | 10 | ||||
-rw-r--r-- | drawinglayer/source/tools/emfphelperdata.hxx | 5 | ||||
-rw-r--r-- | drawinglayer/source/tools/primitive2dxmldump.cxx | 2 |
3 files changed, 13 insertions, 4 deletions
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 79ced761e8a2..7a64f8ad4dac 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -442,6 +442,10 @@ namespace emfplushelper maMapTransform *= basegfx::utils::createScaleTranslateB2DHomMatrix(100.0 * mnMmX / mnPixX, 100.0 * mnMmY / mnPixY, double(-mnFrameLeft), double(-mnFrameTop)); maMapTransform *= maBaseTransform; + + // Used only for performance optimization, to do not calculate it every line draw + mdExtractedXScale = std::hypot(maMapTransform.a(), maMapTransform.b()); + mdExtractedYScale = std::hypot(maMapTransform.c(), maMapTransform.d()); } ::basegfx::B2DPoint EmfPlusHelperData::Map(double ix, double iy) const @@ -517,7 +521,7 @@ namespace emfplushelper SAL_WARN_IF(pen->startCap != pen->endCap, "drawinglayer.emf", "emf+ pen uses different start and end cap"); } - const double transformedPenWidth = maMapTransform.get(0, 0) * pen->penWidth; + const double transformedPenWidth = mdExtractedYScale * pen->penWidth; drawinglayer::attribute::LineAttribute lineAttribute(pen->GetColor().getBColor(), transformedPenWidth, pen->GetLineJoinType(), @@ -529,7 +533,7 @@ namespace emfplushelper new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D( polygon, lineAttribute, - pen->GetStrokeAttribute(maMapTransform.get(1, 1)))); + pen->GetStrokeAttribute(mdExtractedXScale))); } else { @@ -537,7 +541,7 @@ namespace emfplushelper new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D( polygon, lineAttribute, - pen->GetStrokeAttribute(maMapTransform.get(1, 1)))); + pen->GetStrokeAttribute(mdExtractedXScale))); mrTargetHolders.Current().append( new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( diff --git a/drawinglayer/source/tools/emfphelperdata.hxx b/drawinglayer/source/tools/emfphelperdata.hxx index cf3474b5b1a7..3d8244b6f208 100644 --- a/drawinglayer/source/tools/emfphelperdata.hxx +++ b/drawinglayer/source/tools/emfphelperdata.hxx @@ -210,6 +210,11 @@ namespace emfplushelper GraphicStateMap mGSStack; GraphicStateMap mGSContainerStack; + /* Performance optimizators */ + /* Extracted Scale values from Transformation Matrix */ + double mdExtractedXScale; + double mdExtractedYScale; + /// data holders wmfemfhelper::TargetHolders& mrTargetHolders; wmfemfhelper::PropertyHolders& mrPropertyHolders; diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index a1fddf900543..27a8adf1b5e3 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -143,7 +143,7 @@ void writeStrokeAttribute(::tools::XmlWriter& rWriter, OUString sDotDash; for (double fDotDash : rStrokeAttribute.getDotDashArray()) { - sDotDash += OUString::number(round(100.0 * fDotDash)) + " "; + sDotDash += OUString::number(lround(fDotDash)) + " "; } rWriter.attribute("dotDashArray", sDotDash); rWriter.attribute("fullDotDashLength", rStrokeAttribute.getFullDotDashLen()); |