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.11 by root, Sun Aug 12 08:44:22 2007 UTC vs.
Revision 1.16 by root, Thu Nov 26 07:19:11 2009 UTC

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;
165
166static void
167apple_nvidia_bug (int enable)
168{
169 g_slice_free1 (TC_WIDTH * TC_HEIGHT, apple_nvidia_bug_buf);
170 apple_nvidia_bug_buf = enable ? g_slice_alloc (TC_WIDTH * TC_HEIGHT) : 0;
171}
172
173static void
174tex_update (int name, int x, int y, int w, int stride, int h, void *bm)
175{
176 glBindTexture (GL_TEXTURE_2D, name);
177
178 if (!apple_nvidia_bug_buf)
179 {
180 glPixelStorei (GL_UNPACK_ROW_LENGTH, stride);
181 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
182 glTexSubImage2D (GL_TEXTURE_2D, 0, x, y, w, h, GL_ALPHA, GL_UNSIGNED_BYTE, bm);
183 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
184 glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
185 }
186 else
187 {
188 /* 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, */
190 /* reading/patching/uploading the full texture one each change */
191 int r;
192
193 glGetTexImage (GL_TEXTURE_2D, 0, GL_ALPHA, GL_UNSIGNED_BYTE, apple_nvidia_bug_buf);
194
195 for (r = 0; r < h; ++r)
196 memcpy ((char *)apple_nvidia_bug_buf + (y + r) * TC_WIDTH + x, (char *)bm + r * stride, w);
197
198 glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, TC_WIDTH, TC_HEIGHT, 0, GL_ALPHA, GL_UNSIGNED_BYTE, apple_nvidia_bug_buf);
199 }
200}
201
164static void 202static void
165draw_glyph (PangoRenderer *renderer_, PangoFont *font, PangoGlyph glyph, double x, double y) 203draw_glyph (PangoRenderer *renderer_, PangoFont *font, PangoGlyph glyph, double x, double y)
166{ 204{
167 PangoOpenGLRenderer *renderer = PANGO_OPENGL_RENDERER (renderer_); 205 PangoOpenGLRenderer *renderer = PANGO_OPENGL_RENDERER (renderer_);
168 glyph_info *g; 206 glyph_info *g;
169 float x1, y1, x2, y2;
170 207
171 if (glyph & PANGO_GLYPH_UNKNOWN_FLAG) 208 if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
172 { 209 {
173 glyph = pango_opengl_get_unknown_glyph (font); 210 glyph = pango_opengl_get_unknown_glyph (font);
174 211
181 if (!g || g->generation != tc_generation) 218 if (!g || g->generation != tc_generation)
182 { 219 {
183 Glyph bm; 220 Glyph bm;
184 font_render_glyph (&bm, font, glyph); 221 font_render_glyph (&bm, font, glyph);
185 222
186 if (g) 223 if (!g)
187 g->generation = tc_generation;
188 else
189 { 224 {
190 g = g_slice_new (glyph_info); 225 g = g_slice_new (glyph_info);
191 226
192 _pango_opengl_font_set_glyph_cache_destroy (font, (GDestroyNotify)free_glyph_info); 227 _pango_opengl_font_set_glyph_cache_destroy (font, (GDestroyNotify)free_glyph_info);
193 _pango_opengl_font_set_cache_glyph_data (font, glyph, g); 228 _pango_opengl_font_set_cache_glyph_data (font, glyph, g);
194 } 229 }
195 230
196 tc_get (&g->tex, bm.width, bm.height); 231 g->generation = tc_generation;
197 232
198 g->left = bm.left; 233 g->left = bm.left;
199 g->top = bm.top; 234 g->top = bm.top;
200 235
201 glBindTexture (GL_TEXTURE_2D, g->tex.name); 236 tc_get (&g->tex, bm.width, bm.height);
202 glPixelStorei (GL_UNPACK_ROW_LENGTH, bm.stride); 237
203 glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 238 if (bm.width && bm.height)
204 glTexSubImage2D (GL_TEXTURE_2D, 0, g->tex.x, g->tex.y, bm.width, bm.height, GL_ALPHA, GL_UNSIGNED_BYTE, bm.bitmap); 239 tex_update (g->tex.name, g->tex.x, g->tex.y, bm.width, bm.stride, bm.height, bm.bitmap);
205 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
206 glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
207 } 240 }
208 241
209 x += g->left; 242 x += g->left;
210 y -= g->top; 243 y -= g->top;
211 244
277 int x, int y, 310 int x, int y,
278 float r, float g, float b, float a, 311 float r, float g, float b, float a,
279 int flags) 312 int flags)
280{ 313{
281 pango_opengl_render_layout_subpixel ( 314 pango_opengl_render_layout_subpixel (
282 layout, rc, x * PANGO_SCALE, y * PANGO_SCALE, r, g, b, a, flags 315 layout, rc, x * PANGO_SCALE, y * PANGO_SCALE, r, g, b, a, flags
283 ); 316 );
284} 317}
285 318
286static void 319static void
287pango_opengl_renderer_init (PangoOpenGLRenderer *renderer) 320pango_opengl_renderer_init (PangoOpenGLRenderer *renderer)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines