/[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 25 by matty, Sat Jan 6 03:47:04 2001 UTC revision 82 by astrand, Tue Jul 30 07:18:48 2002 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-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
# 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(bmpcache)) && (cache_idx < NUM_ELEMENTS(bmpcache[0])))
             && (cache_idx < NUM_ELEMENTS(bmpcache[0])))  
36          {          {
37                  bitmap = bmpcache[cache_id][cache_idx];                  bitmap = bmpcache[cache_id][cache_idx];
38                  if (bitmap != NULL)                  if (bitmap != NULL)
39                          return bitmap;                          return bitmap;
40          }          }
41    
42          ERROR("get bitmap %d:%d\n", cache_id, cache_idx);          error("get bitmap %d:%d\n", cache_id, cache_idx);
43          return NULL;          return NULL;
44  }  }
45    
# 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(bmpcache)) && (cache_idx < NUM_ELEMENTS(bmpcache[0])))
             && (cache_idx < NUM_ELEMENTS(bmpcache[0])))  
53          {          {
54                  old = bmpcache[cache_id][cache_idx];                  old = bmpcache[cache_id][cache_idx];
55                  if (old != NULL)                  if (old != NULL)
# Line 61  cache_put_bitmap(uint8 cache_id, uint16 Line 59  cache_put_bitmap(uint8 cache_id, uint16
59          }          }
60          else          else
61          {          {
62                  ERROR("put bitmap %d:%d\n", cache_id, cache_idx);                  error("put bitmap %d:%d\n", cache_id, cache_idx);
63          }          }
64  }  }
65    
# 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(fontcache)) && (character < NUM_ELEMENTS(fontcache[0])))
             && (character < NUM_ELEMENTS(fontcache[0])))  
77          {          {
78                  glyph = &fontcache[font][character];                  glyph = &fontcache[font][character];
79                  if (glyph->pixmap != NULL)                  if (glyph->pixmap != NULL)
80                          return glyph;                          return glyph;
81          }          }
82    
83          ERROR("get font %d:%d\n", font, character);          error("get font %d:%d\n", font, character);
84          return NULL;          return NULL;
85  }  }
86    
# 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(fontcache)) && (character < NUM_ELEMENTS(fontcache[0])))
             && (character < NUM_ELEMENTS(fontcache[0])))  
95          {          {
96                  glyph = &fontcache[font][character];                  glyph = &fontcache[font][character];
97                  if (glyph->pixmap != NULL)                  if (glyph->pixmap != NULL)
# Line 109  cache_put_font(uint8 font, uint16 charac Line 105  cache_put_font(uint8 font, uint16 charac
105          }          }
106          else          else
107          {          {
108                  ERROR("put font %d:%d\n", font, character);                  error("put font %d:%d\n", font, character);
109          }          }
110  }  }
111    
# Line 130  cache_get_text(uint8 cache_id) Line 126  cache_get_text(uint8 cache_id)
126                          return text;                          return text;
127          }          }
128    
129          ERROR("get text %d\n", cache_id);          error("get text %d\n", cache_id);
130          return NULL;          return NULL;
131  }  }
132    
# Line 152  cache_put_text(uint8 cache_id, void *dat Line 148  cache_put_text(uint8 cache_id, void *dat
148          }          }
149          else          else
150          {          {
151                  ERROR("put text %d\n", cache_id);                  error("put text %d\n", cache_id);
152          }          }
153  }  }
154    
155    
156  /* DESKTOP CACHE */  /* DESKTOP CACHE */
157  static uint8 deskcache[0x38400];  static uint8 deskcache[0x38400 * 4];
158    
159  /* Retrieve desktop data from the cache */  /* Retrieve desktop data from the cache */
160  uint8 *  uint8 *
161  cache_get_desktop(uint32 offset, int cx, int cy)  cache_get_desktop(uint32 offset, int cx, int cy, int bytes_per_pixel)
162  {  {
163          int length = cx * cy;          int length = cx * cy * bytes_per_pixel;
164    
165          if ((offset + length) <= sizeof(deskcache))          if ((offset + length) <= sizeof(deskcache))
166          {          {
167                  return &deskcache[offset];                  return &deskcache[offset];
168          }          }
169    
170          ERROR("get desktop %d:%d\n", offset, length);          error("get desktop %d:%d\n", offset, length);
171          return NULL;          return NULL;
172  }  }
173    
174  /* Store desktop data in the cache */  /* Store desktop data in the cache */
175  void  void
176  cache_put_desktop(uint32 offset, int cx, int cy, int scanline, uint8 *data)  cache_put_desktop(uint32 offset, int cx, int cy, int scanline, int bytes_per_pixel, uint8 * data)
177  {  {
178          int length = cx * cy;          int length = cx * cy * bytes_per_pixel;
179    
180          if ((offset + length) <= sizeof(deskcache))          if ((offset + length) <= sizeof(deskcache))
181          {          {
182                    cx *= bytes_per_pixel;
183                  while (cy--)                  while (cy--)
184                  {                  {
185                          memcpy(&deskcache[offset], data, cx);                          memcpy(&deskcache[offset], data, cx);
# Line 192  cache_put_desktop(uint32 offset, int cx, Line 189  cache_put_desktop(uint32 offset, int cx,
189          }          }
190          else          else
191          {          {
192                  ERROR("put desktop %d:%d\n", offset, length);                  error("put desktop %d:%d\n", offset, length);
193            }
194    }
195    
196    
197    /* CURSOR CACHE */
198    static HCURSOR cursorcache[0x20];
199    
200    /* Retrieve cursor from cache */
201    HCURSOR
202    cache_get_cursor(uint16 cache_idx)
203    {
204            HCURSOR cursor;
205    
206            if (cache_idx < NUM_ELEMENTS(cursorcache))
207            {
208                    cursor = cursorcache[cache_idx];
209                    if (cursor != NULL)
210                            return cursor;
211            }
212    
213            error("get cursor %d\n", cache_idx);
214            return NULL;
215    }
216    
217    /* Store cursor in cache */
218    void
219    cache_put_cursor(uint16 cache_idx, HCURSOR cursor)
220    {
221            HCURSOR old;
222    
223            if (cache_idx < NUM_ELEMENTS(cursorcache))
224            {
225                    old = cursorcache[cache_idx];
226                    if (old != NULL)
227                            ui_destroy_cursor(old);
228    
229                    cursorcache[cache_idx] = cursor;
230            }
231            else
232            {
233                    error("put cursor %d\n", cache_idx);
234          }          }
235  }  }

Legend:
Removed from v.25  
changed lines
  Added in v.82

  ViewVC Help
Powered by ViewVC 1.1.26