LCOV - code coverage report
Current view: top level - vcl/inc - impoct.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 54 54 100.0 %
Date: 2015-06-13 12:38:46 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      106225 :     ImpErrorQuad()
      36             :         : nRed(0)
      37             :         , nGreen(0)
      38      106225 :         , nBlue(0)
      39             :     {
      40      106225 :     }
      41             : 
      42     7101637 :     ImpErrorQuad( const BitmapColor& rColor )
      43     7101637 :         : nRed( (long) rColor.GetRed() << 5L )
      44     7101637 :         , nGreen( (long) rColor.GetGreen() << 5L )
      45    14203274 :         , nBlue( (long) rColor.GetBlue() << 5L )
      46             :     {
      47     7101637 :     }
      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     7209175 : inline void ImpErrorQuad::operator=( const BitmapColor& rColor )
      61             : {
      62     7209175 :     nRed = (long) rColor.GetRed() << 5L;
      63     7209175 :     nGreen = (long) rColor.GetGreen() << 5L;
      64     7209175 :     nBlue = (long) rColor.GetBlue() << 5L;
      65     7209175 : }
      66             : 
      67     7101637 : inline ImpErrorQuad& ImpErrorQuad::operator-=( const BitmapColor& rColor )
      68             : {
      69     7101637 :     nRed -= ( (long) rColor.GetRed() << 5L );
      70     7101637 :     nGreen -= ( (long) rColor.GetGreen() << 5L );
      71     7101637 :     nBlue -= ( (long) rColor.GetBlue() << 5L );
      72             : 
      73     7101637 :     return *this;
      74             : }
      75             : 
      76     7101637 : inline void ImpErrorQuad::ImplAddColorError1( const ImpErrorQuad& rErrQuad )
      77             : {
      78     7101637 :     nRed += ( rErrQuad.nRed >> 4L );
      79     7101637 :     nGreen += ( rErrQuad.nGreen >> 4L );
      80     7101637 :     nBlue += ( rErrQuad.nBlue >> 4L );
      81     7101637 : }
      82             : 
      83     7101637 : inline void ImpErrorQuad::ImplAddColorError3( const ImpErrorQuad& rErrQuad )
      84             : {
      85     7101637 :     nRed += ( rErrQuad.nRed * 3L >> 4L );
      86     7101637 :     nGreen += ( rErrQuad.nGreen * 3L >> 4L );
      87     7101637 :     nBlue += ( rErrQuad.nBlue * 3L >> 4L );
      88     7101637 : }
      89             : 
      90     7101637 : inline void ImpErrorQuad::ImplAddColorError5( const ImpErrorQuad& rErrQuad )
      91             : {
      92     7101637 :     nRed += ( rErrQuad.nRed * 5L >> 4L );
      93     7101637 :     nGreen += ( rErrQuad.nGreen * 5L >> 4L );
      94     7101637 :     nBlue += ( rErrQuad.nBlue * 5L >> 4L );
      95     7101637 : }
      96             : 
      97     7101637 : inline void ImpErrorQuad::ImplAddColorError7( const ImpErrorQuad& rErrQuad )
      98             : {
      99     7101637 :     nRed += ( rErrQuad.nRed * 7L >> 4L );
     100     7101637 :     nGreen += ( rErrQuad.nGreen * 7L >> 4L );
     101     7101637 :     nBlue += ( rErrQuad.nBlue *7L >> 4L );
     102     7101637 : }
     103             : 
     104     7209175 : inline BitmapColor ImpErrorQuad::ImplGetColor()
     105             : {
     106     7209175 :     return BitmapColor( (sal_uInt8) ( ( nRed < 0L ? 0L : nRed > 8160L ? 8160L : nRed ) >> 5L ),
     107     7209175 :                         (sal_uInt8) ( ( nGreen < 0L ? 0L : nGreen > 8160L ? 8160L : nGreen ) >> 5L ),
     108    21627525 :                         (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      172370 : inline OctreeNode* ImpNodeCache::ImplGetFreeNode()
     127             : {
     128             :     OctreeNode* pNode;
     129             : 
     130      172370 :     if ( !pActNode )
     131             :     {
     132       42071 :         pActNode = new NODE;
     133       42071 :         pActNode->pNextInCache = NULL;
     134             :     }
     135             : 
     136      172370 :     pNode = pActNode;
     137      172370 :     pActNode = pNode->pNextInCache;
     138      172370 :     memset( pNode, 0, sizeof( NODE ) );
     139             : 
     140      172370 :     return pNode;
     141             : }
     142             : 
     143      172370 : inline void ImpNodeCache::ImplReleaseNode( OctreeNode* pNode )
     144             : {
     145      172370 :     pNode->pNextInCache = pActNode;
     146      172370 :     pActNode = pNode;
     147      172370 : }
     148             : 
     149             : #endif // INCLUDED_VCL_INC_IMPOCT_HXX
     150             : 
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11