LCOV - code coverage report
Current view: top level - include/basegfx/raster - bpixelraster.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 18 18 100.0 %
Date: 2014-11-03 Functions: 8 8 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_BASEGFX_RASTER_BPIXELRASTER_HXX
      21             : #define INCLUDED_BASEGFX_RASTER_BPIXELRASTER_HXX
      22             : 
      23             : #include <algorithm>
      24             : #include <string.h>
      25             : #include <sal/types.h>
      26             : #include <basegfx/pixel/bpixel.hxx>
      27             : #include <basegfx/basegfxdllapi.h>
      28             : 
      29             : 
      30             : // predeclarations
      31             : 
      32             : 
      33             : 
      34             : namespace basegfx
      35             : {
      36             :     class BPixelRaster
      37             :     {
      38             :     private:
      39             :         // do not allow copy constructor and assignment operator
      40             :         BPixelRaster(const BPixelRaster&);
      41             :         BPixelRaster& operator=(const BPixelRaster&);
      42             : 
      43             :     protected:
      44             :         sal_uInt32                  mnWidth;
      45             :         sal_uInt32                  mnHeight;
      46             :         sal_uInt32                  mnCount;
      47             :         BPixel*                     mpContent;
      48             : 
      49             :     public:
      50             :         // reset
      51          21 :         void reset()
      52             :         {
      53          21 :             memset(mpContent, 0, sizeof(BPixel) * mnCount);
      54          21 :         }
      55             : 
      56             :         // constructor/destructor
      57          21 :         BPixelRaster(sal_uInt32 nWidth, sal_uInt32 nHeight)
      58             :         :   mnWidth(nWidth),
      59             :             mnHeight(nHeight),
      60          21 :             mnCount(nWidth * nHeight),
      61          42 :             mpContent(new BPixel[mnCount])
      62             :         {
      63          21 :             reset();
      64          21 :         }
      65             : 
      66          21 :         ~BPixelRaster()
      67             :         {
      68          21 :             delete [] mpContent;
      69          21 :         }
      70             : 
      71             :         // coordinate calcs between X/Y and span
      72      227696 :         sal_uInt32 getIndexFromXY(sal_uInt32 nX, sal_uInt32 nY) const { return (nX + (nY * mnWidth)); }
      73             :         sal_uInt32 getXFromIndex(sal_uInt32 nIndex) const { return (nIndex % mnWidth); }
      74             :         sal_uInt32 getYFromIndex(sal_uInt32 nIndex) const { return (nIndex / mnWidth); }
      75             : 
      76             :         // data access read
      77      796100 :         sal_uInt32 getWidth() const { return mnWidth; }
      78      435734 :         sal_uInt32 getHeight() const { return mnHeight; }
      79             :         sal_uInt32 getCount() const { return mnCount; }
      80             : 
      81             :         // data access read only
      82     4228721 :         const BPixel& getBPixel(sal_uInt32 nIndex) const
      83             :         {
      84             :             assert(nIndex < mnCount && "Access out of range");
      85     4228721 :             return mpContent[nIndex];
      86             :         }
      87             : 
      88             :         // data access read/write
      89     3355808 :         BPixel& getBPixel(sal_uInt32 nIndex)
      90             :         {
      91             :             assert(nIndex < mnCount && "Access out of range");
      92     3355808 :             return mpContent[nIndex];
      93             :         }
      94             :     };
      95             : } // end of namespace basegfx
      96             : 
      97             : #endif // INCLUDED_BASEGFX_RASTER_BPIXELRASTER_HXX
      98             : 
      99             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10