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

Generated by: LCOV version 1.10