2 * FreeRDP: A Remote Desktop Protocol Client
5 * Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <freerdp/api.h>
24 #include <freerdp/freerdp.h>
25 #include <freerdp/cache/cache.h>
26 #include <freerdp/utils/debug.h>
27 #include <freerdp/codec/color.h>
29 /* For more information, see [MS-RDPEGDI] */
31 /* Binary Raster Operations (ROP2) */
32 #define GDI_R2_BLACK 0x01 /* D = 0 */
33 #define GDI_R2_NOTMERGEPEN 0x02 /* D = ~(D | P) */
34 #define GDI_R2_MASKNOTPEN 0x03 /* D = D & ~P */
35 #define GDI_R2_NOTCOPYPEN 0x04 /* D = ~P */
36 #define GDI_R2_MASKPENNOT 0x05 /* D = P & ~D */
37 #define GDI_R2_NOT 0x06 /* D = ~D */
38 #define GDI_R2_XORPEN 0x07 /* D = D ^ P */
39 #define GDI_R2_NOTMASKPEN 0x08 /* D = ~(D & P) */
40 #define GDI_R2_MASKPEN 0x09 /* D = D & P */
41 #define GDI_R2_NOTXORPEN 0x0A /* D = ~(D ^ P) */
42 #define GDI_R2_NOP 0x0B /* D = D */
43 #define GDI_R2_MERGENOTPEN 0x0C /* D = D | ~P */
44 #define GDI_R2_COPYPEN 0x0D /* D = P */
45 #define GDI_R2_MERGEPENNOT 0x0E /* D = P | ~D */
46 #define GDI_R2_MERGEPEN 0x0F /* D = P | D */
47 #define GDI_R2_WHITE 0x10 /* D = 1 */
49 /* Ternary Raster Operations (ROP3) */
50 #define GDI_SRCCOPY 0x00CC0020 /* D = S */
51 #define GDI_SRCPAINT 0x00EE0086 /* D = S | D */
52 #define GDI_SRCAND 0x008800C6 /* D = S & D */
53 #define GDI_SRCINVERT 0x00660046 /* D = S ^ D */
54 #define GDI_SRCERASE 0x00440328 /* D = S & ~D */
55 #define GDI_NOTSRCCOPY 0x00330008 /* D = ~S */
56 #define GDI_NOTSRCERASE 0x001100A6 /* D = ~S & ~D */
57 #define GDI_MERGECOPY 0x00C000CA /* D = S & P */
58 #define GDI_MERGEPAINT 0x00BB0226 /* D = ~S | D */
59 #define GDI_PATCOPY 0x00F00021 /* D = P */
60 #define GDI_PATPAINT 0x00FB0A09 /* D = D | (P | ~S) */
61 #define GDI_PATINVERT 0x005A0049 /* D = P ^ D */
62 #define GDI_DSTINVERT 0x00550009 /* D = ~D */
63 #define GDI_BLACKNESS 0x00000042 /* D = 0 */
64 #define GDI_WHITENESS 0x00FF0062 /* D = 1 */
65 #define GDI_DSPDxax 0x00E20746 /* D = (S & P) | (~S & D) */
66 #define GDI_SPna 0x000C0324 /* D = S & ~P */
67 #define GDI_DSna 0x00220326 /* D = D & ~S */
68 #define GDI_PDxn 0x00A50065 /* D = D ^ ~P */
71 #define GDI_BS_SOLID 0x00
72 #define GDI_BS_NULL 0x01
73 #define GDI_BS_HATCHED 0x02
74 #define GDI_BS_PATTERN 0x03
77 #define GDI_HS_HORIZONTAL 0x00
78 #define GDI_HS_VERTICAL 0x01
79 #define GDI_HS_FDIAGONAL 0x02
80 #define GDI_HS_BDIAGONAL 0x03
81 #define GDI_HS_CROSS 0x04
82 #define GDI_HS_DIAGCROSS 0x05
85 #define GDI_PS_SOLID 0x00
86 #define GDI_PS_DASH 0x01
87 #define GDI_PS_NULL 0x05
89 /* Background Modes */
90 #define GDI_OPAQUE 0x00000001
91 #define GDI_TRANSPARENT 0x00000002
93 /* GDI Object Types */
94 #define GDIOBJECT_BITMAP 0x00
95 #define GDIOBJECT_PEN 0x01
96 #define GDIOBJECT_PALETTE 0x02
97 #define GDIOBJECT_BRUSH 0x03
98 #define GDIOBJECT_RECT 0x04
99 #define GDIOBJECT_REGION 0x04
105 typedef struct _GDIOBJECT GDIOBJECT;
106 typedef GDIOBJECT* HGDIOBJECT;
108 /* RGB encoded as 0x00BBGGRR */
109 typedef unsigned int GDI_COLOR;
110 typedef GDI_COLOR* LPGDI_COLOR;
120 typedef struct _GDI_RECT GDI_RECT;
121 typedef GDI_RECT* HGDI_RECT;
130 int null; /* null region */
132 typedef struct _GDI_RGN GDI_RGN;
133 typedef GDI_RGN* HGDI_RGN;
145 typedef struct _GDI_BITMAP GDI_BITMAP;
146 typedef GDI_BITMAP* HGDI_BITMAP;
157 typedef struct _GDI_PEN GDI_PEN;
158 typedef GDI_PEN* HGDI_PEN;
160 struct _GDI_PALETTEENTRY
166 typedef struct _GDI_PALETTEENTRY GDI_PALETTEENTRY;
171 GDI_PALETTEENTRY *entries;
173 typedef struct _GDI_PALETTE GDI_PALETTE;
174 typedef GDI_PALETTE* HGDI_PALETTE;
181 typedef struct _GDI_POINT GDI_POINT;
182 typedef GDI_POINT* HGDI_POINT;
191 typedef struct _GDI_BRUSH GDI_BRUSH;
192 typedef GDI_BRUSH* HGDI_BRUSH;
201 typedef struct _GDI_WND GDI_WND;
202 typedef GDI_WND* HGDI_WND;
206 HGDIOBJECT selectedObject;
221 typedef struct _GDI_DC GDI_DC;
222 typedef GDI_DC* HGDI_DC;
230 HGDI_BITMAP org_bitmap;
232 typedef struct gdi_bitmap gdiBitmap;
240 HGDI_BITMAP org_bitmap;
242 typedef struct gdi_glyph gdiGlyph;
260 uint8* primary_buffer;
268 FREERDP_API uint32 gdi_rop3_code(uint8 code);
269 FREERDP_API uint8* gdi_get_bitmap_pointer(HGDI_DC hdcBmp, int x, int y);
270 FREERDP_API uint8* gdi_get_brush_pointer(HGDI_DC hdcBrush, int x, int y);
271 FREERDP_API int gdi_is_mono_pixel_set(uint8* data, int x, int y, int width);
272 FREERDP_API void gdi_resize(rdpGdi* gdi, int width, int height);
274 FREERDP_API int gdi_init(freerdp* instance, uint32 flags, uint8* buffer);
275 FREERDP_API void gdi_free(freerdp* instance);
277 #ifdef WITH_DEBUG_GDI
278 #define DEBUG_GDI(fmt, ...) DEBUG_CLASS(GDI, fmt, ## __VA_ARGS__)
280 #define DEBUG_GDI(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__)