summaryrefslogtreecommitdiff
path: root/basebmp
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-01-18 17:24:26 +0000
committerCaolán McNamara <caolanm@redhat.com>2016-01-18 20:47:02 +0000
commit36fcdd5fd4f719dec7ff46593ebaab3995908324 (patch)
tree49b4d55b13e287fa3a23dfedeba2a43ef381c131 /basebmp
parentbd25d89b7e6daf2a050d7f7ad996af2f083daca0 (diff)
devices are always top-down now
and remove some more unused out of tests code Change-Id: Ie63b03d1de754038d5477112ddfc9266dbf93709
Diffstat (limited to 'basebmp')
-rw-r--r--basebmp/source/bitmapdevice.cxx170
-rw-r--r--basebmp/test/basictest.cxx177
2 files changed, 4 insertions, 343 deletions
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index c16737673baa..f40d931e79d7 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -163,60 +163,21 @@ namespace
typedef RawAccessor raw_accessor_type;
typedef AccessorSelector accessor_selector;
- typedef typename Masks::clipmask_format_traits::iterator_type mask_iterator_type;
- typedef typename Masks::clipmask_format_traits::raw_accessor_type mask_rawaccessor_type;
- typedef typename Masks::clipmask_format_traits::accessor_selector mask_accessorselector_type;
-
- typedef typename Masks::alphamask_format_traits::iterator_type alphamask_iterator_type;
- typedef typename Masks::alphamask_format_traits::raw_accessor_type alphamask_rawaccessor_type;
- typedef typename Masks::alphamask_format_traits::accessor_selector alphamask_accessorselector_type;
-
typedef typename AccessorSelector::template wrap_accessor<
raw_accessor_type >::type dest_accessor_type;
typedef AccessorTraits< dest_accessor_type > accessor_traits;
- typedef CompositeIterator2D< dest_iterator_type,
- mask_iterator_type > composite_iterator_type;
-
- typedef BitmapRenderer<mask_iterator_type,
- mask_rawaccessor_type,
- mask_accessorselector_type,
- Masks> mask_bitmap_type;
- typedef BitmapRenderer<alphamask_iterator_type,
- alphamask_rawaccessor_type,
- alphamask_accessorselector_type,
- Masks> alphamask_bitmap_type;
-
-
typedef AccessorTraits< raw_accessor_type > raw_accessor_traits;
typedef typename uInt32Converter<
typename raw_accessor_type::value_type>::to to_uint32_functor;
- typedef typename raw_accessor_traits::template masked_accessor<
- mask_rawaccessor_type,
- dest_iterator_type,
- mask_iterator_type,
- Masks::clipmask_polarity>::type raw_maskedaccessor_type;
- typedef typename accessor_selector::template wrap_accessor<
- raw_maskedaccessor_type >::type masked_accessor_type;
-
-
- typedef JoinImageAccessorAdapter< dest_accessor_type,
- mask_rawaccessor_type > joined_image_accessor_type;
- typedef JoinImageAccessorAdapter< GenericColorImageAccessor,
- GenericColorImageAccessor > joined_generic_image_accessor_type;
-
-
-
dest_iterator_type maBegin;
typename accessor_traits::color_lookup maColorLookup;
to_uint32_functor maToUInt32Converter;
dest_accessor_type maAccessor;
raw_accessor_type maRawAccessor;
- masked_accessor_type maMaskedAccessor;
- raw_maskedaccessor_type maRawMaskedAccessor;
@@ -237,9 +198,7 @@ namespace
maColorLookup(),
maToUInt32Converter(),
maAccessor( accessor ),
- maRawAccessor( rawAccessor ),
- maMaskedAccessor( accessor ),
- maRawMaskedAccessor( rawAccessor )
+ maRawAccessor( rawAccessor )
{}
private:
@@ -256,69 +215,6 @@ namespace
return getCompatibleBitmap(bmp).get() != nullptr;
}
- std::shared_ptr<mask_bitmap_type> getCompatibleClipMask( const BitmapDeviceSharedPtr& bmp ) const
- {
- std::shared_ptr<mask_bitmap_type> pMask( std::dynamic_pointer_cast<mask_bitmap_type>( bmp ));
-
- if( !pMask )
- return pMask;
-
- if( pMask->getSize() != getSize() )
- pMask.reset();
-
- return pMask;
- }
-
- virtual bool isCompatibleClipMask( const BitmapDeviceSharedPtr& bmp ) const override
- {
- // TODO(P1): dynamic_cast usually called twice for
- // compatible formats
- return std::dynamic_pointer_cast<mask_bitmap_type>( bmp ).get() != nullptr;
- }
-
- static std::shared_ptr<alphamask_bitmap_type> getCompatibleAlphaMask( const BitmapDeviceSharedPtr& bmp )
- {
- return std::dynamic_pointer_cast<alphamask_bitmap_type>( bmp );
- }
-
- virtual void clear_i( Color fillColor,
- const basegfx::B2IBox& rBounds ) override
- {
- fillImage(destIterRange(maBegin,
- maRawAccessor,
- rBounds),
- maColorLookup(
- maAccessor,
- fillColor) );
- }
-
- virtual void setPixel_i( const basegfx::B2IPoint& rPt,
- Color pixelColor ) override
- {
- const DestIterator pixel( maBegin +
- vigra::Diff2D(rPt.getX(),
- rPt.getY()) );
- maAccessor.set( pixelColor, pixel );
- }
-
- virtual void setPixel_i( const basegfx::B2IPoint& rPt,
- Color pixelColor,
- const BitmapDeviceSharedPtr& rClip ) override
- {
- std::shared_ptr<mask_bitmap_type> pMask( getCompatibleClipMask(rClip) );
- OSL_ASSERT( pMask );
-
- const vigra::Diff2D offset(rPt.getX(),
- rPt.getY());
-
- const composite_iterator_type aIter(
- maBegin + offset,
- pMask->maBegin + offset );
-
- maMaskedAccessor.set( pixelColor,
- aIter );
- }
-
virtual Color getPixel_i(const basegfx::B2IPoint& rPt ) override
{
const DestIterator pixel( maBegin +
@@ -335,15 +231,6 @@ namespace
return maToUInt32Converter(maRawAccessor(pixel));
}
- composite_iterator_type getMaskedIter( const BitmapDeviceSharedPtr& rClip ) const
- {
- std::shared_ptr<mask_bitmap_type> pMask( getCompatibleClipMask(rClip) );
- OSL_ASSERT( pMask );
-
- return composite_iterator_type( maBegin,
- pMask->maBegin );
- }
-
template< typename Iterator, typename RawAcc >
void implDrawBitmap(const BitmapDeviceSharedPtr& rSrcBitmap,
const basegfx::B2IBox& rSrcRect,
@@ -398,8 +285,8 @@ namespace
sal_Int32 dstStride = getScanlineStride();
sal_Int32 srcStride = rSrcBitmap->getScanlineStride();
sal_Int32 bytesPerPixel = (bitsPerPixel[getScanlineFormat()] + 7) >> 3; // round up to bytes
- bool dstTopDown = isTopDown();
- bool srcTopDown = rSrcBitmap->isTopDown();
+ bool dstTopDown = true;
+ bool srcTopDown = true;
if (dstBuf == srcBuf && nSrcY < nDestY) // reverse copy order to avoid overlapping
{
@@ -539,11 +426,6 @@ basegfx::B2IVector BitmapDevice::getSize() const
mpImpl->maBounds.getMaxY() - mpImpl->maBounds.getMinY() );
}
-bool BitmapDevice::isTopDown() const
-{
- return mpImpl->mnScanlineStride >= 0;
-}
-
basegfx::B2IVector BitmapDevice::getBufferSize() const
{
return mpImpl->maBufferSize;
@@ -575,37 +457,6 @@ bool BitmapDevice::isSharedBuffer( const BitmapDeviceSharedPtr& rOther ) const
return rOther.get()->getBuffer().get() == getBuffer().get();
}
-void BitmapDevice::clear( Color fillColor )
-{
- clear_i( fillColor, mpImpl->maBounds );
-}
-
-void BitmapDevice::setPixel( const basegfx::B2IPoint& rPt,
- Color lineColor )
-{
- if( mpImpl->maBounds.isInside(rPt) )
- setPixel_i(rPt,lineColor);
-}
-
-void BitmapDevice::setPixel( const basegfx::B2IPoint& rPt,
- Color lineColor,
- const BitmapDeviceSharedPtr& rClip )
-{
- if( !rClip )
- {
- setPixel(rPt,lineColor);
- return;
- }
-
- if( mpImpl->maBounds.isInside(rPt) )
- {
- if( isCompatibleClipMask( rClip ) )
- setPixel_i(rPt,lineColor,rClip);
- else
- getGenericRenderer()->setPixel( rPt, lineColor, rClip );
- }
-}
-
Color BitmapDevice::getPixel( const basegfx::B2IPoint& rPt )
{
if( mpImpl->maBounds.isInside(rPt) )
@@ -863,7 +714,6 @@ BitmapDeviceSharedPtr createRenderer(
namespace
{
BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& rSize,
- bool bTopDown,
Format nScanlineFormat,
boost::shared_array< sal_uInt8 > pMem,
PaletteMemorySharedVector pPal,
@@ -886,9 +736,6 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector&
sal_Int32 nScanlineStride = getBitmapDeviceStrideForWidth(nScanlineFormat, rSize.getX());
- // factor in bottom-up scanline order case
- nScanlineStride *= bTopDown ? 1 : -1;
-
const sal_uInt32 nWidth(nScanlineStride < 0 ? -nScanlineStride : nScanlineStride);
const sal_uInt32 nHeight(rSize.getY());
@@ -1040,14 +887,13 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector&
}
BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& rSize,
- bool bTopDown,
Format nScanlineFormat,
boost::shared_array< sal_uInt8 > pMem,
PaletteMemorySharedVector pPal,
const basegfx::B2IBox* pSubset,
bool bBlack = true)
{
- BitmapDeviceSharedPtr result( createBitmapDeviceImplInner( rSize, bTopDown, nScanlineFormat, pMem, pPal, pSubset, bBlack ) );
+ BitmapDeviceSharedPtr result( createBitmapDeviceImplInner( rSize, nScanlineFormat, pMem, pPal, pSubset, bBlack ) );
#ifdef SAL_LOG_INFO
std::ostringstream subset;
@@ -1058,7 +904,6 @@ BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector&
SAL_INFO( "basebmp.bitmapdevice",
"createBitmapDevice: "
<< rSize.getX() << "x" << rSize.getY()
- << (bTopDown ? " top-down " : " bottom-up ")
<< subset.str()
<< " = " << result.get() );
#endif
@@ -1080,11 +925,9 @@ sal_Int32 getBitmapDeviceStrideForWidth(Format nScanlineFormat, sal_Int32 nWidth
}
BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
- bool bTopDown,
Format nScanlineFormat )
{
return createBitmapDeviceImpl( rSize,
- bTopDown,
nScanlineFormat,
boost::shared_array< sal_uInt8 >(),
PaletteMemorySharedVector(),
@@ -1092,12 +935,10 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
}
BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
- bool bTopDown,
Format nScanlineFormat,
const PaletteMemorySharedVector& rPalette )
{
return createBitmapDeviceImpl( rSize,
- bTopDown,
nScanlineFormat,
boost::shared_array< sal_uInt8 >(),
rPalette,
@@ -1105,13 +946,11 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize
}
BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize,
- bool bTopDown,
Format nScanlineFormat,
const RawMemorySharedArray& rMem,
const PaletteMemorySharedVector& rPalette )
{
return createBitmapDeviceImpl( rSize,
- bTopDown,
nScanlineFormat,
rMem,
rPalette,
@@ -1122,7 +961,6 @@ BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector& rSize,
const BitmapDeviceSharedPtr& rProto )
{
return createBitmapDeviceImpl( rSize,
- rProto->isTopDown(),
rProto->getScanlineFormat(),
boost::shared_array< sal_uInt8 >(),
rProto->getPalette(),
diff --git a/basebmp/test/basictest.cxx b/basebmp/test/basictest.cxx
index 52ff73516a00..05da4f554ee9 100644
--- a/basebmp/test/basictest.cxx
+++ b/basebmp/test/basictest.cxx
@@ -110,12 +110,9 @@ public:
const basegfx::B2ISize aSize(101,101);
basegfx::B2ISize aSize2(aSize);
BitmapDeviceSharedPtr pDevice( createBitmapDevice( aSize,
- true,
Format::OneBitMsbPal ) );
CPPUNIT_ASSERT_EQUAL_MESSAGE("right size",
aSize2, pDevice->getSize() );
- CPPUNIT_ASSERT_MESSAGE("Top down format",
- pDevice->isTopDown() );
CPPUNIT_ASSERT_EQUAL_MESSAGE("Scanline format",
Format::OneBitMsbPal, pDevice->getScanlineFormat() );
sal_Int32 nExpectedStride = (aSize2.getY() + 7)/8;
@@ -136,7 +133,6 @@ public:
const basegfx::B2ISize aSize(101,101);
basegfx::B2ISize aSize2(3,3);
BitmapDeviceSharedPtr pDevice( createBitmapDevice( aSize,
- true,
Format::OneBitMsbPal ) );
BitmapDeviceSharedPtr pClone( cloneBitmapDevice(
@@ -146,178 +142,6 @@ public:
aSize2, pClone->getSize() );
}
- void testPixelFuncs()
- {
- // 1bpp
- const basegfx::B2ISize aSize(64,64);
- BitmapDeviceSharedPtr pDevice( createBitmapDevice( aSize,
- true,
- Format::OneBitMsbPal ) );
-
- const basegfx::B2IPoint aPt(3,3);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("getPixelData for virgin device",
- sal_uInt32(0), pDevice->getPixelData(aPt));
-
- const Color aCol(0xFFFFFFFF);
- pDevice->setPixel( aPt, aCol );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #1",
- aCol, pDevice->getPixel(aPt));
- CPPUNIT_ASSERT_EQUAL_MESSAGE("getPixelData for white pixel",
- sal_uInt32(1), pDevice->getPixelData(aPt));
-
- const basegfx::B2IPoint aPt2(0,0);
- const Color aCol2(0xFFFFFFFF);
- pDevice->setPixel( aPt2, aCol2 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #2",
- aCol2, pDevice->getPixel(aPt2));
-
- const basegfx::B2IPoint aPt3(aSize.getX()-1,aSize.getY()-1);
- const Color aCol3(0x00000000);
- pDevice->setPixel( aPt3, aCol3 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #3",
- aCol3, pDevice->getPixel(aPt3));
-
- pDevice->setPixel( aPt3, aCol2 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #3.5",
- aCol2, pDevice->getPixel(aPt3));
-
- const basegfx::B2IPoint aPt4(-100000,-100000);
- pDevice->setPixel( aPt4, aCol3 );
- const basegfx::B2IPoint aPt5(100000,100000);
- pDevice->setPixel( aPt5, aCol3 );
-
- auto nPixel(countPixel(pDevice, aCol2));
- const basegfx::B2IPoint aPt6(aSize.getX(),aSize.getY());
- pDevice->setPixel( aPt6, aCol2 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("setPixel clipping",
- nPixel, countPixel(pDevice, aCol2));
-
- CPPUNIT_ASSERT_EQUAL_MESSAGE("raw pixel value #1",
- sal_uInt8(0x80), pDevice->getBuffer()[0]);
-
- // 1bit LSB
- {
- pDevice = createBitmapDevice( aSize,
- true,
- Format::OneBitLsbPal );
-
- pDevice->setPixel( aPt2, aCol );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #4",
- aCol, pDevice->getPixel(aPt2));
-
- const basegfx::B2IPoint aPt222(1,1);
- pDevice->setPixel( aPt222, aCol );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #5",
- aCol, pDevice->getPixel(aPt222));
-
- pDevice->setPixel( aPt3, aCol );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #6",
- aCol, pDevice->getPixel(aPt3));
-
- CPPUNIT_ASSERT_EQUAL_MESSAGE("raw pixel value #2",
- sal_uInt8(0x01), pDevice->getBuffer()[0]);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("raw pixel value #3",
- sal_uInt8(0x02), pDevice->getBuffer()[8]);
- }
-
- // 8bit alpha
- {
- pDevice = createBitmapDevice( aSize,
- true,
- Format::EightBitGrey );
-
- const Color aCol4(0x010101);
- pDevice->setPixel( aPt, aCol4 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #4",
- aCol4, pDevice->getPixel(aPt));
-
- const Color aCol5(0x0F0F0F);
- pDevice->setPixel( aPt2, aCol5 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #5",
- aCol5, pDevice->getPixel(aPt2));
-
- const Color aCol6(0xFFFFFF);
- pDevice->setPixel( aPt3, aCol6 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #6",
- aCol6, pDevice->getPixel(aPt3));
- }
-
- // 16bpp
- {
- pDevice = createBitmapDevice( aSize,
- true,
- Format::SixteenBitLsbTcMask );
- const Color aCol7(0);
- pDevice->clear( aCol7 );
-
- const Color aCol4(0x00101010);
- pDevice->setPixel( aPt, aCol4 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #7",
- aCol4, pDevice->getPixel(aPt));
-
- const Color aCol5(0x00F0F0F0);
- pDevice->setPixel( aPt2, aCol5 );
- CPPUNIT_ASSERT_MESSAGE("get/setPixel roundtrip #8",
- pDevice->getPixel(aPt2) != aCol7);
-
- const Color aCol6(0x00FFFFFF);
- pDevice->setPixel( aPt3, aCol6 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #9",
- aCol6, pDevice->getPixel(aPt3));
- }
-
- // 24bpp
- {
- pDevice = createBitmapDevice( aSize,
- true,
- Format::TwentyFourBitTcMask );
-
- const Color aCol4(0x01010101);
- pDevice->setPixel( aPt, aCol4 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #10",
- aCol4, pDevice->getPixel(aPt));
-
- const Color aCol5(0x0F3F2F1F);
- pDevice->setPixel( aPt2, aCol5 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #11",
- aCol5, pDevice->getPixel(aPt2));
-
- const Color aCol6(0xFFFFFFFF);
- pDevice->setPixel( aPt3, aCol6 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #12",
- aCol6, pDevice->getPixel(aPt3));
-
- CPPUNIT_ASSERT_EQUAL_MESSAGE("raw pixel value #4",
- sal_uInt8(0x3F), pDevice->getBuffer()[2]);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("raw pixel value #4",
- sal_uInt8(0x2F), pDevice->getBuffer()[1]);
- CPPUNIT_ASSERT_EQUAL_MESSAGE("raw pixel value #4",
- sal_uInt8(0x1F), pDevice->getBuffer()[0]);
- }
-
- // 32bpp
- {
- pDevice = createBitmapDevice( aSize,
- true,
- Format::ThirtyTwoBitTcMaskBGRA );
-
- const Color aCol4(0x01010101);
- pDevice->setPixel( aPt, aCol4 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #13",
- aCol4, pDevice->getPixel(aPt));
-
- const Color aCol5(0x0F0F0F0F);
- pDevice->setPixel( aPt2, aCol5 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #14",
- aCol5, pDevice->getPixel(aPt2));
-
- const Color aCol6(0xFFFFFFFF);
- pDevice->setPixel( aPt3, aCol6 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("get/setPixel roundtrip #15",
- aCol6, pDevice->getPixel(aPt3));
- }
- }
-
// Change the following lines only, if you add, remove or rename
// member functions of the current class,
// because these macros are need by auto register mechanism.
@@ -326,7 +150,6 @@ public:
CPPUNIT_TEST(colorTest);
CPPUNIT_TEST(testConstruction);
CPPUNIT_TEST(testClone);
- CPPUNIT_TEST(testPixelFuncs);
CPPUNIT_TEST_SUITE_END();
};