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-27 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       11640 : SvpSalVirtualDevice::~SvpSalVirtualDevice()
      32             : {
      33       11640 : }
      34             : 
      35        7101 : SalGraphics* SvpSalVirtualDevice::GetGraphics()
      36             : {
      37        7101 :     SvpSalGraphics* pGraphics = new SvpSalGraphics();
      38        7101 :     pGraphics->setDevice( m_aDevice );
      39        7101 :     m_aGraphics.push_back( pGraphics );
      40        7101 :     return pGraphics;
      41             : }
      42             : 
      43        5980 : void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
      44             : {
      45        5980 :     m_aGraphics.remove( dynamic_cast<SvpSalGraphics*>(pGraphics) );
      46        5980 :     delete pGraphics;
      47        5980 : }
      48             : 
      49        7728 : sal_Bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
      50             : {
      51        7728 :     return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray() );
      52             : }
      53             : 
      54        7728 : sal_Bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer )
      55             : {
      56        7728 :     B2IVector aDevSize( nNewDX, nNewDY );
      57        7728 :     if( aDevSize.getX() == 0 )
      58           0 :         aDevSize.setX( 1 );
      59        7728 :     if( aDevSize.getY() == 0 )
      60           0 :         aDevSize.setY( 1 );
      61        7728 :     if( ! m_aDevice.get() || m_aDevice->getSize() != aDevSize )
      62             :     {
      63        7727 :         sal_uInt32 nFormat = SVP_DEFAULT_BITMAP_FORMAT;
      64        7727 :         std::vector< basebmp::Color > aDevPal;
      65        7727 :         switch( m_nBitCount )
      66             :         {
      67         430 :             case 1: nFormat = Format::ONE_BIT_MSB_PAL;
      68         430 :                 aDevPal.reserve(2);
      69         430 :                 aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
      70         430 :                 aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
      71         430 :                 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         131 :             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        7166 :             case 0:  nFormat = Format::TWENTYFOUR_BIT_TC_MASK; break;
      85             : #endif
      86             :         }
      87        7727 :         m_aDevice = aDevPal.empty()
      88             :                     ? ( pBuffer
      89             :                         ? createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
      90        7297 :                         : createBitmapDevice( aDevSize, false, nFormat )
      91             :                        )
      92       15024 :                     : createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
      93             : 
      94             :         // update device in existing graphics
      95       25569 :         for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();
      96       17046 :              it != m_aGraphics.end(); ++it )
      97        8523 :              (*it)->setDevice( m_aDevice );
      98             : 
      99             :     }
     100        7728 :     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