Accelerating Line Drawing

Windows CE 2.0 and later include support for accelerating line drawing. The levels of accelerated line drawing are largely the same as for accelerated blit operations. The discussion of Accelerating Bit Block Transfers in the previous sections is relevant for line drawing as well, except that the emulation library provided in the Platform Builder does not provide software-accelerated line drawing. Developers can add software-accelerated line drawing functions, if necessary.

Display drivers route line drawing to the GPE, to custom software acceleration routines, or directly to the hardware. The following code example from the S3Virge display driver sample shows how these methods are invoked. This source code is very similar in design to the acceleration processing performed for blit operations.

SCODE 
S3Virge::Line(GPELineParms *pLineParms, EGPEPhase phase)
{

#ifdef ENABLE_ACCELERATION
    if (phase == gpeSingle || phase == gpePrepare)
    {
        DispPerfStart (ROP_LINE);
        pLineParms->pLine = EmulatedLine;
        if (pLineParms->pDst->InVideoMemory() && pLineParms->mix == 0x0d0d)
        {
#if VIRGE_VERBOSE_MSGS
            switch (phase)
            {
            case gpeSingle:
                RETAILMSG(VIRGE_VERBOSE_MSGS, (TEXT("in single\n\r")));
                break;
            case gpePrepare:
                RETAILMSG(VIRGE_VERBOSE_MSGS, (TEXT("in prepare\n\r")));
                break;
            }
#endif
            SelectSolidColor(pLineParms->solidColor);
            pLineParms->pLine = (SCODE (GPE::*)(struct GPELineParms *)) AcceleratedSolidLine;
        }
    } else if (phase == gpeComplete) {
        DispPerfEnd (0);
    }
#else
    pLineParms->pLine = EmulatedLine;
#endif
    return S_OK;
}

The S3Virge driver conditionally compiles the hardware acceleration code with the ENABLE_ACCELERATION preprocessor directive. Line drawing begins with a call to the driver’s Line function. For improved performance, the driver’s Line function can examine the characteristics of the line drawing and the associated surfaces to determine whether an accelerated form of line drawing is appropriate. The default line drawing function is set to the EmulatedLine function of the GPE. The driver checks for a destination surface in video memory and checks the line drawing parameters. If the parameters are valid for acceleration, the line drawing function is set to the driver’s AcceleratedSolidLine function.