📄 line.cpp
字号:
/*==========================================================================\
* LINE.CPP --
* Copyright (c) Epson Research and Development, Inc. 1998,2001
* All Rights Reserved.
* Created 9-21-1998, Epson Research and Development, Inc.
*---------------------------------------------------------------------------
* This source file contains the following functions:
*
*
* $Header: /home/devolder/.cvs/wince/DRIVERS/DISPLAY/au1100lcd/line.cpp,v 1.1 2002/02/14 20:48:52 devolder Exp $
*
* Initial version. (Cindy Y.)
*
\*==========================================================================*/
// Copyright (c) 2002 BSQUARE Corporation. All rights reserved.
#if 0
// Sample MGDI driver (for Epson Graphics Chips)
#include "precomp.h"
#include "mode.h"
//////////////////////////////////////////////////////////////////////////////////////
SCODE Epson::Line(
GPELineParms *pLineParms,
EGPEPhase phase )
{
pLineParms->pLine = (SCODE (GPE::*)(struct GPELineParms * )) MyEmulatedLine;
if (m_fAltDisplay && !(m_fActiveFlags2 & mfHWBLT) )
return S_OK;
if ( m_fAltDisplay && (m_aModes[m_Entry].Hdr.Flags & mfROTATED) )
return S_OK;
if (phase == gpeSingle || phase == gpePrepare) //follow S3 Virge CE 3.0 sample???
// if ( phase == gpePrepare)
{
if ( pLineParms->pDst->InVideoMemory() && (m_aModes[m_Entry].Hdr.Flags & mfHWBLT) && pLineParms->mix == 0x0d0d ) //R2_COPYPEN=0x0d: P
pLineParms->pLine = (SCODE (GPE::*)(struct GPELineParms *)) AcceleratedSolidLine;
}
return S_OK;
}
SCODE Epson::MyEmulatedLine(
GPELineParms *pLineParms )
{
// before any access to/from video memory, always wait for blt to be finished.
// this prevents Graphics engine and h/w blt engine access the same video memory.
WaitForHwBltDone();
EmulatedLine( pLineParms );
return S_OK;
}
SCODE Epson::AcceleratedSolidLine( GPELineParms *pLineParms )
{
#ifdef SURFACE_HEAP
int adjustTop = 0;
int adjustLeft = 0;
#else
int adjustTop = ((EpsonSurf *)(pLineParms->pDst))->Top();
int adjustLeft = ((EpsonSurf *)(pLineParms->pDst))->Left();
#endif
int rectTop, rectBottom, rectRight, rectLeft;
int x1, x2, y1, y2;
// only handle horinzontal and vertical lines acceleration
if ( pLineParms->dN )
return MyEmulatedLine(pLineParms);
// If the number of pixels to light up isn't the same as the major axis this isn't the
// expected case, so emulate the line.
if ( (unsigned long) pLineParms->cPels != (pLineParms->dM >> 4) )
{
return MyEmulatedLine(pLineParms);
}
//we can only accelerate solid line.
if ( pLineParms->style != 0 )
{
return MyEmulatedLine(pLineParms);
}
//
// Determine the offsets from the start position. This depends upon the octant.
//
// LineSegment() could be merged into this code. The seperation helps keep the line
// drawing destinct from the CEPC line setup.
//
x1 = pLineParms->xStart + adjustLeft;
y1 = pLineParms->yStart + adjustTop;
//
// Clip one pixel less in the major axis.
//
switch (pLineParms->iDir)
{
// X Major
case 0:
// Setup the line
x2 = x1 + (pLineParms->dM >> 4);
y2 = y1;
// Setup coordinates registers for the line (left to right)
rectLeft = x1;
rectRight = x2 - 1;
rectTop = y1;
rectBottom = y2;
break;
case 3:
// Setup the line
x2 = x1 - (pLineParms->dM >> 4);
y2 = y1;
// Setup coordinates registers for the line (left to right)
rectLeft = x2 + 1;
rectRight = x1;
rectTop = y1;
rectBottom = y2;
break;
case 4:
// Setup the line
x2 = x1 - (pLineParms->dM >> 4);
y2 = y1;
// Setup coordinates registers for the line (left to right)
rectLeft = x2 + 1;
rectRight = x1;
rectTop = y2;
rectBottom = y1;
break;
case 7:
// Setup the line
x2 = x1 + (pLineParms->dM >> 4);
y2 = y1;
// Setup coordinates registers for the line (left to right)
rectLeft = x1;
rectRight = x2 - 1;
rectTop = y2;
rectBottom = y1;
break;
// Y Major
case 1:
// Setup the line
x2 = x1;
y2 = y1 + (pLineParms->dM >> 4);
// Setup coordinates registers for the line (left to right)
rectLeft = x1;
rectRight = x2;
rectTop = y1;
rectBottom = y2 - 1;
break;
case 2:
// Setup the line
x2 = x1;
y2 = y1 + (pLineParms->dM >> 4);
// Setup coordinates registers for the line (left to right)
rectLeft = x2;
rectRight = x1;
rectTop = y1;
rectBottom = y2 - 1;
break;
case 5:
// Setup the line
x2 = x1;
y2 = y1 - (pLineParms->dM >> 4);
// Setup coordinates registers for the line (left to right)
rectLeft = x2;
rectRight = x1;
rectTop = y2 + 1;
rectBottom = y1;
break;
case 6:
// Setup the line
x2 = x1;
y2 = y1 - (pLineParms->dM >> 4);
// Setup coordinates registers for the line (left to right)
rectLeft = x1;
rectRight = x2;
rectTop = y2 + 1;
rectBottom = y1;
break;
}
// Draw the line
LineSegment(rectLeft, rectTop, rectRight, rectBottom, (WORD) (pLineParms->solidColor), pLineParms );
return S_OK;
}
SCODE Epson::LineSegment( int x1, int y1, int x2, int y2, DWORD color, GPELineParms *pLineParms)
{
if ( x2<x1 || y2<y1 )
return S_OK;
WORD Width = (WORD) (x2 - x1) +1;
WORD Height = (WORD) (y2 - y1)+1;
WORD BltStride = pLineParms->pDst->Stride();
DWORD DstAddr;
if ( !(m_aModes[m_Entry].Hdr.Flags & mfROTATED ) )
DstAddr = y1 * BltStride + x1 * m_pMode->Bpp / 8;
else
DstAddr = (x1+1) * BltStride - (y1+Height) * m_pMode->Bpp / 8;
#ifdef SURFACE_HEAP
DstAddr += ((EpsonSurf *) (pLineParms->pDst))->OffsetInVideoMemory();
#endif
if (m_fAltDisplay)
DstAddr += DC2StartAddr;
// before any access to/from video memory, always wait for blt to be finished.
// this prevents Graphics engine & h/w blt engine access the same video memory at the same time.
WaitForHwBltDone();
if ( m_pMode->Bpp == 8 )
m_Reg[Reg::BltCtrl1] = 0x00; // FIFO depth & color depth
else
m_Reg[Reg::BltCtrl1] = 0x01; // FIFO depth & color depth
m_Reg[Reg::BltOperation] = 0x0C; // solid fill blt
//program foreground color
*(PVWORD)&m_Reg[Reg::BltFgColor0] = (WORD)(color);
//BltStride registers
*(PVWORD)&m_Reg[Reg::BltStride0] = BltStride>>1;
//Dst Start address registers
*(PVDWORD)&m_Reg[Reg::BltDstStart0] = DstAddr;
if ( !(m_aModes[m_Entry].Hdr.Flags & mfROTATED ) )
{
//Dst Width registers
*(PVWORD)&m_Reg[Reg::BltWidth0] = Width-1;
//Dst Height registers
*(PVWORD)&m_Reg[Reg::BltHeight0] = Height-1;
}
else
{
//Dst Width registers
*(PVWORD)&m_Reg[Reg::BltWidth0] = Height-1;
//Dst Height registers
*(PVWORD)&m_Reg[Reg::BltHeight0] = Width-1;
}
//start the blt
m_Reg[Reg::BltCtrl0] = 0x80;
return S_OK;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -