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

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

Issue 1426403008: Cleanup some fxge font code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits 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"
(...skipping 19 matching lines...) Expand all
30 public: 30 public:
31 ScopedFontTransform(FT_Face face, FXFT_Matrix* matrix) : m_Face(face) { 31 ScopedFontTransform(FT_Face face, FXFT_Matrix* matrix) : m_Face(face) {
32 FXFT_Set_Transform(m_Face, matrix, 0); 32 FXFT_Set_Transform(m_Face, matrix, 0);
33 } 33 }
34 34
35 ~ScopedFontTransform() { ResetTransform(m_Face); } 35 ~ScopedFontTransform() { ResetTransform(m_Face); }
36 36
37 private: 37 private:
38 FT_Face m_Face; 38 FT_Face m_Face;
39 }; 39 };
40 } 40
41 } // namespace
41 42
42 FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos, 43 FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos,
43 int nChars, 44 int nChars,
44 int anti_alias, 45 int anti_alias,
45 FX_FLOAT retinaScaleX, 46 FX_FLOAT retinaScaleX,
46 FX_FLOAT retinaScaleY) { 47 FX_FLOAT retinaScaleY) {
47 FX_RECT rect(0, 0, 0, 0); 48 FX_RECT rect(0, 0, 0, 0);
48 FX_BOOL bStarted = FALSE; 49 FX_BOOL bStarted = FALSE;
49 for (int iChar = 0; iChar < nChars; iChar++) { 50 for (int iChar = 0; iChar < nChars; iChar++) {
50 FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar]; 51 FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 289 }
289 glyph.m_OriginY = FXSYS_round(glyph.m_fOriginY); 290 glyph.m_OriginY = FXSYS_round(glyph.m_fOriginY);
290 if (charpos.m_bGlyphAdjust) { 291 if (charpos.m_bGlyphAdjust) {
291 CFX_AffineMatrix new_matrix( 292 CFX_AffineMatrix new_matrix(
292 charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], 293 charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1],
293 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); 294 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0);
294 new_matrix.Concat(deviceCtm); 295 new_matrix.Concat(deviceCtm);
295 glyph.m_pGlyph = pFaceCache->LoadGlyphBitmap( 296 glyph.m_pGlyph = pFaceCache->LoadGlyphBitmap(
296 pFont, charpos.m_GlyphIndex, charpos.m_bFontStyle, &new_matrix, 297 pFont, charpos.m_GlyphIndex, charpos.m_bFontStyle, &new_matrix,
297 charpos.m_FontCharWidth, anti_alias, nativetext_flags); 298 charpos.m_FontCharWidth, anti_alias, nativetext_flags);
298 } else 299 } else {
299 glyph.m_pGlyph = pFaceCache->LoadGlyphBitmap( 300 glyph.m_pGlyph = pFaceCache->LoadGlyphBitmap(
300 pFont, charpos.m_GlyphIndex, charpos.m_bFontStyle, &deviceCtm, 301 pFont, charpos.m_GlyphIndex, charpos.m_bFontStyle, &deviceCtm,
301 charpos.m_FontCharWidth, anti_alias, nativetext_flags); 302 charpos.m_FontCharWidth, anti_alias, nativetext_flags);
303 }
302 } 304 }
303 if (anti_alias < FXFT_RENDER_MODE_LCD && nChars > 1) { 305 if (anti_alias < FXFT_RENDER_MODE_LCD && nChars > 1) {
304 _AdjustGlyphSpace(pGlyphAndPos, nChars); 306 _AdjustGlyphSpace(pGlyphAndPos, nChars);
305 } 307 }
306 FX_RECT bmp_rect1 = FXGE_GetGlyphsBBox(pGlyphAndPos, nChars, anti_alias); 308 FX_RECT bmp_rect1 = FXGE_GetGlyphsBBox(pGlyphAndPos, nChars, anti_alias);
307 if (scale_x > 1 && scale_y > 1) { 309 if (scale_x > 1 && scale_y > 1) {
308 bmp_rect1.left--; 310 bmp_rect1.left--;
309 bmp_rect1.top--; 311 bmp_rect1.top--;
310 bmp_rect1.right++; 312 bmp_rect1.right++;
311 bmp_rect1.bottom++; 313 bmp_rect1.bottom++;
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 auto curr_it = it++; 1223 auto curr_it = it++;
1222 CFX_CountedFaceCache* cache = curr_it->second; 1224 CFX_CountedFaceCache* cache = curr_it->second;
1223 if (bRelease || cache->m_nCount < 2) { 1225 if (bRelease || cache->m_nCount < 2) {
1224 delete cache->m_Obj; 1226 delete cache->m_Obj;
1225 delete cache; 1227 delete cache;
1226 m_ExtFaceMap.erase(curr_it); 1228 m_ExtFaceMap.erase(curr_it);
1227 } 1229 }
1228 } 1230 }
1229 } 1231 }
1230 1232
1231 CFX_FaceCache::CFX_FaceCache(FXFT_Face face) { 1233 CFX_FaceCache::CFX_FaceCache(FXFT_Face face) : m_Face(face) {}
1232 m_Face = face; 1234
1233 }
1234 CFX_FaceCache::~CFX_FaceCache() { 1235 CFX_FaceCache::~CFX_FaceCache() {
1235 for (const auto& pair : m_SizeMap) { 1236 for (const auto& pair : m_SizeMap) {
1236 delete pair.second; 1237 delete pair.second;
1237 } 1238 }
1238 m_SizeMap.clear(); 1239 m_SizeMap.clear();
1239 FX_POSITION pos = m_PathMap.GetStartPosition(); 1240 FX_POSITION pos = m_PathMap.GetStartPosition();
1240 void* key1; 1241 void* key1;
1241 CFX_PathData* pPath; 1242 CFX_PathData* pPath;
1242 while (pos) { 1243 while (pos) {
1243 m_PathMap.GetNextAssoc(pos, key1, (void*&)pPath); 1244 m_PathMap.GetNextAssoc(pos, key1, (void*&)pPath);
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 return pGlyphBitmap; 1650 return pGlyphBitmap;
1650 } 1651 }
1651 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, 1652 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont,
1652 FX_DWORD glyph_index, 1653 FX_DWORD glyph_index,
1653 int dest_width) { 1654 int dest_width) {
1654 if (m_Face == NULL || glyph_index == (FX_DWORD)-1) { 1655 if (m_Face == NULL || glyph_index == (FX_DWORD)-1) {
1655 return NULL; 1656 return NULL;
1656 } 1657 }
1657 CFX_PathData* pGlyphPath = NULL; 1658 CFX_PathData* pGlyphPath = NULL;
1658 void* key; 1659 void* key;
1659 if (pFont->GetSubstFont()) 1660 if (pFont->GetSubstFont()) {
1660 key = (void*)(uintptr_t)( 1661 key = (void*)(uintptr_t)(
1661 glyph_index + ((pFont->GetSubstFont()->m_Weight / 16) << 15) + 1662 glyph_index + ((pFont->GetSubstFont()->m_Weight / 16) << 15) +
1662 ((pFont->GetSubstFont()->m_ItalicAngle / 2) << 21) + 1663 ((pFont->GetSubstFont()->m_ItalicAngle / 2) << 21) +
1663 ((dest_width / 16) << 25) + (pFont->IsVertical() << 31)); 1664 ((dest_width / 16) << 25) + (pFont->IsVertical() << 31));
1664 else { 1665 } else {
1665 key = (void*)(uintptr_t)glyph_index; 1666 key = (void*)(uintptr_t)glyph_index;
1666 } 1667 }
1667 if (m_PathMap.Lookup(key, (void*&)pGlyphPath)) { 1668 if (m_PathMap.Lookup(key, (void*&)pGlyphPath)) {
1668 return pGlyphPath; 1669 return pGlyphPath;
1669 } 1670 }
1670 pGlyphPath = pFont->LoadGlyphPath(glyph_index, dest_width); 1671 pGlyphPath = pFont->LoadGlyphPath(glyph_index, dest_width);
1671 m_PathMap.SetAt(key, pGlyphPath); 1672 m_PathMap.SetAt(key, pGlyphPath);
1672 return pGlyphPath; 1673 return pGlyphPath;
1673 } 1674 }
1674 typedef struct { 1675 typedef struct {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 void _CFX_UniqueKeyGen::Generate(int count, ...) { 1872 void _CFX_UniqueKeyGen::Generate(int count, ...) {
1872 va_list argList; 1873 va_list argList;
1873 va_start(argList, count); 1874 va_start(argList, count);
1874 for (int i = 0; i < count; i++) { 1875 for (int i = 0; i < count; i++) {
1875 int p = va_arg(argList, int); 1876 int p = va_arg(argList, int);
1876 ((FX_DWORD*)m_Key)[i] = p; 1877 ((FX_DWORD*)m_Key)[i] = p;
1877 } 1878 }
1878 va_end(argList); 1879 va_end(argList);
1879 m_KeyLen = count * sizeof(FX_DWORD); 1880 m_KeyLen = count * sizeof(FX_DWORD);
1880 } 1881 }
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