From f9395a123e8c85134bdd6e471bc93b2745e22a9d Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 29 Nov 2022 20:31:27 +0000 Subject: tdf#152094 retain more accuracy from RefDevMode::MSO1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit do it like this to avoid adding another mapmode and to keep things "the same" as much as possible Change-Id: I1965aa545646f2d27b950d6335b2f608c3e4e04b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143475 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- canvas/source/cairo/cairo_textlayout.cxx | 19 ++++++++--------- canvas/source/cairo/cairo_textlayout.hxx | 2 +- canvas/source/directx/dx_textlayout_drawhelper.cxx | 6 ++++-- canvas/source/opengl/ogl_canvashelper.cxx | 6 ++++-- canvas/source/vcl/textlayout.cxx | 24 +++++++++------------- canvas/source/vcl/textlayout.hxx | 3 +-- 6 files changed, 28 insertions(+), 32 deletions(-) (limited to 'canvas/source') diff --git a/canvas/source/cairo/cairo_textlayout.cxx b/canvas/source/cairo/cairo_textlayout.cxx index ebfcfe6dc11a..1a6f0143a60a 100644 --- a/canvas/source/cairo/cairo_textlayout.cxx +++ b/canvas/source/cairo/cairo_textlayout.cxx @@ -29,10 +29,10 @@ #include #include #include +#include #include #include - #include "cairo_textlayout.hxx" using namespace ::cairo; @@ -265,8 +265,7 @@ namespace cairocanvas if (maLogicalAdvancements.hasElements()) { - std::vector aOffsets(maLogicalAdvancements.getLength()); - setupTextOffsets( aOffsets.data(), maLogicalAdvancements, viewState, renderState ); + KernArray aOffsets(setupTextOffsets(maLogicalAdvancements, viewState, renderState)); rOutDev.DrawTextArray( rOutpos, maText.Text, aOffsets, {}, ::canvas::tools::numeric_cast(maText.StartPosition), @@ -312,14 +311,11 @@ namespace cairocanvas }; } - void TextLayout::setupTextOffsets( sal_Int32* outputOffsets, + KernArray TextLayout::setupTextOffsets( const uno::Sequence< double >& inputOffsets, const rendering::ViewState& viewState, const rendering::RenderState& renderState ) const { - ENSURE_OR_THROW( outputOffsets!=nullptr, - "TextLayout::setupTextOffsets offsets NULL" ); - ::basegfx::B2DHomMatrix aMatrix; ::canvas::tools::mergeViewAndRenderTransform(aMatrix, @@ -327,10 +323,11 @@ namespace cairocanvas renderState); // fill integer offsets - std::transform( inputOffsets.begin(), - inputOffsets.end(), - outputOffsets, - OffsetTransformer( aMatrix ) ); + KernArray outputOffsets; + OffsetTransformer aTransform(aMatrix); + std::for_each(inputOffsets.begin(), inputOffsets.end(), + [&outputOffsets, &aTransform](double n) {outputOffsets.push_back(aTransform(n)); } ); + return outputOffsets; } OUString SAL_CALL TextLayout::getImplementationName() diff --git a/canvas/source/cairo/cairo_textlayout.hxx b/canvas/source/cairo/cairo_textlayout.hxx index fb14e620c518..bec692e75707 100644 --- a/canvas/source/cairo/cairo_textlayout.hxx +++ b/canvas/source/cairo/cairo_textlayout.hxx @@ -85,7 +85,7 @@ namespace cairocanvas const css::rendering::ViewState& viewState, const css::rendering::RenderState& renderState ) const; - void setupTextOffsets( sal_Int32* outputOffsets, + KernArray setupTextOffsets( const css::uno::Sequence< double >& inputOffsets, const css::rendering::ViewState& viewState, const css::rendering::RenderState& renderState ) const; diff --git a/canvas/source/directx/dx_textlayout_drawhelper.cxx b/canvas/source/directx/dx_textlayout_drawhelper.cxx index 0ce689241b7e..9a8771428d93 100644 --- a/canvas/source/directx/dx_textlayout_drawhelper.cxx +++ b/canvas/source/directx/dx_textlayout_drawhelper.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -207,9 +208,10 @@ namespace dxcanvas { // create the DXArray const sal_Int32 nLen( rLogicalAdvancements.getLength() ); - std::vector DXArray( nLen ); + KernArray DXArray; + DXArray.reserve(nLen); for( sal_Int32 i=0; iDrawTextArray( aEmptyPoint, diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx index 257bb21b3218..1b84879b005c 100644 --- a/canvas/source/opengl/ogl_canvashelper.cxx +++ b/canvas/source/opengl/ogl_canvashelper.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -729,9 +730,10 @@ namespace oglcanvas { // create the DXArray const sal_Int32 nLen( aLogicalAdvancements.getLength() ); - std::vector aDXArray(nLen); + KernArray aDXArray; + aDXArray.resize(nLen); for( sal_Int32 i=0; iGetTextOutlines(rAct.maPolyPolys, diff --git a/canvas/source/vcl/textlayout.cxx b/canvas/source/vcl/textlayout.cxx index f350a38cd4eb..689720e4570a 100644 --- a/canvas/source/vcl/textlayout.cxx +++ b/canvas/source/vcl/textlayout.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -117,8 +118,7 @@ namespace vclcanvas uno::Sequence(4), rendering::CompositeOperation::SOURCE); - std::vector aOffsets(maLogicalAdvancements.getLength()); - setupTextOffsets(aOffsets.data(), maLogicalAdvancements, aViewState, aRenderState); + KernArray aOffsets(setupTextOffsets(maLogicalAdvancements, aViewState, aRenderState)); std::vector< uno::Reference< rendering::XPolyPolygon2D> > aOutlineSequence; ::basegfx::B2DPolyPolygonVector aOutlines; @@ -165,8 +165,7 @@ namespace vclcanvas uno::Sequence(4), rendering::CompositeOperation::SOURCE); - std::unique_ptr< sal_Int32 []> aOffsets(new sal_Int32[maLogicalAdvancements.getLength()]); - setupTextOffsets(aOffsets.get(), maLogicalAdvancements, aViewState, aRenderState); + KernArray aOffsets(setupTextOffsets(maLogicalAdvancements, aViewState, aRenderState)); std::vector< ::tools::Rectangle > aMetricVector; uno::Sequence aBoundingBoxes; @@ -335,8 +334,7 @@ namespace vclcanvas if( maLogicalAdvancements.hasElements() ) { // TODO(P2): cache that - std::vector aOffsets(maLogicalAdvancements.getLength()); - setupTextOffsets( aOffsets.data(), maLogicalAdvancements, viewState, renderState ); + KernArray aOffsets(setupTextOffsets(maLogicalAdvancements, viewState, renderState)); // TODO(F3): ensure correct length and termination for DX // array (last entry _must_ contain the overall width) @@ -389,14 +387,11 @@ namespace vclcanvas }; } - void TextLayout::setupTextOffsets( sal_Int32* outputOffsets, + KernArray TextLayout::setupTextOffsets( const uno::Sequence< double >& inputOffsets, const rendering::ViewState& viewState, const rendering::RenderState& renderState ) const { - ENSURE_OR_THROW( outputOffsets!=nullptr, - "TextLayout::setupTextOffsets offsets NULL" ); - ::basegfx::B2DHomMatrix aMatrix; ::canvas::tools::mergeViewAndRenderTransform(aMatrix, @@ -404,10 +399,11 @@ namespace vclcanvas renderState); // fill integer offsets - std::transform( inputOffsets.begin(), - inputOffsets.end(), - outputOffsets, - OffsetTransformer( aMatrix ) ); + KernArray outputOffsets; + OffsetTransformer aTransform(aMatrix); + std::for_each(inputOffsets.begin(), inputOffsets.end(), + [&outputOffsets, &aTransform](double n) {outputOffsets.push_back(aTransform(n)); } ); + return outputOffsets; } OUString SAL_CALL TextLayout::getImplementationName() diff --git a/canvas/source/vcl/textlayout.hxx b/canvas/source/vcl/textlayout.hxx index 5a403c28070a..be8603d812f1 100644 --- a/canvas/source/vcl/textlayout.hxx +++ b/canvas/source/vcl/textlayout.hxx @@ -29,7 +29,6 @@ #include "canvasfont.hxx" #include "impltools.hxx" - /* Definition of TextLayout class */ namespace vclcanvas @@ -85,7 +84,7 @@ namespace vclcanvas const css::rendering::RenderState& renderState ) const; private: - void setupTextOffsets( sal_Int32* outputOffsets, + KernArray setupTextOffsets( const css::uno::Sequence< double >& inputOffsets, const css::rendering::ViewState& viewState, const css::rendering::RenderState& renderState ) const; -- cgit v1.2.3