summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Eves <tim_eves@sil.org>2016-05-10 09:47:30 +0700
committerMartin Hosken <martin_hosken@sil.org>2016-05-10 07:00:31 +0000
commit1caae7289d696686e88f60155cef895c5d781f53 (patch)
tree3d0e8470751744ff9c4d04837eb059b854e03c39
parent5949683a5da9efd11fa387007363a754f39833d9 (diff)
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 <ci@libreoffice.org> Reviewed-by: Martin Hosken <martin_hosken@sil.org>
-rw-r--r--vcl/win/gdi/winlayout.cxx14
1 files changed, 8 insertions, 6 deletions
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index be97cfe59a21..7c217b6d22c7 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -3745,8 +3745,9 @@ bool D2DWriteTextOutRenderer::operator ()(WinLayout const &rLayout, HDC hDC,
bool succeeded = GetDWriteInkBox(*mpFontFace, rLayout, mlfEmHeight, bounds);
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;
@@ -3781,14 +3782,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();
@@ -3886,7 +3887,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)