| OLD | NEW |
| 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 #include "../../../include/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
| 8 #include "../../../include/fxge/fx_freetype.h" | 8 #include "../../../include/fxge/fx_freetype.h" |
| 9 #include "../../../include/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
| 10 #include "text_int.h" | 10 #include "text_int.h" |
| (...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 delete cache; | 1197 delete cache; |
| 1198 m_ExtFaceMap.erase(curr_it); | 1198 m_ExtFaceMap.erase(curr_it); |
| 1199 } | 1199 } |
| 1200 } | 1200 } |
| 1201 } | 1201 } |
| 1202 | 1202 |
| 1203 CFX_FaceCache::CFX_FaceCache(FXFT_Face face) { | 1203 CFX_FaceCache::CFX_FaceCache(FXFT_Face face) { |
| 1204 m_Face = face; | 1204 m_Face = face; |
| 1205 } | 1205 } |
| 1206 CFX_FaceCache::~CFX_FaceCache() { | 1206 CFX_FaceCache::~CFX_FaceCache() { |
| 1207 FX_POSITION pos = m_SizeMap.GetStartPosition(); | 1207 for (const auto& pair : m_SizeMap) { |
| 1208 CFX_ByteString Key; | 1208 delete pair.second; |
| 1209 CFX_SizeGlyphCache* pSizeCache = NULL; | |
| 1210 while (pos) { | |
| 1211 m_SizeMap.GetNextAssoc(pos, Key, (void*&)pSizeCache); | |
| 1212 delete pSizeCache; | |
| 1213 } | 1209 } |
| 1214 m_SizeMap.RemoveAll(); | 1210 m_SizeMap.clear(); |
| 1215 pos = m_PathMap.GetStartPosition(); | 1211 FX_POSITION pos = m_PathMap.GetStartPosition(); |
| 1216 void* key1; | 1212 void* key1; |
| 1217 CFX_PathData* pPath; | 1213 CFX_PathData* pPath; |
| 1218 while (pos) { | 1214 while (pos) { |
| 1219 m_PathMap.GetNextAssoc(pos, key1, (void*&)pPath); | 1215 m_PathMap.GetNextAssoc(pos, key1, (void*&)pPath); |
| 1220 delete pPath; | 1216 delete pPath; |
| 1221 } | 1217 } |
| 1222 m_PathMap.RemoveAll(); | 1218 m_PathMap.RemoveAll(); |
| 1223 } | 1219 } |
| 1224 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 1220 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
| 1225 void CFX_FaceCache::InitPlatform() {} | 1221 void CFX_FaceCache::InitPlatform() {} |
| 1226 #endif | 1222 #endif |
| 1227 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap( | 1223 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap( |
| 1228 CFX_Font* pFont, | 1224 CFX_Font* pFont, |
| 1229 const CFX_AffineMatrix* pMatrix, | 1225 const CFX_AffineMatrix* pMatrix, |
| 1230 CFX_ByteStringC& FaceGlyphsKey, | 1226 CFX_ByteStringC& FaceGlyphsKey, |
| 1231 FX_DWORD glyph_index, | 1227 FX_DWORD glyph_index, |
| 1232 FX_BOOL bFontStyle, | 1228 FX_BOOL bFontStyle, |
| 1233 int dest_width, | 1229 int dest_width, |
| 1234 int anti_alias) { | 1230 int anti_alias) { |
| 1235 CFX_SizeGlyphCache* pSizeCache = NULL; | 1231 CFX_SizeGlyphCache* pSizeCache; |
| 1236 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { | 1232 auto it = m_SizeMap.find(FaceGlyphsKey); |
| 1233 if (it == m_SizeMap.end()) { |
| 1237 pSizeCache = new CFX_SizeGlyphCache; | 1234 pSizeCache = new CFX_SizeGlyphCache; |
| 1238 if (pSizeCache == NULL) { | 1235 m_SizeMap[FaceGlyphsKey] = pSizeCache; |
| 1239 return NULL; | 1236 } else { |
| 1240 } | 1237 pSizeCache = it->second; |
| 1241 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); | |
| 1242 } | 1238 } |
| 1243 CFX_GlyphBitmap* pGlyphBitmap = NULL; | 1239 CFX_GlyphBitmap* pGlyphBitmap = NULL; |
| 1244 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, | 1240 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, |
| 1245 (void*&)pGlyphBitmap)) { | 1241 (void*&)pGlyphBitmap)) { |
| 1246 return pGlyphBitmap; | 1242 return pGlyphBitmap; |
| 1247 } | 1243 } |
| 1248 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix, | 1244 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix, |
| 1249 dest_width, anti_alias); | 1245 dest_width, anti_alias); |
| 1250 if (pGlyphBitmap == NULL) { | 1246 if (pGlyphBitmap == NULL) { |
| 1251 return NULL; | 1247 return NULL; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); | 1299 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); |
| 1304 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 1300 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
| 1305 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, | 1301 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, |
| 1306 bFontStyle, dest_width, anti_alias); | 1302 bFontStyle, dest_width, anti_alias); |
| 1307 #else | 1303 #else |
| 1308 if (text_flags & FXTEXT_NO_NATIVETEXT) { | 1304 if (text_flags & FXTEXT_NO_NATIVETEXT) { |
| 1309 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, | 1305 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, |
| 1310 bFontStyle, dest_width, anti_alias); | 1306 bFontStyle, dest_width, anti_alias); |
| 1311 } | 1307 } |
| 1312 CFX_GlyphBitmap* pGlyphBitmap; | 1308 CFX_GlyphBitmap* pGlyphBitmap; |
| 1313 CFX_SizeGlyphCache* pSizeCache = NULL; | 1309 auto it = m_SizeMap.find(FaceGlyphsKey); |
| 1314 if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { | 1310 if (it != m_SizeMap.end()) { |
| 1311 CFX_SizeGlyphCache* pSizeCache = it->second; |
| 1315 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, | 1312 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, |
| 1316 (void*&)pGlyphBitmap)) { | 1313 (void*&)pGlyphBitmap)) { |
| 1317 return pGlyphBitmap; | 1314 return pGlyphBitmap; |
| 1318 } | 1315 } |
| 1319 pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, | 1316 pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, |
| 1320 dest_width, anti_alias); | 1317 dest_width, anti_alias); |
| 1321 if (pGlyphBitmap) { | 1318 if (pGlyphBitmap) { |
| 1322 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); | 1319 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); |
| 1323 return pGlyphBitmap; | 1320 return pGlyphBitmap; |
| 1324 } | 1321 } |
| 1325 } else { | 1322 } else { |
| 1326 pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, | 1323 pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, |
| 1327 dest_width, anti_alias); | 1324 dest_width, anti_alias); |
| 1328 if (pGlyphBitmap) { | 1325 if (pGlyphBitmap) { |
| 1329 pSizeCache = new CFX_SizeGlyphCache; | 1326 CFX_SizeGlyphCache* pSizeCache = new CFX_SizeGlyphCache; |
| 1330 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); | 1327 m_SizeMap[FaceGlyphsKey] = pSizeCache; |
| 1331 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); | 1328 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); |
| 1332 return pGlyphBitmap; | 1329 return pGlyphBitmap; |
| 1333 } | 1330 } |
| 1334 } | 1331 } |
| 1335 if (pFont->GetSubstFont()) | 1332 if (pFont->GetSubstFont()) |
| 1336 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), | 1333 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), |
| 1337 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), | 1334 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), |
| 1338 dest_width, anti_alias, pFont->GetSubstFont()->m_Weight, | 1335 dest_width, anti_alias, pFont->GetSubstFont()->m_Weight, |
| 1339 pFont->GetSubstFont()->m_ItalicAngle, pFont->IsVertical()); | 1336 pFont->GetSubstFont()->m_ItalicAngle, pFont->IsVertical()); |
| 1340 else | 1337 else |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1851 void _CFX_UniqueKeyGen::Generate(int count, ...) { | 1848 void _CFX_UniqueKeyGen::Generate(int count, ...) { |
| 1852 va_list argList; | 1849 va_list argList; |
| 1853 va_start(argList, count); | 1850 va_start(argList, count); |
| 1854 for (int i = 0; i < count; i++) { | 1851 for (int i = 0; i < count; i++) { |
| 1855 int p = va_arg(argList, int); | 1852 int p = va_arg(argList, int); |
| 1856 ((FX_DWORD*)m_Key)[i] = p; | 1853 ((FX_DWORD*)m_Key)[i] = p; |
| 1857 } | 1854 } |
| 1858 va_end(argList); | 1855 va_end(argList); |
| 1859 m_KeyLen = count * sizeof(FX_DWORD); | 1856 m_KeyLen = count * sizeof(FX_DWORD); |
| 1860 } | 1857 } |
| OLD | NEW |