LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive2d - primitivetools2d.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 9 37 24.3 %
Date: 2015-06-13 12:38:46 Functions: 1 4 25.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             : #include <drawinglayer/primitive2d/primitivetools2d.hxx>
      21             : #include <basegfx/vector/b2dvector.hxx>
      22             : #include <drawinglayer/geometry/viewinformation2d.hxx>
      23             : 
      24             : 
      25             : 
      26             : namespace drawinglayer
      27             : {
      28             :     namespace primitive2d
      29             :     {
      30        2180 :         Primitive2DSequence DiscreteMetricDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      31             :         {
      32        2180 :             ::osl::MutexGuard aGuard( m_aMutex );
      33             : 
      34             :             // get the current DiscreteUnit, look at X and Y and use the maximum
      35        4360 :             const basegfx::B2DVector aDiscreteVector(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 1.0));
      36        2180 :             const double fDiscreteUnit(std::min(fabs(aDiscreteVector.getX()), fabs(aDiscreteVector.getY())));
      37             : 
      38        2180 :             if(getBuffered2DDecomposition().hasElements() && !basegfx::fTools::equal(fDiscreteUnit, getDiscreteUnit()))
      39             :             {
      40             :                 // conditions of last local decomposition have changed, delete
      41          14 :                 const_cast< DiscreteMetricDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
      42             :             }
      43             : 
      44        2180 :             if(!getBuffered2DDecomposition().hasElements())
      45             :             {
      46             :                 // remember new valid DiscreteUnit
      47        1253 :                 const_cast< DiscreteMetricDependentPrimitive2D* >(this)->updateDiscreteUnit(fDiscreteUnit);
      48             :             }
      49             : 
      50             :             // call base implementation
      51        4360 :             return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
      52             :         }
      53             :     } // end of namespace primitive2d
      54             : } // end of namespace drawinglayer
      55             : 
      56             : 
      57             : 
      58             : namespace drawinglayer
      59             : {
      60             :     namespace primitive2d
      61             :     {
      62           0 :         Primitive2DSequence ViewportDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      63             :         {
      64           0 :             ::osl::MutexGuard aGuard( m_aMutex );
      65             : 
      66             :             // get the current Viewport
      67           0 :             const basegfx::B2DRange& rViewport = rViewInformation.getViewport();
      68             : 
      69           0 :             if(getBuffered2DDecomposition().hasElements() && !rViewport.equal(getViewport()))
      70             :             {
      71             :                 // conditions of last local decomposition have changed, delete
      72           0 :                 const_cast< ViewportDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
      73             :             }
      74             : 
      75           0 :             if(!getBuffered2DDecomposition().hasElements())
      76             :             {
      77             :                 // remember new valid DiscreteUnit
      78           0 :                 const_cast< ViewportDependentPrimitive2D* >(this)->maViewport = rViewport;
      79             :             }
      80             : 
      81             :             // call base implementation
      82           0 :             return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
      83             :         }
      84             :     } // end of namespace primitive2d
      85             : } // end of namespace drawinglayer
      86             : 
      87             : 
      88             : 
      89             : namespace drawinglayer
      90             : {
      91             :     namespace primitive2d
      92             :     {
      93           0 :         Primitive2DSequence ViewTransformationDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      94             :         {
      95           0 :             ::osl::MutexGuard aGuard( m_aMutex );
      96             : 
      97             :             // get the current ViewTransformation
      98           0 :             const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation();
      99             : 
     100           0 :             if(getBuffered2DDecomposition().hasElements() && rViewTransformation != getViewTransformation())
     101             :             {
     102             :                 // conditions of last local decomposition have changed, delete
     103           0 :                 const_cast< ViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
     104             :             }
     105             : 
     106           0 :             if(!getBuffered2DDecomposition().hasElements())
     107             :             {
     108             :                 // remember new valid ViewTransformation
     109           0 :                 const_cast< ViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation;
     110             :             }
     111             : 
     112             :             // call base implementation
     113           0 :             return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
     114             :         }
     115             :     } // end of namespace primitive2d
     116             : } // end of namespace drawinglayer
     117             : 
     118             : 
     119             : 
     120             : namespace drawinglayer
     121             : {
     122             :     namespace primitive2d
     123             :     {
     124           0 :         Primitive2DSequence ObjectAndViewTransformationDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
     125             :         {
     126           0 :             ::osl::MutexGuard aGuard( m_aMutex );
     127             : 
     128             :             // get the current ViewTransfromation
     129           0 :             const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation();
     130             : 
     131           0 :             if(getBuffered2DDecomposition().hasElements() && rViewTransformation != getViewTransformation())
     132             :             {
     133             :                 // conditions of last local decomposition have changed, delete
     134           0 :                 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
     135             :             }
     136             : 
     137             :             // get the current ObjectTransformation
     138           0 :             const basegfx::B2DHomMatrix& rObjectTransformation = rViewInformation.getObjectTransformation();
     139             : 
     140           0 :             if(getBuffered2DDecomposition().hasElements() && rObjectTransformation != getObjectTransformation())
     141             :             {
     142             :                 // conditions of last local decomposition have changed, delete
     143           0 :                 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
     144             :             }
     145             : 
     146           0 :             if(!getBuffered2DDecomposition().hasElements())
     147             :             {
     148             :                 // remember new valid ViewTransformation, and ObjectTransformation
     149           0 :                 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation;
     150           0 :                 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maObjectTransformation = rObjectTransformation;
     151             :             }
     152             : 
     153             :             // call base implementation
     154           0 :             return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
     155             :         }
     156             :     } // end of namespace primitive2d
     157             : } // end of namespace drawinglayer
     158             : 
     159             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11