[Libreoffice-commits] core.git: 2 commits - solenv/clang-format vcl/inc vcl/Library_vcl.mk vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Sun Apr 14 12:19:42 UTC 2019


 solenv/clang-format/blacklist                             |    3 
 vcl/Library_vcl.mk                                        |    2 
 vcl/inc/bitmap/Octree.hxx                                 |  115 +++++
 vcl/inc/bitmap/impoctree.hxx                              |  146 ++++++
 vcl/inc/impoctree.hxx                                     |  147 ------
 vcl/inc/octree.hxx                                        |  119 -----
 vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx |    2 
 vcl/source/bitmap/Octree.cxx                              |  302 ++++++++++++++
 vcl/source/gdi/bitmap3.cxx                                |    4 
 vcl/source/gdi/octree.cxx                                 |  298 -------------
 10 files changed, 567 insertions(+), 571 deletions(-)

New commits:
commit f441b7c74d9074b0b29eabfbf35f47a1df7cea9c
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Apr 14 15:34:03 2019 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sun Apr 14 14:19:03 2019 +0200

    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 at gmail.com>

diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 732fc7c40550..ccd57fa3c047 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -17336,8 +17336,6 @@ vcl/inc/ios/svsys.h
 vcl/inc/jobset.h
 vcl/inc/langboost.hxx
 vcl/inc/listbox.hxx
-vcl/inc/bitmap/Octree.hxx
-vcl/inc/bitmap/impoctree.hxx
 vcl/inc/opengl/BufferObject.hxx
 vcl/inc/opengl/DeviceInfo.hxx
 vcl/inc/opengl/FixedTextureAtlas.hxx
@@ -17777,7 +17775,6 @@ vcl/source/bitmap/BitmapTools.cxx
 vcl/source/bitmap/bitmap.cxx
 vcl/source/bitmap/bitmapfilter.cxx
 vcl/source/bitmap/checksum.cxx
-vcl/source/bitmap/Octree.cxx
 vcl/source/components/dtranscomp.cxx
 vcl/source/components/factory.cxx
 vcl/source/components/fontident.cxx
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;
diff --git a/vcl/source/bitmap/Octree.cxx b/vcl/source/bitmap/Octree.cxx
index 64914f76385e..6650e52d0692 100644
--- a/vcl/source/bitmap/Octree.cxx
+++ b/vcl/source/bitmap/Octree.cxx
@@ -27,12 +27,12 @@
 
 static const sal_uInt8 pImplMask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
 
