URI:
       tx11-fill.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tx11-fill.c (992B)
       ---
            1 #include <u.h>
            2 #include "x11-inc.h"
            3 #include <libc.h>
            4 #include <draw.h>
            5 #include <memdraw.h>
            6 #include "x11-memdraw.h"
            7 
            8 void
            9 memfillcolor(Memimage *m, u32int val)
           10 {
           11         _memfillcolor(m, val);
           12         if(m->X == nil)
           13                 return;
           14         if((val & 0xFF) == 0xFF)        /* full alpha */
           15                 _xfillcolor(m, m->r, _rgbatoimg(m, val));
           16         else
           17                 _xputxdata(m, m->r);
           18 }
           19 
           20 void
           21 _xfillcolor(Memimage *m, Rectangle r, u32int v)
           22 {
           23         Point p;
           24         Xmem *xm;
           25         XGC gc;
           26 
           27         xm = m->X;
           28         assert(xm != nil);
           29 
           30         /*
           31          * Set up fill context appropriately.
           32          */
           33         if(m->chan == GREY1){
           34                 gc = _x.gcfill0;
           35                 if(_x.gcfill0color != v){
           36                         XSetForeground(_x.display, gc, v);
           37                         _x.gcfill0color = v;
           38                 }
           39         }else{
           40                 if(m->chan == CMAP8 && _x.usetable)
           41                         v = _x.tox11[v];
           42                 gc = _x.gcfill;
           43                 if(_x.gcfillcolor != v){
           44                         XSetForeground(_x.display, gc, v);
           45                         _x.gcfillcolor = v;
           46                 }
           47         }
           48 
           49         /*
           50          * XFillRectangle takes coordinates relative to image rectangle.
           51          */
           52         p = subpt(r.min, m->r.min);
           53         XFillRectangle(_x.display, xm->pixmap, gc, p.x, p.y, Dx(r), Dy(r));
           54 }