[Mesa-dev] [PATCH] glx: Fix for throwing BadDrawable (invalid Pixmap or Window parameter) by Xserver

Brian Paul brianp at vmware.com
Thu Sep 5 09:56:41 PDT 2013


On 09/04/2013 10:30 AM, Maniak, Lukasz wrote:
>      Fix for thro= wing BadDrawable (invalid Pixmap or Window parameter)
>
>      by Xserver w= hen calling XCreatePixmap or fill_bitmap from
>
>      DRI_glXUseXF= ont.
>
> <= /span>
>
>      current= Drawable which came from __glXGetCurrentContext was not
> correct in
>
>      this case, w= e use DefaultRootWindow(dpy) instead.

By "was not correct" do you mean it was zero?

The drawable/window parameter to XCreatePixmap() is really just used to 
determine the depth for the Pixmap.  I think any window/depth should be 
OK since we're just looking for zero and non-zero pixels when generating 
the gl bitmaps.


>
> Signed-off-by: Lukasz Maniak &l= t;lukasz.maniak at intel.com>
>
> ---
>
> src/glx/xfont.c | 6 ++-= ---
>
> 1 file changed, 2 insertions(&#= 43;), 4 deletions(-)
>
> diff --git a/src/glx/xfont.c b/= src/glx/xfont.c
>
> index 316c585..60e28ab 100644
>
> --- a/src/glx/xfont.c
>
> +++ b/src/glx/xfont= .c
>
> @@ -215,7 +215,6 @@ _X_HIDD= EN void
>
> DRI_glXUseXFont(struct glx_cont= ext *CC, Font font, int first, int
> count, int listbase)
>
> {
>
>      Display *dpy= ;
>
> -   Window win;<= /o:p>
>
>      Pixmap pixma= p;
>
>      GC gc; =
>
>      XGCValu= es values;
>
> @@ -231,7 +230,6 @@ DRI_glX= UseXFont(struct glx_context *CC, Font font,
> int first, int count, int lis
>
>      int i;<= /o:p>
>
>      dpy =3D= CC->currentDpy;
>
> -   win =3D CC->cu= rrentDrawable;
>
>      fs =3D = XQueryFont(dpy, font);
>
>      if (!fs) {
>
> @@ -279,7 +277,7 @@ DRI_glX= UseXFont(struct glx_context *CC, Font font,
> int first, int count, int lis
>
>      glPixelStore= i(GL_UNPACK_SKIP_PIXELS, 0);
>
>      glPixel= Storei(GL_UNPACK_ALIGNMENT, 1);
>
> -   pixmap =3D XCreat= ePixmap(dpy, win, 10, 10, 1);
>
> +   pixmap =3D XC= reatePixmap(dpy, DefaultRootWindow(dpy), 10, 10, 1);
>
>      values.foreg= round =3D BlackPixel(dpy, DefaultScreen(dpy));
>
>      values.backg= round =3D WhitePixel(dpy, DefaultScreen(dpy));
>
>      values.font = =3D fs->fid;
>
> @@ -342,7 +340,7 @@ DRI_glX= UseXFont(struct glx_context *CC, Font font,
> int first, int count, int lis
>
>       &= nbsp; if (valid && (bm_width > 0) && (bm_height > 0))= {
>
>       &= nbsp;    memset(bm, '\0', bm_width * bm_height);
>
> -     =     fill_bitmap(dpy, win, gc, bm_width, bm_height, x, y, c, = bm);
>
> +    &n= bsp;    fill_bitmap(dpy, DefaultRootWindow(dpy), gc, bm_widt=
> h, bm_height, x, y, c, bm);
>
>       &= nbsp;    glBitmap(width, height, x0, y0, dx, dy, bm);
>
> #ifdef DEBUG<= /p>
>

A less invasive change would be to simply replace

  win = CC->currentDrawable;

with

  win = DefaultRootWindow(dpy);

I'd prefer that.

-Brian



More information about the mesa-dev mailing list