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

Generated by: LCOV version 1.10