summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/page/cpdf_colorstate.cpp6
-rw-r--r--core/fpdfapi/render/cpdf_transferfunc.cpp8
-rw-r--r--core/fpdfapi/render/cpdf_transferfunc.h2
-rw-r--r--core/fpdfdoc/cpdf_bookmark.cpp12
-rw-r--r--core/fxge/dib/fx_dib_main.cpp2
-rw-r--r--core/fxge/fx_dib.h5
-rw-r--r--fpdfsdk/cpdfsdk_interform.cpp6
7 files changed, 25 insertions, 16 deletions
diff --git a/core/fpdfapi/page/cpdf_colorstate.cpp b/core/fpdfapi/page/cpdf_colorstate.cpp
index 2361552556..227fd62045 100644
--- a/core/fpdfapi/page/cpdf_colorstate.cpp
+++ b/core/fpdfapi/page/cpdf_colorstate.cpp
@@ -99,7 +99,7 @@ void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
return;
}
}
- pData->m_FillColorRef = ret ? FXSYS_RGB(R, G, B) : 0xFFFFFFFF;
+ pData->m_FillColorRef = ret ? FXSYS_BGR(B, G, R) : 0xFFFFFFFF;
}
void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
@@ -118,7 +118,7 @@ void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
}
}
pData->m_StrokeColorRef =
- pData->m_StrokeColor.GetRGB(&R, &G, &B) ? FXSYS_RGB(R, G, B) : 0xFFFFFFFF;
+ pData->m_StrokeColor.GetRGB(&R, &G, &B) ? FXSYS_BGR(B, G, R) : 0xFFFFFFFF;
}
void CPDF_ColorState::SetColor(CPDF_Color& color,
@@ -138,7 +138,7 @@ void CPDF_ColorState::SetColor(CPDF_Color& color,
int R;
int G;
int B;
- *colorref = color.GetRGB(&R, &G, &B) ? FXSYS_RGB(R, G, B) : 0xFFFFFFFF;
+ *colorref = color.GetRGB(&R, &G, &B) ? FXSYS_BGR(B, G, R) : 0xFFFFFFFF;
}
CPDF_ColorState::ColorData::ColorData()
diff --git a/core/fpdfapi/render/cpdf_transferfunc.cpp b/core/fpdfapi/render/cpdf_transferfunc.cpp
index c28afde0d9..25717437d3 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 bgr) const {
- return FXSYS_RGB(m_Samples[FXSYS_GetRValue(bgr)],
- m_Samples[256 + FXSYS_GetGValue(bgr)],
- m_Samples[512 + FXSYS_GetBValue(bgr)]);
+FX_COLORREF CPDF_TransferFunc::TranslateColor(FX_COLORREF colorref) const {
+ return FXSYS_BGR(m_Samples[512 + FXSYS_GetBValue(colorref)],
+ m_Samples[256 + FXSYS_GetGValue(colorref)],
+ m_Samples[FXSYS_GetRValue(colorref)]);
}
RetainPtr<CFX_DIBSource> CPDF_TransferFunc::TranslateImage(
diff --git a/core/fpdfapi/render/cpdf_transferfunc.h b/core/fpdfapi/render/cpdf_transferfunc.h
index de95a439c3..dfc186ec6c 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 bgr) const;
+ FX_COLORREF TranslateColor(FX_COLORREF colorref) const;
RetainPtr<CFX_DIBSource> TranslateImage(const RetainPtr<CFX_DIBSource>& pSrc);
const CPDF_Document* GetDocument() const { return m_pPDFDoc.Get(); }
diff --git a/core/fpdfdoc/cpdf_bookmark.cpp b/core/fpdfdoc/cpdf_bookmark.cpp
index cc7e127d23..5f8997d647 100644
--- a/core/fpdfdoc/cpdf_bookmark.cpp
+++ b/core/fpdfdoc/cpdf_bookmark.cpp
@@ -14,6 +14,12 @@
#include "core/fpdfdoc/cpdf_nametree.h"
#include "core/fxge/fx_dib.h"
+namespace {
+
+constexpr uint32_t kBlackBGR = FXSYS_BGR(0, 0, 0);
+
+} // namespace
+
CPDF_Bookmark::CPDF_Bookmark() {}
CPDF_Bookmark::CPDF_Bookmark(const CPDF_Bookmark& that) = default;
@@ -24,16 +30,16 @@ CPDF_Bookmark::~CPDF_Bookmark() {}
uint32_t CPDF_Bookmark::GetColorRef() const {
if (!m_pDict)
- return FXSYS_RGB(0, 0, 0);
+ return kBlackBGR;
CPDF_Array* pColor = m_pDict->GetArrayFor("C");
if (!pColor)
- return FXSYS_RGB(0, 0, 0);
+ return kBlackBGR;
int r = FXSYS_round(pColor->GetNumberAt(0) * 255);
int g = FXSYS_round(pColor->GetNumberAt(1) * 255);
int b = FXSYS_round(pColor->GetNumberAt(2) * 255);
- return FXSYS_RGB(r, g, b);
+ return FXSYS_BGR(b, g, r);
}
uint32_t CPDF_Bookmark::GetFontStyle() const {
diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp
index 6c3a236edd..002fc2e394 100644
--- a/core/fxge/dib/fx_dib_main.cpp
+++ b/core/fxge/dib/fx_dib_main.cpp
@@ -84,7 +84,7 @@ std::pair<int, FX_COLORREF> ArgbToAlphaAndColorRef(FX_ARGB argb) {
}
FX_COLORREF ArgbToColorRef(FX_ARGB argb) {
- return FXSYS_RGB(FXARGB_R(argb), FXARGB_G(argb), FXARGB_B(argb));
+ return FXSYS_BGR(FXARGB_B(argb), FXARGB_G(argb), FXARGB_R(argb));
}
FX_ARGB AlphaAndColorRefToArgb(int a, FX_COLORREF colorref) {
diff --git a/core/fxge/fx_dib.h b/core/fxge/fx_dib.h
index 4af47907ea..9acfa51bbe 100644
--- a/core/fxge/fx_dib.h
+++ b/core/fxge/fx_dib.h
@@ -74,8 +74,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))
+constexpr uint32_t FXSYS_BGR(uint8_t b, uint8_t g, uint8_t r) {
+ return (b << 16) | (g << 8) | r;
+}
constexpr uint8_t FXSYS_GetRValue(uint32_t bgr) {
return bgr & 0xff;
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index f4e22d7744..9231951d33 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -46,6 +46,8 @@
namespace {
+constexpr uint32_t kWhiteBGR = FXSYS_BGR(255, 255, 255);
+
bool IsFormFieldTypeComboOrText(FormFieldType fieldType) {
switch (fieldType) {
case FormFieldType::kComboBox:
@@ -699,7 +701,7 @@ bool CPDFSDK_InterForm::IsNeedHighLight(FormFieldType fieldType) {
void CPDFSDK_InterForm::RemoveAllHighLights() {
std::fill(m_HighlightColor, m_HighlightColor + kFormFieldTypeCount,
- FXSYS_RGB(255, 255, 255));
+ kWhiteBGR);
std::fill(m_NeedsHighlight, m_NeedsHighlight + kFormFieldTypeCount, false);
}
@@ -721,7 +723,7 @@ void CPDFSDK_InterForm::SetAllHighlightColors(FX_COLORREF clr) {
FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(FormFieldType fieldType) {
if (fieldType == FormFieldType::kUnknown)
- return FXSYS_RGB(255, 255, 255);
+ return kWhiteBGR;
#ifdef PDF_ENABLE_XFA
// For the XFA fields, we need to return the specific field type highlight