1 |
/* |
/* |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
Cache routines |
Cache routines |
4 |
Copyright (C) Matthew Chapman 1999-2000 |
Copyright (C) Matthew Chapman 1999-2001 |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
40 |
return bitmap; |
return bitmap; |
41 |
} |
} |
42 |
|
|
43 |
ERROR("get bitmap %d:%d\n", cache_id, cache_idx); |
error("get bitmap %d:%d\n", cache_id, cache_idx); |
44 |
return NULL; |
return NULL; |
45 |
} |
} |
46 |
|
|
61 |
} |
} |
62 |
else |
else |
63 |
{ |
{ |
64 |
ERROR("put bitmap %d:%d\n", cache_id, cache_idx); |
error("put bitmap %d:%d\n", cache_id, cache_idx); |
65 |
} |
} |
66 |
} |
} |
67 |
|
|
83 |
return glyph; |
return glyph; |
84 |
} |
} |
85 |
|
|
86 |
ERROR("get font %d:%d\n", font, character); |
error("get font %d:%d\n", font, character); |
87 |
return NULL; |
return NULL; |
88 |
} |
} |
89 |
|
|
109 |
} |
} |
110 |
else |
else |
111 |
{ |
{ |
112 |
ERROR("put font %d:%d\n", font, character); |
error("put font %d:%d\n", font, character); |
113 |
} |
} |
114 |
} |
} |
115 |
|
|
130 |
return text; |
return text; |
131 |
} |
} |
132 |
|
|
133 |
ERROR("get text %d\n", cache_id); |
error("get text %d\n", cache_id); |
134 |
return NULL; |
return NULL; |
135 |
} |
} |
136 |
|
|
152 |
} |
} |
153 |
else |
else |
154 |
{ |
{ |
155 |
ERROR("put text %d\n", cache_id); |
error("put text %d\n", cache_id); |
156 |
} |
} |
157 |
} |
} |
158 |
|
|
159 |
|
|
160 |
/* DESKTOP CACHE */ |
/* DESKTOP CACHE */ |
161 |
static uint8 deskcache[0x38400]; |
static uint8 deskcache[0x38400 * 4]; |
162 |
|
|
163 |
/* Retrieve desktop data from the cache */ |
/* Retrieve desktop data from the cache */ |
164 |
uint8 * |
uint8 * |
165 |
cache_get_desktop(uint32 offset, int cx, int cy) |
cache_get_desktop(uint32 offset, int cx, int cy, int bytes_per_pixel) |
166 |
{ |
{ |
167 |
int length = cx * cy; |
int length = cx * cy * bytes_per_pixel; |
168 |
|
|
169 |
if ((offset + length) <= sizeof(deskcache)) |
if ((offset + length) <= sizeof(deskcache)) |
170 |
{ |
{ |
171 |
return &deskcache[offset]; |
return &deskcache[offset]; |
172 |
} |
} |
173 |
|
|
174 |
ERROR("get desktop %d:%d\n", offset, length); |
error("get desktop %d:%d\n", offset, length); |
175 |
return NULL; |
return NULL; |
176 |
} |
} |
177 |
|
|
178 |
/* Store desktop data in the cache */ |
/* Store desktop data in the cache */ |
179 |
void |
void |
180 |
cache_put_desktop(uint32 offset, int cx, int cy, int scanline, uint8 *data) |
cache_put_desktop(uint32 offset, int cx, int cy, int scanline, |
181 |
|
int bytes_per_pixel, uint8 * data) |
182 |
{ |
{ |
183 |
int length = cx * cy; |
int length = cx * cy * bytes_per_pixel; |
184 |
|
|
185 |
if ((offset + length) <= sizeof(deskcache)) |
if ((offset + length) <= sizeof(deskcache)) |
186 |
{ |
{ |
187 |
|
cx *= bytes_per_pixel; |
188 |
while (cy--) |
while (cy--) |
189 |
{ |
{ |
190 |
memcpy(&deskcache[offset], data, cx); |
memcpy(&deskcache[offset], data, cx); |
194 |
} |
} |
195 |
else |
else |
196 |
{ |
{ |
197 |
ERROR("put desktop %d:%d\n", offset, length); |
error("put desktop %d:%d\n", offset, length); |
198 |
|
} |
199 |
|
} |
200 |
|
|
201 |
|
|
202 |
|
/* CURSOR CACHE */ |
203 |
|
static HCURSOR cursorcache[0x20]; |
204 |
|
|
205 |
|
/* Retrieve cursor from cache */ |
206 |
|
HCURSOR |
207 |
|
cache_get_cursor(uint16 cache_idx) |
208 |
|
{ |
209 |
|
HCURSOR cursor; |
210 |
|
|
211 |
|
if (cache_idx < NUM_ELEMENTS(cursorcache)) |
212 |
|
{ |
213 |
|
cursor = cursorcache[cache_idx]; |
214 |
|
if (cursor != NULL) |
215 |
|
return cursor; |
216 |
|
} |
217 |
|
|
218 |
|
error("get cursor %d\n", cache_idx); |
219 |
|
return NULL; |
220 |
|
} |
221 |
|
|
222 |
|
/* Store cursor in cache */ |
223 |
|
void |
224 |
|
cache_put_cursor(uint16 cache_idx, HCURSOR cursor) |
225 |
|
{ |
226 |
|
HCURSOR old; |
227 |
|
|
228 |
|
if (cache_idx < NUM_ELEMENTS(cursorcache)) |
229 |
|
{ |
230 |
|
old = cursorcache[cache_idx]; |
231 |
|
if (old != NULL) |
232 |
|
ui_destroy_cursor(old); |
233 |
|
|
234 |
|
cursorcache[cache_idx] = cursor; |
235 |
|
} |
236 |
|
else |
237 |
|
{ |
238 |
|
error("put cursor %d\n", cache_idx); |
239 |
} |
} |
240 |
} |
} |