[Libreoffice-commits] core.git: vcl/win
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Dec 13 10:21:30 UTC 2018
vcl/win/gdi/gdiimpl.cxx | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
New commits:
commit e71f44f4dc847c75b874d514888d0675ccb00496
Author: Dmitriy Shilin <dshil at fastmail.com>
AuthorDate: Thu Dec 13 07:23:37 2018 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu Dec 13 11:21:03 2018 +0100
vcl/win/gdi: get dither mapping value explicitly
Having a macro with a very short and nice API but assuming
that some variables must be defined before using it leads
to a huge misunderstanding.
Change-Id: Idb16307ab4bdeff055ee2a9e237c1436cacd3591
Reviewed-on: https://gerrit.libreoffice.org/65069
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index b8fafc25482d..1f161619589a 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -61,8 +61,6 @@
#define SAL_POLYPOLYCOUNT_STACKBUF 8
#define SAL_POLYPOLYPOINTS_STACKBUF 64
-#define DMAP( _def_nVal, _def_nThres ) ((pDitherDiff[_def_nVal]>(_def_nThres))?pDitherHigh[_def_nVal]:pDitherLow[_def_nVal])
-
#define SAL_POLY_STACKBUF 32
namespace {
@@ -1462,6 +1460,12 @@ HBRUSH WinSalGraphicsImpl::SearchStockBrush(COLORREF nBrushColor)
namespace
{
+BYTE GetDitherMappingValue(BYTE nVal, BYTE nThres, const SalData* pSalData)
+{
+ return (pSalData->mpDitherDiff[nVal] > nThres) ?
+ pSalData->mpDitherHigh[nVal] : pSalData->mpDitherLow[nVal];
+}
+
HBRUSH Make16BitDIBPatternBrush(Color nColor)
{
const SalData* pSalData = GetSalData();
@@ -1483,18 +1487,15 @@ HBRUSH Make16BitDIBPatternBrush(Color nColor)
};
BYTE* pTmp = pSalData->mpDitherDIBData;
- long* pDitherDiff = pSalData->mpDitherDiff;
- BYTE* pDitherLow = pSalData->mpDitherLow;
- BYTE* pDitherHigh = pSalData->mpDitherHigh;
for(int nY = 0; nY < 8; ++nY)
{
for(int nX = 0; nX < 8; ++nX)
{
const BYTE nThres = aOrdDither16Bit[nY][nX];
- *pTmp++ = DMAP(nBlue, nThres);
- *pTmp++ = DMAP(nGreen, nThres);
- *pTmp++ = DMAP(nRed, nThres);
+ *pTmp++ = GetDitherMappingValue(nBlue, nThres, pSalData);
+ *pTmp++ = GetDitherMappingValue(nGreen, nThres, pSalData);
+ *pTmp++ = GetDitherMappingValue(nRed, nThres, pSalData);
}
}
@@ -1522,18 +1523,15 @@ HBRUSH Make8BitDIBPatternBrush(Color nColor)
};
BYTE* pTmp = pSalData->mpDitherDIBData;
- long* pDitherDiff = pSalData->mpDitherDiff;
- BYTE* pDitherLow = pSalData->mpDitherLow;
- BYTE* pDitherHigh = pSalData->mpDitherHigh;
for (int nY = 0; nY < 8; ++nY)
{
for (int nX = 0; nX < 8; ++nX)
{
const BYTE nThres = aOrdDither8Bit[nY][nX];
- *pTmp = DMAP(nRed, nThres) +
- DMAP(nGreen, nThres) * 6 +
- DMAP(nBlue, nThres) * 36;
+ *pTmp = GetDitherMappingValue(nRed, nThres, pSalData) +
+ GetDitherMappingValue(nGreen, nThres, pSalData) * 6 +
+ GetDitherMappingValue(nBlue, nThres, pSalData) * 36;
pTmp++;
}
}
More information about the Libreoffice-commits
mailing list