Initial commit - from Precise source
[freerdp-ubuntu-pcb-backport.git] / include / freerdp / graphics.h
1 /**
2  * FreeRDP: A Remote Desktop Protocol Client
3  * Graphical Objects
4  *
5  * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6  *
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
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
20 #ifndef __GRAPHICS_H
21 #define __GRAPHICS_H
22
23 typedef struct rdp_bitmap rdpBitmap;
24 typedef struct rdp_pointer rdpPointer;
25 typedef struct rdp_glyph rdpGlyph;
26
27 #include <stdlib.h>
28 #include <freerdp/api.h>
29 #include <freerdp/types.h>
30 #include <freerdp/freerdp.h>
31
32 /* Bitmap Class */
33
34 typedef void (*pBitmap_New)(rdpContext* context, rdpBitmap* bitmap);
35 typedef void (*pBitmap_Free)(rdpContext* context, rdpBitmap* bitmap);
36 typedef void (*pBitmap_Paint)(rdpContext* context, rdpBitmap* bitmap);
37 typedef void (*pBitmap_Decompress)(rdpContext* context, rdpBitmap* bitmap,
38                 uint8* data, int width, int height, int bpp, int length, boolean compressed);
39 typedef void (*pBitmap_SetSurface)(rdpContext* context, rdpBitmap* bitmap, boolean primary);
40
41 struct rdp_bitmap
42 {
43         size_t size; /* 0 */
44         pBitmap_New New; /* 1 */
45         pBitmap_Free Free; /* 2 */
46         pBitmap_Paint Paint; /* 3 */
47         pBitmap_Decompress Decompress; /* 4 */
48         pBitmap_SetSurface SetSurface; /* 5 */
49         uint32 paddingA[16 - 6];  /* 6 */
50
51         uint32 left; /* 16 */
52         uint32 top; /* 17 */
53         uint32 right; /* 18 */
54         uint32 bottom; /* 19 */
55         uint32 width; /* 20 */
56         uint32 height; /* 21 */
57         uint32 bpp; /* 22 */
58         uint32 flags; /* 23 */
59         uint32 length; /* 24 */
60         uint8* data; /* 25 */
61         uint32 paddingB[32 - 26]; /* 26 */
62
63         boolean compressed; /* 32 */
64         boolean ephemeral; /* 33 */
65         uint32 paddingC[64 - 34]; /* 34 */
66 };
67
68 FREERDP_API rdpBitmap* Bitmap_Alloc(rdpContext* context);
69 FREERDP_API void Bitmap_New(rdpContext* context, rdpBitmap* bitmap);
70 FREERDP_API void Bitmap_Free(rdpContext* context, rdpBitmap* bitmap);
71 FREERDP_API void Bitmap_Register(rdpContext* context, rdpBitmap* bitmap);
72 FREERDP_API void Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
73                 uint8* data, int width, int height, int bpp, int length, boolean compressed);
74 FREERDP_API void Bitmap_SetRectangle(rdpContext* context, rdpBitmap* bitmap,
75                 uint16 left, uint16 top, uint16 right, uint16 bottom);
76 FREERDP_API void Bitmap_SetDimensions(rdpContext* context, rdpBitmap* bitmap, uint16 width, uint16 height);
77 FREERDP_API void Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, boolean primary);
78
79 /* Pointer Class */
80
81 typedef void (*pPointer_New)(rdpContext* context, rdpPointer* pointer);
82 typedef void (*pPointer_Free)(rdpContext* context, rdpPointer* pointer);
83 typedef void (*pPointer_Set)(rdpContext* context, rdpPointer* pointer);
84
85 struct rdp_pointer
86 {
87         size_t size; /* 0 */
88         pPointer_New New; /* 1 */
89         pPointer_Free Free; /* 2 */
90         pPointer_Set Set; /* 3 */
91         uint32 paddingA[16 - 4]; /* 4 */
92
93         uint32 xPos; /* 16 */
94         uint32 yPos; /* 17 */
95         uint32 width; /* 18 */
96         uint32 height; /* 19 */
97         uint32 xorBpp; /* 20 */
98         uint32 lengthAndMask; /* 21 */
99         uint32 lengthXorMask; /* 22 */
100         uint8* xorMaskData; /* 23 */
101         uint8* andMaskData; /* 24 */
102         uint32 paddingB[32 - 25]; /* 25 */
103 };
104
105 FREERDP_API rdpPointer* Pointer_Alloc(rdpContext* context);
106 FREERDP_API void Pointer_New(rdpContext* context, rdpPointer* pointer);
107 FREERDP_API void Pointer_Free(rdpContext* context, rdpPointer* pointer);
108 FREERDP_API void Pointer_Set(rdpContext* context, rdpPointer* pointer);
109
110 /* Glyph Class */
111
112 typedef void (*pGlyph_New)(rdpContext* context, rdpGlyph* glyph);
113 typedef void (*pGlyph_Free)(rdpContext* context, rdpGlyph* glyph);
114 typedef void (*pGlyph_Draw)(rdpContext* context, rdpGlyph* glyph, int x, int y);
115 typedef void (*pGlyph_BeginDraw)(rdpContext* context, int x, int y, int width, int height, uint32 bgcolor, uint32 fgcolor);
116 typedef void (*pGlyph_EndDraw)(rdpContext* context, int x, int y, int width, int height, uint32 bgcolor, uint32 fgcolor);
117
118 struct rdp_glyph
119 {
120         size_t size; /* 0 */
121         pGlyph_New New; /* 1 */
122         pGlyph_Free Free; /* 2 */
123         pGlyph_Draw Draw; /* 3 */
124         pGlyph_BeginDraw BeginDraw; /* 4 */
125         pGlyph_EndDraw EndDraw; /* 5 */
126         uint32 paddingA[16 - 6]; /* 6 */
127
128         sint32 x; /* 16 */
129         sint32 y; /* 17 */
130         uint32 cx; /* 18 */
131         uint32 cy; /* 19 */
132         uint32 cb; /* 20 */
133         uint8* aj; /* 21 */
134         uint32 paddingB[32 - 22]; /* 22 */
135 };
136
137 FREERDP_API rdpGlyph* Glyph_Alloc(rdpContext* context);
138 FREERDP_API void Glyph_New(rdpContext* context, rdpGlyph* glyph);
139 FREERDP_API void Glyph_Free(rdpContext* context, rdpGlyph* glyph);
140 FREERDP_API void Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y);
141 FREERDP_API void Glyph_BeginDraw(rdpContext* context, int x, int y, int width, int height, uint32 bgcolor, uint32 fgcolor);
142 FREERDP_API void Glyph_EndDraw(rdpContext* context, int x, int y, int width, int height, uint32 bgcolor, uint32 fgcolor);
143
144 /* Graphics Module */
145
146 struct rdp_graphics
147 {
148         rdpContext* context; /* 0 */
149         rdpBitmap* Bitmap_Prototype; /* 1 */
150         rdpPointer* Pointer_Prototype; /* 2 */
151         rdpGlyph* Glyph_Prototype; /* 3 */
152         uint32 paddingA[16 - 4]; /* 4 */
153 };
154
155 FREERDP_API void graphics_register_bitmap(rdpGraphics* graphics, rdpBitmap* bitmap);
156 FREERDP_API void graphics_register_pointer(rdpGraphics* graphics, rdpPointer* pointer);
157 FREERDP_API void graphics_register_glyph(rdpGraphics* graphics, rdpGlyph* glyph);
158
159 FREERDP_API rdpGraphics* graphics_new(rdpContext* context);
160 FREERDP_API void graphics_free(rdpGraphics* graphics);
161
162 #endif /* __GRAPHICS_H */