From 2e6405c333d8daae4e3edaa6b48f5ac5a8d7675b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 20 Mar 2018 15:25:57 +0000 Subject: Change ArgbToColorRef() to ArgbToAlphaAndColorRef(). Since that is what it really returns. Add a replacement ArgbToColorRef() that only returns a FX_COLORREF, and remove a duplicate implementation. Then update callers and only use ArgbToAlphaAndColorRef() where appropriate. Also update comments to explain what FX_COLORREF is. Change-Id: I5ed3d71683898dc2b3a66395dea0ec2562c14a68 Reviewed-on: https://pdfium-review.googlesource.com/28575 Reviewed-by: dsinclair Commit-Queue: dsinclair --- core/fxge/win32/fx_win32_device.cpp | 27 +++++++++++---------------- core/fxge/win32/fx_win32_print.cpp | 6 ++---- 2 files changed, 13 insertions(+), 20 deletions(-) (limited to 'core/fxge/win32') diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 673593cdda..b857dde91b 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -132,11 +132,9 @@ HPEN CreateExtPen(const CFX_GraphStateData* pGraphState, break; } - int a; - FX_COLORREF bgr; - std::tie(a, bgr) = ArgbToColorRef(argb); + FX_COLORREF colorref = ArgbToColorRef(argb); LOGBRUSH lb; - lb.lbColor = bgr; + lb.lbColor = colorref; lb.lbStyle = BS_SOLID; lb.lbHatch = 0; std::vector dashes; @@ -155,10 +153,7 @@ HPEN CreateExtPen(const CFX_GraphStateData* pGraphState, } HBRUSH CreateBrush(uint32_t argb) { - int a; - FX_COLORREF bgr; - std::tie(a, bgr) = ArgbToColorRef(argb); - return CreateSolidBrush(bgr); + return CreateSolidBrush(ArgbToColorRef(argb)); } void SetPathToDC(HDC hDC, @@ -1073,15 +1068,15 @@ bool CGdiDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, return false; int alpha; - FX_COLORREF bgr; - std::tie(alpha, bgr) = ArgbToColorRef(fill_color); + FX_COLORREF colorref; + std::tie(alpha, colorref) = ArgbToAlphaAndColorRef(fill_color); if (alpha == 0) return true; if (alpha < 255) return false; - HBRUSH hBrush = CreateSolidBrush(bgr); + HBRUSH hBrush = CreateSolidBrush(colorref); ::FillRect(m_hDC, (RECT*)pRect, hBrush); DeleteObject(hBrush); return true; @@ -1126,13 +1121,13 @@ bool CGdiDeviceDriver::DrawCosmeticLine(const CFX_PointF& ptMoveTo, if (blend_type != FXDIB_BLEND_NORMAL) return false; - int a; - FX_COLORREF bgr; - std::tie(a, bgr) = ArgbToColorRef(color); - if (a == 0) + int alpha; + FX_COLORREF colorref; + std::tie(alpha, colorref) = ArgbToAlphaAndColorRef(color); + if (alpha == 0) return true; - HPEN hPen = CreatePen(PS_SOLID, 1, bgr); + HPEN hPen = CreatePen(PS_SOLID, 1, colorref); hPen = (HPEN)SelectObject(m_hDC, hPen); MoveToEx(m_hDC, FXSYS_round(ptMoveTo.x), FXSYS_round(ptMoveTo.y), nullptr); LineTo(m_hDC, FXSYS_round(ptLineTo.x), FXSYS_round(ptLineTo.y)); diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index f2ae8a726e..66fbdd9b02 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -280,10 +280,8 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars, ModifyWorldTransform(m_hDC, &xform, MWT_LEFTMULTIPLY); // Color - int iUnusedAlpha; - FX_COLORREF bgr; - std::tie(iUnusedAlpha, bgr) = ArgbToColorRef(color); - SetTextColor(m_hDC, bgr); + FX_COLORREF colorref = ArgbToColorRef(color); + SetTextColor(m_hDC, colorref); SetBkMode(m_hDC, TRANSPARENT); // Text -- cgit v1.2.3