OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fxge/cfx_facecache.h" | 7 #include "core/fxge/cfx_facecache.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 CFX_FaceCache::~CFX_FaceCache() { | 86 CFX_FaceCache::~CFX_FaceCache() { |
87 #ifdef _SKIA_SUPPORT_ | 87 #ifdef _SKIA_SUPPORT_ |
88 SkSafeUnref(m_pTypeface); | 88 SkSafeUnref(m_pTypeface); |
89 #endif | 89 #endif |
90 } | 90 } |
91 | 91 |
92 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(const CFX_Font* pFont, | 92 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(const CFX_Font* pFont, |
93 uint32_t glyph_index, | 93 uint32_t glyph_index, |
94 FX_BOOL bFontStyle, | 94 bool bFontStyle, |
95 const CFX_Matrix* pMatrix, | 95 const CFX_Matrix* pMatrix, |
96 int dest_width, | 96 int dest_width, |
97 int anti_alias) { | 97 int anti_alias) { |
98 if (!m_Face) | 98 if (!m_Face) |
99 return nullptr; | 99 return nullptr; |
100 | 100 |
101 FXFT_Matrix ft_matrix; | 101 FXFT_Matrix ft_matrix; |
102 ft_matrix.xx = (signed long)(pMatrix->GetA() / 64 * 65536); | 102 ft_matrix.xx = (signed long)(pMatrix->GetA() / 64 * 65536); |
103 ft_matrix.xy = (signed long)(pMatrix->GetC() / 64 * 65536); | 103 ft_matrix.xy = (signed long)(pMatrix->GetC() / 64 * 65536); |
104 ft_matrix.yx = (signed long)(pMatrix->GetB() / 64 * 65536); | 104 ft_matrix.yx = (signed long)(pMatrix->GetB() / 64 * 65536); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 if (it != m_PathMap.end()) | 247 if (it != m_PathMap.end()) |
248 return it->second.get(); | 248 return it->second.get(); |
249 | 249 |
250 CFX_PathData* pGlyphPath = pFont->LoadGlyphPathImpl(glyph_index, dest_width); | 250 CFX_PathData* pGlyphPath = pFont->LoadGlyphPathImpl(glyph_index, dest_width); |
251 m_PathMap[key] = std::unique_ptr<CFX_PathData>(pGlyphPath); | 251 m_PathMap[key] = std::unique_ptr<CFX_PathData>(pGlyphPath); |
252 return pGlyphPath; | 252 return pGlyphPath; |
253 } | 253 } |
254 | 254 |
255 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(const CFX_Font* pFont, | 255 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(const CFX_Font* pFont, |
256 uint32_t glyph_index, | 256 uint32_t glyph_index, |
257 FX_BOOL bFontStyle, | 257 bool bFontStyle, |
258 const CFX_Matrix* pMatrix, | 258 const CFX_Matrix* pMatrix, |
259 int dest_width, | 259 int dest_width, |
260 int anti_alias, | 260 int anti_alias, |
261 int& text_flags) { | 261 int& text_flags) { |
262 if (glyph_index == kInvalidGlyphIndex) | 262 if (glyph_index == kInvalidGlyphIndex) |
263 return nullptr; | 263 return nullptr; |
264 | 264 |
265 _CFX_UniqueKeyGen keygen; | 265 _CFX_UniqueKeyGen keygen; |
266 int nMatrixA = static_cast<int>(pMatrix->a * 10000); | 266 int nMatrixA = static_cast<int>(pMatrix->a * 10000); |
267 int nMatrixB = static_cast<int>(pMatrix->b * 10000); | 267 int nMatrixB = static_cast<int>(pMatrix->b * 10000); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 363 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
364 void CFX_FaceCache::InitPlatform() {} | 364 void CFX_FaceCache::InitPlatform() {} |
365 #endif | 365 #endif |
366 | 366 |
367 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap( | 367 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap( |
368 const CFX_Font* pFont, | 368 const CFX_Font* pFont, |
369 const CFX_Matrix* pMatrix, | 369 const CFX_Matrix* pMatrix, |
370 const CFX_ByteString& FaceGlyphsKey, | 370 const CFX_ByteString& FaceGlyphsKey, |
371 uint32_t glyph_index, | 371 uint32_t glyph_index, |
372 FX_BOOL bFontStyle, | 372 bool bFontStyle, |
373 int dest_width, | 373 int dest_width, |
374 int anti_alias) { | 374 int anti_alias) { |
375 CFX_SizeGlyphCache* pSizeCache; | 375 CFX_SizeGlyphCache* pSizeCache; |
376 auto it = m_SizeMap.find(FaceGlyphsKey); | 376 auto it = m_SizeMap.find(FaceGlyphsKey); |
377 if (it == m_SizeMap.end()) { | 377 if (it == m_SizeMap.end()) { |
378 pSizeCache = new CFX_SizeGlyphCache; | 378 pSizeCache = new CFX_SizeGlyphCache; |
379 m_SizeMap[FaceGlyphsKey] = std::unique_ptr<CFX_SizeGlyphCache>(pSizeCache); | 379 m_SizeMap[FaceGlyphsKey] = std::unique_ptr<CFX_SizeGlyphCache>(pSizeCache); |
380 } else { | 380 } else { |
381 pSizeCache = it->second.get(); | 381 pSizeCache = it->second.get(); |
382 } | 382 } |
383 auto it2 = pSizeCache->m_GlyphMap.find(glyph_index); | 383 auto it2 = pSizeCache->m_GlyphMap.find(glyph_index); |
384 if (it2 != pSizeCache->m_GlyphMap.end()) | 384 if (it2 != pSizeCache->m_GlyphMap.end()) |
385 return it2->second; | 385 return it2->second; |
386 | 386 |
387 CFX_GlyphBitmap* pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, | 387 CFX_GlyphBitmap* pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, |
388 pMatrix, dest_width, anti_alias); | 388 pMatrix, dest_width, anti_alias); |
389 pSizeCache->m_GlyphMap[glyph_index] = pGlyphBitmap; | 389 pSizeCache->m_GlyphMap[glyph_index] = pGlyphBitmap; |
390 return pGlyphBitmap; | 390 return pGlyphBitmap; |
391 } | 391 } |
OLD | NEW |