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

Generated by: LCOV version 1.11