diff options
author | Lei Zhang <thestig@chromium.org> | 2018-03-15 15:06:11 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-03-15 15:06:11 +0000 |
commit | c2d9e2d00ee871fa538bc46c8209e98ab9a30c44 (patch) | |
tree | e2d97c232971510f74bbf1a6d6e25045592c56b4 /core | |
parent | 9875889910585b08d2abd372ddc95469baf1a7e9 (diff) | |
download | pdfium-c2d9e2d00ee871fa538bc46c8209e98ab9a30c44.tar.xz |
Rename FX_COLORREF variables from "rgb" to "bgr".
FX_COLORREF should work like win32 COLORREF, which is BGR.
Change-Id: I9f8bb3e2d30a64dc822ac6b8c46130358a03678a
Reviewed-on: https://pdfium-review.googlesource.com/28574
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/page/cpdf_colorstate.h | 1 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 16 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_transferfunc.cpp | 8 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_transferfunc.h | 2 | ||||
-rw-r--r-- | core/fxge/dib/fx_dib_main.cpp | 6 | ||||
-rw-r--r-- | core/fxge/fx_dib.h | 5 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 24 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_print.cpp | 6 |
8 files changed, 36 insertions, 32 deletions
diff --git a/core/fpdfapi/page/cpdf_colorstate.h b/core/fpdfapi/page/cpdf_colorstate.h index 9619051e2c..cae79b28e2 100644 --- a/core/fpdfapi/page/cpdf_colorstate.h +++ b/core/fpdfapi/page/cpdf_colorstate.h @@ -54,6 +54,7 @@ class CPDF_ColorState { void SetDefault(); + // TODO(thestig): Rename these to BGR. uint32_t m_FillRGB; uint32_t m_StrokeRGB; CPDF_Color m_FillColor; diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 0022fb1bdb..1ded1ca496 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -1357,8 +1357,8 @@ FX_ARGB CPDF_RenderStatus::GetFillArgb(CPDF_PageObject* pObj, if (MissingFillColor(pColorState)) pColorState = &m_InitialStates.m_ColorState; - FX_COLORREF rgb = pColorState->GetFillRGB(); - if (rgb == (uint32_t)-1) + FX_COLORREF bgr = pColorState->GetFillRGB(); + if (bgr == 0xFFFFFFFF) return 0; int32_t alpha = @@ -1369,9 +1369,9 @@ FX_ARGB CPDF_RenderStatus::GetFillArgb(CPDF_PageObject* pObj, GetTransferFunc(pObj->m_GeneralState.GetTR())); } if (pObj->m_GeneralState.GetTransferFunc()) - rgb = pObj->m_GeneralState.GetTransferFunc()->TranslateColor(rgb); + bgr = pObj->m_GeneralState.GetTransferFunc()->TranslateColor(bgr); } - return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); + return m_Options.TranslateColor(ArgbEncode(alpha, bgr)); } FX_ARGB CPDF_RenderStatus::GetStrokeArgb(CPDF_PageObject* pObj) const { @@ -1382,8 +1382,8 @@ FX_ARGB CPDF_RenderStatus::GetStrokeArgb(CPDF_PageObject* pObj) const { if (MissingStrokeColor(pColorState)) pColorState = &m_InitialStates.m_ColorState; - FX_COLORREF rgb = pColorState->GetStrokeRGB(); - if (rgb == (uint32_t)-1) + FX_COLORREF bgr = pColorState->GetStrokeRGB(); + if (bgr == 0xFFFFFFFF) return 0; int32_t alpha = static_cast<int32_t>(pObj->m_GeneralState.GetStrokeAlpha() * @@ -1394,9 +1394,9 @@ FX_ARGB CPDF_RenderStatus::GetStrokeArgb(CPDF_PageObject* pObj) const { GetTransferFunc(pObj->m_GeneralState.GetTR())); } if (pObj->m_GeneralState.GetTransferFunc()) - rgb = pObj->m_GeneralState.GetTransferFunc()->TranslateColor(rgb); + bgr = pObj->m_GeneralState.GetTransferFunc()->TranslateColor(bgr); } - return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); + return m_Options.TranslateColor(ArgbEncode(alpha, bgr)); } void CPDF_RenderStatus::ProcessClipPath(const CPDF_ClipPath& ClipPath, diff --git a/core/fpdfapi/render/cpdf_transferfunc.cpp b/core/fpdfapi/render/cpdf_transferfunc.cpp index 98528c3c14..c28afde0d9 100644 --- a/core/fpdfapi/render/cpdf_transferfunc.cpp +++ b/core/fpdfapi/render/cpdf_transferfunc.cpp @@ -14,10 +14,10 @@ CPDF_TransferFunc::CPDF_TransferFunc(CPDF_Document* pDoc) : m_pPDFDoc(pDoc) {} CPDF_TransferFunc::~CPDF_TransferFunc() {} -FX_COLORREF CPDF_TransferFunc::TranslateColor(FX_COLORREF rgb) const { - return FXSYS_RGB(m_Samples[FXSYS_GetRValue(rgb)], - m_Samples[256 + FXSYS_GetGValue(rgb)], - m_Samples[512 + FXSYS_GetBValue(rgb)]); +FX_COLORREF CPDF_TransferFunc::TranslateColor(FX_COLORREF bgr) const { + return FXSYS_RGB(m_Samples[FXSYS_GetRValue(bgr)], + m_Samples[256 + FXSYS_GetGValue(bgr)], + m_Samples[512 + FXSYS_GetBValue(bgr)]); } RetainPtr<CFX_DIBSource> CPDF_TransferFunc::TranslateImage( diff --git a/core/fpdfapi/render/cpdf_transferfunc.h b/core/fpdfapi/render/cpdf_transferfunc.h index d7e21fcfef..de95a439c3 100644 --- a/core/fpdfapi/render/cpdf_transferfunc.h +++ b/core/fpdfapi/render/cpdf_transferfunc.h @@ -19,7 +19,7 @@ class CPDF_TransferFunc : public Retainable { template <typename T, typename... Args> friend RetainPtr<T> pdfium::MakeRetain(Args&&... args); - FX_COLORREF TranslateColor(FX_COLORREF src) const; + FX_COLORREF TranslateColor(FX_COLORREF bgr) const; RetainPtr<CFX_DIBSource> TranslateImage(const RetainPtr<CFX_DIBSource>& pSrc); const CPDF_Document* GetDocument() const { return m_pPDFDoc.Get(); } diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp index 68e06a6c5d..1349e3e43c 100644 --- a/core/fxge/dib/fx_dib_main.cpp +++ b/core/fxge/dib/fx_dib_main.cpp @@ -84,9 +84,9 @@ std::pair<int, FX_COLORREF> ArgbToColorRef(FX_ARGB argb) { FXSYS_RGB(FXARGB_R(argb), FXARGB_G(argb), FXARGB_B(argb))}; } -uint32_t ArgbEncode(int a, FX_COLORREF rgb) { - return FXARGB_MAKE(a, FXSYS_GetRValue(rgb), FXSYS_GetGValue(rgb), - FXSYS_GetBValue(rgb)); +uint32_t ArgbEncode(int a, FX_COLORREF bgr) { + return FXARGB_MAKE(a, FXSYS_GetRValue(bgr), FXSYS_GetGValue(bgr), + FXSYS_GetBValue(bgr)); } FX_ARGB StringToFXARGB(const WideStringView& wsValue) { diff --git a/core/fxge/fx_dib.h b/core/fxge/fx_dib.h index f7626afd35..8134c5066d 100644 --- a/core/fxge/fx_dib.h +++ b/core/fxge/fx_dib.h @@ -70,7 +70,9 @@ extern const int16_t SDP_Table[513]; #define FXDIB_BLEND_LUMINOSITY 24 #define FXDIB_BLEND_UNSUPPORTED -1 +// TODO(thestig): Rename to FXSYS_BGR() and check callers. #define FXSYS_RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16)) +// TODO(thestig): Rename parameter to |bgr| and check callers. #define FXSYS_GetRValue(rgb) ((rgb)&0xff) #define FXSYS_GetGValue(rgb) (((rgb) >> 8) & 0xff) #define FXSYS_GetBValue(rgb) (((rgb) >> 16) & 0xff) @@ -93,7 +95,8 @@ std::pair<int, FX_COLORREF> ArgbToColorRef(FX_ARGB argb); inline FX_ARGB ArgbEncode(int a, int r, int g, int b) { return (a << 24) | (r << 16) | (g << 8) | b; } -FX_ARGB ArgbEncode(int a, FX_COLORREF rgb); +// TODO(thestig): Rename to AlphaAndColorRefToArgb(). +FX_ARGB ArgbEncode(int a, FX_COLORREF bgr); FX_ARGB StringToFXARGB(const WideStringView& view); diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index ec0ed3561d..673593cdda 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -133,10 +133,10 @@ HPEN CreateExtPen(const CFX_GraphStateData* pGraphState, } int a; - FX_COLORREF rgb; - std::tie(a, rgb) = ArgbToColorRef(argb); + FX_COLORREF bgr; + std::tie(a, bgr) = ArgbToColorRef(argb); LOGBRUSH lb; - lb.lbColor = rgb; + lb.lbColor = bgr; lb.lbStyle = BS_SOLID; lb.lbHatch = 0; std::vector<uint32_t> dashes; @@ -156,9 +156,9 @@ HPEN CreateExtPen(const CFX_GraphStateData* pGraphState, HBRUSH CreateBrush(uint32_t argb) { int a; - FX_COLORREF rgb; - std::tie(a, rgb) = ArgbToColorRef(argb); - return CreateSolidBrush(rgb); + FX_COLORREF bgr; + std::tie(a, bgr) = ArgbToColorRef(argb); + return CreateSolidBrush(bgr); } void SetPathToDC(HDC hDC, @@ -1073,15 +1073,15 @@ bool CGdiDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, return false; int alpha; - FX_COLORREF rgb; - std::tie(alpha, rgb) = ArgbToColorRef(fill_color); + FX_COLORREF bgr; + std::tie(alpha, bgr) = ArgbToColorRef(fill_color); if (alpha == 0) return true; if (alpha < 255) return false; - HBRUSH hBrush = CreateSolidBrush(rgb); + HBRUSH hBrush = CreateSolidBrush(bgr); ::FillRect(m_hDC, (RECT*)pRect, hBrush); DeleteObject(hBrush); return true; @@ -1127,12 +1127,12 @@ bool CGdiDeviceDriver::DrawCosmeticLine(const CFX_PointF& ptMoveTo, return false; int a; - FX_COLORREF rgb; - std::tie(a, rgb) = ArgbToColorRef(color); + FX_COLORREF bgr; + std::tie(a, bgr) = ArgbToColorRef(color); if (a == 0) return true; - HPEN hPen = CreatePen(PS_SOLID, 1, rgb); + HPEN hPen = CreatePen(PS_SOLID, 1, bgr); 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 df9e8387d5..f2ae8a726e 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -281,9 +281,9 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars, // Color int iUnusedAlpha; - FX_COLORREF rgb; - std::tie(iUnusedAlpha, rgb) = ArgbToColorRef(color); - SetTextColor(m_hDC, rgb); + FX_COLORREF bgr; + std::tie(iUnusedAlpha, bgr) = ArgbToColorRef(color); + SetTextColor(m_hDC, bgr); SetBkMode(m_hDC, TRANSPARENT); // Text |