1 diff -r c1195334f839 gfx/cairo/cairo/src/cairo-xlib-surface.c
2 --- a/gfx/cairo/cairo/src/cairo-xlib-surface.c Fri May 21 17:42:55 2010 +0300
3 +++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c Fri May 21 19:12:29 2010 +0300
4 @@ -189,16 +189,57 @@ static const XTransform identity = { {
6 #define CAIRO_SURFACE_RENDER_HAS_PDF_OPERATORS(surface) CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 11)
8 #define CAIRO_SURFACE_RENDER_SUPPORTS_OPERATOR(surface, op) \
9 ((op) <= CAIRO_OPERATOR_SATURATE || \
10 (CAIRO_SURFACE_RENDER_HAS_PDF_OPERATORS(surface) && \
11 (op) <= CAIRO_OPERATOR_HSL_LUMINOSITY))
14 +_visual_for_xrender_format(Screen *screen,
15 + XRenderPictFormat *xrender_format)
18 + for (d = 0; d < screen->ndepths; d++) {
19 + Depth *d_info = &screen->depths[d];
20 + if (d_info->depth != xrender_format->depth)
23 + for (v = 0; v < d_info->nvisuals; v++) {
24 + Visual *visual = &d_info->visuals[v];
26 + switch (visual->class) {
28 + if (xrender_format->type != PictTypeDirect)
32 + /* Prefer TrueColor to DirectColor.
33 + (XRenderFindVisualFormat considers both TrueColor and
34 + DirectColor Visuals to match the same PictFormat.) */
40 + if (xrender_format->type != PictTypeIndexed)
45 + if (xrender_format ==
46 + XRenderFindVisualFormat (DisplayOfScreen(screen), visual))
55 _cairo_xlib_surface_set_clip_region (cairo_xlib_surface_t *surface,
56 cairo_region_t *region)
58 cairo_bool_t had_clip_rects = surface->clip_region != NULL;
60 if (had_clip_rects == FALSE && region == NULL)
61 return CAIRO_STATUS_SUCCESS;
62 @@ -313,16 +354,19 @@ _cairo_xlib_surface_create_similar (void
63 * visual/depth etc. as possible. */
64 pix = XCreatePixmap (src->dpy, src->drawable,
65 width <= 0 ? 1 : width, height <= 0 ? 1 : height,
66 xrender_format->depth);
69 if (xrender_format == src->xrender_format)
72 + visual = _visual_for_xrender_format(src->screen->screen,
75 surface = (cairo_xlib_surface_t *)
76 _cairo_xlib_surface_create_internal (src->screen, pix,
80 xrender_format->depth);
82 @@ -3178,28 +3222,32 @@ cairo_xlib_surface_create_with_xrender_f
84 XRenderPictFormat *format,
88 cairo_xlib_screen_t *screen;
89 cairo_surface_t *surface;
90 cairo_status_t status;
93 if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX)
94 return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE);
96 status = _cairo_xlib_screen_get (dpy, scr, &screen);
97 if (unlikely (status))
98 return _cairo_surface_create_in_error (status);
100 X_DEBUG ((dpy, "create_with_xrender_format (drawable=%x)", (unsigned int) drawable));
103 + visual = _visual_for_xrender_format (scr, format);
105 surface = _cairo_xlib_surface_create_internal (screen, drawable,
109 _cairo_xlib_screen_destroy (screen);
113 slim_hidden_def (cairo_xlib_surface_create_with_xrender_format);
116 @@ -3413,33 +3461,37 @@ cairo_xlib_surface_get_screen (cairo_sur
118 return surface->screen->screen;
122 * cairo_xlib_surface_get_visual:
123 * @surface: a #cairo_xlib_surface_t
125 - * Get the X Visual used for underlying X Drawable.
126 + * Gets the X Visual associated with @surface, suitable for use with the
127 + * underlying X Drawable. If @surface was created by
128 + * cairo_xlib_surface_create(), the return value is the Visual passed to that
131 - * Return value: the visual.
132 + * Return value: the Visual or %NULL if there is no appropriate Visual for
138 -cairo_xlib_surface_get_visual (cairo_surface_t *abstract_surface)
139 +cairo_xlib_surface_get_visual (cairo_surface_t *surface)
141 - cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
143 - if (! _cairo_surface_is_xlib (abstract_surface)) {
144 + cairo_xlib_surface_t *xlib_surface = (cairo_xlib_surface_t *) surface;
146 + if (! _cairo_surface_is_xlib (surface)) {
147 _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
151 - return surface->visual;
152 + return xlib_surface->visual;
156 * cairo_xlib_surface_get_depth:
157 * @surface: a #cairo_xlib_surface_t
159 * Get the number of bits used to represent each pixel value.