Rename CFX_FaceCache to CFX_GlyphCache.

Because it caches bitmaps and paths, not face objects per-se, and
there is another object, CTTFontDesc, which I want to subsequently
rename to CFX_FaceCache.

Change-Id: Idccea04da7b84182e6a1be200ce47dfd688eef2c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/54550
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/BUILD.gn b/core/fxge/BUILD.gn
index 83374cc..ad155fe 100644
--- a/core/fxge/BUILD.gn
+++ b/core/fxge/BUILD.gn
@@ -24,8 +24,6 @@
     "cfx_color.cpp",
     "cfx_color.h",
     "cfx_defaultrenderdevice.h",
-    "cfx_facecache.cpp",
-    "cfx_facecache.h",
     "cfx_folderfontinfo.cpp",
     "cfx_folderfontinfo.h",
     "cfx_font.cpp",
@@ -39,6 +37,8 @@
     "cfx_gemodule.h",
     "cfx_glyphbitmap.cpp",
     "cfx_glyphbitmap.h",
+    "cfx_glyphcache.cpp",
+    "cfx_glyphcache.h",
     "cfx_graphstate.cpp",
     "cfx_graphstate.h",
     "cfx_graphstatedata.cpp",
diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp
index d290ac4..ad2bdaf 100644
--- a/core/fxge/apple/fx_apple_platform.cpp
+++ b/core/fxge/apple/fx_apple_platform.cpp
@@ -11,10 +11,10 @@
 
 #include "core/fxge/apple/apple_int.h"
 #include "core/fxge/cfx_cliprgn.h"
-#include "core/fxge/cfx_facecache.h"
 #include "core/fxge/cfx_font.h"
 #include "core/fxge/cfx_gemodule.h"
 #include "core/fxge/cfx_glyphbitmap.h"
+#include "core/fxge/cfx_glyphcache.h"
 #include "core/fxge/cfx_renderdevice.h"
 #include "core/fxge/cfx_substfont.h"
 #include "core/fxge/dib/cfx_dibitmap.h"
@@ -165,11 +165,11 @@
 
 #endif  // _SKIA_SUPPORT_
 
-void CFX_FaceCache::InitPlatform() {}
+void CFX_GlyphCache::InitPlatform() {}
 
-void CFX_FaceCache::DestroyPlatform() {}
+void CFX_GlyphCache::DestroyPlatform() {}
 
