~ubuntu-branches/ubuntu/precise/virtualbox/precise-updates

« back to all changes in this revision

Viewing changes to src/VBox/RDP/client/cache.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-07-04 13:02:31 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110704130231-l843es6wqhx614n7
Tags: 4.0.10-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Add the Modaliases control field manually for maximum backportability.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- c-basic-offset: 8 -*-
2
2
   rdesktop: A Remote Desktop Protocol client.
3
3
   Cache routines
4
 
   Copyright (C) Matthew Chapman 1999-2007
5
 
   Copyright (C) Jeroen Meijer 2005
 
4
   Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 1999-2008
 
5
   Copyright (C) Jeroen Meijer <jeroen@oldambt7.com> 2005
 
6
   Copyright 2003-2011 Peter Astrand <astrand@cendio.se> for Cendio AB
6
7
 
7
 
   This program is free software; you can redistribute it and/or modify
 
8
   This program is free software: you can redistribute it and/or modify
8
9
   it under the terms of the GNU General Public License as published by
9
 
   the Free Software Foundation; either version 2 of the License, or
 
10
   the Free Software Foundation, either version 3 of the License, or
10
11
   (at your option) any later version.
11
12
 
12
13
   This program is distributed in the hope that it will be useful,
15
16
   GNU General Public License for more details.
16
17
 
17
18
   You should have received a copy of the GNU General Public License
18
 
   along with this program; if not, write to the Free Software
19
 
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
20
*/
21
21
 
22
22
/*
59
59
 
60
60
static int g_bmpcache_lru[3] = { NOT_SET, NOT_SET, NOT_SET };
61
61
static int g_bmpcache_mru[3] = { NOT_SET, NOT_SET, NOT_SET };
 
62
 
62
63
static int g_bmpcache_count[3];
63
64
 
64
65
/* Setup the bitmap cache lru/mru linked list */
103
104
        {
104
105
                error("Oops. %d in bitmap cache linked list, %d in ui cache...\n", c,
105
106
                      g_bmpcache_count[id]);
106
 
                exit(1);
 
107
                exit(EX_SOFTWARE);
107
108
        }
108
109
}
109
110
 
185
186
 
186
187
        idx = g_bmpcache_lru[id];
187
188
        n_idx = g_bmpcache[id][idx].next;
188
 
        DEBUG_RDP5(("evict bitmap: id=%d idx=%d n_idx=%d bmp=0x%x\n", id, idx, n_idx,
 
189
        DEBUG_RDP5(("evict bitmap: id=%d idx=%d n_idx=%d bmp=%p\n", id, idx, n_idx,
189
190
                    g_bmpcache[id][idx].bitmap));
190
191
 
191
192
        ui_destroy_bitmap(g_bmpcache[id][idx].bitmap);
439
440
                error("put cursor %d\n", cache_idx);
440
441
        }
441
442
}
 
443
 
 
444
/* BRUSH CACHE */
 
445
/* index 0 is 2 colour brush, index 1 is muti colour brush */
 
446
static BRUSHDATA g_brushcache[2][64];
 
447
 
 
448
/* Retrieve brush from cache */
 
449
BRUSHDATA *
 
450
cache_get_brush_data(uint8 colour_code, uint8 idx)
 
451
{
 
452
        colour_code = colour_code == 1 ? 0 : 1;
 
453
        if (idx < NUM_ELEMENTS(g_brushcache[0]))
 
454
        {
 
455
                return &g_brushcache[colour_code][idx];
 
456
        }
 
457
        error("get brush %d %d\n", colour_code, idx);
 
458
        return NULL;
 
459
}
 
460
 
 
461
/* Store brush in cache */
 
462
/* this function takes over the data pointer in struct, eg, caller gives it up */
 
463
void
 
464
cache_put_brush_data(uint8 colour_code, uint8 idx, BRUSHDATA * brush_data)
 
465
{
 
466
        BRUSHDATA *bd;
 
467
 
 
468
        colour_code = colour_code == 1 ? 0 : 1;
 
469
        if (idx < NUM_ELEMENTS(g_brushcache[0]))
 
470
        {
 
471
                bd = &g_brushcache[colour_code][idx];
 
472
                if (bd->data != 0)
 
473
                {
 
474
                        xfree(bd->data);
 
475
                }
 
476
                memcpy(bd, brush_data, sizeof(BRUSHDATA));
 
477
        }
 
478
        else
 
479
        {
 
480
                error("put brush %d %d\n", colour_code, idx);
 
481
        }
 
482
}