From a263a497722ddda21b47423dbde0c473020a8c55 Mon Sep 17 00:00:00 2001 From: Tim Eves Date: Tue, 10 May 2016 09:47:30 +0700 Subject: tdf#99207: Fix incorrect RGB ordering in Graphite DWrite path Direct 2D accepts colours specified as UINT32 ARGB values or floats. However GDI presents colours as COLOREFS which are 32 bit FBGR (F is a flag not an alpha) values. Passing a COLORREF to D2D1:ColorF swaps the red and blue channels. This patch converts the COLORREF into RGB float triples using the GDI colour macros. Change-Id: Iee5c00bfb10fa8771a2a1019976f70633cca4094 Reviewed-on: https://gerrit.libreoffice.org/24819 Tested-by: Jenkins Reviewed-by: Martin Hosken Reviewed-on: https://gerrit.libreoffice.org/24823 --- vcl/win/source/gdi/winlayout.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index aa42a1950306..170c94be21a2 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -3730,8 +3730,9 @@ bool D2DWriteTextOutRenderer::operator ()(WinLayout const &rLayout, HDC hDC, } succeeded &= BindDC(hDC, bounds); // Update the bounding rect. - ID2D1SolidColorBrush* pBlackBrush = NULL; - succeeded &= SUCCEEDED(mpRT->CreateSolidColorBrush(D2D1::ColorF(GetTextColor(hDC)), &pBlackBrush)); + ID2D1SolidColorBrush* pBrush = NULL; + COLORREF bgrTextColor = GetTextColor(mhDC); + succeeded &= SUCCEEDED(mpRT->CreateSolidColorBrush(D2D1::ColorF(GetRValue(bgrTextColor) / 255.0f, GetGValue(bgrTextColor) / 255.0f, GetBValue(bgrTextColor) / 255.0f), &pBrush)); HRESULT hr = S_OK; int nGlyphs = 0; @@ -3766,14 +3767,14 @@ bool D2DWriteTextOutRenderer::operator ()(WinLayout const &rLayout, HDC hDC, 0 }; - mpRT->DrawGlyphRun(baseline, &glyphs, pBlackBrush); + mpRT->DrawGlyphRun(baseline, &glyphs, pBrush); } while (!pRectToErase); hr = mpRT->EndDraw(); } - if (pBlackBrush) - pBlackBrush->Release(); + if (pBrush) + pBrush->Release(); ReleaseFont(); @@ -3874,7 +3875,8 @@ bool D2DWriteTextOutRenderer::DrawGlyphs(const Point & origin, uint16_t * pGid, bool succeeded = BindDC(mhDC, bounds); // Update the bounding rect. ID2D1SolidColorBrush* pBrush = NULL; - succeeded &= SUCCEEDED(mpRT->CreateSolidColorBrush(D2D1::ColorF(GetTextColor(mhDC)), &pBrush)); + COLORREF bgrTextColor = GetTextColor(mhDC); + succeeded &= SUCCEEDED(mpRT->CreateSolidColorBrush(D2D1::ColorF(GetRValue(bgrTextColor) / 255.0f, GetGValue(bgrTextColor) / 255.0f, GetBValue(bgrTextColor) / 255.0f), &pBrush)); HRESULT hr = S_OK; if (succeeded) -- cgit v1.2.3