summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-11-19 11:51:47 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-11-23 14:25:59 +0000
commitb639fe60eab2a221e23dc9d509f9281857d656a3 (patch)
treedf756046e58d3b36891676b8c45449a3ff6a2223 /desktop
parentc43a3a58677b467274ce6c21d7db1a6c0cc65cb4 (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')
-rw-r--r--desktop/CppunitTest_desktop_lib.mk1
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx6
-rw-r--r--desktop/source/lib/init.cxx25
3 files changed, 19 insertions, 13 deletions
diff --git a/desktop/CppunitTest_desktop_lib.mk b/desktop/CppunitTest_desktop_lib.mk
index bbedfdc8348e..2119e15735fb 100644
--- a/desktop/CppunitTest_desktop_lib.mk
+++ b/desktop/CppunitTest_desktop_lib.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,desktop_lib, \
))
$(eval $(call gb_CppunitTest_use_libraries,desktop_lib, \
+ basebmp \
comphelper \
cppu \
cppuhelper \
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 0874eeddba1b..07607dd6b365 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -14,7 +14,7 @@
#include <com/sun/star/awt/Key.hpp>
#include <com/sun/star/awt/XReschedule.hpp>
#include <com/sun/star/awt/Toolkit.hpp>
-
+#include <basebmp/bitmapdevice.hxx>
#include <boost/property_tree/json_parser.hpp>
#include <comphelper/processfactory.hxx>
#include <sfx2/objsh.hxx>
@@ -316,7 +316,9 @@ void DesktopLOKTest::testPaintTile()
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
int nCanvasWidth = 100;
int nCanvasHeight = 300;
- std::vector<unsigned char> aBuffer(nCanvasWidth * nCanvasHeight * 4);
+ sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(basebmp::Format::ThirtyTwoBitTcMaskBGRX,
+ nCanvasWidth);
+ std::vector<unsigned char> aBuffer(nStride * nCanvasHeight);
int nTilePosX = 0;
int nTilePosY = 0;
int nTileWidth = 1000;
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;