-ImpNodeCache::ImpNodeCache( const sal_uLong nInitSize ) :
-            pActNode( nullptr )
+ImpNodeCache::ImpNodeCache(const sal_uLong nInitSize)
+    : pActNode(nullptr)
 {
     const sal_uLong nSize = nInitSize + 4;
 
-    for( sal_uLong i = 0; i < nSize; i++ )
+    for (sal_uLong i = 0; i < nSize; i++)
     {
         OctreeNode* pNewNode = new OctreeNode;
 
@@ -43,7 +43,7 @@ ImpNodeCache::ImpNodeCache( const sal_uLong nInitSize ) :
 
 ImpNodeCache::~ImpNodeCache()
 {
-    while( pActNode )
+    while (pActNode)
     {
         OctreeNode* pNode = pActNode;
 
@@ -61,26 +61,26 @@ Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong nColors)
     , nPalIndex(0)
 {
     sal_uLong nMax(nColors);
-    pNodeCache.reset( new ImpNodeCache( nColors ) );
-    memset( pReduce, 0, ( OCTREE_BITS + 1 ) * sizeof( OctreeNode* ) );
+    pNodeCache.reset(new ImpNodeCache(nColors));
+    memset(pReduce, 0, (OCTREE_BITS + 1) * sizeof(OctreeNode*));
 
-    if( !!*pAcc )
+    if (!!*pAcc)
     {
-        const long      nWidth = pAcc->Width();
-        const long      nHeight = pAcc->Height();
+        const long nWidth = pAcc->Width();
+        const long nHeight = pAcc->Height();
 
-        if( pAcc->HasPalette() )
+        if (pAcc->HasPalette())
         {
-            for( long nY = 0; nY < nHeight; nY++ )
+            for (long nY = 0; nY < nHeight; nY++)
             {
-                Scanline pScanline = pAcc->GetScanline( nY );
-                for( long nX = 0; nX < nWidth; nX++ )
+                Scanline pScanline = pAcc->GetScanline(nY);
+                for (long nX = 0; nX < nWidth; nX++)
                 {
-                    pColor = &pAcc->GetPaletteColor( pAcc->GetIndexFromData( pScanline, nX ) );
+                    pColor = &pAcc->GetPaletteColor(pAcc->GetIndexFromData(pScanline, nX));
                     nLevel = 0;
-                    ImplAdd( &pTree );
+                    ImplAdd(&pTree);
 
-                    while( nLeafCount > nMax )
+                    while (nLeafCount > nMax)
                         ImplReduce();
                 }
             }
@@ -91,16 +91,16 @@ Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong nColors)
 
             pColor = &aColor;
 
-            for( long nY = 0; nY < nHeight; nY++ )
+            for (long nY = 0; nY < nHeight; nY++)
             {
-                Scanline pScanline = pAcc->GetScanline( nY );
-                for( long nX = 0; nX < nWidth; nX++ )
+                Scanline pScanline = pAcc->GetScanline(nY);
+                for (long nX = 0; nX < nWidth; nX++)
                 {
-                    aColor = pAcc->GetPixelFromData( pScanline, nX );
+                    aColor = pAcc->GetPixelFromData(pScanline, nX);
                     nLevel = 0;
-                    ImplAdd( &pTree );
+                    ImplAdd(&pTree);
 
-                    while( nLeafCount > nMax )
+                    while (nLeafCount > nMax)
                         ImplReduce();
                 }
             }
@@ -110,40 +110,40 @@ Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong nColors)
 
 Octree::~Octree()
 {
-    ImplDeleteOctree( &pTree );
+    ImplDeleteOctree(&pTree);
     pNodeCache.reset();
 }
 
-void Octree::ImplDeleteOctree( OctreeNode** ppNode )
+void Octree::ImplDeleteOctree(OctreeNode** ppNode)
 {
     for (OctreeNode* i : (*ppNode)->pChild)
     {
-        if ( i )
-            ImplDeleteOctree( &i );
+        if (i)
+            ImplDeleteOctree(&i);
     }
 
-    pNodeCache->ImplReleaseNode( *ppNode );
+    pNodeCache->ImplReleaseNode(*ppNode);
     *ppNode = nullptr;
 }
 
-void Octree::ImplAdd( OctreeNode** ppNode )
+void Octree::ImplAdd(OctreeNode** ppNode)
 {
     // possibly generate new nodes
-    if( !*ppNode )
+    if (!*ppNode)
     {
         *ppNode = pNodeCache->ImplGetFreeNode();
-        (*ppNode)->bLeaf = ( OCTREE_BITS == nLevel );
+        (*ppNode)->bLeaf = (OCTREE_BITS == nLevel);
 
-        if( (*ppNode)->bLeaf )
+        if ((*ppNode)->bLeaf)
             nLeafCount++;
         else
         {
-            (*ppNode)->pNext = pReduce[ nLevel ];
-            pReduce[ nLevel ] = *ppNode;
+            (*ppNode)->pNext = pReduce[nLevel];
+            pReduce[nLevel] = *ppNode;
         }
     }
 
-    if( (*ppNode)->bLeaf )
+    if ((*ppNode)->bLeaf)
     {
         (*ppNode)->nCount++;
         (*ppNode)->nRed += pColor->GetRed();
@@ -153,43 +153,45 @@ void Octree::ImplAdd( OctreeNode** ppNode )
     else
     {
         const sal_uLong nShift = 7 - nLevel;
-        const sal_uInt8  cMask = pImplMask[ nLevel ];
-        const sal_uLong nIndex = ( ( ( pColor->GetRed() & cMask ) >> nShift ) << 2 ) |
-                             ( ( ( pColor->GetGreen() & cMask ) >> nShift ) << 1 ) |
-                             ( ( pColor->GetBlue() & cMask ) >> nShift );
+        const sal_uInt8 cMask = pImplMask[nLevel];
+        const sal_uLong nIndex = (((pColor->GetRed() & cMask) >> nShift) << 2)
+                                 | (((pColor->GetGreen() & cMask) >> nShift) << 1)
+                                 | ((pColor->GetBlue() & cMask) >> nShift);
 
         nLevel++;
-        ImplAdd( &(*ppNode)->pChild[ nIndex ] );
+        ImplAdd(&(*ppNode)->pChild[nIndex]);
     }
 }
 
 void Octree::ImplReduce()
 {
-    sal_uLong   i;
+    sal_uLong i;
     OctreeNode* pNode;
-    sal_uLong   nRedSum = 0;
-    sal_uLong   nGreenSum = 0;
-    sal_uLong   nBlueSum = 0;
-    sal_uLong   nChildren = 0;
+    sal_uLong nRedSum = 0;
+    sal_uLong nGreenSum = 0;
+    sal_uLong nBlueSum = 0;
+    sal_uLong nChildren = 0;
 
-    for ( i = OCTREE_BITS - 1; i && !pReduce[i]; i-- ) {}
+    for (i = OCTREE_BITS - 1; i && !pReduce[i]; i--)
+    {
+    }
 
-    pNode = pReduce[ i ];
-    pReduce[ i ] = pNode->pNext;
+    pNode = pReduce[i];
+    pReduce[i] = pNode->pNext;
 
-    for ( i = 0; i < 8; i++ )
+    for (i = 0; i < 8; i++)
     {
-        if ( pNode->pChild[ i ] )
+        if (pNode->pChild[i])
         {
-            OctreeNode* pChild = pNode->pChild[ i ];
+            OctreeNode* pChild = pNode->pChild[i];
 
             nRedSum += pChild->nRed;
             nGreenSum += pChild->nGreen;
             nBlueSum += pChild->nBlue;
             pNode->nCount += pChild->nCount;
 
-            pNodeCache->ImplReleaseNode( pNode->pChild[ i ] );
-            pNode->pChild[ i ] = nullptr;
+            pNodeCache->ImplReleaseNode(pNode->pChild[i]);
+            pNode->pChild[i] = nullptr;
             nChildren++;
         }
     }
@@ -201,75 +203,79 @@ void Octree::ImplReduce()
     nLeafCount -= --nChildren;
 }
 
-void Octree::CreatePalette( OctreeNode* pNode )
+void Octree::CreatePalette(OctreeNode* pNode)
 {
-    if( pNode->bLeaf )
+    if (pNode->bLeaf)
     {
         pNode->nPalIndex = nPalIndex;
-        aPal[ nPalIndex++ ] = BitmapColor( static_cast<sal_uInt8>( static_cast<double>(pNode->nRed) / pNode->nCount ),
-                                           static_cast<sal_uInt8>( static_cast<double>(pNode->nGreen) / pNode->nCount ),
-                                           static_cast<sal_uInt8>( static_cast<double>(pNode->nBlue) / pNode->nCount ) );
+        aPal[nPalIndex++] = BitmapColor(
+            static_cast<sal_uInt8>(static_cast<double>(pNode->nRed) / pNode->nCount),
+            static_cast<sal_uInt8>(static_cast<double>(pNode->nGreen) / pNode->nCount),
+            static_cast<sal_uInt8>(static_cast<double>(pNode->nBlue) / pNode->nCount));
     }
-    else for(OctreeNode* i : pNode->pChild)
-        if( i )
-            CreatePalette( i );
-
+    else
+        for (OctreeNode* i : pNode->pChild)
+        {
+            if (i)
+                CreatePalette(i);
+        }
 }
 
-void Octree::GetPalIndex( OctreeNode* pNode )
+void Octree::GetPalIndex(OctreeNode* pNode)
 {
-    if ( pNode->bLeaf )
+    if (pNode->bLeaf)
         nPalIndex = pNode->nPalIndex;
     else
     {
         const sal_uLong nShift = 7 - nLevel;
-        const sal_uInt8  cMask = pImplMask[ nLevel++ ];
-        const sal_uLong nIndex = ( ( ( pColor->GetRed() & cMask ) >> nShift ) << 2 ) |
-                             ( ( ( pColor->GetGreen() & cMask ) >> nShift ) << 1 ) |
-                             ( ( pColor->GetBlue() & cMask ) >> nShift );
+        const sal_uInt8 cMask = pImplMask[nLevel++];
+        const sal_uLong nIndex = (((pColor->GetRed() & cMask) >> nShift) << 2)
+                                 | (((pColor->GetGreen() & cMask) >> nShift) << 1)
+                                 | ((pColor->GetBlue() & cMask) >> nShift);
 
-        GetPalIndex( pNode->pChild[ nIndex ] );
+        GetPalIndex(pNode->pChild[nIndex]);
     }
 }
 
-InverseColorMap::InverseColorMap( const BitmapPalette& rPal )
+InverseColorMap::InverseColorMap(const BitmapPalette& rPal)
 {
-    const int     nColorMax = 1 << OCTREE_BITS;
-    const unsigned long xsqr = 1 << ( gnBits << 1 );
+    const int nColorMax = 1 << OCTREE_BITS;
+    const unsigned long xsqr = 1 << (gnBits << 1);
     const unsigned long xsqr2 = xsqr << 1;
-    const int     nColors = rPal.GetEntryCount();
-    const long      x = 1 << gnBits;
-    const long      x2 = x >> 1;
-    sal_uLong           r, g, b;
-    long            rxx, gxx, bxx;
+    const int nColors = rPal.GetEntryCount();
+    const long x = 1 << gnBits;
+    const long x2 = x >> 1;
+    sal_uLong r, g, b;
+    long rxx, gxx, bxx;
 
-    ImplCreateBuffers( nColorMax );
+    ImplCreateBuffers(nColorMax);
 
-    for( int nIndex = 0; nIndex < nColors; nIndex++ )
+    for (int nIndex = 0; nIndex < nColors; nIndex++)
     {
-        const BitmapColor&  rColor = rPal[ static_cast<sal_uInt16>(nIndex) ];
-        const long          cRed = rColor.GetRed();
-        const long          cGreen = rColor.GetGreen();
-        const long          cBlue = rColor.GetBlue();
+        const BitmapColor& rColor = rPal[static_cast<sal_uInt16>(nIndex)];
+        const long cRed = rColor.GetRed();
+        const long cGreen = rColor.GetGreen();
+        const long cBlue = rColor.GetBlue();
 
         long rdist = cRed - x2;
         long gdist = cGreen - x2;
         long bdist = cBlue - x2;
-        rdist = rdist*rdist + gdist*gdist + bdist*bdist;
+        rdist = rdist * rdist + gdist * gdist + bdist * bdist;
 
-        const long crinc = ( xsqr - ( cRed << gnBits ) ) << 1;
-        const long cginc = ( xsqr - ( cGreen << gnBits ) ) << 1;
-        const long cbinc = ( xsqr - ( cBlue << gnBits ) ) << 1;
+        const long crinc = (xsqr - (cRed << gnBits)) << 1;
+        const long cginc = (xsqr - (cGreen << gnBits)) << 1;
+        const long cbinc = (xsqr - (cBlue << gnBits)) << 1;
 
         sal_uLong* cdp = reinterpret_cast<sal_uLong*>(pBuffer.get());
         sal_uInt8* crgbp = pMap.get();
 
-        for( r = 0, rxx = crinc; r < nColorMax; rdist += rxx, r++, rxx += xsqr2 )
+        for (r = 0, rxx = crinc; r < nColorMax; rdist += rxx, r++, rxx += xsqr2)
         {
-            for( g = 0, gdist = rdist, gxx = cginc; g < nColorMax;  gdist += gxx, g++, gxx += xsqr2 )
+            for (g = 0, gdist = rdist, gxx = cginc; g < nColorMax; gdist += gxx, g++, gxx += xsqr2)
             {
-                for( b = 0, bdist = gdist, bxx = cbinc; b < nColorMax; bdist += bxx, b++, cdp++, crgbp++, bxx += xsqr2 )
-                    if ( !nIndex || static_cast<long>(*cdp) > bdist )
+                for (b = 0, bdist = gdist, bxx = cbinc; b < nColorMax;
+                     bdist += bxx, b++, cdp++, crgbp++, bxx += xsqr2)
+                    if (!nIndex || static_cast<long>(*cdp) > bdist)
                     {
                         *cdp = bdist;
                         *crgbp = static_cast<sal_uInt8>(nIndex);
@@ -279,20 +285,18 @@ InverseColorMap::InverseColorMap( const BitmapPalette& rPal )
     }
 }
 
-InverseColorMap::~InverseColorMap()
-{
-}
+InverseColorMap::~InverseColorMap() {}
 
-void InverseColorMap::ImplCreateBuffers( const sal_uLong nMax )
+void InverseColorMap::ImplCreateBuffers(const sal_uLong nMax)
 {
     const sal_uLong nCount = nMax * nMax * nMax;
-    const sal_uLong nSize = nCount * sizeof( sal_uLong );
+    const sal_uLong nSize = nCount * sizeof(sal_uLong);
 
-    pMap.reset(new sal_uInt8[ nCount ]);
-    memset( pMap.get(), 0x00, nCount );
+    pMap.reset(new sal_uInt8[nCount]);
+    memset(pMap.get(), 0x00, nCount);
 
-    pBuffer.reset(new sal_uInt8[ nSize ]);
-    memset( pBuffer.get(), 0xff, nSize );
+    pBuffer.reset(new sal_uInt8[nSize]);
+    memset(pBuffer.get(), 0xff, nSize);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 8db9363c8ef6138d2420366cc4f42ca1d662bdd7
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Apr 14 18:37:54 2019 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sun Apr 14 14:18:50 2019 +0200

    move octree to bitmap folder, and *octree headers to inc/bitmap
    
    Octree is a tree, that's used for color quantization, so it's
    better to move it there. Headers are also moved to bitmap
    subfolder so it's better organized.
    
    Change-Id: I2b84a5469c1479cf0a060ba8eb46591dabab2883
    Reviewed-on: https://gerrit.libreoffice.org/70726
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index 830cfe7fa9d8..732fc7c40550 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -17331,13 +17331,13 @@ vcl/inc/impfontmetric.hxx
 vcl/inc/impfontmetricdata.hxx
 vcl/inc/impgraph.hxx
 vcl/inc/implimagetree.hxx
-vcl/inc/impoctree.hxx
 vcl/inc/ios/iosinst.hxx
 vcl/inc/ios/svsys.h
 vcl/inc/jobset.h
 vcl/inc/langboost.hxx
 vcl/inc/listbox.hxx
-vcl/inc/octree.hxx
+vcl/inc/bitmap/Octree.hxx
+vcl/inc/bitmap/impoctree.hxx
 vcl/inc/opengl/BufferObject.hxx
 vcl/inc/opengl/DeviceInfo.hxx
 vcl/inc/opengl/FixedTextureAtlas.hxx
@@ -17777,6 +17777,7 @@ vcl/source/bitmap/BitmapTools.cxx
 vcl/source/bitmap/bitmap.cxx
 vcl/source/bitmap/bitmapfilter.cxx
 vcl/source/bitmap/checksum.cxx
+vcl/source/bitmap/Octree.cxx
 vcl/source/components/dtranscomp.cxx
 vcl/source/components/factory.cxx
 vcl/source/components/fontident.cxx
@@ -17909,7 +17910,6 @@ vcl/source/gdi/lineinfo.cxx
 vcl/source/gdi/mapmod.cxx
 vcl/source/gdi/metaact.cxx
 vcl/source/gdi/mtfxmldump.cxx
-vcl/source/gdi/octree.cxx
 vcl/source/gdi/oldprintadaptor.cxx
 vcl/source/gdi/pdfextoutdevdata.cxx
 vcl/source/gdi/pdffontcache.cxx
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 7265eb39811f..242af6a996fb 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -280,7 +280,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/gdi/lineinfo \
     vcl/source/gdi/mapmod \
     vcl/source/gdi/metaact \
-    vcl/source/gdi/octree \
     vcl/source/gdi/oldprintadaptor \
     vcl/source/gdi/pdfbuildin_fonts \
     vcl/source/gdi/pdfextoutdevdata \
@@ -344,6 +343,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/bitmap/BitmapSimpleColorQuantizationFilter \
     vcl/source/bitmap/BitmapTools \
     vcl/source/bitmap/checksum \
+    vcl/source/bitmap/Octree \
     vcl/source/image/Image \
     vcl/source/image/ImageTree \
     vcl/source/image/ImageRepository \
diff --git a/vcl/inc/octree.hxx b/vcl/inc/bitmap/Octree.hxx
similarity index 100%
rename from vcl/inc/octree.hxx
rename to vcl/inc/bitmap/Octree.hxx
diff --git a/vcl/inc/impoctree.hxx b/vcl/inc/bitmap/impoctree.hxx
similarity index 99%
rename from vcl/inc/impoctree.hxx
rename to vcl/inc/bitmap/impoctree.hxx
index 97de164ed405..b2f05b351c5a 100644
--- a/vcl/inc/impoctree.hxx
+++ b/vcl/inc/bitmap/impoctree.hxx
@@ -20,7 +20,7 @@
 #ifndef INCLUDED_VCL_INC_IMPOCTREE_HXX
 #define INCLUDED_VCL_INC_IMPOCTREE_HXX
 
-#include "octree.hxx"
+#include "Octree.hxx"
 
 class ImpErrorQuad
 {
diff --git a/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx b/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx
index 2f1fb9906a1f..ae066cc66cf6 100644
--- a/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx
+++ b/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx
@@ -14,7 +14,7 @@
 #include <vcl/BitmapSimpleColorQuantizationFilter.hxx>
 
 #include <bitmapwriteaccess.hxx>
-#include <impoctree.hxx>
+#include <bitmap/Octree.hxx>
 
 #include <cstdlib>
 
diff --git a/vcl/source/gdi/octree.cxx b/vcl/source/bitmap/Octree.cxx
similarity index 99%
rename from vcl/source/gdi/octree.cxx
rename to vcl/source/bitmap/Octree.cxx
index 4635067901f8..64914f76385e 100644
--- a/vcl/source/gdi/octree.cxx
+++ b/vcl/source/bitmap/Octree.cxx
@@ -22,8 +22,8 @@
 #include <rtl/alloc.h>
 #include <vcl/bitmapaccess.hxx>
 
-#include <octree.hxx>
-#include <impoctree.hxx>
+#include <bitmap/Octree.hxx>
+#include <bitmap/impoctree.hxx>
 
 static const sal_uInt8 pImplMask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
 
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index 23aa996b6a2d..71a3bc468876 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -32,13 +32,13 @@
 #endif
 #include <vcl/BitmapMonochromeFilter.hxx>
 
-#include <impoctree.hxx>
 #include <BitmapScaleSuperFilter.hxx>
 #include <BitmapScaleConvolutionFilter.hxx>
 #include <BitmapFastScaleFilter.hxx>
 #include <BitmapInterpolateScaleFilter.hxx>
 #include <bitmapwriteaccess.hxx>
-#include <octree.hxx>
+#include <bitmap/impoctree.hxx>
+#include <bitmap/Octree.hxx>
 #include <svdata.hxx>
 #include <salinst.hxx>
 #include <salbmp.hxx>


More information about the Libreoffice-commits mailing list