LCOV - code coverage report
Current view: top level - basebmp/source - polypolygonrenderer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 39 39 100.0 %
Date: 2012-08-25 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 34 48 70.8 %

           Branch data     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                 :            : #include "basebmp/polypolygonrenderer.hxx"
      21                 :            : 
      22                 :            : #include <algorithm>
      23                 :            : 
      24                 :            : 
      25                 :            : namespace basebmp
      26                 :            : {
      27                 :            : namespace detail
      28                 :            : {
      29                 :    3012078 :     sal_uInt32 setupGlobalEdgeTable( VectorOfVectorOfVertices&      rGET,
      30                 :            :                                      basegfx::B2DPolyPolygon const& rPolyPoly,
      31                 :            :                                      sal_Int32                      nMinY )
      32                 :            :     {
      33                 :    3012078 :         sal_Int32 const nNumScanlines( (sal_Int32)rGET.size() );
      34                 :            : 
      35                 :            :         // add all polygons to GET
      36 [ +  + ][ +  - ]:    6043180 :         for( sal_uInt32 i(0), nCount(rPolyPoly.count());
      37                 :            :              i<nCount;
      38                 :            :              ++i )
      39                 :            :         {
      40                 :            :             // add all vertices to GET
      41         [ +  - ]:    3031102 :             const basegfx::B2DPolygon& rPoly( rPolyPoly.getB2DPolygon(i) );
      42 [ +  - ][ +  + ]:   16892156 :             for( sal_uInt32 k(0), nVertices(rPoly.count());
      43                 :            :                  k<nVertices;
      44                 :            :                  ++k )
      45                 :            :             {
      46         [ +  - ]:   13861054 :                 const basegfx::B2DPoint& rP1( rPoly.getB2DPoint(k) );
      47         [ +  - ]:   13861054 :                 const basegfx::B2DPoint& rP2( rPoly.getB2DPoint( (k + 1) % nVertices ) );
      48                 :            : 
      49                 :   13861054 :                 const sal_Int32 nVertexYP1( basegfx::fround(rP1.getY()) );
      50                 :   13861054 :                 const sal_Int32 nVertexYP2( basegfx::fround(rP2.getY()) );
      51                 :            : 
      52                 :            :                 // insert only vertices which are not strictly
      53                 :            :                 // horizontal. Strictly horizontal vertices don't add
      54                 :            :                 // any information that is not already present - due
      55                 :            :                 // to their adjacent vertices.
      56         [ +  + ]:   13861054 :                 if(nVertexYP1 != nVertexYP2)
      57                 :            :                 {
      58         [ +  + ]:    6833780 :                     if( nVertexYP2 < nVertexYP1 )
      59                 :            :                     {
      60                 :    3416684 :                         const sal_Int32 nStartScanline(nVertexYP2 - nMinY);
      61                 :            : 
      62                 :            :                         // edge direction is upwards - add with swapped vertices
      63         [ +  + ]:    3416684 :                         if( nStartScanline < nNumScanlines )
      64         [ +  - ]:    3405359 :                             rGET[ nStartScanline ].push_back( Vertex(rP2, rP1, false) );
      65                 :            :                     }
      66                 :            :                     else
      67                 :            :                     {
      68                 :    3417096 :                         const sal_Int32 nStartScanline(nVertexYP1 - nMinY);
      69                 :            : 
      70         [ +  + ]:    3417096 :                         if( nStartScanline < nNumScanlines )
      71         [ +  - ]:    3376413 :                             rGET[ nStartScanline ].push_back( Vertex(rP1, rP2, true) );
      72                 :            :                     }
      73                 :            :                 }
      74                 :   13861054 :             }
      75         [ +  - ]:    3031102 :         }
      76                 :            : 
      77                 :            :         // now sort all scanlines individually, with increasing x
      78                 :            :         // coordinates
      79                 :    3012078 :         VectorOfVectorOfVertices::iterator       aIter( rGET.begin() );
      80                 :    3012078 :         const VectorOfVectorOfVertices::iterator aEnd( rGET.end() );
      81                 :    3012078 :         sal_uInt32                               nVertexCount(0);
      82                 :    3012078 :         RasterConvertVertexComparator            aComp;
      83 [ +  - ][ +  + ]:   81700041 :         while( aIter != aEnd )
      84                 :            :         {
      85                 :            :             std::sort( aIter->begin(),
      86                 :            :                        aIter->end(),
      87         [ +  - ]:   78687963 :                        aComp );
      88                 :   78687963 :             nVertexCount += aIter->size();
      89                 :            : 
      90                 :   78687963 :             ++aIter;
      91                 :            :         }
      92                 :            : 
      93                 :    3012078 :         return nVertexCount;
      94                 :            :     }
      95                 :            : 
      96                 :        261 :     void sortAET( VectorOfVertexPtr& rAETSrc,
      97                 :            :                   VectorOfVertexPtr& rAETDest )
      98                 :            :     {
      99 [ +  + ][ +  - ]:        261 :         static RasterConvertVertexComparator aComp;
     100                 :            : 
     101                 :        261 :         rAETDest.clear();
     102                 :            : 
     103                 :            :         // prune AET from ended edges
     104                 :        261 :         VectorOfVertexPtr::iterator iter( rAETSrc.begin() );
     105                 :        261 :         VectorOfVertexPtr::iterator const end( rAETSrc.end() );
     106 [ +  - ][ +  + ]:       1465 :         while( iter != end )
     107                 :            :         {
     108         [ +  + ]:       1204 :             if( (*iter)->mnYCounter > 0 )
     109         [ +  - ]:       1135 :                 rAETDest.push_back( *iter );
     110                 :       1204 :             ++iter;
     111                 :            :         }
     112                 :            : 
     113                 :            :         // stable sort is necessary, to avoid segment crossing where
     114                 :            :         // none was intended.
     115         [ +  - ]:        261 :         std::stable_sort( rAETDest.begin(), rAETDest.end(), aComp );
     116                 :        261 :     }
     117                 :            : 
     118                 :            : } // namespace detail
     119                 :            : } // namespace basebmp
     120                 :            : 
     121                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10