Make CPDF_Type3GlyphMap::m_GlyphMap a private member

Change-Id: Ied0e5bc555c5eb124f9b4cf8096029e8e2297618
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/57771
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 55b959d..ec3af9e 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1898,7 +1898,7 @@
       if (device_type == DeviceType::kDisplay) {
         RetainPtr<CPDF_Type3Cache> pCache = GetCachedType3(pType3Font);
         refTypeCache.m_dwCount++;
-        CFX_GlyphBitmap* pBitmap = pCache->LoadGlyph(charcode, &matrix);
+        const CFX_GlyphBitmap* pBitmap = pCache->LoadGlyph(charcode, &matrix);
         if (!pBitmap)
           continue;
 
diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp
index 0a6ca83..d2d6cd6 100644
--- a/core/fpdfapi/render/cpdf_type3cache.cpp
+++ b/core/fpdfapi/render/cpdf_type3cache.cpp
@@ -87,8 +87,8 @@
 
 CPDF_Type3Cache::~CPDF_Type3Cache() {}
 
-CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode,
-                                            const CFX_Matrix* pMatrix) {
+const CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode,
+                                                  const CFX_Matrix* pMatrix) {
   CPDF_UniqueKeyGen keygen;
   keygen.Generate(
       4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000),
@@ -103,14 +103,14 @@
   } else {
     pSizeCache = it->second.get();
   }
-  auto it2 = pSizeCache->m_GlyphMap.find(charcode);
-  if (it2 != pSizeCache->m_GlyphMap.end())
-    return it2->second.get();
+  const CFX_GlyphBitmap* pExisting = pSizeCache->GetBitmap(charcode);
+  if (pExisting)
+    return pExisting;
 
   std::unique_ptr<CFX_GlyphBitmap> pNewBitmap =
       RenderGlyph(pSizeCache, charcode, pMatrix);
   CFX_GlyphBitmap* pGlyphBitmap = pNewBitmap.get();
-  pSizeCache->m_GlyphMap[charcode] = std::move(pNewBitmap);
+  pSizeCache->SetBitmap(charcode, std::move(pNewBitmap));
   return pGlyphBitmap;
 }
 
diff --git a/core/fpdfapi/render/cpdf_type3cache.h b/core/fpdfapi/render/cpdf_type3cache.h
index d491784..2f5c9ca 100644
--- a/core/fpdfapi/render/cpdf_type3cache.h
+++ b/core/fpdfapi/render/cpdf_type3cache.h
@@ -24,7 +24,8 @@
   template <typename T, typename... Args>
   friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
 
-  CFX_GlyphBitmap* LoadGlyph(uint32_t charcode, const CFX_Matrix* pMatrix);
+  const CFX_GlyphBitmap* LoadGlyph(uint32_t charcode,
+                                   const CFX_Matrix* pMatrix);
 
  private:
   explicit CPDF_Type3Cache(CPDF_Type3Font* pFont);
diff --git a/core/fpdfapi/render/cpdf_type3glyphmap.cpp b/core/fpdfapi/render/cpdf_type3glyphmap.cpp
index 8f0e330..025a41f 100644
--- a/core/fpdfapi/render/cpdf_type3glyphmap.cpp
+++ b/core/fpdfapi/render/cpdf_type3glyphmap.cpp
@@ -8,6 +8,7 @@
 
 #include <algorithm>
 #include <map>
+#include <utility>
 
 #include "core/fxge/cfx_glyphbitmap.h"
 #include "core/fxge/fx_font.h"
@@ -44,3 +45,13 @@
   return std::make_pair(AdjustBlueHelper(top, &m_TopBlue),
                         AdjustBlueHelper(bottom, &m_BottomBlue));
 }
+
+const CFX_GlyphBitmap* CPDF_Type3GlyphMap::GetBitmap(uint32_t charcode) const {
+  auto it = m_GlyphMap.find(charcode);
+  return it != m_GlyphMap.end() ? it->second.get() : nullptr;
+}
+
+void CPDF_Type3GlyphMap::SetBitmap(uint32_t charcode,
+                                   std::unique_ptr<CFX_GlyphBitmap> pMap) {
+  m_GlyphMap[charcode] = std::move(pMap);
+}
diff --git a/core/fpdfapi/render/cpdf_type3glyphmap.h b/core/fpdfapi/render/cpdf_type3glyphmap.h
index e712f9a..fced0ee 100644
--- a/core/fpdfapi/render/cpdf_type3glyphmap.h
+++ b/core/fpdfapi/render/cpdf_type3glyphmap.h
@@ -24,11 +24,13 @@
   // Returns a pair of integers (top_line, bottom_line).
   std::pair<int, int> AdjustBlue(float top, float bottom);
 
-  std::map<uint32_t, std::unique_ptr<CFX_GlyphBitmap>> m_GlyphMap;
+  const CFX_GlyphBitmap* GetBitmap(uint32_t charcode) const;
+  void SetBitmap(uint32_t charcode, std::unique_ptr<CFX_GlyphBitmap> pMap);
 
  private:
   std::vector<int> m_TopBlue;
   std::vector<int> m_BottomBlue;
+  std::map<uint32_t, std::unique_ptr<CFX_GlyphBitmap>> m_GlyphMap;
 };
 
 #endif  // CORE_FPDFAPI_RENDER_CPDF_TYPE3GLYPHMAP_H_