gdk_gc_set_clip_mask doesn't work, using directfb as backend.



Hello, everybody. This is my first time to look for help here. Please
forgive me for not being familiar with a lot of things as I am new to
this place.

I am working on gtk-directfb these days.
I am porting a program, from gtk-x11 to gtk-directfb. And the program
doesn't work fine. Something showing isn't correct. When I track in,
it seems that gdk_gc_set_clip_mask doesn't work.(Where using this
function doesn't display correctly.)  So I wrote a sample code to test
it, and then ensured my guess.

The sample code, below
==========================================================
#include <gtk/gtk.h>

gboolean repaint (GtkWidget *widget, GdkEventExpose *event,
        gpointer user_data)
{
    int w = widget->allocation.width, h = widget->allocation.height;

    /* Custom Draw. */

    // GDK
    GdkPixmap *mask = gdk_pixmap_new (widget->window, w, h, 1);
    GdkGC *gc = gdk_gc_new (widget->window);
    GdkGC *maskgc = gdk_gc_new (mask);

    // Color
    GdkColor black, white, color;
    GdkColormap *cmap = gdk_colormap_get_system ();
    black.blue = black.green = black.red = 0;
    white.blue = white.green = white.red = -1;
    gdk_colormap_alloc_color (cmap, &black, TRUE, TRUE);
    gdk_colormap_alloc_color (cmap, &white, TRUE, TRUE);

    color.blue = -1;
    color.green = color.red = 0;
    gdk_colormap_alloc_color (cmap, &color, TRUE, TRUE);

    // Pixmap entire black
    gdk_gc_set_foreground (maskgc, &black);
    gdk_draw_rectangle (mask, maskgc, TRUE, 0, 0, w, h);

    // Pixmap half left white
    gdk_gc_set_foreground (maskgc, &white);
    gdk_draw_rectangle (mask, maskgc, TRUE, 0, 0, w/2, h);

    // Set clip mask
    gdk_gc_set_clip_mask (gc, mask);
    gdk_gc_set_clip_origin (gc, 0, 0);

    // Drawing
    gdk_gc_set_foreground (gc, &color);
    gdk_draw_rectangle (widget->window, gc, TRUE, 0, 0, w, h);

    // Cleaning
    gdk_colormap_free_colors (cmap, &black, 1);
    gdk_colormap_free_colors (cmap, &white, 1);
    gdk_colormap_free_colors (cmap, &color, 1);
    g_object_unref (cmap);
    g_object_unref (gc);
    g_object_unref (maskgc);
    g_object_unref (mask);

    return TRUE;
}

int main (int argc, char **argv)
{
    gtk_init (&argc, &argv);

    GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

#if 1
    // Gtk_DRAWING_AREA
    GtkWidget *drawing_area = gtk_drawing_area_new ();
    gtk_widget_set_size_request (drawing_area, 479, 271);
    g_signal_connect (G_OBJECT (drawing_area), "expose_event",
            G_CALLBACK (repaint), NULL);

    gtk_container_add (GTK_CONTAINER (window), drawing_area);
    gtk_widget_show (drawing_area);
#endif
    g_signal_connect (G_OBJECT (window), "expose_event",
            G_CALLBACK (repaint), NULL);

    gtk_widget_show (window);
    gtk_main ();

    return 0;
}
===========================================================
This sample would create a window. Left half of the window shoud have
been blue, and right half should have been default window color.
But after I compiled it with gtk-directfb, the blue was filled in the
entire window, not left half only. (It can be right if linked to
gtk-x11)

Hasn't clip mask of gc in gtk-directfb implemented yet?
I track in the gdkgc-directfb.c and gdkdrawable-directfb.c. I found
clip mask is set correctly, but isn't used indeed. Is that true?

Can someone help me please? Tell me some more details about
gdk_gc_set_clip_mask in gtk-directfb, tell me how to port the programs
which use gdk_gc_set_clip_mask within gtk-directfb, including this
sample code. Please thank you. Thank you very much.

I'm waiting for...


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