Home | History | Annotate | Download | only in fxge
      1 // Copyright 2016 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #ifndef CORE_FXGE_CFX_FACECACHE_H_
      8 #define CORE_FXGE_CFX_FACECACHE_H_
      9 
     10 #include <map>
     11 #include <memory>
     12 
     13 #include "core/fxge/fx_font.h"
     14 #include "core/fxge/fx_freetype.h"
     15 
     16 class CFX_FaceCache {
     17  public:
     18   explicit CFX_FaceCache(FXFT_Face face);
     19   ~CFX_FaceCache();
     20   const CFX_GlyphBitmap* LoadGlyphBitmap(const CFX_Font* pFont,
     21                                          uint32_t glyph_index,
     22                                          bool bFontStyle,
     23                                          const CFX_Matrix* pMatrix,
     24                                          int dest_width,
     25                                          int anti_alias,
     26                                          int& text_flags);
     27   const CFX_PathData* LoadGlyphPath(const CFX_Font* pFont,
     28                                     uint32_t glyph_index,
     29                                     int dest_width);
     30 
     31 #if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_
     32   CFX_TypeFace* GetDeviceCache(const CFX_Font* pFont);
     33 #endif
     34 
     35  private:
     36   CFX_GlyphBitmap* RenderGlyph(const CFX_Font* pFont,
     37                                uint32_t glyph_index,
     38                                bool bFontStyle,
     39                                const CFX_Matrix* pMatrix,
     40                                int dest_width,
     41                                int anti_alias);
     42   CFX_GlyphBitmap* RenderGlyph_Nativetext(const CFX_Font* pFont,
     43                                           uint32_t glyph_index,
     44                                           const CFX_Matrix* pMatrix,
     45                                           int dest_width,
     46                                           int anti_alias);
     47   CFX_GlyphBitmap* LookUpGlyphBitmap(const CFX_Font* pFont,
     48                                      const CFX_Matrix* pMatrix,
     49                                      const CFX_ByteString& FaceGlyphsKey,
     50                                      uint32_t glyph_index,
     51                                      bool bFontStyle,
     52                                      int dest_width,
     53                                      int anti_alias);
     54   void InitPlatform();
     55   void DestroyPlatform();
     56 
     57   FXFT_Face const m_Face;
     58   std::map<CFX_ByteString, std::unique_ptr<CFX_SizeGlyphCache>> m_SizeMap;
     59   std::map<uint32_t, std::unique_ptr<CFX_PathData>> m_PathMap;
     60 #if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_
     61   CFX_TypeFace* m_pTypeface;
     62 #endif
     63 };
     64 
     65 #endif  //  CORE_FXGE_CFX_FACECACHE_H_
     66