Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: core/fxge/include/fx_font.h

Issue 2350243002: Make CFX_FontCache global (Closed)
Patch Set: Remove fix leaks code. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxge/include/cfx_renderdevice.h ('k') | core/fxge/include/ifx_renderdevicedriver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_FXGE_INCLUDE_FX_FONT_H_ 7 #ifndef CORE_FXGE_INCLUDE_FX_FONT_H_
8 #define CORE_FXGE_INCLUDE_FX_FONT_H_ 8 #define CORE_FXGE_INCLUDE_FX_FONT_H_
9 9
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "core/fxcrt/include/fx_system.h" 13 #include "core/fxcrt/include/fx_system.h"
14 #include "core/fxge/include/cfx_substfont.h" 14 #include "core/fxge/include/cfx_substfont.h"
15 #include "core/fxge/include/fx_dib.h" 15 #include "core/fxge/include/fx_dib.h"
16 #include "core/fxge/include/fx_freetype.h" 16 #include "core/fxge/include/fx_freetype.h"
17 17
18 typedef struct FT_FaceRec_* FXFT_Face; 18 typedef struct FT_FaceRec_* FXFT_Face;
19 typedef void* FXFT_Library; 19 typedef void* FXFT_Library;
20 20
21 class CFX_FaceCache; 21 class CFX_FaceCache;
22 class CFX_FontCache; 22 class CFX_GlyphBitmap;
23 class CFX_PathData; 23 class CFX_PathData;
24 class CFX_SizeGlyphCache; 24 class CFX_SizeGlyphCache;
25 25
26 #ifdef _SKIA_SUPPORT_ 26 #ifdef _SKIA_SUPPORT_
27 class SkTypeface; 27 class SkTypeface;
28 28
29 using CFX_TypeFace = SkTypeface; 29 using CFX_TypeFace = SkTypeface;
30 #endif 30 #endif
31 31
32 /* Character sets for the font */ 32 /* Character sets for the font */
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 FX_BOOL LoadEmbedded(const uint8_t* data, uint32_t size); 108 FX_BOOL LoadEmbedded(const uint8_t* data, uint32_t size);
109 FXFT_Face GetFace() const { return m_Face; } 109 FXFT_Face GetFace() const { return m_Face; }
110 CFX_SubstFont* GetSubstFont() const { return m_pSubstFont.get(); } 110 CFX_SubstFont* GetSubstFont() const { return m_pSubstFont.get(); }
111 111
112 #ifdef PDF_ENABLE_XFA 112 #ifdef PDF_ENABLE_XFA
113 FX_BOOL LoadFile(IFX_FileRead* pFile, 113 FX_BOOL LoadFile(IFX_FileRead* pFile,
114 int nFaceIndex = 0, 114 int nFaceIndex = 0,
115 int* pFaceCount = nullptr); 115 int* pFaceCount = nullptr);
116 116
117 FX_BOOL LoadClone(const CFX_Font* pFont); 117 FX_BOOL LoadClone(const CFX_Font* pFont);
118 void SetFace(FXFT_Face face) { m_Face = face; } 118 void SetFace(FXFT_Face face);
119 void SetSubstFont(std::unique_ptr<CFX_SubstFont> subst) { 119 void SetSubstFont(std::unique_ptr<CFX_SubstFont> subst) {
120 m_pSubstFont = std::move(subst); 120 m_pSubstFont = std::move(subst);
121 } 121 }
122 #endif // PDF_ENABLE_XFA 122 #endif // PDF_ENABLE_XFA
123 123
124 CFX_PathData* LoadGlyphPath(uint32_t glyph_index, int dest_width = 0); 124 const CFX_GlyphBitmap* LoadGlyphBitmap(uint32_t glyph_index,
125 FX_BOOL bFontStyle,
126 const CFX_Matrix* pMatrix,
127 int dest_width,
128 int anti_alias,
129 int& text_flags) const;
130 const CFX_PathData* LoadGlyphPath(uint32_t glyph_index, int dest_width) const;
131
132 #ifdef _SKIA_SUPPORT_
133 CFX_TypeFace* GetDeviceCache() const;
134 #endif
135
125 int GetGlyphWidth(uint32_t glyph_index); 136 int GetGlyphWidth(uint32_t glyph_index);
126 int GetAscent() const; 137 int GetAscent() const;
127 int GetDescent() const; 138 int GetDescent() const;
128 FX_BOOL GetGlyphBBox(uint32_t glyph_index, FX_RECT& bbox); 139 FX_BOOL GetGlyphBBox(uint32_t glyph_index, FX_RECT& bbox);
129 bool IsItalic() const; 140 bool IsItalic() const;
130 bool IsBold() const; 141 bool IsBold() const;
131 bool IsFixedWidth() const; 142 bool IsFixedWidth() const;
132 FX_BOOL IsVertical() const { return m_bVertical; } 143 FX_BOOL IsVertical() const { return m_bVertical; }
133 CFX_ByteString GetPsName() const; 144 CFX_ByteString GetPsName() const;
134 CFX_ByteString GetFamilyName() const; 145 CFX_ByteString GetFamilyName() const;
135 CFX_ByteString GetFaceName() const; 146 CFX_ByteString GetFaceName() const;
136 FX_BOOL IsTTFont() const; 147 FX_BOOL IsTTFont() const;
137 FX_BOOL GetBBox(FX_RECT& bbox); 148 FX_BOOL GetBBox(FX_RECT& bbox);
138 int GetHeight() const; 149 int GetHeight() const;
139 int GetULPos() const; 150 int GetULPos() const;
140 int GetULthickness() const; 151 int GetULthickness() const;
141 int GetMaxAdvanceWidth() const; 152 int GetMaxAdvanceWidth() const;
142 FX_BOOL IsEmbedded() const { return m_bEmbedded; } 153 FX_BOOL IsEmbedded() const { return m_bEmbedded; }
143 uint8_t* GetSubData() const { return m_pGsubData; } 154 uint8_t* GetSubData() const { return m_pGsubData; }
144 void SetSubData(uint8_t* data) { m_pGsubData = data; } 155 void SetSubData(uint8_t* data) { m_pGsubData = data; }
145 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 156 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
146 void* GetPlatformFont() const { return m_pPlatformFont; } 157 void* GetPlatformFont() const { return m_pPlatformFont; }
147 void SetPlatformFont(void* font) { m_pPlatformFont = font; } 158 void SetPlatformFont(void* font) { m_pPlatformFont = font; }
148 #endif 159 #endif
149 uint8_t* GetFontData() const { return m_pFontData; } 160 uint8_t* GetFontData() const { return m_pFontData; }
150 uint32_t GetSize() const { return m_dwSize; } 161 uint32_t GetSize() const { return m_dwSize; }
151 void AdjustMMParams(int glyph_index, int width, int weight); 162 void AdjustMMParams(int glyph_index, int width, int weight) const;
152 163
153 static const size_t kAngleSkewArraySize = 30; 164 static const size_t kAngleSkewArraySize = 30;
154 static const char s_AngleSkew[kAngleSkewArraySize]; 165 static const char s_AngleSkew[kAngleSkewArraySize];
155 static const size_t kWeightPowArraySize = 100; 166 static const size_t kWeightPowArraySize = 100;
156 static const uint8_t s_WeightPow[kWeightPowArraySize]; 167 static const uint8_t s_WeightPow[kWeightPowArraySize];
157 static const uint8_t s_WeightPow_11[kWeightPowArraySize]; 168 static const uint8_t s_WeightPow_11[kWeightPowArraySize];
158 static const uint8_t s_WeightPow_SHIFTJIS[kWeightPowArraySize]; 169 static const uint8_t s_WeightPow_SHIFTJIS[kWeightPowArraySize];
159 170
160 #ifdef PDF_ENABLE_XFA 171 #ifdef PDF_ENABLE_XFA
161 protected: 172 protected:
162 CFX_BinaryBuf m_OtfFontData; 173 CFX_BinaryBuf m_OtfFontData;
163 bool m_bShallowCopy; 174 bool m_bShallowCopy;
164 FXFT_StreamRec* m_pOwnedStream; 175 FXFT_StreamRec* m_pOwnedStream;
165 #endif // PDF_ENABLE_XFA 176 #endif // PDF_ENABLE_XFA
166 177
167 private: 178 private:
179 friend class CFX_FaceCache;
180 CFX_PathData* LoadGlyphPathImpl(uint32_t glyph_index,
181 int dest_width = 0) const;
182
183 private:
184 CFX_FaceCache* GetFaceCache() const;
185
168 void ReleasePlatformResource(); 186 void ReleasePlatformResource();
169 void DeleteFace(); 187 void DeleteFace();
170 188
189 void ClearFaceCache();
190
171 FXFT_Face m_Face; 191 FXFT_Face m_Face;
192 mutable CFX_FaceCache* m_FaceCache; // not owned.
172 std::unique_ptr<CFX_SubstFont> m_pSubstFont; 193 std::unique_ptr<CFX_SubstFont> m_pSubstFont;
173 std::vector<uint8_t> m_pFontDataAllocation; 194 std::vector<uint8_t> m_pFontDataAllocation;
174 uint8_t* m_pFontData; 195 uint8_t* m_pFontData;
175 uint8_t* m_pGsubData; 196 uint8_t* m_pGsubData;
176 uint32_t m_dwSize; 197 uint32_t m_dwSize;
177 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 198 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
178 void* m_pPlatformFont; 199 void* m_pPlatformFont;
179 #endif 200 #endif
180 FX_BOOL m_bEmbedded; 201 FX_BOOL m_bEmbedded;
181 FX_BOOL m_bVertical; 202 FX_BOOL m_bVertical;
182 }; 203 };
183 204
184 class CFX_FontFaceInfo { 205 class CFX_FontFaceInfo {
185 public: 206 public:
186 CFX_FontFaceInfo(CFX_ByteString filePath, 207 CFX_FontFaceInfo(CFX_ByteString filePath,
187 CFX_ByteString faceName, 208 CFX_ByteString faceName,
188 CFX_ByteString fontTables, 209 CFX_ByteString fontTables,
189 uint32_t fontOffset, 210 uint32_t fontOffset,
190 uint32_t fileSize); 211 uint32_t fileSize);
191 212
192 const CFX_ByteString m_FilePath; 213 const CFX_ByteString m_FilePath;
193 const CFX_ByteString m_FaceName; 214 const CFX_ByteString m_FaceName;
194 const CFX_ByteString m_FontTables; 215 const CFX_ByteString m_FontTables;
195 const uint32_t m_FontOffset; 216 const uint32_t m_FontOffset;
196 const uint32_t m_FileSize; 217 const uint32_t m_FileSize;
197 uint32_t m_Styles; 218 uint32_t m_Styles;
198 uint32_t m_Charsets; 219 uint32_t m_Charsets;
199 }; 220 };
200 221
201 class CFX_CountedFaceCache {
202 public:
203 CFX_FaceCache* m_Obj;
204 uint32_t m_nCount;
205 };
206
207 class CFX_GlyphBitmap { 222 class CFX_GlyphBitmap {
208 public: 223 public:
209 int m_Top; 224 int m_Top;
210 int m_Left; 225 int m_Left;
211 CFX_DIBitmap m_Bitmap; 226 CFX_DIBitmap m_Bitmap;
212 }; 227 };
213 228
214 struct FXTEXT_GLYPHPOS { 229 struct FXTEXT_GLYPHPOS {
215 const CFX_GlyphBitmap* m_pGlyph; 230 const CFX_GlyphBitmap* m_pGlyph;
216 int m_OriginX; 231 int m_OriginX;
217 int m_OriginY; 232 int m_OriginY;
218 FX_FLOAT m_fOriginX; 233 FX_FLOAT m_fOriginX;
219 FX_FLOAT m_fOriginY; 234 FX_FLOAT m_fOriginY;
220 }; 235 };
221 236
222 FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs, 237 FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs,
223 int anti_alias, 238 int anti_alias,
224 FX_FLOAT retinaScaleX = 1.0f, 239 FX_FLOAT retinaScaleX = 1.0f,
225 FX_FLOAT retinaScaleY = 1.0f); 240 FX_FLOAT retinaScaleY = 1.0f);
226 241
227 CFX_ByteString GetNameFromTT(const uint8_t* name_table, 242 CFX_ByteString GetNameFromTT(const uint8_t* name_table,
228 uint32_t name_table_size, 243 uint32_t name_table_size,
229 uint32_t name); 244 uint32_t name);
230 245
231 int PDF_GetStandardFontName(CFX_ByteString* name); 246 int PDF_GetStandardFontName(CFX_ByteString* name);
232 247
233 #endif // CORE_FXGE_INCLUDE_FX_FONT_H_ 248 #endif // CORE_FXGE_INCLUDE_FX_FONT_H_
OLDNEW
« no previous file with comments | « core/fxge/include/cfx_renderdevice.h ('k') | core/fxge/include/ifx_renderdevicedriver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698