LCOV - code coverage report
Current view: top level - vcl/headless - svpvd.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 32 40 80.0 %
Date: 2014-11-03 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/svpinst.hxx"
      24             : #include "headless/svpvd.hxx"
      25             : #include "headless/svpgdi.hxx"
      26             : 
      27             : #include <basegfx/vector/b2ivector.hxx>
      28             : #include <basebmp/scanlineformats.hxx>
      29             : 
      30             : #include "stdio.h"
      31             : 
      32             : using namespace basegfx;
      33             : using namespace basebmp;
      34             : 
      35      404650 : SvpSalVirtualDevice::~SvpSalVirtualDevice()
      36             : {
      37      404650 : }
      38             : 
      39      205679 : SalGraphics* SvpSalVirtualDevice::AcquireGraphics()
      40             : {
      41      205679 :     SvpSalGraphics* pGraphics = new SvpSalGraphics();
      42      205679 :     pGraphics->setDevice( m_aDevice );
      43      205679 :     m_aGraphics.push_back( pGraphics );
      44      205679 :     return pGraphics;
      45             : }
      46             : 
      47      205189 : void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
      48             : {
      49      205189 :     m_aGraphics.remove( dynamic_cast<SvpSalGraphics*>(pGraphics) );
      50      205189 :     delete pGraphics;
      51      205189 : }
      52             : 
      53      249657 : bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
      54             : {
      55      249657 :     return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray(), false );
      56             : }
      57             : 
      58      249657 : bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
      59             :                                               const basebmp::RawMemorySharedArray &pBuffer,
      60             :                                               const bool bTopDown )
      61             : {
      62      249657 :     B2IVector aDevSize( nNewDX, nNewDY );
      63      249657 :     if( aDevSize.getX() == 0 )
      64           0 :         aDevSize.setX( 1 );
      65      249657 :     if( aDevSize.getY() == 0 )
      66           0 :         aDevSize.setY( 1 );
      67      249657 :     if( ! m_aDevice.get() || m_aDevice->getSize() != aDevSize )
      68             :     {
      69      249431 :         SvpSalInstance* pInst = SvpSalInstance::s_pDefaultInstance;
      70             :         assert( pInst );
      71      249431 :         basebmp::Format nFormat = pInst->getFormatForBitCount( m_nBitCount );
      72             : 
      73      249431 :         if ( m_nBitCount == 1 )
      74             :         {
      75       20668 :             std::vector< basebmp::Color > aDevPal(2);
      76       20668 :             aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
      77       20668 :             aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
      78       20668 :             m_aDevice = createBitmapDevice( aDevSize, bTopDown, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
      79             :         }
      80             :         else
      81             :         {
      82      457526 :             m_aDevice = pBuffer ?
      83             :                           createBitmapDevice( aDevSize, bTopDown, nFormat, pBuffer, PaletteMemorySharedVector() )
      84      686289 :                         : createBitmapDevice( aDevSize, bTopDown, nFormat );
      85             :         }
      86             : 
      87             :         // update device in existing graphics
      88      888141 :         for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();
      89      592094 :              it != m_aGraphics.end(); ++it )
      90       46616 :              (*it)->setDevice( m_aDevice );
      91             : 
      92             :     }
      93      249657 :     return true;
      94             : }
      95             : 
      96           0 : void SvpSalVirtualDevice::GetSize( long& rWidth, long& rHeight )
      97             : {
      98           0 :     if( m_aDevice.get() )
      99             :     {
     100           0 :         B2IVector aDevSize( m_aDevice->getSize() );
     101           0 :         rWidth = aDevSize.getX();
     102           0 :         rHeight = aDevSize.getY();
     103             :     }
     104             :     else
     105           0 :         rWidth = rHeight = 0;
     106        1125 : }
     107             : 
     108             : #endif
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10