Bug 977880 - Handle ReleaseFence on tiled thebes layer r=cwiiis,nical,BenWa
[gecko.git] / gfx / cairo / cairo-x-visual.patch
blob29f6c737e8c811f184bbeb22ae1425c81a0cbe3f
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))
13 +static Visual *
14 +_visual_for_xrender_format(Screen *screen,
15 + XRenderPictFormat *xrender_format)
17 + int d, v;
18 + for (d = 0; d < screen->ndepths; d++) {
19 + Depth *d_info = &screen->depths[d];
20 + if (d_info->depth != xrender_format->depth)
21 + continue;
23 + for (v = 0; v < d_info->nvisuals; v++) {
24 + Visual *visual = &d_info->visuals[v];
26 + switch (visual->class) {
27 + case TrueColor:
28 + if (xrender_format->type != PictTypeDirect)
29 + continue;
30 + break;
31 + case DirectColor:
32 + /* Prefer TrueColor to DirectColor.
33 + (XRenderFindVisualFormat considers both TrueColor and
34 + DirectColor Visuals to match the same PictFormat.) */
35 + continue;
36 + case StaticGray:
37 + case GrayScale:
38 + case StaticColor:
39 + case PseudoColor:
40 + if (xrender_format->type != PictTypeIndexed)
41 + continue;
42 + break;
43 + }
45 + if (xrender_format ==
46 + XRenderFindVisualFormat (DisplayOfScreen(screen), visual))
47 + return visual;
48 + }
49 + }
51 + return NULL;
54 static cairo_status_t
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);
68 visual = NULL;
69 if (xrender_format == src->xrender_format)
70 visual = src->visual;
71 + else
72 + visual = _visual_for_xrender_format(src->screen->screen,
73 + xrender_format);
75 surface = (cairo_xlib_surface_t *)
76 _cairo_xlib_surface_create_internal (src->screen, pix,
77 visual,
78 xrender_format,
79 width, height,
80 xrender_format->depth);
82 @@ -3178,28 +3222,32 @@ cairo_xlib_surface_create_with_xrender_f
83 Screen *scr,
84 XRenderPictFormat *format,
85 int width,
86 int height)
88 cairo_xlib_screen_t *screen;
89 cairo_surface_t *surface;
90 cairo_status_t status;
91 + Visual *visual;
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));
102 + if (format)
103 + visual = _visual_for_xrender_format (scr, format);
105 surface = _cairo_xlib_surface_create_internal (screen, drawable,
106 - NULL, format,
107 + visual, format,
108 width, height, 0);
109 _cairo_xlib_screen_destroy (screen);
111 return surface;
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
129 + * constructor.
131 - * Return value: the visual.
132 + * Return value: the Visual or %NULL if there is no appropriate Visual for
133 + * @surface.
135 * Since: 1.2
137 Visual *
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);
148 return NULL;
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.