desktop/Library_sofficeapp.mk | 1 desktop/qa/gtktiledviewer/gtktiledviewer.cxx | 6 +++ desktop/source/lib/init.cxx | 11 +++++- vcl/headless/svpbmp.cxx | 24 +++----------- vcl/headless/svpinst.cxx | 45 +++++++++++++++++++++++++++ vcl/headless/svpvd.cxx | 44 +++++++++----------------- vcl/inc/headless/svpinst.hxx | 12 +++++++ 7 files changed, 94 insertions(+), 49 deletions(-)
New commits: commit e7449e17c121631013213326479a2555da5930ba Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Fri May 23 20:02:05 2014 +0100 Upgrade gtktiledviewer to RGBA. The Alpha channel seems to be set incorrectly by LO, hence we need to manually set it here for now. Change-Id: I1f9091b8b6f88c1dba6653dfb7bf51f9fe14b3fc diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx index ee81cbc..1a9ae31 100644 --- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx @@ -49,9 +49,13 @@ bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpoint 0, 0, // origin nWidth, nHeight ); + for (int i = 3; i < nRowStride*nRenderHeight; i += 4) + { + pBuffer[i] = 0xFF; + } GdkPixbuf* pBixBuf = gdk_pixbuf_new_from_data( pBuffer, GDK_COLORSPACE_RGB, - false, 8, + true, 8, nRenderWidth, nRenderHeight, nRowStride, 0, 0 ); commit 53ea8cb4be1c9c1736ccf9486c3397f5ccd15b02 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Fri May 23 20:00:58 2014 +0100 Upgrade LibLO tiled rendering to RGBA. This is the expected format for gtk+ pixbufs which is currently the primary target. We could potentially allow the user to choose the format via LibLO -- but we want to eventually allow passing in a buffer (rather than passing out an LO owned buffer) anyway, so should add that then. Change-Id: I8427925a94366917fa82fb8ea28e7dbb3fa1840d diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk index 3453968..8a2500a 100644 --- a/desktop/Library_sofficeapp.mk +++ b/desktop/Library_sofficeapp.mk @@ -51,6 +51,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\ ucbhelper \ utl \ vcl \ + vclplug_svp \ $(gb_UWINAPI) \ )) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 7761c3a..459ab8d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -49,7 +49,10 @@ #include <unotxdoc.hxx> #include <viewsh.hxx> -// And let's also grab the SvpSalVirtualDevice +#include <salinst.hxx> + +// And let's also grab the SvpSalInstance and SvpSalVirtualDevice +#include <headless/svpinst.hxx> #include <headless/svpvd.hxx> #include <basebmp/bitmapdevice.hxx> @@ -408,7 +411,11 @@ static unsigned char* doc_paintTile (LibreOfficeDocument* pThis, SwDoc* pDoc = pDocShell->GetDoc(); SwViewShell* pViewShell = pDoc->GetCurrentViewShell(); - VirtualDevice aDevice(0, (sal_uInt16)0); + ImplSVData* pSVData = ImplGetSVData(); + SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst); + pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA ); + + VirtualDevice aDevice(0, (sal_uInt16)32); pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); commit 84f71087b2e007ce15789802112144a10d77de76 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Fri May 23 19:59:03 2014 +0100 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 diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 3e08e90..0a81fdc 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -20,6 +20,7 @@ #ifndef IOS #include "headless/svpbmp.hxx" +#include "headless/svpinst.hxx" #include <basegfx/vector/b2ivector.hxx> #include <basegfx/range/b2ibox.hxx> @@ -40,25 +41,12 @@ bool SvpSalBitmap::Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPalette ) { - basebmp::Format nFormat = SVP_DEFAULT_BITMAP_FORMAT; SAL_INFO( "vcl.headless", "SvpSalBitmap::Create(" << rSize.Width() << "," << rSize.Height() << "," << nBitCount << ")" ); - switch( nBitCount ) - { - case 1: nFormat = FORMAT_ONE_BIT_MSB_PAL; 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; -#ifdef ANDROID - case 32: nFormat = FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA; break; -#else - case 32: nFormat = FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA; break; -#endif - } + + SvpSalInstance* pInst = SvpSalInstance::s_pDefaultInstance; + assert( pInst ); + basebmp::Format nFormat = pInst->getFormatForBitCount( nBitCount ); + B2IVector aSize( rSize.Width(), rSize.Height() ); if( aSize.getX() == 0 ) aSize.setX( 1 ); diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 2ce2a01..3fa2226 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -45,6 +45,8 @@ // FIXME: remove when we re-work the svp mainloop #include <unx/salunxtime.h> +using namespace basebmp; + bool SvpSalInstance::isFrameAlive( const SalFrame* pFrame ) const { for( std::list< SalFrame* >::const_iterator it = m_aFrames.begin(); @@ -405,4 +407,47 @@ void SvpSalTimer::Start( sal_uLong nMS ) m_pInstance->StartTimer( nMS ); } +void SvpSalInstance::setBitCountFormatMapping( sal_uInt16 nBitCount, + Format aFormat ) +{ + m_aBitCountFormatMap[nBitCount] = aFormat; +} + +Format SvpSalInstance::getFormatForBitCount( sal_uInt16 nBitCount ) +{ + BitCountFormatMap::iterator aIt; + if ( (aIt = m_aBitCountFormatMap.find( nBitCount )) != m_aBitCountFormatMap.end() ) + { + return aIt->second; + } + + switch( nBitCount ) + { + case 1: + return FORMAT_ONE_BIT_MSB_PAL; + case 4: + return FORMAT_FOUR_BIT_MSB_PAL; + case 8: + return FORMAT_EIGHT_BIT_PAL; + case 16: +#ifdef OSL_BIGENDIAN + return FORMAT_SIXTEEN_BIT_MSB_TC_MASK; +#else + return FORMAT_SIXTEEN_BIT_LSB_TC_MASK; +#endif + case 24: + return FORMAT_TWENTYFOUR_BIT_TC_MASK; + case 32: + return FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA; + case 0: +#ifdef ANDROID + return FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA; +#else + return FORMAT_TWENTYFOUR_BIT_TC_MASK; +#endif + default: + return SVP_DEFAULT_BITMAP_FORMAT; + } + +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx index e5a20b5..d85cd8c 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(); diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx index dd557d1..0bf542f 100644 --- a/vcl/inc/headless/svpinst.hxx +++ b/vcl/inc/headless/svpinst.hxx @@ -27,6 +27,7 @@ #include <saltimer.hxx> #include <generic/geninst.h> #include <generic/genprn.h> +#include <basebmp/scanlineformats.hxx> #include <list> @@ -84,6 +85,9 @@ class SvpSalInstance : public SalGenericInstance void DoReleaseYield( int nTimeoutMS ); + typedef std::map< sal_uInt16, ::basebmp::Format > BitCountFormatMap; + BitCountFormatMap m_aBitCountFormatMap; + public: static SvpSalInstance* s_pDefaultInstance; @@ -161,6 +165,14 @@ public: virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) SAL_OVERRIDE; virtual GenPspGraphics *CreatePrintGraphics() SAL_OVERRIDE; + + // We want to be able to select colourspace, i.e. ARGB vs RGBA vs BGRA etc. + // -- as the rest of vcl always uses bit depths, it is perhaps simplest + // to let us simply change the mapping of bitcount to format (which was + // previously unchangeable). + SAL_DLLPUBLIC_EXPORT void setBitCountFormatMapping( sal_uInt16 nBitCount, ::basebmp::Format aFormat ); + + SAL_DLLPUBLIC_EXPORT ::basebmp::Format getFormatForBitCount( sal_uInt16 ); }; #endif // INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits