Bitmap cache

Although bitmaps in RDP can be drawn without using a cache, the most efficient way to to use the RDP orders and bitmaps caching.

Bitmap Cache version 1

Bitmaps in RDP are cached in slots. There are three different cache slot types depending on the size of the bitmap. The largest bitmap width or height is 64. Larger bitmaps a drawn by splitting up the bitmap into smaller bitmaps that do fit into a slot.
The three slot lists are:
600 slots of size 256 pixels or smaller
300 slots of size 1024 pixels or smaller
262 slots of size 4096 pixels or smaller

Bitmap Cache version 2

With RDP5.0 came a second version of the bitmap cache. The 3 slot sizes are still the same but the number of each is now determined by the client. There is also a persistent bitmap cache that can use the hard drive to make the cache much bigger. Currently xrdp tells the client to use v1 bitmap cache.

When drawing a bitmap, how do you know if you should cache a bitmaps or draw it without caching. Well, xrdp always caches the bitmaps when drawing. Max 64 x 64 pixel bitmaps are copied from the bitmap to be drawn and as they are being copied, a CRC is generated. This CRC is used to quickly check the cache if this bitmap is already at the client. If so, use the cached one with a memblt order to draw it. The CRC method of comparing bitmaps is much more efficient than comparing the contents of the bitmap.

This drawing method is a bit slower(video wise) than always sending the bitmap, but a lot of bandwidth can be saved if the same bitmaps is drawn over and over.

see xrdp_cache.c, xrdp_painter.c, and xrdp_bitmap.c for more info.

Last updated: 10/02/2007