22#include <freerdp/config.h>
28#include <freerdp/freerdp.h>
29#include <freerdp/gdi/gdi.h>
31#include <freerdp/gdi/region.h>
35BOOL gdi_SetClipRgn(
HGDI_DC hdc, INT32 nXLeft, INT32 nYLeft, INT32 nWidth, INT32 nHeight)
37 return gdi_SetRgn(hdc->clip, nXLeft, nYLeft, nWidth, nHeight);
59BOOL gdi_SetNullClipRgn(
HGDI_DC hdc)
61 if (!gdi_SetClipRgn(hdc, 0, 0, 0, 0))
63 hdc->clip->null = TRUE;
79BOOL gdi_ClipCoords(
HGDI_DC hdc, INT32* x, INT32* y, INT32* w, INT32* h, INT32* srcx, INT32* srcy)
83 GDI_RECT coords = WINPR_C_ARRAY_INIT;
97 if (!gdi_CRgnToRect(0, 0, hBmp->width, hBmp->height, &clip))
102 if (!gdi_RgnToRect(hdc->clip, &clip))
104 if (!gdi_CRgnToRect(0, 0, hBmp->width, hBmp->height, &bmp))
107 if (clip.left < bmp.left)
108 clip.left = bmp.left;
110 if (clip.right > bmp.right)
111 clip.right = bmp.right;
113 if (clip.top < bmp.top)
116 if (clip.bottom > bmp.bottom)
117 clip.bottom = bmp.bottom;
122 if (!gdi_RgnToRect(hdc->clip, &clip))
126 if (!gdi_CRgnToRect(*x, *y, *w, *h, &coords))
129 if (coords.right >= clip.left && coords.left <= clip.right && coords.bottom >= clip.top &&
130 coords.top <= clip.bottom)
133 if (coords.left < clip.left)
135 dx = (clip.left - coords.left);
136 coords.left = clip.left;
139 if (coords.right > clip.right)
140 coords.right = clip.right;
142 if (coords.top < clip.top)
144 dy = (clip.top - coords.top);
145 coords.top = clip.top;
148 if (coords.bottom > clip.bottom)
149 coords.bottom = clip.bottom;
167 if (!gdi_RectToCRgn(&coords, x, y, w, h))