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

Side by Side Diff: core/src/fxge/ge/fx_ge_text.cpp

Issue 1410683013: Merge to XFA: Cleanup some fxge font code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: fix merge Created 5 years, 1 month 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/fxge/ge/fx_ge_fontmap.cpp ('k') | no next file » | 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/fxge/fx_freetype.h" 8 #include "../../../include/fxge/fx_freetype.h"
9 #include "../../../include/fxcodec/fx_codec.h" 9 #include "../../../include/fxcodec/fx_codec.h"
10 #include "text_int.h" 10 #include "text_int.h"
11 #undef FX_GAMMA 11 #undef FX_GAMMA
12 #undef FX_GAMMA_INVERSE 12 #undef FX_GAMMA_INVERSE
13 #define FX_GAMMA(value) (value) 13 #define FX_GAMMA(value) (value)
14 #define FX_GAMMA_INVERSE(value) (value) 14 #define FX_GAMMA_INVERSE(value) (value)
15
15 FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos, 16 FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos,
16 int nChars, 17 int nChars,
17 int anti_alias, 18 int anti_alias,
18 FX_FLOAT retinaScaleX, 19 FX_FLOAT retinaScaleX,
19 FX_FLOAT retinaScaleY) { 20 FX_FLOAT retinaScaleY) {
20 FX_RECT rect(0, 0, 0, 0); 21 FX_RECT rect(0, 0, 0, 0);
21 FX_BOOL bStarted = FALSE; 22 FX_BOOL bStarted = FALSE;
22 for (int iChar = 0; iChar < nChars; iChar++) { 23 for (int iChar = 0; iChar < nChars; iChar++) {
23 FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar]; 24 FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
24 const CFX_GlyphBitmap* pGlyph = glyph.m_pGlyph; 25 const CFX_GlyphBitmap* pGlyph = glyph.m_pGlyph;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 262 }
262 glyph.m_OriginY = FXSYS_round(glyph.m_fOriginY); 263 glyph.m_OriginY = FXSYS_round(glyph.m_fOriginY);
263 if (charpos.m_bGlyphAdjust) { 264 if (charpos.m_bGlyphAdjust) {
264 CFX_AffineMatrix new_matrix( 265 CFX_AffineMatrix new_matrix(
265 charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], 266 charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1],
266 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); 267 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0);
267 new_matrix.Concat(deviceCtm); 268 new_matrix.Concat(deviceCtm);
268 glyph.m_pGlyph = pFaceCache->LoadGlyphBitmap( 269 glyph.m_pGlyph = pFaceCache->LoadGlyphBitmap(
269 pFont, charpos.m_GlyphIndex, charpos.m_bFontStyle, &new_matrix, 270 pFont, charpos.m_GlyphIndex, charpos.m_bFontStyle, &new_matrix,
270 charpos.m_FontCharWidth, anti_alias, nativetext_flags); 271 charpos.m_FontCharWidth, anti_alias, nativetext_flags);
271 } else 272 } else {
272 glyph.m_pGlyph = pFaceCache->LoadGlyphBitmap( 273 glyph.m_pGlyph = pFaceCache->LoadGlyphBitmap(
273 pFont, charpos.m_GlyphIndex, charpos.m_bFontStyle, &deviceCtm, 274 pFont, charpos.m_GlyphIndex, charpos.m_bFontStyle, &deviceCtm,
274 charpos.m_FontCharWidth, anti_alias, nativetext_flags); 275 charpos.m_FontCharWidth, anti_alias, nativetext_flags);
276 }
275 } 277 }
276 if (anti_alias < FXFT_RENDER_MODE_LCD && nChars > 1) { 278 if (anti_alias < FXFT_RENDER_MODE_LCD && nChars > 1) {
277 _AdjustGlyphSpace(pGlyphAndPos, nChars); 279 _AdjustGlyphSpace(pGlyphAndPos, nChars);
278 } 280 }
279 FX_RECT bmp_rect1 = FXGE_GetGlyphsBBox(pGlyphAndPos, nChars, anti_alias); 281 FX_RECT bmp_rect1 = FXGE_GetGlyphsBBox(pGlyphAndPos, nChars, anti_alias);
280 if (scale_x > 1 && scale_y > 1) { 282 if (scale_x > 1 && scale_y > 1) {
281 bmp_rect1.left--; 283 bmp_rect1.left--;
282 bmp_rect1.top--; 284 bmp_rect1.top--;
283 bmp_rect1.right++; 285 bmp_rect1.right++;
284 bmp_rect1.bottom++; 286 bmp_rect1.bottom++;
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 auto curr_it = it++; 1195 auto curr_it = it++;
1194 CFX_CountedFaceCache* cache = curr_it->second; 1196 CFX_CountedFaceCache* cache = curr_it->second;
1195 if (bRelease || cache->m_nCount < 2) { 1197 if (bRelease || cache->m_nCount < 2) {
1196 delete cache->m_Obj; 1198 delete cache->m_Obj;
1197 delete cache; 1199 delete cache;
1198 m_ExtFaceMap.erase(curr_it); 1200 m_ExtFaceMap.erase(curr_it);
1199 } 1201 }
1200 } 1202 }
1201 } 1203 }
1202 1204
1203 CFX_FaceCache::CFX_FaceCache(FXFT_Face face) { 1205 CFX_FaceCache::CFX_FaceCache(FXFT_Face face) : m_Face(face) {}
1204 m_Face = face; 1206
1205 }
1206 CFX_FaceCache::~CFX_FaceCache() { 1207 CFX_FaceCache::~CFX_FaceCache() {
1207 for (const auto& pair : m_SizeMap) { 1208 for (const auto& pair : m_SizeMap) {
1208 delete pair.second; 1209 delete pair.second;
1209 } 1210 }
1210 m_SizeMap.clear(); 1211 m_SizeMap.clear();
1211 FX_POSITION pos = m_PathMap.GetStartPosition(); 1212 FX_POSITION pos = m_PathMap.GetStartPosition();
1212 void* key1; 1213 void* key1;
1213 CFX_PathData* pPath; 1214 CFX_PathData* pPath;
1214 while (pos) { 1215 while (pos) {
1215 m_PathMap.GetNextAssoc(pos, key1, (void*&)pPath); 1216 m_PathMap.GetNextAssoc(pos, key1, (void*&)pPath);
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 return pGlyphBitmap; 1622 return pGlyphBitmap;
1622 } 1623 }
1623 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, 1624 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont,
1624 FX_DWORD glyph_index, 1625 FX_DWORD glyph_index,
1625 int dest_width) { 1626 int dest_width) {
1626 if (m_Face == NULL || glyph_index == (FX_DWORD)-1) { 1627 if (m_Face == NULL || glyph_index == (FX_DWORD)-1) {
1627 return NULL; 1628 return NULL;
1628 } 1629 }
1629 CFX_PathData* pGlyphPath = NULL; 1630 CFX_PathData* pGlyphPath = NULL;
1630 void* key; 1631 void* key;
1631 if (pFont->GetSubstFont()) 1632 if (pFont->GetSubstFont()) {
1632 key = (void*)(uintptr_t)( 1633 key = (void*)(uintptr_t)(
1633 glyph_index + ((pFont->GetSubstFont()->m_Weight / 16) << 15) + 1634 glyph_index + ((pFont->GetSubstFont()->m_Weight / 16) << 15) +
1634 ((pFont->GetSubstFont()->m_ItalicAngle / 2) << 21) + 1635 ((pFont->GetSubstFont()->m_ItalicAngle / 2) << 21) +
1635 ((dest_width / 16) << 25) + (pFont->IsVertical() << 31)); 1636 ((dest_width / 16) << 25) + (pFont->IsVertical() << 31));
1636 else { 1637 } else {
1637 key = (void*)(uintptr_t)glyph_index; 1638 key = (void*)(uintptr_t)glyph_index;
1638 } 1639 }
1639 if (m_PathMap.Lookup(key, (void*&)pGlyphPath)) { 1640 if (m_PathMap.Lookup(key, (void*&)pGlyphPath)) {
1640 return pGlyphPath; 1641 return pGlyphPath;
1641 } 1642 }
1642 pGlyphPath = pFont->LoadGlyphPath(glyph_index, dest_width); 1643 pGlyphPath = pFont->LoadGlyphPath(glyph_index, dest_width);
1643 m_PathMap.SetAt(key, pGlyphPath); 1644 m_PathMap.SetAt(key, pGlyphPath);
1644 return pGlyphPath; 1645 return pGlyphPath;
1645 } 1646 }
1646 typedef struct { 1647 typedef struct {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 void _CFX_UniqueKeyGen::Generate(int count, ...) { 1844 void _CFX_UniqueKeyGen::Generate(int count, ...) {
1844 va_list argList; 1845 va_list argList;
1845 va_start(argList, count); 1846 va_start(argList, count);
1846 for (int i = 0; i < count; i++) { 1847 for (int i = 0; i < count; i++) {
1847 int p = va_arg(argList, int); 1848 int p = va_arg(argList, int);
1848 ((FX_DWORD*)m_Key)[i] = p; 1849 ((FX_DWORD*)m_Key)[i] = p;
1849 } 1850 }
1850 va_end(argList); 1851 va_end(argList);
1851 m_KeyLen = count * sizeof(FX_DWORD); 1852 m_KeyLen = count * sizeof(FX_DWORD);
1852 } 1853 }
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_fontmap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698