--- deliantra/Deliantra-Client/pango-render.c 2008/01/13 08:22:33 1.14 +++ deliantra/Deliantra-Client/pango-render.c 2018/11/18 00:52:22 1.19 @@ -62,7 +62,7 @@ size = (size + 4095) & ~4095; free (buffer); alloc = size; - buffer = malloc (size); + buffer = (char *)malloc (size); } return buffer; @@ -92,7 +92,7 @@ glyph->top = top; glyph->left = left; - glyph->bitmap = temp_buffer (width * height); + glyph->bitmap = (uint8_t *)temp_buffer (width * height); memset (glyph->bitmap, 0, glyph->stride * height); for (i = width; i--; ) @@ -161,6 +161,43 @@ g_slice_free (glyph_info, g); } +static int apple_nvidia_bug_workaround; + +static void +apple_nvidia_bug (int enable) +{ + apple_nvidia_bug_workaround = enable; +} + +static void +tex_update (int name, int x, int y, int w, int stride, int h, void *bm) +{ + glBindTexture (GL_TEXTURE_2D, name); + + if (!apple_nvidia_bug_workaround) + { + glPixelStorei (GL_UNPACK_ROW_LENGTH, stride); + /*glPixelStorei (GL_UNPACK_ALIGNMENT, 1); expected cfplus default */ + glTexSubImage2D (GL_TEXTURE_2D, 0, x, y, w, h, GL_ALPHA, GL_UNSIGNED_BYTE, bm); + /*glPixelStorei (GL_UNPACK_ALIGNMENT, 4);*/ + glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); + } + else + { + /* starting with 10.5.5 (or 10.5.6), pple's nvidia driver corrupts textures */ + /* when glTexSubImage is used, so do it the horribly slow way, */ + /* reading/patching/uploading the full texture one each change */ + int r; + + glGetTexImage (GL_TEXTURE_2D, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tc_temptile); + + for (r = 0; r < h; ++r) + memcpy (tc_temptile + (y + r) * TC_WIDTH + x, (char *)bm + r * stride, w); + + glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, TC_WIDTH, TC_HEIGHT, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tc_temptile); + } +} + static void draw_glyph (PangoRenderer *renderer_, PangoFont *font, PangoGlyph glyph, double x, double y) { @@ -175,7 +212,7 @@ glyph = PANGO_GLYPH_UNKNOWN_FLAG; } - g = _pango_opengl_font_get_cache_glyph_data (font, glyph); + g = (glyph_info *)_pango_opengl_font_get_cache_glyph_data (font, glyph); if (!g || g->generation != tc_generation) { @@ -191,20 +228,14 @@ } g->generation = tc_generation; - tc_get (&g->tex, bm.width, bm.height); g->left = bm.left; g->top = bm.top; + tc_get (&g->tex, bm.width, bm.height); + if (bm.width && bm.height) - { - glBindTexture (GL_TEXTURE_2D, g->tex.name); - glPixelStorei (GL_UNPACK_ROW_LENGTH, bm.stride); - glPixelStorei (GL_UNPACK_ALIGNMENT, 1); - glTexSubImage2D (GL_TEXTURE_2D, 0, g->tex.x, g->tex.y, bm.width, bm.height, GL_ALPHA, GL_UNSIGNED_BYTE, bm.bitmap); - glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei (GL_UNPACK_ALIGNMENT, 4); - } + tex_update (g->tex.name, g->tex.x, g->tex.y, bm.width, bm.stride, bm.height, bm.bitmap); } x += g->left; @@ -280,7 +311,7 @@ int flags) { pango_opengl_render_layout_subpixel ( - layout, rc, x * PANGO_SCALE, y * PANGO_SCALE, r, g, b, a, flags + layout, rc, x * PANGO_SCALE, y * PANGO_SCALE, r, g, b, a, flags ); } @@ -312,12 +343,12 @@ for (l = run->item->analysis.extra_attrs; l; l = l->next) { - PangoAttribute *attr = l->data; + PangoAttribute *attr = (PangoAttribute *)l->data; switch (attr->klass->type) { case PANGO_ATTR_UNDERLINE: - renderer->underline = ((PangoAttrInt *)attr)->value; + renderer->underline = (PangoUnderline)((PangoAttrInt *)attr)->value; break; case PANGO_ATTR_STRIKETHROUGH: