diff options
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 2 | ||||
-rw-r--r-- | vcl/Library_vcl.mk | 12 | ||||
-rw-r--r-- | vcl/headless/svpbmp.cxx | 466 | ||||
-rw-r--r-- | vcl/headless/svpgdi.cxx | 90 | ||||
-rw-r--r-- | vcl/headless/svpinst.cxx | 38 | ||||
-rw-r--r-- | vcl/inc/headless/svpbmp.hxx | 16 | ||||
-rw-r--r-- | vcl/inc/headless/svpgdi.hxx | 8 | ||||
-rw-r--r-- | vcl/inc/headless/svpinst.hxx | 4 | ||||
-rw-r--r-- | vcl/ios/iosinst.cxx | 3 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salbmp.cxx | 4 |
10 files changed, 201 insertions, 442 deletions
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 5fd2bf8c0ae7..635137ec7869 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -773,7 +773,7 @@ DECLARE_OOXMLIMPORT_TEST(testN777345, "n777345.docx") Graphic aGraphic(xGraphic); // If this changes later, feel free to update it, but make sure it's not // the checksum of a white/transparent placeholder rectangle. - CPPUNIT_ASSERT_EQUAL(BitmapChecksum(SAL_CONST_UINT64(12149824012634930130)), aGraphic.GetChecksum()); + CPPUNIT_ASSERT_EQUAL(BitmapChecksum(SAL_CONST_UINT64(17166884950237449306)), aGraphic.GetChecksum()); #endif } diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 3c63a7732faa..7093baca1812 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -592,10 +592,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ $(vcl_headless_freetype_code) \ )) -$(eval $(call gb_Library_use_libraries,vcl,\ - basebmp \ -)) - $(eval $(call gb_Library_use_externals,vcl,\ cairo \ cups \ @@ -616,10 +612,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ $(vcl_headless_freetype_code) \ )) -$(eval $(call gb_Library_use_libraries,vcl,\ - basebmp \ -)) - $(eval $(call gb_Library_use_externals,vcl,\ cairo \ freetype \ @@ -646,10 +638,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ $(vcl_headless_freetype_code) \ )) -$(eval $(call gb_Library_use_static_libraries,vcl,\ - basebmp \ -)) - $(eval $(call gb_Library_use_externals,vcl,\ cairo \ fontconfig \ diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 05545b6757f5..2fe05d2241f0 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -20,69 +20,160 @@ #ifndef IOS #include "headless/svpbmp.hxx" +#include "headless/svpgdi.hxx" #include "headless/svpinst.hxx" #include <basegfx/vector/b2ivector.hxx> #include <basegfx/range/b2ibox.hxx> -#include <basebmp/scanlineformats.hxx> -#include <basebmp/color.hxx> #include <vcl/salbtype.hxx> #include <vcl/bitmap.hxx> -using namespace basebmp; using namespace basegfx; SvpSalBitmap::~SvpSalBitmap() { + Destroy(); } -bool SvpSalBitmap::Create( const Size& rSize, - sal_uInt16 nBitCount, - const BitmapPalette& rPalette ) +BitmapBuffer* ImplCreateDIB( + const Size& rSize, + sal_uInt16 nBitCount, + const BitmapPalette& rPal) { - SAL_INFO( "vcl.headless", "SvpSalBitmap::Create(" << rSize.Width() << "," << rSize.Height() << "," << nBitCount << ")" ); - - basebmp::Format nFormat = SvpSalInstance::getBaseBmpFormatForBitCount( nBitCount ); - - B2IVector aSize( rSize.Width(), rSize.Height() ); - if( aSize.getX() == 0 ) - aSize.setX( 1 ); - if( aSize.getY() == 0 ) - aSize.setY( 1 ); - if( nBitCount > 8 ) - m_aBitmap = createBitmapDevice(aSize, nFormat); - else + assert( + (nBitCount == 0 + || nBitCount == 1 + || nBitCount == 4 + || nBitCount == 8 + || nBitCount == 16 + || nBitCount == 24 + || nBitCount == 32) + && "Unsupported BitCount!"); + + BitmapBuffer* pDIB = nullptr; + + if( rSize.Width() && rSize.Height() ) { - // prepare palette - unsigned int nEntries = 1U << nBitCount; - std::vector<basebmp::Color>* pPalette = - new std::vector<basebmp::Color>( nEntries, basebmp::Color(COL_WHITE) ); - unsigned int nColors = rPalette.GetEntryCount(); - for( unsigned int i = 0; i < nColors; i++ ) + try + { + pDIB = new BitmapBuffer; + } + catch (const std::bad_alloc&) + { + pDIB = nullptr; + } + + if( pDIB ) { - const BitmapColor& rCol = rPalette[i]; - (*pPalette)[i] = basebmp::Color( rCol.GetRed(), rCol.GetGreen(), rCol.GetBlue() ); + const sal_uInt16 nColors = ( nBitCount <= 8 ) ? ( 1 << nBitCount ) : 0; + + switch (nBitCount) + { + case 1: + pDIB->mnFormat = BMP_FORMAT_1BIT_MSB_PAL; + break; + case 4: + pDIB->mnFormat = BMP_FORMAT_4BIT_MSN_PAL; + break; + case 8: + pDIB->mnFormat = BMP_FORMAT_8BIT_PAL; + break; + case 16: + { +#ifdef OSL_BIGENDIAN + pDIB->mnFormat= BMP_FORMAT_16BIT_TC_MSB_MASK; +#else + pDIB->mnFormat= BMP_FORMAT_16BIT_TC_LSB_MASK; +#endif + ColorMaskElement aRedMask(0xf800); + aRedMask.CalcMaskShift(); + ColorMaskElement aGreenMask(0x07e0); + aGreenMask.CalcMaskShift(); + ColorMaskElement aBlueMask(0x001f); + aBlueMask.CalcMaskShift(); + pDIB->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask); + break; + } + default: + nBitCount = 32; + //fall through + case 32: + { + pDIB->mnFormat = SVP_CAIRO_FORMAT; + break; + } + } + + pDIB->mnFormat |= BMP_FORMAT_TOP_DOWN; + pDIB->mnWidth = rSize.Width(); + pDIB->mnHeight = rSize.Height(); + pDIB->mnScanlineSize = AlignedWidth4Bytes( pDIB->mnWidth * nBitCount ); + pDIB->mnBitCount = nBitCount; + + if( nColors ) + { + pDIB->maPalette = rPal; + pDIB->maPalette.SetEntryCount( nColors ); + } + + try + { + pDIB->mpBits = new sal_uInt8[ pDIB->mnScanlineSize * pDIB->mnHeight ]; + } + catch (const std::bad_alloc&) + { + delete pDIB; + pDIB = nullptr; + } } - m_aBitmap = createBitmapDevice( aSize, nFormat, - basebmp::RawMemorySharedArray(), - basebmp::PaletteMemorySharedVector(pPalette) ); } - return true; + else + pDIB = nullptr; + + return pDIB; +} + +bool SvpSalBitmap::Create(BitmapBuffer *pBuf) +{ + Destroy(); + mpDIB = pBuf; + return mpDIB != nullptr; +} + +bool SvpSalBitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal) +{ + Destroy(); + mpDIB = ImplCreateDIB( rSize, nBitCount, rPal ); + return mpDIB != nullptr; } -bool SvpSalBitmap::Create( const SalBitmap& rSalBmp ) +bool SvpSalBitmap::Create(const SalBitmap& rBmp) { - const SvpSalBitmap& rSrc = static_cast<const SvpSalBitmap&>(rSalBmp); - const BitmapDeviceSharedPtr& rSrcBmp = rSrc.getBitmap(); - if( rSrcBmp.get() ) + Destroy(); + + const SvpSalBitmap& rSalBmp = static_cast<const SvpSalBitmap&>(rBmp); + + if (rSalBmp.mpDIB) { - m_aBitmap = cloneBitmapDevice(rSrcBmp); + // TODO: reference counting... + mpDIB = new BitmapBuffer( *rSalBmp.mpDIB ); + // TODO: get rid of this when BitmapBuffer gets copy constructor + try + { + mpDIB->mpBits = new sal_uInt8[ mpDIB->mnScanlineSize * mpDIB->mnHeight ]; + } + catch (const std::bad_alloc&) + { + delete mpDIB; + mpDIB = nullptr; + } + + if (mpDIB) + memcpy(mpDIB->mpBits, rSalBmp.mpDIB->mpBits, mpDIB->mnScanlineSize * mpDIB->mnHeight); } - else - m_aBitmap.reset(); - return true; + return !rSalBmp.mpDIB || (rSalBmp.mpDIB && mpDIB != nullptr); } bool SvpSalBitmap::Create( const SalBitmap& /*rSalBmp*/, @@ -104,262 +195,42 @@ bool SvpSalBitmap::Create( const css::uno::Reference< css::rendering::XBitmapCan void SvpSalBitmap::Destroy() { - m_aBitmap.reset(); + if (mpDIB) + { + delete[] mpDIB->mpBits; + delete mpDIB, mpDIB = nullptr; + } } Size SvpSalBitmap::GetSize() const { Size aSize; - if( m_aBitmap.get() ) - { - B2IVector aVec( m_aBitmap->getSize() ); - aSize = Size( aVec.getX(), aVec.getY() ); - } + + if (mpDIB) + aSize.Width() = mpDIB->mnWidth, aSize.Height() = mpDIB->mnHeight; return aSize; } sal_uInt16 SvpSalBitmap::GetBitCount() const { - sal_uInt16 nDepth = 0; - if( m_aBitmap.get() ) - nDepth = getBitCountFromScanlineFormat( m_aBitmap->getScanlineFormat() ); - return nDepth; -} + sal_uInt16 nBitCount; -BitmapBuffer* SvpSalBitmap::AcquireBuffer( BitmapAccessMode ) -{ - BitmapBuffer* pBuf = nullptr; - if( m_aBitmap.get() ) - { - pBuf = new BitmapBuffer(); - sal_uInt16 nBitCount = 1; - switch( m_aBitmap->getScanlineFormat() ) - { - case Format::OneBitMsbGrey: - case Format::OneBitMsbPal: - nBitCount = 1; - pBuf->mnFormat = BMP_FORMAT_1BIT_MSB_PAL; - break; - case Format::OneBitLsbGrey: - case Format::OneBitLsbPal: - nBitCount = 1; - pBuf->mnFormat = BMP_FORMAT_1BIT_LSB_PAL; - break; - case Format::FourBitMsbGrey: - case Format::FourBitMsbPal: - nBitCount = 4; - pBuf->mnFormat = BMP_FORMAT_4BIT_MSN_PAL; - break; - case Format::FourBitLsbGrey: - case Format::FourBitLsbPal: - nBitCount = 4; - pBuf->mnFormat = BMP_FORMAT_4BIT_LSN_PAL; - break; - case Format::EightBitPal: - nBitCount = 8; - pBuf->mnFormat = BMP_FORMAT_8BIT_PAL; - break; - case Format::EightBitGrey: - nBitCount = 8; - pBuf->mnFormat = BMP_FORMAT_8BIT_PAL; - break; - case Format::SixteenBitLsbTcMask: - { - nBitCount = 16; - pBuf->mnFormat = BMP_FORMAT_16BIT_TC_LSB_MASK; - ColorMaskElement aRedMask(0xf800); - aRedMask.CalcMaskShift(); - ColorMaskElement aGreenMask(0x07e0); - aGreenMask.CalcMaskShift(); - ColorMaskElement aBlueMask(0x001f); - aBlueMask.CalcMaskShift(); - pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask); - break; - } - case Format::SixteenBitMsbTcMask: - { - nBitCount = 16; - pBuf->mnFormat = BMP_FORMAT_16BIT_TC_MSB_MASK; - ColorMaskElement aRedMask(0xf800); - aRedMask.CalcMaskShift(); - ColorMaskElement aGreenMask(0x07e0); - aGreenMask.CalcMaskShift(); - ColorMaskElement aBlueMask(0x001f); - aBlueMask.CalcMaskShift(); - pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask); - break; - } - case Format::TwentyFourBitTcMask: - nBitCount = 24; - pBuf->mnFormat = BMP_FORMAT_24BIT_TC_BGR; - break; - case Format::ThirtyTwoBitTcMaskBGRA: - { - nBitCount = 32; - pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK; - ColorMaskElement aRedMask(0x00ff0000); - ColorMaskElement aGreenMask(0x0000ff00); - ColorMaskElement aBlueMask(0x000000ff); - sal_uInt32 nAlphaChannel(0xff000000); - aBlueMask.CalcMaskShift(); - aRedMask.CalcMaskShift(); - aGreenMask.CalcMaskShift(); - pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask, nAlphaChannel); - break; - } - case Format::ThirtyTwoBitTcMaskARGB: - { - nBitCount = 32; - pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK; - ColorMaskElement aRedMask(0x0000ff00); - ColorMaskElement aGreenMask(0x00ff0000); - ColorMaskElement aBlueMask(0xff000000); - sal_uInt32 nAlphaChannel(0x000000ff); - aBlueMask.CalcMaskShift(); - aRedMask.CalcMaskShift(); - aGreenMask.CalcMaskShift(); - pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask, nAlphaChannel); - break; - } - case Format::ThirtyTwoBitTcMaskABGR: - { - nBitCount = 32; - pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK; - ColorMaskElement aRedMask(0xff000000); - ColorMaskElement aGreenMask(0x00ff0000); - ColorMaskElement aBlueMask(0x0000ff00); - sal_uInt32 nAlphaChannel(0x000000ff); - aBlueMask.CalcMaskShift(); - aRedMask.CalcMaskShift(); - aGreenMask.CalcMaskShift(); - pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask, nAlphaChannel); - break; - } - case Format::ThirtyTwoBitTcMaskRGBA: - { - nBitCount = 32; - pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK; - ColorMaskElement aRedMask(0x000000ff); - ColorMaskElement aGreenMask(0x0000ff00); - ColorMaskElement aBlueMask(0x00ff0000); - sal_uInt32 nAlphaChannel(0xff000000); - aBlueMask.CalcMaskShift(); - aRedMask.CalcMaskShift(); - aGreenMask.CalcMaskShift(); - pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask, nAlphaChannel); - break; - } - default: - // this is an error case !!!!! - nBitCount = 1; - pBuf->mnFormat = BMP_FORMAT_1BIT_MSB_PAL; - break; - } - - pBuf->mnFormat |= BMP_FORMAT_TOP_DOWN; - - B2IVector aSize = m_aBitmap->getSize(); - pBuf->mnWidth = aSize.getX(); - pBuf->mnHeight = aSize.getY(); - pBuf->mnScanlineSize = m_aBitmap->getScanlineStride(); - pBuf->mnBitCount = nBitCount; - pBuf->mpBits = m_aBitmap->getBuffer().get(); - if( nBitCount <= 8 ) - { - if( m_aBitmap->getScanlineFormat() == Format::EightBitGrey || - m_aBitmap->getScanlineFormat() == Format::FourBitLsbGrey || - m_aBitmap->getScanlineFormat() == Format::FourBitMsbGrey || - m_aBitmap->getScanlineFormat() == Format::OneBitLsbGrey || - m_aBitmap->getScanlineFormat() == Format::OneBitMsbGrey - ) - pBuf->maPalette = Bitmap::GetGreyPalette( 1U << nBitCount ); - else - { - basebmp::PaletteMemorySharedVector aPalette = m_aBitmap->getPalette(); - if( aPalette.get() ) - { - unsigned int nColors = aPalette->size(); - if( nColors > 0 ) - { - pBuf->maPalette.SetEntryCount( nColors ); - for( unsigned int i = 0; i < nColors; i++ ) - { - const basebmp::Color& rCol = (*aPalette)[i]; - pBuf->maPalette[i] = BitmapColor( rCol.getRed(), rCol.getGreen(), rCol.getBlue() ); - } - } - } - } - } - } + if (mpDIB) + nBitCount = mpDIB->mnBitCount; + else + nBitCount = 0; - return pBuf; + return nBitCount; } -void SvpSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) +BitmapBuffer* SvpSalBitmap::AcquireBuffer(BitmapAccessMode) { - if( nMode == BITMAP_WRITE_ACCESS && pBuffer->maPalette.GetEntryCount() ) - { - // palette might have changed, clone device (but recycle - // memory) - sal_uInt16 nBitCount = 0; - switch( m_aBitmap->getScanlineFormat() ) - { - case Format::OneBitMsbGrey: - // FALLTHROUGH intended - case Format::OneBitMsbPal: - // FALLTHROUGH intended - case Format::OneBitLsbGrey: - // FALLTHROUGH intended - case Format::OneBitLsbPal: - nBitCount = 1; - break; - - case Format::FourBitMsbGrey: - // FALLTHROUGH intended - case Format::FourBitMsbPal: - // FALLTHROUGH intended - case Format::FourBitLsbGrey: - // FALLTHROUGH intended - case Format::FourBitLsbPal: - nBitCount = 4; - break; - - case Format::EightBitPal: - // FALLTHROUGH intended - case Format::EightBitGrey: - nBitCount = 8; - break; - - default: - break; - } - - if( nBitCount ) - { - sal_uInt32 nEntries = 1U << nBitCount; - - std::shared_ptr< std::vector<basebmp::Color> > pPal( - new std::vector<basebmp::Color>( nEntries, - basebmp::Color(COL_WHITE))); - const sal_uInt32 nColors = std::min( - (sal_uInt32)pBuffer->maPalette.GetEntryCount(), - nEntries); - for( sal_uInt32 i = 0; i < nColors; i++ ) - { - const BitmapColor& rCol = pBuffer->maPalette[i]; - (*pPal)[i] = basebmp::Color( rCol.GetRed(), rCol.GetGreen(), rCol.GetBlue() ); - } - - m_aBitmap = basebmp::createBitmapDevice( m_aBitmap->getSize(), - m_aBitmap->getScanlineFormat(), - m_aBitmap->getBuffer(), - pPal ); - } - } + return mpDIB; +} - delete pBuffer; +void SvpSalBitmap::ReleaseBuffer(BitmapBuffer*, BitmapAccessMode) +{ } bool SvpSalBitmap::GetSystemData( BitmapSystemData& ) @@ -377,47 +248,6 @@ bool SvpSalBitmap::Replace( const ::Color& /*rSearchColor*/, const ::Color& /*rR return false; } -sal_uInt32 SvpSalBitmap::getBitCountFromScanlineFormat( basebmp::Format nFormat ) -{ - sal_uInt32 nBitCount = 1; - switch( nFormat ) - { - case Format::OneBitMsbGrey: - case Format::OneBitLsbGrey: - case Format::OneBitMsbPal: - case Format::OneBitLsbPal: - nBitCount = 1; - break; - case Format::FourBitMsbGrey: - case Format::FourBitLsbGrey: - case Format::FourBitMsbPal: - case Format::FourBitLsbPal: - nBitCount = 4; - break; - case Format::EightBitPal: - case Format::EightBitGrey: - nBitCount = 8; - break; - case Format::SixteenBitLsbTcMask: - case Format::SixteenBitMsbTcMask: - nBitCount = 16; - break; - case Format::TwentyFourBitTcMask: - nBitCount = 24; - break; - case Format::ThirtyTwoBitTcMaskBGRA: - case Format::ThirtyTwoBitTcMaskARGB: - case Format::ThirtyTwoBitTcMaskABGR: - case Format::ThirtyTwoBitTcMaskRGBA: - nBitCount = 32; - break; - default: - OSL_FAIL( "unsupported basebmp format" ); - break; - } - return nBitCount; -} - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 59e8947ed8f0..9af7bc292d0a 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -33,7 +33,6 @@ #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> -#include <basebmp/scanlineformats.hxx> #include <cairo.h> @@ -118,24 +117,26 @@ namespace public: SourceHelper(const SalBitmap& rSourceBitmap) { - const SvpSalBitmap& rSrc = static_cast<const SvpSalBitmap&>(rSourceBitmap); - const basebmp::BitmapDeviceSharedPtr& rSrcBmp = rSrc.getBitmap(); + const SvpSalBitmap& rSrcBmp = static_cast<const SvpSalBitmap&>(rSourceBitmap); - if (rSourceBitmap.GetBitCount() != 32) + if (rSrcBmp.GetBitCount() != 32) { //big stupid copy here static bool bWarnedOnce; SAL_WARN_IF(!bWarnedOnce, "vcl.gdi", "non default depth bitmap, slow convert, upscale the input"); bWarnedOnce = true; - Size aSize = rSourceBitmap.GetSize(); - aTmpBmp.Create(aSize, 0, BitmapPalette()); + + const BitmapBuffer* pSrc = rSrcBmp.GetBuffer(); + const SalTwoRect aTwoRect = { 0, 0, pSrc->mnWidth, pSrc->mnHeight, + 0, 0, pSrc->mnWidth, pSrc->mnHeight }; + aTmpBmp.Create(StretchAndConvert(*pSrc, aTwoRect, SVP_CAIRO_FORMAT)); + + assert(aTmpBmp.GetBitCount() == 32); - const basebmp::BitmapDeviceSharedPtr& rTmpSrc = aTmpBmp.getBitmap(); - rTmpSrc->convertBitmap(rSrcBmp); - source = SvpSalGraphics::createCairoSurface(rTmpSrc); + source = SvpSalGraphics::createCairoSurface(aTmpBmp.GetBuffer()); } else - source = SvpSalGraphics::createCairoSurface(rSrcBmp); + source = SvpSalGraphics::createCairoSurface(rSrcBmp.GetBuffer()); } ~SourceHelper() { @@ -156,20 +157,15 @@ namespace MaskHelper(const SalBitmap& rAlphaBitmap) { const SvpSalBitmap& rMask = static_cast<const SvpSalBitmap&>(rAlphaBitmap); - const basebmp::BitmapDeviceSharedPtr& rMaskBmp = rMask.getBitmap(); - - basegfx::B2IVector size = rMaskBmp->getSize(); - sal_Int32 nStride = rMaskBmp->getScanlineStride(); - basebmp::RawMemorySharedArray data = rMaskBmp->getBuffer(); + const BitmapBuffer* pMaskBuf = rMask.GetBuffer(); if (rAlphaBitmap.GetBitCount() == 8) { // the alpha values need to be inverted for Cairo // so big stupid copy and invert here - const int nImageSize = size.getY() * nStride; - const unsigned char* pSrcBits = data.get(); + const int nImageSize = pMaskBuf->mnHeight * pMaskBuf->mnScanlineSize; pAlphaBits = new unsigned char[nImageSize]; - memcpy(pAlphaBits, pSrcBits, nImageSize); + memcpy(pAlphaBits, pMaskBuf->mpBits, nImageSize); // TODO: make upper layers use standard alpha sal_uInt32* pLDst = reinterpret_cast<sal_uInt32*>(pAlphaBits); @@ -179,17 +175,18 @@ namespace mask = cairo_image_surface_create_for_data(pAlphaBits, CAIRO_FORMAT_A8, - size.getX(), size.getY(), - nStride); + pMaskBuf->mnWidth, pMaskBuf->mnHeight, + pMaskBuf->mnScanlineSize); } else { // the alpha values need to be inverted for Cairo // so big stupid copy and invert here - const int nImageSize = size.getY() * nStride; - const unsigned char* pSrcBits = data.get(); + const int nImageSize = pMaskBuf->mnHeight * pMaskBuf->mnScanlineSize; + pAlphaBits = new unsigned char[nImageSize]; + memcpy(pAlphaBits, pMaskBuf->mpBits, nImageSize); pAlphaBits = new unsigned char[nImageSize]; - memcpy(pAlphaBits, pSrcBits, nImageSize); + memcpy(pAlphaBits, pMaskBuf->mpBits, nImageSize); // TODO: make upper layers use standard alpha unsigned char* pDst = pAlphaBits; @@ -198,8 +195,8 @@ namespace mask = cairo_image_surface_create_for_data(pAlphaBits, CAIRO_FORMAT_A1, - size.getX(), size.getY(), - nStride); + pMaskBuf->mnWidth, pMaskBuf->mnHeight, + pMaskBuf->mnScanlineSize); } } ~MaskHelper() @@ -1077,10 +1074,10 @@ void SvpSalGraphics::drawMask( const SalTwoRect& rTR, SalBitmap* SvpSalGraphics::getBitmap( long nX, long nY, long nWidth, long nHeight ) { - basegfx::B2IVector aSize(nWidth, nHeight); - basebmp::BitmapDeviceSharedPtr aCopy = createBitmapDevice(aSize, SVP_CAIRO_FORMAT); + SvpSalBitmap* pBitmap = new SvpSalBitmap(); + pBitmap->Create(Size(nWidth, nHeight), 32, BitmapPalette()); - cairo_surface_t* target = SvpSalGraphics::createCairoSurface(aCopy); + cairo_surface_t* target = SvpSalGraphics::createCairoSurface(pBitmap->GetBuffer()); cairo_t* cr = cairo_create(target); SalTwoRect aTR(nX, nY, nWidth, nHeight, 0, 0, nWidth, nHeight); @@ -1089,9 +1086,6 @@ SalBitmap* SvpSalGraphics::getBitmap( long nX, long nY, long nWidth, long nHeigh cairo_destroy(cr); cairo_surface_destroy(target); - SvpSalBitmap* pBitmap = new SvpSalBitmap(); - pBitmap->setBitmap(aCopy); - return pBitmap; } @@ -1206,47 +1200,41 @@ bool SvpSalGraphics::drawEPS( long, long, long, long, void*, sal_uLong ) namespace { - cairo_format_t getCairoFormat(const basebmp::BitmapDeviceSharedPtr &rBuffer) + cairo_format_t getCairoFormat(const BitmapBuffer& rBuffer) { cairo_format_t nFormat; - if (rBuffer->getScanlineFormat() == SVP_CAIRO_FORMAT) + assert(rBuffer.mnBitCount == 32 || rBuffer.mnBitCount == 1); + if (rBuffer.mnBitCount == 32) nFormat = CAIRO_FORMAT_ARGB32; else nFormat = CAIRO_FORMAT_A1; return nFormat; } - bool isCairoCompatible(const basebmp::BitmapDeviceSharedPtr &rBuffer) + bool isCairoCompatible(const BitmapBuffer* pBuffer) { - if (!rBuffer) + if (!pBuffer) return false; - if (rBuffer->getScanlineFormat() != SVP_CAIRO_FORMAT && - rBuffer->getScanlineFormat() != basebmp::Format::OneBitMsbPal) + if (pBuffer->mnBitCount != 32 && pBuffer->mnBitCount != 1) return false; - basegfx::B2IVector size = rBuffer->getSize(); - sal_Int32 nStride = rBuffer->getScanlineStride(); - cairo_format_t nFormat = getCairoFormat(rBuffer); - return (cairo_format_stride_for_width(nFormat, size.getX()) == nStride); + cairo_format_t nFormat = getCairoFormat(*pBuffer); + return (cairo_format_stride_for_width(nFormat, pBuffer->mnWidth) == pBuffer->mnScanlineSize); } } -cairo_surface_t* SvpSalGraphics::createCairoSurface(const basebmp::BitmapDeviceSharedPtr &rBuffer) +cairo_surface_t* SvpSalGraphics::createCairoSurface(const BitmapBuffer *pBuffer) { - if (!isCairoCompatible(rBuffer)) + if (!isCairoCompatible(pBuffer)) return nullptr; - basegfx::B2IVector size = rBuffer->getSize(); - sal_Int32 nStride = rBuffer->getScanlineStride(); - - basebmp::RawMemorySharedArray data = rBuffer->getBuffer(); - cairo_format_t nFormat = getCairoFormat(rBuffer); + cairo_format_t nFormat = getCairoFormat(*pBuffer); cairo_surface_t *target = - cairo_image_surface_create_for_data(data.get(), + cairo_image_surface_create_for_data(pBuffer->mpBits, nFormat, - size.getX(), size.getY(), - nStride); + pBuffer->mnWidth, pBuffer->mnHeight, + pBuffer->mnScanlineSize); return target; } diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index f45b813f7dd8..5e3ffdfb771f 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -41,12 +41,9 @@ #include <salframe.hxx> #include <svdata.hxx> #include <unx/gendata.hxx> -#include <basebmp/scanlineformats.hxx> // FIXME: remove when we re-work the svp mainloop #include <unx/salunxtime.h> -using namespace basebmp; - bool SvpSalInstance::isFrameAlive( const SalFrame* pFrame ) const { for( std::list< SalFrame* >::const_iterator it = m_aFrames.begin(); @@ -417,39 +414,4 @@ void SvpSalTimer::Start( sal_uLong nMS ) m_pInstance->StartTimer( nMS ); } -Format SvpSalInstance::getBaseBmpFormatForBitCount( sal_uInt16 nBitCount ) -{ - switch( nBitCount ) - { - case 1: - return Format::OneBitMsbPal; - case 4: - return Format::FourBitMsbPal; - case 8: - return Format::EightBitPal; - case 16: -#ifdef OSL_BIGENDIAN - return Format::SixteenBitMsbTcMask; -#else - return Format::SixteenBitLsbTcMask; -#endif - case 32: - return Format::ThirtyTwoBitTcMaskBGRA; - default: - return SVP_CAIRO_FORMAT; - } - -} - -Format SvpSalInstance::getBaseBmpFormatForDeviceFormat(DeviceFormat eFormat) -{ - switch (eFormat) - { - case DeviceFormat::BITMASK: - return Format::OneBitMsbPal; - default: - return SVP_CAIRO_FORMAT; - } -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx index 757f6d52e03a..85c4e13c5a5a 100644 --- a/vcl/inc/headless/svpbmp.hxx +++ b/vcl/inc/headless/svpbmp.hxx @@ -23,20 +23,15 @@ #include "sal/config.h" #include "tools/solar.h" -#include "basebmp/bitmapdevice.hxx" - #include <salbmp.hxx> class VCL_DLLPUBLIC SvpSalBitmap : public SalBitmap { - basebmp::BitmapDeviceSharedPtr m_aBitmap; + BitmapBuffer* mpDIB; public: - SvpSalBitmap() {} + SvpSalBitmap() : mpDIB(nullptr) {} virtual ~SvpSalBitmap(); - const basebmp::BitmapDeviceSharedPtr& getBitmap() const { return m_aBitmap; } - void setBitmap( const basebmp::BitmapDeviceSharedPtr& rSrc ) { m_aBitmap = rSrc; } - // SalBitmap virtual bool Create( const Size& rSize, sal_uInt16 nBitCount, @@ -49,6 +44,11 @@ public: virtual bool Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas, Size& rSize, bool bMask = false ) override; + bool Create(BitmapBuffer *pBuf); + const BitmapBuffer* GetBuffer() const + { + return mpDIB; + } virtual void Destroy() override; virtual Size GetSize() const override; virtual sal_uInt16 GetBitCount() const override; @@ -59,8 +59,6 @@ public: virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override; virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) override; - - static sal_uInt32 getBitCountFromScanlineFormat( basebmp::Format nFormat ); }; #endif // INCLUDED_VCL_INC_HEADLESS_SVPBMP_HXX diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 1cece1a7b8d8..1dfba8901588 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -20,7 +20,6 @@ #ifndef INCLUDED_VCL_INC_HEADLESS_SVPGDI_HXX #define INCLUDED_VCL_INC_HEADLESS_SVPGDI_HXX -#include <basebmp/bitmapdevice.hxx> #include <vcl/sysdata.hxx> #include <vcl/metric.hxx> #include <config_cairo_canvas.h> @@ -39,11 +38,12 @@ //cairo then matches the OpenGL GL_RGBA format so we can use it there //where we don't have GL_BGRA support. #ifdef ANDROID -# define SVP_CAIRO_FORMAT basebmp::Format::ThirtyTwoBitTcMaskRGBA +# define SVP_CAIRO_FORMAT (BMP_FORMAT_32BIT_TC_RGBA | BMP_FORMAT_TOP_DOWN) #else -# define SVP_CAIRO_FORMAT basebmp::Format::ThirtyTwoBitTcMaskBGRA +# define SVP_CAIRO_FORMAT (BMP_FORMAT_32BIT_TC_BGRA | BMP_FORMAT_TOP_DOWN) #endif +class BitmapBuffer; class GlyphCache; class ServerFont; typedef struct _cairo cairo_t; @@ -219,7 +219,7 @@ public: cairo_t* getCairoContext(bool bXorModeAllowed) const; void releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, const cairo_rectangle_int_t& extents) const; - static cairo_surface_t* createCairoSurface(const basebmp::BitmapDeviceSharedPtr &rBuffer); + static cairo_surface_t* createCairoSurface(const BitmapBuffer *pBuffer); void clipRegion(cairo_t* cr); }; diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx index ecf68d48654b..417afd8f51de 100644 --- a/vcl/inc/headless/svpinst.hxx +++ b/vcl/inc/headless/svpinst.hxx @@ -27,7 +27,6 @@ #include <saltimer.hxx> #include <unx/geninst.h> #include <unx/genprn.h> -#include <basebmp/scanlineformats.hxx> #include <list> @@ -166,9 +165,6 @@ public: virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override; virtual GenPspGraphics *CreatePrintGraphics() override; - - static ::basebmp::Format getBaseBmpFormatForBitCount(sal_uInt16); - static ::basebmp::Format getBaseBmpFormatForDeviceFormat(DeviceFormat); }; #endif // INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx index 7bfb37e2226e..5f58b7bdbe28 100644 --- a/vcl/ios/iosinst.cxx +++ b/vcl/ios/iosinst.cxx @@ -21,8 +21,6 @@ #include <UIKit/UIKit.h> #include <postmac.h> -#include <basebmp/scanlineformats.hxx> - #include "ios/iosinst.hxx" #include "headless/svpdummies.hxx" #include "generic/gendata.hxx" @@ -92,7 +90,6 @@ public: SalFrameStyleFlags nSalFrameStyle, SystemParentData *pSysParent ) : SvpSalFrame( pInstance, pParent, nSalFrameStyle, - basebmp::Format::ThirtyTwoBitTcMaskRGBA, pSysParent ) { if (pParent == NULL && viewWidth > 1 && viewHeight > 1) diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx index 91c1f6fcd109..052c60647137 100644 --- a/vcl/unx/generic/gdi/salbmp.cxx +++ b/vcl/unx/generic/gdi/salbmp.cxx @@ -117,8 +117,8 @@ namespace BitmapBuffer* X11SalBitmap::ImplCreateDIB( const Size& rSize, sal_uInt16 nBitCount, - const BitmapPalette& rPal -) { + const BitmapPalette& rPal) +{ DBG_ASSERT( nBitCount == 1 || nBitCount == 4 |