LCOV - code coverage report
Current view: top level - libreoffice/vcl/headless - svpvd.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 35 48 72.9 %
Date: 2012-12-17 Functions: 6 7 85.7 %
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 "headless/svpvd.hxx"
      21             : #include "headless/svpgdi.hxx"
      22             : 
      23             : #include <basegfx/vector/b2ivector.hxx>
      24             : #include <basebmp/scanlineformats.hxx>
      25             : 
      26             : #include "stdio.h"
      27             : 
      28             : using namespace basegfx;
      29             : using namespace basebmp;
      30             : 
      31       25644 : SvpSalVirtualDevice::~SvpSalVirtualDevice()
      32             : {
      33       25644 : }
      34             : 
      35       15926 : SalGraphics* SvpSalVirtualDevice::GetGraphics()
      36             : {
      37       15926 :     SvpSalGraphics* pGraphics = new SvpSalGraphics();
      38       15926 :     pGraphics->setDevice( m_aDevice );
      39       15926 :     m_aGraphics.push_back( pGraphics );
      40       15926 :     return pGraphics;
      41             : }
      42             : 
      43       13230 : void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
      44             : {
      45       13230 :     m_aGraphics.remove( dynamic_cast<SvpSalGraphics*>(pGraphics) );
      46       13230 :     delete pGraphics;
      47       13230 : }
      48             : 
      49       17285 : sal_Bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
      50             : {
      51       17285 :     return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray() );
      52             : }
      53             : 
      54       17285 : sal_Bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer )
      55             : {
      56       17285 :     B2IVector aDevSize( nNewDX, nNewDY );
      57       17285 :     if( aDevSize.getX() == 0 )
      58           0 :         aDevSize.setX( 1 );
      59       17285 :     if( aDevSize.getY() == 0 )
      60           0 :         aDevSize.setY( 1 );
      61       17285 :     if( ! m_aDevice.get() || m_aDevice->getSize() != aDevSize )
      62             :     {
      63       17283 :         sal_uInt32 nFormat = SVP_DEFAULT_BITMAP_FORMAT;
      64       17283 :         std::vector< basebmp::Color > aDevPal;
      65       17283 :         switch( m_nBitCount )
      66             :         {
      67         918 :             case 1: nFormat = Format::ONE_BIT_MSB_PAL;
      68         918 :                 aDevPal.reserve(2);
      69         918 :                 aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
      70         918 :                 aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
      71         918 :                 break;
      72           0 :             case 4: nFormat = Format::FOUR_BIT_MSB_PAL; break;
      73           0 :             case 8: nFormat = Format::EIGHT_BIT_PAL; break;
      74             : #ifdef OSL_BIGENDIAN
      75             :             case 16: nFormat = Format::SIXTEEN_BIT_MSB_TC_MASK; break;
      76             : #else
      77           0 :             case 16: nFormat = Format::SIXTEEN_BIT_LSB_TC_MASK; break;
      78             : #endif
      79         332 :             case 24: nFormat = Format::TWENTYFOUR_BIT_TC_MASK; break;
      80           0 :             case 32: nFormat = Format::THIRTYTWO_BIT_TC_MASK; break;
      81             : #if defined(ANDROID) || defined(IOS)
      82             :             case 0:  nFormat = Format::THIRTYTWO_BIT_TC_MASK_RGBA; break;
      83             : #else
      84       16033 :             case 0:  nFormat = Format::TWENTYFOUR_BIT_TC_MASK; break;
      85             : #endif
      86             :         }
      87       17283 :         m_aDevice = aDevPal.empty()
      88             :                     ? ( pBuffer
      89             :                         ? createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
      90       16365 :                         : createBitmapDevice( aDevSize, false, nFormat )
      91             :                        )
      92       33648 :                     : createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
      93             : 
      94             :         // update device in existing graphics
      95       57216 :         for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();
      96       38144 :              it != m_aGraphics.end(); ++it )
      97       19072 :              (*it)->setDevice( m_aDevice );
      98             : 
      99             :     }
     100       17285 :     return true;
     101             : }
     102             : 
     103           0 : void SvpSalVirtualDevice::GetSize( long& rWidth, long& rHeight )
     104             : {
     105           0 :     if( m_aDevice.get() )
     106             :     {
     107           0 :         B2IVector aDevSize( m_aDevice->getSize() );
     108           0 :         rWidth = aDevSize.getX();
     109           0 :         rHeight = aDevSize.getY();
     110             :     }
     111             :     else
     112           0 :         rWidth = rHeight = 0;
     113           0 : }
     114             : 
     115             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10