TLIBAPI TBOOL region_getminmax(struct RectPool *pool, struct Region *region, TINT *minmax) { if (region_isempty(pool, region)) return TFALSE; TINT minx = 1000000; TINT miny = 1000000; TINT maxx = 0; TINT maxy = 0; struct TNode *next, *node = region->rg_Rects.rl_List.tlh_Head; for (; (next = node->tln_Succ); node = next) { struct RectNode *rn = (struct RectNode *) node; minx = TMIN(minx, rn->rn_Rect[0]); miny = TMIN(miny, rn->rn_Rect[1]); maxx = TMAX(maxx, rn->rn_Rect[2]); maxy = TMAX(maxy, rn->rn_Rect[3]); } minmax[0] = minx; minmax[1] = miny; minmax[2] = maxx; minmax[3] = maxy; return TTRUE; }
LOCAL TBOOL rfb_damage(struct rfb_Display *mod, TINT drect[], struct rfb_Window *v) { TAPTR TExecBase = TGetExecBase(mod); struct RectPool *pool = &mod->rfb_RectPool; struct Region A, B; if (!region_init(pool, &A, drect)) return TFALSE; TDBPRINTF(TDB_TRACE, ("incoming damage: %d %d %d %d\n", drect[0], drect[1], drect[2], drect[3])); /* traverse window stack; refresh B where A and B overlap ; A = A - B */ struct TNode *next, *node = mod->rfb_VisualList.tlh_Head.tln_Succ; TBOOL success = TTRUE; TBOOL below = TFALSE; TLock(mod->rfb_InstanceLock); for (; success && !region_isempty(pool, &A) && (next = node->tln_Succ); node = next) { struct rfb_Window *bv = (struct rfb_Window *) node; if (v && !below) { if (bv == v) below = TTRUE; else /* above: subtract current from rect to be damaged: */ success = region_subrect(pool, &A, bv->rfbw_ScreenRect.r); continue; } success = TFALSE; if (region_init(pool, &B, bv->rfbw_ScreenRect.r)) { if (region_andregion(pool, &B, &A)) { region_shift(&B, bv->rfbw_WinRect.r[0] - bv->rfbw_ScreenRect.r[0], bv->rfbw_WinRect.r[1] - bv->rfbw_ScreenRect.r[1]); struct TNode *next, *node = B.rg_Rects.rl_List.tlh_Head.tln_Succ; for (; (next = node->tln_Succ); node = next) { struct RectNode *r = (struct RectNode *) node; if (bv->rfbw_Flags & RFBWFL_BACKBUFFER) { rfb_markdirty(mod, bv, r->rn_Rect); } else if (bv->rfbw_InputMask & TITYPE_REFRESH) { TIMSG *imsg; if (rfb_getimsg(mod, bv, &imsg, TITYPE_REFRESH)) { TDBPRINTF(TDB_TRACE, ("send refresh %d %d %d %d\n", r->rn_Rect[0], r->rn_Rect[1], r->rn_Rect[2], r->rn_Rect[3])); imsg->timsg_X = r->rn_Rect[0]; imsg->timsg_Y = r->rn_Rect[1]; imsg->timsg_Width = r->rn_Rect[2] - r->rn_Rect[0] + 1; imsg->timsg_Height = r->rn_Rect[3] - r->rn_Rect[1] + 1; imsg->timsg_X -= bv->rfbw_ScreenRect.r[0]; imsg->timsg_Y -= bv->rfbw_ScreenRect.r[1]; TPutMsg(bv->rfbw_IMsgPort, TNULL, imsg); } } } success = TTRUE; } region_free(pool, &B); } if (success) success = region_subrect(pool, &A, bv->rfbw_ScreenRect.r); } TUnlock(mod->rfb_InstanceLock); region_free(pool, &A); return success; }