Hello,

The attached code attempts to typeset a LEN x 1 sized eight-bit AA
glyph.  By default, LEN is 255, and everything works fine.  If LEN is
changed to be 256, nothing is rendered.

Playing with the op seems to imply that in the latter case the alpha
channel is consistently taken to be all zeroes.

I'm using XFree86 4.2.0 (as patched by Debian) on x86, visual is
24/32.  The problem is reproducible on Savage and ATI Rage.

                                        Juliusz
#include <stdlib.h>
#include <stdio.h>
#include "Xlib.h"
#include "Xrender.h"

#define LEN 255

int
main()
{
    Display *dpy;
    Screen *scr;
    XSetWindowAttributes swa;
    Window window;
    Visual *visual;
    XRenderPictFormat templ;
    XRenderPictureAttributes pictattr;
    XRenderPictFormat *pictformat;
    Picture picture;
    XRenderPictFormat *gpictformat;
    Pixmap tpixmap;
    Picture tppicture;
    XRenderPictFormat *tpictformat;
    GlyphSet glyphset;
    XGlyphInfo ginfo;
    Glyph g;
    XRenderColor rcolor;
    XEvent event;
    int i;
    char buf[2048];

    dpy = XOpenDisplay(NULL);
    if(dpy == NULL)
        exit(1);

    scr = DefaultScreenOfDisplay(dpy);
    visual = DefaultVisualOfScreen(scr);
    pictformat = XRenderFindVisualFormat(dpy, visual);

    templ.type = 1;
    templ.depth = 8;
    templ.direct.redMask = 0;
    templ.direct.greenMask = 0;
    templ.direct.blueMask = 0;
    templ.direct.alphaMask = 0xFF;
    templ.direct.alpha = 0;
    gpictformat = 
        XRenderFindFormat(dpy,
                          (PictFormatType | PictFormatDepth |
                           PictFormatRedMask | PictFormatGreenMask |
                           PictFormatBlueMask |
                           PictFormatAlpha | PictFormatAlphaMask), 
                          &templ, 0);
    if(gpictformat == NULL)
        exit(1);

    swa.event_mask = ExposureMask;
    swa.background_pixel = WhitePixelOfScreen(scr);
    
    window = XCreateWindow(dpy, RootWindowOfScreen(scr),
                           100, 100, 700, 300, 0,
                           DefaultDepthOfScreen(scr),
                           InputOutput, visual,
                           CWEventMask | CWBackPixel, &swa);

    picture = XRenderCreatePicture(dpy, window, pictformat, 0L, &pictattr);

    tpixmap = XCreatePixmap(dpy, window, 1, 1, 32);
    templ.type = 1;
    templ.depth = 32;
    templ.direct.redMask = pictformat->direct.redMask;
    templ.direct.red = pictformat->direct.red;
    templ.direct.greenMask = pictformat->direct.greenMask;
    templ.direct.green = pictformat->direct.green;
    templ.direct.blueMask = pictformat->direct.blueMask;
    templ.direct.blue = pictformat->direct.blue;
    templ.direct.alphaMask = 0xFF;
    tpictformat = XRenderFindFormat(dpy,
                          (PictFormatType | PictFormatDepth |
                           PictFormatRedMask | PictFormatRed |
                           PictFormatGreenMask | PictFormatGreen |
                           PictFormatBlueMask | PictFormatBlue |
                           PictFormatAlphaMask), 
                          &templ, 0);
    if(tpictformat == NULL)
        exit(1);
    pictattr.repeat = 1;
    tppicture = XRenderCreatePicture(dpy, tpixmap, tpictformat,
                                     CPRepeat, &pictattr);
    rcolor.red = 0xFFFF;
    rcolor.green = 0;
    rcolor.blue = 0;
    rcolor.alpha = 0xFFFF;
    XRenderFillRectangle(dpy, PictOpSrc, tppicture,
                         &rcolor, 0, 0, 1, 1);
    glyphset = XRenderCreateGlyphSet(dpy, gpictformat);
    for(i = 0; i < 512; i++)
        buf[i] = i;
    ginfo.width = LEN;
    ginfo.height = 1;
    ginfo.x = 0;
    ginfo.y = 0;
    ginfo.xOff = 0;
    ginfo.yOff = 0;
    g = 0;
    XRenderAddGlyphs(dpy, glyphset, &g, &ginfo, 1, buf, LEN);
    XMapWindow(dpy, window);
    while(1) {
        XNextEvent(dpy, &event);
        if(event.type != Expose)
            continue;
        XRenderCompositeString8(dpy, PictOpOver,
                                tppicture, picture,
                                gpictformat, glyphset,
                                0, 0, 100, 200, "\0", 1);
    } 
    return 0;
}

Reply via email to