diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-11-19 11:51:47 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-11-23 14:25:59 +0000 |
commit | b639fe60eab2a221e23dc9d509f9281857d656a3 (patch) | |
tree | df756046e58d3b36891676b8c45449a3ff6a2223 /desktop/source | |
parent | c43a3a58677b467274ce6c21d7db1a6c0cc65cb4 (diff) |
VirtualDevices either match another device depth, or are 1 bit
cairo can therefore always render to a svp virtual device with
need for a fallback
Change-Id: I5d03ae541820389e26f7448444444be009fb28a4
Diffstat (limited to 'desktop/source')
-rw-r--r-- | desktop/source/lib/init.cxx | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 68eb01dd67ba..69ff1c3b1aaf 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -882,12 +882,12 @@ void doc_paintTile (LibreOfficeKitDocument* pThis, SystemGraphicsData aData; aData.rCGContext = reinterpret_cast<CGContextRef>(pBuffer); // the Size argument is irrelevant, I hope - ScopedVclPtrInstance<VirtualDevice> pDevice(&aData, Size(1, 1), DeviceFormat::FULLCOLOR); + ScopedVclPtrInstance<VirtualDevice> pDevice(&aData, Size(1, 1), DeviceFormat::DEFAULT); pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); #elif defined(ANDROID) - ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), DeviceFormat::FULLCOLOR) ; + ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT) ; boost::shared_array<sal_uInt8> aBuffer(pBuffer, NoDelete< sal_uInt8 >()); @@ -900,20 +900,19 @@ void doc_paintTile (LibreOfficeKitDocument* pThis, pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); #else - ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), DeviceFormat::FULLCOLOR) ; + ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT) ; // 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); -// TO_DO: enable alpha -// boost::shared_array<sal_uInt8> aAlphaBuffer(aAlpha.data(), NoDelete<sal_uInt8>()); - boost::shared_array<sal_uInt8> aAlphaBuffer; + sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(basebmp::Format::ThirtyTwoBitTcMaskBGRX, + nCanvasWidth); + std::vector<sal_uInt8> aAlpha(nCanvasHeight * nStride); + + boost::shared_array<sal_uInt8> aAlphaBuffer(aAlpha.data(), NoDelete<sal_uInt8>()); pDevice->SetOutputSizePixelScaleOffsetAndBuffer( Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), @@ -927,11 +926,15 @@ void doc_paintTile (LibreOfficeKitDocument* pThis, { for (int nCol = 0; nCol < nCanvasWidth; ++nCol) { - const int nOffset = (nCanvasWidth * nRow) + nCol; + const int nOffset = (nRow * nStride) + nCol * 4; // VCL's transparent is 0, RGBA's transparent is 0xff. - pBuffer[nOffset * 4 +3] = 0xff - aAlpha[nOffset]; + pBuffer[nOffset + 3] = 0xff - aAlpha[nOffset]; + double fAlpha = pBuffer[nOffset + 3]/255.0; + for (int i = 0; i < 3; ++i) + pBuffer[nOffset + i] *= fAlpha; } } + #endif static bool bDebug = getenv("LOK_DEBUG") != nullptr; |