… | |
… | |
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 | |
164 | static char *apple_nvidia_bug_buf; |
164 | static int apple_nvidia_bug_workaround; |
165 | |
165 | |
166 | static void |
166 | static void |
167 | apple_nvidia_bug (int enable) |
167 | apple_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 | |
173 | static void |
172 | static void |
174 | tex_update (int name, int x, int y, int w, int stride, int h, void *bm) |
173 | tex_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 | |
202 | static void |
201 | static void |
203 | draw_glyph (PangoRenderer *renderer_, PangoFont *font, PangoGlyph glyph, double x, double y) |
202 | draw_glyph (PangoRenderer *renderer_, PangoFont *font, PangoGlyph glyph, double x, double y) |