int gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h) { GDI_RECT inv; GDI_RECT rgn; HGDI_RGN invalid; HGDI_BITMAP bmp; if (hdc->hwnd == NULL) return 0; if (hdc->hwnd->invalid == NULL) return 0; invalid = hdc->hwnd->invalid; bmp = (HGDI_BITMAP) hdc->selectedObject; if (invalid->null) { invalid->x = x; invalid->y = y; invalid->w = w; invalid->h = h; invalid->null = 0; return 0; } gdi_CRgnToRect(x, y, w, h, &rgn); gdi_RgnToRect(invalid, &inv); if (rgn.left < 0) rgn.left = 0; if (rgn.top < 0) rgn.top = 0; if (rgn.left < inv.left) inv.left = rgn.left; if (rgn.top < inv.top) inv.top = rgn.top; if (rgn.right > inv.right) inv.right = rgn.right; if (rgn.bottom > inv.bottom) inv.bottom = rgn.bottom; gdi_RectToRgn(&inv, invalid); return 0; }
INLINE BOOL gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h) { GDI_RECT inv; GDI_RECT rgn; HGDI_RGN invalid; HGDI_RGN cinvalid; if (!hdc->hwnd) return TRUE; if (!hdc->hwnd->invalid) return TRUE; if (w == 0 || h == 0) return TRUE; cinvalid = hdc->hwnd->cinvalid; if ((hdc->hwnd->ninvalid + 1) > hdc->hwnd->count) { int new_cnt; HGDI_RGN new_rgn; new_cnt = hdc->hwnd->count * 2; new_rgn = (HGDI_RGN) realloc(cinvalid, sizeof(GDI_RGN) * new_cnt); if (!new_rgn) return FALSE; hdc->hwnd->count = new_cnt; cinvalid = new_rgn; } gdi_SetRgn(&cinvalid[hdc->hwnd->ninvalid++], x, y, w, h); hdc->hwnd->cinvalid = cinvalid; invalid = hdc->hwnd->invalid; if (invalid->null) { invalid->x = x; invalid->y = y; invalid->w = w; invalid->h = h; invalid->null = 0; return TRUE; } gdi_CRgnToRect(x, y, w, h, &rgn); gdi_RgnToRect(invalid, &inv); if (rgn.left < 0) rgn.left = 0; if (rgn.top < 0) rgn.top = 0; if (rgn.left < inv.left) inv.left = rgn.left; if (rgn.top < inv.top) inv.top = rgn.top; if (rgn.right > inv.right) inv.right = rgn.right; if (rgn.bottom > inv.bottom) inv.bottom = rgn.bottom; gdi_RectToRgn(&inv, invalid); return TRUE; }
BOOL gdi_ClipCoords(HGDI_DC hdc, INT32* x, INT32* y, INT32* w, INT32* h, INT32* srcx, INT32* srcy) { GDI_RECT bmp; GDI_RECT clip; GDI_RECT coords; HGDI_BITMAP hBmp; int dx = 0; int dy = 0; BOOL draw = TRUE; if (hdc == NULL) return FALSE; hBmp = (HGDI_BITMAP) hdc->selectedObject; if (hBmp != NULL) { if (hdc->clip->null) { gdi_CRgnToRect(0, 0, hBmp->width, hBmp->height, &clip); } else { gdi_RgnToRect(hdc->clip, &clip); gdi_CRgnToRect(0, 0, hBmp->width, hBmp->height, &bmp); if (clip.left < bmp.left) clip.left = bmp.left; if (clip.right > bmp.right) clip.right = bmp.right; if (clip.top < bmp.top) clip.top = bmp.top; if (clip.bottom > bmp.bottom) clip.bottom = bmp.bottom; } } else { gdi_RgnToRect(hdc->clip, &clip); } gdi_CRgnToRect(*x, *y, *w, *h, &coords); if (coords.right >= clip.left && coords.left <= clip.right && coords.bottom >= clip.top && coords.top <= clip.bottom) { /* coordinates overlap with clipping region */ if (coords.left < clip.left) { dx = (clip.left - coords.left); coords.left = clip.left; } if (coords.right > clip.right) coords.right = clip.right; if (coords.top < clip.top) { dy = (clip.top - coords.top); coords.top = clip.top; } if (coords.bottom > clip.bottom) coords.bottom = clip.bottom; } else { /* coordinates do not overlap with clipping region */ coords.left = 0; coords.right = 0; coords.top = 0; coords.bottom = 0; draw = FALSE; } if (srcx != NULL) *srcx += dx; if (srcy != NULL) *srcy += dy; gdi_RectToCRgn(&coords, x, y, w, h); return draw; }
INLINE int gdi_InvalidateRegion(HGDI_DC hdc, int x, int y, int w, int h) { GDI_RECT inv; GDI_RECT rgn; HGDI_RGN invalid; HGDI_RGN cinvalid; if (hdc->hwnd == NULL) return 0; if (hdc->hwnd->invalid == NULL) return 0; cinvalid = hdc->hwnd->cinvalid; if (hdc->hwnd->ninvalid + 1 > hdc->hwnd->count) { hdc->hwnd->count *= 2; cinvalid = (HGDI_RGN) realloc(cinvalid, sizeof(GDI_RGN) * (hdc->hwnd->count)); } gdi_SetRgn(&cinvalid[hdc->hwnd->ninvalid++], x, y, w, h); hdc->hwnd->cinvalid = cinvalid; invalid = hdc->hwnd->invalid; if (invalid->null) { invalid->x = x; invalid->y = y; invalid->w = w; invalid->h = h; invalid->null = 0; return 0; } gdi_CRgnToRect(x, y, w, h, &rgn); gdi_RgnToRect(invalid, &inv); if (rgn.left < 0) rgn.left = 0; if (rgn.top < 0) rgn.top = 0; if (rgn.left < inv.left) inv.left = rgn.left; if (rgn.top < inv.top) inv.top = rgn.top; if (rgn.right > inv.right) inv.right = rgn.right; if (rgn.bottom > inv.bottom) inv.bottom = rgn.bottom; gdi_RectToRgn(&inv, invalid); return 0; }