FreeRDP
include/freerdp/gdi/gdi.h
1 
22 #ifndef FREERDP_GDI_H
23 #define FREERDP_GDI_H
24 
25 #include <winpr/wlog.h>
26 
27 #include <freerdp/api.h>
28 #include <freerdp/types.h>
29 
30 #include <freerdp/log.h>
31 #include <freerdp/types.h>
32 #include <freerdp/codec/color.h>
33 #include <freerdp/codec/region.h>
34 
35 #include <freerdp/client/rdpgfx.h>
36 #include <freerdp/client/geometry.h>
37 #include <freerdp/client/video.h>
38 
39 /* For more information, see [MS-RDPEGDI] */
40 
41 /* Binary Raster Operations (ROP2) */
42 #define GDI_R2_BLACK 0x01 /* D = 0 */
43 #define GDI_R2_NOTMERGEPEN 0x02 /* D = ~(D | P) */
44 #define GDI_R2_MASKNOTPEN 0x03 /* D = D & ~P */
45 #define GDI_R2_NOTCOPYPEN 0x04 /* D = ~P */
46 #define GDI_R2_MASKPENNOT 0x05 /* D = P & ~D */
47 #define GDI_R2_NOT 0x06 /* D = ~D */
48 #define GDI_R2_XORPEN 0x07 /* D = D ^ P */
49 #define GDI_R2_NOTMASKPEN 0x08 /* D = ~(D & P) */
50 #define GDI_R2_MASKPEN 0x09 /* D = D & P */
51 #define GDI_R2_NOTXORPEN 0x0A /* D = ~(D ^ P) */
52 #define GDI_R2_NOP 0x0B /* D = D */
53 #define GDI_R2_MERGENOTPEN 0x0C /* D = D | ~P */
54 #define GDI_R2_COPYPEN 0x0D /* D = P */
55 #define GDI_R2_MERGEPENNOT 0x0E /* D = P | ~D */
56 #define GDI_R2_MERGEPEN 0x0F /* D = P | D */
57 #define GDI_R2_WHITE 0x10 /* D = 1 */
58 
59 /* Ternary Raster Operations (ROP3) */
60 #define GDI_BLACKNESS 0x00000042
61 #define GDI_DPSoon 0x00010289
62 #define GDI_DPSona 0x00020C89
63 #define GDI_PSon 0x000300AA
64 #define GDI_SDPona 0x00040C88
65 #define GDI_DPon 0x000500A9
66 #define GDI_PDSxnon 0x00060865
67 #define GDI_PDSaon 0x000702C5
68 #define GDI_SDPnaa 0x00080F08
69 #define GDI_PDSxon 0x00090245
70 #define GDI_DPna 0x000A0329
71 #define GDI_PSDnaon 0x000B0B2A
72 #define GDI_SPna 0x000C0324
73 #define GDI_PDSnaon 0x000D0B25
74 #define GDI_PDSonon 0x000E08A5
75 #define GDI_Pn 0x000F0001
76 #define GDI_PDSona 0x00100C85
77 #define GDI_NOTSRCERASE 0x001100A6
78 #define GDI_SDPxnon 0x00120868
79 #define GDI_SDPaon 0x001302C8
80 #define GDI_DPSxnon 0x00140869
81 #define GDI_DPSaon 0x001502C9
82 #define GDI_PSDPSanaxx 0x00165CCA
83 #define GDI_SSPxDSxaxn 0x00171D54
84 #define GDI_SPxPDxa 0x00180D59
85 #define GDI_SDPSanaxn 0x00191CC8
86 #define GDI_PDSPaox 0x001A06C5
87 #define GDI_SDPSxaxn 0x001B0768
88 #define GDI_PSDPaox 0x001C06CA
89 #define GDI_DSPDxaxn 0x001D0766
90 #define GDI_PDSox 0x001E01A5
91 #define GDI_PDSoan 0x001F0385
92 #define GDI_DPSnaa 0x00200F09
93 #define GDI_SDPxon 0x00210248
94 #define GDI_DSna 0x00220326
95 #define GDI_SPDnaon 0x00230B24
96 #define GDI_SPxDSxa 0x00240D55
97 #define GDI_PDSPanaxn 0x00251CC5
98 #define GDI_SDPSaox 0x002606C8
99 #define GDI_SDPSxnox 0x00271868
100 #define GDI_DPSxa 0x00280369
101 #define GDI_PSDPSaoxxn 0x002916CA
102 #define GDI_DPSana 0x002A0CC9
103 #define GDI_SSPxPDxaxn 0x002B1D58
104 #define GDI_SPDSoax 0x002C0784
105 #define GDI_PSDnox 0x002D060A
106 #define GDI_PSDPxox 0x002E064A
107 #define GDI_PSDnoan 0x002F0E2A
108 #define GDI_PSna 0x0030032A
109 #define GDI_SDPnaon 0x00310B28
110 #define GDI_SDPSoox 0x00320688
111 #define GDI_NOTSRCCOPY 0x00330008
112 #define GDI_SPDSaox 0x003406C4
113 #define GDI_SPDSxnox 0x00351864
114 #define GDI_SDPox 0x003601A8
115 #define GDI_SDPoan 0x00370388
116 #define GDI_PSDPoax 0x0038078A
117 #define GDI_SPDnox 0x00390604
118 #define GDI_SPDSxox 0x003A0644
119 #define GDI_SPDnoan 0x003B0E24
120 #define GDI_PSx 0x003C004A
121 #define GDI_SPDSonox 0x003D18A4
122 #define GDI_SPDSnaox 0x003E1B24
123 #define GDI_PSan 0x003F00EA
124 #define GDI_PSDnaa 0x00400F0A
125 #define GDI_DPSxon 0x00410249
126 #define GDI_SDxPDxa 0x00420D5D
127 #define GDI_SPDSanaxn 0x00431CC4
128 #define GDI_SRCERASE 0x00440328
129 #define GDI_DPSnaon 0x00450B29
130 #define GDI_DSPDaox 0x004606C6
131 #define GDI_PSDPxaxn 0x0047076A
132 #define GDI_SDPxa 0x00480368
133 #define GDI_PDSPDaoxxn 0x004916C5
134 #define GDI_DPSDoax 0x004A0789
135 #define GDI_PDSnox 0x004B0605
136 #define GDI_SDPana 0x004C0CC8
137 #define GDI_SSPxDSxoxn 0x004D1954
138 #define GDI_PDSPxox 0x004E0645
139 #define GDI_PDSnoan 0x004F0E25
140 #define GDI_PDna 0x00500325
141 #define GDI_DSPnaon 0x00510B26
142 #define GDI_DPSDaox 0x005206C9
143 #define GDI_SPDSxaxn 0x00530764
144 #define GDI_DPSonon 0x005408A9
145 #define GDI_DSTINVERT 0x00550009
146 #define GDI_DPSox 0x005601A9
147 #define GDI_DPSoan 0x00570389
148 #define GDI_PDSPoax 0x00580785
149 #define GDI_DPSnox 0x00590609
150 #define GDI_PATINVERT 0x005A0049
151 #define GDI_DPSDonox 0x005B18A9
152 #define GDI_DPSDxox 0x005C0649
153 #define GDI_DPSnoan 0x005D0E29
154 #define GDI_DPSDnaox 0x005E1B29
155 #define GDI_DPan 0x005F00E9
156 #define GDI_PDSxa 0x00600365
157 #define GDI_DSPDSaoxxn 0x006116C6
158 #define GDI_DSPDoax 0x00620786
159 #define GDI_SDPnox 0x00630608
160 #define GDI_SDPSoax 0x00640788
161 #define GDI_DSPnox 0x00650606
162 #define GDI_SRCINVERT 0x00660046
163 #define GDI_SDPSonox 0x006718A8
164 #define GDI_DSPDSonoxxn 0x006858A6
165 #define GDI_PDSxxn 0x00690145
166 #define GDI_DPSax 0x006A01E9
167 #define GDI_PSDPSoaxxn 0x006B178A
168 #define GDI_SDPax 0x006C01E8
169 #define GDI_PDSPDoaxxn 0x006D1785
170 #define GDI_SDPSnoax 0x006E1E28
171 #define GDI_PDSxnan 0x006F0C65
172 #define GDI_PDSana 0x00700CC5
173 #define GDI_SSDxPDxaxn 0x00711D5C
174 #define GDI_SDPSxox 0x00720648
175 #define GDI_SDPnoan 0x00730E28
176 #define GDI_DSPDxox 0x00740646
177 #define GDI_DSPnoan 0x00750E26
178 #define GDI_SDPSnaox 0x00761B28
179 #define GDI_DSan 0x007700E6
180 #define GDI_PDSax 0x007801E5
181 #define GDI_DSPDSoaxxn 0x00791786
182 #define GDI_DPSDnoax 0x007A1E29
183 #define GDI_SDPxnan 0x007B0C68
184 #define GDI_SPDSnoax 0x007C1E24
185 #define GDI_DPSxnan 0x007D0C69
186 #define GDI_SPxDSxo 0x007E0955
187 #define GDI_DPSaan 0x007F03C9
188 #define GDI_DPSaa 0x008003E9
189 #define GDI_SPxDSxon 0x00810975
190 #define GDI_DPSxna 0x00820C49
191 #define GDI_SPDSnoaxn 0x00831E04
192 #define GDI_SDPxna 0x00840C48
193 #define GDI_PDSPnoaxn 0x00851E05
194 #define GDI_DSPDSoaxx 0x008617A6
195 #define GDI_PDSaxn 0x008701C5
196 #define GDI_SRCAND 0x008800C6
197 #define GDI_SDPSnaoxn 0x00891B08
198 #define GDI_DSPnoa 0x008A0E06
199 #define GDI_DSPDxoxn 0x008B0666
200 #define GDI_SDPnoa 0x008C0E08
201 #define GDI_SDPSxoxn 0x008D0668
202 #define GDI_SSDxPDxax 0x008E1D7C
203 #define GDI_PDSanan 0x008F0CE5
204 #define GDI_PDSxna 0x00900C45
205 #define GDI_SDPSnoaxn 0x00911E08
206 #define GDI_DPSDPoaxx 0x009217A9
207 #define GDI_SPDaxn 0x009301C4
208 #define GDI_PSDPSoaxx 0x009417AA
209 #define GDI_DPSaxn 0x009501C9
210 #define GDI_DPSxx 0x00960169
211 #define GDI_PSDPSonoxx 0x0097588A
212 #define GDI_SDPSonoxn 0x00981888
213 #define GDI_DSxn 0x00990066
214 #define GDI_DPSnax 0x009A0709
215 #define GDI_SDPSoaxn 0x009B07A8
216 #define GDI_SPDnax 0x009C0704
217 #define GDI_DSPDoaxn 0x009D07A6
218 #define GDI_DSPDSaoxx 0x009E16E6
219 #define GDI_PDSxan 0x009F0345
220 #define GDI_DPa 0x00A000C9
221 #define GDI_PDSPnaoxn 0x00A11B05
222 #define GDI_DPSnoa 0x00A20E09
223 #define GDI_DPSDxoxn 0x00A30669
224 #define GDI_PDSPonoxn 0x00A41885
225 #define GDI_PDxn 0x00A50065
226 #define GDI_DSPnax 0x00A60706
227 #define GDI_PDSPoaxn 0x00A707A5
228 #define GDI_DPSoa 0x00A803A9
229 #define GDI_DPSoxn 0x00A90189
230 #define GDI_DSTCOPY 0x00AA0029
231 #define GDI_DPSono 0x00AB0889
232 #define GDI_SPDSxax 0x00AC0744
233 #define GDI_DPSDaoxn 0x00AD06E9
234 #define GDI_DSPnao 0x00AE0B06
235 #define GDI_DPno 0x00AF0229
236 #define GDI_PDSnoa 0x00B00E05
237 #define GDI_PDSPxoxn 0x00B10665
238 #define GDI_SSPxDSxox 0x00B21974
239 #define GDI_SDPanan 0x00B30CE8
240 #define GDI_PSDnax 0x00B4070A
241 #define GDI_DPSDoaxn 0x00B507A9
242 #define GDI_DPSDPaoxx 0x00B616E9
243 #define GDI_SDPxan 0x00B70348
244 #define GDI_PSDPxax 0x00B8074A
245 #define GDI_DSPDaoxn 0x00B906E6
246 #define GDI_DPSnao 0x00BA0B09
247 #define GDI_MERGEPAINT 0x00BB0226
248 #define GDI_SPDSanax 0x00BC1CE4
249 #define GDI_SDxPDxan 0x00BD0D7D
250 #define GDI_DPSxo 0x00BE0269
251 #define GDI_DPSano 0x00BF08C9
252 #define GDI_MERGECOPY 0x00C000CA
253 #define GDI_SPDSnaoxn 0x00C11B04
254 #define GDI_SPDSonoxn 0x00C21884
255 #define GDI_PSxn 0x00C3006A
256 #define GDI_SPDnoa 0x00C40E04
257 #define GDI_SPDSxoxn 0x00C50664
258 #define GDI_SDPnax 0x00C60708
259 #define GDI_PSDPoaxn 0x00C707AA
260 #define GDI_SDPoa 0x00C803A8
261 #define GDI_SPDoxn 0x00C90184
262 #define GDI_DPSDxax 0x00CA0749
263 #define GDI_SPDSaoxn 0x00CB06E4
264 #define GDI_SRCCOPY 0x00CC0020
265 #define GDI_SDPono 0x00CD0888
266 #define GDI_SDPnao 0x00CE0B08
267 #define GDI_SPno 0x00CF0224
268 #define GDI_PSDnoa 0x00D00E0A
269 #define GDI_PSDPxoxn 0x00D1066A
270 #define GDI_PDSnax 0x00D20705
271 #define GDI_SPDSoaxn 0x00D307A4
272 #define GDI_SSPxPDxax 0x00D41D78
273 #define GDI_DPSanan 0x00D50CE9
274 #define GDI_PSDPSaoxx 0x00D616EA
275 #define GDI_DPSxan 0x00D70349
276 #define GDI_PDSPxax 0x00D80745
277 #define GDI_SDPSaoxn 0x00D906E8
278 #define GDI_DPSDanax 0x00DA1CE9
279 #define GDI_SPxDSxan 0x00DB0D75
280 #define GDI_SPDnao 0x00DC0B04
281 #define GDI_SDno 0x00DD0228
282 #define GDI_SDPxo 0x00DE0268
283 #define GDI_SDPano 0x00DF08C8
284 #define GDI_PDSoa 0x00E003A5
285 #define GDI_PDSoxn 0x00E10185
286 #define GDI_DSPDxax 0x00E20746
287 #define GDI_PSDPaoxn 0x00E306EA
288 #define GDI_SDPSxax 0x00E40748
289 #define GDI_PDSPaoxn 0x00E506E5
290 #define GDI_SDPSanax 0x00E61CE8
291 #define GDI_SPxPDxan 0x00E70D79
292 #define GDI_SSPxDSxax 0x00E81D74
293 #define GDI_DSPDSanaxxn 0x00E95CE6
294 #define GDI_DPSao 0x00EA02E9
295 #define GDI_DPSxno 0x00EB0849
296 #define GDI_SDPao 0x00EC02E8
297 #define GDI_SDPxno 0x00ED0848
298 #define GDI_SRCPAINT 0x00EE0086
299 #define GDI_SDPnoo 0x00EF0A08
300 #define GDI_PATCOPY 0x00F00021
301 #define GDI_PDSono 0x00F10885
302 #define GDI_PDSnao 0x00F20B05
303 #define GDI_PSno 0x00F3022A
304 #define GDI_PSDnao 0x00F40B0A
305 #define GDI_PDno 0x00F50225
306 #define GDI_PDSxo 0x00F60265
307 #define GDI_PDSano 0x00F708C5
308 #define GDI_PDSao 0x00F802E5
309 #define GDI_PDSxno 0x00F90845
310 #define GDI_DPo 0x00FA0089
311 #define GDI_PATPAINT 0x00FB0A09
312 #define GDI_PSo 0x00FC008A
313 #define GDI_PSDnoo 0x00FD0A0A
314 #define GDI_DPSoo 0x00FE02A9
315 #define GDI_WHITENESS 0x00FF0062
316 #define GDI_GLYPH_ORDER 0xFFFFFFFF
317 
318 /* Brush Styles */
319 #define GDI_BS_SOLID 0x00
320 #define GDI_BS_NULL 0x01
321 #define GDI_BS_HATCHED 0x02
322 #define GDI_BS_PATTERN 0x03
323 
324 /* Hatch Patterns */
325 #define GDI_HS_HORIZONTAL 0x00
326 #define GDI_HS_VERTICAL 0x01
327 #define GDI_HS_FDIAGONAL 0x02
328 #define GDI_HS_BDIAGONAL 0x03
329 #define GDI_HS_CROSS 0x04
330 #define GDI_HS_DIAGCROSS 0x05
331 
332 /* Pen Styles */
333 #define GDI_PS_SOLID 0x00
334 #define GDI_PS_DASH 0x01
335 #define GDI_PS_NULL 0x05
336 
337 /* Background Modes */
338 #define GDI_OPAQUE 0x00000001
339 #define GDI_TRANSPARENT 0x00000002
340 
341 /* Fill Modes */
342 #define GDI_FILL_ALTERNATE 0x01
343 #define GDI_FILL_WINDING 0x02
344 
345 /* GDI Object Types */
346 #define GDIOBJECT_BITMAP 0x00
347 #define GDIOBJECT_PEN 0x01
348 #define GDIOBJECT_PALETTE 0x02
349 #define GDIOBJECT_BRUSH 0x03
350 #define GDIOBJECT_RECT 0x04
351 #define GDIOBJECT_REGION 0x05
352 
353 /* Region return values */
354 #ifndef NULLREGION
355 #define NULLREGION 0x01
356 #define SIMPLEREGION 0x02
357 #define COMPLEXREGION 0x03
358 #endif
359 
360 #ifdef __cplusplus
361 extern "C"
362 {
363 #endif
364 
365  typedef struct
366  {
367  BYTE objectType;
368  } GDIOBJECT;
369  typedef GDIOBJECT* HGDIOBJECT;
370 
371  typedef struct
372  {
373  BYTE objectType;
374  INT32 left;
375  INT32 top;
376  INT32 right;
377  INT32 bottom;
378  } GDI_RECT;
379  typedef GDI_RECT* HGDI_RECT;
380 
381  typedef struct
382  {
383  BYTE objectType;
384  INT32 x; /* left */
385  INT32 y; /* top */
386  INT32 w; /* width */
387  INT32 h; /* height */
388  BOOL null; /* null region */
389  } GDI_RGN;
390  typedef GDI_RGN* HGDI_RGN;
391 
392  typedef struct
393  {
394  BYTE objectType;
395  UINT32 format;
396  INT32 width;
397  INT32 height;
398  UINT32 scanline;
399  BYTE* data;
400  void (*free)(void*);
401  } GDI_BITMAP;
402  typedef GDI_BITMAP* HGDI_BITMAP;
403 
404  typedef struct
405  {
406  BYTE objectType;
407  UINT32 style;
408  INT32 width;
409  INT32 posX;
410  INT32 posY;
411  UINT32 color;
412  UINT32 format;
413  const gdiPalette* palette;
414  } GDI_PEN;
415  typedef GDI_PEN* HGDI_PEN;
416 
417  typedef struct
418  {
419  BYTE red;
420  BYTE green;
421  BYTE blue;
423 
424  typedef struct
425  {
426  UINT16 count;
427  GDI_PALETTEENTRY* entries;
428  } GDI_PALETTE;
429  typedef GDI_PALETTE* HGDI_PALETTE;
430 
431  typedef struct
432  {
433  INT32 x;
434  INT32 y;
435  } GDI_POINT;
436  typedef GDI_POINT* HGDI_POINT;
437 
438  typedef struct
439  {
440  BYTE objectType;
441  int style;
442  HGDI_BITMAP pattern;
443  UINT32 color;
444  INT32 nXOrg;
445  INT32 nYOrg;
446  } GDI_BRUSH;
447  typedef GDI_BRUSH* HGDI_BRUSH;
448 
449  typedef struct
450  {
451  UINT32 count;
452  INT32 ninvalid;
453  HGDI_RGN invalid;
454  HGDI_RGN cinvalid;
455  } GDI_WND;
456  typedef GDI_WND* HGDI_WND;
457 
458  typedef struct
459  {
460  HGDIOBJECT selectedObject;
461  UINT32 format;
462  UINT32 bkColor;
463  UINT32 textColor;
464  HGDI_BRUSH brush;
465  HGDI_RGN clip;
466  HGDI_PEN pen;
467  HGDI_WND hwnd;
468  INT32 drawMode;
469  INT32 bkMode;
470  } GDI_DC;
471  typedef GDI_DC* HGDI_DC;
472 
473  struct gdi_bitmap
474  {
475  rdpBitmap _p;
476 
477  HGDI_DC hdc;
478  HGDI_BITMAP bitmap;
479  HGDI_BITMAP org_bitmap;
480  };
481  typedef struct gdi_bitmap gdiBitmap;
482 
483  struct gdi_glyph
484  {
485  rdpBitmap _p;
486 
487  HGDI_DC hdc;
488  HGDI_BITMAP bitmap;
489  HGDI_BITMAP org_bitmap;
490  };
491  typedef struct gdi_glyph gdiGlyph;
492 
493  struct rdp_gdi
494  {
495  rdpContext* context;
496 
497  INT32 width;
498  INT32 height;
499  UINT32 stride;
500  UINT32 dstFormat;
501  UINT32 cursor_x;
502  UINT32 cursor_y;
503 
504  HGDI_DC hdc;
505  gdiBitmap* primary;
506  gdiBitmap* drawing;
507  UINT32 bitmap_size;
508  UINT32 bitmap_stride;
509  BYTE* primary_buffer;
510  gdiPalette palette;
511  gdiBitmap* image;
512  void (*free)(void*);
513 
514  BOOL inGfxFrame;
515  BOOL graphicsReset; /* deprecated, remove with FreeRDP v3 */
516  BOOL suppressOutput;
517  UINT16 outputSurfaceId;
518  UINT32 frameId;
519  RdpgfxClientContext* gfx;
520  VideoClientContext* video;
521  GeometryClientContext* geometry;
522 
523  wLog* log;
524  };
525  typedef struct rdp_gdi rdpGdi;
526 
527  FREERDP_API DWORD gdi_rop3_code(BYTE code);
528  FREERDP_API const char* gdi_rop3_code_string(BYTE code);
529  FREERDP_API const char* gdi_rop3_string(DWORD rop);
530 
531  FREERDP_API UINT32 gdi_get_pixel_format(UINT32 bitsPerPixel);
532  FREERDP_API BOOL gdi_decode_color(rdpGdi* gdi, const UINT32 srcColor, UINT32* color,
533  UINT32* format);
534  FREERDP_API BOOL gdi_resize(rdpGdi* gdi, UINT32 width, UINT32 height);
535  FREERDP_API BOOL gdi_resize_ex(rdpGdi* gdi, UINT32 width, UINT32 height, UINT32 stride,
536  UINT32 format, BYTE* buffer, void (*pfree)(void*));
537  FREERDP_API BOOL gdi_init(freerdp* instance, UINT32 format);
538  FREERDP_API BOOL gdi_init_ex(freerdp* instance, UINT32 format, UINT32 stride, BYTE* buffer,
539  void (*pfree)(void*));
540  FREERDP_API void gdi_free(freerdp* instance);
541 
542  FREERDP_API BOOL gdi_send_suppress_output(rdpGdi* gdi, BOOL suppress);
543 
544 #ifdef __cplusplus
545 }
546 #endif
547 
548 #endif /* FREERDP_GDI_H */