/[rdesktop]/sourceforge.net/trunk/rdesktop/cache.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/cache.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 30 by matty, Fri Sep 14 13:51:38 2001 UTC revision 563 by jsorg71, Wed Dec 24 17:23:03 2003 UTC
# Line 1  Line 1 
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-2001     Copyright (C) Matthew Chapman 1999-2002
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
# Line 24  Line 24 
24    
25    
26  /* BITMAP CACHE */  /* BITMAP CACHE */
27  static HBITMAP bmpcache[3][600];  static HBITMAP g_bmpcache[3][600];
28    
29  /* Retrieve a bitmap from the cache */  /* Retrieve a bitmap from the cache */
30  HBITMAP  HBITMAP
# Line 32  cache_get_bitmap(uint8 cache_id, uint16 Line 32  cache_get_bitmap(uint8 cache_id, uint16
32  {  {
33          HBITMAP bitmap;          HBITMAP bitmap;
34    
35          if ((cache_id < NUM_ELEMENTS(bmpcache))          if ((cache_id < NUM_ELEMENTS(g_bmpcache)) && (cache_idx < NUM_ELEMENTS(g_bmpcache[0])))
             && (cache_idx < NUM_ELEMENTS(bmpcache[0])))  
36          {          {
37                  bitmap = bmpcache[cache_id][cache_idx];                  bitmap = g_bmpcache[cache_id][cache_idx];
38                  if (bitmap != NULL)                  if (bitmap != NULL)
39                          return bitmap;                          return bitmap;
40          }          }
# Line 50  cache_put_bitmap(uint8 cache_id, uint16 Line 49  cache_put_bitmap(uint8 cache_id, uint16
49  {  {
50          HBITMAP old;          HBITMAP old;
51    
52          if ((cache_id < NUM_ELEMENTS(bmpcache))          if ((cache_id < NUM_ELEMENTS(g_bmpcache)) && (cache_idx < NUM_ELEMENTS(g_bmpcache[0])))
             && (cache_idx < NUM_ELEMENTS(bmpcache[0])))  
53          {          {
54                  old = bmpcache[cache_id][cache_idx];                  old = g_bmpcache[cache_id][cache_idx];
55                  if (old != NULL)                  if (old != NULL)
56                          ui_destroy_bitmap(old);                          ui_destroy_bitmap(old);
57    
58                  bmpcache[cache_id][cache_idx] = bitmap;                  g_bmpcache[cache_id][cache_idx] = bitmap;
59          }          }
60          else          else
61          {          {
# Line 67  cache_put_bitmap(uint8 cache_id, uint16 Line 65  cache_put_bitmap(uint8 cache_id, uint16
65    
66    
67  /* FONT CACHE */  /* FONT CACHE */
68  static FONTGLYPH fontcache[12][256];  static FONTGLYPH g_fontcache[12][256];
69    
70  /* Retrieve a glyph from the font cache */  /* Retrieve a glyph from the font cache */
71  FONTGLYPH *  FONTGLYPH *
# Line 75  cache_get_font(uint8 font, uint16 charac Line 73  cache_get_font(uint8 font, uint16 charac
73  {  {
74          FONTGLYPH *glyph;          FONTGLYPH *glyph;
75    
76          if ((font < NUM_ELEMENTS(fontcache))          if ((font < NUM_ELEMENTS(g_fontcache)) && (character < NUM_ELEMENTS(g_fontcache[0])))
             && (character < NUM_ELEMENTS(fontcache[0])))  
77          {          {
78                  glyph = &fontcache[font][character];                  glyph = &g_fontcache[font][character];
79                  if (glyph->pixmap != NULL)                  if (glyph->pixmap != NULL)
80                          return glyph;                          return glyph;
81          }          }
# Line 94  cache_put_font(uint8 font, uint16 charac Line 91  cache_put_font(uint8 font, uint16 charac
91  {  {
92          FONTGLYPH *glyph;          FONTGLYPH *glyph;
93    
94          if ((font < NUM_ELEMENTS(fontcache))          if ((font < NUM_ELEMENTS(g_fontcache)) && (character < NUM_ELEMENTS(g_fontcache[0])))
             && (character < NUM_ELEMENTS(fontcache[0])))  
95          {          {
96                  glyph = &fontcache[font][character];                  glyph = &g_fontcache[font][character];
97                  if (glyph->pixmap != NULL)                  if (glyph->pixmap != NULL)
98                          ui_destroy_glyph(glyph->pixmap);                          ui_destroy_glyph(glyph->pixmap);
99    
# Line 115  cache_put_font(uint8 font, uint16 charac Line 111  cache_put_font(uint8 font, uint16 charac
111    
112    
113  /* TEXT CACHE */  /* TEXT CACHE */
114  static DATABLOB textcache[256];  static DATABLOB g_textcache[256];
115    
116  /* Retrieve a text item from the cache */  /* Retrieve a text item from the cache */
117  DATABLOB *  DATABLOB *
# Line 123  cache_get_text(uint8 cache_id) Line 119  cache_get_text(uint8 cache_id)
119  {  {
120          DATABLOB *text;          DATABLOB *text;
121    
122          if (cache_id < NUM_ELEMENTS(textcache))          if (cache_id < NUM_ELEMENTS(g_textcache))
123          {          {
124                  text = &textcache[cache_id];                  text = &g_textcache[cache_id];
125                  if (text->data != NULL)                  if (text->data != NULL)
126                          return text;                          return text;
127          }          }
# Line 140  cache_put_text(uint8 cache_id, void *dat Line 136  cache_put_text(uint8 cache_id, void *dat
136  {  {
137          DATABLOB *text;          DATABLOB *text;
138    
139          if (cache_id < NUM_ELEMENTS(textcache))          if (cache_id < NUM_ELEMENTS(g_textcache))
140          {          {
141                  text = &textcache[cache_id];                  text = &g_textcache[cache_id];
142                  if (text->data != NULL)                  if (text->data != NULL)
143                          xfree(text->data);                          xfree(text->data);
144    
# Line 158  cache_put_text(uint8 cache_id, void *dat Line 154  cache_put_text(uint8 cache_id, void *dat
154    
155    
156  /* DESKTOP CACHE */  /* DESKTOP CACHE */
157  static uint8 deskcache[0x38400 * 4];  static uint8 g_deskcache[0x38400 * 4];
158    
159  /* Retrieve desktop data from the cache */  /* Retrieve desktop data from the cache */
160  uint8 *  uint8 *
# Line 166  cache_get_desktop(uint32 offset, int cx, Line 162  cache_get_desktop(uint32 offset, int cx,
162  {  {
163          int length = cx * cy * bytes_per_pixel;          int length = cx * cy * bytes_per_pixel;
164    
165          if ((offset + length) <= sizeof(deskcache))          if (offset > sizeof(g_deskcache))
166                    offset = 0;
167    
168            if ((offset + length) <= sizeof(g_deskcache))
169          {          {
170                  return &deskcache[offset];                  return &g_deskcache[offset];
171          }          }
172    
173          error("get desktop %d:%d\n", offset, length);          error("get desktop %d:%d\n", offset, length);
# Line 177  cache_get_desktop(uint32 offset, int cx, Line 176  cache_get_desktop(uint32 offset, int cx,
176    
177  /* Store desktop data in the cache */  /* Store desktop data in the cache */
178  void  void
179  cache_put_desktop(uint32 offset, int cx, int cy, int scanline,  cache_put_desktop(uint32 offset, int cx, int cy, int scanline, int bytes_per_pixel, uint8 * data)
                   int bytes_per_pixel, uint8 *data)  
180  {  {
181          int length = cx * cy * bytes_per_pixel;          int length = cx * cy * bytes_per_pixel;
182    
183          if ((offset + length) <= sizeof(deskcache))          if (offset > sizeof(g_deskcache))
184                    offset = 0;
185    
186            if ((offset + length) <= sizeof(g_deskcache))
187          {          {
188                  cx *= bytes_per_pixel;                  cx *= bytes_per_pixel;
189                  while (cy--)                  while (cy--)
190                  {                  {
191                          memcpy(&deskcache[offset], data, cx);                          memcpy(&g_deskcache[offset], data, cx);
192                          data += scanline;                          data += scanline;
193                          offset += cx;                          offset += cx;
194                  }                  }
# Line 200  cache_put_desktop(uint32 offset, int cx, Line 201  cache_put_desktop(uint32 offset, int cx,
201    
202    
203  /* CURSOR CACHE */  /* CURSOR CACHE */
204  static HCURSOR cursorcache[0x20];  static HCURSOR g_cursorcache[0x20];
205    
206  /* Retrieve cursor from cache */  /* Retrieve cursor from cache */
207  HCURSOR cache_get_cursor(uint16 cache_idx)  HCURSOR
208    cache_get_cursor(uint16 cache_idx)
209  {  {
210          HCURSOR cursor;          HCURSOR cursor;
211    
212          if (cache_idx < NUM_ELEMENTS(cursorcache))          if (cache_idx < NUM_ELEMENTS(g_cursorcache))
213          {          {
214                  cursor = cursorcache[cache_idx];                  cursor = g_cursorcache[cache_idx];
215                  if (cursor != NULL)                  if (cursor != NULL)
216                          return cursor;                          return cursor;
217          }          }
# Line 224  cache_put_cursor(uint16 cache_idx, HCURS Line 226  cache_put_cursor(uint16 cache_idx, HCURS
226  {  {
227          HCURSOR old;          HCURSOR old;
228    
229          if (cache_idx < NUM_ELEMENTS(cursorcache))          if (cache_idx < NUM_ELEMENTS(g_cursorcache))
230          {          {
231                  old = cursorcache[cache_idx];                  old = g_cursorcache[cache_idx];
232                  if (old != NULL)                  if (old != NULL)
233                          ui_destroy_cursor(old);                          ui_destroy_cursor(old);
234    
235                  cursorcache[cache_idx] = cursor;                  g_cursorcache[cache_idx] = cursor;
236          }          }
237          else          else
238          {          {

Legend:
Removed from v.30  
changed lines
  Added in v.563

  ViewVC Help
Powered by ViewVC 1.1.26