summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorDmitriy Shilin <dshil@fastmail.com>2018-12-13 07:23:37 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-12-13 11:21:03 +0100
commite71f44f4dc847c75b874d514888d0675ccb00496 (patch)
tree1cdf3e51f816877406c0ec9e6933de487a0cf525 /vcl/win
parent46ba7ac94595ff8317dc8988852aa75ec28a049e (diff)
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@collabora.com> Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/gdi/gdiimpl.cxx26
1 files changed, 12 insertions, 14 deletions
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++;
}
}