/* Store a bitmap in the cache */ void cache_put_bitmap(uint8 id, uint16 idx, RD_HBITMAP bitmap) { RD_HBITMAP old; if ((id < NUM_ELEMENTS(g_bmpcache)) && (idx < NUM_ELEMENTS(g_bmpcache[0]))) { old = g_bmpcache[id][idx].bitmap; if (old != NULL) ui_destroy_bitmap(old); g_bmpcache[id][idx].bitmap = bitmap; if (IS_PERSISTENT(id)) { if (old == NULL) g_bmpcache[id][idx].previous = g_bmpcache[id][idx].next = NOT_SET; cache_bump_bitmap(id, idx, TO_TOP); if (g_bmpcache_count[id] > BMPCACHE2_C2_CELLS) cache_evict_bitmap(id); } } else if ((id < NUM_ELEMENTS(g_volatile_bc)) && (idx == 0x7fff)) { old = g_volatile_bc[id]; if (old != NULL) ui_destroy_bitmap(old); g_volatile_bc[id] = bitmap; } else { error("put bitmap %d:%d\n", id, idx); } }
/* Store a bitmap in the cache */ void cache_put_bitmap(rdcConnection conn, uint8 id, uint16 idx, HBITMAP bitmap) { HBITMAP old; if ((id < NUM_ELEMENTS(conn->bmpcache)) && (idx < NUM_ELEMENTS(conn->bmpcache[0]))) { old = conn->bmpcache[id][idx].bitmap; if (old != NULL) ui_destroy_bitmap(old); conn->bmpcache[id][idx].bitmap = bitmap; if (IS_PERSISTENT(id)) { if (old == NULL) conn->bmpcache[id][idx].previous = conn->bmpcache[id][idx].next = NOT_SET; cache_bump_bitmap(conn, id, idx, TO_TOP); if (conn->bmpcacheCount[id] > BMPCACHE2_C2_CELLS) cache_evict_bitmap(conn, id); } } else if ((id < NUM_ELEMENTS(conn->volatileBc)) && (idx == 0x7fff)) { old = conn->volatileBc[id]; if (old != NULL) ui_destroy_bitmap(old); conn->volatileBc[id] = bitmap; } else { error("put bitmap %d:%d\n", id, idx); } }
/* Store a bitmap in the cache */ void cache_put_bitmap(uint8 cache_id, uint16 cache_idx, HBITMAP bitmap) { HBITMAP old; if ((cache_id < NUM_ELEMENTS(bmpcache)) && (cache_idx < NUM_ELEMENTS(bmpcache[0]))) { old = bmpcache[cache_id][cache_idx]; if (old != NULL) ui_destroy_bitmap(old); bmpcache[cache_id][cache_idx] = bitmap; } else { error("put bitmap %d:%d\n", cache_id, cache_idx); } }
/* Evict the least-recently used bitmap from the cache */ void cache_evict_bitmap(uint8 id) { uint16 idx; int n_idx; if (!IS_PERSISTENT(id)) return; idx = g_bmpcache_lru[id]; n_idx = g_bmpcache[id][idx].next; DEBUG_RDP5(("evict bitmap: id=%d idx=%d n_idx=%d bmp=0x%x\n", id, idx, n_idx, g_bmpcache[id][idx].bitmap)); ui_destroy_bitmap(g_bmpcache[id][idx].bitmap); --g_bmpcache_count[id]; g_bmpcache[id][idx].bitmap = 0; g_bmpcache_lru[id] = n_idx; g_bmpcache[id][n_idx].previous = NOT_SET; pstcache_touch_bitmap(id, idx, 0); }
/* Evict the least-recently used bitmap from the cache */ static void cache_evict_bitmap(rdcConnection conn, uint8 id) { uint16 idx; int n_idx; if (!IS_PERSISTENT(id)) return; idx = conn->bmpcacheLru[id]; n_idx = conn->bmpcache[id][idx].next; DEBUG_RDP5(("evict bitmap: id=%d idx=%d n_idx=%d bmp=0x%x\n", id, idx, n_idx, conn->bmpcache[id][idx].bitmap)); ui_destroy_bitmap(conn->bmpcache[id][idx].bitmap); --conn->bmpcacheCount[id]; conn->bmpcache[id][idx].bitmap = 0; conn->bmpcacheLru[id] = n_idx; conn->bmpcache[id][n_idx].previous = NOT_SET; pstcache_touch_bitmap(conn, id, idx, 0); }
/* Evict the least-recently used bitmap from the cache */ void cache_evict_bitmap(RDPCLIENT * This, uint8 id) { uint16 idx; int n_idx; if (!IS_PERSISTENT(id)) return; idx = This->cache.bmpcache_lru[id]; n_idx = This->cache.bmpcache[id][idx].next; DEBUG_RDP5(("evict bitmap: id=%d idx=%d n_idx=%d bmp=0x%x\n", id, idx, n_idx, This->cache.bmpcache[id][idx].bitmap)); ui_destroy_bitmap(This, This->cache.bmpcache[id][idx].bitmap); --This->cache.bmpcache_count[id]; This->cache.bmpcache[id][idx].bitmap = 0; This->cache.bmpcache_lru[id] = n_idx; This->cache.bmpcache[id][n_idx].previous = NOT_SET; pstcache_touch_bitmap(This, id, idx, 0); }