diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-04-14 23:33:43 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-04-15 01:57:07 +0200 |
commit | 36679103fb538f514416768027636c9d484866b1 (patch) | |
tree | 96aac1980b9b780900ff9c99cc6a33073ec7f99e /vcl | |
parent | 8aaeaa27b021b7322d0b55ab81095349bbb721e7 (diff) |
move ImpNodeCache into Octree.cxx and clean-up
ImpNodeCache is specific to Octree so it's best that it lives
near the source.
Change-Id: I35e937343312b0ab18ed1a4dcaa067ea01a0191f
Reviewed-on: https://gerrit.libreoffice.org/70736
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/bitmap/impoctree.hxx | 35 | ||||
-rw-r--r-- | vcl/source/bitmap/Octree.cxx | 60 |
2 files changed, 44 insertions, 51 deletions
diff --git a/vcl/inc/bitmap/impoctree.hxx b/vcl/inc/bitmap/impoctree.hxx index 727551123c5c..06fbd69249d0 100644 --- a/vcl/inc/bitmap/impoctree.hxx +++ b/vcl/inc/bitmap/impoctree.hxx @@ -104,41 +104,6 @@ inline BitmapColor ImpErrorQuad::ImplGetColor() std::clamp(nBlue, 0L, 8160L) >> 5); } -class ImpNodeCache -{ - OctreeNode* pActNode; - -public: - ImpNodeCache(const sal_uLong nInitSize); - ~ImpNodeCache(); - - inline OctreeNode* ImplGetFreeNode(); - inline void ImplReleaseNode(OctreeNode* pNode); -}; - -inline OctreeNode* ImpNodeCache::ImplGetFreeNode() -{ - OctreeNode* pNode; - - if (!pActNode) - { - pActNode = new OctreeNode; - pActNode->pNextInCache = nullptr; - } - - pNode = pActNode; - pActNode = pNode->pNextInCache; - memset(pNode, 0, sizeof(OctreeNode)); - - return pNode; -} - -inline void ImpNodeCache::ImplReleaseNode(OctreeNode* pNode) -{ - pNode->pNextInCache = pActNode; - pActNode = pNode; -} - #endif // INCLUDED_VCL_INC_IMPOCTREE_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/bitmap/Octree.cxx b/vcl/source/bitmap/Octree.cxx index 5f291e6ab8fb..592d17c1d469 100644 --- a/vcl/source/bitmap/Octree.cxx +++ b/vcl/source/bitmap/Octree.cxx @@ -23,7 +23,6 @@ #include <vcl/bitmapaccess.hxx> #include <bitmap/Octree.hxx> -#include <bitmap/impoctree.hxx> namespace { @@ -34,30 +33,59 @@ constexpr sal_uLong gnBits = 8 - OCTREE_BITS; } // end anonymous namespace -ImpNodeCache::ImpNodeCache(const sal_uLong nInitSize) - : pActNode(nullptr) +class ImpNodeCache { - const sal_uLong nSize = nInitSize + 4; +private: + OctreeNode* mpActNode; - for (sal_uLong i = 0; i < nSize; i++) +public: + ImpNodeCache(const sal_uLong nInitSize) + : mpActNode(nullptr) { - OctreeNode* pNewNode = new OctreeNode; + const sal_uLong nSize = nInitSize + 4; - pNewNode->pNextInCache = pActNode; - pActNode = pNewNode; + for (sal_uLong i = 0; i < nSize; i++) + { + OctreeNode* pNewNode = new OctreeNode; + + pNewNode->pNextInCache = mpActNode; + mpActNode = pNewNode; + } } -} -ImpNodeCache::~ImpNodeCache() -{ - while (pActNode) + ~ImpNodeCache() { - OctreeNode* pNode = pActNode; + while (mpActNode) + { + OctreeNode* pNode = mpActNode; - pActNode = pNode->pNextInCache; - delete pNode; + mpActNode = pNode->pNextInCache; + delete pNode; + } } -} + + OctreeNode* ImplGetFreeNode() + { + OctreeNode* pNode; + + if (!mpActNode) + { + mpActNode = new OctreeNode; + mpActNode->pNextInCache = nullptr; + } + + pNode = mpActNode; + mpActNode = pNode->pNextInCache; + memset(pNode, 0, sizeof(OctreeNode)); + + return pNode; + } + void ImplReleaseNode(OctreeNode* pNode) + { + pNode->pNextInCache = mpActNode; + mpActNode = pNode; + } +}; Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong nColors) : mnLeafCount(0) |