help with metacity compositor



[Maybe this message isn't suitable for this list, so point me where to ask it]

Hi,

After some hours trying to create a glitz backend for cairo, so I can use it to draw an SVG image with rsvg in the gl_window that the metacity compositor creates, I decide to ask the metacity developers for help. The code that I write is this (in the drawable-node.c file of libcm):

    cm_node_render (CM_NODE (dnode->deform), state);

    /* these are declared above */
    pSvg = rsvg_handle_new_from_file ("/home/carlosd/Desktop/test.svg", NULL);
    rsvg_handle_get_dimensions (pSvg, &dimensions);

    glitz_drawable_format_t formatTemplate;
    glitz_drawable_format_t *pCurrentFormat, *pResultFormat;
    XVisualInfo *pVisualInfo;
    glitz_format_t *format;
    formatTemplate.doublebuffer = 0;
    unsigned long mask;
    glitz_drawable_format_t templ, templl;
    gint iFormatIndex;

    formatTemplate.doublebuffer = 1;
    mask = GLITZ_FORMAT_DOUBLEBUFFER_MASK;

    iFormatIndex = 0;
    do
    {
        pCurrentFormat = glitz_glx_find_window_format (display->xdisplay,
                               ws_screen_get_number (screen),
                               mask,
                               &formatTemplate,
                               iFormatIndex++);
        if (pCurrentFormat)
        {
            pVisualInfo = glitz_glx_get_visual_info_from_format
                (display->xdisplay,
                 ws_screen_get_number (screen),
                 pCurrentFormat);
           
            if (pVisualInfo->depth == 24)
            {
                pResultFormat = pCurrentFormat;
                break;
            }
            else
                if (!pResultFormat)
                    pResultFormat = pCurrentFormat;
        }
    } while (pCurrentFormat);
   
    glitz_drawable_t *gdt = NULL;
   
    gdt = glitz_glx_create_drawable_for_window (
        display->xdisplay,
        ws_screen_get_number (screen),
        pResultFormat,
        WS_RESOURCE_XID (screen->gl_window),
        ws_screen_get_width (screen),
        ws_screen_get_height (screen));
    if (!gdt) {
        g_print ("glitz_glx_create_drawable_for_window ():");
        g_print ("Can't create!\n");
        exit (0);
        }

    glitz_surface_t *gst = NULL;
    gst = glitz_surface_create (gdt,
                pResultFormat,
                ws_screen_get_width (screen),
                ws_screen_get_height (screen),
                0,
                NULL);

    glitz_drawable_buffer_t buffer;
    buffer = GLITZ_DRAWABLE_BUFFER_BACK_COLOR;

    glitz_surface_attach (gst, gdt, buffer);
   
    cairo_surface_t *cst = NULL;
    cst = cairo_glitz_surface_create (gst);
    cairo_t *ct = NULL;
    ct = cairo_create (cst);
    cairo_translate (ct, dnode->geometry.x, dnode->geometry.y);
    rsvg_handle_render_cairo (pSvg, ct);
    cairo_destroy (ct);
    glitz_drawable_destroy (gdt);
    glitz_surface_destroy (gst);
   
    glPopMatrix();

You can see that I didn't change the compositor code, only added something in the middle of the calls cm_node_render and glPopMatrix.

Although the code is working the output is not the desired one. What I saw is my wallpaper an two black rows where must be the panels and the SVG file rendered.

So, my questions are:

Why I don't see the composited desktop?

I'm doing this (creating an glitz backend for cairo), since I think that I will use the OpenGL state previous configured by the compositor. Is this think right? If not, there is some way to do this?

Thanks,
Carlos.


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