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

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

Issue 2060973002: Make code compile with clang_use_chrome_plugin (part I) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments Created 4 years, 6 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/fpdfapi/fpdf_render/fpdf_render_image.cpp ('k') | core/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 "core/fpdfapi/fpdf_render/render_int.h" 7 #include "core/fpdfapi/fpdf_render/render_int.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 27 matching lines...) Expand all
38 for (int i = 0; i < count; i++) { 38 for (int i = 0; i < count; i++) {
39 int p = va_arg(argList, int); 39 int p = va_arg(argList, int);
40 ((uint32_t*)m_Key)[i] = p; 40 ((uint32_t*)m_Key)[i] = p;
41 } 41 }
42 va_end(argList); 42 va_end(argList);
43 m_KeyLen = count * sizeof(uint32_t); 43 m_KeyLen = count * sizeof(uint32_t);
44 } 44 }
45 45
46 } // namespace 46 } // namespace
47 47
48 CPDF_Type3Cache::CPDF_Type3Cache(CPDF_Type3Font* pFont) : m_pFont(pFont) {}
49
48 CPDF_Type3Cache::~CPDF_Type3Cache() { 50 CPDF_Type3Cache::~CPDF_Type3Cache() {
49 for (const auto& pair : m_SizeMap) { 51 for (const auto& pair : m_SizeMap) {
50 delete pair.second; 52 delete pair.second;
51 } 53 }
52 m_SizeMap.clear(); 54 m_SizeMap.clear();
53 } 55 }
56
54 CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode, 57 CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode,
55 const CFX_Matrix* pMatrix, 58 const CFX_Matrix* pMatrix,
56 FX_FLOAT retinaScaleX, 59 FX_FLOAT retinaScaleX,
57 FX_FLOAT retinaScaleY) { 60 FX_FLOAT retinaScaleY) {
58 CPDF_UniqueKeyGen keygen; 61 CPDF_UniqueKeyGen keygen;
59 keygen.Generate( 62 keygen.Generate(
60 4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000), 63 4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000),
61 FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000)); 64 FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000));
62 CFX_ByteString FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); 65 CFX_ByteString FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
63 CPDF_Type3Glyphs* pSizeCache; 66 CPDF_Type3Glyphs* pSizeCache;
64 auto it = m_SizeMap.find(FaceGlyphsKey); 67 auto it = m_SizeMap.find(FaceGlyphsKey);
65 if (it == m_SizeMap.end()) { 68 if (it == m_SizeMap.end()) {
66 pSizeCache = new CPDF_Type3Glyphs; 69 pSizeCache = new CPDF_Type3Glyphs;
67 m_SizeMap[FaceGlyphsKey] = pSizeCache; 70 m_SizeMap[FaceGlyphsKey] = pSizeCache;
68 } else { 71 } else {
69 pSizeCache = it->second; 72 pSizeCache = it->second;
70 } 73 }
71 auto it2 = pSizeCache->m_GlyphMap.find(charcode); 74 auto it2 = pSizeCache->m_GlyphMap.find(charcode);
72 if (it2 != pSizeCache->m_GlyphMap.end()) 75 if (it2 != pSizeCache->m_GlyphMap.end())
73 return it2->second; 76 return it2->second;
74 77
75 CFX_GlyphBitmap* pGlyphBitmap = 78 CFX_GlyphBitmap* pGlyphBitmap =
76 RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, retinaScaleY); 79 RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, retinaScaleY);
77 pSizeCache->m_GlyphMap[charcode] = pGlyphBitmap; 80 pSizeCache->m_GlyphMap[charcode] = pGlyphBitmap;
78 return pGlyphBitmap; 81 return pGlyphBitmap;
79 } 82 }
83
84 CPDF_Type3Glyphs::CPDF_Type3Glyphs()
85 : m_TopBlueCount(0), m_BottomBlueCount(0) {}
86
80 CPDF_Type3Glyphs::~CPDF_Type3Glyphs() { 87 CPDF_Type3Glyphs::~CPDF_Type3Glyphs() {
81 for (const auto& pair : m_GlyphMap) 88 for (const auto& pair : m_GlyphMap)
82 delete pair.second; 89 delete pair.second;
83 } 90 }
91
84 static int _AdjustBlue(FX_FLOAT pos, int& count, int blues[]) { 92 static int _AdjustBlue(FX_FLOAT pos, int& count, int blues[]) {
85 FX_FLOAT min_distance = 1000000.0f * 1.0f; 93 FX_FLOAT min_distance = 1000000.0f * 1.0f;
86 int closest_pos = -1; 94 int closest_pos = -1;
87 for (int i = 0; i < count; i++) { 95 for (int i = 0; i < count; i++) {
88 FX_FLOAT distance = (FX_FLOAT)FXSYS_fabs(pos - (FX_FLOAT)blues[i]); 96 FX_FLOAT distance = (FX_FLOAT)FXSYS_fabs(pos - (FX_FLOAT)blues[i]);
89 if (distance < 1.0f * 80.0f / 100.0f && distance < min_distance) { 97 if (distance < 1.0f * 80.0f / 100.0f && distance < min_distance) {
90 min_distance = distance; 98 min_distance = distance;
91 closest_pos = i; 99 closest_pos = i;
92 } 100 }
93 } 101 }
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, 787 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX,
780 charpos.m_OriginY); 788 charpos.m_OriginY);
781 path.m_Path.New()->Append(pPath, &matrix); 789 path.m_Path.New()->Append(pPath, &matrix);
782 path.m_Matrix = *pTextMatrix; 790 path.m_Matrix = *pTextMatrix;
783 path.m_bStroke = bStroke; 791 path.m_bStroke = bStroke;
784 path.m_FillType = bFill ? FXFILL_WINDING : 0; 792 path.m_FillType = bFill ? FXFILL_WINDING : 0;
785 path.CalcBoundingBox(); 793 path.CalcBoundingBox();
786 ProcessPath(&path, pObj2Device); 794 ProcessPath(&path, pObj2Device);
787 } 795 }
788 } 796 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_render/fpdf_render_image.cpp ('k') | core/fpdfapi/fpdf_render/render_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698