示例#1
0
/*
 * Clear the specified area of a window and possibly make an exposure event.
 * This sets the area window to its background color or pixmap.  If the
 * exposeflag is nonzero, then this also creates an exposure event for the
 * window.
 */
void
GsWpClearWindow(GR_WINDOW *wp, GR_COORD x, GR_COORD y, GR_SIZE width,
	GR_SIZE  height, GR_BOOL exposeflag)
{
	if (!wp->realized || !wp->output)
		return;
	/*
	 * Reduce the arguments so that they actually lie within the window.
	 */
	if (x < 0) {
		width += x;
		x = 0;
	}
	if (y < 0) {
		height += y;
		y = 0;
	}
	if (x + width > wp->width)
		width = wp->width - x;
	if (y + height > wp->height)
		height = wp->height - y;

	/*
	 * Now see if the region is really in the window.  If not, then
	 * do nothing.
	 */
	if ((x >= wp->width) || (y >= wp->height) || (width <= 0) ||
		(height <= 0))
			return;

	/*
	 * Draw the background of the window.
	 * Invalidate the current graphics context since
	 * we are changing the foreground color and mode.
	 */
	GsSetClipWindow(wp, NULL, 0);
	curgcp = NULL;

	GdSetFillMode(GR_FILL_SOLID);

	if (!(wp->props & GR_WM_PROPS_NOBACKGROUND)) {
		GdSetMode(GR_MODE_COPY);
		GdSetForegroundColor(wp->psd, wp->background);
		if (wp->bgpixmap) {
			GsWpDrawBackgroundPixmap(wp, wp->bgpixmap, x, y,
				width, height);
		} else {
			GdFillRect(wp->psd, wp->x + x, wp->y + y, width,height);
		}
	}

	/*
	 * Now do the exposure if required.
	 */
	if (exposeflag)
		GsDeliverExposureEvent(wp, x, y, width, height);
}
示例#2
0
/*
 * Clear the specified area of a window and possibly make an exposure event.
 * This sets the area window to its background color or pixmap.  If the
 * exposeflag is 1, then this also creates an exposure event for the window.
 * For buffered windows, mark drawing finalized and draw if
 * exposeflag = 2.
 */
void
GsClearWindow(GR_WINDOW *wp, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE  height, int exposeflag)
{
	if (!wp->realized || !wp->output)
		return;

	/*
	 * Reduce the arguments so that they actually lie within the window.
	 */
	if (x < 0) {
		width += x;
		x = 0;
	}
	if (y < 0) {
		height += y;
		y = 0;
	}
	if (x + width > wp->width)
		width = wp->width - x;
	if (y + height > wp->height)
		height = wp->height - y;

	/*
	 * Now see if the region is really in the window.  If not, then
	 * do nothing.
	 */
	if (x >= wp->width || y >= wp->height || width <= 0 || height <= 0)
		return;

	/*
	 * Buffered window drawing. First check if drawing finalized and
	 * set flag.  Physical window background erase is never performed
	 * with buffered windows, all drawing is postponed until the application
	 * is finished by calling GrClearWindow(..., 2), ie. GrFlushWindow()
	 */
	if (exposeflag == 2)
		wp->props |= GR_WM_PROPS_DRAWING_DONE;

	if (wp->props & GR_WM_PROPS_BUFFERED) {

		/* nothing to do until drawing finalized*/
		if (!(wp->props & GR_WM_PROPS_DRAWING_DONE))
			return;

		/* prepare clipping to window boundaries*/
		GsSetClipWindow(wp, NULL, 0);
		clipwp = NULL;		/* reset clip cache since no user regions used*/

#if DEBUG_EXPOSE
curgcp = NULL;
GdSetFillMode(GR_FILL_SOLID);
GdSetMode(GR_MODE_COPY);
GdSetForegroundColor(wp->psd, MWRGB(255,255,0)); /* yellow*/
GdFillRect(wp->psd, wp->x+x, wp->y+y, width, height);
usleep(500000);
#endif

		/* copy window pixmap buffer to window*/
		GdBlit(wp->psd, wp->x + x, wp->y + y, width, height, wp->buffer->psd, x, y, MWROP_COPY);
		return;				/* don't deliver exposure events*/
	}

	/*
	 * Unbuffered window: erase background unless nobackground flag set
	 */
	if (!(wp->props & GR_WM_PROPS_NOBACKGROUND)) {
		/* perhaps find a better way of determining whether pixmap needs src_over*/
		int hasalpha = wp->bgpixmap && (wp->bgpixmap->psd->data_format & MWIF_HASALPHA);

		/*
	 	 * Draw the background of the window.
	 	 * Invalidate the current graphics context since
	 	 * we are changing the foreground color and mode.
	 	 */
		GsSetClipWindow(wp, NULL, 0);
		clipwp = NULL;		/* reset clip cache since no user regions used*/

#if DEBUG_EXPOSE
GdSetFillMode(GR_FILL_SOLID);
GdSetMode(GR_MODE_COPY);
GdSetForegroundColor(wp->psd, MWRGB(255,255,0)); /* yellow*/
GdFillRect(wp->psd, wp->x+x, wp->y+y, width, height);
usleep(500000);
#endif

		curgcp = NULL;
		GdSetFillMode(GR_FILL_SOLID);
		GdSetMode(GR_MODE_COPY);
		GdSetForegroundColor(wp->psd, wp->background);

		/* if background pixmap w/alpha channel and stretchblit, fill entire (clipped) window*/
		if (hasalpha && wp->bgpixmapflags == GR_BACKGROUND_STRETCH)
				GdFillRect(wp->psd, wp->x, wp->y, wp->width, wp->height);
		else /* if no pixmap background clear exposed area*/
			if (!wp->bgpixmap || hasalpha)	/* FIXME will flash with pixmap, should check src_over*/
				if (!(wp->bgpixmapflags & GR_BACKGROUND_TRANS))
					GdFillRect(wp->psd, wp->x + x, wp->y + y, width, height);

		if (wp->bgpixmap)
			GsDrawBackgroundPixmap(wp, wp->bgpixmap, x, y, width, height);
	}

	/*
	 * Do the exposure if required for unbuffered windows.
	 */
	if (exposeflag)
		GsDeliverExposureEvent(wp, x, y, width, height);
}