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