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/fpdfapi/fpdf_render.h" | 8 #include "../../../include/fpdfapi/fpdf_render.h" |
9 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 9 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
10 #include "../fpdf_page/pageint.h" | 10 #include "../fpdf_page/pageint.h" |
11 #include "render_int.h" | 11 #include "render_int.h" |
12 extern FX_BOOL IsAvailableMatrix(const CFX_AffineMatrix& matrix); | 12 extern FX_BOOL IsAvailableMatrix(const CFX_AffineMatrix& matrix); |
13 CPDF_Type3Cache::~CPDF_Type3Cache() { | 13 CPDF_Type3Cache::~CPDF_Type3Cache() { |
14 FX_POSITION pos = m_SizeMap.GetStartPosition(); | 14 auto it = m_SizeMap.begin(); |
15 CFX_ByteString Key; | 15 while (it != m_SizeMap.end()) { |
Lei Zhang
2015/08/15 00:35:44
Range-Based For Loop?
Tom Sepez
2015/08/17 20:15:25
Done.
| |
16 CPDF_Type3Glyphs* pSizeCache = NULL; | 16 auto temp = it++; |
17 while (pos) { | 17 delete temp->second; |
18 pSizeCache = (CPDF_Type3Glyphs*)m_SizeMap.GetNextValue(pos); | 18 m_SizeMap.erase(temp); |
19 delete pSizeCache; | |
20 } | 19 } |
21 m_SizeMap.RemoveAll(); | |
22 } | 20 } |
23 CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(FX_DWORD charcode, | 21 CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(FX_DWORD charcode, |
24 const CFX_AffineMatrix* pMatrix, | 22 const CFX_AffineMatrix* pMatrix, |
25 FX_FLOAT retinaScaleX, | 23 FX_FLOAT retinaScaleX, |
26 FX_FLOAT retinaScaleY) { | 24 FX_FLOAT retinaScaleY) { |
27 _CPDF_UniqueKeyGen keygen; | 25 _CPDF_UniqueKeyGen keygen; |
28 keygen.Generate( | 26 keygen.Generate( |
29 4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000), | 27 4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000), |
30 FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000)); | 28 FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000)); |
31 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); | 29 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); |
32 CPDF_Type3Glyphs* pSizeCache = NULL; | 30 CPDF_Type3Glyphs* pSizeCache; |
33 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { | 31 auto it = m_SizeMap.find(FaceGlyphsKey); |
32 if (it == m_SizeMap.end()) { | |
34 pSizeCache = new CPDF_Type3Glyphs; | 33 pSizeCache = new CPDF_Type3Glyphs; |
35 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); | 34 m_SizeMap[FaceGlyphsKey] = pSizeCache; |
35 } else { | |
36 pSizeCache = it->second; | |
36 } | 37 } |
37 CFX_GlyphBitmap* pGlyphBitmap; | 38 CFX_GlyphBitmap* pGlyphBitmap; |
38 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)charcode, | 39 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)charcode, |
39 (void*&)pGlyphBitmap)) { | 40 (void*&)pGlyphBitmap)) { |
40 return pGlyphBitmap; | 41 return pGlyphBitmap; |
41 } | 42 } |
42 pGlyphBitmap = | 43 pGlyphBitmap = |
43 RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, retinaScaleY); | 44 RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, retinaScaleY); |
44 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)charcode, pGlyphBitmap); | 45 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)charcode, pGlyphBitmap); |
45 return pGlyphBitmap; | 46 return pGlyphBitmap; |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 ProcessPath(&path, pObj2Device); | 792 ProcessPath(&path, pObj2Device); |
792 } | 793 } |
793 } | 794 } |
794 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) { | 795 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) { |
795 int glyph_index = GlyphFromCharCode(charcode); | 796 int glyph_index = GlyphFromCharCode(charcode); |
796 if (m_Font.m_Face == NULL) { | 797 if (m_Font.m_Face == NULL) { |
797 return NULL; | 798 return NULL; |
798 } | 799 } |
799 return m_Font.LoadGlyphPath(glyph_index, dest_width); | 800 return m_Font.LoadGlyphPath(glyph_index, dest_width); |
800 } | 801 } |
OLD | NEW |