From f8a5ef3056619c1a8e7d1108ac3720c97ca8e67d Mon Sep 17 00:00:00 2001 From: caryclark Date: Mon, 4 Apr 2016 12:27:16 -0700 Subject: Support the device font cache Reuse the Skia typeface on sucessive text draw calls. This reduces the SKP size by 100x for some documents. Note that this does not use a smart pointer for the Skia typeface object. The downside of doing so is that it requires all clients that include fx_font.h to also have access to Skia. In this specific case, it is preferable to have a forward declared class to isolate Skia from the rest of PDFium. R=dsinclair,tsepez@chromium.org Review URL: https://codereview.chromium.org/1837113004 --- core/include/fxge/fx_font.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'core/include/fxge/fx_font.h') diff --git a/core/include/fxge/fx_font.h b/core/include/fxge/fx_font.h index c52e614e97..4e2b97e677 100644 --- a/core/include/fxge/fx_font.h +++ b/core/include/fxge/fx_font.h @@ -27,6 +27,12 @@ class CFX_SubstFont; class CTTFontDesc; class IFX_SystemFontInfo; +#ifdef _SKIA_SUPPORT_ +class SkTypeface; + +using CFX_TypeFace = SkTypeface; +#endif + #define FXFONT_FIXED_PITCH 0x01 #define FXFONT_SERIF 0x02 #define FXFONT_SYMBOLIC 0x04 @@ -452,6 +458,9 @@ class CFX_FontCache { CFX_FaceCache* GetCachedFace(CFX_Font* pFont); void ReleaseCachedFace(CFX_Font* pFont); void FreeCache(FX_BOOL bRelease = FALSE); +#ifdef _SKIA_SUPPORT_ + CFX_TypeFace* GetDeviceCache(CFX_Font* pFont); +#endif private: using CFX_FTCacheMap = std::map; @@ -490,6 +499,10 @@ class CFX_FaceCache { uint32_t glyph_index, int dest_width); +#ifdef _SKIA_SUPPORT_ + CFX_TypeFace* GetDeviceCache(CFX_Font* pFont); +#endif + private: CFX_GlyphBitmap* RenderGlyph(CFX_Font* pFont, uint32_t glyph_index, @@ -516,6 +529,9 @@ class CFX_FaceCache { std::map m_SizeMap; std::map m_PathMap; CFX_DIBitmap* m_pBitmap; +#ifdef _SKIA_SUPPORT_ + CFX_TypeFace* m_pTypeface; +#endif }; struct FXTEXT_GLYPHPOS { -- cgit v1.2.3