blob: d3f83e8859975294320676ee3b302c1438c17581 [file] [log] [blame]
rsced7c8e82003-09-30 17:47:42 +00001#include <u.h>
2#include <libc.h>
3#include <draw.h>
4
5void
6_setdrawop(Display *d, Drawop op)
7{
8 uchar *a;
9
10 if(op != SoverD){
11 a = bufimage(d, 1+1);
12 if(a == 0)
13 return;
14 a[0] = 'O';
15 a[1] = op;
16 }
17}
18
19static void
20draw1(Image *dst, Rectangle *r, Image *src, Point *p0, Image *mask, Point *p1, Drawop op)
21{
22 uchar *a;
23
24 _setdrawop(dst->display, op);
25
26 a = bufimage(dst->display, 1+4+4+4+4*4+2*4+2*4);
27 if(a == 0)
28 return;
29 if(src == nil)
30 src = dst->display->black;
31 if(mask == nil)
32 mask = dst->display->opaque;
33 a[0] = 'd';
34 BPLONG(a+1, dst->id);
35 BPLONG(a+5, src->id);
36 BPLONG(a+9, mask->id);
37 BPLONG(a+13, r->min.x);
38 BPLONG(a+17, r->min.y);
39 BPLONG(a+21, r->max.x);
40 BPLONG(a+25, r->max.y);
41 BPLONG(a+29, p0->x);
42 BPLONG(a+33, p0->y);
43 BPLONG(a+37, p1->x);
44 BPLONG(a+41, p1->y);
45}
46
47void
48draw(Image *dst, Rectangle r, Image *src, Image *mask, Point p1)
49{
50 draw1(dst, &r, src, &p1, mask, &p1, SoverD);
51}
52
53void
54drawop(Image *dst, Rectangle r, Image *src, Image *mask, Point p1, Drawop op)
55{
56 draw1(dst, &r, src, &p1, mask, &p1, op);
57}
58
59void
60gendraw(Image *dst, Rectangle r, Image *src, Point p0, Image *mask, Point p1)
61{
62 draw1(dst, &r, src, &p0, mask, &p1, SoverD);
63}
64
65void
66gendrawop(Image *dst, Rectangle r, Image *src, Point p0, Image *mask, Point p1, Drawop op)
67{
68 draw1(dst, &r, src, &p0, mask, &p1, op);
69}