LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/vcl - octree.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 9 15 60.0 %
Date: 2013-07-09 Functions: 2 3 66.7 %
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             : #define OCTREE_BITS     5
      27             : #define OCTREE_BITS_1   10
      28             : 
      29             : typedef struct OctreeNode
      30             : {
      31             :     sal_uLong       nCount;
      32             :     sal_uLong       nRed;
      33             :     sal_uLong       nGreen;
      34             :     sal_uLong       nBlue;
      35             :     OctreeNode* pChild[ 8 ];
      36             :     OctreeNode* pNext;
      37             :     OctreeNode* pNextInCache;
      38             :     sal_uInt16      nPalIndex;
      39             :     sal_Bool        bLeaf;
      40             : } NODE;
      41             : 
      42             : typedef NODE*       PNODE;
      43             : typedef PNODE*      PPNODE;
      44             : 
      45             : class ImpNodeCache;
      46             : class BitmapReadAccess;
      47             : 
      48             : class VCL_PLUGIN_PUBLIC Octree
      49             : {
      50             : private:
      51             : 
      52             :     BitmapPalette               aPal;
      53             :     sal_uLong                       nMax;
      54             :     sal_uLong                       nLeafCount;
      55             :     sal_uLong                       nLevel;
      56             :     PNODE                       pTree;
      57             :     PNODE                       pReduce[ OCTREE_BITS + 1 ];
      58             :     BitmapColor*                pColor;
      59             :     ImpNodeCache*               pNodeCache;
      60             :     const BitmapReadAccess*     pAcc;
      61             :     sal_uInt16                      nPalIndex;
      62             : 
      63             :                                 Octree() {}
      64             : 
      65             :     void                        CreatePalette( PNODE pNode );
      66             :     void                        GetPalIndex( PNODE pNode );
      67             : 
      68             :     SAL_DLLPRIVATE void         ImplCreateOctree();
      69             :     SAL_DLLPRIVATE void         ImplDeleteOctree( PPNODE ppNode );
      70             :     SAL_DLLPRIVATE void         ImplAdd( PPNODE ppNode );
      71             :     SAL_DLLPRIVATE void         ImplReduce();
      72             : 
      73             : public:
      74             : 
      75             :                                 Octree( const BitmapReadAccess& rReadAcc, sal_uLong nColors );
      76             :                                 ~Octree();
      77             : 
      78             :     inline const BitmapPalette& GetPalette();
      79             :     inline sal_uInt16               GetBestPaletteIndex( const BitmapColor& rColor );
      80             : };
      81             : 
      82         469 : inline const BitmapPalette& Octree::GetPalette()
      83             : {
      84         469 :     aPal.SetEntryCount( (sal_uInt16) nLeafCount );
      85         469 :     nPalIndex = 0;
      86         469 :     CreatePalette( pTree );
      87         469 :     return aPal;
      88             : }
      89             : 
      90           0 : inline sal_uInt16 Octree::GetBestPaletteIndex( const BitmapColor& rColor )
      91             : {
      92           0 :     pColor = &(BitmapColor&) rColor;
      93           0 :     nPalIndex = 65535;
      94           0 :     nLevel = 0L;
      95           0 :     GetPalIndex( pTree );
      96           0 :     return nPalIndex;
      97             : }
      98             : 
      99             : class VCL_PLUGIN_PUBLIC InverseColorMap
     100             : {
     101             : private:
     102             : 
     103             :     sal_uInt8*              pBuffer;
     104             :     sal_uInt8*              pMap;
     105             :     const sal_uLong         nBits;
     106             : 
     107             : 
     108             :     SAL_DLLPRIVATE void ImplCreateBuffers( const sal_uLong nMax );
     109             : 
     110             : public:
     111             : 
     112             :     explicit            InverseColorMap( const BitmapPalette& rPal );
     113             :                         ~InverseColorMap();
     114             : 
     115             :     inline sal_uInt16       GetBestPaletteIndex( const BitmapColor& rColor );
     116             : };
     117             : 
     118     2529589 : inline sal_uInt16 InverseColorMap::GetBestPaletteIndex( const BitmapColor& rColor )
     119             : {
     120     5059178 :     return pMap[ ( ( (sal_uLong) rColor.GetRed() >> nBits ) << OCTREE_BITS_1 ) |
     121     5059178 :                  ( ( (sal_uLong) rColor.GetGreen() >> nBits ) << OCTREE_BITS ) |
     122     7588767 :                  ( (sal_uLong) rColor.GetBlue() >> nBits ) ];
     123             : }
     124             : 
     125             : #endif // _SV_OCTREE_HXX
     126             : 
     127             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10