INLINE BOOL gdi_CopyOverlap(INT32 x, INT32 y, INT32 width, INT32 height, INT32 srcx, INT32 srcy) { GDI_RECT dst; GDI_RECT src; gdi_CRgnToRect(x, y, width, height, &dst); gdi_CRgnToRect(srcx, srcy, width, height, &src); return (dst.right >= src.left && dst.left <= src.right && dst.bottom >= src.top && dst.top <= src.bottom) ? TRUE : FALSE; }
INLINE int gdi_CopyOverlap(int x, int y, int width, int height, int srcx, int srcy) { GDI_RECT dst; GDI_RECT src; gdi_CRgnToRect(x, y, width, height, &dst); gdi_CRgnToRect(srcx, srcy, width, height, &src); return (dst.right > src.left && dst.left < src.right && dst.bottom > src.top && dst.top < src.bottom) ? 1 : 0; }
static BOOL gdi_multi_opaque_rect(rdpContext* context, const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) { UINT32 i; GDI_RECT rect; HGDI_BRUSH hBrush; UINT32 brush_color; rdpGdi* gdi = context->gdi; BOOL ret = TRUE; if (!gdi_decode_color(gdi, multi_opaque_rect->color, &brush_color, NULL)) return FALSE; hBrush = gdi_CreateSolidBrush(brush_color); if (!hBrush) return FALSE; for (i = 0; i < multi_opaque_rect->numRectangles; i++) { const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i]; gdi_CRgnToRect(rectangle->left, rectangle->top, rectangle->width, rectangle->height, &rect); ret = gdi_FillRect(gdi->drawing->hdc, &rect, hBrush); if (!ret) break; } gdi_DeleteObject((HGDIOBJECT) hBrush); return ret; }
static BOOL gdi_multi_opaque_rect(rdpContext* context, MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) { int i; GDI_RECT rect; HGDI_BRUSH hBrush; UINT32 brush_color; DELTA_RECT* rectangle; rdpGdi* gdi = context->gdi; BOOL ret = TRUE; for (i = 1; i < (int) multi_opaque_rect->numRectangles + 1; i++) { rectangle = &multi_opaque_rect->rectangles[i]; gdi_CRgnToRect(rectangle->left, rectangle->top, rectangle->width, rectangle->height, &rect); brush_color = freerdp_convert_gdi_order_color(multi_opaque_rect->color, gdi->srcBpp, gdi->format, gdi->palette); hBrush = gdi_CreateSolidBrush(brush_color); if (!hBrush) { ret = FALSE; break; } gdi_FillRect(gdi->drawing->hdc, &rect, hBrush); gdi_DeleteObject((HGDIOBJECT) hBrush); } return ret; }
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; }
static void gdi_opaque_rect(rdpContext* context, OPAQUE_RECT_ORDER* opaque_rect) { GDI_RECT rect; HGDI_BRUSH hBrush; UINT32 brush_color; rdpGdi* gdi = context->gdi; gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight, &rect); brush_color = freerdp_convert_gdi_order_color(opaque_rect->color, gdi->srcBpp, gdi->format, gdi->palette); hBrush = gdi_CreateSolidBrush(brush_color); gdi_FillRect(gdi->drawing->hdc, &rect, hBrush); gdi_DeleteObject((HGDIOBJECT) hBrush); }
void gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, uint32 bgcolor, uint32 fgcolor) { GDI_RECT rect; HGDI_BRUSH brush; rdpGdi* gdi = context->gdi; bgcolor = freerdp_color_convert_var_bgr(bgcolor, gdi->srcBpp, 32, gdi->clrconv); fgcolor = freerdp_color_convert_var_bgr(fgcolor, gdi->srcBpp, 32, gdi->clrconv); gdi_CRgnToRect(x, y, width, height, &rect); brush = gdi_CreateSolidBrush(fgcolor); gdi_FillRect(gdi->drawing->hdc, &rect, brush); gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor); }
void gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor, BOOL fOpRedundant) { GDI_RECT rect; HGDI_BRUSH brush; rdpGdi* gdi = context->gdi; /* TODO: handle fOpRedundant! See xf_Glyph_BeginDraw() */ bgcolor = freerdp_convert_gdi_order_color(bgcolor, gdi->srcBpp, gdi->format, gdi->palette); fgcolor = freerdp_convert_gdi_order_color(fgcolor, gdi->srcBpp, gdi->format, gdi->palette); gdi_CRgnToRect(x, y, width, height, &rect); brush = gdi_CreateSolidBrush(fgcolor); gdi_FillRect(gdi->drawing->hdc, &rect, brush); gdi_DeleteObject((HGDIOBJECT) brush); gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor); }
void gdi_Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, UINT32 bgcolor, UINT32 fgcolor) { GDI_RECT rect; HGDI_BRUSH brush; rdpGdi* gdi = context->gdi; bgcolor = freerdp_color_convert_drawing_order_color_to_gdi_color( bgcolor, gdi->srcBpp, gdi->clrconv); fgcolor = freerdp_color_convert_drawing_order_color_to_gdi_color( fgcolor, gdi->srcBpp, gdi->clrconv); gdi_CRgnToRect(x, y, width, height, &rect); brush = gdi_CreateSolidBrush(fgcolor); gdi_FillRect(gdi->drawing->hdc, &rect, brush); gdi_DeleteObject((HGDIOBJECT) brush); gdi->textColor = gdi_SetTextColor(gdi->drawing->hdc, bgcolor); }
static BOOL gdi_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opaque_rect) { GDI_RECT rect; HGDI_BRUSH hBrush; UINT32 brush_color; rdpGdi* gdi = context->gdi; BOOL ret; gdi_CRgnToRect(opaque_rect->nLeftRect, opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight, &rect); if (!gdi_decode_color(gdi, opaque_rect->color, &brush_color, NULL)) return FALSE; if (!(hBrush = gdi_CreateSolidBrush(brush_color))) return FALSE; ret = gdi_FillRect(gdi->drawing->hdc, &rect, hBrush); gdi_DeleteObject((HGDIOBJECT) hBrush); return ret; }
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; }