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.12 by root, Mon Aug 13 15:31:21 2007 UTC vs.
Revision 1.17 by root, Sun Nov 29 14:45:12 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 int apple_nvidia_bug_workaround;
165
166static void
167apple_nvidia_bug (int enable)
168{
169 apple_nvidia_bug_workaround = enable;
170}
171
172static void
173tex_update (int name, int x, int y, int w, int stride, int h, void *bm)
174{
175 glBindTexture (GL_TEXTURE_2D, name);
176
177 if (!apple_nvidia_bug_workaround)
178 {
179 glPixelStorei (GL_UNPACK_ROW_LENGTH, stride);
180 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
181 glTexSubImage2D (GL_TEXTURE_2D, 0, x, y, w, h, GL_ALPHA, GL_UNSIGNED_BYTE, bm);
182 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
183 glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
184 }
185 else
186 {
187 /* starting with 10.5.5 (or 10.5.6), pple's nvidia driver corrupts textures */
188 /* when glTexSubImage is used, so do it the horribly slow way, */
189 /* reading/patching/uploading the full texture one each change */
190 int r;
191
192 glGetTexImage (GL_TEXTURE_2D, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tc_temptile);
193
194 for (r = 0; r < h; ++r)
195 memcpy (tc_temptile + (y + r) * TC_WIDTH + x, (char *)bm + r * stride, w);
196
197 glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, TC_WIDTH, TC_HEIGHT, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tc_temptile);
198 }
199}
200
164static void 201static void
165draw_glyph (PangoRenderer *renderer_, PangoFont *font, PangoGlyph glyph, double x, double y) 202draw_glyph (PangoRenderer *renderer_, PangoFont *font, PangoGlyph glyph, double x, double y)
166{ 203{
167 PangoOpenGLRenderer *renderer = PANGO_OPENGL_RENDERER (renderer_); 204 PangoOpenGLRenderer *renderer = PANGO_OPENGL_RENDERER (renderer_);
168 glyph_info *g; 205 glyph_info *g;
180 if (!g || g->generation != tc_generation) 217 if (!g || g->generation != tc_generation)
181 { 218 {
182 Glyph bm; 219 Glyph bm;
183 font_render_glyph (&bm, font, glyph); 220 font_render_glyph (&bm, font, glyph);
184 221
185 if (g) 222 if (!g)
186 g->generation = tc_generation;
187 else
188 { 223 {
189 g = g_slice_new (glyph_info); 224 g = g_slice_new (glyph_info);
190 225
191 _pango_opengl_font_set_glyph_cache_destroy (font, (GDestroyNotify)free_glyph_info); 226 _pango_opengl_font_set_glyph_cache_destroy (font, (GDestroyNotify)free_glyph_info);
192 _pango_opengl_font_set_cache_glyph_data (font, glyph, g); 227 _pango_opengl_font_set_cache_glyph_data (font, glyph, g);
193 } 228 }
194 229
195 tc_get (&g->tex, bm.width, bm.height); 230 g->generation = tc_generation;
196 231
197 g->left = bm.left; 232 g->left = bm.left;
198 g->top = bm.top; 233 g->top = bm.top;
199 234
200 glBindTexture (GL_TEXTURE_2D, g->tex.name); 235 tc_get (&g->tex, bm.width, bm.height);
201 glPixelStorei (GL_UNPACK_ROW_LENGTH, bm.stride); 236
202 glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 237 if (bm.width && bm.height)
203 glTexSubImage2D (GL_TEXTURE_2D, 0, g->tex.x, g->tex.y, bm.width, bm.height, GL_ALPHA, GL_UNSIGNED_BYTE, bm.bitmap); 238 tex_update (g->tex.name, g->tex.x, g->tex.y, bm.width, bm.stride, bm.height, bm.bitmap);
204 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
205 glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
206 } 239 }
207 240
208 x += g->left; 241 x += g->left;
209 y -= g->top; 242 y -= g->top;
210 243
276 int x, int y, 309 int x, int y,
277 float r, float g, float b, float a, 310 float r, float g, float b, float a,
278 int flags) 311 int flags)
279{ 312{
280 pango_opengl_render_layout_subpixel ( 313 pango_opengl_render_layout_subpixel (
281 layout, rc, x * PANGO_SCALE, y * PANGO_SCALE, r, g, b, a, flags 314 layout, rc, x * PANGO_SCALE, y * PANGO_SCALE, r, g, b, a, flags
282 ); 315 );
283} 316}
284 317
285static void 318static void
286pango_opengl_renderer_init (PangoOpenGLRenderer *renderer) 319pango_opengl_renderer_init (PangoOpenGLRenderer *renderer)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines