summaryrefslogtreecommitdiff
path: root/vcl/headless/svpvd.cxx
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-05-23 19:59:03 +0100
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-06-25 13:04:29 +0100
commite82d491263edf18fadf7c403f60e2895887fe971 (patch)
tree985d86012f177761914821fe93823fa38791a739 /vcl/headless/svpvd.cxx
parentdbf426edeab1a9f06073fa40a14561075206e58f (diff)
svp: deduplicate bitcount->colourspace mapping and allow overriding.
Although svp defaults to BGR, we might want to use alternative formats (e.g. for tiled rendering to bitmap buffers which are to be used in e.g. gtk), it is probably safest to keep the current defaults but allow the user to change to whatever format they may require. (This currently only makes sense for the 32-bit RGBA/ARGB/etc. formats. However the 23 bit formats could potentially be expanded to allow a similar RGB/BGR choice.) Change-Id: I70bd3d6e7d297faef163b910f576655efee4cb3f
Diffstat (limited to 'vcl/headless/svpvd.cxx')
-rw-r--r--vcl/headless/svpvd.cxx44
1 files changed, 16 insertions, 28 deletions
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index e5a20b58fcac..d85cd8c7da29 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -20,6 +20,7 @@
#ifndef IOS
#include "headless/svpbmp.hxx"
+#include "headless/svpinst.hxx"
#include "headless/svpvd.hxx"
#include "headless/svpgdi.hxx"
@@ -63,36 +64,23 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const ba
aDevSize.setY( 1 );
if( ! m_aDevice.get() || m_aDevice->getSize() != aDevSize )
{
- basebmp::Format nFormat = SVP_DEFAULT_BITMAP_FORMAT;
- std::vector< basebmp::Color > aDevPal;
- switch( m_nBitCount )
+ SvpSalInstance* pInst = SvpSalInstance::s_pDefaultInstance;
+ assert( pInst );
+ basebmp::Format nFormat = pInst->getFormatForBitCount( m_nBitCount );
+
+ if ( m_nBitCount == 1 )
{
- case 1: nFormat = FORMAT_ONE_BIT_MSB_PAL;
- aDevPal.reserve(2);
- aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
- aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
- break;
- case 4: nFormat = FORMAT_FOUR_BIT_MSB_PAL; break;
- case 8: nFormat = FORMAT_EIGHT_BIT_PAL; break;
-#ifdef OSL_BIGENDIAN
- case 16: nFormat = FORMAT_SIXTEEN_BIT_MSB_TC_MASK; break;
-#else
- case 16: nFormat = FORMAT_SIXTEEN_BIT_LSB_TC_MASK; break;
-#endif
- case 24: nFormat = FORMAT_TWENTYFOUR_BIT_TC_MASK; break;
- case 32: nFormat = FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA; break;
-#ifdef ANDROID
- case 0: nFormat = FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA; break;
-#else
- case 0: nFormat = FORMAT_TWENTYFOUR_BIT_TC_MASK; break;
-#endif
+ std::vector< basebmp::Color > aDevPal(2);
+ aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
+ aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
+ m_aDevice = createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
+ }
+ else
+ {
+ m_aDevice = pBuffer ?
+ createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
+ : createBitmapDevice( aDevSize, false, nFormat );
}
- m_aDevice = aDevPal.empty()
- ? ( pBuffer
- ? createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
- : createBitmapDevice( aDevSize, false, nFormat )
- )
- : createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
// update device in existing graphics
for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin();