cache.c revision d65680efa46fa49e8bf14e67b29b782510ff934c
/* -*- c-basic-offset: 8 -*-
rdesktop: A Remote Desktop Protocol client.
Cache routines
Copyright (C) Matthew Chapman 1999-2007
Copyright (C) Jeroen Meijer 2005
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Sun GPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Sun elects to use only
* the General Public License version 2 (GPLv2) at this time for any software where
* a choice of GPL license versions is made available with the language indicating
* that GPLv2 or any later version may be used, or where a choice of which version
* of the GPL is applied is otherwise unspecified.
*/
#include "rdesktop.h"
/* BITMAP CACHE */
extern int g_pstcache_fd[];
#define TO_TOP -1
#define NOT_SET -1
/*
* TODO: Test for optimal value of BUMP_COUNT. TO_TOP gives lowest cpu utilisation but using
* a positive value will hopefully result in less frequently used bitmaps having a greater chance
* of being evicted from the cache, and therby reducing the need to load bitmaps from disk.
* (Jeroen)
*/
#define BUMP_COUNT 40
struct bmpcache_entry
{
};
static int g_bmpcache_count[3];
void
{
int n = count, c = 0;
/* find top, skip evicted bitmaps */
if (n < 0)
{
return;
}
c++;
/* link list */
while (n >= 0)
{
/* skip evicted bitmaps */
if (n < 0)
break;
c++;
}
if (c != g_bmpcache_count[id])
{
error("Oops. %d in bitmap cache linked list, %d in ui cache...\n", c,
exit(1);
}
}
/* Move a bitmap to a new position in the linked list. */
void
{
if (!IS_PERSISTENT(id))
return;
return;
{
/* remove */
--g_bmpcache_count[id];
else
else
}
else
{
}
if (bump >= 0)
{
{
}
}
else
{
}
/* insert */
++g_bmpcache_count[id];
if (p_idx >= 0)
else
if (n_idx >= 0)
else
}
/* Evict the least-recently used bitmap from the cache */
void
{
int n_idx;
if (!IS_PERSISTENT(id))
return;
--g_bmpcache_count[id];
}
/* Retrieve a bitmap from the cache */
{
{
{
if (IS_PERSISTENT(id))
}
}
{
return g_volatile_bc[id];
}
return NULL;
}
/* Store a bitmap in the cache */
void
{
{
if (IS_PERSISTENT(id))
{
}
}
{
}
else
{
}
}
/* Updates the persistent bitmap cache MRU information on exit */
void
cache_save_state(void)
{
int idx;
if (IS_PERSISTENT(id))
{
while (idx >= 0)
{
}
DEBUG_RDP5((" %d stamps written.\n", t));
}
}
/* FONT CACHE */
/* Retrieve a glyph from the font cache */
{
{
return glyph;
}
return NULL;
}
/* Store a glyph in the font cache */
void
{
{
}
else
{
}
}
/* TEXT CACHE */
/* Retrieve a text item from the cache */
DATABLOB *
{
return text;
}
/* Store a text item in the cache */
void
{
}
/* DESKTOP CACHE */
/* Retrieve desktop data from the cache */
uint8 *
{
if (offset > sizeof(g_deskcache))
offset = 0;
{
return &g_deskcache[offset];
}
return NULL;
}
/* Store desktop data in the cache */
void
{
if (offset > sizeof(g_deskcache))
offset = 0;
{
cx *= bytes_per_pixel;
while (cy--)
{
}
}
else
{
}
}
/* CURSOR CACHE */
/* Retrieve cursor from cache */
{
{
return cursor;
}
return NULL;
}
/* Store cursor in cache */
void
{
{
}
else
{
}
}