diff options
Diffstat (limited to 'meta/packages/gtk+/gtk+-2.12.3/pangoxft2.10.6.diff')
-rw-r--r-- | meta/packages/gtk+/gtk+-2.12.3/pangoxft2.10.6.diff | 2456 |
1 files changed, 2456 insertions, 0 deletions
diff --git a/meta/packages/gtk+/gtk+-2.12.3/pangoxft2.10.6.diff b/meta/packages/gtk+/gtk+-2.12.3/pangoxft2.10.6.diff new file mode 100644 index 0000000000..63828cec63 --- /dev/null +++ b/meta/packages/gtk+/gtk+-2.12.3/pangoxft2.10.6.diff | |||
@@ -0,0 +1,2456 @@ | |||
1 | http://mail.gnome.org/archives/performance-list/2006-October/msg00063.html | ||
2 | |||
3 | From: Xan Lópe | ||
4 | To: ext Matt Hoosier | ||
5 | Cc: performance-list gnome org | ||
6 | Subject: Re: [patch] Remove pangocairo from Gtk+ 2.8.20 | ||
7 | Date: Mon, 30 Oct 2006 14:31:56 +0200 | ||
8 | Hi, | ||
9 | |||
10 | I've upgraded your patch against GTK+ 2.10.6, and we are getting great | ||
11 | performance figures compared to GTK+ 2.10.6 with pangocairo too | ||
12 | (basically at the level of GTK+ 2.6.10 again). Right now I'm working on | ||
13 | a python/cairo script to get some nice graphics from a torture test | ||
14 | session with several GTK+s, hope to get it ready soon. | ||
15 | |||
16 | Index: gtk+-2.10.6/configure.in | ||
17 | =================================================================== | ||
18 | --- gtk+-2.10.6.orig/configure.in 2006-10-30 12:59:28.000000000 +0000 | ||
19 | +++ gtk+-2.10.6/configure.in 2006-10-30 12:59:30.000000000 +0000 | ||
20 | @@ -1435,7 +1435,7 @@ | ||
21 | if test "x$gdktarget" = "xwin32"; then | ||
22 | PANGO_PACKAGES="pangowin32 pangocairo" | ||
23 | else | ||
24 | - PANGO_PACKAGES="pango pangocairo" | ||
25 | + PANGO_PACKAGES="pango pangocairo pangoxft" | ||
26 | fi | ||
27 | |||
28 | AC_MSG_CHECKING(Pango flags) | ||
29 | Index: gtk+-2.10.6/gdk/gdkaliasdef.c | ||
30 | =================================================================== | ||
31 | --- gtk+-2.10.6.orig/gdk/gdkaliasdef.c 2006-10-30 12:58:29.000000000 +0000 | ||
32 | +++ gtk+-2.10.6/gdk/gdkaliasdef.c 2006-10-30 12:59:30.000000000 +0000 | ||
33 | @@ -1799,9 +1799,6 @@ | ||
34 | #undef gdk_pango_context_get | ||
35 | extern __typeof (gdk_pango_context_get) gdk_pango_context_get __attribute((alias("IA__gdk_pango_context_get"), visibility("default"))); | ||
36 | |||
37 | -#undef gdk_pango_context_get_for_screen | ||
38 | -extern __typeof (gdk_pango_context_get_for_screen) gdk_pango_context_get_for_screen __attribute((alias("IA__gdk_pango_context_get_for_screen"), visibility("default"))); | ||
39 | - | ||
40 | #ifndef GDK_DISABLE_DEPRECATED | ||
41 | #undef gdk_pango_context_set_colormap | ||
42 | extern __typeof (gdk_pango_context_set_colormap) gdk_pango_context_set_colormap __attribute((alias("IA__gdk_pango_context_set_colormap"), visibility("default"))); | ||
43 | @@ -1836,6 +1833,13 @@ | ||
44 | |||
45 | #endif | ||
46 | #endif | ||
47 | +#if IN_HEADER(__GDK_PANGO_H__) | ||
48 | +#if IN_FILE(__GDK_PANGO_X11_C__) | ||
49 | +#undef gdk_pango_context_get_for_screen | ||
50 | +extern __typeof (gdk_pango_context_get_for_screen) gdk_pango_context_get_for_screen __attribute((alias("IA__gdk_pango_context_get_for_screen"), visibility("default"))); | ||
51 | + | ||
52 | +#endif | ||
53 | +#endif | ||
54 | #if IN_HEADER(__GDK_PIXBUF_H__) | ||
55 | #if IN_FILE(__GDK_PIXBUF_DRAWABLE_C__) | ||
56 | #undef gdk_pixbuf_get_from_drawable | ||
57 | Index: gtk+-2.10.6/gdk/gdkalias.h | ||
58 | =================================================================== | ||
59 | --- gtk+-2.10.6.orig/gdk/gdkalias.h 2006-10-30 12:58:29.000000000 +0000 | ||
60 | +++ gtk+-2.10.6/gdk/gdkalias.h 2006-10-30 12:59:30.000000000 +0000 | ||
61 | @@ -1796,9 +1796,6 @@ | ||
62 | extern __typeof (gdk_pango_context_get) IA__gdk_pango_context_get __attribute((visibility("hidden"))); | ||
63 | #define gdk_pango_context_get IA__gdk_pango_context_get | ||
64 | |||
65 | -extern __typeof (gdk_pango_context_get_for_screen) IA__gdk_pango_context_get_for_screen __attribute((visibility("hidden"))); | ||
66 | -#define gdk_pango_context_get_for_screen IA__gdk_pango_context_get_for_screen | ||
67 | - | ||
68 | #ifndef GDK_DISABLE_DEPRECATED | ||
69 | extern __typeof (gdk_pango_context_set_colormap) IA__gdk_pango_context_set_colormap __attribute((visibility("hidden"))); | ||
70 | #define gdk_pango_context_set_colormap IA__gdk_pango_context_set_colormap | ||
71 | @@ -1833,6 +1830,13 @@ | ||
72 | |||
73 | #endif | ||
74 | #endif | ||
75 | +#if IN_HEADER(__GDK_PANGO_H__) | ||
76 | +#if IN_FILE(__GDK_PANGO_X11_C__) | ||
77 | +extern __typeof (gdk_pango_context_get_for_screen) IA__gdk_pango_context_get_for_screen __attribute((visibility("hidden"))); | ||
78 | +#define gdk_pango_context_get_for_screen IA__gdk_pango_context_get_for_screen | ||
79 | + | ||
80 | +#endif | ||
81 | +#endif | ||
82 | #if IN_HEADER(__GDK_PIXBUF_H__) | ||
83 | #if IN_FILE(__GDK_PIXBUF_DRAWABLE_C__) | ||
84 | extern __typeof (gdk_pixbuf_get_from_drawable) IA__gdk_pixbuf_get_from_drawable __attribute((visibility("hidden"))); | ||
85 | Index: gtk+-2.10.6/gdk/gdkdraw.c | ||
86 | =================================================================== | ||
87 | --- gtk+-2.10.6.orig/gdk/gdkdraw.c 2006-10-30 12:58:29.000000000 +0000 | ||
88 | +++ gtk+-2.10.6/gdk/gdkdraw.c 2006-10-30 12:59:30.000000000 +0000 | ||
89 | @@ -909,9 +909,9 @@ | ||
90 | { | ||
91 | g_return_if_fail (GDK_IS_DRAWABLE (drawable)); | ||
92 | g_return_if_fail (GDK_IS_GC (gc)); | ||
93 | - | ||
94 | - real_draw_glyphs (drawable, gc, NULL, font, | ||
95 | - x, y, glyphs); | ||
96 | + | ||
97 | + | ||
98 | + GDK_DRAWABLE_GET_CLASS (drawable)->draw_glyphs (drawable, gc, font, x, y, glyphs); | ||
99 | } | ||
100 | |||
101 | /** | ||
102 | @@ -949,8 +949,9 @@ | ||
103 | g_return_if_fail (GDK_IS_DRAWABLE (drawable)); | ||
104 | g_return_if_fail (GDK_IS_GC (gc)); | ||
105 | |||
106 | - real_draw_glyphs (drawable, gc, matrix, font, | ||
107 | - x / PANGO_SCALE, y / PANGO_SCALE, glyphs); | ||
108 | + if (GDK_DRAWABLE_GET_CLASS (drawable)->draw_glyphs_transformed) | ||
109 | + GDK_DRAWABLE_GET_CLASS (drawable)->draw_glyphs_transformed (drawable, gc, matrix, | ||
110 | + font, x, y, glyphs); | ||
111 | } | ||
112 | |||
113 | /** | ||
114 | @@ -974,28 +975,12 @@ | ||
115 | GdkTrapezoid *trapezoids, | ||
116 | gint n_trapezoids) | ||
117 | { | ||
118 | - cairo_t *cr; | ||
119 | - int i; | ||
120 | - | ||
121 | g_return_if_fail (GDK_IS_DRAWABLE (drawable)); | ||
122 | g_return_if_fail (GDK_IS_GC (gc)); | ||
123 | g_return_if_fail (n_trapezoids == 0 || trapezoids != NULL); | ||
124 | |||
125 | - cr = gdk_cairo_create (drawable); | ||
126 | - _gdk_gc_update_context (gc, cr, NULL, NULL, TRUE); | ||
127 | - | ||
128 | - for (i = 0; i < n_trapezoids; i++) | ||
129 | - { | ||
130 | - cairo_move_to (cr, trapezoids[i].x11, trapezoids[i].y1); | ||
131 | - cairo_line_to (cr, trapezoids[i].x21, trapezoids[i].y1); | ||
132 | - cairo_line_to (cr, trapezoids[i].x22, trapezoids[i].y2); | ||
133 | - cairo_line_to (cr, trapezoids[i].x21, trapezoids[i].y2); | ||
134 | - cairo_close_path (cr); | ||
135 | - } | ||
136 | - | ||
137 | - cairo_fill (cr); | ||
138 | - | ||
139 | - cairo_destroy (cr); | ||
140 | + GDK_DRAWABLE_GET_CLASS (drawable)->draw_trapezoids (drawable, gc, | ||
141 | + trapezoids, n_trapezoids); | ||
142 | } | ||
143 | |||
144 | /** | ||
145 | Index: gtk+-2.10.6/gdk/gdkpango.c | ||
146 | =================================================================== | ||
147 | --- gtk+-2.10.6.orig/gdk/gdkpango.c 2006-10-30 12:58:29.000000000 +0000 | ||
148 | +++ gtk+-2.10.6/gdk/gdkpango.c 2006-10-30 12:59:30.000000000 +0000 | ||
149 | @@ -50,19 +50,34 @@ | ||
150 | GdkBitmap *stipple[MAX_RENDER_PART + 1]; | ||
151 | gboolean embossed; | ||
152 | |||
153 | - cairo_t *cr; | ||
154 | - PangoRenderPart last_part; | ||
155 | + /* When switching between the normal and shadow copies when | ||
156 | + * drawing shadows we can get unexpected recursion into the | ||
157 | + * drawing functions; the 'in_emboss' flag guards against that. | ||
158 | + */ | ||
159 | + gboolean in_emboss; | ||
160 | |||
161 | /* Current target */ | ||
162 | GdkDrawable *drawable; | ||
163 | GdkGC *base_gc; | ||
164 | |||
165 | gboolean gc_changed; | ||
166 | + | ||
167 | + /* Cached GC, derived from base_gc */ | ||
168 | + GdkGC *gc; | ||
169 | + PangoColor gc_color; | ||
170 | + gboolean gc_color_set; | ||
171 | + GdkBitmap *gc_stipple; | ||
172 | + | ||
173 | + /* we accumulate trapezoids for the same PangoRenderPart */ | ||
174 | + GArray *trapezoids; | ||
175 | + PangoRenderPart trapezoid_part; | ||
176 | }; | ||
177 | |||
178 | static PangoAttrType gdk_pango_attr_stipple_type; | ||
179 | static PangoAttrType gdk_pango_attr_embossed_type; | ||
180 | |||
181 | +static void flush_trapezoids (GdkPangoRenderer *gdk_renderer); | ||
182 | + | ||
183 | enum { | ||
184 | PROP_0, | ||
185 | PROP_SCREEN | ||
186 | @@ -77,6 +92,10 @@ | ||
187 | GdkPangoRendererPrivate *priv = gdk_renderer->priv; | ||
188 | int i; | ||
189 | |||
190 | + if (priv->gc) | ||
191 | + g_object_unref (priv->gc); | ||
192 | + if (priv->gc_stipple) | ||
193 | + g_object_unref (priv->gc_stipple); | ||
194 | if (priv->base_gc) | ||
195 | g_object_unref (priv->base_gc); | ||
196 | if (priv->drawable) | ||
197 | @@ -86,6 +105,8 @@ | ||
198 | if (priv->stipple[i]) | ||
199 | g_object_unref (priv->stipple[i]); | ||
200 | |||
201 | + g_array_free (priv->trapezoids, TRUE); | ||
202 | + | ||
203 | G_OBJECT_CLASS (gdk_pango_renderer_parent_class)->finalize (object); | ||
204 | } | ||
205 | |||
206 | @@ -112,25 +133,6 @@ | ||
207 | return object; | ||
208 | } | ||
209 | |||
210 | -/* Adjusts matrix and color for the renderer to draw the secondary | ||
211 | - * "shadow" copy for embossed text */ | ||
212 | -static void | ||
213 | -emboss_context (cairo_t *cr) | ||
214 | -{ | ||
215 | - cairo_matrix_t tmp_matrix; | ||
216 | - | ||
217 | - /* The gymnastics here to adjust the matrix are because we want | ||
218 | - * to offset by +1,+1 in device-space, not in user-space, | ||
219 | - * so we can't just draw the layout at x + 1, y + 1 | ||
220 | - */ | ||
221 | - cairo_get_matrix (cr, &tmp_matrix); | ||
222 | - tmp_matrix.x0 += 1.0; | ||
223 | - tmp_matrix.y0 += 1.0; | ||
224 | - cairo_set_matrix (cr, &tmp_matrix); | ||
225 | - | ||
226 | - cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); | ||
227 | -} | ||
228 | - | ||
229 | static inline gboolean | ||
230 | color_equal (PangoColor *c1, PangoColor *c2) | ||
231 | { | ||
232 | @@ -146,74 +148,154 @@ | ||
233 | return FALSE; | ||
234 | } | ||
235 | |||
236 | -static cairo_t * | ||
237 | -get_cairo_context (GdkPangoRenderer *gdk_renderer, | ||
238 | - PangoRenderPart part) | ||
239 | +/* Adjusts matrix and color for the renderer to draw the secondar | ||
240 | + * "shadow" copy for embossed text */ | ||
241 | +static void | ||
242 | +emboss_renderer (PangoRenderer *renderer, | ||
243 | + PangoRenderPart part, | ||
244 | + PangoMatrix **save_matrix, | ||
245 | + PangoColor **save_color) | ||
246 | +{ | ||
247 | + GdkPangoRendererPrivate *priv = GDK_PANGO_RENDERER(renderer)->priv; | ||
248 | + static const PangoColor white = { 0xffff, 0xffff, 0xffff }; | ||
249 | + PangoMatrix tmp_matrix = PANGO_MATRIX_INIT; | ||
250 | + | ||
251 | + priv->in_emboss = TRUE; | ||
252 | + | ||
253 | + *save_color = pango_renderer_get_color (renderer, part); | ||
254 | + if (*save_color) | ||
255 | + *save_color = pango_color_copy (*save_color); | ||
256 | + | ||
257 | + *save_matrix = renderer->matrix; | ||
258 | + if (*save_matrix) | ||
259 | + { | ||
260 | + *save_matrix = pango_matrix_copy (*save_matrix); | ||
261 | + tmp_matrix = **save_matrix; | ||
262 | + } | ||
263 | + | ||
264 | + /* The gymnastics here to adjust the matrix are because we want | ||
265 | + * to offset by +1,+1 in device-space, not in user-space, | ||
266 | + * so we can't just draw the layout at x + 1, y + 1 | ||
267 | + */ | ||
268 | + tmp_matrix.x0 += 1; | ||
269 | + tmp_matrix.y0 += 1; | ||
270 | + | ||
271 | + pango_renderer_set_matrix (renderer, &tmp_matrix); | ||
272 | + pango_renderer_set_color (renderer, part, &white); | ||
273 | +} | ||
274 | + | ||
275 | +/* Restores from emboss_renderer() */ | ||
276 | +static void | ||
277 | +unemboss_renderer (PangoRenderer *renderer, | ||
278 | + PangoRenderPart part, | ||
279 | + PangoMatrix **save_matrix, | ||
280 | + PangoColor **save_color) | ||
281 | +{ | ||
282 | + GdkPangoRendererPrivate *priv = GDK_PANGO_RENDERER(renderer)->priv; | ||
283 | + pango_renderer_set_matrix (renderer, *save_matrix); | ||
284 | + pango_renderer_set_color (renderer, part, *save_color); | ||
285 | + | ||
286 | + if (*save_matrix) | ||
287 | + pango_matrix_free (*save_matrix); | ||
288 | + if (*save_color) | ||
289 | + pango_color_free (*save_color); | ||
290 | + | ||
291 | + priv->in_emboss = FALSE; | ||
292 | +} | ||
293 | + | ||
294 | +/* Gets the GC for drawing @part. This make involve copying the base GC | ||
295 | + * for the renderer, in which case we keep a one-GC cache. */ | ||
296 | +static GdkGC * | ||
297 | +get_gc (GdkPangoRenderer *gdk_renderer, | ||
298 | + PangoRenderPart part) | ||
299 | { | ||
300 | PangoRenderer *renderer = PANGO_RENDERER (gdk_renderer); | ||
301 | + PangoColor *color; | ||
302 | + GdkBitmap *stipple; | ||
303 | GdkPangoRendererPrivate *priv = gdk_renderer->priv; | ||
304 | |||
305 | - if (!priv->cr) | ||
306 | + color = pango_renderer_get_color (renderer, part); | ||
307 | + | ||
308 | + if (part <= MAX_RENDER_PART) | ||
309 | + stipple = priv->stipple[part]; | ||
310 | + else | ||
311 | + stipple = NULL; | ||
312 | + | ||
313 | + if (!color && !stipple) /* nothing override, use base_gc */ | ||
314 | + return priv->base_gc; | ||
315 | + else | ||
316 | { | ||
317 | - const PangoMatrix *matrix; | ||
318 | + gboolean new_stipple = FALSE; | ||
319 | + gboolean new_color = FALSE; | ||
320 | |||
321 | - priv->cr = gdk_cairo_create (priv->drawable); | ||
322 | + if (stipple != priv->gc_stipple) | ||
323 | + new_stipple = TRUE; | ||
324 | |||
325 | - matrix = pango_renderer_get_matrix (renderer); | ||
326 | - if (matrix) | ||
327 | + if ((priv->gc_color_set && !color) || | ||
328 | + (!priv->gc_color_set && color) || | ||
329 | + priv->gc_color.red != color->red || | ||
330 | + priv->gc_color.green != color->green || | ||
331 | + priv->gc_color.blue != color->blue) | ||
332 | + new_color = TRUE; | ||
333 | + | ||
334 | + if (!priv->gc) | ||
335 | { | ||
336 | - cairo_matrix_t cairo_matrix; | ||
337 | - | ||
338 | - cairo_matrix_init (&cairo_matrix, | ||
339 | - matrix->xx, matrix->yx, | ||
340 | - matrix->xy, matrix->yy, | ||
341 | - matrix->x0, matrix->y0); | ||
342 | - cairo_set_matrix (priv->cr, &cairo_matrix); | ||
343 | + priv->gc = gdk_gc_new (priv->drawable); | ||
344 | + gdk_gc_copy (priv->gc, priv->base_gc); | ||
345 | + } | ||
346 | + else if (new_color && priv->gc_color_set && !color) | ||
347 | + { | ||
348 | + /* We have to recopy the original GC onto the cached GC | ||
349 | + * to get the default color */ | ||
350 | + new_stipple = TRUE; | ||
351 | + gdk_gc_copy (priv->gc, priv->base_gc); | ||
352 | + } | ||
353 | + else if (new_stipple && priv->gc_stipple && !stipple) | ||
354 | + { | ||
355 | + /* Similarly, we need to make a new copy to restore to the | ||
356 | + * default stipple state (the caller may have set a stipple | ||
357 | + * on the GC, and even if not, gdk_gc_set_stipple (gc, NULL) | ||
358 | + * doesn't work currently to restore to the default X stipple) */ | ||
359 | + new_color = TRUE; | ||
360 | + gdk_gc_copy (priv->gc, priv->base_gc); | ||
361 | } | ||
362 | - } | ||
363 | - | ||
364 | - if (part != priv->last_part) | ||
365 | - { | ||
366 | - PangoColor *pango_color; | ||
367 | - GdkColor *color; | ||
368 | - GdkColor tmp_color; | ||
369 | - gboolean changed; | ||
370 | |||
371 | - pango_color = pango_renderer_get_color (renderer, part); | ||
372 | - | ||
373 | - if (priv->last_part != -1) | ||
374 | - changed = priv->gc_changed || | ||
375 | - priv->stipple[priv->last_part] != priv->stipple[part] || | ||
376 | - !color_equal (pango_color, | ||
377 | - pango_renderer_get_color (renderer, priv->last_part)); | ||
378 | - else | ||
379 | - changed = TRUE; | ||
380 | - | ||
381 | - if (changed) | ||
382 | + if (new_color) | ||
383 | { | ||
384 | - if (pango_color) | ||
385 | + if (color) | ||
386 | { | ||
387 | - tmp_color.red = pango_color->red; | ||
388 | - tmp_color.green = pango_color->green; | ||
389 | - tmp_color.blue = pango_color->blue; | ||
390 | + GdkColor gdk_color; | ||
391 | + | ||
392 | + gdk_color.red = color->red; | ||
393 | + gdk_color.green = color->green; | ||
394 | + gdk_color.blue = color->blue; | ||
395 | |||
396 | - color = &tmp_color; | ||
397 | + gdk_gc_set_rgb_fg_color (priv->gc, &gdk_color); | ||
398 | + | ||
399 | + priv->gc_color = *color; | ||
400 | + priv->gc_color_set = TRUE; | ||
401 | } | ||
402 | else | ||
403 | - color = NULL; | ||
404 | + priv->gc_color_set = FALSE; | ||
405 | + } | ||
406 | |||
407 | - _gdk_gc_update_context (priv->base_gc, | ||
408 | - priv->cr, | ||
409 | - color, | ||
410 | - priv->stipple[part], | ||
411 | - priv->gc_changed); | ||
412 | + if (new_stipple) | ||
413 | + { | ||
414 | + if (priv->gc_stipple) | ||
415 | + g_object_unref (priv->gc_stipple); | ||
416 | + | ||
417 | + if (stipple) | ||
418 | + { | ||
419 | + gdk_gc_set_stipple (priv->gc, stipple); | ||
420 | + gdk_gc_set_fill (priv->gc, GDK_STIPPLED); | ||
421 | + priv->gc_stipple = g_object_ref (stipple); | ||
422 | + } | ||
423 | + else | ||
424 | + priv->gc_stipple = NULL; | ||
425 | } | ||
426 | |||
427 | - priv->last_part = part; | ||
428 | - priv->gc_changed = FALSE; | ||
429 | + return priv->gc; | ||
430 | } | ||
431 | - | ||
432 | - return priv->cr; | ||
433 | } | ||
434 | |||
435 | static void | ||
436 | @@ -225,133 +307,78 @@ | ||
437 | { | ||
438 | GdkPangoRenderer *gdk_renderer = GDK_PANGO_RENDERER (renderer); | ||
439 | GdkPangoRendererPrivate *priv = gdk_renderer->priv; | ||
440 | - cairo_t *cr; | ||
441 | |||
442 | - cr = get_cairo_context (gdk_renderer, | ||
443 | - PANGO_RENDER_PART_FOREGROUND); | ||
444 | + flush_trapezoids (gdk_renderer); | ||
445 | |||
446 | - if (priv->embossed) | ||
447 | + if (!priv->in_emboss && priv->embossed) | ||
448 | { | ||
449 | - cairo_save (cr); | ||
450 | - emboss_context (cr); | ||
451 | - cairo_move_to (cr, (double)x / PANGO_SCALE, (double)y / PANGO_SCALE); | ||
452 | - pango_cairo_show_glyph_string (cr, font, glyphs); | ||
453 | - cairo_restore (cr); | ||
454 | - } | ||
455 | - | ||
456 | - cairo_move_to (cr, (double)x / PANGO_SCALE, (double)y / PANGO_SCALE); | ||
457 | - pango_cairo_show_glyph_string (cr, font, glyphs); | ||
458 | -} | ||
459 | - | ||
460 | -/* Draws an error underline that looks like one of: | ||
461 | - * H E H | ||
462 | - * /\ /\ /\ /\ /\ - | ||
463 | - * A/ \ / \ / \ A/ \ / \ | | ||
464 | - * \ \ / \ / /D \ \ / \ | | ||
465 | - * \ \/ C \/ / \ \/ C \ | height = HEIGHT_SQUARES * square | ||
466 | - * \ /\ F / \ F /\ \ | | ||
467 | - * \ / \ / \ / \ \G | | ||
468 | - * \ / \ / \ / \ / | | ||
469 | - * \/ \/ \/ \/ - | ||
470 | - * B B | ||
471 | - * |----| | ||
472 | - * unit_width = (HEIGHT_SQUARES - 1) * square | ||
473 | - * | ||
474 | - * The x, y, width, height passed in give the desired bounding box; | ||
475 | - * x/width are adjusted to make the underline a integer number of units | ||
476 | - * wide. | ||
477 | - */ | ||
478 | -#define HEIGHT_SQUARES 2.5 | ||
479 | + PangoMatrix *save_matrix; | ||
480 | + PangoColor *save_color; | ||
481 | |||
482 | -/* Cut-and-pasted between here and pango/pango/pangocairo-render.c */ | ||
483 | + emboss_renderer (renderer, PANGO_RENDER_PART_FOREGROUND, &save_matrix, &save_color); | ||
484 | + gdk_draw_glyphs_transformed (priv->drawable, | ||
485 | + get_gc (gdk_renderer, PANGO_RENDER_PART_FOREGROUND), | ||
486 | + renderer->matrix, font, x, y, glyphs); | ||
487 | + unemboss_renderer (renderer, PANGO_RENDER_PART_FOREGROUND, &save_matrix, &save_color); | ||
488 | + } | ||
489 | + | ||
490 | + gdk_draw_glyphs_transformed (priv->drawable, | ||
491 | + get_gc (gdk_renderer, PANGO_RENDER_PART_FOREGROUND), | ||
492 | + renderer->matrix, font, x, y, glyphs); | ||
493 | +} | ||
494 | + | ||
495 | +/* Outputs any pending trapezoids, we do this when the part or | ||
496 | + * part color changes, when we are about to draw text, etc. */ | ||
497 | static void | ||
498 | -draw_error_underline (cairo_t *cr, | ||
499 | - double x, | ||
500 | - double y, | ||
501 | - double width, | ||
502 | - double height) | ||
503 | -{ | ||
504 | - double square = height / HEIGHT_SQUARES; | ||
505 | - double unit_width = (HEIGHT_SQUARES - 1) * square; | ||
506 | - int width_units = (width + unit_width / 2) / unit_width; | ||
507 | - double y_top, y_bottom; | ||
508 | - int i; | ||
509 | +flush_trapezoids (GdkPangoRenderer *gdk_renderer) | ||
510 | +{ | ||
511 | + GdkPangoRendererPrivate *priv = gdk_renderer->priv; | ||
512 | |||
513 | - x += (width - width_units * unit_width) / 2; | ||
514 | - width = width_units * unit_width; | ||
515 | + if (!priv->trapezoids || priv->trapezoids->len == 0) | ||
516 | + return; | ||
517 | |||
518 | - y_top = y; | ||
519 | - y_bottom = y + height; | ||
520 | - | ||
521 | - /* Bottom of squiggle */ | ||
522 | - cairo_move_to (cr, x - square / 2, y_top + square / 2); /* A */ | ||
523 | - for (i = 0; i < width_units; i += 2) | ||
524 | - { | ||
525 | - double x_middle = x + (i + 1) * unit_width; | ||
526 | - double x_right = x + (i + 2) * unit_width; | ||
527 | - | ||
528 | - cairo_line_to (cr, x_middle, y_bottom); /* B */ | ||
529 | - | ||
530 | - if (i + 1 == width_units) | ||
531 | - /* Nothing */; | ||
532 | - else if (i + 2 == width_units) | ||
533 | - cairo_line_to (cr, x_right + square / 2, y_top + square / 2); /* D */ | ||
534 | - else | ||
535 | - cairo_line_to (cr, x_right, y_top + square); /* C */ | ||
536 | - } | ||
537 | - | ||
538 | - /* Top of squiggle */ | ||
539 | - for (i -= 2; i >= 0; i -= 2) | ||
540 | - { | ||
541 | - double x_left = x + i * unit_width; | ||
542 | - double x_middle = x + (i + 1) * unit_width; | ||
543 | - double x_right = x + (i + 2) * unit_width; | ||
544 | - | ||
545 | - if (i + 1 == width_units) | ||
546 | - cairo_line_to (cr, x_middle + square / 2, y_bottom - square / 2); /* G */ | ||
547 | - else { | ||
548 | - if (i + 2 == width_units) | ||
549 | - cairo_line_to (cr, x_right, y_top); /* E */ | ||
550 | - cairo_line_to (cr, x_middle, y_bottom - square); /* F */ | ||
551 | - } | ||
552 | - | ||
553 | - cairo_line_to (cr, x_left, y_top); /* H */ | ||
554 | - } | ||
555 | + gdk_draw_trapezoids (priv->drawable, | ||
556 | + get_gc (gdk_renderer, priv->trapezoid_part), | ||
557 | + (GdkTrapezoid *)priv->trapezoids->data, | ||
558 | + priv->trapezoids->len); | ||
559 | |||
560 | - cairo_close_path (cr); | ||
561 | - cairo_fill (cr); | ||
562 | + g_array_set_size (priv->trapezoids, 0); | ||
563 | } | ||
564 | |||
565 | +/* Draws a single trapezoid ... we don't draw it immediately, but rather | ||
566 | + * cache it to join together with other trapezoids that form part of the | ||
567 | + * same logical shape */ | ||
568 | static void | ||
569 | -gdk_pango_renderer_draw_rectangle (PangoRenderer *renderer, | ||
570 | - PangoRenderPart part, | ||
571 | - int x, | ||
572 | - int y, | ||
573 | - int width, | ||
574 | - int height) | ||
575 | +gdk_pango_renderer_draw_trapezoid (PangoRenderer *renderer, | ||
576 | + PangoRenderPart part, | ||
577 | + double y1, | ||
578 | + double x11, | ||
579 | + double x21, | ||
580 | + double y2, | ||
581 | + double x12, | ||
582 | + double x22) | ||
583 | { | ||
584 | GdkPangoRenderer *gdk_renderer = GDK_PANGO_RENDERER (renderer); | ||
585 | - GdkPangoRendererPrivate *priv = gdk_renderer->priv; | ||
586 | - cairo_t *cr; | ||
587 | - | ||
588 | - cr = get_cairo_context (gdk_renderer, part); | ||
589 | - | ||
590 | - if (priv->embossed && part != PANGO_RENDER_PART_BACKGROUND) | ||
591 | - { | ||
592 | - cairo_save (cr); | ||
593 | - emboss_context (cr); | ||
594 | - cairo_rectangle (cr, | ||
595 | - (double)x / PANGO_SCALE, (double)y / PANGO_SCALE, | ||
596 | - (double)width / PANGO_SCALE, (double)height / PANGO_SCALE); | ||
597 | + GdkTrapezoid trap; | ||
598 | |||
599 | - cairo_fill (cr); | ||
600 | - cairo_restore (cr); | ||
601 | - } | ||
602 | + if (!gdk_renderer->priv->trapezoids) | ||
603 | + gdk_renderer->priv->trapezoids = g_array_new (FALSE, FALSE, | ||
604 | + sizeof (GdkTrapezoid)); | ||
605 | + | ||
606 | + if (gdk_renderer->priv->trapezoids->len > 0 && | ||
607 | + gdk_renderer->priv->trapezoid_part != part) | ||
608 | + flush_trapezoids (gdk_renderer); | ||
609 | + | ||
610 | + gdk_renderer->priv->trapezoid_part = part; | ||
611 | + | ||
612 | + trap.y1 = y1; | ||
613 | + trap.x11 = x11 / 2; | ||
614 | + trap.x21 = x21; | ||
615 | + trap.y2 = y2; | ||
616 | + trap.x12 = x12; | ||
617 | + trap.x22 = x22; | ||
618 | |||
619 | - cairo_rectangle (cr, | ||
620 | - (double)x / PANGO_SCALE, (double)y / PANGO_SCALE, | ||
621 | - (double)width / PANGO_SCALE, (double)height / PANGO_SCALE); | ||
622 | - cairo_fill (cr); | ||
623 | + g_array_append_val (gdk_renderer->priv->trapezoids, trap); | ||
624 | } | ||
625 | |||
626 | static void | ||
627 | @@ -363,23 +390,51 @@ | ||
628 | { | ||
629 | GdkPangoRenderer *gdk_renderer = GDK_PANGO_RENDERER (renderer); | ||
630 | GdkPangoRendererPrivate *priv = gdk_renderer->priv; | ||
631 | - cairo_t *cr; | ||
632 | - | ||
633 | - cr = get_cairo_context (gdk_renderer, PANGO_RENDER_PART_UNDERLINE); | ||
634 | - | ||
635 | - if (priv->embossed) | ||
636 | + | ||
637 | + if (!priv->in_emboss && priv->embossed) | ||
638 | { | ||
639 | - cairo_save (cr); | ||
640 | - emboss_context (cr); | ||
641 | - draw_error_underline (cr, | ||
642 | - (double)x / PANGO_SCALE, (double)y / PANGO_SCALE, | ||
643 | - (double)width / PANGO_SCALE, (double)height / PANGO_SCALE); | ||
644 | - cairo_restore (cr); | ||
645 | + PangoMatrix *save_matrix; | ||
646 | + PangoColor *save_color; | ||
647 | + | ||
648 | + emboss_renderer (renderer, PANGO_RENDER_PART_UNDERLINE, &save_matrix, &save_color); | ||
649 | + PANGO_RENDERER_CLASS (gdk_pango_renderer_parent_class)->draw_error_underline (renderer, | ||
650 | + x, y, width, height); | ||
651 | + unemboss_renderer (renderer, PANGO_RENDER_PART_UNDERLINE, &save_matrix, &save_color); | ||
652 | } | ||
653 | |||
654 | - draw_error_underline (cr, | ||
655 | - (double)x / PANGO_SCALE, (double)y / PANGO_SCALE, | ||
656 | - (double)width / PANGO_SCALE, (double)height / PANGO_SCALE); | ||
657 | + PANGO_RENDERER_CLASS (gdk_pango_renderer_parent_class)->draw_error_underline (renderer, | ||
658 | + x, y, width, height); | ||
659 | +} | ||
660 | + | ||
661 | +/* We can't handle embossing at the level of trapezoids, because when an | ||
662 | + * underline is split into multiple trapezoids, the normal and shadow | ||
663 | + * trapezoids will be drawn mixed together. Instead, we have to emboss | ||
664 | + * and entire rectangle or error underline | ||
665 | + */ | ||
666 | +static void | ||
667 | +gdk_pango_renderer_draw_rectangle (PangoRenderer *renderer, | ||
668 | + PangoRenderPart part, | ||
669 | + int x, | ||
670 | + int y, | ||
671 | + int width, | ||
672 | + int height) | ||
673 | +{ | ||
674 | + GdkPangoRenderer *gdk_renderer = GDK_PANGO_RENDERER (renderer); | ||
675 | + GdkPangoRendererPrivate *priv = gdk_renderer->priv; | ||
676 | + | ||
677 | + if (!priv->in_emboss && priv->embossed && part != PANGO_RENDER_PART_BACKGROUND) | ||
678 | + { | ||
679 | + PangoMatrix *save_matrix; | ||
680 | + PangoColor *save_color; | ||
681 | + | ||
682 | + emboss_renderer (renderer, part, &save_matrix, &save_color); | ||
683 | + PANGO_RENDERER_CLASS (gdk_pango_renderer_parent_class)->draw_rectangle (renderer, part, | ||
684 | + x, y, width, height); | ||
685 | + unemboss_renderer (renderer, part, &save_matrix, &save_color); | ||
686 | + } | ||
687 | + | ||
688 | + PANGO_RENDERER_CLASS (gdk_pango_renderer_parent_class)->draw_rectangle (renderer, part, | ||
689 | + x, y, width, height); | ||
690 | } | ||
691 | |||
692 | static void | ||
693 | @@ -388,8 +443,8 @@ | ||
694 | { | ||
695 | GdkPangoRenderer *gdk_renderer = GDK_PANGO_RENDERER (renderer); | ||
696 | |||
697 | - if (gdk_renderer->priv->last_part == part) | ||
698 | - gdk_renderer->priv->last_part = (PangoRenderPart)-1; | ||
699 | + if (part == gdk_renderer->priv->trapezoid_part) | ||
700 | + flush_trapezoids (gdk_renderer); | ||
701 | } | ||
702 | |||
703 | static void | ||
704 | @@ -410,13 +465,8 @@ | ||
705 | { | ||
706 | GdkPangoRenderer *gdk_renderer = GDK_PANGO_RENDERER (renderer); | ||
707 | GdkPangoRendererPrivate *priv = gdk_renderer->priv; | ||
708 | - | ||
709 | - if (priv->cr) | ||
710 | - { | ||
711 | - cairo_destroy (priv->cr); | ||
712 | - priv->cr = NULL; | ||
713 | - } | ||
714 | - priv->last_part = (PangoRenderPart)-1; | ||
715 | + | ||
716 | + flush_trapezoids (gdk_renderer); | ||
717 | } | ||
718 | |||
719 | static void | ||
720 | @@ -515,7 +565,6 @@ | ||
721 | GDK_TYPE_PANGO_RENDERER, | ||
722 | GdkPangoRendererPrivate); | ||
723 | |||
724 | - renderer->priv->last_part = (PangoRenderPart)-1; | ||
725 | renderer->priv->gc_changed = TRUE; | ||
726 | } | ||
727 | |||
728 | @@ -527,6 +576,7 @@ | ||
729 | PangoRendererClass *renderer_class = PANGO_RENDERER_CLASS (klass); | ||
730 | |||
731 | renderer_class->draw_glyphs = gdk_pango_renderer_draw_glyphs; | ||
732 | + renderer_class->draw_trapezoid = gdk_pango_renderer_draw_trapezoid; | ||
733 | renderer_class->draw_rectangle = gdk_pango_renderer_draw_rectangle; | ||
734 | renderer_class->draw_error_underline = gdk_pango_renderer_draw_error_underline; | ||
735 | renderer_class->part_changed = gdk_pango_renderer_part_changed; | ||
736 | @@ -647,6 +697,8 @@ | ||
737 | |||
738 | priv = gdk_renderer->priv; | ||
739 | |||
740 | + flush_trapezoids (gdk_renderer); | ||
741 | + | ||
742 | if (priv->drawable != drawable) | ||
743 | { | ||
744 | if (priv->drawable) | ||
745 | @@ -681,6 +733,8 @@ | ||
746 | |||
747 | priv = gdk_renderer->priv; | ||
748 | |||
749 | + flush_trapezoids (gdk_renderer); | ||
750 | + | ||
751 | if (priv->base_gc != gc) | ||
752 | { | ||
753 | if (priv->base_gc) | ||
754 | @@ -689,6 +743,20 @@ | ||
755 | if (priv->base_gc) | ||
756 | g_object_ref (priv->base_gc); | ||
757 | |||
758 | + if (priv->gc) | ||
759 | + { | ||
760 | + g_object_unref (priv->gc); | ||
761 | + priv->gc = NULL; | ||
762 | + } | ||
763 | + | ||
764 | + priv->gc_color_set = FALSE; | ||
765 | + | ||
766 | + if (priv->gc_stipple) | ||
767 | + { | ||
768 | + g_object_unref (priv->gc_stipple); | ||
769 | + priv->gc_stipple = NULL; | ||
770 | + } | ||
771 | + | ||
772 | priv->gc_changed = TRUE; | ||
773 | } | ||
774 | } | ||
775 | @@ -1414,50 +1482,5 @@ | ||
776 | return gdk_pango_context_get_for_screen (gdk_screen_get_default ()); | ||
777 | } | ||
778 | |||
779 | -/** | ||
780 | - * gdk_pango_context_get_for_screen: | ||
781 | - * @screen: the #GdkScreen for which the context is to be created. | ||
782 | - * | ||
783 | - * Creates a #PangoContext for @screen. | ||
784 | - * | ||
785 | - * The context must be freed when you're finished with it. | ||
786 | - * | ||
787 | - * When using GTK+, normally you should use gtk_widget_get_pango_context() | ||
788 | - * instead of this function, to get the appropriate context for | ||
789 | - * the widget you intend to render text onto. | ||
790 | - * | ||
791 | - * The newly created context will have the default font options | ||
792 | - * (see #cairo_font_options_t) for the screen; if these options | ||
793 | - * change it will not be updated. Using gtk_widget_get_pango_context() | ||
794 | - * is more convenient if you want to keep a context around and track | ||
795 | - * changes to the screen's font rendering settings. | ||
796 | - * | ||
797 | - * Return value: a new #PangoContext for @screen | ||
798 | - * | ||
799 | - * Since: 2.2 | ||
800 | - **/ | ||
801 | -PangoContext * | ||
802 | -gdk_pango_context_get_for_screen (GdkScreen *screen) | ||
803 | -{ | ||
804 | - PangoFontMap *fontmap; | ||
805 | - PangoContext *context; | ||
806 | - const cairo_font_options_t *options; | ||
807 | - double dpi; | ||
808 | - | ||
809 | - g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); | ||
810 | - | ||
811 | - fontmap = pango_cairo_font_map_get_default (); | ||
812 | - | ||
813 | - context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap)); | ||
814 | - | ||
815 | - options = gdk_screen_get_font_options (screen); | ||
816 | - pango_cairo_context_set_font_options (context, options); | ||
817 | - | ||
818 | - dpi = gdk_screen_get_resolution (screen); | ||
819 | - pango_cairo_context_set_resolution (context, dpi); | ||
820 | - | ||
821 | - return context; | ||
822 | -} | ||
823 | - | ||
824 | #define __GDK_PANGO_C__ | ||
825 | #include "gdkaliasdef.c" | ||
826 | Index: gtk+-2.10.6/gdk/gdk.symbols | ||
827 | =================================================================== | ||
828 | --- gtk+-2.10.6.orig/gdk/gdk.symbols 2006-10-30 12:58:29.000000000 +0000 | ||
829 | +++ gtk+-2.10.6/gdk/gdk.symbols 2006-10-30 12:59:30.000000000 +0000 | ||
830 | @@ -861,7 +861,6 @@ | ||
831 | gdk_pango_attr_embossed_new | ||
832 | gdk_pango_attr_stipple_new | ||
833 | gdk_pango_context_get | ||
834 | -gdk_pango_context_get_for_screen | ||
835 | #ifndef GDK_DISABLE_DEPRECATED | ||
836 | gdk_pango_context_set_colormap | ||
837 | #endif | ||
838 | @@ -877,6 +876,12 @@ | ||
839 | #endif | ||
840 | #endif | ||
841 | |||
842 | +#if IN_HEADER(__GDK_PANGO_H__) | ||
843 | +#if IN_FILE(__GDK_PANGO_X11_C__) | ||
844 | +gdk_pango_context_get_for_screen | ||
845 | +#endif | ||
846 | +#endif | ||
847 | + | ||
848 | #if IN_HEADER(__GDK_PIXBUF_H__) | ||
849 | #if IN_FILE(__GDK_PIXBUF_DRAWABLE_C__) | ||
850 | gdk_pixbuf_get_from_drawable | ||
851 | Index: gtk+-2.10.6/gdk/gdkwindow.c | ||
852 | =================================================================== | ||
853 | --- gtk+-2.10.6.orig/gdk/gdkwindow.c 2006-10-30 12:58:29.000000000 +0000 | ||
854 | +++ gtk+-2.10.6/gdk/gdkwindow.c 2006-10-30 12:59:30.000000000 +0000 | ||
855 | @@ -1834,9 +1834,14 @@ | ||
856 | } | ||
857 | else | ||
858 | { | ||
859 | - method->cr = cairo_create (paint->surface); | ||
860 | + /*method->cr = cairo_create (paint->surface); | ||
861 | |||
862 | - gdk_cairo_set_source_color (method->cr, &private->bg_color); | ||
863 | + gdk_cairo_set_source_color (method->cr, &private->bg_color);*/ | ||
864 | + GdkGC *gc = _gdk_drawable_get_scratch_gc (paint->pixmap, FALSE); | ||
865 | + | ||
866 | + gdk_gc_set_foreground (gc, &(private->bg_color)); | ||
867 | + | ||
868 | + method->gc = g_object_ref (gc); | ||
869 | } | ||
870 | } | ||
871 | |||
872 | Index: gtk+-2.10.6/gdk/x11/gdkdisplay-x11.c | ||
873 | =================================================================== | ||
874 | --- gtk+-2.10.6.orig/gdk/x11/gdkdisplay-x11.c 2006-10-30 12:58:29.000000000 +0000 | ||
875 | +++ gtk+-2.10.6/gdk/x11/gdkdisplay-x11.c 2006-10-30 12:59:30.000000000 +0000 | ||
876 | @@ -190,7 +190,8 @@ | ||
877 | display_x11->leader_window_title_set = FALSE; | ||
878 | |||
879 | display_x11->have_render = GDK_UNKNOWN; | ||
880 | - | ||
881 | + display_x11->have_render_with_trapezoids = GDK_UNKNOWN; | ||
882 | + | ||
883 | #ifdef HAVE_XFIXES | ||
884 | if (XFixesQueryExtension (display_x11->xdisplay, | ||
885 | &display_x11->xfixes_event_base, | ||
886 | Index: gtk+-2.10.6/gdk/x11/gdkdisplay-x11.h | ||
887 | =================================================================== | ||
888 | --- gtk+-2.10.6.orig/gdk/x11/gdkdisplay-x11.h 2006-10-30 12:58:29.000000000 +0000 | ||
889 | +++ gtk+-2.10.6/gdk/x11/gdkdisplay-x11.h 2006-10-30 12:59:30.000000000 +0000 | ||
890 | @@ -78,6 +78,7 @@ | ||
891 | gboolean use_xshm; | ||
892 | gboolean have_shm_pixmaps; | ||
893 | GdkTristate have_render; | ||
894 | + GdkTristate have_render_with_trapezoids; | ||
895 | gboolean have_xfixes; | ||
896 | gint xfixes_event_base; | ||
897 | |||
898 | Index: gtk+-2.10.6/gdk/x11/gdkdrawable-x11.c | ||
899 | =================================================================== | ||
900 | --- gtk+-2.10.6.orig/gdk/x11/gdkdrawable-x11.c 2006-10-30 12:58:30.000000000 +0000 | ||
901 | +++ gtk+-2.10.6/gdk/x11/gdkdrawable-x11.c 2006-10-30 12:59:30.000000000 +0000 | ||
902 | @@ -26,6 +26,8 @@ | ||
903 | |||
904 | #include <config.h> | ||
905 | |||
906 | +#include <pango/pangoxft.h> | ||
907 | + | ||
908 | #include "gdkx.h" | ||
909 | #include "gdkregion-generic.h" | ||
910 | |||
911 | @@ -106,7 +108,21 @@ | ||
912 | GdkGC *gc, | ||
913 | GdkPoint *points, | ||
914 | gint npoints); | ||
915 | - | ||
916 | + | ||
917 | +static void gdk_x11_draw_glyphs (GdkDrawable *drawable, | ||
918 | + GdkGC *gc, | ||
919 | + PangoFont *font, | ||
920 | + gint x, | ||
921 | + gint y, | ||
922 | + PangoGlyphString *glyphs); | ||
923 | +static void gdk_x11_draw_glyphs_transformed (GdkDrawable *drawable, | ||
924 | + GdkGC *gc, | ||
925 | + PangoMatrix *matrix, | ||
926 | + PangoFont *font, | ||
927 | + gint x, | ||
928 | + gint y, | ||
929 | + PangoGlyphString *glyphs); | ||
930 | + | ||
931 | static void gdk_x11_draw_image (GdkDrawable *drawable, | ||
932 | GdkGC *gc, | ||
933 | GdkImage *image, | ||
934 | @@ -129,6 +145,11 @@ | ||
935 | gint x_dither, | ||
936 | gint y_dither); | ||
937 | |||
938 | +static void gdk_x11_draw_trapezoids (GdkDrawable *drawable, | ||
939 | + GdkGC *gc, | ||
940 | + GdkTrapezoid *trapezoids, | ||
941 | + gint n_trapezoids); | ||
942 | + | ||
943 | static cairo_surface_t *gdk_x11_ref_cairo_surface (GdkDrawable *drawable); | ||
944 | |||
945 | static void gdk_x11_set_colormap (GdkDrawable *drawable, | ||
946 | @@ -163,8 +184,11 @@ | ||
947 | drawable_class->draw_points = gdk_x11_draw_points; | ||
948 | drawable_class->draw_segments = gdk_x11_draw_segments; | ||
949 | drawable_class->draw_lines = gdk_x11_draw_lines; | ||
950 | + drawable_class->draw_glyphs = gdk_x11_draw_glyphs; | ||
951 | + drawable_class->draw_glyphs_transformed = gdk_x11_draw_glyphs_transformed; | ||
952 | drawable_class->draw_image = gdk_x11_draw_image; | ||
953 | drawable_class->draw_pixbuf = gdk_x11_draw_pixbuf; | ||
954 | + drawable_class->draw_trapezoids = gdk_x11_draw_trapezoids; | ||
955 | |||
956 | drawable_class->ref_cairo_surface = gdk_x11_ref_cairo_surface; | ||
957 | |||
958 | @@ -327,6 +351,72 @@ | ||
959 | return x11display->have_render == GDK_YES; | ||
960 | } | ||
961 | |||
962 | +gboolean | ||
963 | +_gdk_x11_have_render_with_trapezoids (GdkDisplay *display) | ||
964 | +{ | ||
965 | + Display *xdisplay = GDK_DISPLAY_XDISPLAY (display); | ||
966 | + GdkDisplayX11 *x11display = GDK_DISPLAY_X11 (display); | ||
967 | + | ||
968 | + if (x11display->have_render_with_trapezoids == GDK_UNKNOWN) | ||
969 | + { | ||
970 | + x11display->have_render_with_trapezoids = GDK_NO; | ||
971 | + if (_gdk_x11_have_render (display)) | ||
972 | + { | ||
973 | + /* | ||
974 | + * Require protocol >= 0.4 for CompositeTrapezoids support. | ||
975 | + */ | ||
976 | + int major_version, minor_version; | ||
977 | + | ||
978 | +#define XRENDER_TETRAPEZOIDS_MAJOR 0 | ||
979 | +#define XRENDER_TETRAPEZOIDS_MINOR 4 | ||
980 | + | ||
981 | + if (XRenderQueryVersion (xdisplay, &major_version, | ||
982 | + &minor_version)) | ||
983 | + if ((major_version == XRENDER_TETRAPEZOIDS_MAJOR) && | ||
984 | + (minor_version >= XRENDER_TETRAPEZOIDS_MINOR)) | ||
985 | + x11display->have_render_with_trapezoids = GDK_YES; | ||
986 | + } | ||
987 | + } | ||
988 | + | ||
989 | + return x11display->have_render_with_trapezoids == GDK_YES; | ||
990 | +} | ||
991 | + | ||
992 | +static XftDraw * | ||
993 | +gdk_x11_drawable_get_xft_draw (GdkDrawable *drawable) | ||
994 | +{ | ||
995 | + GdkDrawableImplX11 *impl = GDK_DRAWABLE_IMPL_X11 (drawable); | ||
996 | + | ||
997 | + if (impl->xft_draw == NULL) | ||
998 | + { | ||
999 | + GdkColormap *colormap = gdk_drawable_get_colormap (drawable); | ||
1000 | + | ||
1001 | + if (colormap) | ||
1002 | + { | ||
1003 | + GdkVisual *visual; | ||
1004 | + | ||
1005 | + visual = gdk_colormap_get_visual (colormap); | ||
1006 | + | ||
1007 | + impl->xft_draw = XftDrawCreate (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid, | ||
1008 | + GDK_VISUAL_XVISUAL (visual), GDK_COLORMAP_XCOLORMAP (colormap)); | ||
1009 | + } | ||
1010 | + else if (gdk_drawable_get_depth (drawable) == 1) | ||
1011 | + { | ||
1012 | + impl->xft_draw = XftDrawCreateBitmap (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid); | ||
1013 | + } | ||
1014 | + else | ||
1015 | + { | ||
1016 | + g_warning ("Using Xft rendering requires the drawable argument to\n" | ||
1017 | + "have a specified colormap. All windows have a colormap,\n" | ||
1018 | + "however, pixmaps only have colormap by default if they\n" | ||
1019 | + "were created with a non-NULL window argument. Otherwise\n" | ||
1020 | + "a colormap must be set on them with gdk_drawable_set_colormap"); | ||
1021 | + return NULL; | ||
1022 | + } | ||
1023 | + } | ||
1024 | + | ||
1025 | + return impl->xft_draw; | ||
1026 | +} | ||
1027 | + | ||
1028 | static Picture | ||
1029 | gdk_x11_drawable_get_picture (GdkDrawable *drawable) | ||
1030 | { | ||
1031 | @@ -393,6 +483,57 @@ | ||
1032 | } | ||
1033 | } | ||
1034 | |||
1035 | +static void | ||
1036 | +gdk_x11_drawable_update_xft_clip (GdkDrawable *drawable, | ||
1037 | + GdkGC *gc) | ||
1038 | +{ | ||
1039 | + XftDraw *xft_draw = gdk_x11_drawable_get_xft_draw (drawable); | ||
1040 | + GdkRegion *clip_region = _gdk_gc_get_clip_region (gc); | ||
1041 | + | ||
1042 | + if (gc && clip_region) | ||
1043 | + { | ||
1044 | + GdkRegionBox *boxes = clip_region->rects; | ||
1045 | + gint n_boxes = clip_region->numRects; | ||
1046 | +#if 0 /* Until XftDrawSetClipRectangles is there */ | ||
1047 | + XRectangle *rects = g_new (XRectangle, n_boxes); | ||
1048 | + int i; | ||
1049 | + | ||
1050 | + for (i=0; i < n_boxes; i++) | ||
1051 | + { | ||
1052 | + rects[i].x = CLAMP (boxes[i].x1 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT); | ||
1053 | + rects[i].y = CLAMP (boxes[i].y1 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT); | ||
1054 | + rects[i].width = CLAMP (boxes[i].x2 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT) - rects[i].x; | ||
1055 | + rects[i].height = CLAMP (boxes[i].y2 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT) - rects[i].y; | ||
1056 | + } | ||
1057 | + XftDrawSetClipRectangles (xft_draw, 0, 0, rects, n_boxes); | ||
1058 | + | ||
1059 | + g_free (rects); | ||
1060 | +#else | ||
1061 | + Region xregion = XCreateRegion (); | ||
1062 | + int i; | ||
1063 | + | ||
1064 | + for (i=0; i < n_boxes; i++) | ||
1065 | + { | ||
1066 | + XRectangle rect; | ||
1067 | + | ||
1068 | + rect.x = CLAMP (boxes[i].x1 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT); | ||
1069 | + rect.y = CLAMP (boxes[i].y1 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT); | ||
1070 | + rect.width = CLAMP (boxes[i].x2 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT) - rect.x; | ||
1071 | + rect.height = CLAMP (boxes[i].y2 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT) - rect.y; | ||
1072 | + | ||
1073 | + XUnionRectWithRegion (&rect, xregion, xregion); | ||
1074 | + } | ||
1075 | + | ||
1076 | + XftDrawSetClip (xft_draw, xregion); | ||
1077 | + XDestroyRegion (xregion); | ||
1078 | +#endif | ||
1079 | + } | ||
1080 | + else | ||
1081 | + { | ||
1082 | + XftDrawSetClip (xft_draw, NULL); | ||
1083 | + } | ||
1084 | +} | ||
1085 | + | ||
1086 | /***************************************************** | ||
1087 | * X11 specific implementations of generic functions * | ||
1088 | *****************************************************/ | ||
1089 | @@ -780,6 +921,45 @@ | ||
1090 | } | ||
1091 | |||
1092 | static void | ||
1093 | +gdk_x11_draw_glyphs (GdkDrawable *drawable, | ||
1094 | + GdkGC *gc, | ||
1095 | + PangoFont *font, | ||
1096 | + gint x, | ||
1097 | + gint y, | ||
1098 | + PangoGlyphString *glyphs) | ||
1099 | +{ | ||
1100 | + gdk_x11_draw_glyphs_transformed (drawable, gc, NULL, | ||
1101 | + font, | ||
1102 | + x * PANGO_SCALE, | ||
1103 | + y * PANGO_SCALE, | ||
1104 | + glyphs); | ||
1105 | +} | ||
1106 | + | ||
1107 | +static void | ||
1108 | +gdk_x11_draw_glyphs_transformed (GdkDrawable *drawable, | ||
1109 | + GdkGC *gc, | ||
1110 | + PangoMatrix *matrix, | ||
1111 | + PangoFont *font, | ||
1112 | + gint x, | ||
1113 | + gint y, | ||
1114 | + PangoGlyphString *glyphs) | ||
1115 | +{ | ||
1116 | + GdkDrawableImplX11 *impl; | ||
1117 | + PangoRenderer *renderer; | ||
1118 | + | ||
1119 | + impl = GDK_DRAWABLE_IMPL_X11 (drawable); | ||
1120 | + | ||
1121 | + g_return_if_fail (PANGO_XFT_IS_FONT (font)); | ||
1122 | + | ||
1123 | + renderer = _gdk_x11_renderer_get (drawable, gc); | ||
1124 | + if (matrix) | ||
1125 | + pango_renderer_set_matrix (renderer, matrix); | ||
1126 | + pango_renderer_draw_glyphs (renderer, font, glyphs, x, y); | ||
1127 | + if (matrix) | ||
1128 | + pango_renderer_set_matrix (renderer, NULL); | ||
1129 | +} | ||
1130 | + | ||
1131 | +static void | ||
1132 | gdk_x11_draw_image (GdkDrawable *drawable, | ||
1133 | GdkGC *gc, | ||
1134 | GdkImage *image, | ||
1135 | @@ -1444,6 +1624,47 @@ | ||
1136 | } | ||
1137 | |||
1138 | static void | ||
1139 | +gdk_x11_draw_trapezoids (GdkDrawable *drawable, | ||
1140 | + GdkGC *gc, | ||
1141 | + GdkTrapezoid *trapezoids, | ||
1142 | + gint n_trapezoids) | ||
1143 | +{ | ||
1144 | + GdkScreen *screen = GDK_DRAWABLE_IMPL_X11 (drawable)->screen; | ||
1145 | + GdkDisplay *display = gdk_screen_get_display (screen); | ||
1146 | + XTrapezoid *xtrapezoids; | ||
1147 | + gint i; | ||
1148 | + | ||
1149 | + if (!_gdk_x11_have_render_with_trapezoids (display)) | ||
1150 | + { | ||
1151 | + GdkDrawable *wrapper = GDK_DRAWABLE_IMPL_X11 (drawable)->wrapper; | ||
1152 | + GDK_DRAWABLE_CLASS (_gdk_drawable_impl_x11_parent_class)->draw_trapezoids (wrapper, gc, | ||
1153 | + trapezoids, n_trapezoids); | ||
1154 | + return; | ||
1155 | + } | ||
1156 | + | ||
1157 | + xtrapezoids = g_new (XTrapezoid, n_trapezoids); | ||
1158 | + | ||
1159 | + for (i = 0; i < n_trapezoids; i++) | ||
1160 | + { | ||
1161 | + xtrapezoids[i].top = XDoubleToFixed (trapezoids[i].y1); | ||
1162 | + xtrapezoids[i].bottom = XDoubleToFixed (trapezoids[i].y2); | ||
1163 | + xtrapezoids[i].left.p1.x = XDoubleToFixed (trapezoids[i].x11); | ||
1164 | + xtrapezoids[i].left.p1.y = XDoubleToFixed (trapezoids[i].y1); | ||
1165 | + xtrapezoids[i].left.p2.x = XDoubleToFixed (trapezoids[i].x12); | ||
1166 | + xtrapezoids[i].left.p2.y = XDoubleToFixed (trapezoids[i].y2); | ||
1167 | + xtrapezoids[i].right.p1.x = XDoubleToFixed (trapezoids[i].x21); | ||
1168 | + xtrapezoids[i].right.p1.y = XDoubleToFixed (trapezoids[i].y1); | ||
1169 | + xtrapezoids[i].right.p2.x = XDoubleToFixed (trapezoids[i].x22); | ||
1170 | + xtrapezoids[i].right.p2.y = XDoubleToFixed (trapezoids[i].y2); | ||
1171 | + } | ||
1172 | + | ||
1173 | + _gdk_x11_drawable_draw_xtrapezoids (drawable, gc, | ||
1174 | + xtrapezoids, n_trapezoids); | ||
1175 | + | ||
1176 | + g_free (xtrapezoids); | ||
1177 | +} | ||
1178 | + | ||
1179 | +static void | ||
1180 | gdk_x11_cairo_surface_destroy (void *data) | ||
1181 | { | ||
1182 | GdkDrawableImplX11 *impl = data; | ||
1183 | @@ -1498,5 +1719,89 @@ | ||
1184 | return impl->cairo_surface; | ||
1185 | } | ||
1186 | |||
1187 | +void | ||
1188 | +_gdk_x11_drawable_draw_xtrapezoids (GdkDrawable *drawable, | ||
1189 | + GdkGC *gc, | ||
1190 | + XTrapezoid *xtrapezoids, | ||
1191 | + int n_trapezoids) | ||
1192 | +{ | ||
1193 | + GdkScreen *screen = GDK_DRAWABLE_IMPL_X11 (drawable)->screen; | ||
1194 | + GdkDisplay *display = gdk_screen_get_display (screen); | ||
1195 | + GdkDisplayX11 *x11display = GDK_DISPLAY_X11 (display); | ||
1196 | + | ||
1197 | + XftDraw *draw; | ||
1198 | + | ||
1199 | + if (!_gdk_x11_have_render_with_trapezoids (display)) | ||
1200 | + { | ||
1201 | + /* This is the case of drawing the borders of the unknown glyph box | ||
1202 | + * without render on the display, we need to feed it back to | ||
1203 | + * fallback code. Not efficient, but doesn't matter. | ||
1204 | + */ | ||
1205 | + GdkTrapezoid *trapezoids = g_new (GdkTrapezoid, n_trapezoids); | ||
1206 | + int i; | ||
1207 | + | ||
1208 | + for (i = 0; i < n_trapezoids; i++) | ||
1209 | + { | ||
1210 | + trapezoids[i].y1 = XFixedToDouble (xtrapezoids[i].top); | ||
1211 | + trapezoids[i].y2 = XFixedToDouble (xtrapezoids[i].bottom); | ||
1212 | + trapezoids[i].x11 = XFixedToDouble (xtrapezoids[i].left.p1.x); | ||
1213 | + trapezoids[i].x12 = XFixedToDouble (xtrapezoids[i].left.p2.x); | ||
1214 | + trapezoids[i].x21 = XFixedToDouble (xtrapezoids[i].right.p1.x); | ||
1215 | + trapezoids[i].x22 = XFixedToDouble (xtrapezoids[i].right.p2.x); | ||
1216 | + } | ||
1217 | + | ||
1218 | + gdk_x11_draw_trapezoids (drawable, gc, trapezoids, n_trapezoids); | ||
1219 | + g_free (trapezoids); | ||
1220 | + | ||
1221 | + return; | ||
1222 | + } | ||
1223 | + | ||
1224 | + gdk_x11_drawable_update_xft_clip (drawable, gc); | ||
1225 | + draw = gdk_x11_drawable_get_xft_draw (drawable); | ||
1226 | + | ||
1227 | + if (!x11display->mask_format) | ||
1228 | + x11display->mask_format = XRenderFindStandardFormat (x11display->xdisplay, | ||
1229 | + PictStandardA8); | ||
1230 | + | ||
1231 | + XRenderCompositeTrapezoids (x11display->xdisplay, PictOpOver, | ||
1232 | + _gdk_x11_gc_get_fg_picture (gc), | ||
1233 | + XftDrawPicture (draw), | ||
1234 | + x11display->mask_format, | ||
1235 | + - gc->ts_x_origin, - gc->ts_y_origin, | ||
1236 | + xtrapezoids, n_trapezoids); | ||
1237 | +} | ||
1238 | + | ||
1239 | +void | ||
1240 | +_gdk_x11_drawable_draw_xft_glyphs (GdkDrawable *drawable, | ||
1241 | + GdkGC *gc, | ||
1242 | + XftFont *xft_font, | ||
1243 | + XftGlyphSpec *glyphs, | ||
1244 | + gint n_glyphs) | ||
1245 | +{ | ||
1246 | + GdkScreen *screen = GDK_DRAWABLE_IMPL_X11 (drawable)->screen; | ||
1247 | + GdkDisplay *display = gdk_screen_get_display (screen); | ||
1248 | + GdkDisplayX11 *x11display = GDK_DISPLAY_X11 (display); | ||
1249 | + XftDraw *draw; | ||
1250 | + | ||
1251 | + gdk_x11_drawable_update_xft_clip (drawable, gc); | ||
1252 | + draw = gdk_x11_drawable_get_xft_draw (drawable); | ||
1253 | + | ||
1254 | + if (_gdk_x11_have_render (display)) | ||
1255 | + { | ||
1256 | + XftGlyphSpecRender (x11display->xdisplay, PictOpOver, | ||
1257 | + _gdk_x11_gc_get_fg_picture (gc), | ||
1258 | + xft_font, | ||
1259 | + XftDrawPicture (draw), | ||
1260 | + - gc->ts_x_origin, - gc->ts_y_origin, | ||
1261 | + glyphs, n_glyphs); | ||
1262 | + } | ||
1263 | + else | ||
1264 | + { | ||
1265 | + XftColor color; | ||
1266 | + | ||
1267 | + _gdk_gc_x11_get_fg_xft_color (gc, &color); | ||
1268 | + XftDrawGlyphSpec (draw, &color, xft_font, glyphs, n_glyphs); | ||
1269 | + } | ||
1270 | +} | ||
1271 | #define __GDK_DRAWABLE_X11_C__ | ||
1272 | #include "gdkaliasdef.c" | ||
1273 | Index: gtk+-2.10.6/gdk/x11/gdkdrawable-x11.h | ||
1274 | =================================================================== | ||
1275 | --- gtk+-2.10.6.orig/gdk/x11/gdkdrawable-x11.h 2006-10-30 12:58:30.000000000 +0000 | ||
1276 | +++ gtk+-2.10.6/gdk/x11/gdkdrawable-x11.h 2006-10-30 12:59:30.000000000 +0000 | ||
1277 | @@ -33,6 +33,7 @@ | ||
1278 | |||
1279 | #include <X11/Xlib.h> | ||
1280 | #include <X11/extensions/Xrender.h> | ||
1281 | +#include <X11/Xft/Xft.h> | ||
1282 | |||
1283 | G_BEGIN_DECLS | ||
1284 | |||
1285 | @@ -68,6 +69,8 @@ | ||
1286 | Window xid; | ||
1287 | GdkScreen *screen; | ||
1288 | |||
1289 | + XftDraw *xft_draw; | ||
1290 | + | ||
1291 | Picture picture; | ||
1292 | cairo_surface_t *cairo_surface; | ||
1293 | }; | ||
1294 | @@ -92,7 +95,15 @@ | ||
1295 | /* Note that the following take GdkDrawableImplX11, not the wrapper drawable */ | ||
1296 | void _gdk_x11_drawable_finish (GdkDrawable *drawable); | ||
1297 | void _gdk_x11_drawable_update_size (GdkDrawable *drawable); | ||
1298 | - | ||
1299 | +void _gdk_x11_drawable_draw_xtrapezoids (GdkDrawable *drawable, | ||
1300 | + GdkGC *gc, | ||
1301 | + XTrapezoid *xtrapezoids, | ||
1302 | + int n_trapezoids); | ||
1303 | +void _gdk_x11_drawable_draw_xft_glyphs (GdkDrawable *drawable, | ||
1304 | + GdkGC *gc, | ||
1305 | + XftFont *xft_font, | ||
1306 | + XftGlyphSpec *glyphs, | ||
1307 | + gint n_glyphs); | ||
1308 | G_END_DECLS | ||
1309 | |||
1310 | #endif /* __GDK_DRAWABLE_X11_H__ */ | ||
1311 | Index: gtk+-2.10.6/gdk/x11/gdkgc-x11.c | ||
1312 | =================================================================== | ||
1313 | --- gtk+-2.10.6.orig/gdk/x11/gdkgc-x11.c 2006-10-30 12:58:30.000000000 +0000 | ||
1314 | +++ gtk+-2.10.6/gdk/x11/gdkgc-x11.c 2006-10-30 12:59:30.000000000 +0000 | ||
1315 | @@ -80,7 +80,10 @@ | ||
1316 | gdk_gc_x11_finalize (GObject *object) | ||
1317 | { | ||
1318 | GdkGCX11 *x11_gc = GDK_GC_X11 (object); | ||
1319 | - | ||
1320 | + | ||
1321 | + if (x11_gc->fg_picture != None) | ||
1322 | + XRenderFreePicture (GDK_GC_XDISPLAY (x11_gc), x11_gc->fg_picture); | ||
1323 | + | ||
1324 | XFreeGC (GDK_GC_XDISPLAY (x11_gc), GDK_GC_XGC (x11_gc)); | ||
1325 | |||
1326 | G_OBJECT_CLASS (_gdk_gc_x11_parent_class)->finalize (object); | ||
1327 | @@ -110,7 +113,7 @@ | ||
1328 | |||
1329 | private->dirty_mask = 0; | ||
1330 | private->have_clip_mask = FALSE; | ||
1331 | - | ||
1332 | + | ||
1333 | private->screen = GDK_DRAWABLE_IMPL_X11 (drawable)->screen; | ||
1334 | |||
1335 | private->depth = gdk_drawable_get_depth (drawable); | ||
1336 | @@ -339,6 +342,18 @@ | ||
1337 | } | ||
1338 | |||
1339 | static void | ||
1340 | +clear_fg_picture (GdkGC *gc) | ||
1341 | +{ | ||
1342 | + GdkGCX11 *x11_gc = GDK_GC_X11 (gc); | ||
1343 | + | ||
1344 | + if (x11_gc->fg_picture != None) | ||
1345 | + { | ||
1346 | + XRenderFreePicture (GDK_GC_XDISPLAY (x11_gc), x11_gc->fg_picture); | ||
1347 | + x11_gc->fg_picture = None; | ||
1348 | + } | ||
1349 | +} | ||
1350 | + | ||
1351 | +static void | ||
1352 | gdk_x11_gc_set_values (GdkGC *gc, | ||
1353 | GdkGCValues *values, | ||
1354 | GdkGCValuesMask values_mask) | ||
1355 | @@ -367,6 +382,29 @@ | ||
1356 | x11_gc->have_clip_mask = values->clip_mask != NULL; | ||
1357 | } | ||
1358 | |||
1359 | + if (values_mask & GDK_GC_BACKGROUND) | ||
1360 | + { | ||
1361 | + if (_gdk_gc_get_fill (gc) == GDK_OPAQUE_STIPPLED) | ||
1362 | + clear_fg_picture (gc); | ||
1363 | + } | ||
1364 | + | ||
1365 | + if (values_mask & GDK_GC_FILL) | ||
1366 | + { | ||
1367 | + clear_fg_picture (gc); | ||
1368 | + } | ||
1369 | + | ||
1370 | + if (values_mask & GDK_GC_STIPPLE) | ||
1371 | + { | ||
1372 | + if (_gdk_gc_get_fill (gc) == GDK_STIPPLED || _gdk_gc_get_fill (gc) == GDK_OPAQUE_STIPPLED) | ||
1373 | + clear_fg_picture (gc); | ||
1374 | + } | ||
1375 | + | ||
1376 | + if (values_mask & GDK_GC_TILE) | ||
1377 | + { | ||
1378 | + if (_gdk_gc_get_fill (gc) == GDK_TILED) | ||
1379 | + clear_fg_picture (gc); | ||
1380 | + } | ||
1381 | + | ||
1382 | gdk_x11_gc_values_to_xvalues (values, values_mask, &xvalues, &xvalues_mask); | ||
1383 | |||
1384 | XChangeGC (GDK_GC_XDISPLAY (gc), | ||
1385 | @@ -642,6 +680,8 @@ | ||
1386 | x11_dst_gc->dirty_mask = x11_src_gc->dirty_mask; | ||
1387 | x11_dst_gc->have_clip_region = x11_src_gc->have_clip_region; | ||
1388 | x11_dst_gc->have_clip_mask = x11_src_gc->have_clip_mask; | ||
1389 | + | ||
1390 | + clear_fg_picture (dst_gc); | ||
1391 | } | ||
1392 | |||
1393 | /** | ||
1394 | @@ -701,5 +741,359 @@ | ||
1395 | return gc_x11->xgc; | ||
1396 | } | ||
1397 | |||
1398 | +/* Various bits of the below are roughly cribbed from XFree86 | ||
1399 | + * lib/Xft/xftdraw.c, Copyright 2000, Keith Packard | ||
1400 | + */ | ||
1401 | + | ||
1402 | +static XRenderPictFormat * | ||
1403 | +foreground_format (GdkGC *gc) | ||
1404 | +{ | ||
1405 | + XRenderPictFormat pf; | ||
1406 | + | ||
1407 | + pf.type = PictTypeDirect; | ||
1408 | + pf.depth = 32; | ||
1409 | + pf.direct.redMask = 0xff; | ||
1410 | + pf.direct.greenMask = 0xff; | ||
1411 | + pf.direct.blueMask = 0xff; | ||
1412 | + pf.direct.alphaMask = 0xff; | ||
1413 | + | ||
1414 | + return XRenderFindFormat (GDK_GC_XDISPLAY (gc), | ||
1415 | + (PictFormatType | | ||
1416 | + PictFormatDepth | | ||
1417 | + PictFormatRedMask | | ||
1418 | + PictFormatGreenMask | | ||
1419 | + PictFormatBlueMask | | ||
1420 | + PictFormatAlphaMask), | ||
1421 | + &pf, | ||
1422 | + 0); | ||
1423 | +} | ||
1424 | + | ||
1425 | +static Picture | ||
1426 | +make_fg_tile_picture (GdkGC *gc) | ||
1427 | +{ | ||
1428 | + GdkGCX11 *x11_gc = GDK_GC_X11 (gc); | ||
1429 | + GdkVisual *visual = gdk_drawable_get_visual (_gdk_gc_get_tile (gc)); | ||
1430 | + XRenderPictFormat *format = NULL; | ||
1431 | + | ||
1432 | + if (visual) | ||
1433 | + { | ||
1434 | + format = XRenderFindVisualFormat (GDK_GC_XDISPLAY (gc), | ||
1435 | + GDK_VISUAL_XVISUAL (visual)); | ||
1436 | + } | ||
1437 | + else if (x11_gc->depth == 1) | ||
1438 | + { | ||
1439 | + format = XRenderFindStandardFormat (GDK_GC_XDISPLAY (gc), | ||
1440 | + PictStandardA1); | ||
1441 | + } | ||
1442 | + | ||
1443 | + if (format) | ||
1444 | + { | ||
1445 | + XRenderPictureAttributes pa; | ||
1446 | + pa.repeat = True; | ||
1447 | + | ||
1448 | + return XRenderCreatePicture (GDK_GC_XDISPLAY (gc), | ||
1449 | + GDK_PIXMAP_XID (_gdk_gc_get_tile (gc)), | ||
1450 | + format, | ||
1451 | + CPRepeat, &pa); | ||
1452 | + } | ||
1453 | + | ||
1454 | + return None; | ||
1455 | +} | ||
1456 | + | ||
1457 | +static Picture | ||
1458 | +make_stipple_picture (GdkGC *gc) | ||
1459 | +{ | ||
1460 | + XRenderPictFormat *format = NULL; | ||
1461 | + XRenderPictureAttributes pa; | ||
1462 | + | ||
1463 | + format = XRenderFindStandardFormat (GDK_GC_XDISPLAY (gc), | ||
1464 | + PictStandardA1); | ||
1465 | + | ||
1466 | + pa.repeat = True; | ||
1467 | + return XRenderCreatePicture (GDK_GC_XDISPLAY (gc), | ||
1468 | + GDK_PIXMAP_XID (_gdk_gc_get_stipple (gc)), | ||
1469 | + format, | ||
1470 | + CPRepeat, &pa); | ||
1471 | +} | ||
1472 | + | ||
1473 | +static Picture | ||
1474 | +make_color_picture (GdkGC *gc, | ||
1475 | + XRenderColor *color) | ||
1476 | +{ | ||
1477 | + GdkGCX11 *x11_gc = GDK_GC_X11 (gc); | ||
1478 | + XRenderPictureAttributes pa; | ||
1479 | + XRenderPictFormat *pix_format = foreground_format (gc); | ||
1480 | + Pixmap pix; | ||
1481 | + Picture picture; | ||
1482 | + | ||
1483 | + if (!pix_format) | ||
1484 | + return None; | ||
1485 | + | ||
1486 | + pix = XCreatePixmap (GDK_GC_XDISPLAY (gc), | ||
1487 | + GDK_SCREEN_XROOTWIN (x11_gc->screen), | ||
1488 | + 1, 1, pix_format->depth); | ||
1489 | + pa.repeat = True; | ||
1490 | + picture = XRenderCreatePicture (GDK_GC_XDISPLAY (gc), | ||
1491 | + pix, | ||
1492 | + pix_format, | ||
1493 | + CPRepeat, &pa); | ||
1494 | + XFreePixmap (GDK_GC_XDISPLAY (gc), pix); | ||
1495 | + | ||
1496 | + XRenderFillRectangle (GDK_GC_XDISPLAY (gc), PictOpSrc, | ||
1497 | + picture, color, | ||
1498 | + 0, 0, 1, 1); | ||
1499 | + | ||
1500 | + return picture; | ||
1501 | +} | ||
1502 | + | ||
1503 | +static void | ||
1504 | +get_bg_color (GdkGC *gc, | ||
1505 | + XRenderColor *render_color) | ||
1506 | +{ | ||
1507 | + GdkColormap *cmap; | ||
1508 | + | ||
1509 | + cmap = gdk_gc_get_colormap (gc); | ||
1510 | + | ||
1511 | + if (cmap) | ||
1512 | + { | ||
1513 | + GdkColor color; | ||
1514 | + | ||
1515 | + gdk_colormap_query_color (cmap, _gdk_gc_get_bg_pixel (gc), &color); | ||
1516 | + | ||
1517 | + render_color->alpha = 0xffff; | ||
1518 | + render_color->red = color.red; | ||
1519 | + render_color->green = color.green; | ||
1520 | + render_color->blue = color.blue; | ||
1521 | + } | ||
1522 | + else /* Not worth warning, just use black */ | ||
1523 | + { | ||
1524 | + render_color->alpha = 0xffff; | ||
1525 | + render_color->red = 0; | ||
1526 | + render_color->green = 0; | ||
1527 | + render_color->blue = 0; | ||
1528 | + } | ||
1529 | +} | ||
1530 | + | ||
1531 | +/** | ||
1532 | + * _gdk_x11_gc_get_fg_picture: | ||
1533 | + * @gc: a #GdkGC | ||
1534 | + * | ||
1535 | + * Gets a Xrender Picture object suitable for being the source | ||
1536 | + * drawable for drawing with the foreground the graphics context. | ||
1537 | + * | ||
1538 | + * Return value: a Picture, owned by the GC; this cannot be | ||
1539 | + * used over subsequent modification of the GC. | ||
1540 | + **/ | ||
1541 | +Picture | ||
1542 | +_gdk_x11_gc_get_fg_picture (GdkGC *gc) | ||
1543 | +{ | ||
1544 | + GdkGCX11 *x11_gc; | ||
1545 | + gboolean new = FALSE; | ||
1546 | + XftColor xftcolor; | ||
1547 | + GdkFill fill; | ||
1548 | + int width, height; | ||
1549 | + | ||
1550 | + g_return_val_if_fail (GDK_IS_GC_X11 (gc), None); | ||
1551 | + | ||
1552 | + if (!_gdk_x11_have_render (GDK_GC_DISPLAY (gc))) | ||
1553 | + return None; | ||
1554 | + | ||
1555 | + x11_gc = GDK_GC_X11 (gc); | ||
1556 | + | ||
1557 | + fill = GDK_SOLID; | ||
1558 | + width = 1; | ||
1559 | + height = 1; | ||
1560 | + | ||
1561 | + switch (_gdk_gc_get_fill (gc)) | ||
1562 | + { | ||
1563 | + case GDK_SOLID: | ||
1564 | + break; | ||
1565 | + case GDK_TILED: | ||
1566 | + if (_gdk_gc_get_tile (gc)) | ||
1567 | + { | ||
1568 | + if (!x11_gc->fg_picture) | ||
1569 | + x11_gc->fg_picture = make_fg_tile_picture (gc); | ||
1570 | + | ||
1571 | + if (x11_gc->fg_picture != None) | ||
1572 | + return x11_gc->fg_picture; | ||
1573 | + } | ||
1574 | + break; | ||
1575 | + case GDK_STIPPLED: | ||
1576 | + case GDK_OPAQUE_STIPPLED: | ||
1577 | + if (_gdk_gc_get_stipple (gc)) | ||
1578 | + { | ||
1579 | + gdk_drawable_get_size (_gdk_gc_get_stipple (gc), &width, &height); | ||
1580 | + fill = _gdk_gc_get_fill (gc); | ||
1581 | + } | ||
1582 | + break; | ||
1583 | + } | ||
1584 | + | ||
1585 | + if (x11_gc->fg_picture == None) | ||
1586 | + { | ||
1587 | + XRenderPictureAttributes pa; | ||
1588 | + XRenderPictFormat *pix_format = foreground_format (gc); | ||
1589 | + Pixmap pix; | ||
1590 | + | ||
1591 | + if (!pix_format) | ||
1592 | + return None; | ||
1593 | + | ||
1594 | + pix = XCreatePixmap (GDK_GC_XDISPLAY (gc), | ||
1595 | + GDK_SCREEN_XROOTWIN (x11_gc->screen), | ||
1596 | + width, height, pix_format->depth); | ||
1597 | + pa.repeat = True; | ||
1598 | + x11_gc->fg_picture = XRenderCreatePicture (GDK_GC_XDISPLAY (gc), | ||
1599 | + pix, | ||
1600 | + pix_format, | ||
1601 | + CPRepeat, &pa); | ||
1602 | + XFreePixmap (GDK_GC_XDISPLAY (gc), pix); | ||
1603 | + | ||
1604 | + new = TRUE; | ||
1605 | + } | ||
1606 | + | ||
1607 | + _gdk_gc_x11_get_fg_xft_color (gc, &xftcolor); | ||
1608 | + | ||
1609 | + if (x11_gc->fg_picture_color.alpha != 0xffff || | ||
1610 | + x11_gc->fg_picture_color.red != xftcolor.color.red || | ||
1611 | + x11_gc->fg_picture_color.green != xftcolor.color.green || | ||
1612 | + x11_gc->fg_picture_color.blue != xftcolor.color.blue) | ||
1613 | + { | ||
1614 | + x11_gc->fg_picture_color.alpha = 0xffff; | ||
1615 | + x11_gc->fg_picture_color.red = xftcolor.color.red; | ||
1616 | + x11_gc->fg_picture_color.green = xftcolor.color.green; | ||
1617 | + x11_gc->fg_picture_color.blue = xftcolor.color.blue; | ||
1618 | + | ||
1619 | + new = TRUE; | ||
1620 | + } | ||
1621 | + | ||
1622 | + switch (fill) | ||
1623 | + { | ||
1624 | + case GDK_SOLID: | ||
1625 | + XRenderFillRectangle (GDK_GC_XDISPLAY (gc), PictOpSrc, | ||
1626 | + x11_gc->fg_picture, &x11_gc->fg_picture_color, | ||
1627 | + 0, 0, width, height); | ||
1628 | + break; | ||
1629 | + case GDK_STIPPLED: | ||
1630 | + { | ||
1631 | + Picture stipple_picture = make_stipple_picture (gc); | ||
1632 | + | ||
1633 | + XRenderFillRectangle (GDK_GC_XDISPLAY (gc), PictOpSrc, | ||
1634 | + x11_gc->fg_picture, &x11_gc->fg_picture_color, | ||
1635 | + 0, 0, width, height); | ||
1636 | + XRenderComposite (GDK_GC_XDISPLAY (gc), | ||
1637 | + PictOpInReverse, | ||
1638 | + stipple_picture, None, x11_gc->fg_picture, | ||
1639 | + 0, 0, 0, 0, 0, 0, width, height); | ||
1640 | + | ||
1641 | + XRenderFreePicture (GDK_GC_XDISPLAY (x11_gc), stipple_picture); | ||
1642 | + } | ||
1643 | + break; | ||
1644 | + case GDK_OPAQUE_STIPPLED: | ||
1645 | + { | ||
1646 | + XRenderColor bg_color; | ||
1647 | + | ||
1648 | + Picture stipple_picture = make_stipple_picture (gc); | ||
1649 | + Picture fg_picture = make_color_picture (gc, &x11_gc->fg_picture_color); | ||
1650 | + | ||
1651 | + get_bg_color (gc, &bg_color); | ||
1652 | + | ||
1653 | + XRenderFillRectangle (GDK_GC_XDISPLAY (gc), PictOpSrc, | ||
1654 | + x11_gc->fg_picture, &bg_color, | ||
1655 | + 0, 0, width, height); | ||
1656 | + XRenderComposite (GDK_GC_XDISPLAY (gc), | ||
1657 | + PictOpOver, | ||
1658 | + fg_picture, stipple_picture, x11_gc->fg_picture, | ||
1659 | + 0, 0, 0, 0, 0, 0, width, height); | ||
1660 | + | ||
1661 | + XRenderFreePicture (GDK_GC_XDISPLAY (x11_gc), stipple_picture); | ||
1662 | + XRenderFreePicture (GDK_GC_XDISPLAY (x11_gc), fg_picture); | ||
1663 | + } | ||
1664 | + break; | ||
1665 | + case GDK_TILED: | ||
1666 | + g_assert_not_reached (); /* handled above */ | ||
1667 | + break; | ||
1668 | + } | ||
1669 | + | ||
1670 | + return x11_gc->fg_picture; | ||
1671 | +} | ||
1672 | + | ||
1673 | +/** | ||
1674 | + * _gdk_gc_x11_get_fg_xft_color: | ||
1675 | + * @gc: a #GdkGC | ||
1676 | + * @xftcolor: location to store the color | ||
1677 | + * | ||
1678 | + * Gets the foreground color of the GC as a XftColor. | ||
1679 | + **/ | ||
1680 | +void | ||
1681 | +_gdk_gc_x11_get_fg_xft_color (GdkGC *gc, | ||
1682 | + XftColor *xftcolor) | ||
1683 | +{ | ||
1684 | + GdkGCX11 *x11_gc; | ||
1685 | + GdkColormap *cmap; | ||
1686 | + GdkColor color; | ||
1687 | + | ||
1688 | + g_return_if_fail (GDK_IS_GC_X11 (gc)); | ||
1689 | + | ||
1690 | + x11_gc = GDK_GC_X11 (gc); | ||
1691 | + | ||
1692 | + cmap = gdk_gc_get_colormap (gc); | ||
1693 | + | ||
1694 | + xftcolor->pixel = _gdk_gc_get_fg_pixel (gc); | ||
1695 | + | ||
1696 | + if (cmap) | ||
1697 | + { | ||
1698 | + gdk_colormap_query_color (cmap, xftcolor->pixel, &color); | ||
1699 | + xftcolor->color.alpha = 0xffff; | ||
1700 | + xftcolor->color.red = color.red; | ||
1701 | + xftcolor->color.green = color.green; | ||
1702 | + xftcolor->color.blue = color.blue; | ||
1703 | + } | ||
1704 | + else if (x11_gc->depth == 1) | ||
1705 | + { | ||
1706 | + /* Drawing with Xft on a bitmap is a bit bizzare; it | ||
1707 | + * takes alpha >= 0x8000 to mean 'set to 1' and | ||
1708 | + * alpha < 0x8000 to mean 'set to 0'. | ||
1709 | + */ | ||
1710 | + if (xftcolor->pixel) | ||
1711 | + { | ||
1712 | + xftcolor->color.red = 0xffff; | ||
1713 | + xftcolor->color.green = 0xffff; | ||
1714 | + xftcolor->color.blue = 0xffff; | ||
1715 | + xftcolor->color.alpha = 0xffff; | ||
1716 | + } | ||
1717 | + else | ||
1718 | + { | ||
1719 | + xftcolor->color.red = 0; | ||
1720 | + xftcolor->color.green = 0; | ||
1721 | + xftcolor->color.blue = 0; | ||
1722 | + xftcolor->color.alpha = 0; | ||
1723 | + } | ||
1724 | + } | ||
1725 | + else | ||
1726 | + { | ||
1727 | + g_warning ("Using Xft rendering requires the GC argument to have a\n" | ||
1728 | + "specified colormap. If the GC was created for a drawable\n" | ||
1729 | + "with a colormap, the colormap will be set on the GC\n" | ||
1730 | + "automatically. Otherwise, a colormap must be set on it with" | ||
1731 | + "gdk_gc_set_colormap"); | ||
1732 | + } | ||
1733 | +} | ||
1734 | + | ||
1735 | +void | ||
1736 | +_gdk_windowing_gc_get_foreground (GdkGC *gc, | ||
1737 | + GdkColor *color) | ||
1738 | +{ | ||
1739 | + GdkColormap *cmap; | ||
1740 | + | ||
1741 | + g_return_if_fail (GDK_IS_GC_X11 (gc)); | ||
1742 | + | ||
1743 | + color->pixel = _gdk_gc_get_fg_pixel (gc); | ||
1744 | + | ||
1745 | + cmap = gdk_gc_get_colormap (gc); | ||
1746 | + | ||
1747 | + if (cmap) | ||
1748 | + gdk_colormap_query_color (cmap, _gdk_gc_get_fg_pixel (gc), color); | ||
1749 | + else | ||
1750 | + g_warning ("No colormap in _gdk_windowing_gc_get_foreground"); | ||
1751 | +} | ||
1752 | #define __GDK_GC_X11_C__ | ||
1753 | #include "gdkaliasdef.c" | ||
1754 | Index: gtk+-2.10.6/gdk/x11/gdkprivate-x11.h | ||
1755 | =================================================================== | ||
1756 | --- gtk+-2.10.6.orig/gdk/x11/gdkprivate-x11.h 2006-10-30 12:58:30.000000000 +0000 | ||
1757 | +++ gtk+-2.10.6/gdk/x11/gdkprivate-x11.h 2006-10-30 12:59:30.000000000 +0000 | ||
1758 | @@ -63,6 +63,9 @@ | ||
1759 | guint have_clip_region : 1; | ||
1760 | guint have_clip_mask : 1; | ||
1761 | guint depth : 8; | ||
1762 | + | ||
1763 | + Picture fg_picture; | ||
1764 | + XRenderColor fg_picture_color; | ||
1765 | }; | ||
1766 | |||
1767 | struct _GdkGCX11Class | ||
1768 | @@ -102,6 +105,11 @@ | ||
1769 | GType _gdk_gc_x11_get_type (void); | ||
1770 | |||
1771 | gboolean _gdk_x11_have_render (GdkDisplay *display); | ||
1772 | +gboolean _gdk_x11_have_render_with_trapezoids (GdkDisplay *display); | ||
1773 | + | ||
1774 | +Picture _gdk_x11_gc_get_fg_picture (GdkGC *gc); | ||
1775 | +void _gdk_gc_x11_get_fg_xft_color (GdkGC *gc, | ||
1776 | + XftColor *xftcolor); | ||
1777 | |||
1778 | GdkGC *_gdk_x11_gc_new (GdkDrawable *drawable, | ||
1779 | GdkGCValues *values, | ||
1780 | Index: gtk+-2.10.6/gdk/x11/gdkwindow-x11.c | ||
1781 | =================================================================== | ||
1782 | --- gtk+-2.10.6.orig/gdk/x11/gdkwindow-x11.c 2006-10-30 12:58:30.000000000 +0000 | ||
1783 | +++ gtk+-2.10.6/gdk/x11/gdkwindow-x11.c 2006-10-30 12:59:30.000000000 +0000 | ||
1784 | @@ -1114,7 +1114,8 @@ | ||
1785 | { | ||
1786 | GdkWindowObject *private = (GdkWindowObject *)window; | ||
1787 | GdkToplevelX11 *toplevel; | ||
1788 | - | ||
1789 | + GdkDrawableImplX11 *draw_impl; | ||
1790 | + | ||
1791 | g_return_if_fail (GDK_IS_WINDOW (window)); | ||
1792 | |||
1793 | _gdk_selection_window_destroyed (window); | ||
1794 | @@ -1126,6 +1127,11 @@ | ||
1795 | if (toplevel) | ||
1796 | gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window), toplevel); | ||
1797 | |||
1798 | + draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl); | ||
1799 | + | ||
1800 | + if (draw_impl->xft_draw) | ||
1801 | + XftDrawDestroy (draw_impl->xft_draw); | ||
1802 | + | ||
1803 | _gdk_x11_drawable_finish (private->impl); | ||
1804 | |||
1805 | if (!recursing && !foreign_destroy) | ||
1806 | Index: gtk+-2.10.6/gdk/x11/Makefile.am | ||
1807 | =================================================================== | ||
1808 | --- gtk+-2.10.6.orig/gdk/x11/Makefile.am 2006-10-30 12:58:30.000000000 +0000 | ||
1809 | +++ gtk+-2.10.6/gdk/x11/Makefile.am 2006-10-30 12:59:30.000000000 +0000 | ||
1810 | @@ -37,6 +37,7 @@ | ||
1811 | gdkinput.c \ | ||
1812 | gdkkeys-x11.c \ | ||
1813 | gdkmain-x11.c \ | ||
1814 | + gdkpango-x11.c \ | ||
1815 | gdkpixmap-x11.c \ | ||
1816 | gdkpixmap-x11.h \ | ||
1817 | gdkproperty-x11.c \ | ||
1818 | Index: gtk+-2.10.6/gtk/gtkcalendar.c | ||
1819 | =================================================================== | ||
1820 | --- gtk+-2.10.6.orig/gtk/gtkcalendar.c 2006-10-30 12:58:30.000000000 +0000 | ||
1821 | +++ gtk+-2.10.6/gtk/gtkcalendar.c 2006-10-30 12:59:30.000000000 +0000 | ||
1822 | @@ -1821,7 +1821,7 @@ | ||
1823 | } | ||
1824 | } | ||
1825 | |||
1826 | - | ||
1827 | + | ||
1828 | /**************************************** | ||
1829 | * Repainting * | ||
1830 | ****************************************/ | ||
1831 | @@ -1831,7 +1831,7 @@ | ||
1832 | { | ||
1833 | GtkWidget *widget = GTK_WIDGET (calendar); | ||
1834 | GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); | ||
1835 | - cairo_t *cr; | ||
1836 | + GdkGC *gc; | ||
1837 | char buffer[255]; | ||
1838 | int x, y; | ||
1839 | gint header_width; | ||
1840 | @@ -1849,7 +1849,7 @@ | ||
1841 | else | ||
1842 | year_left = !priv->year_before; | ||
1843 | |||
1844 | - cr = gdk_cairo_create (priv->header_win); | ||
1845 | + gc = calendar->gc; | ||
1846 | |||
1847 | header_width = widget->allocation.width - 2 * widget->style->xthickness; | ||
1848 | |||
1849 | @@ -1902,9 +1902,9 @@ | ||
1850 | - (max_year_width - logical_rect.width)/2); | ||
1851 | |||
1852 | |||
1853 | - gdk_cairo_set_source_color (cr, HEADER_FG_COLOR (GTK_WIDGET (calendar))); | ||
1854 | - cairo_move_to (cr, x, y); | ||
1855 | - pango_cairo_show_layout (cr, layout); | ||
1856 | + gdk_gc_set_foreground (gc, HEADER_FG_COLOR (GTK_WIDGET (calendar))); | ||
1857 | + gdk_draw_layout (priv->header_win, gc, x, y, layout); | ||
1858 | + | ||
1859 | |||
1860 | /* Draw month */ | ||
1861 | g_snprintf (buffer, sizeof (buffer), "%s", default_monthname[calendar->month]); | ||
1862 | @@ -1924,19 +1924,19 @@ | ||
1863 | else | ||
1864 | x = 3 + priv->arrow_width + (max_month_width - logical_rect.width)/2; | ||
1865 | |||
1866 | - cairo_move_to (cr, x, y); | ||
1867 | - pango_cairo_show_layout (cr, layout); | ||
1868 | - | ||
1869 | + gdk_draw_layout (priv->header_win, gc, x, y, layout); | ||
1870 | + | ||
1871 | + gdk_gc_set_foreground (gc, BACKGROUND_COLOR (GTK_WIDGET (calendar))); | ||
1872 | + | ||
1873 | g_object_unref (layout); | ||
1874 | - cairo_destroy (cr); | ||
1875 | } | ||
1876 | |||
1877 | static void | ||
1878 | calendar_paint_day_names (GtkCalendar *calendar) | ||
1879 | { | ||
1880 | GtkWidget *widget = GTK_WIDGET (calendar); | ||
1881 | + GdkGC *gc; | ||
1882 | GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); | ||
1883 | - cairo_t *cr; | ||
1884 | char buffer[255]; | ||
1885 | int day,i; | ||
1886 | int day_width, cal_width; | ||
1887 | @@ -1946,8 +1946,7 @@ | ||
1888 | gint focus_padding; | ||
1889 | gint focus_width; | ||
1890 | |||
1891 | - cr = gdk_cairo_create (priv->day_name_win); | ||
1892 | - | ||
1893 | + gc = calendar->gc; | ||
1894 | gtk_widget_style_get (GTK_WIDGET (widget), | ||
1895 | "focus-line-width", &focus_width, | ||
1896 | "focus-padding", &focus_padding, | ||
1897 | @@ -1961,22 +1960,19 @@ | ||
1898 | * Draw rectangles as inverted background for the labels. | ||
1899 | */ | ||
1900 | |||
1901 | - gdk_cairo_set_source_color (cr, SELECTED_BG_COLOR (widget)); | ||
1902 | - cairo_rectangle (cr, | ||
1903 | - CALENDAR_MARGIN, CALENDAR_MARGIN, | ||
1904 | - cal_width-CALENDAR_MARGIN * 2, | ||
1905 | - priv->day_name_h - CALENDAR_MARGIN); | ||
1906 | - cairo_fill (cr); | ||
1907 | - | ||
1908 | + gdk_gc_set_foreground (gc, SELECTED_BG_COLOR (widget)); | ||
1909 | + gdk_draw_rectangle (priv->day_name_win, gc, TRUE, | ||
1910 | + CALENDAR_MARGIN, CALENDAR_MARGIN, | ||
1911 | + cal_width-CALENDAR_MARGIN * 2, | ||
1912 | + priv->day_name_h - CALENDAR_MARGIN); | ||
1913 | + | ||
1914 | if (calendar->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS) | ||
1915 | - { | ||
1916 | - cairo_rectangle (cr, | ||
1917 | - CALENDAR_MARGIN, | ||
1918 | - priv->day_name_h - CALENDAR_YSEP, | ||
1919 | - priv->week_width - CALENDAR_YSEP - CALENDAR_MARGIN, | ||
1920 | - CALENDAR_YSEP); | ||
1921 | - cairo_fill (cr); | ||
1922 | - } | ||
1923 | + gdk_draw_rectangle (priv->day_name_win, gc, TRUE, | ||
1924 | + CALENDAR_MARGIN, | ||
1925 | + priv->day_name_h - CALENDAR_YSEP, | ||
1926 | + priv->week_width - CALENDAR_YSEP - CALENDAR_MARGIN, | ||
1927 | + CALENDAR_YSEP); | ||
1928 | + | ||
1929 | |||
1930 | /* | ||
1931 | * Write the labels | ||
1932 | @@ -1984,7 +1980,7 @@ | ||
1933 | |||
1934 | layout = gtk_widget_create_pango_layout (widget, NULL); | ||
1935 | |||
1936 | - gdk_cairo_set_source_color (cr, SELECTED_FG_COLOR (widget)); | ||
1937 | + gdk_gc_set_foreground (gc, SELECTED_FG_COLOR (widget)); | ||
1938 | for (i = 0; i < 7; i++) | ||
1939 | { | ||
1940 | if (gtk_widget_get_direction (GTK_WIDGET (calendar)) == GTK_TEXT_DIR_RTL) | ||
1941 | @@ -1997,19 +1993,18 @@ | ||
1942 | pango_layout_set_text (layout, buffer, -1); | ||
1943 | pango_layout_get_pixel_extents (layout, NULL, &logical_rect); | ||
1944 | |||
1945 | - cairo_move_to (cr, | ||
1946 | - (CALENDAR_MARGIN + | ||
1947 | - + (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ? | ||
1948 | - (priv->week_width + (priv->week_width ? CALENDAR_XSEP : 0)) | ||
1949 | - : 0) | ||
1950 | - + day_wid_sep * i | ||
1951 | - + (day_width - logical_rect.width)/2), | ||
1952 | - CALENDAR_MARGIN + focus_width + focus_padding + logical_rect.y); | ||
1953 | - pango_cairo_show_layout (cr, layout); | ||
1954 | + gdk_draw_layout (priv->day_name_win, gc, | ||
1955 | + (CALENDAR_MARGIN + | ||
1956 | + + (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ? | ||
1957 | + (priv->week_width + (priv->week_width ? CALENDAR_XSEP : 0)) | ||
1958 | + : 0) | ||
1959 | + + day_wid_sep * i | ||
1960 | + + (day_width - logical_rect.width)/2), | ||
1961 | + CALENDAR_MARGIN + focus_width + focus_padding + logical_rect.y, | ||
1962 | + layout); | ||
1963 | } | ||
1964 | |||
1965 | g_object_unref (layout); | ||
1966 | - cairo_destroy (cr); | ||
1967 | } | ||
1968 | |||
1969 | static void | ||
1970 | @@ -2017,7 +2012,7 @@ | ||
1971 | { | ||
1972 | GtkWidget *widget = GTK_WIDGET (calendar); | ||
1973 | GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); | ||
1974 | - cairo_t *cr; | ||
1975 | + GdkGC *gc; | ||
1976 | gint row, week = 0, year; | ||
1977 | gint x_loc; | ||
1978 | char buffer[32]; | ||
1979 | @@ -2027,7 +2022,7 @@ | ||
1980 | gint focus_padding; | ||
1981 | gint focus_width; | ||
1982 | |||
1983 | - cr = gdk_cairo_create (priv->week_win); | ||
1984 | + gc = calendar->gc; | ||
1985 | |||
1986 | gtk_widget_style_get (GTK_WIDGET (widget), | ||
1987 | "focus-line-width", &focus_width, | ||
1988 | @@ -2038,20 +2033,20 @@ | ||
1989 | * Draw a rectangle as inverted background for the labels. | ||
1990 | */ | ||
1991 | |||
1992 | - gdk_cairo_set_source_color (cr, SELECTED_BG_COLOR (widget)); | ||
1993 | + gdk_gc_set_foreground (gc, SELECTED_BG_COLOR (widget)); | ||
1994 | if (priv->day_name_win) | ||
1995 | - cairo_rectangle (cr, | ||
1996 | - CALENDAR_MARGIN, | ||
1997 | - 0, | ||
1998 | - priv->week_width - CALENDAR_MARGIN, | ||
1999 | - priv->main_h - CALENDAR_MARGIN); | ||
2000 | + gdk_draw_rectangle (priv->week_win, gc, TRUE, | ||
2001 | + CALENDAR_MARGIN, | ||
2002 | + 0, | ||
2003 | + priv->week_width - CALENDAR_MARGIN, | ||
2004 | + priv->main_h - CALENDAR_MARGIN); | ||
2005 | else | ||
2006 | - cairo_rectangle (cr, | ||
2007 | - CALENDAR_MARGIN, | ||
2008 | - CALENDAR_MARGIN, | ||
2009 | - priv->week_width - CALENDAR_MARGIN, | ||
2010 | - priv->main_h - 2 * CALENDAR_MARGIN); | ||
2011 | - cairo_fill (cr); | ||
2012 | + gdk_draw_rectangle (priv->week_win, gc, TRUE, | ||
2013 | + CALENDAR_MARGIN, | ||
2014 | + CALENDAR_MARGIN, | ||
2015 | + priv->week_width - CALENDAR_MARGIN, | ||
2016 | + priv->main_h - 2 * CALENDAR_MARGIN); | ||
2017 | + | ||
2018 | |||
2019 | /* | ||
2020 | * Write the labels | ||
2021 | @@ -2059,7 +2054,7 @@ | ||
2022 | |||
2023 | layout = gtk_widget_create_pango_layout (widget, NULL); | ||
2024 | |||
2025 | - gdk_cairo_set_source_color (cr, SELECTED_FG_COLOR (widget)); | ||
2026 | + gdk_gc_set_foreground (gc, SELECTED_FG_COLOR (widget)); | ||
2027 | day_height = calendar_row_height (calendar); | ||
2028 | for (row = 0; row < 6; row++) | ||
2029 | { | ||
2030 | @@ -2095,12 +2090,10 @@ | ||
2031 | - logical_rect.width | ||
2032 | - CALENDAR_XSEP - focus_padding - focus_width); | ||
2033 | |||
2034 | - cairo_move_to (cr, x_loc, y_loc); | ||
2035 | - pango_cairo_show_layout (cr, layout); | ||
2036 | + gdk_draw_layout (priv->week_win, gc, x_loc, y_loc, layout); | ||
2037 | } | ||
2038 | |||
2039 | g_object_unref (layout); | ||
2040 | - cairo_destroy (cr); | ||
2041 | } | ||
2042 | |||
2043 | static void | ||
2044 | @@ -2149,7 +2142,7 @@ | ||
2045 | { | ||
2046 | GtkWidget *widget = GTK_WIDGET (calendar); | ||
2047 | GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); | ||
2048 | - cairo_t *cr; | ||
2049 | + GdkGC *gc; | ||
2050 | GdkColor *text_color; | ||
2051 | gchar buffer[32]; | ||
2052 | gint day; | ||
2053 | @@ -2162,7 +2155,7 @@ | ||
2054 | g_return_if_fail (row < 6); | ||
2055 | g_return_if_fail (col < 7); | ||
2056 | |||
2057 | - cr = gdk_cairo_create (priv->main_win); | ||
2058 | + gc = calendar->gc; | ||
2059 | |||
2060 | day = calendar->day[row][col]; | ||
2061 | |||
2062 | @@ -2170,11 +2163,11 @@ | ||
2063 | |||
2064 | if (calendar->day_month[row][col] == MONTH_PREV) | ||
2065 | { | ||
2066 | - text_color = PREV_MONTH_COLOR (widget); | ||
2067 | + gdk_gc_set_foreground (gc, PREV_MONTH_COLOR (GTK_WIDGET (calendar))); | ||
2068 | } | ||
2069 | else if (calendar->day_month[row][col] == MONTH_NEXT) | ||
2070 | { | ||
2071 | - text_color = NEXT_MONTH_COLOR (widget); | ||
2072 | + gdk_gc_set_foreground (gc, NEXT_MONTH_COLOR (GTK_WIDGET (calendar))); | ||
2073 | } | ||
2074 | else | ||
2075 | { | ||
2076 | @@ -2188,16 +2181,16 @@ | ||
2077 | #endif | ||
2078 | if (calendar->selected_day == day) | ||
2079 | { | ||
2080 | - gdk_cairo_set_source_color (cr, SELECTED_BG_COLOR (widget)); | ||
2081 | - gdk_cairo_rectangle (cr, &day_rect); | ||
2082 | - cairo_fill (cr); | ||
2083 | + gdk_gc_set_foreground (gc, SELECTED_BG_COLOR (GTK_WIDGET (calendar))); | ||
2084 | + gdk_draw_rectangle (priv->main_win, gc, TRUE, day_rect.x, day_rect.y, | ||
2085 | + day_rect.width, day_rect.height); | ||
2086 | } | ||
2087 | if (calendar->selected_day == day) | ||
2088 | - text_color = SELECTED_FG_COLOR (widget); | ||
2089 | + gdk_gc_set_foreground (gc, SELECTED_FG_COLOR (GTK_WIDGET (calendar))); | ||
2090 | else if (calendar->marked_date[day-1]) | ||
2091 | - text_color = MARKED_COLOR (widget); | ||
2092 | + gdk_gc_set_foreground (gc, MARKED_COLOR (GTK_WIDGET (calendar))); | ||
2093 | else | ||
2094 | - text_color = NORMAL_DAY_COLOR (widget); | ||
2095 | + gdk_gc_set_foreground (gc, NORMAL_DAY_COLOR (GTK_WIDGET (calendar))); | ||
2096 | } | ||
2097 | |||
2098 | /* Translators: this defines whether the day numbers should use | ||
2099 | @@ -2219,16 +2212,13 @@ | ||
2100 | x_loc -= logical_rect.width; | ||
2101 | y_loc = day_rect.y + (day_rect.height - logical_rect.height) / 2; | ||
2102 | |||
2103 | - gdk_cairo_set_source_color (cr, text_color); | ||
2104 | - cairo_move_to (cr, x_loc, y_loc); | ||
2105 | - pango_cairo_show_layout (cr, layout); | ||
2106 | + gdk_draw_layout (priv->main_win, gc, | ||
2107 | + x_loc, y_loc, layout); | ||
2108 | |||
2109 | if (calendar->marked_date[day-1] | ||
2110 | && calendar->day_month[row][col] == MONTH_CURRENT) | ||
2111 | - { | ||
2112 | - cairo_move_to (cr, x_loc - 1, y_loc); | ||
2113 | - pango_cairo_show_layout (cr, layout); | ||
2114 | - } | ||
2115 | + gdk_draw_layout (priv->main_win, gc, | ||
2116 | + x_loc-1, y_loc, layout); | ||
2117 | |||
2118 | if (GTK_WIDGET_HAS_FOCUS (calendar) | ||
2119 | && calendar->focus_row == row && calendar->focus_col == col) | ||
2120 | @@ -2253,7 +2243,6 @@ | ||
2121 | } | ||
2122 | |||
2123 | g_object_unref (layout); | ||
2124 | - cairo_destroy (cr); | ||
2125 | } | ||
2126 | |||
2127 | static void | ||
2128 | Index: gtk+-2.10.6/gtk/gtkentry.c | ||
2129 | =================================================================== | ||
2130 | --- gtk+-2.10.6.orig/gtk/gtkentry.c 2006-10-30 12:58:30.000000000 +0000 | ||
2131 | +++ gtk+-2.10.6/gtk/gtkentry.c 2006-10-30 12:59:30.000000000 +0000 | ||
2132 | @@ -3333,7 +3333,6 @@ | ||
2133 | if (GTK_WIDGET_DRAWABLE (entry)) | ||
2134 | { | ||
2135 | PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE); | ||
2136 | - cairo_t *cr; | ||
2137 | gint x, y; | ||
2138 | gint start_pos, end_pos; | ||
2139 | |||
2140 | @@ -3341,56 +3340,60 @@ | ||
2141 | |||
2142 | get_layout_position (entry, &x, &y); | ||
2143 | |||
2144 | - cr = gdk_cairo_create (entry->text_area); | ||
2145 | - | ||
2146 | - cairo_move_to (cr, x, y); | ||
2147 | - gdk_cairo_set_source_color (cr, &widget->style->text [widget->state]); | ||
2148 | - pango_cairo_show_layout (cr, layout); | ||
2149 | - | ||
2150 | + gdk_draw_layout (entry->text_area, widget->style->text_gc [widget->state], | ||
2151 | + x, y, | ||
2152 | + layout); | ||
2153 | + | ||
2154 | if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_pos, &end_pos)) | ||
2155 | { | ||
2156 | gint *ranges; | ||
2157 | gint n_ranges, i; | ||
2158 | PangoRectangle logical_rect; | ||
2159 | - GdkColor *selection_color, *text_color; | ||
2160 | + GdkGC *selection_gc, *text_gc; | ||
2161 | GtkBorder inner_border; | ||
2162 | - | ||
2163 | + GdkRegion *clip_region; | ||
2164 | + | ||
2165 | pango_layout_get_pixel_extents (layout, NULL, &logical_rect); | ||
2166 | gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges); | ||
2167 | |||
2168 | if (GTK_WIDGET_HAS_FOCUS (entry)) | ||
2169 | { | ||
2170 | - selection_color = &widget->style->base [GTK_STATE_SELECTED]; | ||
2171 | - text_color = &widget->style->text [GTK_STATE_SELECTED]; | ||
2172 | + selection_gc = widget->style->base_gc [GTK_STATE_SELECTED]; | ||
2173 | + text_gc = widget->style->text_gc [GTK_STATE_SELECTED]; | ||
2174 | } | ||
2175 | else | ||
2176 | { | ||
2177 | - selection_color = &widget->style->base [GTK_STATE_ACTIVE]; | ||
2178 | - text_color = &widget->style->text [GTK_STATE_ACTIVE]; | ||
2179 | + selection_gc = widget->style->base_gc [GTK_STATE_ACTIVE]; | ||
2180 | + text_gc = widget->style->text_gc [GTK_STATE_ACTIVE]; | ||
2181 | } | ||
2182 | - | ||
2183 | + | ||
2184 | + clip_region = gdk_region_new (); | ||
2185 | _gtk_entry_effective_inner_border (entry, &inner_border); | ||
2186 | |||
2187 | for (i = 0; i < n_ranges; ++i) | ||
2188 | - cairo_rectangle (cr, | ||
2189 | - inner_border.left - entry->scroll_offset + ranges[2 * i], | ||
2190 | - y, | ||
2191 | - ranges[2 * i + 1], | ||
2192 | - logical_rect.height); | ||
2193 | + { | ||
2194 | + GdkRectangle rect; | ||
2195 | |||
2196 | - cairo_clip (cr); | ||
2197 | - | ||
2198 | - gdk_cairo_set_source_color (cr, selection_color); | ||
2199 | - cairo_paint (cr); | ||
2200 | + rect.x = inner_border.left - entry->scroll_offset + ranges[2 * i]; | ||
2201 | + rect.y = y; | ||
2202 | + rect.width = ranges[2 * i + 1]; | ||
2203 | + rect.height = logical_rect.height; | ||
2204 | + | ||
2205 | + gdk_draw_rectangle (entry->text_area, selection_gc, TRUE, | ||
2206 | + rect.x, rect.y, rect.width, rect.height); | ||
2207 | |||
2208 | - cairo_move_to (cr, x, y); | ||
2209 | - gdk_cairo_set_source_color (cr, text_color); | ||
2210 | - pango_cairo_show_layout (cr, layout); | ||
2211 | + gdk_region_union_with_rect (clip_region, &rect); | ||
2212 | + } | ||
2213 | |||
2214 | + gdk_gc_set_clip_region (text_gc, clip_region); | ||
2215 | + gdk_draw_layout (entry->text_area, text_gc, | ||
2216 | + x, y, | ||
2217 | + layout); | ||
2218 | + gdk_gc_set_clip_region (text_gc, NULL); | ||
2219 | + | ||
2220 | + gdk_region_destroy (clip_region); | ||
2221 | g_free (ranges); | ||
2222 | } | ||
2223 | - | ||
2224 | - cairo_destroy (cr); | ||
2225 | } | ||
2226 | } | ||
2227 | |||
2228 | Index: gtk+-2.10.6/gtk/gtkwidget.c | ||
2229 | =================================================================== | ||
2230 | --- gtk+-2.10.6.orig/gtk/gtkwidget.c 2006-10-30 12:58:30.000000000 +0000 | ||
2231 | +++ gtk+-2.10.6/gtk/gtkwidget.c 2006-10-30 12:59:30.000000000 +0000 | ||
2232 | @@ -5445,7 +5445,8 @@ | ||
2233 | GdkScreen *screen; | ||
2234 | |||
2235 | update_pango_context (widget, context); | ||
2236 | - | ||
2237 | +/* TODO: Figure out the proper way to handle this in a pangoxft setting | ||
2238 | + | ||
2239 | screen = gtk_widget_get_screen_unchecked (widget); | ||
2240 | if (screen) | ||
2241 | { | ||
2242 | @@ -5453,7 +5454,7 @@ | ||
2243 | gdk_screen_get_resolution (screen)); | ||
2244 | pango_cairo_context_set_font_options (context, | ||
2245 | gdk_screen_get_font_options (screen)); | ||
2246 | - } | ||
2247 | + }*/ | ||
2248 | } | ||
2249 | } | ||
2250 | |||
2251 | Index: gtk+-2.10.6/gdk/x11/gdkpango-x11.c | ||
2252 | =================================================================== | ||
2253 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | ||
2254 | +++ gtk+-2.10.6/gdk/x11/gdkpango-x11.c 2006-10-30 12:59:30.000000000 +0000 | ||
2255 | @@ -0,0 +1,174 @@ | ||
2256 | +/* GDK - The GIMP Drawing Kit | ||
2257 | + * Copyright (C) 2000 Red Hat, Inc. | ||
2258 | + * | ||
2259 | + * This library is free software; you can redistribute it and/or | ||
2260 | + * modify it under the terms of the GNU Lesser General Public | ||
2261 | + * License as published by the Free Software Foundation; either | ||
2262 | + * version 2 of the License, or (at your option) any later version. | ||
2263 | + * | ||
2264 | + * This library is distributed in the hope that it will be useful, | ||
2265 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2266 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
2267 | + * Lesser General Public License for more details. | ||
2268 | + * | ||
2269 | + * You should have received a copy of the GNU Lesser General Public | ||
2270 | + * License along with this library; if not, write to the | ||
2271 | + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
2272 | + * Boston, MA 02111-1307, USA. | ||
2273 | + */ | ||
2274 | + | ||
2275 | +#include <config.h> | ||
2276 | +#include <stdlib.h> | ||
2277 | + | ||
2278 | +#include "gdkx.h" | ||
2279 | +#include "gdkdisplay-x11.h" | ||
2280 | +#include "gdkpango.h" | ||
2281 | +#include <pango/pangoxft.h> | ||
2282 | +#include <pango/pangoxft-render.h> | ||
2283 | +#include "gdkalias.h" | ||
2284 | + | ||
2285 | +#include <math.h> | ||
2286 | + | ||
2287 | +typedef struct _GdkX11Renderer GdkX11Renderer; | ||
2288 | +typedef struct _GdkX11RendererClass GdkX11RendererClass; | ||
2289 | + | ||
2290 | +#define GDK_TYPE_X11_RENDERER (_gdk_x11_renderer_get_type()) | ||
2291 | +#define GDK_X11_RENDERER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_X11_RENDERER, GdkX11Renderer)) | ||
2292 | +#define GDK_IS_X11_RENDERER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_X11_RENDERER)) | ||
2293 | +#define GDK_X11_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_X11_RENDERER, GdkX11RendererClass)) | ||
2294 | +#define GDK_IS_X11_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X11_RENDERER)) | ||
2295 | +#define GDK_X11_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_X11_RENDERER, GdkX11RendererClass)) | ||
2296 | + | ||
2297 | +#define MAX_RENDER_PART PANGO_RENDER_PART_STRIKETHROUGH | ||
2298 | + | ||
2299 | +struct _GdkX11Renderer | ||
2300 | +{ | ||
2301 | + PangoXftRenderer parent_instance; | ||
2302 | + | ||
2303 | + XRenderPictFormat *mask_format; | ||
2304 | + | ||
2305 | + GdkDrawable *drawable; | ||
2306 | + GdkGC *gc; | ||
2307 | +}; | ||
2308 | + | ||
2309 | +struct _GdkX11RendererClass | ||
2310 | +{ | ||
2311 | + PangoXftRendererClass parent_class; | ||
2312 | +}; | ||
2313 | + | ||
2314 | +G_DEFINE_TYPE (GdkX11Renderer, _gdk_x11_renderer, PANGO_TYPE_XFT_RENDERER) | ||
2315 | + | ||
2316 | +static void | ||
2317 | +gdk_x11_renderer_finalize (GObject *object) | ||
2318 | +{ | ||
2319 | + G_OBJECT_CLASS (_gdk_x11_renderer_parent_class)->finalize (object); | ||
2320 | +} | ||
2321 | + | ||
2322 | +static void | ||
2323 | +gdk_x11_renderer_composite_trapezoids (PangoXftRenderer *xftrenderer, | ||
2324 | + PangoRenderPart part, | ||
2325 | + XTrapezoid *trapezoids, | ||
2326 | + int n_trapezoids) | ||
2327 | +{ | ||
2328 | + /* Because we only use this renderer for "draw_glyphs()" calls, we | ||
2329 | + * won't hit this code path much. However, it is hit for drawing | ||
2330 | + * the "unknown glyph" hex squares. We can safely ignore the part, | ||
2331 | + */ | ||
2332 | + GdkX11Renderer *x11_renderer = GDK_X11_RENDERER (xftrenderer); | ||
2333 | + | ||
2334 | + _gdk_x11_drawable_draw_xtrapezoids (x11_renderer->drawable, | ||
2335 | + x11_renderer->gc, | ||
2336 | + trapezoids, n_trapezoids); | ||
2337 | + | ||
2338 | +} | ||
2339 | + | ||
2340 | +static void | ||
2341 | +gdk_x11_renderer_composite_glyphs (PangoXftRenderer *xftrenderer, | ||
2342 | + XftFont *xft_font, | ||
2343 | + XftGlyphSpec *glyphs, | ||
2344 | + gint n_glyphs) | ||
2345 | +{ | ||
2346 | + GdkX11Renderer *x11_renderer = GDK_X11_RENDERER (xftrenderer); | ||
2347 | + | ||
2348 | + _gdk_x11_drawable_draw_xft_glyphs (x11_renderer->drawable, | ||
2349 | + x11_renderer->gc, | ||
2350 | + xft_font, glyphs, n_glyphs); | ||
2351 | +} | ||
2352 | + | ||
2353 | +static void | ||
2354 | +_gdk_x11_renderer_init (GdkX11Renderer *renderer) | ||
2355 | +{ | ||
2356 | +} | ||
2357 | + | ||
2358 | +static void | ||
2359 | +_gdk_x11_renderer_class_init (GdkX11RendererClass *klass) | ||
2360 | +{ | ||
2361 | + PangoXftRendererClass *xftrenderer_class = PANGO_XFT_RENDERER_CLASS (klass); | ||
2362 | + GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
2363 | + | ||
2364 | + xftrenderer_class->composite_glyphs = gdk_x11_renderer_composite_glyphs; | ||
2365 | + xftrenderer_class->composite_trapezoids = gdk_x11_renderer_composite_trapezoids; | ||
2366 | + | ||
2367 | + object_class->finalize = gdk_x11_renderer_finalize; | ||
2368 | +} | ||
2369 | + | ||
2370 | +PangoRenderer * | ||
2371 | +_gdk_x11_renderer_get (GdkDrawable *drawable, | ||
2372 | + GdkGC *gc) | ||
2373 | +{ | ||
2374 | + GdkScreen *screen = GDK_DRAWABLE_IMPL_X11 (drawable)->screen; | ||
2375 | + GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen); | ||
2376 | + GdkX11Renderer *x11_renderer; | ||
2377 | + | ||
2378 | + if (!screen_x11->renderer) | ||
2379 | + { | ||
2380 | + screen_x11->renderer = g_object_new (GDK_TYPE_X11_RENDERER, | ||
2381 | + "display", GDK_SCREEN_XDISPLAY (screen), | ||
2382 | + "screen", GDK_SCREEN_XNUMBER (screen), | ||
2383 | + NULL); | ||
2384 | + } | ||
2385 | + | ||
2386 | + x11_renderer = GDK_X11_RENDERER (screen_x11->renderer); | ||
2387 | + | ||
2388 | + x11_renderer->drawable = drawable; | ||
2389 | + x11_renderer->gc = gc; | ||
2390 | + | ||
2391 | + return screen_x11->renderer; | ||
2392 | +} | ||
2393 | + | ||
2394 | +/** | ||
2395 | + * gdk_pango_context_get_for_screen: | ||
2396 | + * @screen: the #GdkScreen for which the context is to be created. | ||
2397 | + * | ||
2398 | + * Creates a #PangoContext for @screen. | ||
2399 | + * | ||
2400 | + * The context must be freed when you're finished with it. | ||
2401 | + * | ||
2402 | + * When using GTK+, normally you should use gtk_widget_get_pango_context() | ||
2403 | + * instead of this function, to get the appropriate context for | ||
2404 | + * the widget you intend to render text onto. | ||
2405 | + * | ||
2406 | + * Return value: a new #PangoContext for @screen | ||
2407 | + * | ||
2408 | + * Since: 2.2 | ||
2409 | + **/ | ||
2410 | +PangoContext * | ||
2411 | +gdk_pango_context_get_for_screen (GdkScreen *screen) | ||
2412 | +{ | ||
2413 | + PangoContext *context; | ||
2414 | + | ||
2415 | + g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); | ||
2416 | + | ||
2417 | + if (screen->closed) | ||
2418 | + return NULL; | ||
2419 | + | ||
2420 | + context = pango_xft_get_context (GDK_SCREEN_XDISPLAY (screen), | ||
2421 | + GDK_SCREEN_X11 (screen)->screen_num); | ||
2422 | + | ||
2423 | + g_object_set_data (G_OBJECT (context), "gdk-pango-screen", screen); | ||
2424 | + | ||
2425 | + return context; | ||
2426 | +} | ||
2427 | + | ||
2428 | +#define __GDK_PANGO_X11_C__ | ||
2429 | +#include "gdkaliasdef.c" | ||
2430 | Index: gtk+-2.10.6/gdk/x11/gdkpixmap-x11.c | ||
2431 | =================================================================== | ||
2432 | --- gtk+-2.10.6.orig/gdk/x11/gdkpixmap-x11.c 2006-10-30 12:58:30.000000000 +0000 | ||
2433 | +++ gtk+-2.10.6/gdk/x11/gdkpixmap-x11.c 2006-10-30 12:59:30.000000000 +0000 | ||
2434 | @@ -119,6 +119,9 @@ | ||
2435 | { | ||
2436 | GdkDrawableImplX11 *draw_impl = GDK_DRAWABLE_IMPL_X11 (impl); | ||
2437 | |||
2438 | + if (draw_impl->xft_draw) | ||
2439 | + XftDrawDestroy (draw_impl->xft_draw); | ||
2440 | + | ||
2441 | _gdk_x11_drawable_finish (GDK_DRAWABLE (draw_impl)); | ||
2442 | } | ||
2443 | |||
2444 | --- gtk+-2.10.6.orig/gtk/gtkcalendar.c.orig 2006-11-14 14:39:34.000000000 -0800 | ||
2445 | +++ gtk+-2.10.6/gtk/gtkcalendar.c 2006-11-14 14:37:34.000000000 -0800 | ||
2446 | @@ -1495,6 +1495,10 @@ gtk_calendar_realize (GtkWidget *widget) | ||
2447 | BACKGROUND_COLOR ( GTK_WIDGET ( calendar))); | ||
2448 | gdk_window_show (priv->main_win); | ||
2449 | gdk_window_set_user_data (priv->main_win, widget); | ||
2450 | + | ||
2451 | + /* Set widgets gc */ | ||
2452 | + calendar->gc = gdk_gc_new (widget->window); | ||
2453 | + | ||
2454 | gdk_window_set_background (widget->window, BACKGROUND_COLOR (widget)); | ||
2455 | gdk_window_show (widget->window); | ||
2456 | gdk_window_set_user_data (widget->window, widget); | ||