LOCAL void rfb_setrealcliprect(struct rfb_Display *mod, struct rfb_Window *v) { v->rfbw_ClipRect = v->rfbw_UserClipRect; TBOOL res = region_intersect(v->rfbw_ClipRect.r, v->rfbw_WinRect.r); if (!(v->rfbw_Flags & RFBWFL_BACKBUFFER)) { struct Rect s; REGION_RECT_SET(&s, 0, 0, mod->rfb_Width - 1, mod->rfb_Height - 1); if (!region_intersect(v->rfbw_ClipRect.r, s.r)) res = TFALSE; } if (!res) v->rfbw_ClipRect.r[0] = -1; }
LOCAL TBOOL fbp_copyarea(struct rfb_Display *mod, struct rfb_Window *v, TINT dx, TINT dy, TINT dr[4], struct THook *exposehook) { if (v->rfbw_ClipRect.r[0] < 0 || !region_intersect(dr, v->rfbw_ClipRect.r)) return TFALSE; TBOOL check_expose = fbp_copyarea_int(mod, v, dx, dy, dr); if (check_expose && exposehook) { struct RectPool *pool = &mod->rfb_RectPool; struct Region R, L; if (rfb_getlayers(mod, &R, v, 0, 0)) { if (rfb_getlayers(mod, &L, v, dx, dy)) { if (region_subregion(pool, &L, &R) && region_andrect(pool, &L, dr, 0, 0)) fbp_doexpose(mod, v, &L, exposehook); region_free(pool, &L); } region_free(pool, &R); } } return check_expose; }
void display_region_list_add(struct display_t * disp, struct region_t * r) { struct region_t region; if(disp) { region_init(®ion, 0, 0, disp->fb->width, disp->fb->height); if(region_intersect(®ion, ®ion, r)) region_list_add(disp->rl, ®ion); } }
LOCAL void rfb_markdirty(struct rfb_Display *mod, struct rfb_Window *v, TINT *r) { if (r[2] < r[0] || r[3] < r[1]) return; TINT d[4]; TUINT align = RFB_DIRTY_ALIGN; d[0] = r[0] & ~align; d[1] = r[1] & ~align; d[2] = (r[2] & ~align) + align; d[3] = (r[3] & ~align) + align; if (region_intersect(d, v->rfbw_WinRect.r)) { TBOOL winbackbuffer = v->rfbw_Flags & RFBWFL_BACKBUFFER; TBOOL res = TTRUE; if (!winbackbuffer) { struct Rect s; REGION_RECT_SET(&s, 0, 0, mod->rfb_Width - 1, mod->rfb_Height - 1); res = region_intersect(d, s.r); } if (res) { region_orrect(&mod->rfb_RectPool, winbackbuffer ? &v->rfbw_DirtyRegion : &mod->rfb_DirtyRegion, d, TTRUE); if (winbackbuffer) v->rfbw_Flags |= RFBWFL_DIRTY; else mod->rfb_Flags |= RFBFL_DIRTY; } } }
static TINT rfb_cmdrectaffected(struct rfb_Display *mod, struct TVRequest *req, TINT result[4], TBOOL source_affect) { struct rfb_Window *v = TNULL; TINT *rect = TNULL; TINT *xywh = TNULL; TINT temprect[4]; switch (req->tvr_Req.io_Command) { default: /* not affected, no rect */ return 0; case TVCMD_FLUSH: case TVCMD_SETATTRS: case TVCMD_CLOSEWINDOW: /* yes, affected, but no rect */ return -1; /* window rect: */ case TVCMD_DRAWSTRIP: v = req->tvr_Op.Strip.Window; break; case TVCMD_DRAWFAN: v = req->tvr_Op.Fan.Window; break; case TVCMD_TEXT: v = req->tvr_Op.Text.Window; break; /* specific rect: */ case TVCMD_RECT: v = req->tvr_Op.Rect.Window; xywh = req->tvr_Op.Rect.Rect; break; case TVCMD_FRECT: v = req->tvr_Op.FRect.Window; xywh = req->tvr_Op.FRect.Rect; break; case TVCMD_LINE: v = req->tvr_Op.Line.Window; xywh = req->tvr_Op.Line.Rect; break; case TVCMD_DRAWBUFFER: v = req->tvr_Op.DrawBuffer.Window; xywh = req->tvr_Op.DrawBuffer.RRect; break; case TVCMD_COPYAREA: { v = req->tvr_Op.CopyArea.Window; TINT *s = req->tvr_Op.CopyArea.Rect; TINT dx0 = req->tvr_Op.CopyArea.DestX; TINT dy0 = req->tvr_Op.CopyArea.DestY; TINT sx0 = s[0]; TINT sy0 = s[1]; TINT sx1 = s[0] + s[2] - 1; TINT sy1 = s[1] + s[3] - 1; TINT dx = dx0 - sx0; TINT dy = dy0 - sy0; TINT dx1 = sx1 + dx; TINT dy1 = sy1 + dy; rect = temprect; if (source_affect) { rect[0] = TMIN(sx0, dx0); rect[1] = TMIN(sy0, dy0); rect[2] = TMAX(sx1, dx1); rect[3] = TMAX(sy1, dy1); break; } rect[0] = dx0; rect[1] = dy0; rect[2] = dx1; rect[3] = dy1; break; } case TVCMD_PLOT: v = req->tvr_Op.Plot.Window; rect = temprect; rect[0] = req->tvr_Op.Plot.Rect[0]; rect[1] = req->tvr_Op.Plot.Rect[1]; rect[2] = req->tvr_Op.Plot.Rect[0]; rect[3] = req->tvr_Op.Plot.Rect[1]; break; } if (v->rfbw_ClipRect.r[0] == -1) return 0; if (xywh) { rect = temprect; rect[0] = xywh[0]; rect[1] = xywh[1]; rect[2] = xywh[0] + xywh[2] - 1; rect[3] = xywh[1] + xywh[3] - 1; } if (rect) { result[0] = rect[0] + v->rfbw_WinRect.r[0]; result[1] = rect[1] + v->rfbw_WinRect.r[1]; result[2] = rect[2] + v->rfbw_WinRect.r[0]; result[3] = rect[3] + v->rfbw_WinRect.r[1]; } else memcpy(result, v->rfbw_WinRect.r, 16); return region_intersect(result, v->rfbw_ClipRect.r); }