LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/vcl/inc - impoct.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 51 51 100.0 %
Date: 2013-07-09 Functions: 11 11 100.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_IMPOCT_HXX
      21             : #define _SV_IMPOCT_HXX
      22             : 
      23             : #include <vcl/octree.hxx>
      24             : 
      25             : // ----------------
      26             : // - ImpErrorQuad -
      27             : // ----------------
      28             : 
      29             : class ImpErrorQuad
      30             : {
      31             :     long                    nRed;
      32             :     long                    nGreen;
      33             :     long                    nBlue;
      34             : 
      35             : public:
      36             : 
      37       71265 :     inline                  ImpErrorQuad() {}
      38     2464769 :     inline                  ImpErrorQuad( const BitmapColor& rColor ) :
      39     2464769 :                                 nRed    ( (long) rColor.GetRed() << 5L ),
      40     2464769 :                                 nGreen  ( (long) rColor.GetGreen() << 5L ),
      41     4929538 :                                 nBlue   ( (long) rColor.GetBlue() << 5L ) {}
      42             : 
      43             :     inline void             operator=( const BitmapColor& rColor );
      44             :     inline ImpErrorQuad&    operator-=( const BitmapColor& rColor );
      45             : 
      46             :     inline void             ImplAddColorError1( const ImpErrorQuad& rErrQuad );
      47             :     inline void             ImplAddColorError3( const ImpErrorQuad& rErrQuad );
      48             :     inline void             ImplAddColorError5( const ImpErrorQuad& rErrQuad );
      49             :     inline void             ImplAddColorError7( const ImpErrorQuad& rErrQuad );
      50             : 
      51             :     inline BitmapColor      ImplGetColor();
      52             : };
      53             : 
      54             : // ------------------------------------------------------------------------
      55             : 
      56     2529589 : inline void ImpErrorQuad::operator=( const BitmapColor& rColor )
      57             : {
      58     2529589 :     nRed = (long) rColor.GetRed() << 5L;
      59     2529589 :     nGreen = (long) rColor.GetGreen() << 5L;
      60     2529589 :     nBlue = (long) rColor.GetBlue() << 5L;
      61     2529589 : }
      62             : 
      63             : // ------------------------------------------------------------------------
      64             : 
      65     2464769 : inline ImpErrorQuad& ImpErrorQuad::operator-=( const BitmapColor& rColor )
      66             : {
      67     2464769 :     nRed -= ( (long) rColor.GetRed() << 5L );
      68     2464769 :     nGreen -= ( (long) rColor.GetGreen() << 5L );
      69     2464769 :     nBlue -= ( (long) rColor.GetBlue() << 5L );
      70             : 
      71     2464769 :     return *this;
      72             : }
      73             : 
      74             : // ------------------------------------------------------------------------
      75             : 
      76     2464769 : inline void ImpErrorQuad::ImplAddColorError1( const ImpErrorQuad& rErrQuad )
      77             : {
      78     2464769 :     nRed += ( rErrQuad.nRed >> 4L );
      79     2464769 :     nGreen += ( rErrQuad.nGreen >> 4L );
      80     2464769 :     nBlue += ( rErrQuad.nBlue >> 4L );
      81     2464769 : }
      82             : 
      83             : // ------------------------------------------------------------------------
      84             : 
      85     2464769 : inline void ImpErrorQuad::ImplAddColorError3( const ImpErrorQuad& rErrQuad )
      86             : {
      87     2464769 :     nRed += ( rErrQuad.nRed * 3L >> 4L );
      88     2464769 :     nGreen += ( rErrQuad.nGreen * 3L >> 4L );
      89     2464769 :     nBlue += ( rErrQuad.nBlue * 3L >> 4L );
      90     2464769 : }
      91             : 
      92             : // ------------------------------------------------------------------------
      93             : 
      94     2464769 : inline void ImpErrorQuad::ImplAddColorError5( const ImpErrorQuad& rErrQuad )
      95             : {
      96     2464769 :     nRed += ( rErrQuad.nRed * 5L >> 4L );
      97     2464769 :     nGreen += ( rErrQuad.nGreen * 5L >> 4L );
      98     2464769 :     nBlue += ( rErrQuad.nBlue * 5L >> 4L );
      99     2464769 : }
     100             : 
     101             : // ------------------------------------------------------------------------
     102             : 
     103     2464769 : inline void ImpErrorQuad::ImplAddColorError7( const ImpErrorQuad& rErrQuad )
     104             : {
     105     2464769 :     nRed += ( rErrQuad.nRed * 7L >> 4L );
     106     2464769 :     nGreen += ( rErrQuad.nGreen * 7L >> 4L );
     107     2464769 :     nBlue += ( rErrQuad.nBlue *7L >> 4L );
     108     2464769 : }
     109             : 
     110             : // ------------------------------------------------------------------------
     111             : 
     112     2529589 : inline BitmapColor ImpErrorQuad::ImplGetColor()
     113             : {
     114     2529589 :     return BitmapColor( (sal_uInt8) ( ( nRed < 0L ? 0L : nRed > 8160L ? 8160L : nRed ) >> 5L ),
     115     2529589 :                         (sal_uInt8) ( ( nGreen < 0L ? 0L : nGreen > 8160L ? 8160L : nGreen ) >> 5L ),
     116     7588767 :                         (sal_uInt8) ( ( nBlue < 0L ? 0L : nBlue > 8160L ? 8160L : nBlue ) >> 5L ) );
     117             : }
     118             : 
     119             : // -------------
     120             : // - NodeCache -
     121             : // -------------
     122             : 
     123             : class ImpNodeCache
     124             : {
     125             :     OctreeNode*         pActNode;
     126             : 
     127             : public:
     128             : 
     129             :                         ImpNodeCache( const sal_uLong nInitSize );
     130             :                         ~ImpNodeCache();
     131             : 
     132             :     inline OctreeNode*  ImplGetFreeNode();
     133             :     inline void         ImplReleaseNode( OctreeNode* pNode );
     134             : };
     135             : 
     136             : // ------------------------------------------------------------------------
     137             : 
     138      166486 : inline OctreeNode* ImpNodeCache::ImplGetFreeNode()
     139             : {
     140             :     OctreeNode* pNode;
     141             : 
     142      166486 :     if ( !pActNode )
     143             :     {
     144       43574 :         pActNode = new NODE;
     145       43574 :         pActNode->pNextInCache = NULL;
     146             :     }
     147             : 
     148      166486 :     pNode = pActNode;
     149      166486 :     pActNode = pNode->pNextInCache;
     150      166486 :     memset( pNode, 0, sizeof( NODE ) );
     151             : 
     152      166486 :     return pNode;
     153             : }
     154             : 
     155             : // ------------------------------------------------------------------------
     156             : 
     157      166486 : inline void ImpNodeCache::ImplReleaseNode( OctreeNode* pNode )
     158             : {
     159      166486 :     pNode->pNextInCache = pActNode;
     160      166486 :     pActNode = pNode;
     161      166486 : }
     162             : 
     163             : #endif // _SV_IMPOCT_HXX
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10