Kaydet (Commit) d7d9edb2 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in PolyPolygon

Also
- convert to o3tl::cow_wrapper
- drop the second param to the constructor and just
  let vector use it's own resize logic
- bump MAX_POLYGONS from 0x3FF0 to 0xffff so that the
  ios2met filter can load it's files properly.

Change-Id: I9db19e4f7b4f946e801ea07c31d2d0ded7837a0e
Reviewed-on: https://gerrit.libreoffice.org/47789Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst dacb12d2
...@@ -595,7 +595,7 @@ namespace emfio ...@@ -595,7 +595,7 @@ namespace emfio
if ( mpInputStream->good() && ( nGesPoints * (sizeof(T)+sizeof(T)) ) <= ( nEndPos - mpInputStream->Tell() ) ) if ( mpInputStream->good() && ( nGesPoints * (sizeof(T)+sizeof(T)) ) <= ( nEndPos - mpInputStream->Tell() ) )
{ {
// Get polygon points // Get polygon points
tools::PolyPolygon aPolyPoly(nPoly, nPoly); tools::PolyPolygon aPolyPoly(nPoly);
for (sal_uInt32 i = 0; i < nPoly && mpInputStream->good(); ++i) for (sal_uInt32 i = 0; i < nPoly && mpInputStream->good(); ++i)
{ {
const sal_uInt16 nPointCount(aPoints[i]); const sal_uInt16 nPointCount(aPoints[i]);
......
...@@ -393,7 +393,7 @@ namespace emfio ...@@ -393,7 +393,7 @@ namespace emfio
// Number of points of each polygon. Determine total number of points // Number of points of each polygon. Determine total number of points
std::unique_ptr<sal_uInt16[]> xPolygonPointCounts(new sal_uInt16[nPolyCount]); std::unique_ptr<sal_uInt16[]> xPolygonPointCounts(new sal_uInt16[nPolyCount]);
sal_uInt16* pnPoints = xPolygonPointCounts.get(); sal_uInt16* pnPoints = xPolygonPointCounts.get();
tools::PolyPolygon aPolyPoly(nPolyCount, nPolyCount); tools::PolyPolygon aPolyPoly(nPolyCount);
sal_uInt16 nPoints = 0; sal_uInt16 nPoints = 0;
for (sal_uInt16 a = 0; a < nPolyCount && mpInputStream->good(); ++a) for (sal_uInt16 a = 0; a < nPolyCount && mpInputStream->good(); ++a)
{ {
......
...@@ -60,7 +60,7 @@ enum class PolyFlags : sal_uInt8 ...@@ -60,7 +60,7 @@ enum class PolyFlags : sal_uInt8
class SvStream; class SvStream;
class ImplPolygon; class ImplPolygon;
class ImplPolyPolygon; struct ImplPolyPolygon;
namespace tools { class PolyPolygon; } namespace tools { class PolyPolygon; }
namespace basegfx namespace basegfx
...@@ -189,7 +189,7 @@ public: ...@@ -189,7 +189,7 @@ public:
class SAL_WARN_UNUSED TOOLS_DLLPUBLIC PolyPolygon class SAL_WARN_UNUSED TOOLS_DLLPUBLIC PolyPolygon
{ {
private: private:
ImplPolyPolygon* mpImplPolyPolygon; o3tl::cow_wrapper<ImplPolyPolygon> mpImplPolyPolygon;
enum class PolyClipOp { enum class PolyClipOp {
INTERSECT, INTERSECT,
...@@ -198,7 +198,7 @@ private: ...@@ -198,7 +198,7 @@ private:
TOOLS_DLLPRIVATE void ImplDoOperation( const tools::PolyPolygon& rPolyPoly, tools::PolyPolygon& rResult, PolyClipOp nOperation ) const; TOOLS_DLLPRIVATE void ImplDoOperation( const tools::PolyPolygon& rPolyPoly, tools::PolyPolygon& rResult, PolyClipOp nOperation ) const;
public: public:
PolyPolygon( sal_uInt16 nInitSize = 16, sal_uInt16 nResize = 16 ); PolyPolygon( sal_uInt16 nInitSize = 16 );
PolyPolygon( const tools::Polygon& rPoly ); PolyPolygon( const tools::Polygon& rPoly );
PolyPolygon( const tools::PolyPolygon& rPolyPoly ); PolyPolygon( const tools::PolyPolygon& rPolyPoly );
~PolyPolygon(); ~PolyPolygon();
......
...@@ -235,7 +235,7 @@ void ContourWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta ...@@ -235,7 +235,7 @@ void ContourWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
if (aWorkRect.Left() != aWorkRect.Right() && aWorkRect.Top() != aWorkRect.Bottom()) if (aWorkRect.Left() != aWorkRect.Right() && aWorkRect.Top() != aWorkRect.Bottom())
{ {
tools::PolyPolygon _aPolyPoly(2, 2); tools::PolyPolygon _aPolyPoly(2);
rTarget.Push(PushFlags::FILLCOLOR); rTarget.Push(PushFlags::FILLCOLOR);
_aPolyPoly.Insert(tools::Rectangle(Point(), GetGraphicSize())); _aPolyPoly.Insert(tools::Rectangle(Point(), GetGraphicSize()));
_aPolyPoly.Insert(aWorkRect); _aPolyPoly.Insert(aWorkRect);
......
...@@ -53,27 +53,37 @@ public: ...@@ -53,27 +53,37 @@ public:
bool ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon const * pInitPoly = nullptr ); bool ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon const * pInitPoly = nullptr );
}; };
#define MAX_POLYGONS ((sal_uInt16)0x3FF0) #define MAX_POLYGONS SAL_MAX_UINT16
namespace tools { namespace tools {
class Polygon; class Polygon;
} }
class SAL_WARN_UNUSED ImplPolyPolygon struct ImplPolyPolygon
{ {
public: std::vector<tools::Polygon> mvPolyAry;
tools::Polygon** mpPolyAry;
sal_uInt32 mnRefCount; ImplPolyPolygon( sal_uInt16 nInitSize )
sal_uInt16 mnCount; {
sal_uInt16 mnSize; if ( !nInitSize )
sal_uInt16 mnResize; nInitSize = 1;
mvPolyAry.reserve(nInitSize);
}
ImplPolyPolygon( const tools::Polygon& rPoly )
{
if ( rPoly.GetSize() )
mvPolyAry.push_back(rPoly);
else
mvPolyAry.reserve(16);
}
ImplPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon);
ImplPolyPolygon( sal_uInt16 nInitSize, sal_uInt16 nResize ) bool operator==(ImplPolyPolygon const & other) const
{ mpPolyAry = nullptr; mnCount = 0; mnRefCount = 1; {
mnSize = nInitSize; mnResize = nResize; } return mvPolyAry == other.mvPolyAry;
ImplPolyPolygon( sal_uInt16 nInitSize ); }
ImplPolyPolygon( const ImplPolyPolygon& rImplPolyPoly );
~ImplPolyPolygon();
}; };
#endif #endif
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment