[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#462262: libxft-dev: XftDrawRect buggy behaviour whens erver doesn't support xrender



Package: libxft-dev
Version: 2.1.8.2-8
Severity: normal


XftDrawRect works differently when the alpha channel is < 32768 depending
on wether the server supports the xrender extension or not.

First of all, it is documented to "fill a solid rectangle". This is
the actual behaviour when the server supports xrender: the pixel value
(including alpha channel) is taken as it is and the destination rectangle will be filled with the value:

        XRenderFillRectangle (draw->dpy, PictOpSrc, draw->render.pict,
                              &color->color, x, y, width, height);

(pictopsrc is documented to just copy all four channels (rgba) from source to destination).

However, when the xrender extension is not supported by the x-server,
the behaviour is different: when the alpha value is >= 32768, then the
rectangle will be filled with the pixel value as-is (which is the correct
behaviour), otherwise _NOTHING_ will be done:

    if (color->color.alpha >= 0x8000)
    {   
        XSetForeground (draw->dpy, draw->core.gc, color->pixel);
        XFillRectangle (draw->dpy, draw->drawable, draw->core.gc,
                        x, y, width, height);
    }

This makes xftdrawrect unsuitable for the purpose it was actually created
for: filling the background to some defined value. Regardless of what
the purpose behind xftdrawrect, this is completely different behaviour
depending on wether the server supports xrender or not.

(for example, when xftdrawrect'ing a 100% transparent red over a newly
allocated and uncleared pixmap will result in that pixmap being filled
with 100% transparent red when the server supports xrender, and with
retaining the garbage it contained when the server doesn't support
xrender).

The fix is to always call xfillrectangle even for partly transparent
colours, resulting in the same behaviour regardless of the availability of
xrender.

-- System Information:
Debian Release: 4.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.23-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libxft-dev depends on:
hi  libc6-dev [libc-dev]   2.7-5             GNU C Library: Development Librari
ii  libfontconfig1-dev     2.4.2-1.2         generic font configuration library
hi  libfreetype6-dev       2.3.5-1+b1        FreeType 2 font engine, developmen
ii  libx11-dev             2:1.0.3-7         X11 client-side library (developme
ii  libxft2                2.1.8.2-8         FreeType-based font drawing librar
ii  libxrender-dev         1:0.9.1-3         X Rendering Extension client libra
ii  x11-common             1:7.3+10          X Window System (X.Org) infrastruc
ii  zlib1g-dev [libz-dev]  1:1.2.3.3.dfsg-10 compression library - development

libxft-dev recommends no packages.

-- no debconf information



Reply to: