summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-02-26 21:45:35 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-02-29 16:12:18 +0100
commit6588c30ed4477627b2623560ca867682b189bc80 (patch)
treeb031e5611af09af708de9ebb9b218b958fbec92a /vcl/win
parent657631791421eae2c88a89da27bd2c0dc1822175 (diff)
vcl: separate scanline direction from ScanlineFormat
ScanlineFormat enum is used to indicate 2 things - scanline format type and scanline direction (TopDown or BottomUp). This makes it complex to manipulate with (using bit arithmetics) and hard to use in general for no benefit, so this commit separates direction out from the ScanlineFormat into ScanlineDirection enum. ScanlineFormat is now just a simple enum class (not a bit field). Change-Id: Iad55d0a4c8c07b71221c2facf7cf6a2d518fec0c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163943 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/gdi/salbmp.cxx22
-rw-r--r--vcl/win/gdi/salgdi2.cxx16
2 files changed, 20 insertions, 18 deletions
diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx
index 46c7ea0fa932..c6bd5f3ae7a0 100644
--- a/vcl/win/gdi/salbmp.cxx
+++ b/vcl/win/gdi/salbmp.cxx
@@ -222,7 +222,7 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap()
BitmapBuffer* pRGB = pSalRGB->AcquireBuffer(BitmapAccessMode::Read);
std::optional<BitmapBuffer> pExtraRGB;
- if(pRGB && ScanlineFormat::N24BitTcBgr != RemoveScanline(pRGB->mnFormat))
+ if (pRGB && ScanlineFormat::N24BitTcBgr != pRGB->meFormat)
{
// convert source bitmap to BMP_FORMAT_24BIT_TC_BGR format if not yet in that format
SalTwoRect aSalTwoRect(0, 0, pRGB->mnWidth, pRGB->mnHeight, 0, 0, pRGB->mnWidth, pRGB->mnHeight);
@@ -235,10 +235,10 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap()
pRGB = pExtraRGB ? &*pExtraRGB : nullptr;
}
- if(pRGB
+ if (pRGB
&& pRGB->mnWidth > 0
&& pRGB->mnHeight > 0
- && ScanlineFormat::N24BitTcBgr == RemoveScanline(pRGB->mnFormat))
+ && ScanlineFormat::N24BitTcBgr == pRGB->meFormat)
{
const sal_uInt32 nW(pRGB->mnWidth);
const sal_uInt32 nH(pRGB->mnHeight);
@@ -249,7 +249,7 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap()
{
sal_uInt8* pSrcRGB(pRGB->mpBits);
const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3));
- const bool bTopDown(pRGB->mnFormat & ScanlineFormat::TopDown);
+ 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);
@@ -304,7 +304,7 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap(const Win
BitmapBuffer* pRGB = pSalRGB->AcquireBuffer(BitmapAccessMode::Read);
std::optional<BitmapBuffer> pExtraRGB;
- if(pRGB && ScanlineFormat::N24BitTcBgr != RemoveScanline(pRGB->mnFormat))
+ if (pRGB && ScanlineFormat::N24BitTcBgr != pRGB->meFormat)
{
// convert source bitmap to canlineFormat::N24BitTcBgr format if not yet in that format
SalTwoRect aSalTwoRect(0, 0, pRGB->mnWidth, pRGB->mnHeight, 0, 0, pRGB->mnWidth, pRGB->mnHeight);
@@ -331,7 +331,7 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap(const Win
BitmapBuffer* pA = pSalA->AcquireBuffer(BitmapAccessMode::Read);
std::optional<BitmapBuffer> pExtraA;
- if(pA && ScanlineFormat::N8BitPal != RemoveScanline(pA->mnFormat))
+ if (pA && ScanlineFormat::N8BitPal != pA->meFormat)
{
// 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);
@@ -353,8 +353,8 @@ std::shared_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap(const Win
&& pRGB->mnHeight > 0
&& pRGB->mnWidth == pA->mnWidth
&& pRGB->mnHeight == pA->mnHeight
- && ScanlineFormat::N24BitTcBgr == RemoveScanline(pRGB->mnFormat)
- && ScanlineFormat::N8BitPal == RemoveScanline(pA->mnFormat))
+ && ScanlineFormat::N24BitTcBgr == pRGB->meFormat
+ && ScanlineFormat::N8BitPal == pA->meFormat)
{
// we have alpha and bitmap in known formats, create GdiPlus Bitmap as 32bit ARGB
const sal_uInt32 nW(pRGB->mnWidth);
@@ -368,7 +368,7 @@ 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->mnFormat & ScanlineFormat::TopDown);
+ 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);
@@ -774,13 +774,13 @@ BitmapBuffer* WinSalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ )
{
pBuffer.reset(new BitmapBuffer);
- pBuffer->mnFormat = pBIH->biBitCount == 1 ? ScanlineFormat::N1BitMsbPal :
+ pBuffer->meFormat = pBIH->biBitCount == 1 ? ScanlineFormat::N1BitMsbPal :
pBIH->biBitCount == 8 ? ScanlineFormat::N8BitPal :
pBIH->biBitCount == 24 ? ScanlineFormat::N24BitTcBgr :
pBIH->biBitCount == 32 ? ScanlineFormat::N32BitTcMask :
ScanlineFormat::NONE;
- if( RemoveScanline( pBuffer->mnFormat ) != ScanlineFormat::NONE )
+ if (pBuffer->meFormat != ScanlineFormat::NONE)
{
pBuffer->mnWidth = maSize.Width();
pBuffer->mnHeight = maSize.Height();
diff --git a/vcl/win/gdi/salgdi2.cxx b/vcl/win/gdi/salgdi2.cxx
index a28a59116518..277fbc3b9f98 100644
--- a/vcl/win/gdi/salgdi2.cxx
+++ b/vcl/win/gdi/salgdi2.cxx
@@ -119,7 +119,7 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap)
sal_uInt8* pSource(pRead->mpBits);
sal_uInt8* pDestination(pWrite->mpBits);
tools::Long readRowChange = pRead->mnScanlineSize;
- if(pRead->mnFormat & ScanlineFormat::TopDown)
+ if (pRead->meDirection == ScanlineDirection::TopDown)
{
pSource += pRead->mnScanlineSize * (pRead->mnHeight - 1);
readRowChange = -readRowChange;
@@ -127,12 +127,14 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap)
std::unique_ptr<ColorScanlineConverter> pConverter;
- if (RemoveScanline(pRead->mnFormat) == ScanlineFormat::N24BitTcRgb)
- pConverter.reset(new ColorScanlineConverter(ScanlineFormat::N24BitTcRgb,
- 3, pRead->mnScanlineSize));
- else if (RemoveScanline(pRead->mnFormat) == ScanlineFormat::N32BitTcRgba)
- pConverter.reset(new ColorScanlineConverter(ScanlineFormat::N32BitTcRgba,
- 4, pRead->mnScanlineSize));
+ if (pRead->meFormat == ScanlineFormat::N24BitTcRgb)
+ {
+ pConverter.reset(new ColorScanlineConverter(ScanlineFormat::N24BitTcRgb, 3, pRead->mnScanlineSize));
+ }
+ else if (pRead->meFormat == ScanlineFormat::N32BitTcRgba)
+ {
+ pConverter.reset(new ColorScanlineConverter(ScanlineFormat::N32BitTcRgba, 4, pRead->mnScanlineSize));
+ }
if (pConverter)
{
for (tools::Long y = 0; y < pRead->mnHeight; y++)