~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/X11/mask.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 /**
  4 tv_screen_mask.c:
  5 allows drawing to take place through a clip mask
  6 **/
  7 
  8 #include <stdio.h>
  9 #include <tina/sys.h>
 10 #include <tina/sysfuncs.h>
 11 #include <tina/math.h>
 12 #include <tina/tv.h>
 13 #include <tina/tv_screen.h>
 14 
 15 void   *tv_screen_mask_get(Tv_screen * screen, int lx, int ly, int ux, int uy)
 16 {
 17     Tv_mask *mask = ts_ralloc(Tv_mask);
 18 
 19     mask->lx = lx;
 20     mask->ly = ly;
 21     mask->ux = ux;
 22     mask->uy = uy;
 23     mask->bitmap = XCreatePixmap(screen->display, screen->window,
 24                                  ux - lx, uy - ly, 1);
 25     mask->gc = XCreateGC(screen->display, mask->bitmap, 0, 0);
 26     XSetBackground(screen->display, mask->gc, (unsigned long) 0);
 27     XSetForeground(screen->display, mask->gc, (unsigned long) 0);
 28     XFillRectangle(screen->display, mask->bitmap, mask->gc, 0, 0, ux - lx, uy - ly);
 29     return ((void *) mask);
 30 }
 31 
 32 void    tv_screen_mask_use(Tv_screen * screen, Tv_mask * mask)
 33 {
 34     if (mask == NULL)
 35         XSetClipMask(screen->display, screen->gc, None);
 36     else
 37     {
 38         XSetClipMask(screen->display, screen->gc, mask->bitmap);
 39         XSetClipOrigin(screen->display, screen->gc, mask->lx, mask->ly);
 40     }
 41 }
 42 
 43 void    tv_screen_mask_point(Tv_screen * screen, Tv_mask * mask, Ipos pos, int bit)
 44 {
 45     int     x = ipos_x(pos) - mask->lx;
 46     int     y = ipos_y(pos) - mask->ly;
 47 
 48     XSetForeground(screen->display, mask->gc, (unsigned long) bit);
 49     XDrawPoint(screen->display, mask->bitmap, mask->gc, x, y);
 50 }
 51 
 52 void    tv_screen_mask_free(Tv_screen * screen, Tv_mask * mask)
 53 {
 54     XSetClipMask(screen->display, screen->gc, None);
 55     XFreeGC(screen->display, mask->gc);
 56     XFreePixmap(screen->display, mask->bitmap);
 57     rfree((void *) mask);
 58 }
 59 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.