summaryrefslogtreecommitdiff
path: root/basebmp
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-01-19 12:42:58 +0000
committerCaolán McNamara <caolanm@redhat.com>2016-01-19 13:24:28 +0000
commitdd16d34a6ebfbe60cee1d01752f167069ddb2848 (patch)
tree976c81eb6bd64fc8d98fdac4e0dab0753f425397 /basebmp
parentf73e72fb33f111c2eda12aa359b96dad680e6848 (diff)
either copy the whole thing exactly, or convert between types
Change-Id: Ied1b4f81e2e851b639cc9a514659160b8571e92f
Diffstat (limited to 'basebmp')
-rw-r--r--basebmp/source/bitmapdevice.cxx88
1 files changed, 14 insertions, 74 deletions
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index 3ca3bdf229a5..211f16bd0f9f 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -146,18 +146,6 @@ namespace
private:
- static std::shared_ptr<BitmapRenderer> getCompatibleBitmap( const BitmapDeviceSharedPtr& bmp )
- {
- return std::dynamic_pointer_cast< BitmapRenderer >( bmp );
- }
-
- virtual bool isCompatibleBitmap( const BitmapDeviceSharedPtr& bmp ) const override
- {
- // TODO(P1): dynamic_cast usually called twice for
- // compatible formats
- return getCompatibleBitmap(bmp).get() != nullptr;
- }
-
virtual Color getPixel_i(const basegfx::B2IPoint& rPt ) override
{
const DestIterator pixel( maBegin +
@@ -166,21 +154,6 @@ namespace
return maAccessor(pixel);
}
- template< typename Iterator, typename RawAcc >
- void implDrawBitmap(const BitmapDeviceSharedPtr& rSrcBitmap,
- const Iterator& begin,
- const RawAcc& acc)
- {
- const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() );
- const basegfx::B2IBox aRect(0, 0, rSrcSize.getX(),rSrcSize.getY());
-
- std::shared_ptr<BitmapRenderer> pSrcBmp( getCompatibleBitmap(rSrcBitmap) );
- OSL_ASSERT( pSrcBmp );
-
- vigra::copyImage( pSrcBmp->maBegin, pSrcBmp->maBegin + bottomRight(aRect), pSrcBmp->maRawAccessor,
- begin, acc );
- }
-
template< typename Iterator, typename Acc > static
void implDrawBitmapGeneric(const BitmapDeviceSharedPtr& rSrcBitmap,
const Iterator& begin,
@@ -195,49 +168,9 @@ namespace
begin, acc );
}
- void implDrawBitmapDirect(const BitmapDeviceSharedPtr& rSrcBitmap)
- {
- const basegfx::B2IVector& rSrcSize(rSrcBitmap->getSize());
-
- sal_Int32 nSrcWidth = rSrcSize.getX();
- sal_Int32 nSrcHeight = rSrcSize.getY();
-
- char* dstBuf = reinterpret_cast<char*>(getBuffer().get());
- char* srcBuf = reinterpret_cast<char*>(rSrcBitmap->getBuffer().get());
- sal_Int32 dstStride = getScanlineStride();
- sal_Int32 srcStride = rSrcBitmap->getScanlineStride();
- sal_Int32 bytesPerPixel = (bitsPerPixel[getScanlineFormat()] + 7) >> 3; // round up to bytes
-
- char* dstline = dstBuf;
- char* srcline = srcBuf;
- sal_Int32 lineBytes = nSrcWidth * bytesPerPixel;
-
- for(; 0 < nSrcHeight; nSrcHeight--)
- {
- memmove(dstline, srcline, lineBytes);
- dstline += dstStride;
- srcline += srcStride;
- }
- }
-
- virtual void copyBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap) override
+ virtual void convertBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap) override
{
- if( isCompatibleBitmap( rSrcBitmap ) )
- {
- if (bitsPerPixel[getScanlineFormat()] >= 8
- && rSrcBitmap->getScanlineFormat() == getScanlineFormat())
- implDrawBitmapDirect(rSrcBitmap);
- else
- implDrawBitmap(rSrcBitmap,
- maBegin,
- maRawAccessor);
- }
- else
- {
- implDrawBitmapGeneric(rSrcBitmap,
- maBegin,
- maAccessor);
- }
+ implDrawBitmapGeneric(rSrcBitmap, maBegin, maAccessor);
}
};
} // namespace
@@ -330,12 +263,11 @@ Color BitmapDevice::getPixel( const basegfx::B2IPoint& rPt )
return Color();
}
-void BitmapDevice::copyBitmap( const BitmapDeviceSharedPtr& rSrcBitmap )
+void BitmapDevice::convertBitmap( const BitmapDeviceSharedPtr& rSrcBitmap )
{
- copyBitmap_i( rSrcBitmap );
+ convertBitmap_i(rSrcBitmap);
}
-
/// Produces a specialized renderer for the given pixel format
template< class FormatTraits >
BitmapDeviceSharedPtr createRenderer(
@@ -670,11 +602,19 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize
BitmapDeviceSharedPtr cloneBitmapDevice(const BitmapDeviceSharedPtr& rProto)
{
- BitmapDeviceSharedPtr aCopy = createBitmapDeviceImpl(rProto->getSize(),
+ const basegfx::B2IVector& rSrcSize(rProto->getSize());
+
+ BitmapDeviceSharedPtr aCopy = createBitmapDeviceImpl(rSrcSize,
rProto->getScanlineFormat(),
boost::shared_array< sal_uInt8 >(),
rProto->getPalette() );
- aCopy->copyBitmap(rProto);
+
+ const sal_Int32 nSrcHeight = rSrcSize.getY();
+ char* dstBuf = reinterpret_cast<char*>(aCopy->getBuffer().get());
+ char* srcBuf = reinterpret_cast<char*>(rProto->getBuffer().get());
+ const sal_Int32 nStride = rProto->getScanlineStride();
+ memcpy(dstBuf, srcBuf, nStride * nSrcHeight);
+
return aCopy;
}