diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2025-01-24 11:52:18 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2025-01-24 14:14:14 +0100 |
commit | 42cc3b58451dec8a99af9c26e8bc947cce0ae058 (patch) | |
tree | d2109b7ce9e2b9a13b843d6c8ac5105c50ec1efa /vcl | |
parent | 99f4c0fc0a0e12ff7e72a4b047a6d8cfdfee5012 (diff) |
N32BitTcMask is unnecessary
The remaining usage site can use N32BitTcXrgb
Change-Id: I97c0a7e97d45dfcb4726b197159ca2f197b43713
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180698
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/canvasbitmaptest.cxx | 2 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx | 1 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapFilterStackBlur.cxx | 4 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapReadAccess.cxx | 19 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapWriteAccess.cxx | 5 | ||||
-rw-r--r-- | vcl/source/bitmap/bmpfast.cxx | 18 | ||||
-rw-r--r-- | vcl/source/bitmap/dibtools.cxx | 48 | ||||
-rw-r--r-- | vcl/source/gdi/salmisc.cxx | 12 | ||||
-rw-r--r-- | vcl/source/helper/canvasbitmap.cxx | 9 | ||||
-rw-r--r-- | vcl/win/gdi/salbmp.cxx | 18 |
10 files changed, 21 insertions, 115 deletions
diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx index 91db2e4f73f3..e562824955bd 100644 --- a/vcl/qa/cppunit/canvasbitmaptest.cxx +++ b/vcl/qa/cppunit/canvasbitmaptest.cxx @@ -89,8 +89,6 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp, { BitmapScopedReadAccess pAcc( aContainedBmp ); nDepth = pAcc->GetBitCount(); - if( pAcc->GetScanlineFormat() == ScanlineFormat::N32BitTcMask ) - extraBpp = 8; // the format has 8 unused bits } CPPUNIT_ASSERT_EQUAL_MESSAGE( "Original bitmap size not (200,200)", diff --git a/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx b/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx index 4c19cd7d374f..866583d07a1e 100644 --- a/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx +++ b/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx @@ -351,7 +351,6 @@ Bitmap BitmapBasicMorphologyFilter::filter(Bitmap const& rBitmap) const case ScanlineFormat::N24BitTcBgr: runFilter<24>(bitmapCopy, m_eOp, m_nRadius, m_bUseValueOutside, m_nValueOutside); break; - case ScanlineFormat::N32BitTcMask: case ScanlineFormat::N32BitTcBgra: case ScanlineFormat::N32BitTcBgrx: runFilter<32>(bitmapCopy, m_eOp, m_nRadius, m_bUseValueOutside, m_nValueOutside); diff --git a/vcl/source/bitmap/BitmapFilterStackBlur.cxx b/vcl/source/bitmap/BitmapFilterStackBlur.cxx index 298265266041..fad54b518e82 100644 --- a/vcl/source/bitmap/BitmapFilterStackBlur.cxx +++ b/vcl/source/bitmap/BitmapFilterStackBlur.cxx @@ -619,12 +619,10 @@ Bitmap BitmapFilterStackBlur::filter(Bitmap const& rBitmap) const if (nScanlineFormat == ScanlineFormat::N24BitTcRgb || nScanlineFormat == ScanlineFormat::N24BitTcBgr - || nScanlineFormat == ScanlineFormat::N32BitTcMask || nScanlineFormat == ScanlineFormat::N32BitTcBgra || nScanlineFormat == ScanlineFormat::N32BitTcBgrx) { - int nComponentWidth = (nScanlineFormat == ScanlineFormat::N32BitTcMask - || nScanlineFormat == ScanlineFormat::N32BitTcBgra + int nComponentWidth = (nScanlineFormat == ScanlineFormat::N32BitTcBgra || nScanlineFormat == ScanlineFormat::N32BitTcBgrx) ? 4 : 3; diff --git a/vcl/source/bitmap/BitmapReadAccess.cxx b/vcl/source/bitmap/BitmapReadAccess.cxx index 7688e0db8f64..c5e5a6a92c8e 100644 --- a/vcl/source/bitmap/BitmapReadAccess.cxx +++ b/vcl/source/bitmap/BitmapReadAccess.cxx @@ -93,8 +93,6 @@ FncGetPixel BitmapReadAccess::GetPixelFunction(ScanlineFormat nFormat) case ScanlineFormat::N32BitTcRgbx: assert(!Bitmap32IsPreMultipled()); return GetPixelForN32BitTcRgbx; - case ScanlineFormat::N32BitTcMask: - return GetPixelForN32BitTcMask; default: return nullptr; @@ -137,8 +135,6 @@ FncSetPixel BitmapReadAccess::SetPixelFunction(ScanlineFormat nFormat) case ScanlineFormat::N32BitTcRgbx: assert(!Bitmap32IsPreMultipled()); return SetPixelForN32BitTcRgbx; - case ScanlineFormat::N32BitTcMask: - return SetPixelForN32BitTcMask; default: assert(false); @@ -511,19 +507,4 @@ void BitmapReadAccess::SetPixelForN32BitTcRgbx(Scanline pScanline, tools::Long n *pScanline = 0xFF; } -BitmapColor BitmapReadAccess::GetPixelForN32BitTcMask(ConstScanline pScanline, tools::Long nX, - const ColorMask& rMask) -{ - BitmapColor aColor; - rMask.GetColorFor32Bit(aColor, pScanline + (nX << 2)); - return aColor; -} - -void BitmapReadAccess::SetPixelForN32BitTcMask(Scanline pScanline, tools::Long nX, - const BitmapColor& rBitmapColor, - const ColorMask& rMask) -{ - rMask.SetColorFor32Bit(rBitmapColor, pScanline + (nX << 2)); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/bitmap/BitmapWriteAccess.cxx b/vcl/source/bitmap/BitmapWriteAccess.cxx index f2fc5424eb0e..1d905d763804 100644 --- a/vcl/source/bitmap/BitmapWriteAccess.cxx +++ b/vcl/source/bitmap/BitmapWriteAccess.cxx @@ -85,8 +85,6 @@ void BitmapWriteAccess::CopyScanline(tools::Long nY, ConstScanline aSrcScanline, nSrcScanlineSize)) return; - DBG_ASSERT(eFormat != ScanlineFormat::N32BitTcMask, - "No support for pixel formats with color masks yet!"); FncGetPixel pFncGetPixel; switch (eFormat) { @@ -134,9 +132,6 @@ void BitmapWriteAccess::CopyScanline(tools::Long nY, ConstScanline aSrcScanline, assert(!Bitmap32IsPreMultipled()); pFncGetPixel = GetPixelForN32BitTcRgbx; break; - case ScanlineFormat::N32BitTcMask: - pFncGetPixel = GetPixelForN32BitTcMask; - break; default: assert(false); diff --git a/vcl/source/bitmap/bmpfast.cxx b/vcl/source/bitmap/bmpfast.cxx index 74da808b96cb..37fba37615b1 100644 --- a/vcl/source/bitmap/bmpfast.cxx +++ b/vcl/source/bitmap/bmpfast.cxx @@ -337,10 +337,6 @@ static bool ImplConvertFromBitmap( BitmapBuffer& rDst, const BitmapBuffer& rSrc case ScanlineFormat::N8BitPal: break; - case ScanlineFormat::N32BitTcMask: -// return ImplConvertToBitmap<ScanlineFormat::N32BitTcMask>( aSrcType, rDst, rSrc ); - break; - case ScanlineFormat::N24BitTcBgr: return ImplConvertToBitmap<ScanlineFormat::N24BitTcBgr>( aSrcType, rDst, rSrc ); case ScanlineFormat::N24BitTcRgb: @@ -424,10 +420,6 @@ bool ImplFastBitmapConversion( BitmapBuffer& rDst, const BitmapBuffer& rSrc, case ScanlineFormat::N1BitMsbPal: break; - case ScanlineFormat::N32BitTcMask: -// return ImplConvertFromBitmap<ScanlineFormat::N32BitTcMask>( rDst, rSrc ); - break; - case ScanlineFormat::N8BitPal: if(rSrc.maPalette.IsGreyPalette8Bit()) return ImplConvertFromBitmap<ScanlineFormat::N8BitPal>( rDst, rSrc ); @@ -653,10 +645,6 @@ static bool ImplBlendFromBitmap( BitmapBuffer& rDst, const BitmapBuffer& rSrc, c case ScanlineFormat::N8BitPal: break; - case ScanlineFormat::N32BitTcMask: -// return ImplBlendToBitmap<ScanlineFormat::N32BitTcMask>( aSrcType, rDst, rSrc, rMsk ); - break; - case ScanlineFormat::N24BitTcBgr: return ImplBlendToBitmap<ScanlineFormat::N24BitTcBgr>( aSrcType, rDst, rSrc, rMsk ); case ScanlineFormat::N24BitTcRgb: @@ -744,10 +732,6 @@ bool ImplFastBitmapBlending( BitmapWriteAccess const & rDstWA, case ScanlineFormat::N1BitMsbPal: break; - case ScanlineFormat::N32BitTcMask: -// return ImplBlendFromBitmap<ScanlineFormat::N32BitTcMask>( rDst, rSrc ); - break; - case ScanlineFormat::N8BitPal: if(rSrc.maPalette.IsGreyPalette8Bit()) return ImplBlendFromBitmap<ScanlineFormat::N8BitPal>( rDst, rSrc, rMsk ); @@ -821,8 +805,6 @@ bool ImplFastEraseBitmap( BitmapBuffer& rDst, const BitmapColor& rColor ) // TODO: handle other bitmap formats switch (rDst.meFormat) { - case ScanlineFormat::N32BitTcMask: - case ScanlineFormat::N24BitTcBgr: case ScanlineFormat::N24BitTcRgb: diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx index 97bcb86b0feb..4b503b77ac87 100644 --- a/vcl/source/bitmap/dibtools.cxx +++ b/vcl/source/bitmap/dibtools.cxx @@ -137,11 +137,6 @@ vcl::PixelFormat convertToBPP(sal_uInt16 nCount) vcl::PixelFormat::N24_BPP; } -bool isBitfieldCompression( ScanlineFormat nScanlineFormat ) -{ - return ScanlineFormat::N32BitTcMask == nScanlineFormat; -} - bool ImplReadDIBInfoHeader(SvStream& rIStm, DIBV5Header& rHeader, bool& bTopDown, bool bMSOFormat) { if (rIStm.remainingSize() <= 4) @@ -1375,32 +1370,23 @@ bool ImplWriteDIBBody(const Bitmap& rBitmap, SvStream& rOStm, BitmapReadAccess c aHeader.nHeight = rAcc.Height(); aHeader.nPlanes = 1; - if(isBitfieldCompression(rAcc.GetScanlineFormat())) - { - aHeader.nBitCount = 32; - aHeader.nSizeImage = rAcc.Height() * rAcc.GetScanlineSize(); - nCompression = BITFIELDS; - } - else + // #i5xxx# Limit bitcount to 24bit, the 32 bit cases are + // not handled properly below (would have to set color + // masks, and nCompression=BITFIELDS - but color mask is + // not set for formats != *_TC_*). Note that this very + // problem might cause trouble at other places - the + // introduction of 32 bit RGBA bitmaps is relatively + // recent. + // #i59239# discretize bitcount to 1,8,24 (other cases + // are not written below) + const auto ePixelFormat(convertToBPP(rAcc.GetBitCount())); + aHeader.nBitCount = sal_uInt16(ePixelFormat); + aHeader.nSizeImage = rAcc.Height() * AlignedWidth4Bytes(rAcc.Width() * aHeader.nBitCount); + + if (bCompressed) { - // #i5xxx# Limit bitcount to 24bit, the 32 bit cases are - // not handled properly below (would have to set color - // masks, and nCompression=BITFIELDS - but color mask is - // not set for formats != *_TC_*). Note that this very - // problem might cause trouble at other places - the - // introduction of 32 bit RGBA bitmaps is relatively - // recent. - // #i59239# discretize bitcount to 1,8,24 (other cases - // are not written below) - const auto ePixelFormat(convertToBPP(rAcc.GetBitCount())); - aHeader.nBitCount = sal_uInt16(ePixelFormat); - aHeader.nSizeImage = rAcc.Height() * AlignedWidth4Bytes(rAcc.Width() * aHeader.nBitCount); - - if (bCompressed) - { - if (ePixelFormat == vcl::PixelFormat::N8_BPP) - nCompression = RLE_8; - } + if (ePixelFormat == vcl::PixelFormat::N8_BPP) + nCompression = RLE_8; } if((rOStm.GetCompressMode() & SvStreamCompressFlags::ZBITMAP) && (rOStm.GetVersion() >= SOFFICE_FILEFORMAT_40)) @@ -1510,7 +1496,7 @@ bool ImplWriteDIBBody(const Bitmap& rBitmap, SvStream& rOStm, BitmapReadAccess c bool ImplWriteDIBFileHeader(SvStream& rOStm, BitmapReadAccess const & rAcc) { - const sal_uInt32 nPalCount((rAcc.HasPalette() ? rAcc.GetPaletteEntryCount() : isBitfieldCompression(rAcc.GetScanlineFormat()) ? 3UL : 0UL)); + const sal_uInt32 nPalCount((rAcc.HasPalette() ? rAcc.GetPaletteEntryCount() : 0UL)); const sal_uInt32 nOffset(14 + DIBINFOHEADERSIZE + nPalCount * 4UL); rOStm.WriteUInt16( 0x4D42 ); // 'MB' from BITMAPFILEHEADER diff --git a/vcl/source/gdi/salmisc.cxx b/vcl/source/gdi/salmisc.cxx index 79d976ac25db..1ac8a7a98f75 100644 --- a/vcl/source/gdi/salmisc.cxx +++ b/vcl/source/gdi/salmisc.cxx @@ -228,7 +228,7 @@ static void ImplTCToPAL( const BitmapBuffer& rSrcBuffer, BitmapBuffer const & rD std::optional<BitmapBuffer> StretchAndConvert( const BitmapBuffer& rSrcBuffer, const SalTwoRect& rTwoRect, - ScanlineFormat nDstBitmapFormat, std::optional<BitmapPalette> pDstPal, const ColorMask* pDstMask ) + ScanlineFormat nDstBitmapFormat, std::optional<BitmapPalette> pDstPal ) { FncGetPixel pFncGetPixel; FncSetPixel pFncSetPixel; @@ -262,7 +262,6 @@ std::optional<BitmapBuffer> StretchAndConvert( IMPL_CASE_SET_FORMAT( N32BitTcBgrx, 32 ); IMPL_CASE_SET_FORMAT( N32BitTcRgba, 32 ); IMPL_CASE_SET_FORMAT( N32BitTcRgbx, 32 ); - IMPL_CASE_SET_FORMAT( N32BitTcMask, 32 ); default: // should never come here @@ -315,15 +314,6 @@ std::optional<BitmapBuffer> StretchAndConvert( } pDstBuffer->maPalette = *pDstPal; } - else if (nDstBitmapFormat == ScanlineFormat::N32BitTcMask) - { - assert(pDstMask && "destination buffer requires color mask"); - if (!pDstMask) - { - return std::nullopt; - } - pDstBuffer->maColorMask = *pDstMask; - } // short circuit the most important conversions bool bFastConvert = ImplFastBitmapConversion( *pDstBuffer, rSrcBuffer, rTwoRect ); diff --git a/vcl/source/helper/canvasbitmap.cxx b/vcl/source/helper/canvasbitmap.cxx index fc260b591773..e2bd7b1b8f80 100644 --- a/vcl/source/helper/canvasbitmap.cxx +++ b/vcl/source/helper/canvasbitmap.cxx @@ -275,15 +275,6 @@ VclCanvasBitmap::VclCanvasBitmap( const BitmapEx& rBitmap ) : } break; - case ScanlineFormat::N32BitTcMask: - m_bPalette = false; - m_nBitsPerInputPixel = 32; - m_aLayout.IsMsbFirst = false; // doesn't matter - setComponentInfo( m_pBmpAcc->GetColorMask().GetRedMask(), - m_pBmpAcc->GetColorMask().GetGreenMask(), - m_pBmpAcc->GetColorMask().GetBlueMask() ); - break; - default: OSL_FAIL( "unsupported bitmap format" ); break; diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx index e88a366d2d75..c0f9bf49ba06 100644 --- a/vcl/win/gdi/salbmp.cxx +++ b/vcl/win/gdi/salbmp.cxx @@ -337,13 +337,11 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap(const Win { // convert alpha bitmap to ScanlineFormat::N8BitPal format if not yet in that format SalTwoRect aSalTwoRect(0, 0, pA->mnWidth, pA->mnHeight, 0, 0, pA->mnWidth, pA->mnHeight); - const BitmapPalette& rTargetPalette = Bitmap::GetGreyPalette(256); pExtraA = StretchAndConvert( *pA, aSalTwoRect, - ScanlineFormat::N8BitPal, - rTargetPalette); + ScanlineFormat::N8BitPal); pSalA->ReleaseBuffer(pA, BitmapAccessMode::Read); pA = pExtraA ? &*pExtraA : nullptr; @@ -765,7 +763,7 @@ BitmapBuffer* WinSalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ ) pBuffer->meFormat = pBIH->biBitCount == 8 ? ScanlineFormat::N8BitPal : pBIH->biBitCount == 24 ? ScanlineFormat::N24BitTcBgr : - pBIH->biBitCount == 32 ? ScanlineFormat::N32BitTcMask : + pBIH->biBitCount == 32 ? ScanlineFormat::N32BitTcXrgb : ScanlineFormat::NONE; assert (pBuffer->meFormat != ScanlineFormat::NONE); @@ -784,18 +782,6 @@ BitmapBuffer* WinSalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ ) memcpy( pBuffer->maPalette.ImplGetColorBuffer(), pBI->bmiColors, nPalCount * sizeof( RGBQUAD ) ); pBuffer->mpBits = reinterpret_cast<PBYTE>(pBI) + pBI->bmiHeader.biSize + nPalCount * sizeof( RGBQUAD ); } - else if( pBIH->biBitCount == 32 ) - { - ColorMaskElement aRedMask(0x00ff0000UL); - aRedMask.CalcMaskShift(); - ColorMaskElement aGreenMask(0x0000ff00UL); - aGreenMask.CalcMaskShift(); - ColorMaskElement aBlueMask(0x000000ffUL); - aBlueMask.CalcMaskShift(); - pBuffer->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask); - - pBuffer->mpBits = reinterpret_cast<PBYTE>(pBI) + pBI->bmiHeader.biSize; - } else pBuffer->mpBits = reinterpret_cast<PBYTE>(pBI) + pBI->bmiHeader.biSize; } |