Index

D-Type Direct Color Rasterizer Units

All D-Type Direct Color Rasterizer coordinates are expressed in pixels. A pixel value can be represented as a real (floating point) value of the DT_FLOAT type or, alternatively, as a 24.8 fractional value of the DT_SFRAC type.

The DT_FLOAT type is recommended on machines that have a floating point math processor. Most modern CPUs (e.g. Intel, Motorola) include a floating point processor. However, if a floating point processor is not available (e.g. embedded systems and/or hand-held devices) or if simply the highest possible rendering speed is required, the DT_SFRAC type can be used. This type describes a 24.8 signed fractional value expressed as a 32-bit signed integer. Computations that use DT_SFRAC type are essentially computations with integers and are usually faster than the equivalent computations that use the DT_FLOAT type. To express a floating point number in the 24.8 signed fractional format, simply multiply its value by 256. Mathematically:

fractional_value_24dot8 = floating_point_value * 256
and
floating_point_value = fractional_value_24dot8 / 256

For example, a rectangle that is 5.4 pixels wide and 3.2 pixels tall would be approximately 1382 fractional units wide and 819 fractional units tall in the 24.8 signed fractional pixel space.

It should be noted that D-Type API always provides support for both floating point and fractional values. When a floating point processor is not available, the floating point math is emulated. It is up to the developers to determine which type works best in their application(s).

Finally, care should be taken when using extremely large pixel values. Although the DT_FLOAT type provides practically an unlimited floating point range, numerical overflows and unexpected rendering results may occur when pixel coordinates approach or exceed the limits imposed by 24-bit integers. This is because D-Type Direct Color Rasterizer internally stores all pixel quantities as 24.8 signed fractional values in order to make it possible to render text and vectorial shapes using sub-pixel precision. In other words, it is important to remember that the final output coordinates (in whole pixels) are limited to the [-223 .. +223 - 1] range.

 

Index