File: bitblt.c

package info (click to toggle)
wily 0.13.41-7.3
  • links: PTS
  • area: main
  • in suites: buster
  • size: 2,560 kB
  • ctags: 3,426
  • sloc: ansic: 25,364; perl: 580; makefile: 448; sh: 415; python: 30; exp: 17
file content (58 lines) | stat: -rw-r--r-- 1,416 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* Copyright (c) 1992 AT&T - All rights reserved. */
#include <libc.h>
#include <libg.h>
#include "libgint.h"

void
bitblt(Bitmap *d, Point p, Bitmap *s, Rectangle r, Fcode f)
{
	int sx, sy, dx, dy, bfunc;
	GC g;
	unsigned long plane;
	Bitmap *btmp;

	if(Dx(r)<=0 || Dy(r)<=0)
		return;
	sx = r.min.x;
	sy = r.min.y;
	if(s->flag&SHIFT){
		sx -= s->r.min.x;
		sy -= s->r.min.y;
	}
	dx = p.x;
	dy = p.y;
	if(d->flag&SHIFT){
		dx -= d->r.min.x;
		dy -= d->r.min.y;
	}
	g = _getcopygc(f, d, s, &bfunc);
	if(bfunc == UseCopyArea)
		XCopyArea(_dpy, (Drawable)s->id, (Drawable)d->id, g,
			sx, sy, Dx(r), Dy(r), dx, dy);
	else if(bfunc == UseFillRectangle){
		XFillRectangle(_dpy, (Drawable)d->id, g,
			dx, dy, Dx(r), Dy(r));
	}else{
		/* bfunc == UseCopyPlane */
		plane = _ld2dmask[s->ldepth];
		plane &= ~(plane>>1);
		if(0/*f == S*/)
			XCopyPlane(_dpy, (Drawable)s->id, (Drawable)d->id, g,
				sx, sy, Dx(r), Dy(r), dx, dy, plane);
		else {
			/*
			 * CopyPlane can only do func code S,
			 * so copy src rect into a bitmap with the same depth
			 * as the dest, then do the bitblt from the tmp.
			 * This won't recurse again because we only get
			 * UseCopyPlane with differing bitmap depths
			 */
			btmp = _balloc(Rect(0,0,Dx(r),Dy(r)), d->ldepth);
			XCopyPlane(_dpy, (Drawable)s->id, (Drawable)btmp->id, g,
				sx, sy, Dx(r), Dy(r), 0, 0, plane);
			bitblt(d, p, btmp, btmp->r, f);
			bfree(btmp);
		}
	}

}