LCOV - code coverage report
Current view: top level - include/basegfx/raster - bpixelraster.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 18 18 100.0 %
Date: 2015-06-13 12:38:46 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             : namespace basegfx
      30             : {
      31             :     class BPixelRaster
      32             :     {
      33             :     private:
      34             :         BPixelRaster(const BPixelRaster&) SAL_DELETED_FUNCTION;
      35             :         BPixelRaster& operator=(const BPixelRaster&) SAL_DELETED_FUNCTION;
      36             : 
      37             :     protected:
      38             :         sal_uInt32                  mnWidth;
      39             :         sal_uInt32                  mnHeight;
      40             :         sal_uInt32                  mnCount;
      41             :         BPixel*                     mpContent;
      42             : 
      43             :     public:
      44             :         // reset
      45          13 :         void reset()
      46             :         {
      47          13 :             memset(mpContent, 0, sizeof(BPixel) * mnCount);
      48          13 :         }
      49             : 
      50             :         // constructor/destructor
      51          13 :         BPixelRaster(sal_uInt32 nWidth, sal_uInt32 nHeight)
      52             :         :   mnWidth(nWidth),
      53             :             mnHeight(nHeight),
      54          13 :             mnCount(nWidth * nHeight),
      55          26 :             mpContent(new BPixel[mnCount])
      56             :         {
      57          13 :             reset();
      58          13 :         }
      59             : 
      60          13 :         ~BPixelRaster()
      61             :         {
      62          13 :             delete [] mpContent;
      63          13 :         }
      64             : 
      65             :         // coordinate calcs between X/Y and span
      66      117939 :         sal_uInt32 getIndexFromXY(sal_uInt32 nX, sal_uInt32 nY) const { return (nX + (nY * mnWidth)); }
      67             :         sal_uInt32 getXFromIndex(sal_uInt32 nIndex) const { return (nIndex % mnWidth); }
      68             :         sal_uInt32 getYFromIndex(sal_uInt32 nIndex) const { return (nIndex / mnWidth); }
      69             : 
      70             :         // data access read
      71      352328 :         sal_uInt32 getWidth() const { return mnWidth; }
      72      194694 :         sal_uInt32 getHeight() const { return mnHeight; }
      73             :         sal_uInt32 getCount() const { return mnCount; }
      74             : 
      75             :         // data access read only
      76     2825320 :         const BPixel& getBPixel(sal_uInt32 nIndex) const
      77             :         {
      78             :             assert(nIndex < mnCount && "Access out of range");
      79     2825320 :             return mpContent[nIndex];
      80             :         }
      81             : 
      82             :         // data access read/write
      83     2887446 :         BPixel& getBPixel(sal_uInt32 nIndex)
      84             :         {
      85             :             assert(nIndex < mnCount && "Access out of range");
      86     2887446 :             return mpContent[nIndex];
      87             :         }
      88             :     };
      89             : } // end of namespace basegfx
      90             : 
      91             : #endif // INCLUDED_BASEGFX_RASTER_BPIXELRASTER_HXX
      92             : 
      93             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11