Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "headless/svpvd.hxx"
30 : : #include "headless/svpgdi.hxx"
31 : :
32 : : #include <basegfx/vector/b2ivector.hxx>
33 : : #include <basebmp/scanlineformats.hxx>
34 : :
35 : : #include "stdio.h"
36 : :
37 : : using namespace basegfx;
38 : : using namespace basebmp;
39 : :
40 [ + - ][ + - ]: 94195 : SvpSalVirtualDevice::~SvpSalVirtualDevice()
41 : : {
42 [ - + ]: 188390 : }
43 : :
44 : 99077 : SalGraphics* SvpSalVirtualDevice::GetGraphics()
45 : : {
46 [ + - ][ + - ]: 99077 : SvpSalGraphics* pGraphics = new SvpSalGraphics();
47 [ + - ]: 99077 : pGraphics->setDevice( m_aDevice );
48 [ + - ]: 99077 : m_aGraphics.push_back( pGraphics );
49 : 99077 : return pGraphics;
50 : : }
51 : :
52 : 98401 : void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
53 : : {
54 [ - + ][ + - ]: 98401 : m_aGraphics.remove( dynamic_cast<SvpSalGraphics*>(pGraphics) );
55 [ + - ]: 98401 : delete pGraphics;
56 : 98401 : }
57 : :
58 : 141490 : sal_Bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
59 : : {
60 [ + - ]: 141490 : return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray() );
61 : : }
62 : :
63 : 141490 : sal_Bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer )
64 : : {
65 : 141490 : B2IVector aDevSize( nNewDX, nNewDY );
66 [ - + ]: 141490 : if( aDevSize.getX() == 0 )
67 : 0 : aDevSize.setX( 1 );
68 [ - + ]: 141490 : if( aDevSize.getY() == 0 )
69 : 0 : aDevSize.setY( 1 );
70 [ + + ][ + - ]: 141490 : if( ! m_aDevice.get() || m_aDevice->getSize() != aDevSize )
[ + + ][ + + ]
[ + + # # ]
71 : : {
72 : 141345 : sal_uInt32 nFormat = SVP_DEFAULT_BITMAP_FORMAT;
73 [ + - ]: 141345 : std::vector< basebmp::Color > aDevPal;
74 [ + - - - : 141345 : switch( m_nBitCount )
+ - + - ]
75 : : {
76 : 12600 : case 1: nFormat = Format::ONE_BIT_MSB_PAL;
77 [ + - ]: 12600 : aDevPal.reserve(2);
78 [ + - ]: 12600 : aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
79 [ + - ]: 12600 : aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
80 : 12600 : break;
81 : 0 : case 4: nFormat = Format::FOUR_BIT_MSB_PAL; break;
82 : 0 : case 8: nFormat = Format::EIGHT_BIT_PAL; break;
83 : : #ifdef OSL_BIGENDIAN
84 : : case 16: nFormat = Format::SIXTEEN_BIT_MSB_TC_MASK; break;
85 : : #else
86 : 0 : case 16: nFormat = Format::SIXTEEN_BIT_LSB_TC_MASK; break;
87 : : #endif
88 : 4182 : case 24: nFormat = Format::TWENTYFOUR_BIT_TC_MASK; break;
89 : 0 : case 32: nFormat = Format::THIRTYTWO_BIT_TC_MASK; break;
90 : : #if defined(ANDROID) || defined(IOS)
91 : : case 0: nFormat = Format::THIRTYTWO_BIT_TC_MASK_RGBA; break;
92 : : #else
93 : 124563 : case 0: nFormat = Format::TWENTYFOUR_BIT_TC_MASK; break;
94 : : #endif
95 : : }
96 : 141345 : m_aDevice = aDevPal.empty()
97 : : ? ( pBuffer
98 : : ? createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
99 : 128745 : : createBitmapDevice( aDevSize, false, nFormat )
100 : : )
101 [ # # ][ # # ]: 270090 : : createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ - + ]
[ # # ]
[ # # # # ]
[ + + - + ]
102 : :
103 : : // update device in existing graphics
104 [ + + ]: 375642 : for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();
105 : 187821 : it != m_aGraphics.end(); ++it )
106 [ + - ]: 187821 : (*it)->setDevice( m_aDevice );
107 : :
108 : : }
109 : 141490 : return true;
110 : : }
111 : :
112 : 0 : void SvpSalVirtualDevice::GetSize( long& rWidth, long& rHeight )
113 : : {
114 [ # # ]: 0 : if( m_aDevice.get() )
115 : : {
116 [ # # ]: 0 : B2IVector aDevSize( m_aDevice->getSize() );
117 : 0 : rWidth = aDevSize.getX();
118 : 0 : rHeight = aDevSize.getY();
119 : : }
120 : : else
121 : 0 : rWidth = rHeight = 0;
122 : 0 : }
123 : :
124 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|