 Chromium Code Reviews
 Chromium Code Reviews Issue 2158023002:
  Pdfium: Fix fonts leaking on ClosePage.  (Closed) 
  Base URL: https://pdfium.googlesource.com/pdfium@master
    
  
    Issue 2158023002:
  Pdfium: Fix fonts leaking on ClosePage.  (Closed) 
  Base URL: https://pdfium.googlesource.com/pdfium@master| Index: core/fxge/include/fx_font.h | 
| diff --git a/core/fxge/include/fx_font.h b/core/fxge/include/fx_font.h | 
| index 9a976c44b77bd10ebde7156fdee4f77a107e3cc1..a0134ed043abc5803ee72ae4ca26ce52ca23de36 100644 | 
| --- a/core/fxge/include/fx_font.h | 
| +++ b/core/fxge/include/fx_font.h | 
| @@ -19,7 +19,8 @@ typedef struct FT_FaceRec_* FXFT_Face; | 
| typedef void* FXFT_Library; | 
| class CFX_FaceCache; | 
| -class CFX_FontCache; | 
| +class CFX_FontCacheItem; | 
| +class CFX_GlyphBitmap; | 
| class CFX_PathData; | 
| class CFX_SizeGlyphCache; | 
| @@ -112,7 +113,6 @@ class CFX_Font { | 
| } | 
| #endif // PDF_ENABLE_XFA | 
| - CFX_PathData* LoadGlyphPath(uint32_t glyph_index, int dest_width = 0); | 
| int GetGlyphWidth(uint32_t glyph_index); | 
| int GetAscent() const; | 
| int GetDescent() const; | 
| @@ -141,6 +141,9 @@ class CFX_Font { | 
| uint32_t GetSize() const { return m_dwSize; } | 
| void AdjustMMParams(int glyph_index, int width, int weight); | 
| + const CFX_FontCacheItem* GetFontCache() const { return m_FontCache.get(); } | 
| 
dsinclair
2016/09/14 17:51:51
This isn't really a cache as it's always just one
 
snake
2016/09/14 19:06:29
I did remove m_FontCache member, now CFX_Font tran
 | 
| + CFX_FaceCache* GetFaceCache() const; | 
| + | 
| static const size_t kAngleSkewArraySize = 30; | 
| static const char s_AngleSkew[kAngleSkewArraySize]; | 
| static const size_t kWeightPowArraySize = 100; | 
| @@ -156,10 +159,18 @@ class CFX_Font { | 
| #endif // PDF_ENABLE_XFA | 
| private: | 
| + friend class CFX_FaceCache; | 
| + CFX_PathData* LoadGlyphPath(uint32_t glyph_index, int dest_width = 0); | 
| 
dsinclair
2016/09/14 17:51:51
Why not leave this public then we don't need the f
 
snake
2016/09/14 19:06:29
This method is not using cache, for cleanly any ca
 | 
| + | 
| + private: | 
| void ReleasePlatformResource(); | 
| void DeleteFace(); | 
| + void ClearFaceCache(); | 
| + | 
| FXFT_Face m_Face; | 
| + mutable CFX_FaceCache* m_FaceCache; | 
| 
dsinclair
2016/09/14 17:51:51
Why mutable?
What is the ownership of this? If it
 
snake
2016/09/14 19:06:29
It is initialized on demand in GetFaceCache() cons
 | 
| + std::unique_ptr<CFX_FontCacheItem> m_FontCache; | 
| std::unique_ptr<CFX_SubstFont> m_pSubstFont; | 
| std::vector<uint8_t> m_pFontDataAllocation; | 
| uint8_t* m_pFontData; | 
| @@ -172,6 +183,27 @@ class CFX_Font { | 
| FX_BOOL m_bVertical; | 
| }; | 
| +class CFX_FontCacheItem { | 
| + public: | 
| + explicit CFX_FontCacheItem(CFX_Font* font); | 
| + ~CFX_FontCacheItem(); | 
| + | 
| + const CFX_GlyphBitmap* LoadGlyphBitmap(uint32_t glyph_index, | 
| + FX_BOOL bFontStyle, | 
| + const CFX_Matrix* pMatrix, | 
| + int dest_width, | 
| + int anti_alias, | 
| + int& text_flags) const; | 
| + const CFX_PathData* LoadGlyphPath(uint32_t glyph_index, int dest_width) const; | 
| + | 
| +#ifdef _SKIA_SUPPORT_ | 
| + CFX_TypeFace* GetDeviceCache() const; | 
| +#endif | 
| + | 
| + private: | 
| + CFX_Font* m_Font; | 
| +}; | 
| + | 
| class CFX_FontFaceInfo { | 
| public: | 
| CFX_FontFaceInfo(CFX_ByteString filePath, | 
| @@ -189,12 +221,6 @@ class CFX_FontFaceInfo { | 
| uint32_t m_Charsets; | 
| }; | 
| -class CFX_CountedFaceCache { | 
| - public: | 
| - CFX_FaceCache* m_Obj; | 
| - uint32_t m_nCount; | 
| -}; | 
| - | 
| class CFX_GlyphBitmap { | 
| public: | 
| int m_Top; |