diff options
Diffstat (limited to 'canvas/source')
-rw-r--r-- | canvas/source/cairo/cairo_textlayout.cxx | 19 | ||||
-rw-r--r-- | canvas/source/cairo/cairo_textlayout.hxx | 2 | ||||
-rw-r--r-- | canvas/source/directx/dx_textlayout_drawhelper.cxx | 6 | ||||
-rw-r--r-- | canvas/source/opengl/ogl_canvashelper.cxx | 6 | ||||
-rw-r--r-- | canvas/source/vcl/textlayout.cxx | 24 | ||||
-rw-r--r-- | canvas/source/vcl/textlayout.hxx | 3 |
6 files changed, 28 insertions, 32 deletions
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 <cppuhelper/supportsservice.hxx> #include <comphelper/diagnose_ex.hxx> #include <utility> +#include <vcl/kernarray.hxx> #include <vcl/metric.hxx> #include <vcl/virdev.hxx> - #include "cairo_textlayout.hxx" using namespace ::cairo; @@ -265,8 +265,7 @@ namespace cairocanvas if (maLogicalAdvancements.hasElements()) { - std::vector<sal_Int32> 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<sal_uInt16>(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 <comphelper/diagnose_ex.hxx> #include <tools/poly.hxx> #include <vcl/canvastools.hxx> +#include <vcl/kernarray.hxx> #include <vcl/metric.hxx> #include <vcl/sysdata.hxx> #include <vcl/virdev.hxx> @@ -207,9 +208,10 @@ namespace dxcanvas { // create the DXArray const sal_Int32 nLen( rLogicalAdvancements.getLength() ); - std::vector<sal_Int32> DXArray( nLen ); + KernArray DXArray; + DXArray.reserve(nLen); for( sal_Int32 i=0; i<nLen; ++i ) - DXArray[i] = basegfx::fround( rLogicalAdvancements[i] ); + DXArray.push_back(basegfx::fround(rLogicalAdvancements[i])); // draw the String xVirtualDevice->DrawTextArray( 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 <rtl/math.hxx> #include <comphelper/diagnose_ex.hxx> #include <vcl/font.hxx> +#include <vcl/kernarray.hxx> #include <vcl/metric.hxx> #include <vcl/virdev.hxx> @@ -729,9 +730,10 @@ namespace oglcanvas { // create the DXArray const sal_Int32 nLen( aLogicalAdvancements.getLength() ); - std::vector<sal_Int32> aDXArray(nLen); + KernArray aDXArray; + aDXArray.resize(nLen); for( sal_Int32 i=0; i<nLen; ++i ) - aDXArray[i] = basegfx::fround( aLogicalAdvancements[i] ); + aDXArray.set(i, basegfx::fround(aLogicalAdvancements[i])); // get the glyphs pVDev->GetTextOutlines(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 <comphelper/sequence.hxx> #include <cppuhelper/supportsservice.hxx> #include <utility> +#include <vcl/kernarray.hxx> #include <vcl/metric.hxx> #include <vcl/virdev.hxx> @@ -117,8 +118,7 @@ namespace vclcanvas uno::Sequence<double>(4), rendering::CompositeOperation::SOURCE); - std::vector<sal_Int32> 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<double>(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<geometry::RealRectangle2D> aBoundingBoxes; @@ -335,8 +334,7 @@ namespace vclcanvas if( maLogicalAdvancements.hasElements() ) { // TODO(P2): cache that - std::vector<sal_Int32> 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; |