1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/cairo/cairo-x-visual.patch Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,160 @@ 1.4 +diff -r c1195334f839 gfx/cairo/cairo/src/cairo-xlib-surface.c 1.5 +--- a/gfx/cairo/cairo/src/cairo-xlib-surface.c Fri May 21 17:42:55 2010 +0300 1.6 ++++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c Fri May 21 19:12:29 2010 +0300 1.7 +@@ -189,16 +189,57 @@ static const XTransform identity = { { 1.8 + 1.9 + #define CAIRO_SURFACE_RENDER_HAS_PDF_OPERATORS(surface) CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 11) 1.10 + 1.11 + #define CAIRO_SURFACE_RENDER_SUPPORTS_OPERATOR(surface, op) \ 1.12 + ((op) <= CAIRO_OPERATOR_SATURATE || \ 1.13 + (CAIRO_SURFACE_RENDER_HAS_PDF_OPERATORS(surface) && \ 1.14 + (op) <= CAIRO_OPERATOR_HSL_LUMINOSITY)) 1.15 + 1.16 ++static Visual * 1.17 ++_visual_for_xrender_format(Screen *screen, 1.18 ++ XRenderPictFormat *xrender_format) 1.19 ++{ 1.20 ++ int d, v; 1.21 ++ for (d = 0; d < screen->ndepths; d++) { 1.22 ++ Depth *d_info = &screen->depths[d]; 1.23 ++ if (d_info->depth != xrender_format->depth) 1.24 ++ continue; 1.25 ++ 1.26 ++ for (v = 0; v < d_info->nvisuals; v++) { 1.27 ++ Visual *visual = &d_info->visuals[v]; 1.28 ++ 1.29 ++ switch (visual->class) { 1.30 ++ case TrueColor: 1.31 ++ if (xrender_format->type != PictTypeDirect) 1.32 ++ continue; 1.33 ++ break; 1.34 ++ case DirectColor: 1.35 ++ /* Prefer TrueColor to DirectColor. 1.36 ++ (XRenderFindVisualFormat considers both TrueColor and 1.37 ++ DirectColor Visuals to match the same PictFormat.) */ 1.38 ++ continue; 1.39 ++ case StaticGray: 1.40 ++ case GrayScale: 1.41 ++ case StaticColor: 1.42 ++ case PseudoColor: 1.43 ++ if (xrender_format->type != PictTypeIndexed) 1.44 ++ continue; 1.45 ++ break; 1.46 ++ } 1.47 ++ 1.48 ++ if (xrender_format == 1.49 ++ XRenderFindVisualFormat (DisplayOfScreen(screen), visual)) 1.50 ++ return visual; 1.51 ++ } 1.52 ++ } 1.53 ++ 1.54 ++ return NULL; 1.55 ++} 1.56 ++ 1.57 + static cairo_status_t 1.58 + _cairo_xlib_surface_set_clip_region (cairo_xlib_surface_t *surface, 1.59 + cairo_region_t *region) 1.60 + { 1.61 + cairo_bool_t had_clip_rects = surface->clip_region != NULL; 1.62 + 1.63 + if (had_clip_rects == FALSE && region == NULL) 1.64 + return CAIRO_STATUS_SUCCESS; 1.65 +@@ -313,16 +354,19 @@ _cairo_xlib_surface_create_similar (void 1.66 + * visual/depth etc. as possible. */ 1.67 + pix = XCreatePixmap (src->dpy, src->drawable, 1.68 + width <= 0 ? 1 : width, height <= 0 ? 1 : height, 1.69 + xrender_format->depth); 1.70 + 1.71 + visual = NULL; 1.72 + if (xrender_format == src->xrender_format) 1.73 + visual = src->visual; 1.74 ++ else 1.75 ++ visual = _visual_for_xrender_format(src->screen->screen, 1.76 ++ xrender_format); 1.77 + 1.78 + surface = (cairo_xlib_surface_t *) 1.79 + _cairo_xlib_surface_create_internal (src->screen, pix, 1.80 + visual, 1.81 + xrender_format, 1.82 + width, height, 1.83 + xrender_format->depth); 1.84 + } 1.85 +@@ -3178,28 +3222,32 @@ cairo_xlib_surface_create_with_xrender_f 1.86 + Screen *scr, 1.87 + XRenderPictFormat *format, 1.88 + int width, 1.89 + int height) 1.90 + { 1.91 + cairo_xlib_screen_t *screen; 1.92 + cairo_surface_t *surface; 1.93 + cairo_status_t status; 1.94 ++ Visual *visual; 1.95 + 1.96 + if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX) 1.97 + return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE); 1.98 + 1.99 + status = _cairo_xlib_screen_get (dpy, scr, &screen); 1.100 + if (unlikely (status)) 1.101 + return _cairo_surface_create_in_error (status); 1.102 + 1.103 + X_DEBUG ((dpy, "create_with_xrender_format (drawable=%x)", (unsigned int) drawable)); 1.104 + 1.105 ++ if (format) 1.106 ++ visual = _visual_for_xrender_format (scr, format); 1.107 ++ 1.108 + surface = _cairo_xlib_surface_create_internal (screen, drawable, 1.109 +- NULL, format, 1.110 ++ visual, format, 1.111 + width, height, 0); 1.112 + _cairo_xlib_screen_destroy (screen); 1.113 + 1.114 + return surface; 1.115 + } 1.116 + slim_hidden_def (cairo_xlib_surface_create_with_xrender_format); 1.117 + 1.118 + /** 1.119 +@@ -3413,33 +3461,37 @@ cairo_xlib_surface_get_screen (cairo_sur 1.120 + 1.121 + return surface->screen->screen; 1.122 + } 1.123 + 1.124 + /** 1.125 + * cairo_xlib_surface_get_visual: 1.126 + * @surface: a #cairo_xlib_surface_t 1.127 + * 1.128 +- * Get the X Visual used for underlying X Drawable. 1.129 ++ * Gets the X Visual associated with @surface, suitable for use with the 1.130 ++ * underlying X Drawable. If @surface was created by 1.131 ++ * cairo_xlib_surface_create(), the return value is the Visual passed to that 1.132 ++ * constructor. 1.133 + * 1.134 +- * Return value: the visual. 1.135 ++ * Return value: the Visual or %NULL if there is no appropriate Visual for 1.136 ++ * @surface. 1.137 + * 1.138 + * Since: 1.2 1.139 + **/ 1.140 + Visual * 1.141 +-cairo_xlib_surface_get_visual (cairo_surface_t *abstract_surface) 1.142 ++cairo_xlib_surface_get_visual (cairo_surface_t *surface) 1.143 + { 1.144 +- cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface; 1.145 +- 1.146 +- if (! _cairo_surface_is_xlib (abstract_surface)) { 1.147 ++ cairo_xlib_surface_t *xlib_surface = (cairo_xlib_surface_t *) surface; 1.148 ++ 1.149 ++ if (! _cairo_surface_is_xlib (surface)) { 1.150 + _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); 1.151 + return NULL; 1.152 + } 1.153 + 1.154 +- return surface->visual; 1.155 ++ return xlib_surface->visual; 1.156 + } 1.157 + 1.158 + /** 1.159 + * cairo_xlib_surface_get_depth: 1.160 + * @surface: a #cairo_xlib_surface_t 1.161 + * 1.162 + * Get the number of bits used to represent each pixel value. 1.163 + *