## Display Device Driver Reference for OS/2

[prev][next][parent][TOC]

### Converting Data

The changed display drivers use different internal data formats:

VGA 4bpp planar

XGA 4bpp packed, 8bpp packed, 16bpp packed

When data is transmitted between display drivers, it is done at the lower bpp of the two drivers (or at the lowest bpp; for example, a pair of 16bpp DCAF-enabled drivers could communicate at 4bpp to reduce the amount of data transmitted). Therefore, the following conversion routines are required by the display driver:

    XGA (4bpp, 8bpp, 16bpp packed)

    internal format     required format

    16bpp packed  ->  8bpp packed (compression)
    16bpp packed  ->  4bpp packed (compression)
    16bpp packed  ->  4bpp planar (compression)
     8bpp packed  ->  8bpp packed (compression)
     8bpp packed  ->  4bpp packed (compression)
     8bpp packed  ->  4bpp planar (compression)
     4bpp packed  ->  4bpp planar (compression)

                   external data format     internal format

    (decompression)  8bpp packed -> 16bpp packed
    (decompression)  8bpp packed ->  8bpp packed
    (decompression)  4bpp packed -> 16bpp packed
    (decompression)  4bpp packed ->  8bpp packed
    (decompression)  4bpp planar -> 16bpp packed
    (decompression)  4bpp planar ->  8bpp packed
    (decompression)  4bpp planar ->  4bpp packed

The conversions from packed to planar and vice versa are assisted by the use of a lookup table to split packed bytes into bits that can be conveniently reassembled into planar format (and vice versa).

All conversions to planar format are done by first converting the bits per pel to 4 (still in packed format) and then performing an optimized 4bpp packed-to-planar conversion. In conversions from 4bpp planar a similar, but reverse, process is performed- converting from 4bpp planar to 4bpp packed and then to the required packed destination format.

Conversions from 4bpp and 8bpp use a lookup table to efficiently translate the colors. Conversions from 16bpp cannot use a direct lookup table because the size is prohibitive. Therefore, colors have to be searched for on a nearest color basis in the destination color table. This is much slower than a simple table lookup. To improve performance, a cache of the most recently calculated colors is kept, which saves having to repeatedly recalculate commonly used colors.