-std::unique_ptr<CFX_GlyphBitmap> CFX_FaceCache::RenderGlyph_Nativetext(
+std::unique_ptr<CFX_GlyphBitmap> CFX_GlyphCache::RenderGlyph_Nativetext(
     const CFX_Font* pFont,
     uint32_t glyph_index,
     const CFX_Matrix& matrix,
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp
index 992d22b..3b427c2 100644
--- a/core/fxge/cfx_font.cpp
+++ b/core/fxge/cfx_font.cpp
@@ -15,10 +15,10 @@
 #include "build/build_config.h"
 #include "core/fxcrt/fx_codepage.h"
 #include "core/fxcrt/fx_stream.h"
-#include "core/fxge/cfx_facecache.h"
 #include "core/fxge/cfx_fontcache.h"
 #include "core/fxge/cfx_fontmgr.h"
 #include "core/fxge/cfx_gemodule.h"
+#include "core/fxge/cfx_glyphcache.h"
 #include "core/fxge/cfx_pathdata.h"
 #include "core/fxge/cfx_substfont.h"
 #include "core/fxge/fx_font.h"
@@ -322,7 +322,7 @@
 
 #if !defined(OS_WIN)
 void CFX_Font::SetFace(FXFT_Face face) {
-  ClearFaceCache();
+  ClearGlyphCache();
   m_Face = face;
 }
 
@@ -343,7 +343,7 @@
 }
 
 void CFX_Font::DeleteFace() {
-  ClearFaceCache();
+  ClearGlyphCache();
   if (m_bEmbedded)
     FXFT_Done_Face(m_Face.Release());
   else
@@ -581,14 +581,14 @@
   return true;
 }
 
-RetainPtr<CFX_FaceCache> CFX_Font::GetOrCreateFaceCache() const {
-  if (!m_FaceCache)
-    m_FaceCache = CFX_GEModule::Get()->GetFontCache()->GetFaceCache(this);
-  return m_FaceCache;
+RetainPtr<CFX_GlyphCache> CFX_Font::GetOrCreateGlyphCache() const {
+  if (!m_GlyphCache)
+    m_GlyphCache = CFX_GEModule::Get()->GetFontCache()->GetGlyphCache(this);
+  return m_GlyphCache;
 }
 
-void CFX_Font::ClearFaceCache() {
-  m_FaceCache = nullptr;
+void CFX_Font::ClearGlyphCache() {
+  m_GlyphCache = nullptr;
 }
 
 void CFX_Font::AdjustMMParams(int glyph_index,
@@ -709,18 +709,18 @@
                                                  uint32_t dest_width,
                                                  int anti_alias,
                                                  int* pTextFlags) const {
-  return GetOrCreateFaceCache()->LoadGlyphBitmap(this, glyph_index, bFontStyle,
-                                                 matrix, dest_width, anti_alias,
-                                                 pTextFlags);
+  return GetOrCreateGlyphCache()->LoadGlyphBitmap(this, glyph_index, bFontStyle,
+                                                  matrix, dest_width,
+                                                  anti_alias, pTextFlags);
 }
 
 const CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index,
                                             uint32_t dest_width) const {
-  return GetOrCreateFaceCache()->LoadGlyphPath(this, glyph_index, dest_width);
+  return GetOrCreateGlyphCache()->LoadGlyphPath(this, glyph_index, dest_width);
 }
 
 #if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_
 CFX_TypeFace* CFX_Font::GetDeviceCache() const {
-  return GetOrCreateFaceCache()->GetDeviceCache(this);
+  return GetOrCreateGlyphCache()->GetDeviceCache(this);
 }
 #endif
diff --git a/core/fxge/cfx_font.h b/core/fxge/cfx_font.h
index ab3fe6d..69f53a4 100644
--- a/core/fxge/cfx_font.h
+++ b/core/fxge/cfx_font.h
@@ -21,7 +21,7 @@
 #include "core/fxge/fx_font.h"
 #endif
 
-class CFX_FaceCache;
+class CFX_GlyphCache;
 class CFX_GlyphBitmap;
 class CFX_PathData;
 class CFX_SubstFont;
@@ -126,9 +126,9 @@
 #endif  // PDF_ENABLE_XFA
 
  private:
-  RetainPtr<CFX_FaceCache> GetOrCreateFaceCache() const;
+  RetainPtr<CFX_GlyphCache> GetOrCreateGlyphCache() const;
   void DeleteFace();
-  void ClearFaceCache();
+  void ClearGlyphCache();
 #if defined(OS_MACOSX)
   void ReleasePlatformResource();
 #endif
@@ -136,7 +136,7 @@
   ByteString GetFamilyNameOrUntitled() const;
 
   mutable UnownedPtr<FXFT_FaceRec> m_Face;
-  mutable RetainPtr<CFX_FaceCache> m_FaceCache;
+  mutable RetainPtr<CFX_GlyphCache> m_GlyphCache;
   std::unique_ptr<CFX_SubstFont> m_pSubstFont;
   std::unique_ptr<uint8_t, FxFreeDeleter> m_pGsubData;
   std::vector<uint8_t> m_pFontDataAllocation;
diff --git a/core/fxge/cfx_fontcache.cpp b/core/fxge/cfx_fontcache.cpp
index bb3e1a6..a99cabb 100644
--- a/core/fxge/cfx_fontcache.cpp
+++ b/core/fxge/cfx_fontcache.cpp
@@ -9,8 +9,8 @@
 #include <memory>
 #include <utility>
 
-#include "core/fxge/cfx_facecache.h"
 #include "core/fxge/cfx_font.h"
+#include "core/fxge/cfx_glyphcache.h"
 #include "core/fxge/fx_font.h"
 #include "core/fxge/fx_freetype.h"
 #include "third_party/base/ptr_util.h"
@@ -19,21 +19,21 @@
 
 CFX_FontCache::~CFX_FontCache() = default;
 
-RetainPtr<CFX_FaceCache> CFX_FontCache::GetFaceCache(const CFX_Font* pFont) {
+RetainPtr<CFX_GlyphCache> CFX_FontCache::GetGlyphCache(const CFX_Font* pFont) {
   FXFT_Face face = pFont->GetFace();
   const bool bExternal = !face;
-  auto& map = bExternal ? m_ExtFaceMap : m_FTFaceMap;
+  auto& map = bExternal ? m_ExtGlyphCacheMap : m_GlyphCacheMap;
   auto it = map.find(face);
   if (it != map.end() && it->second)
     return pdfium::WrapRetain(it->second.Get());
 
-  auto new_cache = pdfium::MakeRetain<CFX_FaceCache>(face);
+  auto new_cache = pdfium::MakeRetain<CFX_GlyphCache>(face);
   map[face].Reset(new_cache.Get());
   return new_cache;
 }
 
 #ifdef _SKIA_SUPPORT_
 CFX_TypeFace* CFX_FontCache::GetDeviceCache(const CFX_Font* pFont) {
-  return GetFaceCache(pFont)->GetDeviceCache(pFont);
+  return GetGlyphCache(pFont)->GetDeviceCache(pFont);
 }
 #endif
diff --git a/core/fxge/cfx_fontcache.h b/core/fxge/cfx_fontcache.h
index 7eb0821..635da03 100644
--- a/core/fxge/cfx_fontcache.h
+++ b/core/fxge/cfx_fontcache.h
@@ -11,7 +11,7 @@
 #include <memory>
 
 #include "core/fxcrt/fx_system.h"
-#include "core/fxge/cfx_facecache.h"
+#include "core/fxge/cfx_glyphcache.h"
 #include "core/fxge/fx_freetype.h"
 
 class CFX_Font;
@@ -21,14 +21,14 @@
   CFX_FontCache();
   ~CFX_FontCache();
 
-  RetainPtr<CFX_FaceCache> GetFaceCache(const CFX_Font* pFont);
+  RetainPtr<CFX_GlyphCache> GetGlyphCache(const CFX_Font* pFont);
 #ifdef _SKIA_SUPPORT_
   CFX_TypeFace* GetDeviceCache(const CFX_Font* pFont);
 #endif
 
  private:
-  std::map<FXFT_Face, CFX_FaceCache::ObservedPtr> m_FTFaceMap;
-  std::map<FXFT_Face, CFX_FaceCache::ObservedPtr> m_ExtFaceMap;
+  std::map<FXFT_Face, CFX_GlyphCache::ObservedPtr> m_GlyphCacheMap;
+  std::map<FXFT_Face, CFX_GlyphCache::ObservedPtr> m_ExtGlyphCacheMap;
 };
 
 #endif  // CORE_FXGE_CFX_FONTCACHE_H_
diff --git a/core/fxge/cfx_facecache.cpp b/core/fxge/cfx_glyphcache.cpp
similarity index 91%
rename from core/fxge/cfx_facecache.cpp
rename to core/fxge/cfx_glyphcache.cpp
index eff198c..0156e85 100644
--- a/core/fxge/cfx_facecache.cpp
+++ b/core/fxge/cfx_glyphcache.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "core/fxge/cfx_facecache.h"
+#include "core/fxge/cfx_glyphcache.h"
 
 #include <algorithm>
 #include <limits>
@@ -95,11 +95,11 @@
 
 }  // namespace
 
-CFX_FaceCache::CFX_FaceCache(FXFT_Face face) : m_Face(face) {}
+CFX_GlyphCache::CFX_GlyphCache(FXFT_Face face) : m_Face(face) {}
 
-CFX_FaceCache::~CFX_FaceCache() = default;
+CFX_GlyphCache::~CFX_GlyphCache() = default;
 
-std::unique_ptr<CFX_GlyphBitmap> CFX_FaceCache::RenderGlyph(
+std::unique_ptr<CFX_GlyphBitmap> CFX_GlyphCache::RenderGlyph(
     const CFX_Font* pFont,
     uint32_t glyph_index,
     bool bFontStyle,
@@ -221,9 +221,9 @@
   return pGlyphBitmap;
 }
 
-const CFX_PathData* CFX_FaceCache::LoadGlyphPath(const CFX_Font* pFont,
-                                                 uint32_t glyph_index,
-                                                 uint32_t dest_width) {
+const CFX_PathData* CFX_GlyphCache::LoadGlyphPath(const CFX_Font* pFont,
+                                                  uint32_t glyph_index,
+                                                  uint32_t dest_width) {
   if (!m_Face || glyph_index == kInvalidGlyphIndex)
     return nullptr;
 
@@ -242,13 +242,13 @@
   return pGlyphPath;
 }
 
-const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(const CFX_Font* pFont,
-                                                      uint32_t glyph_index,
-                                                      bool bFontStyle,
-                                                      const CFX_Matrix& matrix,
-                                                      uint32_t dest_width,
-                                                      int anti_alias,
-                                                      int* pTextFlags) {
+const CFX_GlyphBitmap* CFX_GlyphCache::LoadGlyphBitmap(const CFX_Font* pFont,
+                                                       uint32_t glyph_index,
+                                                       bool bFontStyle,
+                                                       const CFX_Matrix& matrix,
+                                                       uint32_t dest_width,
+                                                       int anti_alias,
+                                                       int* pTextFlags) {
   if (glyph_index == kInvalidGlyphIndex)
     return nullptr;
 
@@ -311,7 +311,7 @@
 }
 
 #if defined _SKIA_SUPPORT_ || defined _SKIA_SUPPORT_PATHS_
-CFX_TypeFace* CFX_FaceCache::GetDeviceCache(const CFX_Font* pFont) {
+CFX_TypeFace* CFX_GlyphCache::GetDeviceCache(const CFX_Font* pFont) {
   if (!m_pTypeface) {
     pdfium::span<const uint8_t> span = pFont->GetFontSpan();
     m_pTypeface = SkTypeface::MakeFromStream(
@@ -330,10 +330,10 @@
 #endif  // defined _SKIA_SUPPORT_ || defined _SKIA_SUPPORT_PATHS_
 
 #if !defined(OS_MACOSX)
-void CFX_FaceCache::InitPlatform() {}
+void CFX_GlyphCache::InitPlatform() {}
 #endif
 
-CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(
+CFX_GlyphBitmap* CFX_GlyphCache::LookUpGlyphBitmap(
     const CFX_Font* pFont,
     const CFX_Matrix& matrix,
     const ByteString& FaceGlyphsKey,
diff --git a/core/fxge/cfx_facecache.h b/core/fxge/cfx_glyphcache.h
similarity index 91%
rename from core/fxge/cfx_facecache.h
rename to core/fxge/cfx_glyphcache.h
index a99ddb3..0fb7899 100644
--- a/core/fxge/cfx_facecache.h
+++ b/core/fxge/cfx_glyphcache.h
@@ -4,8 +4,8 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef CORE_FXGE_CFX_FACECACHE_H_
-#define CORE_FXGE_CFX_FACECACHE_H_
+#ifndef CORE_FXGE_CFX_GLYPHCACHE_H_
+#define CORE_FXGE_CFX_GLYPHCACHE_H_
 
 #include <map>
 #include <memory>
@@ -26,12 +26,12 @@
 class CFX_Matrix;
 class CFX_PathData;
 
-class CFX_FaceCache : public Retainable, public Observable<CFX_FaceCache> {
+class CFX_GlyphCache : public Retainable, public Observable<CFX_GlyphCache> {
  public:
   template <typename T, typename... Args>
   friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
 
-  ~CFX_FaceCache() override;
+  ~CFX_GlyphCache() override;
 
   const CFX_GlyphBitmap* LoadGlyphBitmap(const CFX_Font* pFont,
                                          uint32_t glyph_index,
@@ -49,7 +49,7 @@
 #endif
 
  private:
-  explicit CFX_FaceCache(FXFT_Face face);
+  explicit CFX_GlyphCache(FXFT_Face face);
 
   using SizeGlyphCache = std::map<uint32_t, std::unique_ptr<CFX_GlyphBitmap>>;
   // <glyph_index, width, weight, angle, vertical>
@@ -85,4 +85,4 @@
 #endif
 };
 
-#endif  //  CORE_FXGE_CFX_FACECACHE_H_
+#endif  //  CORE_FXGE_CFX_GLYPHCACHE_H_
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index 82cb604..4cc9028 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -13,11 +13,11 @@
 #include "build/build_config.h"
 #include "core/fxcrt/fx_safe_types.h"
 #include "core/fxge/cfx_defaultrenderdevice.h"
-#include "core/fxge/cfx_facecache.h"
 #include "core/fxge/cfx_font.h"
 #include "core/fxge/cfx_fontmgr.h"
 #include "core/fxge/cfx_gemodule.h"
 #include "core/fxge/cfx_glyphbitmap.h"
+#include "core/fxge/cfx_glyphcache.h"
 #include "core/fxge/cfx_graphstatedata.h"
 #include "core/fxge/cfx_pathdata.h"
 #include "core/fxge/dib/cfx_dibitmap.h"
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index 77dd564..cb83a82 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -17,9 +17,9 @@
 #include "core/fxcodec/codec/ccodec_jpegmodule.h"
 #include "core/fxcodec/fx_codec.h"
 #include "core/fxcrt/maybe_owned.h"
-#include "core/fxge/cfx_facecache.h"
 #include "core/fxge/cfx_fontcache.h"
 #include "core/fxge/cfx_gemodule.h"
+#include "core/fxge/cfx_glyphcache.h"
 #include "core/fxge/cfx_pathdata.h"
 #include "core/fxge/cfx_renderdevice.h"
 #include "core/fxge/dib/cfx_dibextractor.h"
@@ -526,7 +526,7 @@
   }
 }
 
-void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache,
+void CFX_PSRenderer::FindPSFontGlyph(CFX_GlyphCache* pGlyphCache,
                                      CFX_Font* pFont,
                                      const TextCharPos& charpos,
                                      int* ps_fontnum,
@@ -594,7 +594,7 @@
         CFX_Matrix(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1],
                    charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0);
   }
-  const CFX_PathData* pPathData = pFaceCache->LoadGlyphPath(
+  const CFX_PathData* pPathData = pGlyphCache->LoadGlyphPath(
       pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth);
   if (!pPathData)
     return;
@@ -664,11 +664,11 @@
       << pObject2Device->e << " " << pObject2Device->f << "]cm\n";
 
   CFX_FontCache* pCache = CFX_GEModule::Get()->GetFontCache();
-  RetainPtr<CFX_FaceCache> pFaceCache = pCache->GetFaceCache(pFont);
+  RetainPtr<CFX_GlyphCache> pGlyphCache = pCache->GetGlyphCache(pFont);
   int last_fontnum = -1;
   for (int i = 0; i < nChars; i++) {
     int ps_fontnum, ps_glyphindex;
-    FindPSFontGlyph(pFaceCache.Get(), pFont, pCharPos[i], &ps_fontnum,
+    FindPSFontGlyph(pGlyphCache.Get(), pFont, pCharPos[i], &ps_fontnum,
                     &ps_glyphindex);
     if (last_fontnum != ps_fontnum) {
       buf << "/X" << ps_fontnum << " Ff " << font_size << " Fs Sf ";
diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h
index ee95a4a..91888df 100644
--- a/core/fxge/win32/cfx_psrenderer.h
+++ b/core/fxge/win32/cfx_psrenderer.h
@@ -19,7 +19,7 @@
 
 class CCodec_ModuleMgr;
 class CFX_DIBBase;
-class CFX_FaceCache;
+class CFX_GlyphCache;
 class CFX_Font;
 class CFX_FontCache;
 class CFX_Matrix;
@@ -82,7 +82,7 @@
                   const CFX_Matrix* pObject2Device);
   void SetGraphState(const CFX_GraphStateData* pGraphState);
   void SetColor(uint32_t color);
-  void FindPSFontGlyph(CFX_FaceCache* pFaceCache,
+  void FindPSFontGlyph(CFX_GlyphCache* pGlyphCache,
                        CFX_Font* pFont,
                        const TextCharPos& charpos,
                        int* ps_fontnum,