LCOV - code coverage report
Current view: top level - drawinglayer/source/processor2d - vclhelperbufferdevice.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 60 61 98.4 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 68 130 52.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                 :            : #include <vclhelperbufferdevice.hxx>
      30                 :            : #include <basegfx/range/b2drange.hxx>
      31                 :            : #include <vcl/bitmapex.hxx>
      32                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      33                 :            : #include <tools/stream.hxx>
      34                 :            : 
      35                 :            : //////////////////////////////////////////////////////////////////////////////
      36                 :            : // support for rendering Bitmap and BitmapEx contents
      37                 :            : 
      38                 :            : namespace drawinglayer
      39                 :            : {
      40                 :       2913 :     impBufferDevice::impBufferDevice(
      41                 :            :         OutputDevice& rOutDev,
      42                 :            :         const basegfx::B2DRange& rRange,
      43                 :            :         bool bAddOffsetToMapping)
      44                 :            :     :   mrOutDev(rOutDev),
      45                 :            :         maContent(rOutDev),
      46                 :            :         mpMask(0L),
      47         [ +  - ]:       2913 :         mpAlpha(0L)
      48                 :            :     {
      49                 :       2913 :         basegfx::B2DRange aRangePixel(rRange);
      50 [ +  - ][ +  - ]:       2913 :         aRangePixel.transform(rOutDev.GetViewTransformation());
                 [ +  - ]
      51                 :            :         const Rectangle aRectPixel(
      52 [ +  - ][ +  - ]:       2913 :             (sal_Int32)floor(aRangePixel.getMinX()), (sal_Int32)floor(aRangePixel.getMinY()),
      53 [ +  - ][ +  - ]:       5826 :             (sal_Int32)ceil(aRangePixel.getMaxX()), (sal_Int32)ceil(aRangePixel.getMaxY()));
                 [ +  - ]
      54                 :       2913 :         const Point aEmptyPoint;
      55         [ +  - ]:       2913 :         maDestPixel = Rectangle(aEmptyPoint, rOutDev.GetOutputSizePixel());
      56         [ +  - ]:       2913 :         maDestPixel.Intersection(aRectPixel);
      57                 :            : 
      58 [ +  - ][ +  - ]:       2913 :         if(isVisible())
      59                 :            :         {
      60 [ +  - ][ +  - ]:       2913 :             maContent.SetOutputSizePixel(maDestPixel.GetSize(), false);
      61                 :            : 
      62                 :            :             // #i93485# assert when copying from window to VDev is used
      63                 :            :             OSL_ENSURE(rOutDev.GetOutDevType() != OUTDEV_WINDOW,
      64                 :            :                 "impBufferDevice render helper: Copying from Window to VDev, this should be avoided (!)");
      65                 :            : 
      66                 :       2913 :             const bool bWasEnabledSrc(rOutDev.IsMapModeEnabled());
      67         [ +  - ]:       2913 :             rOutDev.EnableMapMode(false);
      68 [ +  - ][ +  - ]:       2913 :             maContent.DrawOutDev(aEmptyPoint, maDestPixel.GetSize(), maDestPixel.TopLeft(), maDestPixel.GetSize(), rOutDev);
                 [ +  - ]
      69         [ +  - ]:       2913 :             rOutDev.EnableMapMode(bWasEnabledSrc);
      70                 :            : 
      71         [ +  - ]:       2913 :             MapMode aNewMapMode(rOutDev.GetMapMode());
      72                 :            : 
      73         [ +  - ]:       2913 :             if(bAddOffsetToMapping)
      74                 :            :             {
      75         [ +  - ]:       2913 :                 const Point aLogicTopLeft(rOutDev.PixelToLogic(maDestPixel.TopLeft()));
      76         [ +  - ]:       2913 :                 aNewMapMode.SetOrigin(Point(-aLogicTopLeft.X(), -aLogicTopLeft.Y()));
      77                 :            :             }
      78                 :            : 
      79         [ +  - ]:       2913 :             maContent.SetMapMode(aNewMapMode);
      80                 :            : 
      81                 :            :             // copy AA flag for new target
      82 [ +  - ][ +  - ]:       2913 :             maContent.SetAntialiasing(mrOutDev.GetAntialiasing());
      83                 :            :         }
      84                 :       2913 :     }
      85                 :            : 
      86                 :       2913 :     impBufferDevice::~impBufferDevice()
      87                 :            :     {
      88 [ +  + ][ +  - ]:       2913 :         delete mpMask;
      89 [ +  + ][ +  - ]:       2913 :         delete mpAlpha;
      90                 :       2913 :     }
      91                 :            : 
      92                 :       2913 :     void impBufferDevice::paint(double fTrans)
      93                 :            :     {
      94                 :       2913 :         const Point aEmptyPoint;
      95                 :       2913 :         const Size aSizePixel(maContent.GetOutputSizePixel());
      96                 :       2913 :         const bool bWasEnabledDst(mrOutDev.IsMapModeEnabled());
      97                 :            : 
      98         [ +  - ]:       2913 :         mrOutDev.EnableMapMode(false);
      99         [ +  - ]:       2913 :         maContent.EnableMapMode(false);
     100         [ +  - ]:       2913 :         Bitmap aContent(maContent.GetBitmap(aEmptyPoint, aSizePixel));
     101                 :            : 
     102         [ +  + ]:       2913 :         if(mpAlpha)
     103                 :            :         {
     104         [ +  - ]:       1638 :             mpAlpha->EnableMapMode(false);
     105 [ +  - ][ +  - ]:       1638 :             const AlphaMask aAlphaMask(mpAlpha->GetBitmap(aEmptyPoint, aSizePixel));
                 [ +  - ]
     106                 :            : 
     107 [ +  - ][ +  - ]:       1638 :             mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask));
         [ +  - ][ +  - ]
     108                 :            :         }
     109         [ +  + ]:       1275 :         else if(mpMask)
     110                 :            :         {
     111         [ +  - ]:       1026 :             mpMask->EnableMapMode(false);
     112         [ +  - ]:       1026 :             const Bitmap aMask(mpMask->GetBitmap(aEmptyPoint, aSizePixel));
     113                 :            : 
     114 [ +  - ][ +  - ]:       1026 :             mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aMask));
         [ +  - ][ +  - ]
     115                 :            :         }
     116         [ +  - ]:        249 :         else if(0.0 != fTrans)
     117                 :            :         {
     118                 :        249 :             sal_uInt8 nMaskValue((sal_uInt8)basegfx::fround(fTrans * 255.0));
     119         [ +  - ]:        249 :             const AlphaMask aAlphaMask(aSizePixel, &nMaskValue);
     120 [ +  - ][ +  - ]:        249 :             mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask));
         [ +  - ][ +  - ]
     121                 :            :         }
     122                 :            :         else
     123                 :            :         {
     124         [ #  # ]:          0 :             mrOutDev.DrawBitmap(maDestPixel.TopLeft(), aContent);
     125                 :            :         }
     126                 :            : 
     127 [ +  - ][ +  - ]:       2913 :         mrOutDev.EnableMapMode(bWasEnabledDst);
     128                 :       2913 :     }
     129                 :            : 
     130                 :       1026 :     VirtualDevice& impBufferDevice::getMask()
     131                 :            :     {
     132         [ +  - ]:       1026 :         if(!mpMask)
     133                 :            :         {
     134         [ +  - ]:       1026 :             mpMask = new VirtualDevice(mrOutDev, 1);
     135         [ +  - ]:       1026 :             mpMask->SetOutputSizePixel(maDestPixel.GetSize(), true);
     136                 :       1026 :             mpMask->SetMapMode(maContent.GetMapMode());
     137                 :            : 
     138                 :            :             // do NOT copy AA flag for mask!
     139                 :            :         }
     140                 :            : 
     141                 :       1026 :         return *mpMask;
     142                 :            :     }
     143                 :            : 
     144                 :       1638 :     VirtualDevice& impBufferDevice::getTransparence()
     145                 :            :     {
     146         [ +  - ]:       1638 :         if(!mpAlpha)
     147                 :            :         {
     148         [ +  - ]:       1638 :             mpAlpha = new VirtualDevice();
     149         [ +  - ]:       1638 :             mpAlpha->SetOutputSizePixel(maDestPixel.GetSize(), true);
     150                 :       1638 :             mpAlpha->SetMapMode(maContent.GetMapMode());
     151                 :            : 
     152                 :            :             // copy AA flag for new target; masking needs to be smooth
     153                 :       1638 :             mpAlpha->SetAntialiasing(maContent.GetAntialiasing());
     154                 :            :         }
     155                 :            : 
     156                 :       1638 :         return *mpAlpha;
     157                 :            :     }
     158                 :            : } // end of namespace drawinglayer
     159                 :            : 
     160                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10