summaryrefslogtreecommitdiff
path: root/basebmp/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-02-24 17:19:43 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-02-24 18:38:11 +0000
commitefe28833d484e6c59ce928e4218a07752262c5e9 (patch)
treef192cf333e674d8970ff739481f788f83b354f4c /basebmp/source
parent28f909df366d731ee0684d0608e5a00dcf70181c (diff)
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
Diffstat (limited to 'basebmp/source')
-rw-r--r--basebmp/source/bitmapdevice.cxx41
1 files changed, 27 insertions, 14 deletions
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index 12def64d0eb5..34cf2c882ff8 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,