LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/vcl - octree.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 15 0.0 %
Date: 2012-12-27 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef _SV_OCTREE_HXX
      21             : #define _SV_OCTREE_HXX
      22             : 
      23             : #include <vcl/salbtype.hxx>
      24             : #include <vcl/dllapi.h>
      25             : 
      26             : // -----------
      27             : // - Defines -
      28             : // -----------
      29             : 
      30             : #define OCTREE_BITS     5
      31             : #define OCTREE_BITS_1   10
      32             : 
      33             : // --------------
      34             : // - OctreeNode -
      35             : // --------------
      36             : 
      37             : typedef struct OctreeNode
      38             : {
      39             :     sal_uLong       nCount;
      40             :     sal_uLong       nRed;
      41             :     sal_uLong       nGreen;
      42             :     sal_uLong       nBlue;
      43             :     OctreeNode* pChild[ 8 ];
      44             :     OctreeNode* pNext;
      45             :     OctreeNode* pNextInCache;
      46             :     sal_uInt16      nPalIndex;
      47             :     sal_Bool        bLeaf;
      48             : } NODE;
      49             : 
      50             : typedef NODE*       PNODE;
      51             : typedef PNODE*      PPNODE;
      52             : 
      53             : // ----------
      54             : // - Octree -
      55             : // ----------
      56             : 
      57             : class ImpNodeCache;
      58             : class BitmapReadAccess;
      59             : 
      60             : class VCL_PLUGIN_PUBLIC Octree
      61             : {
      62             : private:
      63             : 
      64             :     BitmapPalette               aPal;
      65             :     sal_uLong                       nMax;
      66             :     sal_uLong                       nLeafCount;
      67             :     sal_uLong                       nLevel;
      68             :     PNODE                       pTree;
      69             :     PNODE                       pReduce[ OCTREE_BITS + 1 ];
      70             :     BitmapColor*                pColor;
      71             :     ImpNodeCache*               pNodeCache;
      72             :     const BitmapReadAccess*     pAcc;
      73             :     sal_uInt16                      nPalIndex;
      74             : 
      75             :                                 Octree() {}
      76             : 
      77             :     void                        CreatePalette( PNODE pNode );
      78             :     void                        GetPalIndex( PNODE pNode );
      79             : 
      80             :     SAL_DLLPRIVATE void         ImplCreateOctree();
      81             :     SAL_DLLPRIVATE void         ImplDeleteOctree( PPNODE ppNode );
      82             :     SAL_DLLPRIVATE void         ImplAdd( PPNODE ppNode );
      83             :     SAL_DLLPRIVATE void         ImplReduce();
      84             : 
      85             : public:
      86             : 
      87             :                                 Octree( const BitmapReadAccess& rReadAcc, sal_uLong nColors );
      88             :                                 ~Octree();
      89             : 
      90             :     inline const BitmapPalette& GetPalette();
      91             :     inline sal_uInt16               GetBestPaletteIndex( const BitmapColor& rColor );
      92             : };
      93             : 
      94             : // ------------------------------------------------------------------------
      95             : 
      96           0 : inline const BitmapPalette& Octree::GetPalette()
      97             : {
      98           0 :     aPal.SetEntryCount( (sal_uInt16) nLeafCount );
      99           0 :     nPalIndex = 0;
     100           0 :     CreatePalette( pTree );
     101           0 :     return aPal;
     102             : }
     103             : 
     104             : // ------------------------------------------------------------------------
     105             : 
     106           0 : inline sal_uInt16 Octree::GetBestPaletteIndex( const BitmapColor& rColor )
     107             : {
     108           0 :     pColor = &(BitmapColor&) rColor;
     109           0 :     nPalIndex = 65535;
     110           0 :     nLevel = 0L;
     111           0 :     GetPalIndex( pTree );
     112           0 :     return nPalIndex;
     113             : }
     114             : 
     115             : // -------------------
     116             : // - InverseColorMap -
     117             : // -------------------
     118             : 
     119             : class VCL_PLUGIN_PUBLIC InverseColorMap
     120             : {
     121             : private:
     122             : 
     123             :     sal_uInt8*              pBuffer;
     124             :     sal_uInt8*              pMap;
     125             :     const sal_uLong         nBits;
     126             : 
     127             : 
     128             :     SAL_DLLPRIVATE void ImplCreateBuffers( const sal_uLong nMax );
     129             : 
     130             : public:
     131             : 
     132             :     explicit            InverseColorMap( const BitmapPalette& rPal );
     133             :                         ~InverseColorMap();
     134             : 
     135             :     inline sal_uInt16       GetBestPaletteIndex( const BitmapColor& rColor );
     136             : };
     137             : 
     138             : // ------------------------------------------------------------------------
     139             : 
     140           0 : inline sal_uInt16 InverseColorMap::GetBestPaletteIndex( const BitmapColor& rColor )
     141             : {
     142           0 :     return pMap[ ( ( (sal_uLong) rColor.GetRed() >> nBits ) << OCTREE_BITS_1 ) |
     143           0 :                  ( ( (sal_uLong) rColor.GetGreen() >> nBits ) << OCTREE_BITS ) |
     144           0 :                  ( (sal_uLong) rColor.GetBlue() >> nBits ) ];
     145             : }
     146             : 
     147             : #endif // _SV_OCTREE_HXX
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10