desktop/source/lib/init.cxx | 24 +++++++++++++++++++++++- include/vcl/virdev.hxx | 2 ++ sw/source/uibase/config/viewopt.cxx | 3 +++ vcl/source/gdi/virdev.cxx | 12 ++++++++---- 4 files changed, 36 insertions(+), 5 deletions(-)
New commits: commit 4fe010cce872ef035fec376298e416f9799c4a21 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Oct 1 16:43:00 2015 +0200 sw tiled rendering: default to transparent background outside page frames Change-Id: Ie018a878eb7d7ef14a80a6b86020c114ff14da88 diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx index 6f29c45..d309671 100644 --- a/sw/source/uibase/config/viewopt.cxx +++ b/sw/source/uibase/config/viewopt.cxx @@ -39,6 +39,7 @@ #include <unotools/syslocale.hxx> #include <editeng/acorrcfg.hxx> +#include <comphelper/lok.hxx> #ifdef DBG_UTIL bool SwViewOption::s_bTest9 = false; //DrawingLayerNotLoading @@ -209,6 +210,8 @@ SwViewOption::SwViewOption() : m_bTest1 = m_bTest2 = m_bTest3 = m_bTest4 = m_bTest5 = m_bTest6 = m_bTest7 = m_bTest8 = m_bTest10 = false; #endif + if (comphelper::LibreOfficeKit::isActive()) + aAppBackgroundColor = COL_TRANSPARENT; } SwViewOption::SwViewOption(const SwViewOption& rVOpt) commit 1d3b613318654ceb2d34996ef8ca653cfe32a8ea Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Oct 1 14:17:21 2015 +0200 desktop, vcl: support transparency in VirtualDevices with user-provided memory Change-Id: I65c31995c02a644aa436aecd065255fab38045e4 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 509983c..e902df0 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -755,10 +755,21 @@ void doc_paintTile (LibreOfficeKitDocument* pThis, InitSvpForLibreOfficeKit(); ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), (sal_uInt16)32) ; + + // Set background to transparent by default. + memset(pBuffer, 0, nCanvasWidth * nCanvasHeight * 4); + pDevice->SetBackground(Wallpaper(Color(COL_TRANSPARENT))); + boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() ); + + // Allocate a separate buffer for the alpha device. + std::vector<sal_uInt8> aAlpha(nCanvasWidth * nCanvasHeight); + memset(aAlpha.data(), 0, nCanvasWidth * nCanvasHeight); + boost::shared_array<sal_uInt8> aAlphaBuffer(aAlpha.data(), NoDelete<sal_uInt8>()); + pDevice->SetOutputSizePixelScaleOffsetAndBuffer( Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), - aBuffer, true ); + aBuffer, aAlphaBuffer, true ); pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); @@ -772,6 +783,17 @@ void doc_paintTile (LibreOfficeKitDocument* pThis, nTilePosX, nTilePosY, nTileWidth, nTileHeight); #endif + // Overwrite pBuffer's alpha channel with the separate alpha buffer. + for (int nRow = 0; nRow < nCanvasHeight; ++nRow) + { + for (int nCol = 0; nCol < nCanvasWidth; ++nCol) + { + const int nOffset = (nCanvasHeight * nRow) + nCol; + // VCL's transparent is 0, RGBA's transparent is 0xff. + pBuffer[nOffset * 4 +3] = 0xff - aAlpha[nOffset]; + } + } + static bool bDebug = getenv("LOK_DEBUG") != 0; if (bDebug) { diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx index ef86e5d..669a224 100644 --- a/include/vcl/virdev.hxx +++ b/include/vcl/virdev.hxx @@ -48,6 +48,7 @@ private: const bool bTopDown ); SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer, + const basebmp::RawMemorySharedArray &pAlphaBuffer, const bool bTopDown ); VirtualDevice (const VirtualDevice &) SAL_DELETED_FUNCTION; @@ -126,6 +127,7 @@ public: const Fraction& rScale, const Point& rNewOffset, const basebmp::RawMemorySharedArray &pBuffer, + const basebmp::RawMemorySharedArray &pAlphaBuffer, const bool bTopDown = false ); bool SetOutputSize( const Size& rNewSize, bool bErase = true ) { return SetOutputSizePixel( LogicToPixel( rNewSize ), bErase ); } diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index 7319a1f..5cdb706 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -393,6 +393,7 @@ void VirtualDevice::ImplFillOpaqueRectangle( const Rectangle& rRect ) bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer, + const basebmp::RawMemorySharedArray &pAlphaBuffer, const bool bTopDown ) { if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer, bTopDown) ) @@ -409,7 +410,7 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, { mpAlphaVDev = VclPtr<VirtualDevice>::Create( *this, mnAlphaDepth ); mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase, - basebmp::RawMemorySharedArray(), + pAlphaBuffer, bTopDown ); } @@ -443,13 +444,16 @@ void VirtualDevice::EnableRTL( bool bEnable ) bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase ) { - return ImplSetOutputSizePixel( rNewSize, bErase, basebmp::RawMemorySharedArray(), false ); + return ImplSetOutputSizePixel( rNewSize, bErase, basebmp::RawMemorySharedArray(), basebmp::RawMemorySharedArray(), false ); } bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset, - const basebmp::RawMemorySharedArray &pBuffer, const bool bTopDown ) + const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pAlphaBuffer, const bool bTopDown ) { + if (pAlphaBuffer) + mnAlphaDepth = 8; + if (pBuffer) { MapMode mm = GetMapMode(); mm.SetOrigin( rNewOffset ); @@ -457,7 +461,7 @@ bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( mm.SetScaleY( rScale ); SetMapMode( mm ); } - return ImplSetOutputSizePixel( rNewSize, true, pBuffer, bTopDown ); + return ImplSetOutputSizePixel( rNewSize, true, pBuffer, pAlphaBuffer, bTopDown ); } void VirtualDevice::SetReferenceDevice( RefDevMode i_eRefDevMode ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits