LCOV - code coverage report
Current view: top level - vcl/source/outdev - mask.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 55 1.8 %
Date: 2014-11-03 Functions: 2 6 33.3 %
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 <vcl/outdev.hxx>
      21             : #include <vcl/virdev.hxx>
      22             : 
      23             : #include <salgdi.hxx>
      24             : #include <impbmp.hxx>
      25             : #include <outdata.hxx>
      26             : 
      27             : extern const sal_uLong nVCLRLut[ 6 ];
      28             : extern const sal_uLong nVCLGLut[ 6 ];
      29             : extern const sal_uLong nVCLBLut[ 6 ];
      30             : extern const sal_uLong nVCLDitherLut[ 256 ];
      31             : extern const sal_uLong nVCLLut[ 256 ];
      32             : 
      33           0 : void OutputDevice::DrawMask( const Point& rDestPt,
      34             :                              const Bitmap& rBitmap, const Color& rMaskColor )
      35             : {
      36           0 :     const Size aSizePix( rBitmap.GetSizePixel() );
      37           0 :     DrawMask( rDestPt, PixelToLogic( aSizePix ), Point(), aSizePix, rBitmap, rMaskColor, META_MASK_ACTION );
      38           0 : }
      39             : 
      40           0 : void OutputDevice::DrawMask( const Point& rDestPt, const Size& rDestSize,
      41             :                              const Bitmap& rBitmap, const Color& rMaskColor )
      42             : {
      43           0 :     DrawMask( rDestPt, rDestSize, Point(), rBitmap.GetSizePixel(), rBitmap, rMaskColor, META_MASKSCALE_ACTION );
      44           0 : }
      45             : 
      46           0 : void OutputDevice::DrawMask( const Point& rDestPt, const Size& rDestSize,
      47             :                              const Point& rSrcPtPixel, const Size& rSrcSizePixel,
      48             :                              const Bitmap& rBitmap, const Color& rMaskColor,
      49             :                              const sal_uLong nAction )
      50             : {
      51           0 :     if( ImplIsRecordLayout() )
      52           0 :         return;
      53             : 
      54           0 :     if( ROP_INVERT == meRasterOp )
      55             :     {
      56           0 :         DrawRect( Rectangle( rDestPt, rDestSize ) );
      57           0 :         return;
      58             :     }
      59             : 
      60           0 :     if ( mpMetaFile )
      61             :     {
      62           0 :         switch( nAction )
      63             :         {
      64             :             case( META_MASK_ACTION ):
      65             :                 mpMetaFile->AddAction( new MetaMaskAction( rDestPt,
      66           0 :                     rBitmap, rMaskColor ) );
      67           0 :             break;
      68             : 
      69             :             case( META_MASKSCALE_ACTION ):
      70             :                 mpMetaFile->AddAction( new MetaMaskScaleAction( rDestPt,
      71           0 :                     rDestSize, rBitmap, rMaskColor ) );
      72           0 :             break;
      73             : 
      74             :             case( META_MASKSCALEPART_ACTION ):
      75             :                 mpMetaFile->AddAction( new MetaMaskScalePartAction( rDestPt, rDestSize,
      76           0 :                     rSrcPtPixel, rSrcSizePixel, rBitmap, rMaskColor ) );
      77           0 :             break;
      78             :         }
      79             :     }
      80             : 
      81           0 :     if ( !IsDeviceOutputNecessary() )
      82           0 :         return;
      83             : 
      84           0 :     if ( !mpGraphics )
      85           0 :         if ( !AcquireGraphics() )
      86           0 :             return;
      87             : 
      88           0 :     if ( mbInitClipRegion )
      89           0 :         InitClipRegion();
      90             : 
      91           0 :     if ( mbOutputClipped )
      92           0 :         return;
      93             : 
      94           0 :     DrawDeviceMask( rBitmap, rMaskColor, rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel );
      95             : 
      96             : }
      97             : 
      98           0 : void OutputDevice::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor,
      99             :                               const Point& rDestPt, const Size& rDestSize,
     100             :                               const Point& rSrcPtPixel, const Size& rSrcSizePixel )
     101             : {
     102           0 :     const ImpBitmap* pImpBmp = rMask.ImplGetImpBitmap();
     103           0 :     if ( pImpBmp )
     104             :     {
     105             :         SalTwoRect aPosAry;
     106             : 
     107           0 :         aPosAry.mnSrcX = rSrcPtPixel.X();
     108           0 :         aPosAry.mnSrcY = rSrcPtPixel.Y();
     109           0 :         aPosAry.mnSrcWidth = rSrcSizePixel.Width();
     110           0 :         aPosAry.mnSrcHeight = rSrcSizePixel.Height();
     111           0 :         aPosAry.mnDestX = ImplLogicXToDevicePixel( rDestPt.X() );
     112           0 :         aPosAry.mnDestY = ImplLogicYToDevicePixel( rDestPt.Y() );
     113           0 :         aPosAry.mnDestWidth = ImplLogicWidthToDevicePixel( rDestSize.Width() );
     114           0 :         aPosAry.mnDestHeight = ImplLogicHeightToDevicePixel( rDestSize.Height() );
     115             : 
     116             :         // we don't want to mirror via cooridates
     117           0 :         const sal_uLong nMirrFlags = AdjustTwoRect( aPosAry, pImpBmp->ImplGetSize() );
     118             : 
     119             :         // check if output is necessary
     120           0 :         if( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight )
     121             :         {
     122             : 
     123           0 :             if( nMirrFlags )
     124             :             {
     125           0 :                 Bitmap aTmp( rMask );
     126           0 :                 aTmp.Mirror( nMirrFlags );
     127           0 :                 mpGraphics->DrawMask( aPosAry, *aTmp.ImplGetImpBitmap()->ImplGetSalBitmap(),
     128           0 :                                       ImplColorToSal( rMaskColor ) , this);
     129             :             }
     130             :             else
     131           0 :                 mpGraphics->DrawMask( aPosAry, *pImpBmp->ImplGetSalBitmap(),
     132           0 :                                       ImplColorToSal( rMaskColor ), this );
     133             : 
     134             :         }
     135             :     }
     136             : 
     137             :     // TODO: Use mask here
     138           0 :     if( mpAlphaVDev )
     139             :     {
     140           0 :         const Bitmap& rAlphaMask( rMask.CreateMask( rMaskColor ) );
     141             : 
     142             :         // #i25167# Restrict mask painting to _opaque_ areas
     143             :         // of the mask, otherwise we spoil areas where no
     144             :         // bitmap content was ever visible. Interestingly
     145             :         // enough, this can be achieved by taking the mask as
     146             :         // the transparency mask of itself
     147             :         mpAlphaVDev->DrawBitmapEx( rDestPt,
     148             :                                    rDestSize,
     149             :                                    rSrcPtPixel,
     150             :                                    rSrcSizePixel,
     151           0 :                                    BitmapEx( rAlphaMask, rMask ) );
     152             :     }
     153        1233 : }
     154             : 
     155             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10