diff options
Diffstat (limited to 'vcl')
27 files changed, 157 insertions, 250 deletions
diff --git a/vcl/headless/BitmapHelper.cxx b/vcl/headless/BitmapHelper.cxx index cfa9f1556eeb..0f21780144e8 100644 --- a/vcl/headless/BitmapHelper.cxx +++ b/vcl/headless/BitmapHelper.cxx @@ -40,8 +40,7 @@ BitmapHelper::BitmapHelper(const SalBitmap& rSourceBitmap, const bool bForceARGB const SalTwoRect aTwoRect = { 0, 0, pSrc->mnWidth, pSrc->mnHeight, 0, 0, pSrc->mnWidth, pSrc->mnHeight }; std::optional<BitmapBuffer> pTmp - = (pSrc->meFormat == SVP_24BIT_FORMAT - && pSrc->meDirection == ScanlineDirection::TopDown) + = (pSrc->meFormat == SVP_24BIT_FORMAT) ? FastConvert24BitRgbTo32BitCairo(pSrc) : StretchAndConvert(*pSrc, aTwoRect, SVP_CAIRO_FORMAT); aTmpBmp.Create(std::move(pTmp)); diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 78a16b729a9e..bf12617ba23e 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -1979,7 +1979,6 @@ std::optional<BitmapBuffer> FastConvert24BitRgbTo32BitCairo(const BitmapBuffer* const tools::Long nHeight = pSrc->mnHeight; std::optional<BitmapBuffer> pDst(std::in_place); pDst->meFormat = ScanlineFormat::N32BitTcArgb; - pDst->meDirection = ScanlineDirection::TopDown; pDst->mnWidth = nWidth; pDst->mnHeight = nHeight; pDst->mnBitCount = 32; diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx index 23a0d094d009..1fcf6f1e5c58 100644 --- a/vcl/headless/svpbmp.cxx +++ b/vcl/headless/svpbmp.cxx @@ -70,7 +70,6 @@ static std::optional<BitmapBuffer> ImplCreateDIB( if (ePixelFormat <= vcl::PixelFormat::N8_BPP) nColors = vcl::numberOfColors(ePixelFormat); - pDIB->meDirection = ScanlineDirection::TopDown; pDIB->mnWidth = rSize.Width(); pDIB->mnHeight = rSize.Height(); tools::Long nScanlineBase; diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx index d2b96f6253cf..eb991be08109 100644 --- a/vcl/headless/svpvd.cxx +++ b/vcl/headless/svpvd.cxx @@ -64,7 +64,28 @@ void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics ) bool SvpSalVirtualDevice::SetSize( tools::Long nNewDX, tools::Long nNewDY ) { - return SetSizeUsingBuffer(nNewDX, nNewDY, nullptr); + if (nNewDX == 0) + nNewDX = 1; + if (nNewDY == 0) + nNewDY = 1; + + if (m_pSurface && m_aFrameSize.getX() == nNewDX && m_aFrameSize.getY() == nNewDY) + return true; + + bool bSuccess = true; + + m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY); + + if (m_bOwnsSurface) + bSuccess = CreateSurface(nNewDX, nNewDY); + + assert(m_pSurface); + + // update device in existing graphics + for (auto const& graphic : m_aGraphics) + graphic->setSurface(m_pSurface, m_aFrameSize); + + return bSuccess; } bool SvpSalVirtualDevice::CreateSurface(tools::Long nNewDX, tools::Long nNewDY, sal_uInt8 *const pBuffer) @@ -74,21 +95,30 @@ bool SvpSalVirtualDevice::CreateSurface(tools::Long nNewDX, tools::Long nNewDY, cairo_surface_destroy(m_pSurface); } - if (pBuffer) + // The buffer should only be set by VirtualDevice::SetOutputSizePixelScaleOffsetAndLOKBuffer() + // when used to draw a tile for LOK. It cannot be used for something else, because otherwise + // this would need a way to detect whether this is a tiled paint that needs LOK handling + // or whether it's that something else that just might happen to be called with LOK active. + assert(comphelper::LibreOfficeKit::isActive()); + // Force scaling of the painting + double fScale = comphelper::LibreOfficeKit::getDPIScale(); + + m_pSurface = cairo_image_surface_create_for_data(pBuffer, CAIRO_FORMAT_ARGB32, + nNewDX, nNewDY, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, nNewDX)); + dl_cairo_surface_set_device_scale(m_pSurface, fScale, fScale); + + SAL_WARN_IF(cairo_surface_status(m_pSurface) != CAIRO_STATUS_SUCCESS, "vcl", "surface of size " << nNewDX << " by " << nNewDY << " creation failed with status of: " << cairo_status_to_string(cairo_surface_status(m_pSurface))); + return cairo_surface_status(m_pSurface) == CAIRO_STATUS_SUCCESS; +} + +bool SvpSalVirtualDevice::CreateSurface(tools::Long nNewDX, tools::Long nNewDY) +{ + if (m_pSurface) { - // The buffer should only be set by VirtualDevice::SetOutputSizePixelScaleOffsetAndLOKBuffer() - // when used to draw a tile for LOK. It cannot be used for something else, because otherwise - // this would need a way to detect whether this is a tiled paint that needs LOK handling - // or whether it's that something else that just might happen to be called with LOK active. - assert(comphelper::LibreOfficeKit::isActive()); - // Force scaling of the painting - double fScale = comphelper::LibreOfficeKit::getDPIScale(); - - m_pSurface = cairo_image_surface_create_for_data(pBuffer, CAIRO_FORMAT_ARGB32, - nNewDX, nNewDY, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, nNewDX)); - dl_cairo_surface_set_device_scale(m_pSurface, fScale, fScale); + cairo_surface_destroy(m_pSurface); } - else if(nNewDX <= 32 && nNewDY <= 32) + + if(nNewDX <= 32 && nNewDY <= 32) { double fXScale, fYScale; dl_cairo_surface_get_device_scale(m_pRefSurface, &fXScale, &fYScale); @@ -115,27 +145,31 @@ bool SvpSalVirtualDevice::CreateSurface(tools::Long nNewDX, tools::Long nNewDY, bool SvpSalVirtualDevice::SetSizeUsingBuffer( tools::Long nNewDX, tools::Long nNewDY, sal_uInt8 *const pBuffer) { - bool bSuccess = true; - if (nNewDX == 0) nNewDX = 1; if (nNewDY == 0) nNewDY = 1; - if (!m_pSurface || m_aFrameSize.getX() != nNewDX || - m_aFrameSize.getY() != nNewDY) + if (m_pSurface && m_aFrameSize.getX() == nNewDX && m_aFrameSize.getY() == nNewDY) { - m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY); + assert(false && "this means that the pBuffer parameter is going to be ignored"); + return true; + } - if (m_bOwnsSurface) - bSuccess = CreateSurface(nNewDX, nNewDY, pBuffer); + bool bSuccess = true; - assert(m_pSurface); + m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY); - // update device in existing graphics - for (auto const& graphic : m_aGraphics) - graphic->setSurface(m_pSurface, m_aFrameSize); - } + if (m_bOwnsSurface) + bSuccess = CreateSurface(nNewDX, nNewDY, pBuffer); + else + assert(false && "this means that the pBuffer parameter is going to be ignored"); + + assert(m_pSurface); + + // update device in existing graphics + for (auto const& graphic : m_aGraphics) + graphic->setSurface(m_pSurface, m_aFrameSize); return bSuccess; } diff --git a/vcl/inc/DropdownBox.hxx b/vcl/inc/DropdownBox.hxx index 0e3c3e315561..a66a841100eb 100644 --- a/vcl/inc/DropdownBox.hxx +++ b/vcl/inc/DropdownBox.hxx @@ -39,7 +39,6 @@ public: void HideContent() override; void ShowContent() override; - bool IsHidden() override; private: DECL_LINK(PBClickHdl, Button*, void); diff --git a/vcl/inc/IPrioritable.hxx b/vcl/inc/IPrioritable.hxx index 0b8dec9ec095..0ad53dd9c076 100644 --- a/vcl/inc/IPrioritable.hxx +++ b/vcl/inc/IPrioritable.hxx @@ -40,7 +40,6 @@ public: virtual void HideContent() = 0; virtual void ShowContent() = 0; - virtual bool IsHidden() = 0; private: int m_nPriority; diff --git a/vcl/inc/OptionalBox.hxx b/vcl/inc/OptionalBox.hxx index 05ab1cbf0cff..6ba0a4f4ce77 100644 --- a/vcl/inc/OptionalBox.hxx +++ b/vcl/inc/OptionalBox.hxx @@ -33,7 +33,6 @@ public: void HideContent() override; void ShowContent() override; - bool IsHidden() override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx index f1666b689aca..245634d229d9 100644 --- a/vcl/inc/headless/svpvd.hxx +++ b/vcl/inc/headless/svpvd.hxx @@ -37,6 +37,7 @@ class VCL_DLLPUBLIC SvpSalVirtualDevice : public SalVirtualDevice std::vector< SvpSalGraphics* > m_aGraphics; bool CreateSurface(tools::Long nNewDX, tools::Long nNewDY, sal_uInt8 *const pBuffer); + bool CreateSurface(tools::Long nNewDX, tools::Long nNewDY); protected: SvpSalGraphics* AddGraphics(SvpSalGraphics* aGraphics); diff --git a/vcl/inc/jsdialog/jsdialogsender.hxx b/vcl/inc/jsdialog/jsdialogsender.hxx index c43cf04cccb4..a83e0edbe2bd 100644 --- a/vcl/inc/jsdialog/jsdialogsender.hxx +++ b/vcl/inc/jsdialog/jsdialogsender.hxx @@ -57,16 +57,16 @@ public: virtual ~JSDialogSender() COVERITY_NOEXCEPT_FALSE; - virtual void sendFullUpdate(bool bForce = false); + void sendFullUpdate(bool bForce = false); void sendClose(); void sendUpdate(const VclPtr<vcl::Window>& pWindow, bool bForce = false); - virtual void sendAction(const VclPtr<vcl::Window>& pWindow, - std::unique_ptr<jsdialog::ActionDataMap> pData); - virtual void sendPopup(const VclPtr<vcl::Window>& pWindow, const OUString& sParentId, - const OUString& sCloseId); - virtual void sendMenu(const VclPtr<PopupMenu>& pMenu, const OUString& sParentId, - const OUString& sCloseId); - virtual void sendClosePopup(vcl::LOKWindowId nWindowId); + void sendAction(const VclPtr<vcl::Window>& pWindow, + std::unique_ptr<jsdialog::ActionDataMap> pData); + void sendPopup(const VclPtr<vcl::Window>& pWindow, const OUString& sParentId, + const OUString& sCloseId); + void sendMenu(const VclPtr<PopupMenu>& pMenu, const OUString& sParentId, + const OUString& sCloseId); + void sendClosePopup(vcl::LOKWindowId nWindowId); void flush() { mpIdleNotify->Invoke(); } protected: diff --git a/vcl/inc/salvd.hxx b/vcl/inc/salvd.hxx index d1035feaebdd..daa790bc482e 100644 --- a/vcl/inc/salvd.hxx +++ b/vcl/inc/salvd.hxx @@ -44,13 +44,13 @@ public: virtual bool SetSize( tools::Long nNewDX, tools::Long nNewDY ) = 0; // Set new size using a buffer at the given address - virtual bool SetSizeUsingBuffer( tools::Long nNewDX, tools::Long nNewDY, - sal_uInt8 * /* pBuffer */) - { - // Only the headless virtual device has an implementation that uses - // pBuffer (and bTopDown). - return SetSize( nNewDX, nNewDY ); - } + virtual bool SetSizeUsingBuffer( tools::Long /*nNewDX*/, tools::Long /*nNewDY*/, + sal_uInt8 * /*pBuffer*/) + { + // Only the headless virtual device has an implementation. + assert(false && "unsupported"); + return false; + } }; #endif // INCLUDED_VCL_INC_SALVD_HXX diff --git a/vcl/qt5/QtBitmap.cxx b/vcl/qt5/QtBitmap.cxx index 235f94715e04..26cb42154042 100644 --- a/vcl/qt5/QtBitmap.cxx +++ b/vcl/qt5/QtBitmap.cxx @@ -120,7 +120,6 @@ BitmapBuffer* QtBitmap::AcquireBuffer(BitmapAccessMode /*nMode*/) pBuffer->mnBitCount = getFormatBits(m_pImage->format()); pBuffer->mpBits = m_pImage->bits(); pBuffer->mnScanlineSize = m_pImage->bytesPerLine(); - pBuffer->meDirection = ScanlineDirection::TopDown; switch (pBuffer->mnBitCount) { diff --git a/vcl/qt5/QtVirtualDevice.cxx b/vcl/qt5/QtVirtualDevice.cxx index c9db9fb5d0e5..68c7c4a5add2 100644 --- a/vcl/qt5/QtVirtualDevice.cxx +++ b/vcl/qt5/QtVirtualDevice.cxx @@ -45,7 +45,29 @@ void QtVirtualDevice::ReleaseGraphics(SalGraphics* pGraphics) bool QtVirtualDevice::SetSize(tools::Long nNewDX, tools::Long nNewDY) { - return SetSizeUsingBuffer(nNewDX, nNewDY, nullptr); + if (nNewDX == 0) + nNewDX = 1; + if (nNewDY == 0) + nNewDY = 1; + + if (m_pImage && m_aFrameSize.width() == nNewDX && m_aFrameSize.height() == nNewDY) + return true; + + m_aFrameSize = QSize(nNewDX, nNewDY); + + nNewDX *= m_fScale; + nNewDY *= m_fScale; + + m_pImage.reset(new QImage(nNewDX, nNewDY, Qt_DefaultFormat32)); + + m_pImage->fill(Qt::transparent); + m_pImage->setDevicePixelRatio(m_fScale); + + // update device in existing graphics + for (auto pQtGraph : m_aGraphics) + pQtGraph->ChangeQImage(m_pImage.get()); + + return true; } bool QtVirtualDevice::SetSizeUsingBuffer(tools::Long nNewDX, tools::Long nNewDY, sal_uInt8* pBuffer) @@ -63,10 +85,7 @@ bool QtVirtualDevice::SetSizeUsingBuffer(tools::Long nNewDX, tools::Long nNewDY, nNewDX *= m_fScale; nNewDY *= m_fScale; - if (pBuffer) - m_pImage.reset(new QImage(pBuffer, nNewDX, nNewDY, Qt_DefaultFormat32)); - else - m_pImage.reset(new QImage(nNewDX, nNewDY, Qt_DefaultFormat32)); + m_pImage.reset(new QImage(pBuffer, nNewDX, nNewDY, Qt_DefaultFormat32)); m_pImage->fill(Qt::transparent); m_pImage->setDevicePixelRatio(m_fScale); diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index 144f3496d44b..ca1bcf863241 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -312,7 +312,6 @@ BitmapBuffer* SkiaSalBitmap::AcquireBuffer(BitmapAccessMode nMode) default: abort(); } - buffer->meDirection = ScanlineDirection::TopDown; // Refcount all read/write accesses, to catch problems with existing accesses while // a bitmap changes, and also to detect when we can free mBuffer if wanted. // Write mode implies also reading. It would be probably a good idea to count even @@ -1147,7 +1146,6 @@ void SkiaSalBitmap::PerformErase() if (!ImplFastEraseBitmap(*bitmapBuffer, fastColor)) { FncSetPixel setPixel = BitmapReadAccess::SetPixelFunction(bitmapBuffer->meFormat); - assert(bitmapBuffer->meDirection == ScanlineDirection::TopDown); // Set first scanline, copy to others. Scanline scanline = bitmapBuffer->mpBits; for (tools::Long x = 0; x < bitmapBuffer->mnWidth; ++x) diff --git a/vcl/source/bitmap/bmpfast.cxx b/vcl/source/bitmap/bmpfast.cxx index 74da808b96cb..bae0ed1f5b3f 100644 --- a/vcl/source/bitmap/bmpfast.cxx +++ b/vcl/source/bitmap/bmpfast.cxx @@ -268,13 +268,7 @@ static bool ImplCopyImage( BitmapBuffer& rDstBuffer, const BitmapBuffer& rSrcBuf const PIXBYTE* pRawSrc = rSrcBuffer.mpBits; PIXBYTE* pRawDst = rDstBuffer.mpBits; - // source and destination don't match upside down - if (rSrcBuffer.meDirection != rDstBuffer.meDirection) - { - pRawDst += (rSrcBuffer.mnHeight - 1) * nDstLinestep; - nDstLinestep = -rDstBuffer.mnScanlineSize; - } - else if( nSrcLinestep == nDstLinestep ) + if( nSrcLinestep == nDstLinestep ) { memcpy( pRawDst, pRawSrc, rSrcBuffer.mnHeight * nDstLinestep ); return true; @@ -308,13 +302,6 @@ static bool ImplConvertToBitmap( TrueColorPixelPtr<SRCFMT>& rSrcLine, TrueColorPixelPtr<DSTFMT> aDstLine; aDstLine.SetRawPtr( rDstBuffer.mpBits ); - // source and destination don't match upside down - if (rSrcBuffer.meDirection != rDstBuffer.meDirection) - { - aDstLine.AddByteOffset( (rSrcBuffer.mnHeight - 1) * nDstLinestep ); - nDstLinestep = -nDstLinestep; - } - for( int y = rSrcBuffer.mnHeight; --y >= 0; ) { ImplConvertLine( aDstLine, rSrcLine, rSrcBuffer.mnWidth ); @@ -379,7 +366,6 @@ bool ImplFastBitmapConversion( BitmapBuffer& rDst, const BitmapBuffer& rSrc, return false; // vertical mirroring if( rTR.mnDestHeight < 0 ) - // TODO: rDst.meDirection != ScanlineDirection::TopDown; return false; // offsetted conversion is not implemented yet @@ -463,10 +449,7 @@ bool ImplFastBitmapConversion( BitmapBuffer& rDst, const BitmapBuffer& rSrc, static inline ConstScanline ImplGetScanline( const BitmapBuffer& rBuf, tools::Long nY ) { - if (rBuf.meDirection == ScanlineDirection::TopDown) - return rBuf.mpBits + nY * rBuf.mnScanlineSize; - else - return rBuf.mpBits + (rBuf.mnHeight - 1 - nY) * rBuf.mnScanlineSize; + return rBuf.mpBits + nY * rBuf.mnScanlineSize; } static inline Scanline ImplGetScanline( BitmapBuffer& rBuf, tools::Long nY ) @@ -584,20 +567,6 @@ static bool ImplBlendToBitmap( TrueColorPixelPtr<SRCFMT>& rSrcLine, if( rMskBuffer.mnHeight == 1 ) nMskLinestep = 0; - // source and mask don't match: upside down - if (rSrcBuffer.meDirection != rMskBuffer.meDirection) - { - aMskLine.AddByteOffset( (rSrcBuffer.mnHeight - 1) * nMskLinestep ); - nMskLinestep = -nMskLinestep; - } - - // source and destination don't match: upside down - if (rSrcBuffer.meDirection != rDstBuffer.meDirection) - { - aDstLine.AddByteOffset( (rDstBuffer.mnHeight - 1) * nDstLinestep ); - nDstLinestep = -nDstLinestep; - } - assert(rDstBuffer.mnHeight <= rSrcBuffer.mnHeight && "not sure about that?"); for (int y = rDstBuffer.mnHeight; --y >= 0;) { @@ -700,7 +669,6 @@ bool ImplFastBitmapBlending( BitmapWriteAccess const & rDstWA, return false; // vertical mirroring if( rTR.mnDestHeight < 0 ) - // TODO: rDst.meDirection != ScanlineDirection::TopDown; return false; // offsetted blending is not implemented yet diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx index 97bcb86b0feb..cd7155e47935 100644 --- a/vcl/source/bitmap/dibtools.cxx +++ b/vcl/source/bitmap/dibtools.cxx @@ -499,7 +499,7 @@ bool ImplReadDIBBits(SvStream& rIStm, DIBV5Header& rHeader, BitmapWriteAccess& r { // we can't trust arbitrary-sourced index based formats to have correct indexes, so we exclude the pal formats // from raw read and force checking their colormap indexes - bNative = ( ( rAcc.IsBottomUp() != bTopDown ) && !bRLE && !bTCMask && ( rAcc.GetScanlineSize() == nAlignedWidth ) ); + bNative = bTopDown && !bRLE && !bTCMask && ( rAcc.GetScanlineSize() == nAlignedWidth ); break; } @@ -1246,13 +1246,8 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, sal_uLong rImageSize = rOStm.Tell(); - if( rAcc.IsBottomUp() ) - rOStm.WriteBytes(rAcc.GetBuffer(), rAcc.Height() * rAcc.GetScanlineSize()); - else - { - for( tools::Long nY = rAcc.Height() - 1, nScanlineSize = rAcc.GetScanlineSize(); nY >= 0; nY-- ) - rOStm.WriteBytes( rAcc.GetScanline(nY), nScanlineSize ); - } + for( tools::Long nY = rAcc.Height() - 1, nScanlineSize = rAcc.GetScanlineSize(); nY >= 0; nY-- ) + rOStm.WriteBytes( rAcc.GetScanline(nY), nScanlineSize ); } else if((RLE_4 == nCompression) || (RLE_8 == nCompression)) { @@ -1271,88 +1266,60 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, sal_uLong // (other cases are not written below) const auto ePixelFormat(convertToBPP(rAcc.GetBitCount())); const sal_uLong nAlignedWidth(AlignedWidth4Bytes(rAcc.Width() * sal_Int32(ePixelFormat))); - bool bNative(false); - switch(rAcc.GetScanlineFormat()) + rImageSize = rOStm.Tell(); + + const tools::Long nWidth(rAcc.Width()); + const tools::Long nHeight(rAcc.Height()); + std::vector<sal_uInt8> aBuf(nAlignedWidth); + switch(ePixelFormat) { - case ScanlineFormat::N1BitMsbPal: - case ScanlineFormat::N8BitPal: - case ScanlineFormat::N24BitTcBgr: + case vcl::PixelFormat::N8_BPP: { - if(rAcc.IsBottomUp() && (rAcc.GetScanlineSize() == nAlignedWidth)) + for( tools::Long nY = nHeight - 1; nY >= 0; nY-- ) { - bNative = true; - } + sal_uInt8* pTmp = aBuf.data(); + Scanline pScanline = rAcc.GetScanline( nY ); - break; + for( tools::Long nX = 0; nX < nWidth; nX++ ) + *pTmp++ = rAcc.GetIndexFromData( pScanline, nX ); + + rOStm.WriteBytes(aBuf.data(), nAlignedWidth); + } } + break; - default: + case vcl::PixelFormat::N24_BPP: { - break; + //valgrind, zero out the trailing unused alignment bytes + size_t nUnusedBytes = nAlignedWidth - nWidth * 3; + memset(aBuf.data() + nAlignedWidth - nUnusedBytes, 0, nUnusedBytes); } - } - - rImageSize = rOStm.Tell(); - - if(bNative) - { - rOStm.WriteBytes(rAcc.GetBuffer(), nAlignedWidth * rAcc.Height()); - } - else - { - const tools::Long nWidth(rAcc.Width()); - const tools::Long nHeight(rAcc.Height()); - std::vector<sal_uInt8> aBuf(nAlignedWidth); - switch(ePixelFormat) + [[fallthrough]]; + // #i59239# fallback to 24 bit format, if bitcount is non-default + default: { - case vcl::PixelFormat::N8_BPP: - { - for( tools::Long nY = nHeight - 1; nY >= 0; nY-- ) - { - sal_uInt8* pTmp = aBuf.data(); - Scanline pScanline = rAcc.GetScanline( nY ); + BitmapColor aPixelColor; - for( tools::Long nX = 0; nX < nWidth; nX++ ) - *pTmp++ = rAcc.GetIndexFromData( pScanline, nX ); - - rOStm.WriteBytes(aBuf.data(), nAlignedWidth); - } - } - break; - - case vcl::PixelFormat::N24_BPP: - { - //valgrind, zero out the trailing unused alignment bytes - size_t nUnusedBytes = nAlignedWidth - nWidth * 3; - memset(aBuf.data() + nAlignedWidth - nUnusedBytes, 0, nUnusedBytes); - } - [[fallthrough]]; - // #i59239# fallback to 24 bit format, if bitcount is non-default - default: + for( tools::Long nY = nHeight - 1; nY >= 0; nY-- ) { - BitmapColor aPixelColor; + sal_uInt8* pTmp = aBuf.data(); - for( tools::Long nY = nHeight - 1; nY >= 0; nY-- ) + for( tools::Long nX = 0; nX < nWidth; nX++ ) { - sal_uInt8* pTmp = aBuf.data(); - - for( tools::Long nX = 0; nX < nWidth; nX++ ) - { - // when alpha is used, this may be non-24bit main bitmap, so use GetColor - // instead of GetPixel to ensure RGB value - aPixelColor = rAcc.GetColor( nY, nX ); + // when alpha is used, this may be non-24bit main bitmap, so use GetColor + // instead of GetPixel to ensure RGB value + aPixelColor = rAcc.GetColor( nY, nX ); - *pTmp++ = aPixelColor.GetBlue(); - *pTmp++ = aPixelColor.GetGreen(); - *pTmp++ = aPixelColor.GetRed(); - } - - rOStm.WriteBytes(aBuf.data(), nAlignedWidth); + *pTmp++ = aPixelColor.GetBlue(); + *pTmp++ = aPixelColor.GetGreen(); + *pTmp++ = aPixelColor.GetRed(); } + + rOStm.WriteBytes(aBuf.data(), nAlignedWidth); } - break; } + break; } } diff --git a/vcl/source/bitmap/salbmp.cxx b/vcl/source/bitmap/salbmp.cxx index 3e8f0b255d2d..a84fc63f4042 100644 --- a/vcl/source/bitmap/salbmp.cxx +++ b/vcl/source/bitmap/salbmp.cxx @@ -62,19 +62,11 @@ void SalBitmap::updateChecksum() const break; } } - if (pBuf->meDirection == ScanlineDirection::TopDown) - { - if( pBuf->mnScanlineSize == lineBitsCount / 8 ) - nCrc = rtl_crc32(nCrc, pBuf->mpBits, pBuf->mnScanlineSize * pBuf->mnHeight); - else // Do not include padding with undefined content in the checksum. - for( tools::Long y = 0; y < pBuf->mnHeight; ++y ) - nCrc = scanlineChecksum(nCrc, pBuf->mpBits + y * pBuf->mnScanlineSize, lineBitsCount, extraBitsMask); - } - else // Compute checksum in the order of scanlines, to make it consistent between different bitmap implementations. - { - for( tools::Long y = pBuf->mnHeight - 1; y >= 0; --y ) + if( pBuf->mnScanlineSize == lineBitsCount / 8 ) + nCrc = rtl_crc32(nCrc, pBuf->mpBits, pBuf->mnScanlineSize * pBuf->mnHeight); + else // Do not include padding with undefined content in the checksum. + for( tools::Long y = 0; y < pBuf->mnHeight; ++y ) nCrc = scanlineChecksum(nCrc, pBuf->mpBits + y * pBuf->mnScanlineSize, lineBitsCount, extraBitsMask); - } pThis->ReleaseBuffer(pBuf, BitmapAccessMode::Read); pThis->mnChecksum = nCrc; pThis->mbChecksumValid = true; diff --git a/vcl/source/control/DropdownBox.cxx b/vcl/source/control/DropdownBox.cxx index 6aaf2e553ace..b1895ecbdf9d 100644 --- a/vcl/source/control/DropdownBox.cxx +++ b/vcl/source/control/DropdownBox.cxx @@ -65,8 +65,6 @@ void DropdownBox::HideContent() } } -bool DropdownBox::IsHidden() { return !m_bInFullView; } - void DropdownBox::ShowContent() { if (!m_bInFullView) diff --git a/vcl/source/filter/webp/reader.cxx b/vcl/source/filter/webp/reader.cxx index cfc28a18440b..2cc3f8c6a08e 100644 --- a/vcl/source/filter/webp/reader.cxx +++ b/vcl/source/filter/webp/reader.cxx @@ -215,23 +215,7 @@ static bool readWebp(SvStream& stream, Graphic& graphic) switch (pixelMode) { case PixelMode::DirectRead: - { - // Adjust for IsBottomUp() if necessary. - if (access->IsBottomUp()) - { - std::vector<char> tmp; - const sal_uInt32 lineSize = access->GetScanlineSize(); - tmp.resize(lineSize); - for (tools::Long y = 0; y < access->Height() / 2; ++y) - { - tools::Long otherY = access->Height() - 1 - y; - memcpy(tmp.data(), access->GetScanline(y), lineSize); - memcpy(access->GetScanline(y), access->GetScanline(otherY), lineSize); - memcpy(access->GetScanline(otherY), tmp.data(), lineSize); - } - } break; - } case PixelMode::Split: { // Split to normal and alpha bitmaps. diff --git a/vcl/source/filter/webp/writer.cxx b/vcl/source/filter/webp/writer.cxx index cd63cd2d2786..6a4e772eafd4 100644 --- a/vcl/source/filter/webp/writer.cxx +++ b/vcl/source/filter/webp/writer.cxx @@ -99,7 +99,7 @@ static bool writeWebp(SvStream& rStream, const BitmapEx& bitmapEx, bool lossless BitmapScopedReadAccess access(bitmap); BitmapScopedReadAccess accessAlpha(bitmapAlpha); bool dataDone = false; - if (!access->IsBottomUp() && bitmapAlpha.IsEmpty()) + if (bitmapAlpha.IsEmpty()) { // Try to directly copy the bitmap data. switch (access->GetScanlineFormat()) diff --git a/vcl/source/gdi/salmisc.cxx b/vcl/source/gdi/salmisc.cxx index 79d976ac25db..2ab6f77a23f1 100644 --- a/vcl/source/gdi/salmisc.cxx +++ b/vcl/source/gdi/salmisc.cxx @@ -235,7 +235,6 @@ std::optional<BitmapBuffer> StretchAndConvert( std::optional<BitmapBuffer> pDstBuffer(std::in_place); - pDstBuffer->meDirection = rSrcBuffer.meDirection; // set function for getting pixels pFncGetPixel = BitmapReadAccess::GetPixelFunction(rSrcBuffer.meFormat); if( !pFncGetPixel ) @@ -379,33 +378,15 @@ std::optional<BitmapBuffer> StretchAndConvert( } // source scanline buffer - Scanline pTmpScan; - tools::Long nOffset; - if (rSrcBuffer.meDirection == ScanlineDirection::TopDown) - { - pTmpScan = rSrcBuffer.mpBits; - nOffset = rSrcBuffer.mnScanlineSize; - } - else - { - pTmpScan = rSrcBuffer.mpBits + ( rSrcBuffer.mnHeight - 1 ) * rSrcBuffer.mnScanlineSize; - nOffset = -rSrcBuffer.mnScanlineSize; - } + Scanline pTmpScan = rSrcBuffer.mpBits; + tools::Long nOffset = rSrcBuffer.mnScanlineSize; for (tools::Long i = 0; i < rSrcBuffer.mnHeight; i++, pTmpScan += nOffset) pSrcScan[ i ] = pTmpScan; // destination scanline buffer - if (pDstBuffer->meDirection == ScanlineDirection::TopDown) - { - pTmpScan = pDstBuffer->mpBits; - nOffset = pDstBuffer->mnScanlineSize; - } - else - { - pTmpScan = pDstBuffer->mpBits + ( pDstBuffer->mnHeight - 1 ) * pDstBuffer->mnScanlineSize; - nOffset = -pDstBuffer->mnScanlineSize; - } + pTmpScan = pDstBuffer->mpBits; + nOffset = pDstBuffer->mnScanlineSize; for (tools::Long i = 0; i < pDstBuffer->mnHeight; i++, pTmpScan += nOffset) pDstScan[ i ] = pTmpScan; diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index 9615cb8fa01e..6c44cb110fce 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -291,6 +291,7 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra } else { + assert(!pBuffer && "passing pBuffer without bErase is not supported"); std::unique_ptr<SalVirtualDevice> pNewVirDev; ImplSVData* pSVData = ImplGetSVData(); diff --git a/vcl/source/helper/canvasbitmap.cxx b/vcl/source/helper/canvasbitmap.cxx index fc260b591773..55a606a466e4 100644 --- a/vcl/source/helper/canvasbitmap.cxx +++ b/vcl/source/helper/canvasbitmap.cxx @@ -399,11 +399,6 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getData( rendering::IntegerB bitmapLayout.ScanLineStride= aRequestedBytes.getOpenWidth(); sal_Int32 nScanlineStride=bitmapLayout.ScanLineStride; - if (m_pBmpAcc->IsBottomUp()) - { - pOutBuf += bitmapLayout.ScanLineStride*(aRequestedBytes.getOpenHeight()-1); - nScanlineStride *= -1; - } if( !m_aBmpEx.IsAlpha() ) { diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index 19fb34df5d96..c0ab64b8ab7f 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -561,25 +561,16 @@ BitmapEx OpenGLHelper::ConvertBufferToBitmapEx(const sal_uInt8* const pBuffer, t BitmapScopedWriteAccess pAlphaWriteAccess( aAlpha ); #ifdef _WIN32 assert(pWriteAccess->GetScanlineFormat() == ScanlineFormat::N24BitTcBgr); - assert(pWriteAccess->IsTopDown()); - assert(pAlphaWriteAccess->IsTopDown()); #else assert(pWriteAccess->GetScanlineFormat() == ScanlineFormat::N24BitTcRgb); - assert(!pWriteAccess->IsTopDown()); - assert(!pAlphaWriteAccess->IsTopDown()); #endif assert(pAlphaWriteAccess->GetScanlineFormat() == ScanlineFormat::N8BitPal); size_t nCurPos = 0; for( tools::Long y = 0; y < nHeight; ++y) { -#ifdef _WIN32 Scanline pScan = pWriteAccess->GetScanline(y); Scanline pAlphaScan = pAlphaWriteAccess->GetScanline(y); -#else - Scanline pScan = pWriteAccess->GetScanline(nHeight-1-y); - Scanline pAlphaScan = pAlphaWriteAccess->GetScanline(nHeight-1-y); -#endif for( tools::Long x = 0; x < nWidth; ++x ) { *pScan++ = pBuffer[nCurPos]; diff --git a/vcl/source/window/OptionalBox.cxx b/vcl/source/window/OptionalBox.cxx index 28055f7e210e..53ffe41afe39 100644 --- a/vcl/source/window/OptionalBox.cxx +++ b/vcl/source/window/OptionalBox.cxx @@ -57,6 +57,4 @@ void OptionalBox::ShowContent() } } -bool OptionalBox::IsHidden() { return !m_bInFullView; } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 173edb8932e0..616ff93da13c 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1075,11 +1075,6 @@ bool Window::IsMenuFloatingWindow() const return mpWindowImpl && mpWindowImpl->mbMenuFloatingWindow; } -bool Window::IsToolbarFloatingWindow() const -{ - return mpWindowImpl && mpWindowImpl->mbToolbarFloatingWindow; -} - bool Window::IsNativeFrame() const { if( mpWindowImpl->mbFrame ) diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx index 16cb794eaf8e..780f91ee8fdb 100644 --- a/vcl/win/gdi/salbmp.cxx +++ b/vcl/win/gdi/salbmp.cxx @@ -251,7 +251,6 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap() { sal_uInt8* pSrcRGB(pRGB->mpBits); const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3)); - const bool bTopDown(pRGB->meDirection == ScanlineDirection::TopDown); const Gdiplus::Rect aAllRect(0, 0, nW, nH); Gdiplus::BitmapData aGdiPlusBitmapData; pRetval->LockBits(&aAllRect, Gdiplus::ImageLockModeWrite, PixelFormat24bppRGB, &aGdiPlusBitmapData); @@ -259,8 +258,7 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap() // copy data to Gdiplus::Bitmap; format is BGR here in both cases, so memcpy is possible for(sal_uInt32 y(0); y < nH; y++) { - const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1); - sal_uInt8* targetPixels = static_cast<sal_uInt8*>(aGdiPlusBitmapData.Scan0) + (nYInsert * aGdiPlusBitmapData.Stride); + sal_uInt8* targetPixels = static_cast<sal_uInt8*>(aGdiPlusBitmapData.Scan0) + (y * aGdiPlusBitmapData.Stride); memcpy(targetPixels, pSrcRGB, nW * 3); pSrcRGB += nW * 3 + nExtraRGB; @@ -370,7 +368,6 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap(const Win sal_uInt8* pSrcA(pA->mpBits); const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3)); const sal_uInt32 nExtraA(pA->mnScanlineSize - nW); - const bool bTopDown(pRGB->meDirection == ScanlineDirection::TopDown); const Gdiplus::Rect aAllRect(0, 0, nW, nH); Gdiplus::BitmapData aGdiPlusBitmapData; pRetval->LockBits(&aAllRect, Gdiplus::ImageLockModeWrite, PixelFormat32bppARGB, &aGdiPlusBitmapData); @@ -379,8 +376,7 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap(const Win // A from alpha, so inner loop is needed (who invented BitmapEx..?) for(sal_uInt32 y(0); y < nH; y++) { - const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1); - sal_uInt8* targetPixels = static_cast<sal_uInt8*>(aGdiPlusBitmapData.Scan0) + (nYInsert * aGdiPlusBitmapData.Stride); + sal_uInt8* targetPixels = static_cast<sal_uInt8*>(aGdiPlusBitmapData.Scan0) + (y * aGdiPlusBitmapData.Stride); for(sal_uInt32 x(0); x < nW; x++) { diff --git a/vcl/win/gdi/salgdi2.cxx b/vcl/win/gdi/salgdi2.cxx index ba4afc157bc3..b4aa68fa29cb 100644 --- a/vcl/win/gdi/salgdi2.cxx +++ b/vcl/win/gdi/salgdi2.cxx @@ -116,14 +116,10 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap) rWinSalBitmap.Create(rSalBitmap.GetSize(), vcl::bitDepthToPixelFormat(rSalBitmap.GetBitCount()), aBitmapPalette); BitmapBuffer* pWrite = rWinSalBitmap.AcquireBuffer(BitmapAccessMode::Write); - sal_uInt8* pSource(pRead->mpBits); + // convert to bottom-up data + sal_uInt8* pSource = pRead->mpBits + pRead->mnScanlineSize * (pRead->mnHeight - 1); sal_uInt8* pDestination(pWrite->mpBits); - tools::Long readRowChange = pRead->mnScanlineSize; - if (pRead->meDirection == ScanlineDirection::TopDown) - { - pSource += pRead->mnScanlineSize * (pRead->mnHeight - 1); - readRowChange = -readRowChange; - } + tools::Long readRowChange = -pRead->mnScanlineSize; std::unique_ptr<ColorScanlineConverter> pConverter; |