summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-10-01 14:17:21 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-10-07 10:17:31 +0200
commit2b3b3f84838927d5d5d4fa103b541d276b5a95f3 (patch)
tree7c3f58b79ee5512ca8d294301f7711267ddd2177 /desktop
parentba7a4cdc714f929b3294d30bdf5ceea543fe57ff (diff)
desktop, vcl: support transparency in VirtualDevices with user-provided memory
Change-Id: I65c31995c02a644aa436aecd065255fab38045e4 (cherry picked from commit 1d3b613318654ceb2d34996ef8ca653cfe32a8ea)
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a4d904c08767..47a50b7414ca 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -757,10 +757,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);
@@ -774,6 +785,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)
{