diff options
author | Dmitriy Shilin <dshil@fastmail.com> | 2018-12-12 10:14:28 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-12-12 11:31:42 +0100 |
commit | 773a29a3fa188b0a1290781d305d2df868e1600c (patch) | |
tree | 7352a3f5cd2b8d37595358d52960985996184dbf /vcl/win | |
parent | 3b6ee27e4bea1414042550f078f30fe3b7845a11 (diff) |
tdf#107792 vcl: split MakeBrush into functions
Change-Id: I531442ca1e121c059fb21bd86ff0c6ac7fa0cac4
Reviewed-on: https://gerrit.libreoffice.org/64914
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/win')
-rw-r--r-- | vcl/win/gdi/gdiimpl.cxx | 103 |
1 files changed, 64 insertions, 39 deletions
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx index cebacda7e5f5..5c1fa6df3e30 100644 --- a/vcl/win/gdi/gdiimpl.cxx +++ b/vcl/win/gdi/gdiimpl.cxx @@ -1457,56 +1457,55 @@ HBRUSH WinSalGraphicsImpl::SearchStockBrush(COLORREF nBrushColor) return nullptr; } -HBRUSH WinSalGraphicsImpl::MakeBrush(Color nColor) +namespace +{ + +HBRUSH Make16BitDIBPatternBrush(Color nColor) { const SalData* pSalData = GetSalData(); - BYTE nRed = nColor.GetRed(); - BYTE nGreen = nColor.GetGreen(); - BYTE nBlue = nColor.GetBlue(); - COLORREF nBrushColor = PALETTERGB(nRed, nGreen, nBlue); + const BYTE nRed = nColor.GetRed(); + const BYTE nGreen = nColor.GetGreen(); + const BYTE nBlue = nColor.GetBlue(); - if (mrParent.isPrinter() || !pSalData->mhDitherDIB) - return CreateSolidBrush(nBrushColor); + static const BYTE aOrdDither16Bit[8][8] = + { + { 0, 6, 1, 7, 0, 6, 1, 7 }, + { 4, 2, 5, 3, 4, 2, 5, 3 }, + { 1, 7, 0, 6, 1, 7, 0, 6 }, + { 5, 3, 4, 2, 5, 3, 4, 2 }, + { 0, 6, 1, 7, 0, 6, 1, 7 }, + { 4, 2, 5, 3, 4, 2, 5, 3 }, + { 1, 7, 0, 6, 1, 7, 0, 6 }, + { 5, 3, 4, 2, 5, 3, 4, 2 } + }; - if (24 == reinterpret_cast<BITMAPINFOHEADER*>(pSalData->mpDitherDIB)->biBitCount) + BYTE* pTmp = pSalData->mpDitherDIBData; + long* pDitherDiff = pSalData->mpDitherDiff; + BYTE* pDitherLow = pSalData->mpDitherLow; + BYTE* pDitherHigh = pSalData->mpDitherHigh; + + for(int nY = 0; nY < 8; ++nY) { - static const BYTE aOrdDither16Bit[8][8] = - { - { 0, 6, 1, 7, 0, 6, 1, 7 }, - { 4, 2, 5, 3, 4, 2, 5, 3 }, - { 1, 7, 0, 6, 1, 7, 0, 6 }, - { 5, 3, 4, 2, 5, 3, 4, 2 }, - { 0, 6, 1, 7, 0, 6, 1, 7 }, - { 4, 2, 5, 3, 4, 2, 5, 3 }, - { 1, 7, 0, 6, 1, 7, 0, 6 }, - { 5, 3, 4, 2, 5, 3, 4, 2 } - }; - - 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) { - 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); - } + const BYTE nThres = aOrdDither16Bit[nY][nX]; + *pTmp++ = DMAP(nBlue, nThres); + *pTmp++ = DMAP(nGreen, nThres); + *pTmp++ = DMAP(nRed, nThres); } - - return CreateDIBPatternBrush(pSalData->mhDitherDIB, DIB_RGB_COLORS); } - if (ImplIsSysColorEntry(nColor)) - return CreateSolidBrush(PALRGB_TO_RGB(nBrushColor)); + return CreateDIBPatternBrush(pSalData->mhDitherDIB, DIB_RGB_COLORS); +} - if (ImplIsPaletteEntry(nRed, nGreen, nBlue)) - return CreateSolidBrush(nBrushColor); +HBRUSH Make8BitDIBPatternBrush(Color nColor) +{ + const SalData* pSalData = GetSalData(); + + const BYTE nRed = nColor.GetRed(); + const BYTE nGreen = nColor.GetGreen(); + const BYTE nBlue = nColor.GetBlue(); static const BYTE aOrdDither8Bit[8][8] = { @@ -1540,6 +1539,32 @@ HBRUSH WinSalGraphicsImpl::MakeBrush(Color nColor) return CreateDIBPatternBrush(pSalData->mhDitherDIB, DIB_PAL_COLORS); } +} // namespace + +HBRUSH WinSalGraphicsImpl::MakeBrush(Color nColor) +{ + const SalData* pSalData = GetSalData(); + + const BYTE nRed = nColor.GetRed(); + const BYTE nGreen = nColor.GetGreen(); + const BYTE nBlue = nColor.GetBlue(); + const COLORREF nBrushColor = PALETTERGB(nRed, nGreen, nBlue); + + if (mrParent.isPrinter() || !pSalData->mhDitherDIB) + return CreateSolidBrush(nBrushColor); + + if (24 == reinterpret_cast<BITMAPINFOHEADER*>(pSalData->mpDitherDIB)->biBitCount) + return Make16BitDIBPatternBrush(nColor); + + if (ImplIsSysColorEntry(nColor)) + return CreateSolidBrush(PALRGB_TO_RGB(nBrushColor)); + + if (ImplIsPaletteEntry(nRed, nGreen, nBlue)) + return CreateSolidBrush(nBrushColor); + + return Make8BitDIBPatternBrush(nColor); +} + void WinSalGraphicsImpl::ResetBrush(HBRUSH hNewBrush) { HBRUSH hOldBrush = SelectBrush(mrParent.getHDC(), hNewBrush); |