… | |
… | |
146 | } |
146 | } |
147 | |
147 | |
148 | typedef struct glyph_info { |
148 | typedef struct glyph_info { |
149 | tc_area tex; |
149 | tc_area tex; |
150 | int left, top; |
150 | int left, top; |
|
|
151 | int generation; |
151 | } glyph_info; |
152 | } glyph_info; |
152 | |
153 | |
153 | static void |
154 | static void |
154 | free_glyph_info (glyph_info *g) |
155 | free_glyph_info (glyph_info *g) |
155 | { |
156 | { |
… | |
… | |
172 | glyph = PANGO_GLYPH_UNKNOWN_FLAG; |
173 | glyph = PANGO_GLYPH_UNKNOWN_FLAG; |
173 | } |
174 | } |
174 | |
175 | |
175 | g = _pango_opengl_font_get_cache_glyph_data (font, glyph); |
176 | g = _pango_opengl_font_get_cache_glyph_data (font, glyph); |
176 | |
177 | |
177 | if (!g) |
178 | if (!g || g->generation != tc_generation) |
178 | { |
179 | { |
179 | Glyph bm; |
180 | Glyph bm; |
180 | font_render_glyph (&bm, font, glyph); |
181 | font_render_glyph (&bm, font, glyph); |
181 | |
182 | |
|
|
183 | if (g) |
|
|
184 | g->generation = tc_generation; |
|
|
185 | else |
|
|
186 | { |
182 | g = g_slice_new (glyph_info); |
187 | g = g_slice_new (glyph_info); |
|
|
188 | |
|
|
189 | _pango_opengl_font_set_glyph_cache_destroy (font, (GDestroyNotify)free_glyph_info); |
|
|
190 | _pango_opengl_font_set_cache_glyph_data (font, glyph, g); |
|
|
191 | } |
|
|
192 | |
|
|
193 | if (renderer->curtex) |
|
|
194 | glEnd (); |
183 | |
195 | |
184 | tc_get (&g->tex, bm.width, bm.height); |
196 | tc_get (&g->tex, bm.width, bm.height); |
185 | |
197 | |
186 | g->left = bm.left; |
198 | g->left = bm.left; |
187 | g->top = bm.top; |
199 | g->top = bm.top; |
188 | |
|
|
189 | if (renderer->curtex) |
|
|
190 | { |
|
|
191 | glEnd (); |
|
|
192 | renderer->curtex = 0; |
|
|
193 | } |
|
|
194 | |
200 | |
195 | glBindTexture (GL_TEXTURE_2D, g->tex.name); |
201 | glBindTexture (GL_TEXTURE_2D, g->tex.name); |
196 | glPixelStorei (GL_UNPACK_ROW_LENGTH, bm.stride); |
202 | glPixelStorei (GL_UNPACK_ROW_LENGTH, bm.stride); |
197 | glPixelStorei (GL_UNPACK_ALIGNMENT, 1); |
203 | glPixelStorei (GL_UNPACK_ALIGNMENT, 1); |
198 | glTexSubImage2D (GL_TEXTURE_2D, 0, g->tex.x, g->tex.y, bm.width, bm.height, GL_ALPHA, GL_UNSIGNED_BYTE, bm.bitmap); |
204 | glTexSubImage2D (GL_TEXTURE_2D, 0, g->tex.x, g->tex.y, bm.width, bm.height, GL_ALPHA, GL_UNSIGNED_BYTE, bm.bitmap); |
199 | glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); |
205 | glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); |
200 | glPixelStorei (GL_UNPACK_ALIGNMENT, 4); |
206 | glPixelStorei (GL_UNPACK_ALIGNMENT, 4); |
201 | |
207 | |
202 | _pango_opengl_font_set_glyph_cache_destroy (font, (GDestroyNotify)free_glyph_info); |
208 | renderer->curtex = g->tex.name; |
203 | _pango_opengl_font_set_cache_glyph_data (font, glyph, g); |
209 | glBegin (GL_QUADS); |
204 | } |
210 | } |
205 | |
211 | |
206 | x += g->left; |
212 | x += g->left; |
207 | y -= g->top; |
213 | y -= g->top; |
208 | |
214 | |
… | |
… | |
216 | if (renderer->curtex) |
222 | if (renderer->curtex) |
217 | glEnd (); |
223 | glEnd (); |
218 | |
224 | |
219 | glBindTexture (GL_TEXTURE_2D, g->tex.name); |
225 | glBindTexture (GL_TEXTURE_2D, g->tex.name); |
220 | renderer->curtex = g->tex.name; |
226 | renderer->curtex = g->tex.name; |
|
|
227 | |
221 | glBegin (GL_QUADS); |
228 | glBegin (GL_QUADS); |
222 | } |
229 | } |
223 | |
230 | |
224 | glTexCoord2f (x1, y1); glVertex2i (x , y ); |
231 | glTexCoord2f (x1, y1); glVertex2i (x , y ); |
225 | glTexCoord2f (x2, y1); glVertex2i (x + g->tex.w, y ); |
232 | glTexCoord2f (x2, y1); glVertex2i (x + g->tex.w, y ); |