📄 line.cpp
字号:
//-----------------------------------------------------------------------
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
// Copyright (c) 1999 Microsoft Corporation
//
// written by: ESG Solution Center Munich
//
//
// Module Name: line.cpp
//
// abstract: Windows CE display driver for C&T 69000
// line drawing accelerations
//
//-----------------------------------------------------------------------
#include "precomp.h"
//
// this driver accelerates horizontal and vertical line drawing
// with all line drawing rops, so we have this table to convert
// a line rop to a blt rop
//
static BYTE bRop2toRop4[17]=
{ 0, 0, 5, 0xa, 0xf, 0x50, 0x55, 0x5a, 0x5f,
0xa0, 0xa5, 0xaa, 0xaf, 0xf0, 0xf5, 0xfa, 0xff};
//-----------------------------------------------------------------------
//
// CT69000::Line
//
// this function is called whenever gpe is about to draw a line.
// if the hardware is able to accelerate line drawing return a pointer
// to the accelerated function, otherwise return the pointer to the
// emulation
//
//-----------------------------------------------------------------------
SCODE
CT69000::Line(GPELineParms *pLineParms, EGPEPhase phase)
{
//
// we can accelerate all lines:
// -- which are in video memory
// -- and have no pattern
//
// note: at this point we don't know yet what type
// of line we are about to draw. So we can just decide
// if we want to go the hardware path or not.
//
//
if ( pLineParms->pDst->InVideoMemory() &&
((pLineParms->mix&0xff) == (pLineParms->mix>>8))
)
{
pLineParms->pLine =
(SCODE (GPE::*)(struct GPELineParms *))AcceleratedLine;
return S_OK;
}
//
// Look if we have a better emulation...
//
switch (pLineParms->pDst->Format())
{
case gpe8Bpp:
pLineParms->pLine =
(SCODE (GPE::*)(struct GPELineParms *))EmulatedLine8Bit;
return S_OK;
case gpe16Bpp:
pLineParms->pLine =
(SCODE (GPE::*)(struct GPELineParms *))EmulatedLine16Bit;
return S_OK;
case gpe24Bpp:
default:
break;
}
//
// must be a complicated line, fall back to emulation
//
pLineParms->pLine = EmulatedLine;
return S_OK;
}
//-----------------------------------------------------------------------
//
// CT69000::AcceleratedLine
//
// program C&T69000 to draw accelerated line
//
// the C&T69000 has no line acceleration, so we accelerate only
// horizontal and vertical lines by drawing a rect with 1 pixel height/
// width
//
//-----------------------------------------------------------------------
SCODE
CT69000::AcceleratedLine(GPELineParms *pLineParms)
{
ASSERT( pLineParms->pDst->InVideoMemory());
DEBUGMSG(CT69K_ZONE_LINE,
(TEXT("CT69000::AcceleratedLine\r\n")));
DEBUGMSG(CT69K_ZONE_LINE,
(TEXT(" iDir: %d xStart: %d yStart: %d cPels: %d\r\n"),
pLineParms->iDir, pLineParms->xStart,
pLineParms->yStart, pLineParms->cPels));
DEBUGMSG(CT69K_ZONE_LINE,
(TEXT(" style: %08lx mix: %04x\r\n"),
pLineParms->style, pLineParms->mix));
DEBUGMSG(CT69K_ZONE_LINE,
(TEXT(" dM: %d dN: %d solidColor %04x\r\n"),
pLineParms->dM, pLineParms->dN, pLineParms->solidColor));
#if CURSORDEBUG
if (m_bBltEmulation==0)
#endif
//
// check we are about to draw a vertical or horizontal line
//
if (pLineParms->dN==0)
{
ULONG ulDstSpan=pLineParms->pDst->Stride();
ULONG ulDstAddress=pLineParms->pDst->OffsetInVideoMemory();
ULONG ulWidth;
ULONG ulHeight;
ULONG ulXStart=pLineParms->xStart;
ULONG ulYStart=pLineParms->yStart;
ULONG ulCmd = bRop2toRop4[pLineParms->mix & 0xff];
ulCmd |= (1L<<19) | (1L<<18);
switch (pLineParms->iDir)
{
// horizontal, right to left
case 3:
case 4:
ulCmd |= 0x100;
// horizontal
case 7:
case 0:
ulWidth=BYTESPERPIXEL(pLineParms->cPels);
ulHeight=1;
break;
// vertical, bottom to top
case 5:
case 6:
ulCmd |= 0x200;
// vertical
case 1:
case 2:
ulWidth=BYTESPERPIXEL(1);
ulHeight=pLineParms->cPels;
break;
}
ulDstAddress += BYTESPERPIXEL(ulXStart)+
ulYStart*ulDstSpan;
ULONG ulBlt=ulWidth | (ulHeight << 16);
if (BltEngineBusy())
WaitForNotBusy();
SetBR( 0, ulDstSpan << 16); // set dest. span
SetBR( 1, pLineParms->solidColor); // set bc color
SetBR( 4, ulCmd); // specify mono pattern
SetBR( 7, ulDstAddress);
SetBR( 8, ulBlt);
DEBUGMSG(CT69K_ZONE_LINE,
(TEXT("--hw accelerated line draw \r\n")));
return S_OK;
}
#if BIOSSETUP
switch (pLineParms->pDst->Format())
{
case gpe8Bpp:
return EmulatedLine8Bit(pLineParms);
case gpe16Bpp:
return EmulatedLine16Bit(pLineParms);
default:
case gpe24Bpp:
return EmulatedLine(pLineParms);
}
#elif FBBPP==8
return EmulatedLine8Bit(pLineParms);
#elif FBBPP==16
return EmulatedLine16Bit(pLineParms);
#else
return EmulatedLine(pLineParms);
#endif
}
//-----------------------------------------------------------------------
//
// CT69000::EmulatedLine8Bit
//
// simplified software version of 8 bit line drawing
//
//-----------------------------------------------------------------------
SCODE
CT69000::EmulatedLine8Bit(GPELineParms *pParms)
{
ASSERT( pParms->pDst->Format()==gpe8Bpp);
#if CURSORDEBUG
if (m_bBltEmulation>1)
return EmulatedLine(pParms);
#endif
LONG accum = (long)(pParms->dN) + pParms->llGamma;
LONG axstp = (long)(pParms->dN);
LONG dgstp = (long)(pParms->dN) - (long)(pParms->dM);
ULONG rop2MarkSpace[2];
rop2MarkSpace[0] = (UCHAR)(pParms->mix);
rop2MarkSpace[1] = (UCHAR)(pParms->mix >> 8);
ULONG ulStyle;
INT iStride = pParms->pDst->Stride()/sizeof(UCHAR);
INT iMajorD;
INT iMinorD;
UCHAR D;
UCHAR P;
DEBUGMSG(CT69K_ZONE_LINE,
(TEXT("CT69000::EmulatedLine8Bit\r\n")));
DEBUGMSG(CT69K_ZONE_LINE,
(TEXT("--Solid color 0x%08x\r\n"),pParms->solidColor));
DEBUGMSG(CT69K_ZONE_LINE,
(TEXT("--Start X=%d,Y=%d\r\n"),pParms->xStart,pParms->yStart));
DEBUGMSG(CT69K_ZONE_LINE,
(TEXT("--iDir:%d accum %d axstp %d dgstp %d\r\n"),
pParms->iDir,accum,axstp,dgstp));
DEBUGMSG(CT69K_ZONE_LINE,
(TEXT("--Mix: %04x Style: %08lx\r\n"),pParms->mix, pParms->style));
if( pParms->pDst->InVideoMemory() )
{
// If we have a pending blt and now attempt a software operation using
// video memory, the pipeline must be flushed.
WaitForNotBusy();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -