summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-10-28 09:27:29 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-10-29 12:38:51 +0200
commit894b4911ffb96ff667fdeb3aec7922316ab7230a (patch)
tree3942ed8088c058b70bb79984b186c5156284abf4 /canvas
parent5b0ae3b59cd2cccfb72d991657366eb2a69bff49 (diff)
pass DX array around using o3tl::span instead of pointer
so we get bounds checking in debug mode Note that I cannot just pass around the std::vectors involved because there is a place in editeng which calls with a subset of a vector. Change-Id: I5088a139593c27bf9cbe5d843ab4b0048ac6d508 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124330 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/cairo/cairo_textlayout.cxx6
-rw-r--r--canvas/source/directx/dx_textlayout_drawhelper.cxx2
-rw-r--r--canvas/source/opengl/ogl_canvashelper.cxx6
-rw-r--r--canvas/source/vcl/textlayout.cxx12
4 files changed, 13 insertions, 13 deletions
diff --git a/canvas/source/cairo/cairo_textlayout.cxx b/canvas/source/cairo/cairo_textlayout.cxx
index 9952d33d343c..acf2672be51d 100644
--- a/canvas/source/cairo/cairo_textlayout.cxx
+++ b/canvas/source/cairo/cairo_textlayout.cxx
@@ -263,14 +263,14 @@ namespace cairocanvas
::osl::MutexGuard aGuard( m_aMutex );
setupLayoutMode( rOutDev, mnTextDirection );
- std::unique_ptr< tools::Long []> aOffsets(new tools::Long[maLogicalAdvancements.getLength()]);
+ std::vector<tools::Long> aOffsets(maLogicalAdvancements.getLength());
if( maLogicalAdvancements.hasElements() )
- setupTextOffsets( aOffsets.get(), maLogicalAdvancements, viewState, renderState );
+ setupTextOffsets( aOffsets.data(), maLogicalAdvancements, viewState, renderState );
if (maLogicalAdvancements.hasElements())
{
- rOutDev.DrawTextArray( rOutpos, maText.Text, aOffsets.get(),
+ rOutDev.DrawTextArray( rOutpos, maText.Text, { aOffsets.data(), aOffsets.size() },
::canvas::tools::numeric_cast<sal_uInt16>(maText.StartPosition),
::canvas::tools::numeric_cast<sal_uInt16>(maText.Length) );
}
diff --git a/canvas/source/directx/dx_textlayout_drawhelper.cxx b/canvas/source/directx/dx_textlayout_drawhelper.cxx
index 1ffeb612de3d..6b5a389f77ae 100644
--- a/canvas/source/directx/dx_textlayout_drawhelper.cxx
+++ b/canvas/source/directx/dx_textlayout_drawhelper.cxx
@@ -213,7 +213,7 @@ namespace dxcanvas
// draw the String
xVirtualDevice->DrawTextArray( aEmptyPoint,
aText,
- pDXArray.get(),
+ o3tl::span<const ::tools::Long>( pDXArray.get(), nLen ),
rText.StartPosition,
rText.Length,
bIsRTL ? SalLayoutFlags::BiDiRtl : SalLayoutFlags::NONE);
diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx
index b0264d8d1d31..fdd4a7ac541b 100644
--- a/canvas/source/opengl/ogl_canvashelper.cxx
+++ b/canvas/source/opengl/ogl_canvashelper.cxx
@@ -729,9 +729,9 @@ namespace oglcanvas
{
// create the DXArray
const sal_Int32 nLen( aLogicalAdvancements.getLength() );
- std::unique_ptr<tools::Long[]> pDXArray( new tools::Long[nLen] );
+ std::vector<tools::Long> aDXArray(nLen);
for( sal_Int32 i=0; i<nLen; ++i )
- pDXArray[i] = basegfx::fround( aLogicalAdvancements[i] );
+ aDXArray[i] = basegfx::fround( aLogicalAdvancements[i] );
// get the glyphs
pVDev->GetTextOutlines(rAct.maPolyPolys,
@@ -740,7 +740,7 @@ namespace oglcanvas
rTxt.StartPosition,
rTxt.Length,
0,
- pDXArray.get() );
+ { aDXArray.data(), aDXArray.size() } );
}
else
{
diff --git a/canvas/source/vcl/textlayout.cxx b/canvas/source/vcl/textlayout.cxx
index 42e96e420233..1c1f1317b865 100644
--- a/canvas/source/vcl/textlayout.cxx
+++ b/canvas/source/vcl/textlayout.cxx
@@ -117,8 +117,8 @@ namespace vclcanvas
uno::Sequence<double>(4),
rendering::CompositeOperation::SOURCE);
- std::unique_ptr< ::tools::Long []> aOffsets(new ::tools::Long[maLogicalAdvancements.getLength()]);
- setupTextOffsets(aOffsets.get(), maLogicalAdvancements, aViewState, aRenderState);
+ std::vector<::tools::Long> aOffsets(maLogicalAdvancements.getLength());
+ setupTextOffsets(aOffsets.data(), maLogicalAdvancements, aViewState, aRenderState);
std::vector< uno::Reference< rendering::XPolyPolygon2D> > aOutlineSequence;
::basegfx::B2DPolyPolygonVector aOutlines;
@@ -129,7 +129,7 @@ namespace vclcanvas
maText.StartPosition,
maText.Length,
0,
- aOffsets.get()))
+ {aOffsets.data(), aOffsets.size()}))
{
aOutlineSequence.reserve(aOutlines.size());
sal_Int32 nIndex (0);
@@ -335,15 +335,15 @@ namespace vclcanvas
if( maLogicalAdvancements.hasElements() )
{
// TODO(P2): cache that
- std::unique_ptr< ::tools::Long []> aOffsets(new ::tools::Long[maLogicalAdvancements.getLength()]);
- setupTextOffsets( aOffsets.get(), maLogicalAdvancements, viewState, renderState );
+ std::vector<::tools::Long> aOffsets(maLogicalAdvancements.getLength());
+ setupTextOffsets( aOffsets.data(), maLogicalAdvancements, viewState, renderState );
// TODO(F3): ensure correct length and termination for DX
// array (last entry _must_ contain the overall width)
rOutDev.DrawTextArray( rOutpos,
maText.Text,
- aOffsets.get(),
+ { aOffsets.data(), aOffsets.size() },
::canvas::tools::numeric_cast<sal_uInt16>(maText.StartPosition),
::canvas::tools::numeric_cast<sal_uInt16>(maText.Length) );
}