LCOV - code coverage report
Current view: top level - vcl/headless - svpvd.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 37 48 77.1 %
Date: 2014-04-11 Functions: 8 9 88.9 %
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             : #ifndef IOS
      21             : 
      22             : #include "headless/svpbmp.hxx"
      23             : #include "headless/svpvd.hxx"
      24             : #include "headless/svpgdi.hxx"
      25             : 
      26             : #include <basegfx/vector/b2ivector.hxx>
      27             : #include <basebmp/scanlineformats.hxx>
      28             : 
      29             : #include "stdio.h"
      30             : 
      31             : using namespace basegfx;
      32             : using namespace basebmp;
      33             : 
      34      221400 : SvpSalVirtualDevice::~SvpSalVirtualDevice()
      35             : {
      36      221400 : }
      37             : 
      38      118953 : SalGraphics* SvpSalVirtualDevice::AcquireGraphics()
      39             : {
      40      118953 :     SvpSalGraphics* pGraphics = new SvpSalGraphics();
      41      118953 :     pGraphics->setDevice( m_aDevice );
      42      118953 :     m_aGraphics.push_back( pGraphics );
      43      118953 :     return pGraphics;
      44             : }
      45             : 
      46      117381 : void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
      47             : {
      48      117381 :     m_aGraphics.remove( dynamic_cast<SvpSalGraphics*>(pGraphics) );
      49      117381 :     delete pGraphics;
      50      117381 : }
      51             : 
      52      141965 : bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
      53             : {
      54      141965 :     return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray() );
      55             : }
      56             : 
      57      141965 : bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer )
      58             : {
      59      141965 :     B2IVector aDevSize( nNewDX, nNewDY );
      60      141965 :     if( aDevSize.getX() == 0 )
      61           0 :         aDevSize.setX( 1 );
      62      141965 :     if( aDevSize.getY() == 0 )
      63           0 :         aDevSize.setY( 1 );
      64      141965 :     if( ! m_aDevice.get() || m_aDevice->getSize() != aDevSize )
      65             :     {
      66      141881 :         basebmp::Format nFormat = SVP_DEFAULT_BITMAP_FORMAT;
      67      141881 :         std::vector< basebmp::Color > aDevPal;
      68      141881 :         switch( m_nBitCount )
      69             :         {
      70       11621 :             case 1: nFormat = FORMAT_ONE_BIT_MSB_PAL;
      71       11621 :                 aDevPal.reserve(2);
      72       11621 :                 aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
      73       11621 :                 aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
      74       11621 :                 break;
      75           0 :             case 4: nFormat = FORMAT_FOUR_BIT_MSB_PAL; break;
      76         946 :             case 8: nFormat = FORMAT_EIGHT_BIT_PAL; break;
      77             : #ifdef OSL_BIGENDIAN
      78             :             case 16: nFormat = FORMAT_SIXTEEN_BIT_MSB_TC_MASK; break;
      79             : #else
      80           0 :             case 16: nFormat = FORMAT_SIXTEEN_BIT_LSB_TC_MASK; break;
      81             : #endif
      82        6221 :             case 24: nFormat = FORMAT_TWENTYFOUR_BIT_TC_MASK; break;
      83           0 :             case 32: nFormat = FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA; break;
      84             : #ifdef ANDROID
      85             :             case 0:  nFormat = FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA; break;
      86             : #else
      87      123093 :             case 0:  nFormat = FORMAT_TWENTYFOUR_BIT_TC_MASK; break;
      88             : #endif
      89             :         }
      90      425643 :         m_aDevice = aDevPal.empty()
      91             :                     ? ( pBuffer
      92             :                         ? createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
      93      130260 :                         : createBitmapDevice( aDevSize, false, nFormat )
      94             :                        )
      95      295383 :                     : createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
      96             : 
      97             :         // update device in existing graphics
      98      514470 :         for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();
      99      342980 :              it != m_aGraphics.end(); ++it )
     100      171490 :              (*it)->setDevice( m_aDevice );
     101             : 
     102             :     }
     103      141965 :     return true;
     104             : }
     105             : 
     106           0 : void SvpSalVirtualDevice::GetSize( long& rWidth, long& rHeight )
     107             : {
     108           0 :     if( m_aDevice.get() )
     109             :     {
     110           0 :         B2IVector aDevSize( m_aDevice->getSize() );
     111           0 :         rWidth = aDevSize.getX();
     112           0 :         rHeight = aDevSize.getY();
     113             :     }
     114             :     else
     115           0 :         rWidth = rHeight = 0;
     116         495 : }
     117             : 
     118             : #endif
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10