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

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

Issue 1301793002: Merge to XFA: CFX_MapByteStringToPtr considered harmful (combo patch). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 4 months 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
« no previous file with comments | « core/src/fpdfapi/fpdf_page/pageint.h ('k') | core/src/fpdfapi/fpdf_render/render_int.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "../../../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 for (const auto& pair : m_SizeMap) {
15 CFX_ByteString Key; 15 delete pair.second;
16 CPDF_Type3Glyphs* pSizeCache = NULL;
17 while (pos) {
18 pSizeCache = (CPDF_Type3Glyphs*)m_SizeMap.GetNextValue(pos);
19 delete pSizeCache;
20 } 16 }
21 m_SizeMap.RemoveAll(); 17 m_SizeMap.clear();
22 } 18 }
23 CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(FX_DWORD charcode, 19 CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(FX_DWORD charcode,
24 const CFX_AffineMatrix* pMatrix, 20 const CFX_AffineMatrix* pMatrix,
25 FX_FLOAT retinaScaleX, 21 FX_FLOAT retinaScaleX,
26 FX_FLOAT retinaScaleY) { 22 FX_FLOAT retinaScaleY) {
27 _CPDF_UniqueKeyGen keygen; 23 _CPDF_UniqueKeyGen keygen;
28 keygen.Generate( 24 keygen.Generate(
29 4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000), 25 4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000),
30 FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000)); 26 FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000));
31 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); 27 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
32 CPDF_Type3Glyphs* pSizeCache = NULL; 28 CPDF_Type3Glyphs* pSizeCache;
33 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { 29 auto it = m_SizeMap.find(FaceGlyphsKey);
30 if (it == m_SizeMap.end()) {
34 pSizeCache = new CPDF_Type3Glyphs; 31 pSizeCache = new CPDF_Type3Glyphs;
35 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); 32 m_SizeMap[FaceGlyphsKey] = pSizeCache;
33 } else {
34 pSizeCache = it->second;
36 } 35 }
37 CFX_GlyphBitmap* pGlyphBitmap; 36 CFX_GlyphBitmap* pGlyphBitmap;
38 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)charcode, 37 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)charcode,
39 (void*&)pGlyphBitmap)) { 38 (void*&)pGlyphBitmap)) {
40 return pGlyphBitmap; 39 return pGlyphBitmap;
41 } 40 }
42 pGlyphBitmap = 41 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.SetAt((void*)(uintptr_t)charcode, pGlyphBitmap);
45 return pGlyphBitmap; 44 return pGlyphBitmap;
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 ProcessPath(&path, pObj2Device); 788 ProcessPath(&path, pObj2Device);
790 } 789 }
791 } 790 }
792 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) { 791 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) {
793 int glyph_index = GlyphFromCharCode(charcode); 792 int glyph_index = GlyphFromCharCode(charcode);
794 if (m_Font.m_Face == NULL) { 793 if (m_Font.m_Face == NULL) {
795 return NULL; 794 return NULL;
796 } 795 }
797 return m_Font.LoadGlyphPath(glyph_index, dest_width); 796 return m_Font.LoadGlyphPath(glyph_index, dest_width);
798 } 797 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/pageint.h ('k') | core/src/fpdfapi/fpdf_render/render_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698