[Libreoffice-commits] core.git: 2 commits - basebmp/source basebmp/test include/basebmp vcl/headless vcl/unx
Caolán McNamara
caolanm at redhat.com
Tue Feb 24 10:38:49 PST 2015
basebmp/source/bitmapdevice.cxx | 41 ++++++++++++++++++++++++-------------
basebmp/test/basictest.cxx | 24 ++++++++++++++-------
basebmp/test/bmpmasktest.cxx | 15 +++++++++----
basebmp/test/bmptest.cxx | 12 +++++++---
basebmp/test/cliptest.cxx | 12 +++++++---
basebmp/test/filltest.cxx | 6 +++--
basebmp/test/linetest.cxx | 12 +++++++---
basebmp/test/masktest.cxx | 9 +++++---
basebmp/test/polytest.cxx | 6 +++--
include/basebmp/bitmapdevice.hxx | 10 ++++++++-
vcl/headless/svpbmp.cxx | 6 +++--
vcl/headless/svpframe.cxx | 3 +-
vcl/headless/svptext.cxx | 10 ++++-----
vcl/headless/svpvd.cxx | 8 ++++---
vcl/unx/gtk/window/gtksalframe.cxx | 7 +++---
15 files changed, 120 insertions(+), 61 deletions(-)
New commits:
commit 6a37123f49d75e886786ccdd1ceb5b2e30173372
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Feb 24 17:28:42 2015 +0000
32 times larger than necessary
bit/byte thinko I imagine
Change-Id: I85ef6de4a4e6cffcd9c593eb15da692a2617736e
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
index 812ff50..ebc038c 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -3424,7 +3424,7 @@ void GtkSalFrame::renderArea( cairo_t *cr, cairo_rectangle_t *area )
cairo_save( cr );
int cairo_stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, area->width);
- unsigned char *p, *src, *mem = (unsigned char *)malloc (32 * cairo_stride * area->height);
+ unsigned char *p, *src, *mem = (unsigned char *)malloc (cairo_stride * area->height);
p = mem;
src = data.get();
src += (int)ay * nStride + (int)ax * 3;
commit efe28833d484e6c59ce928e4218a07752262c5e9
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Feb 24 17:19:43 2015 +0000
make ScanlineStride an argument to createBitmapDevice
so we could create bitmap devices that have the same stride that cairo expects,
provide getBitmapDeviceStrideForWidth to get a default value
Change-Id: I7ecc6f54a734b3f6bed59c699ac3b482c4ad7c47
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index 12def64..34cf2c8 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -1933,14 +1933,12 @@ inline sal_uInt32 nextPow2( sal_uInt32 x )
return ++x;
}
-
-
-
namespace
{
BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& rSize,
bool bTopDown,
Format nScanlineFormat,
+ sal_Int32 nScanlineStride,
boost::shared_array< sal_uInt8 > pMem,
PaletteMemorySharedVector pPal,
const basegfx::B2IBox* pSubset,
@@ -1960,15 +1958,6 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector&
rSize.getX() << " for depth " << nBitsPerPixel);
return BitmapDeviceSharedPtr();
}
- // round up to full 8 bit, divide by 8
- sal_Int32 nScanlineStride = (rSize.getX()*nBitsPerPixel + 7) >> 3;
-
- // rounded up to next full power-of-two number of bytes
- const sal_uInt32 bytesPerPixel = nextPow2(
- (bitsPerPixel[nScanlineFormat] + 7) >> 3);
-
- // now make nScanlineStride a multiple of bytesPerPixel
- nScanlineStride = (nScanlineStride + bytesPerPixel - 1) / bytesPerPixel * bytesPerPixel;
// factor in bottom-up scanline order case
nScanlineStride *= bTopDown ? 1 : -1;
@@ -2130,13 +2119,14 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector&
BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& rSize,
bool bTopDown,
Format nScanlineFormat,
+ sal_Int32 nScanlineStride,
boost::shared_array< sal_uInt8 > pMem,
PaletteMemorySharedVector pPal,
const basegfx::B2IBox* pSubset,
const IBitmapDeviceDamageTrackerSharedPtr& rDamage,
bool bBlack = true)
{
- BitmapDeviceSharedPtr result( createBitmapDeviceImplInner( rSize, bTopDown, nScanlineFormat, pMem, pPal, pSubset, rDamage, bBlack ) );
+ BitmapDeviceSharedPtr result( createBitmapDeviceImplInner( rSize, bTopDown, nScanlineFormat, nScanlineStride, pMem, pPal, pSubset, rDamage, bBlack ) );
#ifdef SAL_LOG_INFO
std::ostringstream subset;
@@ -2156,14 +2146,30 @@ BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector&
}
} // namespace
+sal_Int32 getBitmapDeviceStrideForWidth(Format nScanlineFormat, sal_Int32 nWidth)
+{
+ sal_uInt8 nBitsPerPixel = bitsPerPixel[nScanlineFormat];
+ // round up to full 8 bit, divide by 8
+ sal_Int32 nScanlineStride = (nWidth*nBitsPerPixel + 7) >> 3;
+
+ // rounded up to next full power-of-two number of bytes
+ const sal_uInt32 bytesPerPixel = nextPow2(
+ (bitsPerPixel[nScanlineFormat] + 7) >> 3);
+
+ // now make nScanlineStride a multiple of bytesPerPixel
+ nScanlineStride = (nScanlineStride + bytesPerPixel - 1) / bytesPerPixel * bytesPerPixel;
+ return nScanlineStride;
+}
BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
bool bTopDown,
- Format nScanlineFormat )
+ Format nScanlineFormat,
+ sal_Int32 nScanlineStride )
{
return createBitmapDeviceImpl( rSize,
bTopDown,
nScanlineFormat,
+ nScanlineStride,
boost::shared_array< sal_uInt8 >(),
PaletteMemorySharedVector(),
NULL,
@@ -2173,11 +2179,13 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
bool bTopDown,
Format nScanlineFormat,
+ sal_Int32 nScanlineStride,
const PaletteMemorySharedVector& rPalette )
{
return createBitmapDeviceImpl( rSize,
bTopDown,
nScanlineFormat,
+ nScanlineStride,
boost::shared_array< sal_uInt8 >(),
rPalette,
NULL,
@@ -2187,12 +2195,14 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize
BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
bool bTopDown,
Format nScanlineFormat,
+ sal_Int32 nScanlineStride,
const RawMemorySharedArray& rMem,
const PaletteMemorySharedVector& rPalette )
{
return createBitmapDeviceImpl( rSize,
bTopDown,
nScanlineFormat,
+ nScanlineStride,
rMem,
rPalette,
NULL,
@@ -2205,6 +2215,7 @@ BitmapDeviceSharedPtr createClipDevice( const basegfx::B2IVector& rSize )
createBitmapDeviceImpl( rSize,
false, /* bTopDown */
basebmp::FORMAT_ONE_BIT_MSB_GREY,
+ getBitmapDeviceStrideForWidth(basebmp::FORMAT_ONE_BIT_MSB_GREY, rSize.getX()),
boost::shared_array< sal_uInt8 >(),
PaletteMemorySharedVector(),
NULL,
@@ -2220,6 +2231,7 @@ BitmapDeviceSharedPtr subsetBitmapDevice( const BitmapDeviceSharedPtr& rProto,
return createBitmapDeviceImpl( rProto->getSize(),
rProto->isTopDown(),
rProto->getScanlineFormat(),
+ rProto->getScanlineStride(),
rProto->getBuffer(),
rProto->getPalette(),
&rSubset,
@@ -2232,6 +2244,7 @@ BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector& rSize,
return createBitmapDeviceImpl( rSize,
rProto->isTopDown(),
rProto->getScanlineFormat(),
+ rProto->getScanlineStride(),
boost::shared_array< sal_uInt8 >(),
rProto->getPalette(),
NULL,
diff --git a/basebmp/test/basictest.cxx b/basebmp/test/basictest.cxx
index 4290ed7..59d7e77 100644
--- a/basebmp/test/basictest.cxx
+++ b/basebmp/test/basictest.cxx
@@ -83,7 +83,8 @@ public:
basegfx::B2ISize aSize2(aSize);
BitmapDeviceSharedPtr pDevice( createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL ));
+ FORMAT_ONE_BIT_MSB_PAL,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX())));
CPPUNIT_ASSERT_MESSAGE("right size",
pDevice->getSize() == aSize2 );
CPPUNIT_ASSERT_MESSAGE("Top down format",
@@ -106,7 +107,8 @@ public:
basegfx::B2ISize aSize2(3,3);
BitmapDeviceSharedPtr pDevice( createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL ));
+ FORMAT_ONE_BIT_MSB_PAL,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX())));
BitmapDeviceSharedPtr pClone( cloneBitmapDevice(
aSize2,
@@ -121,7 +123,8 @@ public:
const basegfx::B2ISize aSize(64,64);
BitmapDeviceSharedPtr pDevice( createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL ));
+ FORMAT_ONE_BIT_MSB_PAL,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX())));
const basegfx::B2IPoint aPt(3,3);
CPPUNIT_ASSERT_MESSAGE("getPixelData for virgin device",
@@ -168,7 +171,8 @@ public:
{
pDevice = createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_LSB_PAL );
+ FORMAT_ONE_BIT_LSB_PAL,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_LSB_PAL, aSize.getX()));
pDevice->setPixel( aPt2, aCol, DrawMode_PAINT );
CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #4",
@@ -193,7 +197,8 @@ public:
{
pDevice = createBitmapDevice( aSize,
true,
- FORMAT_EIGHT_BIT_GREY );
+ FORMAT_EIGHT_BIT_GREY,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_EIGHT_BIT_GREY, aSize.getX()));
const Color aCol4(0x010101);
pDevice->setPixel( aPt, aCol4, DrawMode_PAINT );
@@ -215,7 +220,8 @@ public:
{
pDevice = createBitmapDevice( aSize,
true,
- FORMAT_SIXTEEN_BIT_LSB_TC_MASK );
+ FORMAT_SIXTEEN_BIT_LSB_TC_MASK,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_SIXTEEN_BIT_LSB_TC_MASK, aSize.getX()));
const Color aCol7(0);
pDevice->clear( aCol7 );
@@ -239,7 +245,8 @@ public:
{
pDevice = createBitmapDevice( aSize,
true,
- FORMAT_TWENTYFOUR_BIT_TC_MASK );
+ FORMAT_TWENTYFOUR_BIT_TC_MASK,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_TWENTYFOUR_BIT_TC_MASK, aSize.getX()));
const Color aCol4(0x01010101);
pDevice->setPixel( aPt, aCol4, DrawMode_PAINT );
@@ -266,7 +273,8 @@ public:
{
pDevice = createBitmapDevice( aSize,
true,
- FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA );
+ FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, aSize.getX()));
const Color aCol4(0x01010101);
pDevice->setPixel( aPt, aCol4, DrawMode_PAINT );
diff --git a/basebmp/test/bmpmasktest.cxx b/basebmp/test/bmpmasktest.cxx
index 610707a..c9df8b2 100644
--- a/basebmp/test/bmpmasktest.cxx
+++ b/basebmp/test/bmpmasktest.cxx
@@ -93,21 +93,26 @@ public:
const basegfx::B2ISize aSize(10,10);
mpDevice1bpp = createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL );
+ FORMAT_ONE_BIT_MSB_PAL,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX()));
mpDevice32bpp = createBitmapDevice( aSize,
true,
- FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA );
+ FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, aSize.getX()));
mpMaskBmp1bpp = createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_GREY );
+ FORMAT_ONE_BIT_MSB_GREY,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_GREY, aSize.getX()));
mpBmp1bpp = createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL );
+ FORMAT_ONE_BIT_MSB_PAL,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX()));
mpBmp32bpp = createBitmapDevice( aSize,
true,
- FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA );
+ FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, aSize.getX()));
OUString aSvg( "m 0 0h5v10h5v-5h-10z" );
diff --git a/basebmp/test/bmptest.cxx b/basebmp/test/bmptest.cxx
index 1f051ae..30644fb 100644
--- a/basebmp/test/bmptest.cxx
+++ b/basebmp/test/bmptest.cxx
@@ -148,19 +148,23 @@ public:
void setUp() SAL_OVERRIDE
{
const basegfx::B2ISize aSize(10,10);
+ sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX());
mpDevice1bpp = createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL );
+ FORMAT_ONE_BIT_MSB_PAL, nStride );
+ nStride = basebmp::getBitmapDeviceStrideForWidth(FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, aSize.getX());
mpDevice32bpp = createBitmapDevice( aSize,
true,
- FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA );
+ FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, nStride );
+ nStride = basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX());
mpBmp1bpp = createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL );
+ FORMAT_ONE_BIT_MSB_PAL, nStride );
+ nStride = basebmp::getBitmapDeviceStrideForWidth(FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, aSize.getX());
mpBmp32bpp = createBitmapDevice( aSize,
true,
- FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA );
+ FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, nStride );
OUString aSvg( "m 0 0h5v10h5v-5h-10z" );
diff --git a/basebmp/test/cliptest.cxx b/basebmp/test/cliptest.cxx
index 8526964..13ad48c 100644
--- a/basebmp/test/cliptest.cxx
+++ b/basebmp/test/cliptest.cxx
@@ -154,9 +154,10 @@ private:
void implTestMaskColorClip(const BitmapDeviceSharedPtr& rDevice)
{
+ sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(FORMAT_EIGHT_BIT_GREY, rDevice->getSize().getX());
BitmapDeviceSharedPtr pBmp( createBitmapDevice( rDevice->getSize(),
true,
- FORMAT_EIGHT_BIT_GREY ));
+ FORMAT_EIGHT_BIT_GREY, nStride ));
OUString aSvg( "m 0 0h5v10h5v-5h-10z" );
@@ -188,15 +189,18 @@ public:
void setUp() SAL_OVERRIDE
{
const basegfx::B2ISize aSize(11,11);
+ sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_GREY, aSize.getX());
mpClipMask = createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_GREY );
+ FORMAT_ONE_BIT_MSB_GREY, nStride );
+ nStride = basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX());
mpDevice1bpp = createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL );
+ FORMAT_ONE_BIT_MSB_PAL, nStride );
+ nStride = basebmp::getBitmapDeviceStrideForWidth(FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, aSize.getX());
mpDevice32bpp = createBitmapDevice( aSize,
true,
- FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA );
+ FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, nStride );
OUString aSvg( "m 0 0 h5 l5 5 v5 h-5 l-5-5 z" );
basegfx::B2DPolyPolygon aPoly;
diff --git a/basebmp/test/filltest.cxx b/basebmp/test/filltest.cxx
index 067ec24..875a27d 100644
--- a/basebmp/test/filltest.cxx
+++ b/basebmp/test/filltest.cxx
@@ -211,10 +211,12 @@ public:
const basegfx::B2ISize aSize(11,11);
mpDevice1bpp = createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL );
+ FORMAT_ONE_BIT_MSB_PAL,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX()));
mpDevice32bpp = createBitmapDevice( aSize,
true,
- FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA );
+ FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, aSize.getX()));
}
void testRectFill()
diff --git a/basebmp/test/linetest.cxx b/basebmp/test/linetest.cxx
index f6a3909..731158e 100644
--- a/basebmp/test/linetest.cxx
+++ b/basebmp/test/linetest.cxx
@@ -151,10 +151,12 @@ public:
const basegfx::B2ISize aSize(11,11);
mpDevice1bpp = createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL );
+ FORMAT_ONE_BIT_MSB_PAL,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX()) );
mpDevice32bpp = createBitmapDevice( aSize,
true,
- FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA );
+ FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, aSize.getX()) );
}
void testCornerCases()
@@ -163,7 +165,8 @@ public:
BitmapDeviceSharedPtr pDevice = createBitmapDevice(
aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL );
+ FORMAT_ONE_BIT_MSB_PAL,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX()) );
const basegfx::B2IPoint aPt1(0,0);
const basegfx::B2IPoint aPt2(10,10);
@@ -179,7 +182,8 @@ public:
pDevice = createBitmapDevice(
aSize2,
true,
- FORMAT_ONE_BIT_MSB_PAL );
+ FORMAT_ONE_BIT_MSB_PAL,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX()));
CPPUNIT_ASSERT_MESSAGE("only pixel cleared",
pDevice->getPixelData(aPt1) == 0);
diff --git a/basebmp/test/masktest.cxx b/basebmp/test/masktest.cxx
index 90a345c..94c1130 100644
--- a/basebmp/test/masktest.cxx
+++ b/basebmp/test/masktest.cxx
@@ -104,14 +104,17 @@ public:
const basegfx::B2ISize aSize(10,10);
mpDevice1bpp = createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL );
+ FORMAT_ONE_BIT_MSB_PAL,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX()) );
mpDevice32bpp = createBitmapDevice( aSize,
true,
- FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA );
+ FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, aSize.getX()) );
mpMask = createBitmapDevice( aSize,
true,
- FORMAT_EIGHT_BIT_GREY );
+ FORMAT_EIGHT_BIT_GREY,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_EIGHT_BIT_GREY, aSize.getX()) );
OUString aSvg( "m 0 0h5v10h5v-5h-10z" );
diff --git a/basebmp/test/polytest.cxx b/basebmp/test/polytest.cxx
index a0371eb..60746d7 100644
--- a/basebmp/test/polytest.cxx
+++ b/basebmp/test/polytest.cxx
@@ -296,10 +296,12 @@ public:
const basegfx::B2ISize aSize(10,10);
mpDevice1bpp = createBitmapDevice( aSize,
true,
- FORMAT_ONE_BIT_MSB_PAL );
+ FORMAT_ONE_BIT_MSB_PAL,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_ONE_BIT_MSB_PAL, aSize.getX()));
mpDevice32bpp = createBitmapDevice( aSize,
true,
- FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA );
+ FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA,
+ basebmp::getBitmapDeviceStrideForWidth(FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, aSize.getX()));
}
void testEmpty()
diff --git a/include/basebmp/bitmapdevice.hxx b/include/basebmp/bitmapdevice.hxx
index 48c6d47..5953741 100644
--- a/include/basebmp/bitmapdevice.hxx
+++ b/include/basebmp/bitmapdevice.hxx
@@ -659,11 +659,17 @@ private:
std::unique_ptr< ImplBitmapDevice > mpImpl;
};
+/** Function to calculate a suitable BitmapDevice Scanline Stride for a given scanline format and width
+ * you can provide this value or any larger value.
+ */
+sal_Int32 BASEBMP_DLLPUBLIC getBitmapDeviceStrideForWidth(Format nScanlineFormat, sal_Int32 nWidth);
+
/** Function to create a BitmapDevice for given scanline format
*/
BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC createBitmapDevice( const basegfx::B2IVector& rSize,
bool bTopDown,
- Format nScanlineFormat );
+ Format nScanlineFormat,
+ sal_Int32 nScanlineStride );
/** Function to create a BitmapDevice for given scanline format
with the given palette
@@ -675,6 +681,7 @@ BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC createBitmapDevice( const basegfx::B2IVe
BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC createBitmapDevice( const basegfx::B2IVector& rSize,
bool bTopDown,
Format nScanlineFormat,
+ sal_Int32 nScanlineStride,
const PaletteMemorySharedVector& rPalette );
/** Function to create a BitmapDevice for given scanline format
@@ -686,6 +693,7 @@ BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC createBitmapDevice( const basegfx::B2IVe
BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC createBitmapDevice( const basegfx::B2IVector& rSize,
bool bTopDown,
Format nScanlineFormat,
+ sal_Int32 nScanlineStride,
const RawMemorySharedArray& rMem,
const PaletteMemorySharedVector& rPalette );
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index bc2b2b9..cedb975 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -52,8 +52,9 @@ bool SvpSalBitmap::Create( const Size& rSize,
aSize.setX( 1 );
if( aSize.getY() == 0 )
aSize.setY( 1 );
+ sal_Int32 nStride = getBitmapDeviceStrideForWidth(nFormat, aSize.getX());
if( nBitCount > 8 )
- m_aBitmap = createBitmapDevice( aSize, false, nFormat );
+ m_aBitmap = createBitmapDevice( aSize, false, nFormat, nStride );
else
{
// prepare palette
@@ -66,7 +67,7 @@ bool SvpSalBitmap::Create( const Size& rSize,
const BitmapColor& rCol = rPalette[i];
(*pPalette)[i] = basebmp::Color( rCol.GetRed(), rCol.GetGreen(), rCol.GetBlue() );
}
- m_aBitmap = createBitmapDevice( aSize, false, nFormat,
+ m_aBitmap = createBitmapDevice( aSize, false, nFormat, nStride,
basebmp::RawMemorySharedArray(),
basebmp::PaletteMemorySharedVector( pPalette )
);
@@ -326,6 +327,7 @@ void SvpSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode
m_aBitmap = basebmp::createBitmapDevice( m_aBitmap->getSize(),
m_aBitmap->isTopDown(),
m_aBitmap->getScanlineFormat(),
+ m_aBitmap->getScanlineStride(),
m_aBitmap->getBuffer(),
pPal );
}
diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx
index 86915bf..7e91e1d 100644
--- a/vcl/headless/svpframe.cxx
+++ b/vcl/headless/svpframe.cxx
@@ -295,7 +295,8 @@ void SvpSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u
aFrameSize.setX( 1 );
if( aFrameSize.getY() == 0 )
aFrameSize.setY( 1 );
- m_aFrame = createBitmapDevice( aFrameSize, m_bTopDown, m_nScanlineFormat );
+ sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(m_nScanlineFormat, aFrameSize.getX());
+ m_aFrame = createBitmapDevice( aFrameSize, m_bTopDown, m_nScanlineFormat, nStride );
if (m_bDamageTracking)
m_aFrame->setDamageTracker(
basebmp::IBitmapDeviceDamageTrackerSharedPtr( new DamageTracker( *this ) ) );
diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx
index b075399..ef6e1ab 100644
--- a/vcl/headless/svptext.cxx
+++ b/vcl/headless/svptext.cxx
@@ -151,13 +151,13 @@ BitmapDeviceSharedPtr SvpGlyphPeer::GetGlyphBmp( ServerFont& rServerFont,
}
// construct alpha mask from raw bitmap
- const B2IVector aSize(
- pGcpHelper->maRawBitmap.mnScanlineSize,
- pGcpHelper->maRawBitmap.mnHeight );
- if( aSize.getX() && aSize.getY() )
+ if (pGcpHelper->maRawBitmap.mnScanlineSize && pGcpHelper->maRawBitmap.mnHeight)
{
+ const B2IVector aSize(
+ pGcpHelper->maRawBitmap.mnScanlineSize,
+ pGcpHelper->maRawBitmap.mnHeight );
static PaletteMemorySharedVector aDummyPAL;
- pGcpHelper->maBitmapDev = createBitmapDevice( aSize, true, nBmpFormat, pGcpHelper->maRawBitmap.mpBits, aDummyPAL );
+ pGcpHelper->maBitmapDev = createBitmapDevice( aSize, true, nBmpFormat, aSize.getX(), pGcpHelper->maRawBitmap.mpBits, aDummyPAL );
}
rGlyphData.ExtDataRef().meInfo = nBmpFormat;
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index e2f9042..84701eb 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -69,19 +69,21 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
SvpSalInstance* pInst = SvpSalInstance::s_pDefaultInstance;
assert( pInst );
basebmp::Format nFormat = pInst->getFormatForBitCount( m_nBitCount );
+ sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(nFormat, aDevSize.getX());
if ( m_nBitCount == 1 )
{
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, bTopDown, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
+ m_aDevice = createBitmapDevice( aDevSize, bTopDown, nFormat, nStride,
+ PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
}
else
{
m_aDevice = pBuffer ?
- createBitmapDevice( aDevSize, bTopDown, nFormat, pBuffer, PaletteMemorySharedVector() )
- : createBitmapDevice( aDevSize, bTopDown, nFormat );
+ createBitmapDevice( aDevSize, bTopDown, nFormat, nStride, pBuffer, PaletteMemorySharedVector() )
+ : createBitmapDevice( aDevSize, bTopDown, nFormat, nStride );
}
// update device in existing graphics
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
index 82c70e7c..812ff50 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -1965,8 +1965,9 @@ void GtkSalFrame::AllocateFrame()
aFrameSize.setX( 1 );
if( aFrameSize.getY() == 0 )
aFrameSize.setY( 1 );
- m_aFrame = basebmp::createBitmapDevice( aFrameSize, true,
- basebmp::FORMAT_TWENTYFOUR_BIT_TC_MASK );
+ sal_Int32 nStride(basebmp::getBitmapDeviceStrideForWidth(basebmp::FORMAT_TWENTYFOUR_BIT_TC_MASK, aFrameSize.getX()));
+ m_aFrame = basebmp::createBitmapDevice(aFrameSize, true,
+ basebmp::FORMAT_TWENTYFOUR_BIT_TC_MASK, nStride);
m_aFrame->setDamageTracker(
basebmp::IBitmapDeviceDamageTrackerSharedPtr(new DamageTracker(*this)) );
fprintf( stderr, "allocated m_aFrame size of %dx%d \n",
More information about the Libreoffice-commits
mailing list