Remove more _FX_PLATFORM_APPLE_ usage.
Use build/build_config.h to standarize on Chromium's platform defines.
Replace _FX_PLATFORM_APPLE_ with defined(OS_MACOSX).
Change-Id: I88cbc0ed257aa445b730cc03ae989b63ce181ede
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/53713
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 9c526b1..73c4985 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -605,9 +605,7 @@
uint16_t cid = CIDFromCharCode(charcode);
wchar_t unicode = 0;
if (m_bCIDIsGID) {
-#if _FX_PLATFORM_ != _FX_PLATFORM_APPLE_
- return cid;
-#else
+#if defined(OS_MACOSX)
if (FontStyleIsSymbolic(m_Flags))
return cid;
@@ -616,6 +614,8 @@
return cid;
unicode = uni_str[0];
+#else
+ return cid;
#endif
} else {
if (cid && m_pCID2UnicodeMap && m_pCID2UnicodeMap->IsLoaded())
diff --git a/core/fxcrt/cfx_fileaccess_posix.h b/core/fxcrt/cfx_fileaccess_posix.h
index 6d52024..39fdb23 100644
--- a/core/fxcrt/cfx_fileaccess_posix.h
+++ b/core/fxcrt/cfx_fileaccess_posix.h
@@ -11,8 +11,8 @@
#include "core/fxcrt/fileaccess_iface.h"
#include "core/fxcrt/fx_system.h"
-#if _FX_PLATFORM_ != _FX_PLATFORM_LINUX_ && \
- _FX_PLATFORM_ != _FX_PLATFORM_APPLE_ && !defined(OS_ANDROID)
+#if _FX_PLATFORM_ != _FX_PLATFORM_LINUX_ && !defined(OS_MACOSX) && \
+ !defined(OS_ANDROID)
#error "Included on the wrong platform"
#endif
diff --git a/core/fxge/cfx_facecache.cpp b/core/fxge/cfx_facecache.cpp
index 869e464..eb43004 100644
--- a/core/fxge/cfx_facecache.cpp
+++ b/core/fxge/cfx_facecache.cpp
@@ -230,16 +230,7 @@
int nMatrixB = static_cast<int>(matrix.b * 10000);
int nMatrixC = static_cast<int>(matrix.c * 10000);
int nMatrixD = static_cast<int>(matrix.d * 10000);
-#if _FX_PLATFORM_ != _FX_PLATFORM_APPLE_
- if (pFont->GetSubstFont()) {
- keygen.Generate(9, nMatrixA, nMatrixB, nMatrixC, nMatrixD, dest_width,
- anti_alias, pFont->GetSubstFont()->m_Weight,
- pFont->GetSubstFont()->m_ItalicAngle, pFont->IsVertical());
- } else {
- keygen.Generate(6, nMatrixA, nMatrixB, nMatrixC, nMatrixD, dest_width,
- anti_alias);
- }
-#else
+#if defined(OS_MACOSX)
if (text_flags & FXTEXT_NO_NATIVETEXT) {
if (pFont->GetSubstFont()) {
keygen.Generate(9, nMatrixA, nMatrixB, nMatrixC, nMatrixD, dest_width,
@@ -261,6 +252,15 @@
anti_alias, 3);
}
}
+#else
+ if (pFont->GetSubstFont()) {
+ keygen.Generate(9, nMatrixA, nMatrixB, nMatrixC, nMatrixD, dest_width,
+ anti_alias, pFont->GetSubstFont()->m_Weight,
+ pFont->GetSubstFont()->m_ItalicAngle, pFont->IsVertical());
+ } else {
+ keygen.Generate(6, nMatrixA, nMatrixB, nMatrixC, nMatrixD, dest_width,
+ anti_alias);
+ }
#endif
ByteString FaceGlyphsKey(keygen.key_, keygen.key_len_);
#if !defined(OS_MACOSX) || defined _SKIA_SUPPORT_ || \
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index e313191..604450e 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -10,6 +10,7 @@
#include <memory>
#include <utility>
+#include "build/build_config.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxge/cfx_defaultrenderdevice.h"
#include "core/fxge/cfx_facecache.h"
@@ -349,7 +350,7 @@
}
bool ShouldDrawDeviceText(const CFX_Font* pFont, uint32_t text_flags) {
-#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
+#if defined(OS_MACOSX)
if (text_flags & FXFONT_CIDFONT)
return false;
@@ -365,17 +366,7 @@
} // namespace
-TextCharPos::TextCharPos()
- : m_Unicode(0),
- m_GlyphIndex(0),
- m_FontCharWidth(0),
-#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
- m_ExtGID(0),
-#endif
- m_FallbackFontPosition(0),
- m_bGlyphAdjust(false),
- m_bFontStyle(false) {
-}
+TextCharPos::TextCharPos() = default;
TextCharPos::TextCharPos(const TextCharPos&) = default;
@@ -461,14 +452,14 @@
}
if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT)
return pDIB->Create(width, height, FXDIB_8bppMask);
-#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_ || defined _SKIA_SUPPORT_PATHS_
+#if defined(OS_MACOSX) || defined _SKIA_SUPPORT_PATHS_
+ constexpr FXDIB_Format kPlatformFormat = FXDIB_Rgb32;
+#else
+ constexpr FXDIB_Format kPlatformFormat = FXDIB_Rgb;
+#endif
return pDIB->Create(
width, height,
- m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb32);
-#else
- return pDIB->Create(
- width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb);
-#endif
+ m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : kPlatformFormat);
}
bool CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData,
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index 7327abb..b4c53ef 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -10,6 +10,7 @@
#include <memory>
#include <vector>
+#include "build/build_config.h"
#include "core/fpdfdoc/cpdf_defaultappearance.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/unowned_ptr.h"
@@ -76,15 +77,15 @@
~TextCharPos();
CFX_PointF m_Origin;
- uint32_t m_Unicode;
- uint32_t m_GlyphIndex;
- uint32_t m_FontCharWidth;
-#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
- uint32_t m_ExtGID;
+ uint32_t m_Unicode = 0;
+ uint32_t m_GlyphIndex = 0;
+ uint32_t m_FontCharWidth = 0;
+#if defined(OS_MACOSX)
+ uint32_t m_ExtGID = 0;
#endif
- int32_t m_FallbackFontPosition;
- bool m_bGlyphAdjust;
- bool m_bFontStyle;
+ int32_t m_FallbackFontPosition = 0;
+ bool m_bGlyphAdjust = false;
+ bool m_bFontStyle = false;
float m_AdjustMatrix[4];
};
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index 9f91a85..08650e7 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -10,6 +10,7 @@
#include <memory>
#include <utility>
+#include "build/build_config.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxge/cfx_cliprgn.h"
#include "core/fxge/dib/cfx_scanlinecompositor.h"
@@ -315,12 +316,14 @@
if (HasAlpha()) {
if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb))
return false;
-#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
- } else if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb32)) {
+ } else {
+#if defined(OS_MACOSX)
+ constexpr FXDIB_Format kPlatformFormat = FXDIB_Rgb32;
#else
- } else if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb)) {
+ constexpr FXDIB_Format kPlatformFormat = FXDIB_Rgb;
#endif
- return false;
+ if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : kPlatformFormat))
+ return false;
}
}
destOffset = kChannelOffset[destChannel];
@@ -395,12 +398,14 @@
if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyka : FXDIB_Argb)) {
return false;
}
-#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
- } else if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb)) {
+ } else {
+#if defined(OS_MACOSX)
+ constexpr FXDIB_Format kPlatformFormat = FXDIB_Rgb;
#else
- } else if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : FXDIB_Rgb32)) {
+ constexpr FXDIB_Format kPlatformFormat = FXDIB_Rgb32;
#endif
- return false;
+ if (!ConvertFormat(IsCmykImage() ? FXDIB_Cmyk : kPlatformFormat))
+ return false;
}
}
destOffset = kChannelOffset[destChannel];