1 |
/* -*- c-basic-offset: 8 -*- |
/* -*- c-basic-offset: 8 -*- |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
Cache routines |
Cache routines |
4 |
Copyright (C) Matthew Chapman 1999-2005 |
Copyright (C) Matthew Chapman 1999-2008 |
5 |
Copyright (C) Jeroen Meijer 2005 |
Copyright (C) Jeroen Meijer 2005 |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
430 |
error("put cursor %d\n", cache_idx); |
error("put cursor %d\n", cache_idx); |
431 |
} |
} |
432 |
} |
} |
433 |
|
|
434 |
|
/* BRUSH CACHE */ |
435 |
|
/* index 0 is 2 colour brush, index 1 is muti colour brush */ |
436 |
|
static BRUSHDATA g_brushcache[2][64]; |
437 |
|
|
438 |
|
/* Retrieve brush from cache */ |
439 |
|
BRUSHDATA * |
440 |
|
cache_get_brush_data(uint8 colour_code, uint8 idx) |
441 |
|
{ |
442 |
|
colour_code = colour_code == 1 ? 0 : 1; |
443 |
|
if (idx < NUM_ELEMENTS(g_brushcache[0])) |
444 |
|
{ |
445 |
|
return &g_brushcache[colour_code][idx]; |
446 |
|
} |
447 |
|
error("get brush %d %d\n", colour_code, idx); |
448 |
|
return NULL; |
449 |
|
} |
450 |
|
|
451 |
|
/* Store brush in cache */ |
452 |
|
/* this function takes over the data pointer in struct, eg, caller gives it up */ |
453 |
|
void |
454 |
|
cache_put_brush_data(uint8 colour_code, uint8 idx, BRUSHDATA * brush_data) |
455 |
|
{ |
456 |
|
BRUSHDATA * bd; |
457 |
|
|
458 |
|
colour_code = colour_code == 1 ? 0 : 1; |
459 |
|
if (idx < NUM_ELEMENTS(g_brushcache[0])) |
460 |
|
{ |
461 |
|
bd = &g_brushcache[colour_code][idx]; |
462 |
|
if (bd->data != 0) |
463 |
|
{ |
464 |
|
xfree(bd->data); |
465 |
|
} |
466 |
|
memcpy(bd, brush_data, sizeof(BRUSHDATA)); |
467 |
|
} |
468 |
|
else |
469 |
|
{ |
470 |
|
error("put brush %d %d\n", colour_code, idx); |
471 |
|
} |
472 |
|
} |