LCOV - code coverage report
Current view: top level - vcl/headless - svpvd.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 1 48 2.1 %
Date: 2014-04-14 Functions: 2 9 22.2 %
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           0 : SvpSalVirtualDevice::~SvpSalVirtualDevice()
      35             : {
      36           0 : }
      37             : 
      38           0 : SalGraphics* SvpSalVirtualDevice::AcquireGraphics()
      39             : {
      40           0 :     SvpSalGraphics* pGraphics = new SvpSalGraphics();
      41           0 :     pGraphics->setDevice( m_aDevice );
      42           0 :     m_aGraphics.push_back( pGraphics );
      43           0 :     return pGraphics;
      44             : }
      45             : 
      46           0 : void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
      47             : {
      48           0 :     m_aGraphics.remove( dynamic_cast<SvpSalGraphics*>(pGraphics) );
      49           0 :     delete pGraphics;
      50           0 : }
      51             : 
      52           0 : bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
      53             : {
      54           0 :     return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray() );
      55             : }
      56             : 
      57           0 : bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer )
      58             : {
      59           0 :     B2IVector aDevSize( nNewDX, nNewDY );
      60           0 :     if( aDevSize.getX() == 0 )
      61           0 :         aDevSize.setX( 1 );
      62           0 :     if( aDevSize.getY() == 0 )
      63           0 :         aDevSize.setY( 1 );
      64           0 :     if( ! m_aDevice.get() || m_aDevice->getSize() != aDevSize )
      65             :     {
      66           0 :         basebmp::Format nFormat = SVP_DEFAULT_BITMAP_FORMAT;
      67           0 :         std::vector< basebmp::Color > aDevPal;
      68           0 :         switch( m_nBitCount )
      69             :         {
      70           0 :             case 1: nFormat = FORMAT_ONE_BIT_MSB_PAL;
      71           0 :                 aDevPal.reserve(2);
      72           0 :                 aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
      73           0 :                 aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
      74           0 :                 break;
      75           0 :             case 4: nFormat = FORMAT_FOUR_BIT_MSB_PAL; break;
      76           0 :             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           0 :             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           0 :             case 0:  nFormat = FORMAT_TWENTYFOUR_BIT_TC_MASK; break;
      88             : #endif
      89             :         }
      90           0 :         m_aDevice = aDevPal.empty()
      91             :                     ? ( pBuffer
      92             :                         ? createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
      93           0 :                         : createBitmapDevice( aDevSize, false, nFormat )
      94             :                        )
      95           0 :                     : createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
      96             : 
      97             :         // update device in existing graphics
      98           0 :         for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();
      99           0 :              it != m_aGraphics.end(); ++it )
     100           0 :              (*it)->setDevice( m_aDevice );
     101             : 
     102             :     }
     103           0 :     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           3 : }
     117             : 
     118             : #endif
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10