summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-04-06 10:21:01 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-04-06 06:35:11 +0200
commit615ceb107e9faf01b568b0a2440a3f09c8f88ca6 (patch)
treed5d26e22e80bb52f31b3d8ee8c11e0d28f0cf719
parentc7cfd3323cf80d5953f5c3808c1afd6fec0c674b (diff)
vcl: remove 4-bit bitmap support from qt5 backend
We removed 4-bit support for bitmaps, but the qt5 backend still has (special) support this bitmap format, which now can safely be removed and make the backend a lot simpler. Change-Id: I12309909a9ee3079cef7c4e59154ac48151e18d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113619 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--vcl/inc/qt5/Qt5Bitmap.hxx4
-rw-r--r--vcl/qt5/Qt5Bitmap.cxx135
-rw-r--r--vcl/qt5/Qt5Graphics_GDI.cxx22
3 files changed, 18 insertions, 143 deletions
diff --git a/vcl/inc/qt5/Qt5Bitmap.hxx b/vcl/inc/qt5/Qt5Bitmap.hxx
index 8ff4297e43f0..201742ef39cd 100644
--- a/vcl/inc/qt5/Qt5Bitmap.hxx
+++ b/vcl/inc/qt5/Qt5Bitmap.hxx
@@ -29,11 +29,7 @@ class Qt5Bitmap final : public SalBitmap
{
std::unique_ptr<QImage> m_pImage;
BitmapPalette m_aPalette;
-
- // for 4bit support
- std::unique_ptr<sal_uInt8[]> m_pBuffer;
Size m_aSize;
- sal_uInt32 m_nScanline;
public:
Qt5Bitmap();
diff --git a/vcl/qt5/Qt5Bitmap.cxx b/vcl/qt5/Qt5Bitmap.cxx
index fd7932f879bd..a9ea1f707431 100644
--- a/vcl/qt5/Qt5Bitmap.cxx
+++ b/vcl/qt5/Qt5Bitmap.cxx
@@ -41,33 +41,11 @@ bool Qt5Bitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const BitmapPale
if (nBitCount == 1)
assert(2 >= rPal.GetEntryCount());
- if (nBitCount == 4)
- assert(16 >= rPal.GetEntryCount());
if (nBitCount == 8)
assert(256 >= rPal.GetEntryCount());
- if (nBitCount == 4)
- {
- m_pImage.reset();
- m_aSize = rSize;
- bool bFail = o3tl::checked_multiply<sal_uInt32>(rSize.Width(), nBitCount, m_nScanline);
- if (bFail)
- {
- SAL_WARN("vcl.gdi", "checked multiply failed");
- return false;
- }
- m_nScanline = AlignedWidth4Bytes(m_nScanline);
- sal_uInt8* pBuffer = nullptr;
- if (0 != m_nScanline && 0 != rSize.Height())
- pBuffer = new sal_uInt8[m_nScanline * rSize.Height()];
- m_pBuffer.reset(pBuffer);
- }
- else
- {
- m_pImage.reset(new QImage(toQSize(rSize), getBitFormat(nBitCount)));
- m_pImage->fill(Qt::transparent);
- m_pBuffer.reset();
- }
+ m_pImage.reset(new QImage(toQSize(rSize), getBitFormat(nBitCount)));
+ m_pImage->fill(Qt::transparent);
m_aPalette = rPal;
auto count = rPal.GetEntryCount();
@@ -84,25 +62,7 @@ bool Qt5Bitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const BitmapPale
bool Qt5Bitmap::Create(const SalBitmap& rSalBmp)
{
const Qt5Bitmap* pBitmap = static_cast<const Qt5Bitmap*>(&rSalBmp);
- if (pBitmap->m_pImage)
- {
- m_pImage.reset(new QImage(*pBitmap->m_pImage));
- m_pBuffer.reset();
- }
- else
- {
- m_aSize = pBitmap->m_aSize;
- m_nScanline = pBitmap->m_nScanline;
- sal_uInt8* pBuffer = nullptr;
- if (0 != m_nScanline && 0 != m_aSize.Height())
- {
- sal_uInt32 nSize = m_nScanline * m_aSize.Height();
- pBuffer = new sal_uInt8[nSize];
- memcpy(pBuffer, pBitmap->m_pBuffer.get(), nSize);
- }
- m_pBuffer.reset(pBuffer);
- m_pImage.reset();
- }
+ m_pImage.reset(new QImage(*pBitmap->m_pImage));
m_aPalette = pBitmap->m_aPalette;
return true;
}
@@ -113,64 +73,16 @@ bool Qt5Bitmap::Create(const SalBitmap& rSalBmp, SalGraphics* pSalGraphics)
Qt5Graphics* pGraphics = static_cast<Qt5Graphics*>(pSalGraphics);
QImage* pImage = pGraphics->m_pQImage;
m_pImage.reset(new QImage(pBitmap->m_pImage->convertToFormat(pImage->format())));
- m_pBuffer.reset();
return true;
}
bool Qt5Bitmap::Create(const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount)
{
- assert((nNewBitCount == 1 || nNewBitCount == 4 || nNewBitCount == 8 || nNewBitCount == 24
- || nNewBitCount == 32)
+ assert((nNewBitCount == 1 || nNewBitCount == 8 || nNewBitCount == 24 || nNewBitCount == 32)
&& "Unsupported BitCount!");
const Qt5Bitmap* pBitmap = static_cast<const Qt5Bitmap*>(&rSalBmp);
- if (pBitmap->m_pBuffer)
- {
- if (nNewBitCount != 32)
- return false;
-
- // convert 4bit indexed palette to 32bit ARGB
- m_pImage.reset(new QImage(pBitmap->m_aSize.Width(), pBitmap->m_aSize.Height(),
- getBitFormat(nNewBitCount)));
- m_pImage->fill(Qt::transparent);
-
- // prepare a whole palette
- const BitmapPalette& rPal = pBitmap->m_aPalette;
- QVector<QRgb> colorTable(16);
- int i = 0, maxEntry = pBitmap->m_aPalette.GetEntryCount();
- assert(maxEntry <= 16 && maxEntry >= 0);
- for (; i < maxEntry; ++i)
- colorTable[i] = qRgb(rPal[i].GetRed(), rPal[i].GetGreen(), rPal[i].GetBlue());
- for (; i < 16; ++i)
- colorTable[i] = qRgb(0, 0, 0);
-
- sal_uInt32* image_data = reinterpret_cast<sal_uInt32*>(m_pImage->bits());
- sal_uInt8* buffer_data_pos = pBitmap->m_pBuffer.get();
- sal_uInt32 nWidth = pBitmap->m_aSize.Height() / 2;
- bool isOdd(0 != pBitmap->m_aSize.Height() % 2);
-
- for (tools::Long h = 0; h < pBitmap->m_aSize.Height(); ++h)
- {
- sal_uInt8* buffer_data = buffer_data_pos;
- buffer_data_pos += pBitmap->m_nScanline;
- for (sal_uInt32 w = 0; w < nWidth; ++w)
- {
- *image_data = static_cast<sal_uInt32>(colorTable.at(*buffer_data >> 4));
- ++image_data;
- *image_data = static_cast<sal_uInt32>(colorTable.at(*buffer_data & 0xF));
- ++image_data;
- ++buffer_data;
- }
- if (isOdd)
- {
- *image_data = static_cast<sal_uInt32>(colorTable.at(*buffer_data >> 4));
- ++image_data;
- }
- }
- }
- else
- m_pImage.reset(new QImage(pBitmap->m_pImage->convertToFormat(getBitFormat(nNewBitCount))));
- m_pBuffer.reset();
+ m_pImage.reset(new QImage(pBitmap->m_pImage->convertToFormat(getBitFormat(nNewBitCount))));
return true;
}
@@ -180,26 +92,18 @@ bool Qt5Bitmap::Create(const css::uno::Reference<css::rendering::XBitmapCanvas>&
return false;
}
-void Qt5Bitmap::Destroy()
-{
- m_pImage.reset();
- m_pBuffer.reset();
-}
+void Qt5Bitmap::Destroy() { m_pImage.reset(); }
Size Qt5Bitmap::GetSize() const
{
- if (m_pBuffer)
- return m_aSize;
- else if (m_pImage)
+ if (m_pImage)
return toSize(m_pImage->size());
return Size();
}
sal_uInt16 Qt5Bitmap::GetBitCount() const
{
- if (m_pBuffer)
- return 4;
- else if (m_pImage)
+ if (m_pImage)
return getFormatBits(m_pImage->format());
return 0;
}
@@ -208,27 +112,16 @@ BitmapBuffer* Qt5Bitmap::AcquireBuffer(BitmapAccessMode /*nMode*/)
{
static const BitmapPalette aEmptyPalette;
- if (!(m_pImage || m_pBuffer))
+ if (!m_pImage)
return nullptr;
BitmapBuffer* pBuffer = new BitmapBuffer;
- if (m_pBuffer)
- {
- pBuffer->mnWidth = m_aSize.Width();
- pBuffer->mnHeight = m_aSize.Height();
- pBuffer->mnBitCount = 4;
- pBuffer->mpBits = m_pBuffer.get();
- pBuffer->mnScanlineSize = m_nScanline;
- }
- else
- {
- pBuffer->mnWidth = m_pImage->width();
- pBuffer->mnHeight = m_pImage->height();
- pBuffer->mnBitCount = getFormatBits(m_pImage->format());
- pBuffer->mpBits = m_pImage->bits();
- pBuffer->mnScanlineSize = m_pImage->bytesPerLine();
- }
+ pBuffer->mnWidth = m_pImage->width();
+ pBuffer->mnHeight = m_pImage->height();
+ pBuffer->mnBitCount = getFormatBits(m_pImage->format());
+ pBuffer->mpBits = m_pImage->bits();
+ pBuffer->mnScanlineSize = m_pImage->bytesPerLine();
switch (pBuffer->mnBitCount)
{
diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx
index fabed0b3047b..9cc2821a8ad7 100644
--- a/vcl/qt5/Qt5Graphics_GDI.cxx
+++ b/vcl/qt5/Qt5Graphics_GDI.cxx
@@ -477,12 +477,8 @@ void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBit
|| rPosAry.mnDestHeight <= 0)
return;
- Qt5Bitmap aRGBABitmap;
- if (rSalBitmap.GetBitCount() == 4)
- aRGBABitmap.Create(rSalBitmap, 32);
- const QImage* pImage = (rSalBitmap.GetBitCount() != 4)
- ? static_cast<const Qt5Bitmap*>(&rSalBitmap)->GetQImage()
- : aRGBABitmap.GetQImage();
+ const QImage* pImage = static_cast<const Qt5Bitmap*>(&rSalBitmap)->GetQImage();
+
assert(pImage);
drawScaledImage(rPosAry, *pImage);
@@ -576,12 +572,7 @@ static bool getAlphaImage(const SalBitmap& rSourceBitmap, const SalBitmap& rAlph
return false;
}
- Qt5Bitmap aRGBABitmap;
- if (rSourceBitmap.GetBitCount() == 4)
- aRGBABitmap.Create(rSourceBitmap, 32);
- const QImage* pBitmap = (rSourceBitmap.GetBitCount() != 4)
- ? static_cast<const Qt5Bitmap*>(&rSourceBitmap)->GetQImage()
- : aRGBABitmap.GetQImage();
+ const QImage* pBitmap = static_cast<const Qt5Bitmap*>(&rSourceBitmap)->GetQImage();
const QImage* pAlpha = static_cast<const Qt5Bitmap*>(&rAlphaBitmap)->GetQImage();
rAlphaImage = pBitmap->convertToFormat(Qt5_DefaultFormat32);
@@ -635,12 +626,7 @@ bool Qt5Graphics::drawTransformedBitmap(const basegfx::B2DPoint& rNull, const ba
return false;
else
{
- Qt5Bitmap aRGBABitmap;
- if (rSourceBitmap.GetBitCount() == 4)
- aRGBABitmap.Create(rSourceBitmap, 32);
- const QImage* pBitmap = (rSourceBitmap.GetBitCount() != 4)
- ? static_cast<const Qt5Bitmap*>(&rSourceBitmap)->GetQImage()
- : aRGBABitmap.GetQImage();
+ const QImage* pBitmap = static_cast<const Qt5Bitmap*>(&rSourceBitmap)->GetQImage();
aImage = pBitmap->convertToFormat(Qt5_DefaultFormat32);
}