ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/pango-render.c
(Generate patch)

Comparing deliantra/Deliantra-Client/pango-render.c (file contents):
Revision 1.16 by root, Thu Nov 26 07:19:11 2009 UTC vs.
Revision 1.19 by root, Sun Nov 18 00:52:22 2018 UTC

60 if (size > alloc) 60 if (size > alloc)
61 { 61 {
62 size = (size + 4095) & ~4095; 62 size = (size + 4095) & ~4095;
63 free (buffer); 63 free (buffer);
64 alloc = size; 64 alloc = size;
65 buffer = malloc (size); 65 buffer = (char *)malloc (size);
66 } 66 }
67 67
68 return buffer; 68 return buffer;
69} 69}
70 70
90 glyph->width = width; 90 glyph->width = width;
91 glyph->height = height; 91 glyph->height = height;
92 glyph->top = top; 92 glyph->top = top;
93 glyph->left = left; 93 glyph->left = left;
94 94
95 glyph->bitmap = temp_buffer (width * height); 95 glyph->bitmap = (uint8_t *)temp_buffer (width * height);
96 memset (glyph->bitmap, 0, glyph->stride * height); 96 memset (glyph->bitmap, 0, glyph->stride * height);
97 97
98 for (i = width; i--; ) 98 for (i = width; i--; )
99 glyph->bitmap [i] = glyph->bitmap [i + (height - 1) * glyph->stride] = 0xff; 99 glyph->bitmap [i] = glyph->bitmap [i + (height - 1) * glyph->stride] = 0xff;
100 100
159{ 159{
160 tc_put (&g->tex); 160 tc_put (&g->tex);
161 g_slice_free (glyph_info, g); 161 g_slice_free (glyph_info, g);
162} 162}
163 163
164static char *apple_nvidia_bug_buf; 164static int apple_nvidia_bug_workaround;
165 165
166static void 166static void
167apple_nvidia_bug (int enable) 167apple_nvidia_bug (int enable)
168{ 168{
169 g_slice_free1 (TC_WIDTH * TC_HEIGHT, apple_nvidia_bug_buf); 169 apple_nvidia_bug_workaround = enable;
170 apple_nvidia_bug_buf = enable ? g_slice_alloc (TC_WIDTH * TC_HEIGHT) : 0;
171} 170}
172 171
173static void 172static void
174tex_update (int name, int x, int y, int w, int stride, int h, void *bm) 173tex_update (int name, int x, int y, int w, int stride, int h, void *bm)
175{ 174{
176 glBindTexture (GL_TEXTURE_2D, name); 175 glBindTexture (GL_TEXTURE_2D, name);
177 176
178 if (!apple_nvidia_bug_buf) 177 if (!apple_nvidia_bug_workaround)
179 { 178 {
180 glPixelStorei (GL_UNPACK_ROW_LENGTH, stride); 179 glPixelStorei (GL_UNPACK_ROW_LENGTH, stride);
181 glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 180 /*glPixelStorei (GL_UNPACK_ALIGNMENT, 1); expected cfplus default */
182 glTexSubImage2D (GL_TEXTURE_2D, 0, x, y, w, h, GL_ALPHA, GL_UNSIGNED_BYTE, bm); 181 glTexSubImage2D (GL_TEXTURE_2D, 0, x, y, w, h, GL_ALPHA, GL_UNSIGNED_BYTE, bm);
182 /*glPixelStorei (GL_UNPACK_ALIGNMENT, 4);*/
183 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); 183 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
184 glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
185 } 184 }
186 else 185 else
187 { 186 {
188 /* starting with 10.5.5 (or 10.5.6), pple's nvidia driver corrupts textures */ 187 /* starting with 10.5.5 (or 10.5.6), pple's nvidia driver corrupts textures */
189 /* when glTexSubImage is used, so do it the horribly slow way, */ 188 /* when glTexSubImage is used, so do it the horribly slow way, */
190 /* reading/patching/uploading the full texture one each change */ 189 /* reading/patching/uploading the full texture one each change */
191 int r; 190 int r;
192 191
193 glGetTexImage (GL_TEXTURE_2D, 0, GL_ALPHA, GL_UNSIGNED_BYTE, apple_nvidia_bug_buf); 192 glGetTexImage (GL_TEXTURE_2D, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tc_temptile);
194 193
195 for (r = 0; r < h; ++r) 194 for (r = 0; r < h; ++r)
196 memcpy ((char *)apple_nvidia_bug_buf + (y + r) * TC_WIDTH + x, (char *)bm + r * stride, w); 195 memcpy (tc_temptile + (y + r) * TC_WIDTH + x, (char *)bm + r * stride, w);
197 196
198 glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, TC_WIDTH, TC_HEIGHT, 0, GL_ALPHA, GL_UNSIGNED_BYTE, apple_nvidia_bug_buf); 197 glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, TC_WIDTH, TC_HEIGHT, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tc_temptile);
199 } 198 }
200} 199}
201 200
202static void 201static void
203draw_glyph (PangoRenderer *renderer_, PangoFont *font, PangoGlyph glyph, double x, double y) 202draw_glyph (PangoRenderer *renderer_, PangoFont *font, PangoGlyph glyph, double x, double y)
211 210
212 if (glyph == PANGO_GLYPH_EMPTY) 211 if (glyph == PANGO_GLYPH_EMPTY)
213 glyph = PANGO_GLYPH_UNKNOWN_FLAG; 212 glyph = PANGO_GLYPH_UNKNOWN_FLAG;
214 } 213 }
215 214
216 g = _pango_opengl_font_get_cache_glyph_data (font, glyph); 215 g = (glyph_info *)_pango_opengl_font_get_cache_glyph_data (font, glyph);
217 216
218 if (!g || g->generation != tc_generation) 217 if (!g || g->generation != tc_generation)
219 { 218 {
220 Glyph bm; 219 Glyph bm;
221 font_render_glyph (&bm, font, glyph); 220 font_render_glyph (&bm, font, glyph);
342 gl->key.format = 0; // glyphs 341 gl->key.format = 0; // glyphs
343 gl->key.texname = 0; 342 gl->key.texname = 0;
344 343
345 for (l = run->item->analysis.extra_attrs; l; l = l->next) 344 for (l = run->item->analysis.extra_attrs; l; l = l->next)
346 { 345 {
347 PangoAttribute *attr = l->data; 346 PangoAttribute *attr = (PangoAttribute *)l->data;
348 347
349 switch (attr->klass->type) 348 switch (attr->klass->type)
350 { 349 {
351 case PANGO_ATTR_UNDERLINE: 350 case PANGO_ATTR_UNDERLINE:
352 renderer->underline = ((PangoAttrInt *)attr)->value; 351 renderer->underline = (PangoUnderline)((PangoAttrInt *)attr)->value;
353 break; 352 break;
354 353
355 case PANGO_ATTR_STRIKETHROUGH: 354 case PANGO_ATTR_STRIKETHROUGH:
356 renderer->strikethrough = ((PangoAttrInt *)attr)->value; 355 renderer->strikethrough = ((PangoAttrInt *)attr)->value;
357 break; 356 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines