| 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 "render_int.h" | 7 #include "render_int.h" |
| 8 | 8 |
| 9 #include "core/include/fpdfapi/fpdf_pageobj.h" | 9 #include "core/include/fpdfapi/fpdf_pageobj.h" |
| 10 #include "core/include/fpdfapi/fpdf_render.h" | 10 #include "core/include/fpdfapi/fpdf_render.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000)); | 27 FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000)); |
| 28 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); | 28 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); |
| 29 CPDF_Type3Glyphs* pSizeCache; | 29 CPDF_Type3Glyphs* pSizeCache; |
| 30 auto it = m_SizeMap.find(FaceGlyphsKey); | 30 auto it = m_SizeMap.find(FaceGlyphsKey); |
| 31 if (it == m_SizeMap.end()) { | 31 if (it == m_SizeMap.end()) { |
| 32 pSizeCache = new CPDF_Type3Glyphs; | 32 pSizeCache = new CPDF_Type3Glyphs; |
| 33 m_SizeMap[FaceGlyphsKey] = pSizeCache; | 33 m_SizeMap[FaceGlyphsKey] = pSizeCache; |
| 34 } else { | 34 } else { |
| 35 pSizeCache = it->second; | 35 pSizeCache = it->second; |
| 36 } | 36 } |
| 37 CFX_GlyphBitmap* pGlyphBitmap; | 37 auto it2 = pSizeCache->m_GlyphMap.find(charcode); |
| 38 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)charcode, | 38 if (it2 != pSizeCache->m_GlyphMap.end()) |
| 39 (void*&)pGlyphBitmap)) { | 39 return it2->second; |
| 40 return pGlyphBitmap; | 40 |
| 41 } | 41 CFX_GlyphBitmap* pGlyphBitmap = |
| 42 pGlyphBitmap = | |
| 43 RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, retinaScaleY); | 42 RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, retinaScaleY); |
| 44 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)charcode, pGlyphBitmap); | 43 pSizeCache->m_GlyphMap[charcode] = pGlyphBitmap; |
| 45 return pGlyphBitmap; | 44 return pGlyphBitmap; |
| 46 } | 45 } |
| 47 CPDF_Type3Glyphs::~CPDF_Type3Glyphs() { | 46 CPDF_Type3Glyphs::~CPDF_Type3Glyphs() { |
| 48 FX_POSITION pos = m_GlyphMap.GetStartPosition(); | 47 for (const auto& pair : m_GlyphMap) |
| 49 void* Key; | 48 delete pair.second; |
| 50 CFX_GlyphBitmap* pGlyphBitmap; | |
| 51 while (pos) { | |
| 52 m_GlyphMap.GetNextAssoc(pos, Key, (void*&)pGlyphBitmap); | |
| 53 delete pGlyphBitmap; | |
| 54 } | |
| 55 } | 49 } |
| 56 static int _AdjustBlue(FX_FLOAT pos, int& count, int blues[]) { | 50 static int _AdjustBlue(FX_FLOAT pos, int& count, int blues[]) { |
| 57 FX_FLOAT min_distance = 1000000.0f * 1.0f; | 51 FX_FLOAT min_distance = 1000000.0f * 1.0f; |
| 58 int closest_pos = -1; | 52 int closest_pos = -1; |
| 59 for (int i = 0; i < count; i++) { | 53 for (int i = 0; i < count; i++) { |
| 60 FX_FLOAT distance = (FX_FLOAT)FXSYS_fabs(pos - (FX_FLOAT)blues[i]); | 54 FX_FLOAT distance = (FX_FLOAT)FXSYS_fabs(pos - (FX_FLOAT)blues[i]); |
| 61 if (distance < 1.0f * 80.0f / 100.0f && distance < min_distance) { | 55 if (distance < 1.0f * 80.0f / 100.0f && distance < min_distance) { |
| 62 min_distance = distance; | 56 min_distance = distance; |
| 63 closest_pos = i; | 57 closest_pos = i; |
| 64 } | 58 } |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 ProcessPath(&path, pObj2Device); | 783 ProcessPath(&path, pObj2Device); |
| 790 } | 784 } |
| 791 } | 785 } |
| 792 | 786 |
| 793 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) { | 787 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) { |
| 794 int glyph_index = GlyphFromCharCode(charcode); | 788 int glyph_index = GlyphFromCharCode(charcode); |
| 795 if (!m_Font.GetFace()) | 789 if (!m_Font.GetFace()) |
| 796 return nullptr; | 790 return nullptr; |
| 797 return m_Font.LoadGlyphPath(glyph_index, dest_width); | 791 return m_Font.LoadGlyphPath(glyph_index, dest_width); |
| 798 } | 792 } |
| OLD | NEW |