Exemple #1
0
void draw_display_window(display_item *pDI, int undo, BITMAP *pScreen, RECT *pRect)
{
	WINDOW *pContents = (WINDOW*) pDI->pContents;
	BITMAP *pOldContents = pDI->pOldContents;
	RECT tmp_r;

	// dirty rectangle.
	if (pRect)
	{
		rect_copy(&tmp_r, pRect);

		if (pRect->x == -1)
		{
			rect_copy(pRect, &pContents->window);
		} else {
			rect_combine(pRect, &tmp_r, &pContents->window);
		}
	}

	if (undo)
	{
		// draw it
		blit(pOldContents, pScreen, 0, 0, pContents->window.x, pContents->window.y, pContents->window.w, pContents->window.h);
	} else {
		// save it
		if (pDI->is_saving)
		{
			blit(pScreen, pOldContents, pContents->window.x, pContents->window.y, 0, 0, pContents->window.w, pContents->window.h);
		}

		// draw it
		gui_draw_window(pContents, pScreen);
	}
}
Exemple #2
0
void draw_display_bitmap(display_item *pDI, int undo, BITMAP *pScreen, RECT *pRect)
{
	BITMAP *pContents = (BITMAP*) pDI->pContents;
	BITMAP *pOldContents = pDI->pOldContents;
	BITMAP *p = (BITMAP*) (undo?pOldContents:pContents);
	RECT r = {pDI->x, pDI->y, undo?p->w:pDI->is_scaled?pDI->w:p->w, undo?p->h:pDI->is_scaled?pDI->h:p->h};
	RECT tmp_r;

	// dirty rectangle.
	if (pRect)
	{
		rect_copy(&tmp_r, pRect);

		if (pRect->x == -1)
		{
			rect_copy(pRect, &r);
		} else {
			rect_combine(pRect, &tmp_r, &r);
		}
	}

	if (undo)
	{
		// draw it
		if (pDI->is_saving)
			blit(pOldContents, pScreen, 0, 0, pDI->x, pDI->y, pOldContents->w, pOldContents->h);
	} else {
		// draw it.
		if (pDI->is_scaled)
		{
			if (pDI->is_saving)
				blit(pScreen, pOldContents, pDI->x, pDI->y, 0, 0, pDI->w, pDI->h);

			if (pDI->is_sprite)
			{
				stretch_sprite((BITMAP*) pContents, pScreen, pDI->x, pDI->y, pDI->w, pDI->h);
			} else {
				stretch_blit((BITMAP*) pContents, pScreen, 0, 0, pContents->w, pContents->h, pDI->x, pDI->y, pDI->w, pDI->h);
			}
		} else {
			if (pDI->is_saving)
				blit(pScreen, pOldContents, pDI->x, pDI->y, 0, 0, pContents->w, pContents->h);

			if (pDI->is_sprite)
			{
				draw_sprite(pScreen, pContents, pDI->x, pDI->y);
			} else
			if (pDI->is_translucent)
			{
				pDI->pParent->display_prev_table = color_map;
				color_map = pDI->type==DISPLAY_LIGHT?pDI->pParent->display_light_table:pDI->pParent->display_trans_table;
				draw_trans_sprite(pScreen, pContents, pDI->x, pDI->y);
				color_map = pDI->pParent->display_prev_table;
			} else {
				blit(pContents, pScreen, 0, 0, pDI->x, pDI->y, pContents->w, pContents->h);
			}
		}
	}
}
Exemple #3
0
void dirty_addrect(struct rect *rt) {
	if (rt == NULL) {
		_dirty_rects[0].left	= 0;
		_dirty_rects[0].top	= 0;
		_dirty_rects[0].right	= SCREEN_WIDTH;
		_dirty_rects[0].bottom	= SCREEN_HEIGHT;
		_rect_count		= 1;
		return;
	}

	if (_rect_count==0) {
		_dirty_rects[_rect_count] = *rt;
		++_rect_count;
	} else {
		int i;
		struct rect comb;
		int area1, area2, areac, areaBest;
		int bestidx = -1;

		if (_rect_count>=MAX_DIRTY-1) {
			dirty_addrect(NULL);
			return;
		}

		for (i=0; i<_rect_count; ++i) {
			if (rect_contains(&_dirty_rects[i], rt)) return;
		}
		for (i=0; i<_rect_count; ++i) {
			comb = rect_combine(&_dirty_rects[i], rt);
			area1 = rect_calc_area(&_dirty_rects[i]);
			area2 = rect_calc_area(rt);
			areac = rect_calc_area(&comb);
			if (areac < area1 + area2) {
				if (bestidx < 0 || area1 + area2 - areac > areaBest) {
					areaBest = area1 + area2 - areac;
					bestidx = i;
				}
			}
		}
		if (bestidx >= 0)
			_dirty_rects[bestidx] = rect_combine(&_dirty_rects[bestidx], rt);
		else
			_dirty_rects[_rect_count++] = *rt;
	}
}