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

Side by Side Diff: core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp

Issue 1520643002: Replace several more CFX_MapPtrToPtr with std::set or std::map (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years 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
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 #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
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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 ProcessPath(&path, pObj2Device); 785 ProcessPath(&path, pObj2Device);
792 } 786 }
793 } 787 }
794 788
795 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) { 789 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) {
796 int glyph_index = GlyphFromCharCode(charcode); 790 int glyph_index = GlyphFromCharCode(charcode);
797 if (!m_Font.GetFace()) 791 if (!m_Font.GetFace())
798 return nullptr; 792 return nullptr;
799 return m_Font.LoadGlyphPath(glyph_index, dest_width); 793 return m_Font.LoadGlyphPath(glyph_index, dest_width);
800 } 794 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698