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

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

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxge/ge/fx_ge_ps.cpp ('k') | core/src/fxge/ge/text_int.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../../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
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 FX_BOOL bStarted = FALSE; 49 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 FX_BOOL bVertical = FALSE; 90 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
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 FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, const FXTEXT_CHARPOS* pChar Pos, 158 bool CFX_RenderDevice::DrawNormalText(int nChars, const FXTEXT_CHARPOS* pCharPos ,
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 FX_BOOL bNormal = FALSE; 207 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 FX_BOOL bClearType; 210 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
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
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 FX_BOOL bBGRStripe = text_flags & FXTEXT_BGR_STRIPE; 361 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
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 FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars, const FXTEXT_CHARPOS* pCharPo s, 950 bool CFX_RenderDevice::DrawTextPath(int nChars, const FXTEXT_CHARPOS* pCharPos,
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 FX_BOOL bHasAlpha = FXGETFLAG_COLORTYPE(alpha_flag) ? 976 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 FX_BOOL bExternal = internal_face == nullptr; 1009 const 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 FX_BOOL bExternal = internal_face == nullptr; 1031 const 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(FX_BOOL bRelease) 1046 void CFX_FontCache::FreeCache(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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 } 1090 }
1091 delete m_pBitmap; 1091 delete m_pBitmap;
1092 m_PathMap.RemoveAll(); 1092 m_PathMap.RemoveAll();
1093 } 1093 }
1094 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ 1094 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
1095 void CFX_FaceCache::InitPlatform() 1095 void CFX_FaceCache::InitPlatform()
1096 { 1096 {
1097 } 1097 }
1098 #endif 1098 #endif
1099 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Aff ineMatrix* pMatrix, 1099 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Aff ineMatrix* pMatrix,
1100 CFX_ByteStringC& FaceGlyphsKey, FX_DWORD glyph_index, FX_BOOL bFontStyle , 1100 CFX_ByteStringC& FaceGlyphsKey, FX_DWORD glyph_index, bool bFontStyle,
1101 int dest_width, int anti_alias) 1101 int dest_width, int anti_alias)
1102 { 1102 {
1103 CFX_SizeGlyphCache* pSizeCache = NULL; 1103 CFX_SizeGlyphCache* pSizeCache = NULL;
1104 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { 1104 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) {
1105 pSizeCache = new CFX_SizeGlyphCache; 1105 pSizeCache = new CFX_SizeGlyphCache;
1106 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); 1106 m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache);
1107 } 1107 }
1108 CFX_GlyphBitmap* pGlyphBitmap = NULL; 1108 CFX_GlyphBitmap* pGlyphBitmap = NULL;
1109 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, (void*&)pGl yphBitmap)) { 1109 if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, (void*&)pGl yphBitmap)) {
1110 return pGlyphBitmap; 1110 return pGlyphBitmap;
1111 } 1111 }
1112 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix, dest_wid th, anti_alias); 1112 pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, pMatrix, dest_wid th, anti_alias);
1113 if (pGlyphBitmap == NULL) { 1113 if (pGlyphBitmap == NULL) {
1114 return NULL; 1114 return NULL;
1115 } 1115 }
1116 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); 1116 pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap);
1117 return pGlyphBitmap; 1117 return pGlyphBitmap;
1118 } 1118 }
1119 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD glyph_index, FX_BOOL bFontStyle, const CFX_AffineMatrix* pMatrix, 1119 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD glyph_index, bool bFontStyle, const CFX_AffineMatrix* pMatrix,
1120 int dest_width, int anti_alias, int& text_flags) 1120 int dest_width, int anti_alias, int& text_flags)
1121 { 1121 {
1122 if (glyph_index == (FX_DWORD) - 1) { 1122 if (glyph_index == (FX_DWORD) - 1) {
1123 return NULL; 1123 return NULL;
1124 } 1124 }
1125 _CFX_UniqueKeyGen keygen; 1125 _CFX_UniqueKeyGen keygen;
1126 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ 1126 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
1127 if (pFont->GetSubstFont()) 1127 if (pFont->GetSubstFont())
1128 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), 1128 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000),
1129 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), de st_width, anti_alias, 1129 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), de st_width, anti_alias,
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 temp = (int)((*(pSrcRow++) - min) * rate + 0.5); 1307 temp = (int)((*(pSrcRow++) - min) * rate + 0.5);
1308 if (temp > 255) { 1308 if (temp > 255) {
1309 temp = 255; 1309 temp = 255;
1310 } else if (temp < 0) { 1310 } else if (temp < 0) {
1311 temp = 0; 1311 temp = 0;
1312 } 1312 }
1313 *pDstRow ++ = (uint8_t)temp; 1313 *pDstRow ++ = (uint8_t)temp;
1314 } 1314 }
1315 } 1315 }
1316 } 1316 }
1317 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, FX_DWORD glyph_inde x, FX_BOOL bFontStyle, 1317 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, FX_DWORD glyph_inde x, bool bFontStyle,
1318 const CFX_AffineMatrix* pMatrix, int dest_width, int anti_alias) 1318 const CFX_AffineMatrix* pMatrix, int dest_width, int anti_alias)
1319 { 1319 {
1320 if (m_Face == NULL) { 1320 if (m_Face == NULL) {
1321 return NULL; 1321 return NULL;
1322 } 1322 }
1323 FXFT_Matrix ft_matrix; 1323 FXFT_Matrix ft_matrix;
1324 ft_matrix.xx = (signed long)(pMatrix->GetA() / 64 * 65536); 1324 ft_matrix.xx = (signed long)(pMatrix->GetA() / 64 * 65536);
1325 ft_matrix.xy = (signed long)(pMatrix->GetC() / 64 * 65536); 1325 ft_matrix.xy = (signed long)(pMatrix->GetC() / 64 * 65536);
1326 ft_matrix.yx = (signed long)(pMatrix->GetB() / 64 * 65536); 1326 ft_matrix.yx = (signed long)(pMatrix->GetB() / 64 * 65536);
1327 ft_matrix.yy = (signed long)(pMatrix->GetD() / 64 * 65536); 1327 ft_matrix.yy = (signed long)(pMatrix->GetD() / 64 * 65536);
1328 FX_BOOL bUseCJKSubFont = FALSE; 1328 bool bUseCJKSubFont = false;
1329 const CFX_SubstFont* pSubstFont = pFont->GetSubstFont(); 1329 const CFX_SubstFont* pSubstFont = pFont->GetSubstFont();
1330 if (pSubstFont) { 1330 if (pSubstFont) {
1331 bUseCJKSubFont = pSubstFont->m_bSubstOfCJK && bFontStyle; 1331 bUseCJKSubFont = pSubstFont->m_bSubstOfCJK && bFontStyle;
1332 int skew = 0; 1332 int skew = 0;
1333 if (bUseCJKSubFont) { 1333 if (bUseCJKSubFont) {
1334 skew = pSubstFont->m_bItlicCJK ? -15 : 0; 1334 skew = pSubstFont->m_bItlicCJK ? -15 : 0;
1335 } else { 1335 } else {
1336 skew = pSubstFont->m_ItalicAngle; 1336 skew = pSubstFont->m_ItalicAngle;
1337 } 1337 }
1338 if (skew) { 1338 if (skew) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 for (int row = 0; row < bmheight; row ++) { 1418 for (int row = 0; row < bmheight; row ++) {
1419 FXSYS_memcpy(pDestBuf + row * dest_pitch, pSrcBuf + row * src_pi tch, rowbytes); 1419 FXSYS_memcpy(pDestBuf + row * dest_pitch, pSrcBuf + row * src_pi tch, rowbytes);
1420 } 1420 }
1421 } else { 1421 } else {
1422 _ContrastAdjust(pSrcBuf, pDestBuf, bmwidth, bmheight, src_pitch, des t_pitch); 1422 _ContrastAdjust(pSrcBuf, pDestBuf, bmwidth, bmheight, src_pitch, des t_pitch);
1423 _GammaAdjust(pDestBuf, bmwidth, bmheight, dest_pitch, CFX_GEModule:: Get()->GetTextGammaTable()); 1423 _GammaAdjust(pDestBuf, bmwidth, bmheight, dest_pitch, CFX_GEModule:: Get()->GetTextGammaTable());
1424 } 1424 }
1425 } 1425 }
1426 return pGlyphBitmap; 1426 return pGlyphBitmap;
1427 } 1427 }
1428 FX_BOOL _OutputGlyph(void* dib, int x, int y, CFX_Font* pFont, 1428 bool _OutputGlyph(void* dib, int x, int y, CFX_Font* pFont,
1429 int glyph_index, FX_ARGB argb) 1429 int glyph_index, FX_ARGB argb)
1430 { 1430 {
1431 CFX_DIBitmap* pDib = (CFX_DIBitmap*)dib; 1431 CFX_DIBitmap* pDib = (CFX_DIBitmap*)dib;
1432 FXFT_Face face = pFont->GetFace(); 1432 FXFT_Face face = pFont->GetFace();
1433 int error = FXFT_Load_Glyph(face, glyph_index, FXFT_LOAD_NO_BITMAP); 1433 int error = FXFT_Load_Glyph(face, glyph_index, FXFT_LOAD_NO_BITMAP);
1434 if (error) { 1434 if (error) {
1435 return FALSE; 1435 return false;
1436 } 1436 }
1437 error = FXFT_Render_Glyph(face, FXFT_RENDER_MODE_NORMAL); 1437 error = FXFT_Render_Glyph(face, FXFT_RENDER_MODE_NORMAL);
1438 if (error) { 1438 if (error) {
1439 return FALSE; 1439 return false;
1440 } 1440 }
1441 int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(face)); 1441 int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(face));
1442 int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(face)); 1442 int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(face));
1443 int left = FXFT_Get_Glyph_BitmapLeft(face); 1443 int left = FXFT_Get_Glyph_BitmapLeft(face);
1444 int top = FXFT_Get_Glyph_BitmapTop(face); 1444 int top = FXFT_Get_Glyph_BitmapTop(face);
1445 const uint8_t* src_buf = (const uint8_t*)FXFT_Get_Bitmap_Buffer(FXFT_Get_Gly ph_Bitmap(face)); 1445 const uint8_t* src_buf = (const uint8_t*)FXFT_Get_Bitmap_Buffer(FXFT_Get_Gly ph_Bitmap(face));
1446 int src_pitch = FXFT_Get_Bitmap_Pitch(FXFT_Get_Glyph_Bitmap(face)); 1446 int src_pitch = FXFT_Get_Bitmap_Pitch(FXFT_Get_Glyph_Bitmap(face));
1447 CFX_DIBitmap mask; 1447 CFX_DIBitmap mask;
1448 mask.Create(bmwidth, bmheight, FXDIB_8bppMask); 1448 mask.Create(bmwidth, bmheight, FXDIB_8bppMask);
1449 uint8_t* dest_buf = mask.GetBuffer(); 1449 uint8_t* dest_buf = mask.GetBuffer();
1450 int dest_pitch = mask.GetPitch(); 1450 int dest_pitch = mask.GetPitch();
1451 for (int row = 0; row < bmheight; row ++) { 1451 for (int row = 0; row < bmheight; row ++) {
1452 const uint8_t* src_scan = src_buf + row * src_pitch; 1452 const uint8_t* src_scan = src_buf + row * src_pitch;
1453 uint8_t* dest_scan = dest_buf + row * dest_pitch; 1453 uint8_t* dest_scan = dest_buf + row * dest_pitch;
1454 FXSYS_memcpy(dest_scan, src_scan, dest_pitch); 1454 FXSYS_memcpy(dest_scan, src_scan, dest_pitch);
1455 } 1455 }
1456 pDib->CompositeMask(x + left, y - top, bmwidth, bmheight, &mask, argb, 0, 0) ; 1456 pDib->CompositeMask(x + left, y - top, bmwidth, bmheight, &mask, argb, 0, 0) ;
1457 return TRUE; 1457 return true;
1458 } 1458 }
1459 FX_BOOL OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size, 1459 bool OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size,
1460 CFX_AffineMatrix* pText_matrix, unsigned short const* text, u nsigned long argb) 1460 CFX_AffineMatrix* pText_matrix, unsigned short const* text, u nsigned long argb)
1461 { 1461 {
1462 if (!pFont) { 1462 if (!pFont) {
1463 return FALSE; 1463 return false;
1464 } 1464 }
1465 FXFT_Face face = pFont->GetFace(); 1465 FXFT_Face face = pFont->GetFace();
1466 FXFT_Select_Charmap(pFont->m_Face, FXFT_ENCODING_UNICODE); 1466 FXFT_Select_Charmap(pFont->m_Face, FXFT_ENCODING_UNICODE);
1467 if (pText_matrix) { 1467 if (pText_matrix) {
1468 FXFT_Matrix ft_matrix; 1468 FXFT_Matrix ft_matrix;
1469 ft_matrix.xx = (signed long)(pText_matrix->a / 64 * 65536); 1469 ft_matrix.xx = (signed long)(pText_matrix->a / 64 * 65536);
1470 ft_matrix.xy = (signed long)(pText_matrix->c / 64 * 65536); 1470 ft_matrix.xy = (signed long)(pText_matrix->c / 64 * 65536);
1471 ft_matrix.yx = (signed long)(pText_matrix->b / 64 * 65536); 1471 ft_matrix.yx = (signed long)(pText_matrix->b / 64 * 65536);
1472 ft_matrix.yy = (signed long)(pText_matrix->d / 64 * 65536); 1472 ft_matrix.yy = (signed long)(pText_matrix->d / 64 * 65536);
1473 FXFT_Set_Transform(face, &ft_matrix, 0); 1473 FXFT_Set_Transform(face, &ft_matrix, 0);
(...skipping 12 matching lines...) Expand all
1486 int w = FXFT_Get_Glyph_HoriAdvance(pFont->m_Face); 1486 int w = FXFT_Get_Glyph_HoriAdvance(pFont->m_Face);
1487 int em = FXFT_Get_Face_UnitsPerEM(pFont->m_Face); 1487 int em = FXFT_Get_Face_UnitsPerEM(pFont->m_Face);
1488 FX_FLOAT x1, y1; 1488 FX_FLOAT x1, y1;
1489 pText_matrix->Transform(x_pos, 0, x1, y1); 1489 pText_matrix->Transform(x_pos, 0, x1, y1);
1490 _OutputGlyph(dib, (int)x1 + x, (int) - y1 + y, pFont, 1490 _OutputGlyph(dib, (int)x1 + x, (int) - y1 + y, pFont,
1491 glyph_index, argb); 1491 glyph_index, argb);
1492 x_pos += (FX_FLOAT)w / em; 1492 x_pos += (FX_FLOAT)w / em;
1493 } 1493 }
1494 if (pText_matrix) 1494 if (pText_matrix)
1495 ResetTransform(face); 1495 ResetTransform(face);
1496 return TRUE; 1496 return true;
1497 } 1497 }
1498 FX_BOOL OutputGlyph(void* dib, int x, int y, CFX_Font* pFont, double font_size, 1498 bool OutputGlyph(void* dib, int x, int y, CFX_Font* pFont, double font_size,
1499 CFX_AffineMatrix* pMatrix, unsigned long glyph_index, unsign ed long argb) 1499 CFX_AffineMatrix* pMatrix, unsigned long glyph_index, unsign ed long argb)
1500 { 1500 {
1501 FXFT_Matrix ft_matrix; 1501 FXFT_Matrix ft_matrix;
1502 if (pMatrix) { 1502 if (pMatrix) {
1503 ft_matrix.xx = (signed long)(pMatrix->a * font_size / 64 * 65536); 1503 ft_matrix.xx = (signed long)(pMatrix->a * font_size / 64 * 65536);
1504 ft_matrix.xy = (signed long)(pMatrix->c * font_size / 64 * 65536); 1504 ft_matrix.xy = (signed long)(pMatrix->c * font_size / 64 * 65536);
1505 ft_matrix.yx = (signed long)(pMatrix->b * font_size / 64 * 65536); 1505 ft_matrix.yx = (signed long)(pMatrix->b * font_size / 64 * 65536);
1506 ft_matrix.yy = (signed long)(pMatrix->d * font_size / 64 * 65536); 1506 ft_matrix.yy = (signed long)(pMatrix->d * font_size / 64 * 65536);
1507 } else { 1507 } else {
1508 ft_matrix.xx = (signed long)(font_size / 64 * 65536); 1508 ft_matrix.xx = (signed long)(font_size / 64 * 65536);
1509 ft_matrix.xy = ft_matrix.yx = 0; 1509 ft_matrix.xy = ft_matrix.yx = 0;
1510 ft_matrix.yy = (signed long)(font_size / 64 * 65536); 1510 ft_matrix.yy = (signed long)(font_size / 64 * 65536);
1511 } 1511 }
1512 ScopedFontTransform scoped_transform(pFont->m_Face, &ft_matrix); 1512 ScopedFontTransform scoped_transform(pFont->m_Face, &ft_matrix);
1513 FX_BOOL ret = _OutputGlyph(dib, x, y, pFont, 1513 bool ret = _OutputGlyph(dib, x, y, pFont,
1514 glyph_index, argb); 1514 glyph_index, argb);
1515 return ret; 1515 return ret;
1516 } 1516 }
1517 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, FX_DWORD glyph _index, int dest_width) 1517 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, FX_DWORD glyph _index, int dest_width)
1518 { 1518 {
1519 if (m_Face == NULL || glyph_index == (FX_DWORD) - 1) { 1519 if (m_Face == NULL || glyph_index == (FX_DWORD) - 1) {
1520 return NULL; 1520 return NULL;
1521 } 1521 }
1522 CFX_PathData* pGlyphPath = NULL; 1522 CFX_PathData* pGlyphPath = NULL;
1523 void* key; 1523 void* key;
1524 if (pFont->GetSubstFont()) 1524 if (pFont->GetSubstFont())
1525 key = (void*)(uintptr_t)(glyph_index + ((pFont->GetSubstFont()->m_Weight / 16) << 15) + 1525 key = (void*)(uintptr_t)(glyph_index + ((pFont->GetSubstFont()->m_Weight / 16) << 15) +
1526 ((pFont->GetSubstFont()->m_ItalicAngle / 2 ) << 21) + ((dest_width / 16) << 25) + 1526 ((pFont->GetSubstFont()->m_ItalicAngle / 2 ) << 21) + ((dest_width / 16) << 25) +
1527 (pFont->IsVertical() << 31)); 1527 (pFont->IsVertical() << 31));
1528 else { 1528 else {
1529 key = (void*)(uintptr_t)glyph_index; 1529 key = (void*)(uintptr_t)glyph_index;
1530 } 1530 }
1531 if (m_PathMap.Lookup(key, (void*&)pGlyphPath)) { 1531 if (m_PathMap.Lookup(key, (void*&)pGlyphPath)) {
1532 return pGlyphPath; 1532 return pGlyphPath;
1533 } 1533 }
1534 pGlyphPath = pFont->LoadGlyphPath(glyph_index, dest_width); 1534 pGlyphPath = pFont->LoadGlyphPath(glyph_index, dest_width);
1535 m_PathMap.SetAt(key, pGlyphPath); 1535 m_PathMap.SetAt(key, pGlyphPath);
1536 return pGlyphPath; 1536 return pGlyphPath;
1537 } 1537 }
1538 typedef struct { 1538 typedef struct {
1539 FX_BOOL» » » m_bCount; 1539 bool» » » m_bCount;
1540 int m_PointCount; 1540 int m_PointCount;
1541 FX_PATHPOINT* m_pPoints; 1541 FX_PATHPOINT* m_pPoints;
1542 int m_CurX; 1542 int m_CurX;
1543 int m_CurY; 1543 int m_CurY;
1544 FX_FLOAT m_CoordUnit; 1544 FX_FLOAT m_CoordUnit;
1545 } OUTLINE_PARAMS; 1545 } OUTLINE_PARAMS;
1546 void _Outline_CheckEmptyContour(OUTLINE_PARAMS* param) 1546 void _Outline_CheckEmptyContour(OUTLINE_PARAMS* param)
1547 { 1547 {
1548 if (param->m_PointCount >= 2 && param->m_pPoints[param->m_PointCount - 2].m_ Flag == FXPT_MOVETO && 1548 if (param->m_PointCount >= 2 && param->m_pPoints[param->m_PointCount - 2].m_ Flag == FXPT_MOVETO &&
1549 param->m_pPoints[param->m_PointCount - 2].m_PointX == param->m_pPoin ts[param->m_PointCount - 1].m_PointX && 1549 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
1680 FXFT_Outline_Embolden(FXFT_Get_Glyph_Outline(m_Face), level); 1680 FXFT_Outline_Embolden(FXFT_Get_Glyph_Outline(m_Face), level);
1681 } 1681 }
1682 FXFT_Outline_Funcs funcs; 1682 FXFT_Outline_Funcs funcs;
1683 funcs.move_to = _Outline_MoveTo; 1683 funcs.move_to = _Outline_MoveTo;
1684 funcs.line_to = _Outline_LineTo; 1684 funcs.line_to = _Outline_LineTo;
1685 funcs.conic_to = _Outline_ConicTo; 1685 funcs.conic_to = _Outline_ConicTo;
1686 funcs.cubic_to = _Outline_CubicTo; 1686 funcs.cubic_to = _Outline_CubicTo;
1687 funcs.shift = 0; 1687 funcs.shift = 0;
1688 funcs.delta = 0; 1688 funcs.delta = 0;
1689 OUTLINE_PARAMS params; 1689 OUTLINE_PARAMS params;
1690 params.m_bCount = TRUE; 1690 params.m_bCount = true;
1691 params.m_PointCount = 0; 1691 params.m_PointCount = 0;
1692 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, &params); 1692 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, &params);
1693 if (params.m_PointCount == 0) { 1693 if (params.m_PointCount == 0) {
1694 return NULL; 1694 return NULL;
1695 } 1695 }
1696 CFX_PathData* pPath = new CFX_PathData; 1696 CFX_PathData* pPath = new CFX_PathData;
1697 pPath->SetPointCount(params.m_PointCount); 1697 pPath->SetPointCount(params.m_PointCount);
1698 params.m_bCount = FALSE; 1698 params.m_bCount = false;
1699 params.m_PointCount = 0; 1699 params.m_PointCount = 0;
1700 params.m_pPoints = pPath->GetPoints(); 1700 params.m_pPoints = pPath->GetPoints();
1701 params.m_CurX = params.m_CurY = 0; 1701 params.m_CurX = params.m_CurY = 0;
1702 params.m_CoordUnit = 64 * 64.0; 1702 params.m_CoordUnit = 64 * 64.0;
1703 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, &params); 1703 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, &params);
1704 _Outline_CheckEmptyContour(&params); 1704 _Outline_CheckEmptyContour(&params);
1705 pPath->TrimPoints(params.m_PointCount); 1705 pPath->TrimPoints(params.m_PointCount);
1706 if (params.m_PointCount) { 1706 if (params.m_PointCount) {
1707 pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; 1707 pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE;
1708 } 1708 }
1709 return pPath; 1709 return pPath;
1710 } 1710 }
1711 void _CFX_UniqueKeyGen::Generate(int count, ...) 1711 void _CFX_UniqueKeyGen::Generate(int count, ...)
1712 { 1712 {
1713 va_list argList; 1713 va_list argList;
1714 va_start(argList, count); 1714 va_start(argList, count);
1715 for (int i = 0; i < count; i ++) { 1715 for (int i = 0; i < count; i ++) {
1716 int p = va_arg(argList, int); 1716 int p = va_arg(argList, int);
1717 ((FX_DWORD*)m_Key)[i] = p; 1717 ((FX_DWORD*)m_Key)[i] = p;
1718 } 1718 }
1719 va_end(argList); 1719 va_end(argList);
1720 m_KeyLen = count * sizeof(FX_DWORD); 1720 m_KeyLen = count * sizeof(FX_DWORD);
1721 } 1721 }
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_ps.cpp ('k') | core/src/fxge/ge/text_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698