LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/basegfx/raster - bpixelraster.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 17 100.0 %
Date: 2012-08-25 Functions: 8 8 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 5 6 83.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _BGFX_RASTER_BPIXELRASTER_HXX
      30                 :            : #define _BGFX_RASTER_BPIXELRASTER_HXX
      31                 :            : 
      32                 :            : #include <algorithm>
      33                 :            : #include <sal/types.h>
      34                 :            : #include <basegfx/pixel/bpixel.hxx>
      35                 :            : #include <rtl/memory.h>
      36                 :            : #include <basegfx/basegfxdllapi.h>
      37                 :            : 
      38                 :            : //////////////////////////////////////////////////////////////////////////////
      39                 :            : // predeclarations
      40                 :            : 
      41                 :            : //////////////////////////////////////////////////////////////////////////////
      42                 :            : 
      43                 :            : namespace basegfx
      44                 :            : {
      45                 :            :     class BPixelRaster
      46                 :            :     {
      47                 :            :     private:
      48                 :            :         // do not allow copy constructor and assignment operator
      49                 :            :         BPixelRaster(const BPixelRaster&);
      50                 :            :         BPixelRaster& operator=(const BPixelRaster&);
      51                 :            : 
      52                 :            :     protected:
      53                 :            :         sal_uInt32                  mnWidth;
      54                 :            :         sal_uInt32                  mnHeight;
      55                 :            :         sal_uInt32                  mnCount;
      56                 :            :         BPixel*                     mpContent;
      57                 :            : 
      58                 :            :     public:
      59                 :            :         // reset
      60                 :         15 :         void reset()
      61                 :            :         {
      62                 :         15 :             rtl_zeroMemory(mpContent, sizeof(BPixel) * mnCount);
      63                 :         15 :         }
      64                 :            : 
      65                 :            :         // constructor/destructor
      66                 :         15 :         BPixelRaster(sal_uInt32 nWidth, sal_uInt32 nHeight)
      67                 :            :         :   mnWidth(nWidth),
      68                 :            :             mnHeight(nHeight),
      69                 :            :             mnCount(nWidth * nHeight),
      70         [ +  + ]:    3905999 :             mpContent(new BPixel[mnCount])
      71                 :            :         {
      72                 :         15 :             reset();
      73                 :         15 :         }
      74                 :            : 
      75                 :         15 :         ~BPixelRaster()
      76                 :            :         {
      77 [ +  - ][ +  + ]:    3905999 :             delete [] mpContent;
      78                 :         15 :         }
      79                 :            : 
      80                 :            :         // coordinate calcs between X/Y and span
      81                 :      51530 :         sal_uInt32 getIndexFromXY(sal_uInt32 nX, sal_uInt32 nY) const { return (nX + (nY * mnWidth)); }
      82                 :            :         sal_uInt32 getXFromIndex(sal_uInt32 nIndex) const { return (nIndex % mnWidth); }
      83                 :            :         sal_uInt32 getYFromIndex(sal_uInt32 nIndex) const { return (nIndex / mnWidth); }
      84                 :            : 
      85                 :            :         // data access read
      86                 :     104498 :         sal_uInt32 getWidth() const { return mnWidth; }
      87                 :      52845 :         sal_uInt32 getHeight() const { return mnHeight; }
      88                 :            :         sal_uInt32 getCount() const { return mnCount; }
      89                 :            : 
      90                 :            :         // data access read only
      91                 :    3905984 :         const BPixel& getBPixel(sal_uInt32 nIndex) const
      92                 :            :         {
      93                 :            : #ifdef DBG_UTIL
      94                 :            :             if(nIndex >= mnCount)
      95                 :            :             {
      96                 :            :                 OSL_FAIL("getBPixel: Access out of range (!)");
      97                 :            :                 return BPixel::getEmptyBPixel();
      98                 :            :             }
      99                 :            : #endif
     100                 :    3905984 :             return mpContent[nIndex];
     101                 :            :         }
     102                 :            : 
     103                 :            :         // data access read/write
     104                 :    2183132 :         BPixel& getBPixel(sal_uInt32 nIndex)
     105                 :            :         {
     106                 :            : #ifdef DBG_UTIL
     107                 :            :             if(nIndex >= mnCount)
     108                 :            :             {
     109                 :            :                 OSL_FAIL("getBPixel: Access out of range (!)");
     110                 :            :                 return mpContent[0L];
     111                 :            :             }
     112                 :            : #endif
     113                 :    2183132 :             return mpContent[nIndex];
     114                 :            :         }
     115                 :            :     };
     116                 :            : } // end of namespace basegfx
     117                 :            : 
     118                 :            : #endif /* _BGFX_RASTER_BPIXELRASTER_HXX */
     119                 :            : 
     120                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10