Add CFX_GlyphCache::GetFaceRec().
Helps minimize the size of a future CL.
Change-Id: Id8347b0de722d6528f54912de35eb5e38eeeff3e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/55775
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/cfx_glyphcache.cpp b/core/fxge/cfx_glyphcache.cpp
index 9cb0401..8d7a302 100644
--- a/core/fxge/cfx_glyphcache.cpp
+++ b/core/fxge/cfx_glyphcache.cpp
@@ -106,7 +106,7 @@
const CFX_Matrix& matrix,
uint32_t dest_width,
int anti_alias) {
- if (!m_Face)
+ if (!GetFaceRec())
return nullptr;
FT_Matrix ft_matrix;
@@ -142,18 +142,18 @@
pFont->GetSubstFont()->m_Weight);
}
}
- ScopedFontTransform scoped_transform(m_Face, &ft_matrix);
- int load_flags = (m_Face->face_flags & FT_FACE_FLAG_SFNT)
+ ScopedFontTransform scoped_transform(GetFaceRec(), &ft_matrix);
+ int load_flags = (GetFaceRec()->face_flags & FT_FACE_FLAG_SFNT)
? FT_LOAD_NO_BITMAP
: (FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING);
- int error = FT_Load_Glyph(m_Face, glyph_index, load_flags);
+ int error = FT_Load_Glyph(GetFaceRec(), glyph_index, load_flags);
if (error) {
// if an error is returned, try to reload glyphs without hinting.
if (load_flags & FT_LOAD_NO_HINTING || load_flags & FT_LOAD_NO_SCALE)
return nullptr;
load_flags |= FT_LOAD_NO_HINTING;
- error = FT_Load_Glyph(m_Face, glyph_index, load_flags);
+ error = FT_Load_Glyph(GetFaceRec(), glyph_index, load_flags);
if (error)
return nullptr;
}
@@ -176,32 +176,33 @@
(abs(static_cast<int>(ft_matrix.xx)) +
abs(static_cast<int>(ft_matrix.xy))) /
36655;
- FT_Outline_Embolden(FXFT_Get_Glyph_Outline(m_Face),
+ FT_Outline_Embolden(FXFT_Get_Glyph_Outline(GetFaceRec()),
level.ValueOrDefault(0));
}
FT_Library_SetLcdFilter(CFX_GEModule::Get()->GetFontMgr()->GetFTLibrary(),
FT_LCD_FILTER_DEFAULT);
- error = FXFT_Render_Glyph(m_Face, anti_alias);
+ error = FXFT_Render_Glyph(GetFaceRec(), anti_alias);
if (error)
return nullptr;
- int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(m_Face));
- int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(m_Face));
+ int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(GetFaceRec()));
+ int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(GetFaceRec()));
if (bmwidth > kMaxGlyphDimension || bmheight > kMaxGlyphDimension)
return nullptr;
int dib_width = bmwidth;
auto pGlyphBitmap = pdfium::MakeUnique<CFX_GlyphBitmap>(
- FXFT_Get_Glyph_BitmapLeft(m_Face), FXFT_Get_Glyph_BitmapTop(m_Face));
+ FXFT_Get_Glyph_BitmapLeft(GetFaceRec()),
+ FXFT_Get_Glyph_BitmapTop(GetFaceRec()));
pGlyphBitmap->GetBitmap()->Create(
dib_width, bmheight,
anti_alias == FT_RENDER_MODE_MONO ? FXDIB_1bppMask : FXDIB_8bppMask);
int dest_pitch = pGlyphBitmap->GetBitmap()->GetPitch();
- int src_pitch = FXFT_Get_Bitmap_Pitch(FXFT_Get_Glyph_Bitmap(m_Face));
+ int src_pitch = FXFT_Get_Bitmap_Pitch(FXFT_Get_Glyph_Bitmap(GetFaceRec()));
uint8_t* pDestBuf = pGlyphBitmap->GetBitmap()->GetBuffer();
uint8_t* pSrcBuf = static_cast<uint8_t*>(
- FXFT_Get_Bitmap_Buffer(FXFT_Get_Glyph_Bitmap(m_Face)));
+ FXFT_Get_Bitmap_Buffer(FXFT_Get_Glyph_Bitmap(GetFaceRec())));
if (anti_alias != FT_RENDER_MODE_MONO &&
- FXFT_Get_Bitmap_PixelMode(FXFT_Get_Glyph_Bitmap(m_Face)) ==
+ FXFT_Get_Bitmap_PixelMode(FXFT_Get_Glyph_Bitmap(GetFaceRec())) ==
FT_PIXEL_MODE_MONO) {
int bytes = anti_alias == FT_RENDER_MODE_LCD ? 3 : 1;
for (int i = 0; i < bmheight; i++) {
@@ -224,7 +225,7 @@
const CFX_PathData* CFX_GlyphCache::LoadGlyphPath(const CFX_Font* pFont,
uint32_t glyph_index,
uint32_t dest_width) {
- if (!m_Face || glyph_index == kInvalidGlyphIndex)
+ if (!GetFaceRec() || glyph_index == kInvalidGlyphIndex)
return nullptr;
const auto* pSubstFont = pFont->GetSubstFont();
diff --git a/core/fxge/cfx_glyphcache.h b/core/fxge/cfx_glyphcache.h
index ede2fd0..2d1acef 100644
--- a/core/fxge/cfx_glyphcache.h
+++ b/core/fxge/cfx_glyphcache.h
@@ -44,6 +44,8 @@
uint32_t glyph_index,
uint32_t dest_width);
+ FXFT_FaceRec* GetFaceRec() { return m_Face; }
+
#if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_
CFX_TypeFace* GetDeviceCache(const CFX_Font* pFont);
#endif