1 /**
2  * FreeRDP: A Remote Desktop Protocol Implementation
3  * Secondary Drawing Orders Interface API
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 FREERDP_UPDATE_SECONDARY_H
21 #define FREERDP_UPDATE_SECONDARY_H
22 
23 #include <freerdp/types.h>
24 #include <freerdp/primary.h>
25 
26 #define GLYPH_FRAGMENT_NOP 0x00
27 #define GLYPH_FRAGMENT_USE 0xFE
28 #define GLYPH_FRAGMENT_ADD 0xFF
29 
30 #define CBR2_HEIGHT_SAME_AS_WIDTH 0x01
31 #define CBR2_PERSISTENT_KEY_PRESENT 0x02
32 #define CBR2_NO_BITMAP_COMPRESSION_HDR 0x08
33 #define CBR2_DO_NOT_CACHE 0x10
34 
35 #define SCREEN_BITMAP_SURFACE 0xFFFF
36 #define BITMAP_CACHE_WAITING_LIST_INDEX 0x7FFF
37 
38 #define CACHED_BRUSH 0x80
39 
40 #define BMF_1BPP 0x1
41 #define BMF_8BPP 0x3
42 #define BMF_16BPP 0x4
43 #define BMF_24BPP 0x5
44 #define BMF_32BPP 0x6
45 
46 #ifndef _WIN32
47 #define BS_SOLID 0x00
48 #define BS_NULL 0x01
49 #define BS_HATCHED 0x02
50 #define BS_PATTERN 0x03
51 #endif
52 
53 #ifndef _WIN32
54 #define HS_HORIZONTAL 0x00
55 #define HS_VERTICAL 0x01
56 #define HS_FDIAGONAL 0x02
57 #define HS_BDIAGONAL 0x03
58 #define HS_CROSS 0x04
59 #define HS_DIAGCROSS 0x05
60 #endif
61 
62 #define SO_FLAG_DEFAULT_PLACEMENT 0x01
63 #define SO_HORIZONTAL 0x02
64 #define SO_VERTICAL 0x04
65 #define SO_REVERSED 0x08
66 #define SO_ZERO_BEARINGS 0x10
67 #define SO_CHAR_INC_EQUAL_BM_BASE 0x20
68 #define SO_MAXEXT_EQUAL_BM_SIDE 0x40
69 
70 struct _CACHE_BITMAP_ORDER
71 {
72 	UINT32 cacheId;
73 	UINT32 bitmapBpp;
74 	UINT32 bitmapWidth;
75 	UINT32 bitmapHeight;
76 	UINT32 bitmapLength;
77 	UINT32 cacheIndex;
78 	BOOL compressed;
79 	BYTE bitmapComprHdr[8];
80 	BYTE* bitmapDataStream;
81 };
82 typedef struct _CACHE_BITMAP_ORDER CACHE_BITMAP_ORDER;
83 
84 struct _CACHE_BITMAP_V2_ORDER
85 {
86 	UINT32 cacheId;
87 	UINT32 flags;
88 	UINT32 key1;
89 	UINT32 key2;
90 	UINT32 bitmapBpp;
91 	UINT32 bitmapWidth;
92 	UINT32 bitmapHeight;
93 	UINT32 bitmapLength;
94 	UINT32 cacheIndex;
95 	BOOL compressed;
96 	UINT32 cbCompFirstRowSize;
97 	UINT32 cbCompMainBodySize;
98 	UINT32 cbScanWidth;
99 	UINT32 cbUncompressedSize;
100 	BYTE* bitmapDataStream;
101 };
102 typedef struct _CACHE_BITMAP_V2_ORDER CACHE_BITMAP_V2_ORDER;
103 
104 struct _BITMAP_DATA_EX
105 {
106 	UINT32 bpp;
107 	UINT32 codecID;
108 	UINT32 width;
109 	UINT32 height;
110 	UINT32 length;
111 	BYTE* data;
112 };
113 typedef struct _BITMAP_DATA_EX BITMAP_DATA_EX;
114 
115 struct _CACHE_BITMAP_V3_ORDER
116 {
117 	UINT32 cacheId;
118 	UINT32 bpp;
119 	UINT32 flags;
120 	UINT32 cacheIndex;
121 	UINT32 key1;
122 	UINT32 key2;
123 	BITMAP_DATA_EX bitmapData;
124 };
125 typedef struct _CACHE_BITMAP_V3_ORDER CACHE_BITMAP_V3_ORDER;
126 
127 struct _CACHE_COLOR_TABLE_ORDER
128 {
129 	UINT32 cacheIndex;
130 	UINT32 numberColors;
131 	UINT32 colorTable[256];
132 };
133 typedef struct _CACHE_COLOR_TABLE_ORDER CACHE_COLOR_TABLE_ORDER;
134 
135 struct _CACHE_GLYPH_ORDER
136 {
137 	UINT32 cacheId;
138 	UINT32 cGlyphs;
139 	GLYPH_DATA glyphData[256];
140 	WCHAR* unicodeCharacters;
141 };
142 typedef struct _CACHE_GLYPH_ORDER CACHE_GLYPH_ORDER;
143 
144 struct _CACHE_GLYPH_V2_ORDER
145 {
146 	UINT32 cacheId;
147 	UINT32 flags;
148 	UINT32 cGlyphs;
149 	GLYPH_DATA_V2 glyphData[256];
150 	WCHAR* unicodeCharacters;
151 };
152 typedef struct _CACHE_GLYPH_V2_ORDER CACHE_GLYPH_V2_ORDER;
153 
154 struct _CACHE_BRUSH_ORDER
155 {
156 	UINT32 index;
157 	UINT32 bpp;
158 	UINT32 cx;
159 	UINT32 cy;
160 	UINT32 style;
161 	UINT32 length;
162 	BYTE data[256];
163 };
164 typedef struct _CACHE_BRUSH_ORDER CACHE_BRUSH_ORDER;
165 
166 typedef BOOL (*pCacheBitmap)(rdpContext* context, const CACHE_BITMAP_ORDER* cache_bitmap_order);
167 typedef BOOL (*pCacheBitmapV2)(rdpContext* context, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_order);
168 typedef BOOL (*pCacheBitmapV3)(rdpContext* context, CACHE_BITMAP_V3_ORDER* cache_bitmap_v3_order);
169 typedef BOOL (*pCacheColorTable)(rdpContext* context,
170                                  const CACHE_COLOR_TABLE_ORDER* cache_color_table_order);
171 typedef BOOL (*pCacheGlyph)(rdpContext* context, const CACHE_GLYPH_ORDER* cache_glyph_order);
172 typedef BOOL (*pCacheGlyphV2)(rdpContext* context,
173                               const CACHE_GLYPH_V2_ORDER* cache_glyph_v2_order);
174 typedef BOOL (*pCacheBrush)(rdpContext* context, const CACHE_BRUSH_ORDER* cache_brush_order);
175 typedef BOOL (*pCacheOrderInfo)(rdpContext* context, UINT16 orderLength, UINT16 extraFlags,
176                                 UINT8 orderType, const char* orderName);
177 
178 struct rdp_secondary_update
179 {
180 	rdpContext* context;     /* 0 */
181 	UINT32 paddingA[16 - 1]; /* 1 */
182 
183 	pCacheBitmap CacheBitmap;         /* 16 */
184 	pCacheBitmapV2 CacheBitmapV2;     /* 17 */
185 	pCacheBitmapV3 CacheBitmapV3;     /* 18 */
186 	pCacheColorTable CacheColorTable; /* 19 */
187 	pCacheGlyph CacheGlyph;           /* 20 */
188 	pCacheGlyphV2 CacheGlyphV2;       /* 21 */
189 	pCacheBrush CacheBrush;           /* 22 */
190 	/* Statistics callback */
191 	pCacheOrderInfo CacheOrderInfo; /* 23 */
192 	UINT32 paddingE[32 - 24];       /* 24 */
193 
194 	/* internal */
195 
196 	BOOL glyph_v2;
197 };
198 typedef struct rdp_secondary_update rdpSecondaryUpdate;
199 
200 #endif /* FREERDP_UPDATE_SECONDARY_H */
201