mark_rect_as_modified(xmin, ymin, xmax, ymax, 1);
mark_rect_as_modified(xmin, ymin, xmax, ymax, 0);
int direct_fb_copy(int x1, int y1, int x2, int y2, int mark) {	char *src, *dst;	int y, pixelsize = bpp/8;	int xmin = -1, xmax = -1, ymin = -1, ymax = -1;	int do_cmp = 2;	double tm;	int db = 0;if (db) dtime0(&tm);	x1 = nfix(x1, dpy_x);	y1 = nfix(y1, dpy_y);	x2 = nfix(x2, dpy_x+1);	y2 = nfix(y2, dpy_y+1);	if (x1 == x2) {		return 1;	}	if (y1 == y2) {		return 1;	}	X_LOCK;	for (y = y1; y < y2; y++) {		XRANDR_SET_TRAP_RET(0, "direct_fb_copy-set");		copy_image(scanline, x1, y, x2 - x1, 1);		XRANDR_CHK_TRAP_RET(0, "direct_fb_copy-chk");				src = scanline->data;		dst = main_fb + y * main_bytes_per_line + x1 * pixelsize;		if (do_cmp == 0 || !mark) {			memcpy(dst, src, (x2 - x1)*pixelsize);		} else if (do_cmp == 1) {			if (memcmp(dst, src, (x2 - x1)*pixelsize)) {				if (ymin == -1 || y < ymin) {					ymin = y;				}				if (ymax == -1 || y > ymax) {					ymax = y;				}				memcpy(dst, src, (x2 - x1)*pixelsize);			}		} else if (do_cmp == 2) {			int n, shift, xlo, xhi, k, block = 32;			char *dst2, *src2;			for (k=0; k*block < (x2 - x1); k++) {				shift = k*block;				xlo = x1  + shift;				xhi = xlo + block;				if (xhi > x2) {					xhi = x2;				}				n = xhi - xlo;				if (n < 1) {					continue;				}				src2 = src + shift*pixelsize;				dst2 = dst + shift*pixelsize;				if (memcmp(dst2, src2, n*pixelsize)) {					if (ymin == -1 || y < ymin) {						ymin = y;					}					if (ymax == -1 || y > ymax) {						ymax = y;					}					if (xmin == -1 || xlo < xmin) {						xmin = xlo;					}					if (xmax == -1 || xhi > xmax) {						xmax = xhi;					}					memcpy(dst2, src2, n*pixelsize);				}			}		}	}	X_UNLOCK;	if (do_cmp == 0) {		xmin = x1;		ymin = y1;		xmax = x2;		ymax = y2;	} else if (do_cmp == 1) {		xmin = x1;		xmax = x2;	}	if (xmin < 0 || ymin < 0 || xmax < 0 || xmin < 0) {		/* no diffs */		return 1;	}	if (xmax < x2) {		xmax++;	}	if (ymax < y2) {		ymax++;	}	if (mark) {		mark_rect_as_modified(xmin, ymin, xmax, ymax, 1);	}if (db) {	fprintf(stderr, "direct_fb_copy: %dx%d+%d+%d - %d  %.4f\n",		x2 - x1, y2 - y1, x1, y1, mark, dtime(&tm));}	return 1;}