From ff46aaf499edcf153ee2f57c7016587aa96dcfa0 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 27 Jul 2015 11:55:29 -0700 Subject: FX Bool considered harmful, part 3 Try to reland this patch after fixing underlying issues that caused it to be reverted. fx_system.h is the only manual edit. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1258093002 . --- core/src/fxge/android/fpf_skiafont.cpp | 30 +++++++++++++++--------------- core/src/fxge/android/fpf_skiafont.h | 6 +++--- core/src/fxge/android/fpf_skiafontmgr.cpp | 28 ++++++++++++++-------------- core/src/fxge/android/fpf_skiafontmgr.h | 4 ++-- core/src/fxge/android/fx_android_font.cpp | 24 ++++++++++++------------ core/src/fxge/android/fx_android_font.h | 10 +++++----- 6 files changed, 51 insertions(+), 51 deletions(-) (limited to 'core/src/fxge/android') diff --git a/core/src/fxge/android/fpf_skiafont.cpp b/core/src/fxge/android/fpf_skiafont.cpp index 2dad01057a..f5ac6c0ce6 100644 --- a/core/src/fxge/android/fpf_skiafont.cpp +++ b/core/src/fxge/android/fpf_skiafont.cpp @@ -87,23 +87,23 @@ int32_t CFPF_SkiaFont::GetDescent() const } return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Descender(m_Face)); } -FX_BOOL CFPF_SkiaFont::GetGlyphBBox(int32_t iGlyphIndex, FX_RECT &rtBBox) +bool CFPF_SkiaFont::GetGlyphBBox(int32_t iGlyphIndex, FX_RECT &rtBBox) { if (!m_Face) { - return FALSE; + return false; } if (FXFT_Is_Face_Tricky(m_Face)) { if (FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72)) { - return FALSE; + return false; } if (FXFT_Load_Glyph(m_Face, iGlyphIndex, FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) { FXFT_Set_Pixel_Sizes(m_Face, 0, 64); - return FALSE; + return false; } FXFT_Glyph glyph; if (FXFT_Get_Glyph(m_Face->glyph, &glyph)) { FXFT_Set_Pixel_Sizes(m_Face, 0, 64); - return FALSE; + return false; } FXFT_BBox cbox; FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox); @@ -119,24 +119,24 @@ FX_BOOL CFPF_SkiaFont::GetGlyphBBox(int32_t iGlyphIndex, FX_RECT &rtBBox) return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0; } if (FXFT_Load_Glyph(m_Face, iGlyphIndex, FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) { - return FALSE; + return false; } rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriBearingX(m_Face)); rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriBearingY(m_Face)); rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width(m_Face)); rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(m_Face)); - return TRUE; + return true; } -FX_BOOL CFPF_SkiaFont::GetBBox(FX_RECT &rtBBox) +bool CFPF_SkiaFont::GetBBox(FX_RECT &rtBBox) { if (!m_Face) { - return FALSE; + return false; } rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_xMin(m_Face)); rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_yMin(m_Face)); rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_xMax(m_Face)); rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_yMax(m_Face)); - return TRUE; + return true; } int32_t CFPF_SkiaFont::GetHeight() const { @@ -167,10 +167,10 @@ FX_DWORD CFPF_SkiaFont::GetFontData(FX_DWORD dwTable, uint8_t* pBuffer, FX_DWORD } return pdfium::base::checked_cast(ulSize); } -FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescriptor *pFontDes, const CFX_ByteStringC& bsFamily, FX_DWORD dwStyle, uint8_t uCharset) +bool CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescriptor *pFontDes, const CFX_ByteStringC& bsFamily, FX_DWORD dwStyle, uint8_t uCharset) { if (!pFontMgr || !pFontDes) { - return FALSE; + return false; } switch (pFontDes->GetType()) { case FPF_SKIAFONTTYPE_Path: { @@ -189,16 +189,16 @@ FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescrip } break; default: - return FALSE; + return false; } if (!m_Face) { - return FALSE; + return false; } m_dwStyle = dwStyle; m_uCharset = uCharset; m_pFontMgr = pFontMgr; m_pFontDes = pFontDes; m_dwRefCount = 1; - return TRUE; + return true; } #endif diff --git a/core/src/fxge/android/fpf_skiafont.h b/core/src/fxge/android/fpf_skiafont.h index 49819d4c11..90cf5cb29c 100644 --- a/core/src/fxge/android/fpf_skiafont.h +++ b/core/src/fxge/android/fpf_skiafont.h @@ -39,13 +39,13 @@ public: virtual int32_t GetAscent() const; virtual int32_t GetDescent() const; - virtual FX_BOOL GetGlyphBBox(int32_t iGlyphIndex, FX_RECT &rtBBox); - virtual FX_BOOL GetBBox(FX_RECT &rtBBox); + virtual bool GetGlyphBBox(int32_t iGlyphIndex, FX_RECT &rtBBox); + virtual bool GetBBox(FX_RECT &rtBBox); virtual int32_t GetHeight() const; virtual int32_t GetItalicAngle() const; virtual FX_DWORD GetFontData(FX_DWORD dwTable, uint8_t* pBuffer, FX_DWORD dwSize); - FX_BOOL InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescriptor *pFontDes, const CFX_ByteStringC& bsFamily, FX_DWORD dwStyle, uint8_t uCharset); + bool InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescriptor *pFontDes, const CFX_ByteStringC& bsFamily, FX_DWORD dwStyle, uint8_t uCharset); protected: CFPF_SkiaFontMgr *m_pFontMgr; CFPF_SkiaFontDescriptor *m_pFontDes; diff --git a/core/src/fxge/android/fpf_skiafontmgr.cpp b/core/src/fxge/android/fpf_skiafontmgr.cpp index 86bb052435..8c835392fc 100644 --- a/core/src/fxge/android/fpf_skiafontmgr.cpp +++ b/core/src/fxge/android/fpf_skiafontmgr.cpp @@ -103,7 +103,7 @@ FX_DWORD FPF_SkiaGetSansFont(FX_DWORD dwHash) } return 0; } -static uint32_t FPF_GetHashCode_StringA(const FX_CHAR* pStr, int32_t iLength, FX_BOOL bIgnoreCase = FALSE) +static uint32_t FPF_GetHashCode_StringA(const FX_CHAR* pStr, int32_t iLength, bool bIgnoreCase = false) { if (!pStr) { return 0; @@ -208,27 +208,27 @@ static FX_DWORD FPF_SKIAGetFamilyHash(const CFX_ByteStringC& bsFamily, FX_DWORD bsFont += "Serif"; } bsFont += uCharset; - return FPF_GetHashCode_StringA(bsFont.c_str(), bsFont.GetLength(), TRUE); + return FPF_GetHashCode_StringA(bsFont.c_str(), bsFont.GetLength(), true); } -static FX_BOOL FPF_SkiaIsCJK(uint8_t uCharset) +static bool FPF_SkiaIsCJK(uint8_t uCharset) { return (uCharset == FXFONT_GB2312_CHARSET) || (uCharset == FXFONT_CHINESEBIG5_CHARSET) || (uCharset == FXFONT_HANGEUL_CHARSET) || (uCharset == FXFONT_SHIFTJIS_CHARSET); } -static FX_BOOL FPF_SkiaMaybeSymbol(const CFX_ByteStringC& bsFacename) +static bool FPF_SkiaMaybeSymbol(const CFX_ByteStringC& bsFacename) { CFX_ByteString bsName = bsFacename; bsName.MakeLower(); return bsName.Find("symbol") > -1; } -static FX_BOOL FPF_SkiaMaybeArabic(const CFX_ByteStringC& bsFacename) +static bool FPF_SkiaMaybeArabic(const CFX_ByteStringC& bsFacename) { CFX_ByteString bsName = bsFacename; bsName.MakeLower(); return bsName.Find("arabic") > -1; } CFPF_SkiaFontMgr::CFPF_SkiaFontMgr() - : m_bLoaded(FALSE), m_FTLibrary(NULL) + : m_bLoaded(false), m_FTLibrary(NULL) { } CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() @@ -252,7 +252,7 @@ CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() FXFT_Done_FreeType(m_FTLibrary); } } -FX_BOOL CFPF_SkiaFontMgr::InitFTLibrary() +bool CFPF_SkiaFontMgr::InitFTLibrary() { if (m_FTLibrary == NULL) { FXFT_Init_FreeType(&m_FTLibrary); @@ -266,7 +266,7 @@ void CFPF_SkiaFontMgr::LoadSystemFonts() } ScanPath(FX_BSTRC("/system/fonts")); OutputSystemFonts(); - m_bLoaded = TRUE; + m_bLoaded = true; } void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile) { @@ -289,7 +289,7 @@ IFPF_Font* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, uin FX_DWORD dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname); FX_DWORD dwSubst = FPF_SkiaGetSubstFont(dwFaceName); FX_DWORD dwSubstSans = FPF_SkiaGetSansFont(dwFaceName); - FX_BOOL bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname); + bool bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname); if (uCharset != FXFONT_ARABIC_CHARSET && FPF_SkiaMaybeArabic(bsFamilyname)) { uCharset = FXFONT_ARABIC_CHARSET; } else if (uCharset == FXFONT_ANSI_CHARSET && (dwMatch & FPF_MATCHFONT_REPLACEANSI)) { @@ -309,7 +309,7 @@ IFPF_Font* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, uin if (dwFaceName == dwSysFontName) { nFind += FPF_SKIAMATCHWEIGHT_NAME1; } - FX_BOOL bMatchedName = (nFind == FPF_SKIAMATCHWEIGHT_NAME1); + bool bMatchedName = (nFind == FPF_SKIAMATCHWEIGHT_NAME1); if ((dwStyle & FXFONT_BOLD) == (pFontDes->m_dwStyle & FXFONT_BOLD)) { nFind += FPF_SKIAMATCHWEIGHT_1; } @@ -327,7 +327,7 @@ IFPF_Font* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, uin } if (dwSubst == dwSysFontName || dwSubstSans == dwSysFontName) { nFind += FPF_SKIAMATCHWEIGHT_NAME2; - bMatchedName = TRUE; + bMatchedName = true; } if (uCharset == FXFONT_DEFAULT_CHARSET || bMaybeSymbol) { if (nFind > nMax && bMatchedName) { @@ -399,7 +399,7 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const CFX_ByteStringC& bsFile, int32_t i args.pathname = (FT_String*)bsFile.GetCStr(); FXFT_Face face; if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { - return FALSE; + return false; } FXFT_Set_Pixel_Sizes(face, 0, 64); return face; @@ -418,7 +418,7 @@ FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const uint8_t* pBuffer, size_t szBuffer, args.memory_size = szBuffer; FXFT_Face face; if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) { - return FALSE; + return false; } FXFT_Set_Pixel_Sizes(face, 0, 64); return face; @@ -430,7 +430,7 @@ void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteStringC& path) return; } CFX_ByteString filename; - FX_BOOL bFolder = FALSE; + bool bFolder = false; while (FX_GetNextFile(handle, filename, bFolder)) { if (bFolder) { if (filename == FX_BSTRC(".") || filename == FX_BSTRC("..")) { diff --git a/core/src/fxge/android/fpf_skiafontmgr.h b/core/src/fxge/android/fpf_skiafontmgr.h index 8c721ff68a..b4ebe9454a 100644 --- a/core/src/fxge/android/fpf_skiafontmgr.h +++ b/core/src/fxge/android/fpf_skiafontmgr.h @@ -94,7 +94,7 @@ class CFPF_SkiaFontMgr : public IFPF_FontMgr public: CFPF_SkiaFontMgr(); virtual ~CFPF_SkiaFontMgr(); - FX_BOOL InitFTLibrary(); + bool InitFTLibrary(); virtual void LoadSystemFonts(); virtual void LoadPrivateFont(IFX_FileRead* pFontFile); virtual void LoadPrivateFont(const CFX_ByteStringC& bsFileName); @@ -109,7 +109,7 @@ protected: void ScanFile(const CFX_ByteStringC& file); void ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor *pFontDesc); void OutputSystemFonts(); - FX_BOOL m_bLoaded; + bool m_bLoaded; CFX_PtrArray m_FontFaces; FXFT_Library m_FTLibrary; CFX_MapPtrToPtr m_FamilyFonts; diff --git a/core/src/fxge/android/fx_android_font.cpp b/core/src/fxge/android/fx_android_font.cpp index 3e2fc45854..4f2bc15b2a 100644 --- a/core/src/fxge/android/fx_android_font.cpp +++ b/core/src/fxge/android/fx_android_font.cpp @@ -10,20 +10,20 @@ CFX_AndroidFontInfo::CFX_AndroidFontInfo() : m_pFontMgr(NULL) { } -FX_BOOL CFX_AndroidFontInfo::Init(IFPF_FontMgr *pFontMgr) +bool CFX_AndroidFontInfo::Init(IFPF_FontMgr *pFontMgr) { if (!pFontMgr) { - return FALSE; + return false; } pFontMgr->LoadSystemFonts(); m_pFontMgr = pFontMgr; - return TRUE; + return true; } -FX_BOOL CFX_AndroidFontInfo::EnumFontList(CFX_FontMapper* pMapper) +bool CFX_AndroidFontInfo::EnumFontList(CFX_FontMapper* pMapper) { - return FALSE; + return false; } -void* CFX_AndroidFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, const FX_CHAR* face, FX_BOOL& bExact) +void* CFX_AndroidFontInfo::MapFont(int weight, bool bItalic, int charset, int pitch_family, const FX_CHAR* face, bool& bExact) { if (!m_pFontMgr) { return NULL; @@ -57,21 +57,21 @@ FX_DWORD CFX_AndroidFontInfo::GetFontData(void* hFont, FX_DWORD table, uint8_t* } return ((IFPF_Font*)hFont)->GetFontData(table, buffer, size); } -FX_BOOL CFX_AndroidFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) +bool CFX_AndroidFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) { if (!hFont) { - return FALSE; + return false; } name = ((IFPF_Font*)hFont)->GetFamilyName(); - return TRUE; + return true; } -FX_BOOL CFX_AndroidFontInfo::GetFontCharset(void* hFont, int& charset) +bool CFX_AndroidFontInfo::GetFontCharset(void* hFont, int& charset) { if (!hFont) { - return FALSE; + return false; } charset = ((IFPF_Font*)hFont)->GetCharset(); - return FALSE; + return false; } void CFX_AndroidFontInfo::DeleteFont(void* hFont) { diff --git a/core/src/fxge/android/fx_android_font.h b/core/src/fxge/android/fx_android_font.h index 83c04a03a4..075b79e7f2 100644 --- a/core/src/fxge/android/fx_android_font.h +++ b/core/src/fxge/android/fx_android_font.h @@ -18,18 +18,18 @@ public: delete this; } - virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper); + virtual bool EnumFontList(CFX_FontMapper* pMapper); - virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, const FX_CHAR* face, FX_BOOL& bExact); + virtual void* MapFont(int weight, bool bItalic, int charset, int pitch_family, const FX_CHAR* face, bool& bExact); virtual void* GetFont(const FX_CHAR* face); virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, uint8_t* buffer, FX_DWORD size); - virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name); - virtual FX_BOOL GetFontCharset(void* hFont, int& charset); + virtual bool GetFaceName(void* hFont, CFX_ByteString& name); + virtual bool GetFontCharset(void* hFont, int& charset); virtual void DeleteFont(void* hFont); virtual void* RetainFont(void* hFont); - FX_BOOL Init(IFPF_FontMgr *pFontMgr); + bool Init(IFPF_FontMgr *pFontMgr); protected: IFPF_FontMgr *m_pFontMgr; }; -- cgit v1.2.3