summaryrefslogtreecommitdiff
path: root/vcl/inc/bitmap
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-04-14 15:34:03 +0900
committerTomaž Vajngerl <quikee@gmail.com>2019-04-14 14:19:03 +0200
commitf441b7c74d9074b0b29eabfbf35f47a1df7cea9c (patch)
tree17a65e3051b454490fca7c110d740def4c7fb8e4 /vcl/inc/bitmap
parent8db9363c8ef6138d2420366cc4f42ca1d662bdd7 (diff)
put Octree classes out of formatting blacklist
Need to do this so it is at least somewhat formatted sanely before refactoring to the data structures. Change-Id: I136a539a190c2f53aa05cc9a26872a5606f81888 Reviewed-on: https://gerrit.libreoffice.org/70727 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/inc/bitmap')
-rw-r--r--vcl/inc/bitmap/Octree.hxx88
-rw-r--r--vcl/inc/bitmap/impoctree.hxx89
2 files changed, 86 insertions, 91 deletions
diff --git a/vcl/inc/bitmap/Octree.hxx b/vcl/inc/bitmap/Octree.hxx
index cec8e4171494..3e54826a9313 100644
--- a/vcl/inc/bitmap/Octree.hxx
+++ b/vcl/inc/bitmap/Octree.hxx
@@ -23,20 +23,20 @@
#include <vcl/salbtype.hxx>
#include <vcl/dllapi.h>
-#define OCTREE_BITS 5
-#define OCTREE_BITS_1 10
+#define OCTREE_BITS 5
+#define OCTREE_BITS_1 10
struct OctreeNode
{
- sal_uLong nCount;
- sal_uLong nRed;
- sal_uLong nGreen;
- sal_uLong nBlue;
- OctreeNode* pChild[ 8 ];
- OctreeNode* pNext;
- OctreeNode* pNextInCache;
- sal_uInt16 nPalIndex;
- bool bLeaf;
+ sal_uLong nCount;
+ sal_uLong nRed;
+ sal_uLong nGreen;
+ sal_uLong nBlue;
+ OctreeNode* pChild[8];
+ OctreeNode* pNext;
+ OctreeNode* pNextInCache;
+ sal_uInt16 nPalIndex;
+ bool bLeaf;
};
class ImpNodeCache;
@@ -45,73 +45,69 @@ class BitmapReadAccess;
class VCL_PLUGIN_PUBLIC Octree
{
private:
- void CreatePalette( OctreeNode* pNode );
- void GetPalIndex( OctreeNode* pNode );
-
- SAL_DLLPRIVATE void ImplDeleteOctree( OctreeNode** ppNode );
- SAL_DLLPRIVATE void ImplAdd( OctreeNode** ppNode );
- SAL_DLLPRIVATE void ImplReduce();
-
-
- BitmapPalette aPal;
- sal_uLong nLeafCount;
- sal_uLong nLevel;
- OctreeNode* pTree;
- OctreeNode* pReduce[ OCTREE_BITS + 1 ];
- BitmapColor const * pColor;
+ void CreatePalette(OctreeNode* pNode);
+ void GetPalIndex(OctreeNode* pNode);
+
+ SAL_DLLPRIVATE void ImplDeleteOctree(OctreeNode** ppNode);
+ SAL_DLLPRIVATE void ImplAdd(OctreeNode** ppNode);
+ SAL_DLLPRIVATE void ImplReduce();
+
+ BitmapPalette aPal;
+ sal_uLong nLeafCount;
+ sal_uLong nLevel;
+ OctreeNode* pTree;
+ OctreeNode* pReduce[OCTREE_BITS + 1];
+ BitmapColor const* pColor;
std::unique_ptr<ImpNodeCache> pNodeCache;
- const BitmapReadAccess* pAcc;
- sal_uInt16 nPalIndex;
+ const BitmapReadAccess* pAcc;
+ sal_uInt16 nPalIndex;
public:
-
- Octree( const BitmapReadAccess& rReadAcc, sal_uLong nColors );
- ~Octree();
+ Octree(const BitmapReadAccess& rReadAcc, sal_uLong nColors);
+ ~Octree();
inline const BitmapPalette& GetPalette();
- inline sal_uInt16 GetBestPaletteIndex( const BitmapColor& rColor );
+ inline sal_uInt16 GetBestPaletteIndex(const BitmapColor& rColor);
};
inline const BitmapPalette& Octree::GetPalette()
{
- aPal.SetEntryCount( static_cast<sal_uInt16>(nLeafCount) );
+ aPal.SetEntryCount(static_cast<sal_uInt16>(nLeafCount));
nPalIndex = 0;
- CreatePalette( pTree );
+ CreatePalette(pTree);
return aPal;
}
-inline sal_uInt16 Octree::GetBestPaletteIndex( const BitmapColor& rColor )
+inline sal_uInt16 Octree::GetBestPaletteIndex(const BitmapColor& rColor)
{
pColor = &rColor;
nPalIndex = 65535;
nLevel = 0;
- GetPalIndex( pTree );
+ GetPalIndex(pTree);
return nPalIndex;
}
class VCL_PLUGIN_PUBLIC InverseColorMap
{
private:
-
std::unique_ptr<sal_uInt8[]> pBuffer;
std::unique_ptr<sal_uInt8[]> pMap;
- static constexpr sal_uLong gnBits = 8 -OCTREE_BITS;
+ static constexpr sal_uLong gnBits = 8 - OCTREE_BITS;
- SAL_DLLPRIVATE void ImplCreateBuffers( const sal_uLong nMax );
+ SAL_DLLPRIVATE void ImplCreateBuffers(const sal_uLong nMax);
public:
+ explicit InverseColorMap(const BitmapPalette& rPal);
+ ~InverseColorMap();
- explicit InverseColorMap( const BitmapPalette& rPal );
- ~InverseColorMap();
-
- inline sal_uInt16 GetBestPaletteIndex( const BitmapColor& rColor );
+ inline sal_uInt16 GetBestPaletteIndex(const BitmapColor& rColor);
};
-inline sal_uInt16 InverseColorMap::GetBestPaletteIndex( const BitmapColor& rColor )
+inline sal_uInt16 InverseColorMap::GetBestPaletteIndex(const BitmapColor& rColor)
{
- return pMap[ ( ( static_cast<sal_uLong>(rColor.GetRed()) >> gnBits ) << OCTREE_BITS_1 ) |
- ( ( static_cast<sal_uLong>(rColor.GetGreen()) >> gnBits ) << OCTREE_BITS ) |
- ( static_cast<sal_uLong>(rColor.GetBlue()) >> gnBits ) ];
+ return pMap[((static_cast<sal_uLong>(rColor.GetRed()) >> gnBits) << OCTREE_BITS_1)
+ | ((static_cast<sal_uLong>(rColor.GetGreen()) >> gnBits) << OCTREE_BITS)
+ | (static_cast<sal_uLong>(rColor.GetBlue()) >> gnBits)];
}
#endif // INCLUDED_VCL_INC_OCTREE_HXX
diff --git a/vcl/inc/bitmap/impoctree.hxx b/vcl/inc/bitmap/impoctree.hxx
index b2f05b351c5a..0ade7b7bcc3b 100644
--- a/vcl/inc/bitmap/impoctree.hxx
+++ b/vcl/inc/bitmap/impoctree.hxx
@@ -29,7 +29,6 @@ class ImpErrorQuad
long nBlue;
public:
-
ImpErrorQuad()
: nRed(0)
, nGreen(0)
@@ -37,93 +36,93 @@ public:
{
}
- ImpErrorQuad( const BitmapColor& rColor )
- : nRed( static_cast<long>(rColor.GetRed()) << 5 )
- , nGreen( static_cast<long>(rColor.GetGreen()) << 5 )
- , nBlue( static_cast<long>(rColor.GetBlue()) << 5 )
+ ImpErrorQuad(const BitmapColor& rColor)
+ : nRed(static_cast<long>(rColor.GetRed()) << 5)
+ , nGreen(static_cast<long>(rColor.GetGreen()) << 5)
+ , nBlue(static_cast<long>(rColor.GetBlue()) << 5)
{
}
- inline void operator=( const BitmapColor& rColor );
- inline ImpErrorQuad& operator-=( const BitmapColor& rColor );
+ inline void operator=(const BitmapColor& rColor);
+ inline ImpErrorQuad& operator-=(const BitmapColor& rColor);
- inline void ImplAddColorError1( const ImpErrorQuad& rErrQuad );
- inline void ImplAddColorError3( const ImpErrorQuad& rErrQuad );
- inline void ImplAddColorError5( const ImpErrorQuad& rErrQuad );
- inline void ImplAddColorError7( const ImpErrorQuad& rErrQuad );
+ inline void ImplAddColorError1(const ImpErrorQuad& rErrQuad);
+ inline void ImplAddColorError3(const ImpErrorQuad& rErrQuad);
+ inline void ImplAddColorError5(const ImpErrorQuad& rErrQuad);
+ inline void ImplAddColorError7(const ImpErrorQuad& rErrQuad);
- inline BitmapColor ImplGetColor();
+ inline BitmapColor ImplGetColor();
};
-inline void ImpErrorQuad::operator=( const BitmapColor& rColor )
+inline void ImpErrorQuad::operator=(const BitmapColor& rColor)
{
nRed = static_cast<long>(rColor.GetRed()) << 5;
nGreen = static_cast<long>(rColor.GetGreen()) << 5;
nBlue = static_cast<long>(rColor.GetBlue()) << 5;
}
-inline ImpErrorQuad& ImpErrorQuad::operator-=( const BitmapColor& rColor )
+inline ImpErrorQuad& ImpErrorQuad::operator-=(const BitmapColor& rColor)
{
- nRed -= ( static_cast<long>(rColor.GetRed()) << 5 );
- nGreen -= ( static_cast<long>(rColor.GetGreen()) << 5 );
- nBlue -= ( static_cast<long>(rColor.GetBlue()) << 5 );
+ nRed -= (static_cast<long>(rColor.GetRed()) << 5);
+ nGreen -= (static_cast<long>(rColor.GetGreen()) << 5);
+ nBlue -= (static_cast<long>(rColor.GetBlue()) << 5);
return *this;
}
-inline void ImpErrorQuad::ImplAddColorError1( const ImpErrorQuad& rErrQuad )
+inline void ImpErrorQuad::ImplAddColorError1(const ImpErrorQuad& rErrQuad)
{
- nRed += ( rErrQuad.nRed >> 4 );
- nGreen += ( rErrQuad.nGreen >> 4 );
- nBlue += ( rErrQuad.nBlue >> 4 );
+ nRed += (rErrQuad.nRed >> 4);
+ nGreen += (rErrQuad.nGreen >> 4);
+ nBlue += (rErrQuad.nBlue >> 4);
}
-inline void ImpErrorQuad::ImplAddColorError3( const ImpErrorQuad& rErrQuad )
+inline void ImpErrorQuad::ImplAddColorError3(const ImpErrorQuad& rErrQuad)
{
- nRed += ( rErrQuad.nRed * 3L >> 4 );
- nGreen += ( rErrQuad.nGreen * 3L >> 4 );
- nBlue += ( rErrQuad.nBlue * 3L >> 4 );
+ nRed += (rErrQuad.nRed * 3L >> 4);
+ nGreen += (rErrQuad.nGreen * 3L >> 4);
+ nBlue += (rErrQuad.nBlue * 3L >> 4);
}
-inline void ImpErrorQuad::ImplAddColorError5( const ImpErrorQuad& rErrQuad )
+inline void ImpErrorQuad::ImplAddColorError5(const ImpErrorQuad& rErrQuad)
{
- nRed += ( rErrQuad.nRed * 5L >> 4 );
- nGreen += ( rErrQuad.nGreen * 5L >> 4 );
- nBlue += ( rErrQuad.nBlue * 5L >> 4 );
+ nRed += (rErrQuad.nRed * 5L >> 4);
+ nGreen += (rErrQuad.nGreen * 5L >> 4);
+ nBlue += (rErrQuad.nBlue * 5L >> 4);
}
-inline void ImpErrorQuad::ImplAddColorError7( const ImpErrorQuad& rErrQuad )
+inline void ImpErrorQuad::ImplAddColorError7(const ImpErrorQuad& rErrQuad)
{
- nRed += ( rErrQuad.nRed * 7L >> 4 );
- nGreen += ( rErrQuad.nGreen * 7L >> 4 );
- nBlue += ( rErrQuad.nBlue *7L >> 4 );
+ nRed += (rErrQuad.nRed * 7L >> 4);
+ nGreen += (rErrQuad.nGreen * 7L >> 4);
+ nBlue += (rErrQuad.nBlue * 7L >> 4);
}
inline BitmapColor ImpErrorQuad::ImplGetColor()
{
- return BitmapColor( static_cast<sal_uInt8>( ( nRed < 0 ? 0L : nRed > 8160 ? 8160L : nRed ) >> 5 ),
- static_cast<sal_uInt8>( ( nGreen < 0 ? 0L : nGreen > 8160 ? 8160L : nGreen ) >> 5 ),
- static_cast<sal_uInt8>( ( nBlue < 0 ? 0L : nBlue > 8160 ? 8160L : nBlue ) >> 5 ) );
+ return BitmapColor(
+ static_cast<sal_uInt8>((nRed < 0 ? 0L : nRed > 8160 ? 8160L : nRed) >> 5),
+ static_cast<sal_uInt8>((nGreen < 0 ? 0L : nGreen > 8160 ? 8160L : nGreen) >> 5),
+ static_cast<sal_uInt8>((nBlue < 0 ? 0L : nBlue > 8160 ? 8160L : nBlue) >> 5));
}
class ImpNodeCache
{
- OctreeNode* pActNode;
+ OctreeNode* pActNode;
public:
+ ImpNodeCache(const sal_uLong nInitSize);
+ ~ImpNodeCache();
- ImpNodeCache( const sal_uLong nInitSize );
- ~ImpNodeCache();
-
- inline OctreeNode* ImplGetFreeNode();
- inline void ImplReleaseNode( OctreeNode* pNode );
+ inline OctreeNode* ImplGetFreeNode();
+ inline void ImplReleaseNode(OctreeNode* pNode);
};
inline OctreeNode* ImpNodeCache::ImplGetFreeNode()
{
OctreeNode* pNode;
- if ( !pActNode )
+ if (!pActNode)
{
pActNode = new OctreeNode;
pActNode->pNextInCache = nullptr;
@@ -131,12 +130,12 @@ inline OctreeNode* ImpNodeCache::ImplGetFreeNode()
pNode = pActNode;
pActNode = pNode->pNextInCache;
- memset( pNode, 0, sizeof( OctreeNode ) );
+ memset(pNode, 0, sizeof(OctreeNode));
return pNode;
}
-inline void ImpNodeCache::ImplReleaseNode( OctreeNode* pNode )
+inline void ImpNodeCache::ImplReleaseNode(OctreeNode* pNode)
{
pNode->pNextInCache = pActNode;
pActNode = pNode;