OLD | NEW |
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 argb = color; | 104 argb = color; |
105 return; | 105 return; |
106 } | 106 } |
107 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodec
Module()->GetIccModule()) { | 107 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodec
Module()->GetIccModule()) { |
108 pIccTransform = NULL; | 108 pIccTransform = NULL; |
109 } | 109 } |
110 uint8_t bgra[4]; | 110 uint8_t bgra[4]; |
111 if (pIccTransform) { | 111 if (pIccTransform) { |
112 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); | 112 ICodec_IccModule* pIccModule = CFX_GEModule::Get()->GetCodecModule()->Ge
tIccModule(); |
113 color = FXGETFLAG_COLORTYPE(alpha_flag) ? FXCMYK_TODIB(color) : FXARGB_T
ODIB(color); | 113 color = FXGETFLAG_COLORTYPE(alpha_flag) ? FXCMYK_TODIB(color) : FXARGB_T
ODIB(color); |
114 pIccModule->TranslateScanline(pIccTransform, bgra, (FX_LPCBYTE)&color, 1
); | 114 pIccModule->TranslateScanline(pIccTransform, bgra, (const uint8_t*)&colo
r, 1); |
115 bgra[3] = FXGETFLAG_COLORTYPE(alpha_flag) ? | 115 bgra[3] = FXGETFLAG_COLORTYPE(alpha_flag) ? |
116 (alpha_flag >> 24) ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXGETF
LAG_ALPHA_STROKE(alpha_flag) : | 116 (alpha_flag >> 24) ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXGETF
LAG_ALPHA_STROKE(alpha_flag) : |
117 FXARGB_A(color); | 117 FXARGB_A(color); |
118 argb = FXARGB_MAKE(bgra[3], bgra[2], bgra[1], bgra[0]); | 118 argb = FXARGB_MAKE(bgra[3], bgra[2], bgra[1], bgra[0]); |
119 return; | 119 return; |
120 } | 120 } |
121 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), | 121 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), |
122 FXSYS_GetYValue(color), FXSYS_GetKValue(color), | 122 FXSYS_GetYValue(color), FXSYS_GetKValue(color), |
123 bgra[2], bgra[1], bgra[0]); | 123 bgra[2], bgra[1], bgra[0]); |
124 bgra[3] = (alpha_flag >> 24) ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXGETFLAG_
ALPHA_STROKE(alpha_flag); | 124 bgra[3] = (alpha_flag >> 24) ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXGETFLAG_
ALPHA_STROKE(alpha_flag); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 FX_Free(pGlyphAndPos); | 291 FX_Free(pGlyphAndPos); |
292 return FALSE; | 292 return FALSE; |
293 } | 293 } |
294 } else { | 294 } else { |
295 bitmap.Clear(0); | 295 bitmap.Clear(0); |
296 if (bitmap.m_pAlphaMask) { | 296 if (bitmap.m_pAlphaMask) { |
297 bitmap.m_pAlphaMask->Clear(0); | 297 bitmap.m_pAlphaMask->Clear(0); |
298 } | 298 } |
299 } | 299 } |
300 int dest_width = pixel_width; | 300 int dest_width = pixel_width; |
301 FX_LPBYTE dest_buf = bitmap.GetBuffer(); | 301 uint8_t* dest_buf = bitmap.GetBuffer(); |
302 int dest_pitch = bitmap.GetPitch(); | 302 int dest_pitch = bitmap.GetPitch(); |
303 int Bpp = bitmap.GetBPP() / 8; | 303 int Bpp = bitmap.GetBPP() / 8; |
304 int a, r, g, b; | 304 int a, r, g, b; |
305 if (anti_alias == FXFT_RENDER_MODE_LCD) { | 305 if (anti_alias == FXFT_RENDER_MODE_LCD) { |
306 _Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransfor
m); | 306 _Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransfor
m); |
307 ArgbDecode(fill_color, a, r, g, b); | 307 ArgbDecode(fill_color, a, r, g, b); |
308 r = FX_GAMMA(r); | 308 r = FX_GAMMA(r); |
309 g = FX_GAMMA(g); | 309 g = FX_GAMMA(g); |
310 b = FX_GAMMA(b); | 310 b = FX_GAMMA(b); |
311 } | 311 } |
(...skipping 11 matching lines...) Expand all Loading... |
323 if (!bitmap.CompositeMask(left, top, ncols, nrows, pGlyph, fill_colo
r, | 323 if (!bitmap.CompositeMask(left, top, ncols, nrows, pGlyph, fill_colo
r, |
324 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alp
ha_flag, pIccTransform)) { | 324 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alp
ha_flag, pIccTransform)) { |
325 FX_Free(pGlyphAndPos); | 325 FX_Free(pGlyphAndPos); |
326 return FALSE; | 326 return FALSE; |
327 } | 327 } |
328 continue; | 328 continue; |
329 } | 329 } |
330 FX_BOOL bBGRStripe = text_flags & FXTEXT_BGR_STRIPE; | 330 FX_BOOL bBGRStripe = text_flags & FXTEXT_BGR_STRIPE; |
331 ncols /= 3; | 331 ncols /= 3; |
332 int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3; | 332 int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3; |
333 FX_LPBYTE src_buf = pGlyph->GetBuffer(); | 333 uint8_t* src_buf = pGlyph->GetBuffer(); |
334 int src_pitch = pGlyph->GetPitch(); | 334 int src_pitch = pGlyph->GetPitch(); |
335 int start_col = left; | 335 int start_col = left; |
336 if (start_col < 0) { | 336 if (start_col < 0) { |
337 start_col = 0; | 337 start_col = 0; |
338 } | 338 } |
339 int end_col = left + ncols; | 339 int end_col = left + ncols; |
340 if (end_col > dest_width) { | 340 if (end_col > dest_width) { |
341 end_col = dest_width; | 341 end_col = dest_width; |
342 } | 342 } |
343 if (start_col >= end_col) { | 343 if (start_col >= end_col) { |
344 continue; | 344 continue; |
345 } | 345 } |
346 if (bitmap.GetFormat() == FXDIB_Argb) { | 346 if (bitmap.GetFormat() == FXDIB_Argb) { |
347 for (int row = 0; row < nrows; row ++) { | 347 for (int row = 0; row < nrows; row ++) { |
348 int dest_row = row + top; | 348 int dest_row = row + top; |
349 if (dest_row < 0 || dest_row >= bitmap.GetHeight()) { | 349 if (dest_row < 0 || dest_row >= bitmap.GetHeight()) { |
350 continue; | 350 continue; |
351 } | 351 } |
352 FX_LPBYTE src_scan = src_buf + row * src_pitch + (start_col - le
ft) * 3; | 352 uint8_t* src_scan = src_buf + row * src_pitch + (start_col - lef
t) * 3; |
353 FX_LPBYTE dest_scan = dest_buf + dest_row * dest_pitch + (start_
col << 2); | 353 uint8_t* dest_scan = dest_buf + dest_row * dest_pitch + (start_c
ol << 2); |
354 if (bBGRStripe) { | 354 if (bBGRStripe) { |
355 if (x_subpixel == 0) { | 355 if (x_subpixel == 0) { |
356 for (int col = start_col; col < end_col; col ++) { | 356 for (int col = start_col; col < end_col; col ++) { |
357 int src_alpha = src_scan[2]; | 357 int src_alpha = src_scan[2]; |
358 src_alpha = src_alpha * a / 255; | 358 src_alpha = src_alpha * a / 255; |
359 dest_scan[2] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX
_GAMMA(dest_scan[2]), r, src_alpha)); | 359 dest_scan[2] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX
_GAMMA(dest_scan[2]), r, src_alpha)); |
360 src_alpha = src_scan[1]; | 360 src_alpha = src_scan[1]; |
361 src_alpha = src_alpha * a / 255; | 361 src_alpha = src_alpha * a / 255; |
362 dest_scan[1] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX
_GAMMA(dest_scan[1]), g, src_alpha)); | 362 dest_scan[1] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX
_GAMMA(dest_scan[1]), g, src_alpha)); |
363 src_alpha = src_scan[0]; | 363 src_alpha = src_scan[0]; |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 } | 655 } |
656 } | 656 } |
657 } | 657 } |
658 } | 658 } |
659 } else { | 659 } else { |
660 for (int row = 0; row < nrows; row ++) { | 660 for (int row = 0; row < nrows; row ++) { |
661 int dest_row = row + top; | 661 int dest_row = row + top; |
662 if (dest_row < 0 || dest_row >= bitmap.GetHeight()) { | 662 if (dest_row < 0 || dest_row >= bitmap.GetHeight()) { |
663 continue; | 663 continue; |
664 } | 664 } |
665 FX_LPBYTE src_scan = src_buf + row * src_pitch + (start_col - le
ft) * 3; | 665 uint8_t* src_scan = src_buf + row * src_pitch + (start_col - lef
t) * 3; |
666 FX_LPBYTE dest_scan = dest_buf + dest_row * dest_pitch + start_c
ol * Bpp; | 666 uint8_t* dest_scan = dest_buf + dest_row * dest_pitch + start_co
l * Bpp; |
667 if (bBGRStripe) { | 667 if (bBGRStripe) { |
668 if (x_subpixel == 0) { | 668 if (x_subpixel == 0) { |
669 for (int col = start_col; col < end_col; col ++) { | 669 for (int col = start_col; col < end_col; col ++) { |
670 int src_alpha = src_scan[2]; | 670 int src_alpha = src_scan[2]; |
671 ADJUST_ALPHA(dest_scan[2], r, src_alpha, nativetext_
flags, a); | 671 ADJUST_ALPHA(dest_scan[2], r, src_alpha, nativetext_
flags, a); |
672 src_alpha = src_alpha * a / 255; | 672 src_alpha = src_alpha * a / 255; |
673 dest_scan[2] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX
_GAMMA(dest_scan[2]), r, src_alpha)); | 673 dest_scan[2] = FX_GAMMA_INVERSE(FXDIB_ALPHA_MERGE(FX
_GAMMA(dest_scan[2]), r, src_alpha)); |
674 src_alpha = src_scan[1]; | 674 src_alpha = src_scan[1]; |
675 ADJUST_ALPHA(dest_scan[1], g, src_alpha, nativetext_
flags, a); | 675 ADJUST_ALPHA(dest_scan[1], g, src_alpha, nativetext_
flags, a); |
676 src_alpha = src_alpha * a / 255; | 676 src_alpha = src_alpha * a / 255; |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 { | 1038 { |
1039 FX_POSITION pos = m_SizeMap.GetStartPosition(); | 1039 FX_POSITION pos = m_SizeMap.GetStartPosition(); |
1040 CFX_ByteString Key; | 1040 CFX_ByteString Key; |
1041 CFX_SizeGlyphCache* pSizeCache = NULL; | 1041 CFX_SizeGlyphCache* pSizeCache = NULL; |
1042 while(pos) { | 1042 while(pos) { |
1043 m_SizeMap.GetNextAssoc( pos, Key, (void*&)pSizeCache); | 1043 m_SizeMap.GetNextAssoc( pos, Key, (void*&)pSizeCache); |
1044 delete pSizeCache; | 1044 delete pSizeCache; |
1045 } | 1045 } |
1046 m_SizeMap.RemoveAll(); | 1046 m_SizeMap.RemoveAll(); |
1047 pos = m_PathMap.GetStartPosition(); | 1047 pos = m_PathMap.GetStartPosition(); |
1048 FX_LPVOID key1; | 1048 void* key1; |
1049 CFX_PathData* pPath; | 1049 CFX_PathData* pPath; |
1050 while (pos) { | 1050 while (pos) { |
1051 m_PathMap.GetNextAssoc(pos, key1, (FX_LPVOID&)pPath); | 1051 m_PathMap.GetNextAssoc(pos, key1, (void*&)pPath); |
1052 delete pPath; | 1052 delete pPath; |
1053 } | 1053 } |
1054 if (m_pBitmap) { | 1054 if (m_pBitmap) { |
1055 delete m_pBitmap; | 1055 delete m_pBitmap; |
1056 } | 1056 } |
1057 m_PathMap.RemoveAll(); | 1057 m_PathMap.RemoveAll(); |
1058 } | 1058 } |
1059 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 1059 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
1060 void CFX_FaceCache::InitPlatform() | 1060 void CFX_FaceCache::InitPlatform() |
1061 { | 1061 { |
1062 } | 1062 } |
1063 #endif | 1063 #endif |
1064 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Aff
ineMatrix* pMatrix, | 1064 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Aff
ineMatrix* pMatrix, |
1065 CFX_ByteStringC& FaceGlyphsKey, FX_DWORD glyph_index, FX_BOOL bFontStyle
, | 1065 CFX_ByteStringC& FaceGlyphsKey, FX_DWORD glyph_index, FX_BOOL bFontStyle
, |
1066 int dest_width, int anti_alias) | 1066 int dest_width, int anti_alias) |
1067 { | 1067 { |
1068 CFX_SizeGlyphCache* pSizeCache = NULL; | 1068 CFX_SizeGlyphCache* pSizeCache = NULL; |
1069 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { | 1069 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { |
1070 pSizeCache = new CFX_SizeGlyphCache; | 1070 pSizeCache = new CFX_SizeGlyphCache; |
1071 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); | 1071 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); |
1072 } | 1072 } |
1073 CFX_GlyphBitmap* pGlyphBitmap = NULL; | 1073 CFX_GlyphBitmap* pGlyphBitmap = NULL; |
1074 if (pSizeCache->m_GlyphMap.Lookup((FX_LPVOID)(uintptr_t)glyph_index, (void*&
)pGlyphBitmap)) { | 1074 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, (void*&)pGl
yphBitmap)) { |
1075 return pGlyphBitmap; | 1075 return pGlyphBitmap; |
1076 } | 1076 } |
1077 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix, dest_wid
th, anti_alias); | 1077 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix, dest_wid
th, anti_alias); |
1078 if (pGlyphBitmap == NULL) { | 1078 if (pGlyphBitmap == NULL) { |
1079 return NULL; | 1079 return NULL; |
1080 } | 1080 } |
1081 pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(uintptr_t)glyph_index, pGlyphBitmap
); | 1081 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); |
1082 return pGlyphBitmap; | 1082 return pGlyphBitmap; |
1083 } | 1083 } |
1084 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD
glyph_index, FX_BOOL bFontStyle, const CFX_AffineMatrix* pMatrix, | 1084 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD
glyph_index, FX_BOOL bFontStyle, const CFX_AffineMatrix* pMatrix, |
1085 int dest_width, int anti_alias, int& text_flags) | 1085 int dest_width, int anti_alias, int& text_flags) |
1086 { | 1086 { |
1087 if (glyph_index == (FX_DWORD) - 1) { | 1087 if (glyph_index == (FX_DWORD) - 1) { |
1088 return NULL; | 1088 return NULL; |
1089 } | 1089 } |
1090 _CFX_UniqueKeyGen keygen; | 1090 _CFX_UniqueKeyGen keygen; |
1091 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 1091 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
(...skipping 26 matching lines...) Expand all Loading... |
1118 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); | 1118 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); |
1119 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 1119 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
1120 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontSt
yle, dest_width, anti_alias); | 1120 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontSt
yle, dest_width, anti_alias); |
1121 #else | 1121 #else |
1122 if (text_flags & FXTEXT_NO_NATIVETEXT) { | 1122 if (text_flags & FXTEXT_NO_NATIVETEXT) { |
1123 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFo
ntStyle, dest_width, anti_alias); | 1123 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFo
ntStyle, dest_width, anti_alias); |
1124 } else { | 1124 } else { |
1125 CFX_GlyphBitmap* pGlyphBitmap; | 1125 CFX_GlyphBitmap* pGlyphBitmap; |
1126 CFX_SizeGlyphCache* pSizeCache = NULL; | 1126 CFX_SizeGlyphCache* pSizeCache = NULL; |
1127 if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { | 1127 if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { |
1128 if (pSizeCache->m_GlyphMap.Lookup((FX_LPVOID)(uintptr_t)glyph_index,
(void*&)pGlyphBitmap)) { | 1128 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, (vo
id*&)pGlyphBitmap)) { |
1129 return pGlyphBitmap; | 1129 return pGlyphBitmap; |
1130 } | 1130 } |
1131 pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, d
est_width, anti_alias); | 1131 pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, d
est_width, anti_alias); |
1132 if (pGlyphBitmap) { | 1132 if (pGlyphBitmap) { |
1133 pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(uintptr_t)glyph_index,
pGlyphBitmap); | 1133 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGly
phBitmap); |
1134 return pGlyphBitmap; | 1134 return pGlyphBitmap; |
1135 } | 1135 } |
1136 } else { | 1136 } else { |
1137 pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, d
est_width, anti_alias); | 1137 pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, d
est_width, anti_alias); |
1138 if (pGlyphBitmap) { | 1138 if (pGlyphBitmap) { |
1139 pSizeCache = new CFX_SizeGlyphCache; | 1139 pSizeCache = new CFX_SizeGlyphCache; |
1140 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); | 1140 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); |
1141 pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(uintptr_t)glyph_index,
pGlyphBitmap); | 1141 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGly
phBitmap); |
1142 return pGlyphBitmap; | 1142 return pGlyphBitmap; |
1143 } | 1143 } |
1144 } | 1144 } |
1145 if (pFont->GetSubstFont()) | 1145 if (pFont->GetSubstFont()) |
1146 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), | 1146 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), |
1147 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias, | 1147 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias, |
1148 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont
()->m_ItalicAngle, pFont->IsVertical()); | 1148 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont
()->m_ItalicAngle, pFont->IsVertical()); |
1149 else | 1149 else |
1150 keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), | 1150 keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), |
1151 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias); | 1151 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias); |
1152 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); | 1152 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); |
1153 text_flags |= FXTEXT_NO_NATIVETEXT; | 1153 text_flags |= FXTEXT_NO_NATIVETEXT; |
1154 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFo
ntStyle, dest_width, anti_alias); | 1154 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFo
ntStyle, dest_width, anti_alias); |
1155 } | 1155 } |
1156 #endif | 1156 #endif |
1157 } | 1157 } |
1158 CFX_SizeGlyphCache::~CFX_SizeGlyphCache() | 1158 CFX_SizeGlyphCache::~CFX_SizeGlyphCache() |
1159 { | 1159 { |
1160 FX_POSITION pos = m_GlyphMap.GetStartPosition(); | 1160 FX_POSITION pos = m_GlyphMap.GetStartPosition(); |
1161 FX_LPVOID Key; | 1161 void* Key; |
1162 CFX_GlyphBitmap* pGlyphBitmap = NULL; | 1162 CFX_GlyphBitmap* pGlyphBitmap = NULL; |
1163 while(pos) { | 1163 while(pos) { |
1164 m_GlyphMap.GetNextAssoc(pos, Key, (void*&)pGlyphBitmap); | 1164 m_GlyphMap.GetNextAssoc(pos, Key, (void*&)pGlyphBitmap); |
1165 delete pGlyphBitmap; | 1165 delete pGlyphBitmap; |
1166 } | 1166 } |
1167 m_GlyphMap.RemoveAll(); | 1167 m_GlyphMap.RemoveAll(); |
1168 } | 1168 } |
1169 #define CONTRAST_RAMP_STEP 1 | 1169 #define CONTRAST_RAMP_STEP 1 |
1170 void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) | 1170 void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) |
1171 { | 1171 { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 52, 52, 53, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 55, 55, 56, 56, | 1225 52, 52, 53, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 55, 55, 56, 56, |
1226 56, 56, 56, 57, 57, 57, 57, 57, 58, 58, 58, 58, 58, | 1226 56, 56, 56, 57, 57, 57, 57, 57, 58, 58, 58, 58, 58, |
1227 }; | 1227 }; |
1228 static const uint8_t g_WeightPow_SHIFTJIS[WEIGHTPOW_ARRAY_SIZE] = { | 1228 static const uint8_t g_WeightPow_SHIFTJIS[WEIGHTPOW_ARRAY_SIZE] = { |
1229 0, 0, 1, 2, 3, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 21, 22, 24, 26, 28, | 1229 0, 0, 1, 2, 3, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 21, 22, 24, 26, 28, |
1230 30, 32, 33, 35, 37, 39, 41, 43, 45, 48, 48, 48, 48, 49, 49, 49, 50, 50, 50,
50, | 1230 30, 32, 33, 35, 37, 39, 41, 43, 45, 48, 48, 48, 48, 49, 49, 49, 50, 50, 50,
50, |
1231 51, 51, 51, 51, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54,
55, 55, | 1231 51, 51, 51, 51, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54,
55, 55, |
1232 55, 55, 55, 56, 56, 56, 56, 56 , 56, 57, 57, 57 , 57 , 57, 57, 57, 58, 58, 5
8, 58, 58, | 1232 55, 55, 55, 56, 56, 56, 56, 56 , 56, 57, 57, 57 , 57 , 57, 57, 57, 58, 58, 5
8, 58, 58, |
1233 58, 58, 59, 59, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 60, 60, | 1233 58, 58, 59, 59, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 60, 60, |
1234 }; | 1234 }; |
1235 static void _GammaAdjust(FX_LPBYTE pData, int nWid, int nHei, int src_pitch, FX_
LPCBYTE gammaTable) | 1235 static void _GammaAdjust(uint8_t* pData, int nWid, int nHei, int src_pitch, cons
t uint8_t* gammaTable) |
1236 { | 1236 { |
1237 int count = nHei * src_pitch; | 1237 int count = nHei * src_pitch; |
1238 for(int i = 0; i < count; i++) { | 1238 for(int i = 0; i < count; i++) { |
1239 pData[i] = gammaTable[pData[i]]; | 1239 pData[i] = gammaTable[pData[i]]; |
1240 } | 1240 } |
1241 } | 1241 } |
1242 static void _ContrastAdjust(FX_LPBYTE pDataIn, FX_LPBYTE pDataOut, int nWid, int
nHei, int nSrcRowBytes, int nDstRowBytes) | 1242 static void _ContrastAdjust(uint8_t* pDataIn, uint8_t* pDataOut, int nWid, int n
Hei, int nSrcRowBytes, int nDstRowBytes) |
1243 { | 1243 { |
1244 int col, row, temp; | 1244 int col, row, temp; |
1245 int max = 0, min = 255; | 1245 int max = 0, min = 255; |
1246 FX_FLOAT rate; | 1246 FX_FLOAT rate; |
1247 for (row = 0; row < nHei; row ++) { | 1247 for (row = 0; row < nHei; row ++) { |
1248 FX_LPBYTE pRow = pDataIn + row * nSrcRowBytes; | 1248 uint8_t* pRow = pDataIn + row * nSrcRowBytes; |
1249 for (col = 0; col < nWid; col++) { | 1249 for (col = 0; col < nWid; col++) { |
1250 temp = *pRow ++; | 1250 temp = *pRow ++; |
1251 if (temp > max) { | 1251 if (temp > max) { |
1252 max = temp; | 1252 max = temp; |
1253 } | 1253 } |
1254 if (temp < min) { | 1254 if (temp < min) { |
1255 min = temp; | 1255 min = temp; |
1256 } | 1256 } |
1257 } | 1257 } |
1258 } | 1258 } |
1259 temp = max - min; | 1259 temp = max - min; |
1260 if (0 == temp || 255 == temp) { | 1260 if (0 == temp || 255 == temp) { |
1261 int rowbytes = FXSYS_abs(nSrcRowBytes) > nDstRowBytes ? nDstRowBytes : F
XSYS_abs(nSrcRowBytes); | 1261 int rowbytes = FXSYS_abs(nSrcRowBytes) > nDstRowBytes ? nDstRowBytes : F
XSYS_abs(nSrcRowBytes); |
1262 for (row = 0; row < nHei; row ++) { | 1262 for (row = 0; row < nHei; row ++) { |
1263 FXSYS_memcpy32(pDataOut + row * nDstRowBytes, pDataIn + row * nSrcRo
wBytes, rowbytes); | 1263 FXSYS_memcpy32(pDataOut + row * nDstRowBytes, pDataIn + row * nSrcRo
wBytes, rowbytes); |
1264 } | 1264 } |
1265 return; | 1265 return; |
1266 } | 1266 } |
1267 rate = 255.f / temp; | 1267 rate = 255.f / temp; |
1268 for (row = 0; row < nHei; row ++) { | 1268 for (row = 0; row < nHei; row ++) { |
1269 FX_LPBYTE pSrcRow = pDataIn + row * nSrcRowBytes; | 1269 uint8_t* pSrcRow = pDataIn + row * nSrcRowBytes; |
1270 FX_LPBYTE pDstRow = pDataOut + row * nDstRowBytes; | 1270 uint8_t* pDstRow = pDataOut + row * nDstRowBytes; |
1271 for (col = 0; col < nWid; col ++) { | 1271 for (col = 0; col < nWid; col ++) { |
1272 temp = (int)((*(pSrcRow++) - min) * rate + 0.5); | 1272 temp = (int)((*(pSrcRow++) - min) * rate + 0.5); |
1273 if (temp > 255) { | 1273 if (temp > 255) { |
1274 temp = 255; | 1274 temp = 255; |
1275 } else if (temp < 0) { | 1275 } else if (temp < 0) { |
1276 temp = 0; | 1276 temp = 0; |
1277 } | 1277 } |
1278 *pDstRow ++ = (uint8_t)temp; | 1278 *pDstRow ++ = (uint8_t)temp; |
1279 } | 1279 } |
1280 } | 1280 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 return FALSE; | 1400 return FALSE; |
1401 } | 1401 } |
1402 error = FXFT_Render_Glyph(face, FXFT_RENDER_MODE_NORMAL); | 1402 error = FXFT_Render_Glyph(face, FXFT_RENDER_MODE_NORMAL); |
1403 if (error) { | 1403 if (error) { |
1404 return FALSE; | 1404 return FALSE; |
1405 } | 1405 } |
1406 int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(face)); | 1406 int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(face)); |
1407 int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(face)); | 1407 int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(face)); |
1408 int left = FXFT_Get_Glyph_BitmapLeft(face); | 1408 int left = FXFT_Get_Glyph_BitmapLeft(face); |
1409 int top = FXFT_Get_Glyph_BitmapTop(face); | 1409 int top = FXFT_Get_Glyph_BitmapTop(face); |
1410 FX_LPCBYTE src_buf = (FX_LPCBYTE)FXFT_Get_Bitmap_Buffer(FXFT_Get_Glyph_Bitma
p(face)); | 1410 const uint8_t* src_buf = (const uint8_t*)FXFT_Get_Bitmap_Buffer(FXFT_Get_Gly
ph_Bitmap(face)); |
1411 int src_pitch = FXFT_Get_Bitmap_Pitch(FXFT_Get_Glyph_Bitmap(face)); | 1411 int src_pitch = FXFT_Get_Bitmap_Pitch(FXFT_Get_Glyph_Bitmap(face)); |
1412 CFX_DIBitmap mask; | 1412 CFX_DIBitmap mask; |
1413 mask.Create(bmwidth, bmheight, FXDIB_8bppMask); | 1413 mask.Create(bmwidth, bmheight, FXDIB_8bppMask); |
1414 FX_LPBYTE dest_buf = mask.GetBuffer(); | 1414 uint8_t* dest_buf = mask.GetBuffer(); |
1415 int dest_pitch = mask.GetPitch(); | 1415 int dest_pitch = mask.GetPitch(); |
1416 for (int row = 0; row < bmheight; row ++) { | 1416 for (int row = 0; row < bmheight; row ++) { |
1417 FX_LPCBYTE src_scan = src_buf + row * src_pitch; | 1417 const uint8_t* src_scan = src_buf + row * src_pitch; |
1418 FX_LPBYTE dest_scan = dest_buf + row * dest_pitch; | 1418 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
1419 FXSYS_memcpy32(dest_scan, src_scan, dest_pitch); | 1419 FXSYS_memcpy32(dest_scan, src_scan, dest_pitch); |
1420 } | 1420 } |
1421 pDib->CompositeMask(x + left, y - top, bmwidth, bmheight, &mask, argb, 0, 0)
; | 1421 pDib->CompositeMask(x + left, y - top, bmwidth, bmheight, &mask, argb, 0, 0)
; |
1422 return TRUE; | 1422 return TRUE; |
1423 } | 1423 } |
1424 FX_BOOL OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size, | 1424 FX_BOOL OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size, |
1425 CFX_AffineMatrix* pText_matrix, unsigned short const* text, u
nsigned long argb) | 1425 CFX_AffineMatrix* pText_matrix, unsigned short const* text, u
nsigned long argb) |
1426 { | 1426 { |
1427 if (!pFont) { | 1427 if (!pFont) { |
1428 return FALSE; | 1428 return FALSE; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 FX_BOOL ret = _OutputGlyph(dib, x, y, pFont, | 1476 FX_BOOL ret = _OutputGlyph(dib, x, y, pFont, |
1477 glyph_index, argb); | 1477 glyph_index, argb); |
1478 return ret; | 1478 return ret; |
1479 } | 1479 } |
1480 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, FX_DWORD glyph
_index, int dest_width) | 1480 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, FX_DWORD glyph
_index, int dest_width) |
1481 { | 1481 { |
1482 if (m_Face == NULL || glyph_index == (FX_DWORD) - 1) { | 1482 if (m_Face == NULL || glyph_index == (FX_DWORD) - 1) { |
1483 return NULL; | 1483 return NULL; |
1484 } | 1484 } |
1485 CFX_PathData* pGlyphPath = NULL; | 1485 CFX_PathData* pGlyphPath = NULL; |
1486 FX_LPVOID key; | 1486 void* key; |
1487 if (pFont->GetSubstFont()) | 1487 if (pFont->GetSubstFont()) |
1488 key = (FX_LPVOID)(uintptr_t)(glyph_index + ((pFont->GetSubstFont()->m_We
ight / 16) << 15) + | 1488 key = (void*)(uintptr_t)(glyph_index + ((pFont->GetSubstFont()->m_Weight
/ 16) << 15) + |
1489 ((pFont->GetSubstFont()->m_ItalicAngle / 2
) << 21) + ((dest_width / 16) << 25) + | 1489 ((pFont->GetSubstFont()->m_ItalicAngle / 2
) << 21) + ((dest_width / 16) << 25) + |
1490 (pFont->IsVertical() << 31)); | 1490 (pFont->IsVertical() << 31)); |
1491 else { | 1491 else { |
1492 key = (FX_LPVOID)(uintptr_t)glyph_index; | 1492 key = (void*)(uintptr_t)glyph_index; |
1493 } | 1493 } |
1494 if (m_PathMap.Lookup(key, (FX_LPVOID&)pGlyphPath)) { | 1494 if (m_PathMap.Lookup(key, (void*&)pGlyphPath)) { |
1495 return pGlyphPath; | 1495 return pGlyphPath; |
1496 } | 1496 } |
1497 pGlyphPath = pFont->LoadGlyphPath(glyph_index, dest_width); | 1497 pGlyphPath = pFont->LoadGlyphPath(glyph_index, dest_width); |
1498 m_PathMap.SetAt(key, pGlyphPath); | 1498 m_PathMap.SetAt(key, pGlyphPath); |
1499 return pGlyphPath; | 1499 return pGlyphPath; |
1500 } | 1500 } |
1501 typedef struct { | 1501 typedef struct { |
1502 FX_BOOL m_bCount; | 1502 FX_BOOL m_bCount; |
1503 int m_PointCount; | 1503 int m_PointCount; |
1504 FX_PATHPOINT* m_pPoints; | 1504 FX_PATHPOINT* m_pPoints; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 { | 1672 { |
1673 va_list argList; | 1673 va_list argList; |
1674 va_start(argList, count); | 1674 va_start(argList, count); |
1675 for (int i = 0; i < count; i ++) { | 1675 for (int i = 0; i < count; i ++) { |
1676 int p = va_arg(argList, int); | 1676 int p = va_arg(argList, int); |
1677 ((FX_DWORD*)m_Key)[i] = p; | 1677 ((FX_DWORD*)m_Key)[i] = p; |
1678 } | 1678 } |
1679 va_end(argList); | 1679 va_end(argList); |
1680 m_KeyLen = count * sizeof(FX_DWORD); | 1680 m_KeyLen = count * sizeof(FX_DWORD); |
1681 } | 1681 } |
OLD | NEW |