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 28 matching lines...) Expand all Loading... |
39 | 39 |
40 private: | 40 private: |
41 FT_Face m_Face; | 41 FT_Face m_Face; |
42 }; | 42 }; |
43 | 43 |
44 } | 44 } |
45 | 45 |
46 FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos, int nChars, int anti_a
lias, FX_FLOAT retinaScaleX, FX_FLOAT retinaScaleY) | 46 FX_RECT FXGE_GetGlyphsBBox(FXTEXT_GLYPHPOS* pGlyphAndPos, int nChars, int anti_a
lias, FX_FLOAT retinaScaleX, FX_FLOAT retinaScaleY) |
47 { | 47 { |
48 FX_RECT rect(0, 0, 0, 0); | 48 FX_RECT rect(0, 0, 0, 0); |
49 bool bStarted = false; | 49 FX_BOOL bStarted = FALSE; |
50 for (int iChar = 0; iChar < nChars; iChar ++) { | 50 for (int iChar = 0; iChar < nChars; iChar ++) { |
51 FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar]; | 51 FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar]; |
52 const CFX_GlyphBitmap* pGlyph = glyph.m_pGlyph; | 52 const CFX_GlyphBitmap* pGlyph = glyph.m_pGlyph; |
53 if (pGlyph == NULL) { | 53 if (pGlyph == NULL) { |
54 continue; | 54 continue; |
55 } | 55 } |
56 int char_left = glyph.m_OriginX + pGlyph->m_Left; | 56 int char_left = glyph.m_OriginX + pGlyph->m_Left; |
57 int char_width = (int)(pGlyph->m_Bitmap.GetWidth() / retinaScaleX); | 57 int char_width = (int)(pGlyph->m_Bitmap.GetWidth() / retinaScaleX); |
58 if (anti_alias == FXFT_RENDER_MODE_LCD) { | 58 if (anti_alias == FXFT_RENDER_MODE_LCD) { |
59 char_width /= 3; | 59 char_width /= 3; |
60 } | 60 } |
61 int char_right = char_left + char_width; | 61 int char_right = char_left + char_width; |
62 int char_top = glyph.m_OriginY - pGlyph->m_Top; | 62 int char_top = glyph.m_OriginY - pGlyph->m_Top; |
63 int char_bottom = char_top + (int)(pGlyph->m_Bitmap.GetHeight() / retina
ScaleY); | 63 int char_bottom = char_top + (int)(pGlyph->m_Bitmap.GetHeight() / retina
ScaleY); |
64 if (!bStarted) { | 64 if (!bStarted) { |
65 rect.left = char_left; | 65 rect.left = char_left; |
66 rect.right = char_right; | 66 rect.right = char_right; |
67 rect.top = char_top; | 67 rect.top = char_top; |
68 rect.bottom = char_bottom; | 68 rect.bottom = char_bottom; |
69 bStarted = true; | 69 bStarted = TRUE; |
70 } else { | 70 } else { |
71 if (rect.left > char_left) { | 71 if (rect.left > char_left) { |
72 rect.left = char_left; | 72 rect.left = char_left; |
73 } | 73 } |
74 if (rect.right < char_right) { | 74 if (rect.right < char_right) { |
75 rect.right = char_right; | 75 rect.right = char_right; |
76 } | 76 } |
77 if (rect.top > char_top) { | 77 if (rect.top > char_top) { |
78 rect.top = char_top; | 78 rect.top = char_top; |
79 } | 79 } |
80 if (rect.bottom < char_bottom) { | 80 if (rect.bottom < char_bottom) { |
81 rect.bottom = char_bottom; | 81 rect.bottom = char_bottom; |
82 } | 82 } |
83 } | 83 } |
84 } | 84 } |
85 return rect; | 85 return rect; |
86 } | 86 } |
87 static void _AdjustGlyphSpace(FXTEXT_GLYPHPOS* pGlyphAndPos, int nChars) | 87 static void _AdjustGlyphSpace(FXTEXT_GLYPHPOS* pGlyphAndPos, int nChars) |
88 { | 88 { |
89 ASSERT(nChars > 1); | 89 ASSERT(nChars > 1); |
90 bool bVertical = false; | 90 FX_BOOL bVertical = FALSE; |
91 if (pGlyphAndPos[nChars - 1].m_OriginX == pGlyphAndPos[0].m_OriginX) { | 91 if (pGlyphAndPos[nChars - 1].m_OriginX == pGlyphAndPos[0].m_OriginX) { |
92 bVertical = true; | 92 bVertical = TRUE; |
93 } else if (pGlyphAndPos[nChars - 1].m_OriginY != pGlyphAndPos[0].m_OriginY)
{ | 93 } else if (pGlyphAndPos[nChars - 1].m_OriginY != pGlyphAndPos[0].m_OriginY)
{ |
94 return; | 94 return; |
95 } | 95 } |
96 int i = nChars - 1; | 96 int i = nChars - 1; |
97 int* next_origin = bVertical ? &pGlyphAndPos[i].m_OriginY : &pGlyphAndPos[i]
.m_OriginX; | 97 int* next_origin = bVertical ? &pGlyphAndPos[i].m_OriginY : &pGlyphAndPos[i]
.m_OriginX; |
98 FX_FLOAT next_origin_f = bVertical ? pGlyphAndPos[i].m_fOriginY : pGlyphAndP
os[i].m_fOriginX; | 98 FX_FLOAT next_origin_f = bVertical ? pGlyphAndPos[i].m_fOriginY : pGlyphAndP
os[i].m_fOriginX; |
99 for (i --; i > 0; i --) { | 99 for (i --; i > 0; i --) { |
100 int* this_origin = bVertical ? &pGlyphAndPos[i].m_OriginY : &pGlyphAndPo
s[i].m_OriginX; | 100 int* this_origin = bVertical ? &pGlyphAndPos[i].m_OriginY : &pGlyphAndPo
s[i].m_OriginX; |
101 FX_FLOAT this_origin_f = bVertical ? pGlyphAndPos[i].m_fOriginY : pGlyph
AndPos[i].m_fOriginX; | 101 FX_FLOAT this_origin_f = bVertical ? pGlyphAndPos[i].m_fOriginY : pGlyph
AndPos[i].m_fOriginX; |
102 int space = (*next_origin) - (*this_origin); | 102 int space = (*next_origin) - (*this_origin); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 FXARGB_A(color); | 148 FXARGB_A(color); |
149 argb = FXARGB_MAKE(bgra[3], bgra[2], bgra[1], bgra[0]); | 149 argb = FXARGB_MAKE(bgra[3], bgra[2], bgra[1], bgra[0]); |
150 return; | 150 return; |
151 } | 151 } |
152 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), | 152 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), |
153 FXSYS_GetYValue(color), FXSYS_GetKValue(color), | 153 FXSYS_GetYValue(color), FXSYS_GetKValue(color), |
154 bgra[2], bgra[1], bgra[0]); | 154 bgra[2], bgra[1], bgra[0]); |
155 bgra[3] = (alpha_flag >> 24) ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXGETFLAG_
ALPHA_STROKE(alpha_flag); | 155 bgra[3] = (alpha_flag >> 24) ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXGETFLAG_
ALPHA_STROKE(alpha_flag); |
156 argb = FXARGB_MAKE(bgra[3], bgra[2], bgra[1], bgra[0]); | 156 argb = FXARGB_MAKE(bgra[3], bgra[2], bgra[1], bgra[0]); |
157 } | 157 } |
158 bool CFX_RenderDevice::DrawNormalText(int nChars, const FXTEXT_CHARPOS* pCharPos
, | 158 FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, const FXTEXT_CHARPOS* pChar
Pos, |
159 CFX_Font* pFont, CFX_FontCache* pCache, | 159 CFX_Font* pFont, CFX_FontCache* pCache, |
160 FX_FLOAT font_size, const CFX_AffineMatrix* pText2Device, | 160 FX_FLOAT font_size, const CFX_AffineMatrix* pText2Device, |
161 FX_DWORD fill_color, FX_DWORD text_flags, | 161 FX_DWORD fill_color, FX_DWORD text_flags, |
162 int alpha_flag, void* pIccTransform) | 162 int alpha_flag, void* pIccTransform) |
163 { | 163 { |
164 int nativetext_flags = text_flags; | 164 int nativetext_flags = text_flags; |
165 if (m_DeviceClass != FXDC_DISPLAY) { | 165 if (m_DeviceClass != FXDC_DISPLAY) { |
166 if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) { | 166 if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) { |
167 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 167 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
168 if (!(text_flags & FXFONT_CIDFONT) && pFont->GetPsName().Find(CFX_Wi
deString::FromLocal("+ZJHL")) == -1) | 168 if (!(text_flags & FXFONT_CIDFONT) && pFont->GetPsName().Find(CFX_Wi
deString::FromLocal("+ZJHL")) == -1) |
169 #ifdef FOXIT_CHROME_BUILD | 169 #ifdef FOXIT_CHROME_BUILD |
170 if (pFont->GetPsName() != CFX_WideString::FromLocal("CNAAJI+cmex
10")) | 170 if (pFont->GetPsName() != CFX_WideString::FromLocal("CNAAJI+cmex
10")) |
171 #endif | 171 #endif |
172 #endif | 172 #endif |
173 if (m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont,
pCache, pText2Device, font_size, fill_color, alpha_flag, pIccTransform)) { | 173 if (m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont,
pCache, pText2Device, font_size, fill_color, alpha_flag, pIccTransform)) { |
174 return true; | 174 return TRUE; |
175 } | 175 } |
176 } | 176 } |
177 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha
_flag) : FXARGB_A(fill_color); | 177 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha
_flag) : FXARGB_A(fill_color); |
178 if (alpha < 255) { | 178 if (alpha < 255) { |
179 return false; | 179 return FALSE; |
180 } | 180 } |
181 } else if (!(text_flags & FXTEXT_NO_NATIVETEXT)) { | 181 } else if (!(text_flags & FXTEXT_NO_NATIVETEXT)) { |
182 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 182 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
183 if (!(text_flags & FXFONT_CIDFONT)) | 183 if (!(text_flags & FXFONT_CIDFONT)) |
184 #ifdef FOXIT_CHROME_BUILD | 184 #ifdef FOXIT_CHROME_BUILD |
185 if (pFont->GetPsName() != CFX_WideString::FromLocal("CNAAJI+cmex10")
) | 185 if (pFont->GetPsName() != CFX_WideString::FromLocal("CNAAJI+cmex10")
) |
186 #endif | 186 #endif |
187 #endif | 187 #endif |
188 if (m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCa
che, pText2Device, font_size, fill_color, alpha_flag, pIccTransform)) { | 188 if (m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCa
che, pText2Device, font_size, fill_color, alpha_flag, pIccTransform)) { |
189 return true; | 189 return TRUE; |
190 } | 190 } |
191 } | 191 } |
192 CFX_AffineMatrix char2device, deviceCtm, text2Device; | 192 CFX_AffineMatrix char2device, deviceCtm, text2Device; |
193 if (pText2Device) { | 193 if (pText2Device) { |
194 char2device = *pText2Device; | 194 char2device = *pText2Device; |
195 text2Device = *pText2Device; | 195 text2Device = *pText2Device; |
196 } | 196 } |
197 char2device.Scale(font_size, -font_size); | 197 char2device.Scale(font_size, -font_size); |
198 if (FXSYS_fabs(char2device.a) + FXSYS_fabs(char2device.b) > 50 * 1.0f || | 198 if (FXSYS_fabs(char2device.a) + FXSYS_fabs(char2device.b) > 50 * 1.0f || |
199 ((m_DeviceClass == FXDC_PRINTER && !m_pDeviceDriver->IsPSPrintDriver
()) | 199 ((m_DeviceClass == FXDC_PRINTER && !m_pDeviceDriver->IsPSPrintDriver
()) |
200 && !(text_flags & FXTEXT_PRINTIMAGETEXT))) { | 200 && !(text_flags & FXTEXT_PRINTIMAGETEXT))) { |
201 if (pFont->GetFace() != NULL || (pFont->GetSubstFont()->m_SubstFlags & F
XFONT_SUBST_GLYPHPATH)) { | 201 if (pFont->GetFace() != NULL || (pFont->GetSubstFont()->m_SubstFlags & F
XFONT_SUBST_GLYPHPATH)) { |
202 int nPathFlags = (text_flags & FXTEXT_NOSMOOTH) == 0 ? 0 : FXFILL_NO
PATHSMOOTH; | 202 int nPathFlags = (text_flags & FXTEXT_NOSMOOTH) == 0 ? 0 : FXFILL_NO
PATHSMOOTH; |
203 return DrawTextPath(nChars, pCharPos, pFont, pCache, font_size, pTex
t2Device, NULL, NULL, fill_color, 0, NULL, nPathFlags, alpha_flag, pIccTransform
); | 203 return DrawTextPath(nChars, pCharPos, pFont, pCache, font_size, pTex
t2Device, NULL, NULL, fill_color, 0, NULL, nPathFlags, alpha_flag, pIccTransform
); |
204 } | 204 } |
205 } | 205 } |
206 int anti_alias = FXFT_RENDER_MODE_MONO; | 206 int anti_alias = FXFT_RENDER_MODE_MONO; |
207 bool bNormal = false; | 207 FX_BOOL bNormal = FALSE; |
208 if ((text_flags & FXTEXT_NOSMOOTH) == 0) { | 208 if ((text_flags & FXTEXT_NOSMOOTH) == 0) { |
209 if (m_DeviceClass == FXDC_DISPLAY && m_bpp > 1) { | 209 if (m_DeviceClass == FXDC_DISPLAY && m_bpp > 1) { |
210 bool bClearType; | 210 FX_BOOL bClearType; |
211 if (pFont->GetFace() == NULL && !(pFont->GetSubstFont()->m_SubstFlag
s & FXFONT_SUBST_CLEARTYPE)) { | 211 if (pFont->GetFace() == NULL && !(pFont->GetSubstFont()->m_SubstFlag
s & FXFONT_SUBST_CLEARTYPE)) { |
212 bClearType = false; | 212 bClearType = FALSE; |
213 } else { | 213 } else { |
214 bClearType = text_flags & FXTEXT_CLEARTYPE; | 214 bClearType = text_flags & FXTEXT_CLEARTYPE; |
215 } | 215 } |
216 if ((m_RenderCaps & (FXRC_ALPHA_OUTPUT | FXRC_CMYK_OUTPUT))) { | 216 if ((m_RenderCaps & (FXRC_ALPHA_OUTPUT | FXRC_CMYK_OUTPUT))) { |
217 anti_alias = FXFT_RENDER_MODE_LCD; | 217 anti_alias = FXFT_RENDER_MODE_LCD; |
218 bNormal = true; | 218 bNormal = TRUE; |
219 } else if (m_bpp < 16) { | 219 } else if (m_bpp < 16) { |
220 anti_alias = FXFT_RENDER_MODE_NORMAL; | 220 anti_alias = FXFT_RENDER_MODE_NORMAL; |
221 } else { | 221 } else { |
222 if (bClearType == false) { | 222 if (bClearType == FALSE) { |
223 anti_alias = FXFT_RENDER_MODE_LCD; | 223 anti_alias = FXFT_RENDER_MODE_LCD; |
224 bNormal = true; | 224 bNormal = TRUE; |
225 } else { | 225 } else { |
226 anti_alias = FXFT_RENDER_MODE_LCD; | 226 anti_alias = FXFT_RENDER_MODE_LCD; |
227 } | 227 } |
228 } | 228 } |
229 } | 229 } |
230 } | 230 } |
231 if (pCache == NULL) { | 231 if (pCache == NULL) { |
232 pCache = CFX_GEModule::Get()->GetFontCache(); | 232 pCache = CFX_GEModule::Get()->GetFontCache(); |
233 } | 233 } |
234 CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); | 234 CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 bmp_rect1.left--; | 271 bmp_rect1.left--; |
272 bmp_rect1.top --; | 272 bmp_rect1.top --; |
273 bmp_rect1.right ++; | 273 bmp_rect1.right ++; |
274 bmp_rect1.bottom ++; | 274 bmp_rect1.bottom ++; |
275 } | 275 } |
276 FX_RECT bmp_rect(FXSYS_round((FX_FLOAT)(bmp_rect1.left) / scale_x), FXSYS_ro
und((FX_FLOAT)(bmp_rect1.top) / scale_y), | 276 FX_RECT bmp_rect(FXSYS_round((FX_FLOAT)(bmp_rect1.left) / scale_x), FXSYS_ro
und((FX_FLOAT)(bmp_rect1.top) / scale_y), |
277 FXSYS_round((FX_FLOAT)bmp_rect1.right / scale_x), FXSYS_rou
nd((FX_FLOAT)bmp_rect1.bottom / scale_y)); | 277 FXSYS_round((FX_FLOAT)bmp_rect1.right / scale_x), FXSYS_rou
nd((FX_FLOAT)bmp_rect1.bottom / scale_y)); |
278 bmp_rect.Intersect(m_ClipBox); | 278 bmp_rect.Intersect(m_ClipBox); |
279 if (bmp_rect.IsEmpty()) { | 279 if (bmp_rect.IsEmpty()) { |
280 FX_Free(pGlyphAndPos); | 280 FX_Free(pGlyphAndPos); |
281 return true; | 281 return TRUE; |
282 } | 282 } |
283 int pixel_width = FXSYS_round(bmp_rect.Width() * scale_x); | 283 int pixel_width = FXSYS_round(bmp_rect.Width() * scale_x); |
284 int pixel_height = FXSYS_round(bmp_rect.Height() * scale_y); | 284 int pixel_height = FXSYS_round(bmp_rect.Height() * scale_y); |
285 int pixel_left = FXSYS_round(bmp_rect.left * scale_x); | 285 int pixel_left = FXSYS_round(bmp_rect.left * scale_x); |
286 int pixel_top = FXSYS_round(bmp_rect.top * scale_y); | 286 int pixel_top = FXSYS_round(bmp_rect.top * scale_y); |
287 if (anti_alias == FXFT_RENDER_MODE_MONO) { | 287 if (anti_alias == FXFT_RENDER_MODE_MONO) { |
288 CFX_DIBitmap bitmap; | 288 CFX_DIBitmap bitmap; |
289 if (!bitmap.Create(pixel_width, pixel_height, FXDIB_1bppMask)) { | 289 if (!bitmap.Create(pixel_width, pixel_height, FXDIB_1bppMask)) { |
290 FX_Free(pGlyphAndPos); | 290 FX_Free(pGlyphAndPos); |
291 return false; | 291 return FALSE; |
292 } | 292 } |
293 bitmap.Clear(0); | 293 bitmap.Clear(0); |
294 for (iChar = 0; iChar < nChars; iChar ++) { | 294 for (iChar = 0; iChar < nChars; iChar ++) { |
295 FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar]; | 295 FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar]; |
296 if (glyph.m_pGlyph == NULL) { | 296 if (glyph.m_pGlyph == NULL) { |
297 continue; | 297 continue; |
298 } | 298 } |
299 const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; | 299 const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; |
300 bitmap.TransferBitmap(glyph.m_OriginX + glyph.m_pGlyph->m_Left - pix
el_left, | 300 bitmap.TransferBitmap(glyph.m_OriginX + glyph.m_pGlyph->m_Left - pix
el_left, |
301 glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixe
l_top, | 301 glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixe
l_top, |
302 pGlyph->GetWidth(), pGlyph->GetHeight(), pGlyp
h, 0, 0); | 302 pGlyph->GetWidth(), pGlyph->GetHeight(), pGlyp
h, 0, 0); |
303 } | 303 } |
304 FX_Free(pGlyphAndPos); | 304 FX_Free(pGlyphAndPos); |
305 return SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); | 305 return SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); |
306 } | 306 } |
307 CFX_DIBitmap bitmap; | 307 CFX_DIBitmap bitmap; |
308 if (m_bpp == 8) { | 308 if (m_bpp == 8) { |
309 if (!bitmap.Create(pixel_width, pixel_height, FXDIB_8bppMask)) { | 309 if (!bitmap.Create(pixel_width, pixel_height, FXDIB_8bppMask)) { |
310 FX_Free(pGlyphAndPos); | 310 FX_Free(pGlyphAndPos); |
311 return false; | 311 return FALSE; |
312 } | 312 } |
313 } else { | 313 } else { |
314 if (!CreateCompatibleBitmap(&bitmap, pixel_width, pixel_height)) { | 314 if (!CreateCompatibleBitmap(&bitmap, pixel_width, pixel_height)) { |
315 FX_Free(pGlyphAndPos); | 315 FX_Free(pGlyphAndPos); |
316 return false; | 316 return FALSE; |
317 } | 317 } |
318 } | 318 } |
319 if (!bitmap.HasAlpha() && !bitmap.IsAlphaMask()) { | 319 if (!bitmap.HasAlpha() && !bitmap.IsAlphaMask()) { |
320 bitmap.Clear(0xFFFFFFFF); | 320 bitmap.Clear(0xFFFFFFFF); |
321 if (!GetDIBits(&bitmap, bmp_rect.left, bmp_rect.top)) { | 321 if (!GetDIBits(&bitmap, bmp_rect.left, bmp_rect.top)) { |
322 FX_Free(pGlyphAndPos); | 322 FX_Free(pGlyphAndPos); |
323 return false; | 323 return FALSE; |
324 } | 324 } |
325 } else { | 325 } else { |
326 bitmap.Clear(0); | 326 bitmap.Clear(0); |
327 if (bitmap.m_pAlphaMask) { | 327 if (bitmap.m_pAlphaMask) { |
328 bitmap.m_pAlphaMask->Clear(0); | 328 bitmap.m_pAlphaMask->Clear(0); |
329 } | 329 } |
330 } | 330 } |
331 int dest_width = pixel_width; | 331 int dest_width = pixel_width; |
332 uint8_t* dest_buf = bitmap.GetBuffer(); | 332 uint8_t* dest_buf = bitmap.GetBuffer(); |
333 int dest_pitch = bitmap.GetPitch(); | 333 int dest_pitch = bitmap.GetPitch(); |
(...skipping 11 matching lines...) Expand all Loading... |
345 if (glyph.m_pGlyph == NULL) { | 345 if (glyph.m_pGlyph == NULL) { |
346 continue; | 346 continue; |
347 } | 347 } |
348 const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; | 348 const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; |
349 int left = glyph.m_OriginX + glyph.m_pGlyph->m_Left - pixel_left; | 349 int left = glyph.m_OriginX + glyph.m_pGlyph->m_Left - pixel_left; |
350 int top = glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixel_top; | 350 int top = glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixel_top; |
351 int ncols = pGlyph->GetWidth(); | 351 int ncols = pGlyph->GetWidth(); |
352 int nrows = pGlyph->GetHeight(); | 352 int nrows = pGlyph->GetHeight(); |
353 if (anti_alias == FXFT_RENDER_MODE_NORMAL) { | 353 if (anti_alias == FXFT_RENDER_MODE_NORMAL) { |
354 if (!bitmap.CompositeMask(left, top, ncols, nrows, pGlyph, fill_colo
r, | 354 if (!bitmap.CompositeMask(left, top, ncols, nrows, pGlyph, fill_colo
r, |
355 0, 0, FXDIB_BLEND_NORMAL, NULL, false, alp
ha_flag, pIccTransform)) { | 355 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alp
ha_flag, pIccTransform)) { |
356 FX_Free(pGlyphAndPos); | 356 FX_Free(pGlyphAndPos); |
357 return false; | 357 return FALSE; |
358 } | 358 } |
359 continue; | 359 continue; |
360 } | 360 } |
361 bool bBGRStripe = text_flags & FXTEXT_BGR_STRIPE; | 361 FX_BOOL bBGRStripe = text_flags & FXTEXT_BGR_STRIPE; |
362 ncols /= 3; | 362 ncols /= 3; |
363 int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3; | 363 int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3; |
364 uint8_t* src_buf = pGlyph->GetBuffer(); | 364 uint8_t* src_buf = pGlyph->GetBuffer(); |
365 int src_pitch = pGlyph->GetPitch(); | 365 int src_pitch = pGlyph->GetPitch(); |
366 int start_col = left; | 366 int start_col = left; |
367 if (start_col < 0) { | 367 if (start_col < 0) { |
368 start_col = 0; | 368 start_col = 0; |
369 } | 369 } |
370 int end_col = left + ncols; | 370 int end_col = left + ncols; |
371 if (end_col > dest_width) { | 371 if (end_col > dest_width) { |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 } | 938 } |
939 } | 939 } |
940 } | 940 } |
941 } | 941 } |
942 if (bitmap.IsAlphaMask()) { | 942 if (bitmap.IsAlphaMask()) { |
943 SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color, alpha_flag,
pIccTransform); | 943 SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color, alpha_flag,
pIccTransform); |
944 } else { | 944 } else { |
945 SetDIBits(&bitmap, bmp_rect.left, bmp_rect.top); | 945 SetDIBits(&bitmap, bmp_rect.left, bmp_rect.top); |
946 } | 946 } |
947 FX_Free(pGlyphAndPos); | 947 FX_Free(pGlyphAndPos); |
948 return true; | 948 return TRUE; |
949 } | 949 } |
950 bool CFX_RenderDevice::DrawTextPath(int nChars, const FXTEXT_CHARPOS* pCharPos, | 950 FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars, const FXTEXT_CHARPOS* pCharPo
s, |
951 CFX_Font* pFont, CFX_FontCache* pCache, | 951 CFX_Font* pFont, CFX_FontCache* pCache, |
952 FX_FLOAT font_size, const CFX_AffineMatri
x* pText2User, | 952 FX_FLOAT font_size, const CFX_AffineMatri
x* pText2User, |
953 const CFX_AffineMatrix* pUser2Device, con
st CFX_GraphStateData* pGraphState, | 953 const CFX_AffineMatrix* pUser2Device, con
st CFX_GraphStateData* pGraphState, |
954 FX_DWORD fill_color, FX_ARGB stroke_color
, CFX_PathData* pClippingPath, int nFlag, | 954 FX_DWORD fill_color, FX_ARGB stroke_color
, CFX_PathData* pClippingPath, int nFlag, |
955 int alpha_flag, void* pIccTransform, int
blend_type) | 955 int alpha_flag, void* pIccTransform, int
blend_type) |
956 { | 956 { |
957 if (pCache == NULL) { | 957 if (pCache == NULL) { |
958 pCache = CFX_GEModule::Get()->GetFontCache(); | 958 pCache = CFX_GEModule::Get()->GetFontCache(); |
959 } | 959 } |
960 CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); | 960 CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); |
961 FX_FONTCACHE_DEFINE(pCache, pFont); | 961 FX_FONTCACHE_DEFINE(pCache, pFont); |
962 for (int iChar = 0; iChar < nChars; iChar ++) { | 962 for (int iChar = 0; iChar < nChars; iChar ++) { |
963 const FXTEXT_CHARPOS& charpos = pCharPos[iChar]; | 963 const FXTEXT_CHARPOS& charpos = pCharPos[iChar]; |
964 CFX_AffineMatrix matrix; | 964 CFX_AffineMatrix matrix; |
965 if (charpos.m_bGlyphAdjust) | 965 if (charpos.m_bGlyphAdjust) |
966 matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], | 966 matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], |
967 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0,
0); | 967 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0,
0); |
968 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, charpos.m_O
riginY); | 968 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, charpos.m_O
riginY); |
969 const CFX_PathData* pPath = pFaceCache->LoadGlyphPath(pFont, charpos.m_G
lyphIndex, charpos.m_FontCharWidth); | 969 const CFX_PathData* pPath = pFaceCache->LoadGlyphPath(pFont, charpos.m_G
lyphIndex, charpos.m_FontCharWidth); |
970 if (pPath == NULL) { | 970 if (pPath == NULL) { |
971 continue; | 971 continue; |
972 } | 972 } |
973 matrix.Concat(*pText2User); | 973 matrix.Concat(*pText2User); |
974 CFX_PathData TransformedPath(*pPath); | 974 CFX_PathData TransformedPath(*pPath); |
975 TransformedPath.Transform(&matrix); | 975 TransformedPath.Transform(&matrix); |
976 bool bHasAlpha = FXGETFLAG_COLORTYPE(alpha_flag) ? | 976 FX_BOOL bHasAlpha = FXGETFLAG_COLORTYPE(alpha_flag) ? |
977 (FXGETFLAG_ALPHA_FILL(alpha_flag) || FXGETFLAG_ALPHA
_STROKE(alpha_flag)) : | 977 (FXGETFLAG_ALPHA_FILL(alpha_flag) || FXGETFLAG_ALPHA
_STROKE(alpha_flag)) : |
978 (fill_color || stroke_color); | 978 (fill_color || stroke_color); |
979 if (bHasAlpha) { | 979 if (bHasAlpha) { |
980 int fill_mode = nFlag; | 980 int fill_mode = nFlag; |
981 if (FXGETFLAG_COLORTYPE(alpha_flag)) { | 981 if (FXGETFLAG_COLORTYPE(alpha_flag)) { |
982 if (FXGETFLAG_ALPHA_FILL(alpha_flag)) { | 982 if (FXGETFLAG_ALPHA_FILL(alpha_flag)) { |
983 fill_mode |= FXFILL_WINDING; | 983 fill_mode |= FXFILL_WINDING; |
984 } | 984 } |
985 } else { | 985 } else { |
986 if (fill_color) { | 986 if (fill_color) { |
987 fill_mode |= FXFILL_WINDING; | 987 fill_mode |= FXFILL_WINDING; |
988 } | 988 } |
989 } | 989 } |
990 fill_mode |= FX_FILL_TEXT_MODE; | 990 fill_mode |= FX_FILL_TEXT_MODE; |
991 if (!DrawPath(&TransformedPath, pUser2Device, pGraphState, fill_colo
r, stroke_color, fill_mode, alpha_flag, pIccTransform, blend_type)) { | 991 if (!DrawPath(&TransformedPath, pUser2Device, pGraphState, fill_colo
r, stroke_color, fill_mode, alpha_flag, pIccTransform, blend_type)) { |
992 return false; | 992 return FALSE; |
993 } | 993 } |
994 } | 994 } |
995 if (pClippingPath) { | 995 if (pClippingPath) { |
996 pClippingPath->Append(&TransformedPath, pUser2Device); | 996 pClippingPath->Append(&TransformedPath, pUser2Device); |
997 } | 997 } |
998 } | 998 } |
999 return true; | 999 return TRUE; |
1000 } | 1000 } |
1001 CFX_FontCache::~CFX_FontCache() | 1001 CFX_FontCache::~CFX_FontCache() |
1002 { | 1002 { |
1003 FreeCache(true); | 1003 FreeCache(TRUE); |
1004 } | 1004 } |
1005 | 1005 |
1006 CFX_FaceCache* CFX_FontCache::GetCachedFace(CFX_Font* pFont) | 1006 CFX_FaceCache* CFX_FontCache::GetCachedFace(CFX_Font* pFont) |
1007 { | 1007 { |
1008 FXFT_Face internal_face = pFont->GetFace(); | 1008 FXFT_Face internal_face = pFont->GetFace(); |
1009 const bool bExternal = internal_face == nullptr; | 1009 const FX_BOOL bExternal = internal_face == nullptr; |
1010 FXFT_Face face = bExternal ? | 1010 FXFT_Face face = bExternal ? |
1011 (FXFT_Face)pFont->GetSubstFont()->m_ExtHandle : internal_face; | 1011 (FXFT_Face)pFont->GetSubstFont()->m_ExtHandle : internal_face; |
1012 CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap; | 1012 CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap; |
1013 auto it = map.find(face); | 1013 auto it = map.find(face); |
1014 if (it != map.end()) { | 1014 if (it != map.end()) { |
1015 CFX_CountedFaceCache* counted_face_cache = it->second; | 1015 CFX_CountedFaceCache* counted_face_cache = it->second; |
1016 counted_face_cache->m_nCount++; | 1016 counted_face_cache->m_nCount++; |
1017 return counted_face_cache->m_Obj; | 1017 return counted_face_cache->m_Obj; |
1018 } | 1018 } |
1019 | 1019 |
1020 CFX_FaceCache* face_cache = new CFX_FaceCache(bExternal ? nullptr : face); | 1020 CFX_FaceCache* face_cache = new CFX_FaceCache(bExternal ? nullptr : face); |
1021 CFX_CountedFaceCache* counted_face_cache = new CFX_CountedFaceCache; | 1021 CFX_CountedFaceCache* counted_face_cache = new CFX_CountedFaceCache; |
1022 counted_face_cache->m_nCount = 2; | 1022 counted_face_cache->m_nCount = 2; |
1023 counted_face_cache->m_Obj = face_cache; | 1023 counted_face_cache->m_Obj = face_cache; |
1024 map[face] = counted_face_cache; | 1024 map[face] = counted_face_cache; |
1025 return face_cache; | 1025 return face_cache; |
1026 } | 1026 } |
1027 | 1027 |
1028 void CFX_FontCache::ReleaseCachedFace(CFX_Font* pFont) | 1028 void CFX_FontCache::ReleaseCachedFace(CFX_Font* pFont) |
1029 { | 1029 { |
1030 FXFT_Face internal_face = pFont->GetFace(); | 1030 FXFT_Face internal_face = pFont->GetFace(); |
1031 const bool bExternal = internal_face == nullptr; | 1031 const FX_BOOL bExternal = internal_face == nullptr; |
1032 FXFT_Face face = bExternal ? | 1032 FXFT_Face face = bExternal ? |
1033 (FXFT_Face)pFont->GetSubstFont()->m_ExtHandle : internal_face; | 1033 (FXFT_Face)pFont->GetSubstFont()->m_ExtHandle : internal_face; |
1034 CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap; | 1034 CFX_FTCacheMap& map = bExternal ? m_ExtFaceMap : m_FTFaceMap; |
1035 | 1035 |
1036 auto it = map.find(face); | 1036 auto it = map.find(face); |
1037 if (it == map.end()) | 1037 if (it == map.end()) |
1038 return; | 1038 return; |
1039 | 1039 |
1040 CFX_CountedFaceCache* counted_face_cache = it->second; | 1040 CFX_CountedFaceCache* counted_face_cache = it->second; |
1041 if (counted_face_cache->m_nCount > 1) { | 1041 if (counted_face_cache->m_nCount > 1) { |
1042 counted_face_cache->m_nCount--; | 1042 counted_face_cache->m_nCount--; |
1043 } | 1043 } |
1044 } | 1044 } |
1045 | 1045 |
1046 void CFX_FontCache::FreeCache(bool bRelease) | 1046 void CFX_FontCache::FreeCache(FX_BOOL bRelease) |
1047 { | 1047 { |
1048 for (auto it = m_FTFaceMap.begin(); it != m_FTFaceMap.end();) { | 1048 for (auto it = m_FTFaceMap.begin(); it != m_FTFaceMap.end();) { |
1049 auto curr_it = it++; | 1049 auto curr_it = it++; |
1050 CFX_CountedFaceCache* cache = curr_it->second; | 1050 CFX_CountedFaceCache* cache = curr_it->second; |
1051 if (bRelease || cache->m_nCount < 2) { | 1051 if (bRelease || cache->m_nCount < 2) { |
1052 delete cache->m_Obj; | 1052 delete cache->m_Obj; |
1053 delete cache; | 1053 delete cache; |
1054 m_FTFaceMap.erase(curr_it); | 1054 m_FTFaceMap.erase(curr_it); |
1055 } | 1055 } |
1056 } | 1056 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 delete pPath; | 1088 delete pPath; |
1089 } | 1089 } |
1090 m_PathMap.RemoveAll(); | 1090 m_PathMap.RemoveAll(); |
1091 } | 1091 } |
1092 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 1092 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
1093 void CFX_FaceCache::InitPlatform() | 1093 void CFX_FaceCache::InitPlatform() |
1094 { | 1094 { |
1095 } | 1095 } |
1096 #endif | 1096 #endif |
1097 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Aff
ineMatrix* pMatrix, | 1097 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Aff
ineMatrix* pMatrix, |
1098 CFX_ByteStringC& FaceGlyphsKey, FX_DWORD glyph_index, bool bFontStyle, | 1098 CFX_ByteStringC& FaceGlyphsKey, FX_DWORD glyph_index, FX_BOOL bFontStyle
, |
1099 int dest_width, int anti_alias) | 1099 int dest_width, int anti_alias) |
1100 { | 1100 { |
1101 CFX_SizeGlyphCache* pSizeCache = NULL; | 1101 CFX_SizeGlyphCache* pSizeCache = NULL; |
1102 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { | 1102 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { |
1103 pSizeCache = new CFX_SizeGlyphCache; | 1103 pSizeCache = new CFX_SizeGlyphCache; |
1104 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); | 1104 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); |
1105 } | 1105 } |
1106 CFX_GlyphBitmap* pGlyphBitmap = NULL; | 1106 CFX_GlyphBitmap* pGlyphBitmap = NULL; |
1107 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, (void*&)pGl
yphBitmap)) { | 1107 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, (void*&)pGl
yphBitmap)) { |
1108 return pGlyphBitmap; | 1108 return pGlyphBitmap; |
1109 } | 1109 } |
1110 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix, dest_wid
th, anti_alias); | 1110 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix, dest_wid
th, anti_alias); |
1111 if (pGlyphBitmap == NULL) { | 1111 if (pGlyphBitmap == NULL) { |
1112 return NULL; | 1112 return NULL; |
1113 } | 1113 } |
1114 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); | 1114 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); |
1115 return pGlyphBitmap; | 1115 return pGlyphBitmap; |
1116 } | 1116 } |
1117 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD
glyph_index, bool bFontStyle, const CFX_AffineMatrix* pMatrix, | 1117 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD
glyph_index, FX_BOOL bFontStyle, const CFX_AffineMatrix* pMatrix, |
1118 int dest_width, int anti_alias, int& text_flags) | 1118 int dest_width, int anti_alias, int& text_flags) |
1119 { | 1119 { |
1120 if (glyph_index == (FX_DWORD) - 1) { | 1120 if (glyph_index == (FX_DWORD) - 1) { |
1121 return NULL; | 1121 return NULL; |
1122 } | 1122 } |
1123 _CFX_UniqueKeyGen keygen; | 1123 _CFX_UniqueKeyGen keygen; |
1124 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 1124 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
1125 if (pFont->GetSubstFont()) | 1125 if (pFont->GetSubstFont()) |
1126 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), | 1126 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), |
1127 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), de
st_width, anti_alias, | 1127 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), de
st_width, anti_alias, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 temp = (int)((*(pSrcRow++) - min) * rate + 0.5); | 1304 temp = (int)((*(pSrcRow++) - min) * rate + 0.5); |
1305 if (temp > 255) { | 1305 if (temp > 255) { |
1306 temp = 255; | 1306 temp = 255; |
1307 } else if (temp < 0) { | 1307 } else if (temp < 0) { |
1308 temp = 0; | 1308 temp = 0; |
1309 } | 1309 } |
1310 *pDstRow ++ = (uint8_t)temp; | 1310 *pDstRow ++ = (uint8_t)temp; |
1311 } | 1311 } |
1312 } | 1312 } |
1313 } | 1313 } |
1314 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, FX_DWORD glyph_inde
x, bool bFontStyle, | 1314 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, FX_DWORD glyph_inde
x, FX_BOOL bFontStyle, |
1315 const CFX_AffineMatrix* pMatrix, int dest_width, int anti_alias) | 1315 const CFX_AffineMatrix* pMatrix, int dest_width, int anti_alias) |
1316 { | 1316 { |
1317 if (m_Face == NULL) { | 1317 if (m_Face == NULL) { |
1318 return NULL; | 1318 return NULL; |
1319 } | 1319 } |
1320 FXFT_Matrix ft_matrix; | 1320 FXFT_Matrix ft_matrix; |
1321 ft_matrix.xx = (signed long)(pMatrix->GetA() / 64 * 65536); | 1321 ft_matrix.xx = (signed long)(pMatrix->GetA() / 64 * 65536); |
1322 ft_matrix.xy = (signed long)(pMatrix->GetC() / 64 * 65536); | 1322 ft_matrix.xy = (signed long)(pMatrix->GetC() / 64 * 65536); |
1323 ft_matrix.yx = (signed long)(pMatrix->GetB() / 64 * 65536); | 1323 ft_matrix.yx = (signed long)(pMatrix->GetB() / 64 * 65536); |
1324 ft_matrix.yy = (signed long)(pMatrix->GetD() / 64 * 65536); | 1324 ft_matrix.yy = (signed long)(pMatrix->GetD() / 64 * 65536); |
1325 bool bUseCJKSubFont = false; | 1325 FX_BOOL bUseCJKSubFont = FALSE; |
1326 const CFX_SubstFont* pSubstFont = pFont->GetSubstFont(); | 1326 const CFX_SubstFont* pSubstFont = pFont->GetSubstFont(); |
1327 if (pSubstFont) { | 1327 if (pSubstFont) { |
1328 bUseCJKSubFont = pSubstFont->m_bSubstOfCJK && bFontStyle; | 1328 bUseCJKSubFont = pSubstFont->m_bSubstOfCJK && bFontStyle; |
1329 int skew = 0; | 1329 int skew = 0; |
1330 if (bUseCJKSubFont) { | 1330 if (bUseCJKSubFont) { |
1331 skew = pSubstFont->m_bItlicCJK ? -15 : 0; | 1331 skew = pSubstFont->m_bItlicCJK ? -15 : 0; |
1332 } else { | 1332 } else { |
1333 skew = pSubstFont->m_ItalicAngle; | 1333 skew = pSubstFont->m_ItalicAngle; |
1334 } | 1334 } |
1335 if (skew) { | 1335 if (skew) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 for (int row = 0; row < bmheight; row ++) { | 1415 for (int row = 0; row < bmheight; row ++) { |
1416 FXSYS_memcpy(pDestBuf + row * dest_pitch, pSrcBuf + row * src_pi
tch, rowbytes); | 1416 FXSYS_memcpy(pDestBuf + row * dest_pitch, pSrcBuf + row * src_pi
tch, rowbytes); |
1417 } | 1417 } |
1418 } else { | 1418 } else { |
1419 _ContrastAdjust(pSrcBuf, pDestBuf, bmwidth, bmheight, src_pitch, des
t_pitch); | 1419 _ContrastAdjust(pSrcBuf, pDestBuf, bmwidth, bmheight, src_pitch, des
t_pitch); |
1420 _GammaAdjust(pDestBuf, bmwidth, bmheight, dest_pitch, CFX_GEModule::
Get()->GetTextGammaTable()); | 1420 _GammaAdjust(pDestBuf, bmwidth, bmheight, dest_pitch, CFX_GEModule::
Get()->GetTextGammaTable()); |
1421 } | 1421 } |
1422 } | 1422 } |
1423 return pGlyphBitmap; | 1423 return pGlyphBitmap; |
1424 } | 1424 } |
1425 bool _OutputGlyph(void* dib, int x, int y, CFX_Font* pFont, | 1425 FX_BOOL _OutputGlyph(void* dib, int x, int y, CFX_Font* pFont, |
1426 int glyph_index, FX_ARGB argb) | 1426 int glyph_index, FX_ARGB argb) |
1427 { | 1427 { |
1428 CFX_DIBitmap* pDib = (CFX_DIBitmap*)dib; | 1428 CFX_DIBitmap* pDib = (CFX_DIBitmap*)dib; |
1429 FXFT_Face face = pFont->GetFace(); | 1429 FXFT_Face face = pFont->GetFace(); |
1430 int error = FXFT_Load_Glyph(face, glyph_index, FXFT_LOAD_NO_BITMAP); | 1430 int error = FXFT_Load_Glyph(face, glyph_index, FXFT_LOAD_NO_BITMAP); |
1431 if (error) { | 1431 if (error) { |
1432 return false; | 1432 return FALSE; |
1433 } | 1433 } |
1434 error = FXFT_Render_Glyph(face, FXFT_RENDER_MODE_NORMAL); | 1434 error = FXFT_Render_Glyph(face, FXFT_RENDER_MODE_NORMAL); |
1435 if (error) { | 1435 if (error) { |
1436 return false; | 1436 return FALSE; |
1437 } | 1437 } |
1438 int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(face)); | 1438 int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(face)); |
1439 int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(face)); | 1439 int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(face)); |
1440 int left = FXFT_Get_Glyph_BitmapLeft(face); | 1440 int left = FXFT_Get_Glyph_BitmapLeft(face); |
1441 int top = FXFT_Get_Glyph_BitmapTop(face); | 1441 int top = FXFT_Get_Glyph_BitmapTop(face); |
1442 const uint8_t* src_buf = (const uint8_t*)FXFT_Get_Bitmap_Buffer(FXFT_Get_Gly
ph_Bitmap(face)); | 1442 const uint8_t* src_buf = (const uint8_t*)FXFT_Get_Bitmap_Buffer(FXFT_Get_Gly
ph_Bitmap(face)); |
1443 int src_pitch = FXFT_Get_Bitmap_Pitch(FXFT_Get_Glyph_Bitmap(face)); | 1443 int src_pitch = FXFT_Get_Bitmap_Pitch(FXFT_Get_Glyph_Bitmap(face)); |
1444 CFX_DIBitmap mask; | 1444 CFX_DIBitmap mask; |
1445 mask.Create(bmwidth, bmheight, FXDIB_8bppMask); | 1445 mask.Create(bmwidth, bmheight, FXDIB_8bppMask); |
1446 uint8_t* dest_buf = mask.GetBuffer(); | 1446 uint8_t* dest_buf = mask.GetBuffer(); |
1447 int dest_pitch = mask.GetPitch(); | 1447 int dest_pitch = mask.GetPitch(); |
1448 for (int row = 0; row < bmheight; row ++) { | 1448 for (int row = 0; row < bmheight; row ++) { |
1449 const uint8_t* src_scan = src_buf + row * src_pitch; | 1449 const uint8_t* src_scan = src_buf + row * src_pitch; |
1450 uint8_t* dest_scan = dest_buf + row * dest_pitch; | 1450 uint8_t* dest_scan = dest_buf + row * dest_pitch; |
1451 FXSYS_memcpy(dest_scan, src_scan, dest_pitch); | 1451 FXSYS_memcpy(dest_scan, src_scan, dest_pitch); |
1452 } | 1452 } |
1453 pDib->CompositeMask(x + left, y - top, bmwidth, bmheight, &mask, argb, 0, 0)
; | 1453 pDib->CompositeMask(x + left, y - top, bmwidth, bmheight, &mask, argb, 0, 0)
; |
1454 return true; | 1454 return TRUE; |
1455 } | 1455 } |
1456 bool OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size, | 1456 FX_BOOL OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size, |
1457 CFX_AffineMatrix* pText_matrix, unsigned short const* text, u
nsigned long argb) | 1457 CFX_AffineMatrix* pText_matrix, unsigned short const* text, u
nsigned long argb) |
1458 { | 1458 { |
1459 if (!pFont) { | 1459 if (!pFont) { |
1460 return false; | 1460 return FALSE; |
1461 } | 1461 } |
1462 FXFT_Face face = pFont->GetFace(); | 1462 FXFT_Face face = pFont->GetFace(); |
1463 FXFT_Select_Charmap(pFont->m_Face, FXFT_ENCODING_UNICODE); | 1463 FXFT_Select_Charmap(pFont->m_Face, FXFT_ENCODING_UNICODE); |
1464 if (pText_matrix) { | 1464 if (pText_matrix) { |
1465 FXFT_Matrix ft_matrix; | 1465 FXFT_Matrix ft_matrix; |
1466 ft_matrix.xx = (signed long)(pText_matrix->a / 64 * 65536); | 1466 ft_matrix.xx = (signed long)(pText_matrix->a / 64 * 65536); |
1467 ft_matrix.xy = (signed long)(pText_matrix->c / 64 * 65536); | 1467 ft_matrix.xy = (signed long)(pText_matrix->c / 64 * 65536); |
1468 ft_matrix.yx = (signed long)(pText_matrix->b / 64 * 65536); | 1468 ft_matrix.yx = (signed long)(pText_matrix->b / 64 * 65536); |
1469 ft_matrix.yy = (signed long)(pText_matrix->d / 64 * 65536); | 1469 ft_matrix.yy = (signed long)(pText_matrix->d / 64 * 65536); |
1470 FXFT_Set_Transform(face, &ft_matrix, 0); | 1470 FXFT_Set_Transform(face, &ft_matrix, 0); |
(...skipping 12 matching lines...) Expand all Loading... |
1483 int w = FXFT_Get_Glyph_HoriAdvance(pFont->m_Face); | 1483 int w = FXFT_Get_Glyph_HoriAdvance(pFont->m_Face); |
1484 int em = FXFT_Get_Face_UnitsPerEM(pFont->m_Face); | 1484 int em = FXFT_Get_Face_UnitsPerEM(pFont->m_Face); |
1485 FX_FLOAT x1, y1; | 1485 FX_FLOAT x1, y1; |
1486 pText_matrix->Transform(x_pos, 0, x1, y1); | 1486 pText_matrix->Transform(x_pos, 0, x1, y1); |
1487 _OutputGlyph(dib, (int)x1 + x, (int) - y1 + y, pFont, | 1487 _OutputGlyph(dib, (int)x1 + x, (int) - y1 + y, pFont, |
1488 glyph_index, argb); | 1488 glyph_index, argb); |
1489 x_pos += (FX_FLOAT)w / em; | 1489 x_pos += (FX_FLOAT)w / em; |
1490 } | 1490 } |
1491 if (pText_matrix) | 1491 if (pText_matrix) |
1492 ResetTransform(face); | 1492 ResetTransform(face); |
1493 return true; | 1493 return TRUE; |
1494 } | 1494 } |
1495 bool OutputGlyph(void* dib, int x, int y, CFX_Font* pFont, double font_size, | 1495 FX_BOOL OutputGlyph(void* dib, int x, int y, CFX_Font* pFont, double font_size, |
1496 CFX_AffineMatrix* pMatrix, unsigned long glyph_index, unsign
ed long argb) | 1496 CFX_AffineMatrix* pMatrix, unsigned long glyph_index, unsign
ed long argb) |
1497 { | 1497 { |
1498 FXFT_Matrix ft_matrix; | 1498 FXFT_Matrix ft_matrix; |
1499 if (pMatrix) { | 1499 if (pMatrix) { |
1500 ft_matrix.xx = (signed long)(pMatrix->a * font_size / 64 * 65536); | 1500 ft_matrix.xx = (signed long)(pMatrix->a * font_size / 64 * 65536); |
1501 ft_matrix.xy = (signed long)(pMatrix->c * font_size / 64 * 65536); | 1501 ft_matrix.xy = (signed long)(pMatrix->c * font_size / 64 * 65536); |
1502 ft_matrix.yx = (signed long)(pMatrix->b * font_size / 64 * 65536); | 1502 ft_matrix.yx = (signed long)(pMatrix->b * font_size / 64 * 65536); |
1503 ft_matrix.yy = (signed long)(pMatrix->d * font_size / 64 * 65536); | 1503 ft_matrix.yy = (signed long)(pMatrix->d * font_size / 64 * 65536); |
1504 } else { | 1504 } else { |
1505 ft_matrix.xx = (signed long)(font_size / 64 * 65536); | 1505 ft_matrix.xx = (signed long)(font_size / 64 * 65536); |
1506 ft_matrix.xy = ft_matrix.yx = 0; | 1506 ft_matrix.xy = ft_matrix.yx = 0; |
1507 ft_matrix.yy = (signed long)(font_size / 64 * 65536); | 1507 ft_matrix.yy = (signed long)(font_size / 64 * 65536); |
1508 } | 1508 } |
1509 ScopedFontTransform scoped_transform(pFont->m_Face, &ft_matrix); | 1509 ScopedFontTransform scoped_transform(pFont->m_Face, &ft_matrix); |
1510 bool ret = _OutputGlyph(dib, x, y, pFont, | 1510 FX_BOOL ret = _OutputGlyph(dib, x, y, pFont, |
1511 glyph_index, argb); | 1511 glyph_index, argb); |
1512 return ret; | 1512 return ret; |
1513 } | 1513 } |
1514 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, FX_DWORD glyph
_index, int dest_width) | 1514 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, FX_DWORD glyph
_index, int dest_width) |
1515 { | 1515 { |
1516 if (m_Face == NULL || glyph_index == (FX_DWORD) - 1) { | 1516 if (m_Face == NULL || glyph_index == (FX_DWORD) - 1) { |
1517 return NULL; | 1517 return NULL; |
1518 } | 1518 } |
1519 CFX_PathData* pGlyphPath = NULL; | 1519 CFX_PathData* pGlyphPath = NULL; |
1520 void* key; | 1520 void* key; |
1521 if (pFont->GetSubstFont()) | 1521 if (pFont->GetSubstFont()) |
1522 key = (void*)(uintptr_t)(glyph_index + ((pFont->GetSubstFont()->m_Weight
/ 16) << 15) + | 1522 key = (void*)(uintptr_t)(glyph_index + ((pFont->GetSubstFont()->m_Weight
/ 16) << 15) + |
1523 ((pFont->GetSubstFont()->m_ItalicAngle / 2
) << 21) + ((dest_width / 16) << 25) + | 1523 ((pFont->GetSubstFont()->m_ItalicAngle / 2
) << 21) + ((dest_width / 16) << 25) + |
1524 (pFont->IsVertical() << 31)); | 1524 (pFont->IsVertical() << 31)); |
1525 else { | 1525 else { |
1526 key = (void*)(uintptr_t)glyph_index; | 1526 key = (void*)(uintptr_t)glyph_index; |
1527 } | 1527 } |
1528 if (m_PathMap.Lookup(key, (void*&)pGlyphPath)) { | 1528 if (m_PathMap.Lookup(key, (void*&)pGlyphPath)) { |
1529 return pGlyphPath; | 1529 return pGlyphPath; |
1530 } | 1530 } |
1531 pGlyphPath = pFont->LoadGlyphPath(glyph_index, dest_width); | 1531 pGlyphPath = pFont->LoadGlyphPath(glyph_index, dest_width); |
1532 m_PathMap.SetAt(key, pGlyphPath); | 1532 m_PathMap.SetAt(key, pGlyphPath); |
1533 return pGlyphPath; | 1533 return pGlyphPath; |
1534 } | 1534 } |
1535 typedef struct { | 1535 typedef struct { |
1536 bool» » » m_bCount; | 1536 FX_BOOL» » » m_bCount; |
1537 int m_PointCount; | 1537 int m_PointCount; |
1538 FX_PATHPOINT* m_pPoints; | 1538 FX_PATHPOINT* m_pPoints; |
1539 int m_CurX; | 1539 int m_CurX; |
1540 int m_CurY; | 1540 int m_CurY; |
1541 FX_FLOAT m_CoordUnit; | 1541 FX_FLOAT m_CoordUnit; |
1542 } OUTLINE_PARAMS; | 1542 } OUTLINE_PARAMS; |
1543 void _Outline_CheckEmptyContour(OUTLINE_PARAMS* param) | 1543 void _Outline_CheckEmptyContour(OUTLINE_PARAMS* param) |
1544 { | 1544 { |
1545 if (param->m_PointCount >= 2 && param->m_pPoints[param->m_PointCount - 2].m_
Flag == FXPT_MOVETO && | 1545 if (param->m_PointCount >= 2 && param->m_pPoints[param->m_PointCount - 2].m_
Flag == FXPT_MOVETO && |
1546 param->m_pPoints[param->m_PointCount - 2].m_PointX == param->m_pPoin
ts[param->m_PointCount - 1].m_PointX && | 1546 param->m_pPoints[param->m_PointCount - 2].m_PointX == param->m_pPoin
ts[param->m_PointCount - 1].m_PointX && |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 FXFT_Outline_Embolden(FXFT_Get_Glyph_Outline(m_Face), level); | 1677 FXFT_Outline_Embolden(FXFT_Get_Glyph_Outline(m_Face), level); |
1678 } | 1678 } |
1679 FXFT_Outline_Funcs funcs; | 1679 FXFT_Outline_Funcs funcs; |
1680 funcs.move_to = _Outline_MoveTo; | 1680 funcs.move_to = _Outline_MoveTo; |
1681 funcs.line_to = _Outline_LineTo; | 1681 funcs.line_to = _Outline_LineTo; |
1682 funcs.conic_to = _Outline_ConicTo; | 1682 funcs.conic_to = _Outline_ConicTo; |
1683 funcs.cubic_to = _Outline_CubicTo; | 1683 funcs.cubic_to = _Outline_CubicTo; |
1684 funcs.shift = 0; | 1684 funcs.shift = 0; |
1685 funcs.delta = 0; | 1685 funcs.delta = 0; |
1686 OUTLINE_PARAMS params; | 1686 OUTLINE_PARAMS params; |
1687 params.m_bCount = true; | 1687 params.m_bCount = TRUE; |
1688 params.m_PointCount = 0; | 1688 params.m_PointCount = 0; |
1689 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, ¶ms); | 1689 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, ¶ms); |
1690 if (params.m_PointCount == 0) { | 1690 if (params.m_PointCount == 0) { |
1691 return NULL; | 1691 return NULL; |
1692 } | 1692 } |
1693 CFX_PathData* pPath = new CFX_PathData; | 1693 CFX_PathData* pPath = new CFX_PathData; |
1694 pPath->SetPointCount(params.m_PointCount); | 1694 pPath->SetPointCount(params.m_PointCount); |
1695 params.m_bCount = false; | 1695 params.m_bCount = FALSE; |
1696 params.m_PointCount = 0; | 1696 params.m_PointCount = 0; |
1697 params.m_pPoints = pPath->GetPoints(); | 1697 params.m_pPoints = pPath->GetPoints(); |
1698 params.m_CurX = params.m_CurY = 0; | 1698 params.m_CurX = params.m_CurY = 0; |
1699 params.m_CoordUnit = 64 * 64.0; | 1699 params.m_CoordUnit = 64 * 64.0; |
1700 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, ¶ms); | 1700 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, ¶ms); |
1701 _Outline_CheckEmptyContour(¶ms); | 1701 _Outline_CheckEmptyContour(¶ms); |
1702 pPath->TrimPoints(params.m_PointCount); | 1702 pPath->TrimPoints(params.m_PointCount); |
1703 if (params.m_PointCount) { | 1703 if (params.m_PointCount) { |
1704 pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; | 1704 pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; |
1705 } | 1705 } |
1706 return pPath; | 1706 return pPath; |
1707 } | 1707 } |
1708 void _CFX_UniqueKeyGen::Generate(int count, ...) | 1708 void _CFX_UniqueKeyGen::Generate(int count, ...) |
1709 { | 1709 { |
1710 va_list argList; | 1710 va_list argList; |
1711 va_start(argList, count); | 1711 va_start(argList, count); |
1712 for (int i = 0; i < count; i ++) { | 1712 for (int i = 0; i < count; i ++) { |
1713 int p = va_arg(argList, int); | 1713 int p = va_arg(argList, int); |
1714 ((FX_DWORD*)m_Key)[i] = p; | 1714 ((FX_DWORD*)m_Key)[i] = p; |
1715 } | 1715 } |
1716 va_end(argList); | 1716 va_end(argList); |
1717 m_KeyLen = count * sizeof(FX_DWORD); | 1717 m_KeyLen = count * sizeof(FX_DWORD); |
1718 } | 1718 } |
OLD | NEW |