📄 lcd_lin.c
字号:
/*************************************************************************/
/* */
/* Copyright (c) 1999 Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
/* subject matter of this material. All manufacturing, reproduction, */
/* use, and sales rights pertaining to this subject matter are governed */
/* by the license agreement. The recipient of this software implicitly */
/* accepts the terms of the license. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* lcd_lin.c 1.1 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* This file contains the thin line drawing functions for the LCD. */
/* */
/* AUTHOR */
/* */
/* Robert G. Burrill, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* None */
/* */
/* DEPENDENCIES */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* BobB 5/7/98 Made speed improvements */
/* BobB 6/17/98 Removed lclPenColor since it is */
/* already global */
/* */
/*************************************************************************/
#include "meta_wnd.h"
#include "metconst.h" /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h" /* MetaWINDOW Port & Bitmap Definitions */
#include "metaproc.h"
#include "grafdata.h"
#include "blit_5.h"
/* Function mwLILCD is a special case optimization for thin line
drawing to LCD memory destinations, rectangular and/or region
clipping. */
void mwLILCD(blitRcd *lineRec)
{
void ClipAndDrawEntry(void);
int Set_Up_Clip(blitRcd *clipBlit, rect *clipR, int blitMayOverlap,
int isLine);
int Line_Clip_Region(int rectCnt, lineS *destRect);
void nuResume(grafMap *argGRAFMAP);
void IURTable(void);
void IMRTable(void);
void IMOTable(void);
void IUXTable(void);
void IMXTable(void);
void IMATable(void);
void IMO_NDTable(void);
void IMA_NDTable(void);
void QuickEnd(void);
lineS *listPtr; /* Pointer to line to draw */
int blitMayOverlap = 0; /* Set false */
int isLine = 1; /* Set true */
/* BobB 6/17/98 - removed the following line since it is global
byte lclPenColor; */ /* pen color */
/* Table used to NOT the source color according to raster op. */
byte FlipTable[16] = {0, 0, 0, 0xff,
0xff, 0xff, 0xff, 0,
0, 0, 0, 0,
0, 0xff, 0, 0xff};
/* Table used to force the source color to 0xff according to raster op. */
byte ForceTableOr[16] = {0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0xff, 0, 0xff, 0};
/* Table used to force the source color to 0 according to raster op. */
byte ForceTableAnd[16] = {0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff};
/* set up the rectangular/region clip info */
if (Set_Up_Clip(lineRec, &cRect, blitMayOverlap, isLine)) return;
/* do we need to worry about clipping at all*/
if (clipToRectFlag == 0)
{ /* no--valid coordinates are guaranteed at a higher level */
cRect.Xmax--; /* the clipping code expects an old-style
Metawindow clip rect */
cRect.Ymax--;
}
else
{ /* yes, copy the clip rect to the base, unchanging clip rect */
bcXmin = cRect.Xmin;
bcYmin = cRect.Ymin;
bcXmax = cRect.Xmax - 1;
bcYmax = cRect.Ymax - 1;
}
listPtr = (lineS *) lineRec->blitList; /* set up local variables */
rectCnt = lineRec->blitCnt;
lclPortMask = lineRec->blitMask;
dstClass = lineRec->blitRop;
if (lineRec->blitPat == 0) /* pattern 0? */
{ /* yes, use background color */
if (dstClass & 0x10) return; /* done if transparent */
lclPenColor = (byte) lineRec->blitBack;
}
else
{ /* pattern 1 is the only other possibility */
lclPenColor = (byte) lineRec->blitFore;
}
dstClass = dstClass & 0x0f; /* we don't care about transparency */
lclPenColor = lclPenColor ^ FlipTable[dstClass]; /* NOT the
color if appropriate */
lclPenColor = lclPenColor | ForceTableOr[dstClass]; /* make
the color 0xff if appropriate */
lclPenColor = lclPenColor & ForceTableAnd[dstClass]; /* make
the color 0 if appropriate */
dstBmap = lineRec->blitDmap;
M_PAUSE(dstBmap); /* lock grafMap */
dstWidth = dstBmap->pixBytes;
rowTablePtr[1] = (long *) dstBmap->mapTable[0];
switch (dstClass)
{ /* look up the optimization routine */
/* LCD non-transparent */
case 0: /* zREPz : src */
case 4: /* zNREPz : (NOT src) */
case 8: /* zCLEARz : 0's */
case 12: /* zSETz : 1's */
if (lclPortMask == -1)
{ /* unmasked */
optPtr = &IURTable;
}
else
{ /* masked */
optPtr = &IMRTable;
}
break;
case 1: /* zORz : src OR dst */
case 5: /* zNORz : (NOT src) OR dst */
optPtr = &IMOTable;
break;
case 2: /* zXORz : src XOR dst */
case 6: /* zNXORz : (NOT src) XOR dst */
case 14: /* zINVERTz: (NOT dst) */
if (lclPortMask == -1)
{ /* unmasked */
optPtr = &IUXTable;
}
else
{ /* masked */
optPtr = &IMXTable;
}
break;
case 3: /* zNANDz : (NOT src) AND dst */
case 7: /* zANDz : src AND dst */
optPtr = &IMATable;
break;
case 9: /* zORNz : src OR (NOT dst) */
case 13: /* zNORNz : (NOT src) OR (NOT dst) */
optPtr = &IMO_NDTable;
break;
case 10: /* zNOPz : dst <NOP> */
optPtr = &QuickEnd;
break;
case 11: /* zANDNz : src AND (NOT dst) */
case 15: /* zNANDNz : (NOT src) AND (NOT dst) */
optPtr = &IMA_NDTable;
break;
}
if (clipToRegionFlag != 0)
{ /* handle region clipping in a separate loop */
LineDrawer = &ClipAndDrawEntry;
Line_Clip_Region(rectCnt, listPtr);
nuResume(dstBmap);
return;
}
while (rectCnt-- > 0)
{ /* Main line-drawing loop. */
dRect.Xmin = listPtr->lStart.X;
dRect.Ymin = listPtr->lStart.Y;
dRect.Xmax = listPtr->lEnd.X;
dRect.Ymax = listPtr->lEnd.Y;
drawStat = (char) listPtr->flStat;
listPtr++;
ClipAndDrawEntry(); /* clip and draw the line */
}
nuResume(dstBmap);
return;
}
/* BobB 5/7/98 - moved function ClipAndDrawEntry to memory driver */
#define IMRYMLR IMRV
#define IMRXMLR IMRH
#define IMRDLR IMRH
#define IMRXMRL IMRDRL
#define IMXYMLR IMXV
#define IMXXMLR IMXH
#define IMXDLR IMXH
#define IMXXMRL IMXDRL
#define IMOYMLR IMOV
#define IMOXMLR IMOH
#define IMODLR IMOH
#define IMOXMRL IMODRL
#define IMOYMLR_ND IMOV_ND
#define IMOXMLR_ND IMOH_ND
#define IMODLR_ND IMOH_ND
#define IMOXMRL_ND IMODRL_ND
#define IMAYMLR IMAV
#define IMAXMLR IMAH
#define IMADLR IMAH
#define IMAXMRL IMADRL
#define IMAYMLR_ND IMAV_ND
#define IMAXMLR_ND IMAH_ND
#define IMADLR_ND IMAH_ND
#define IMAXMRL_ND IMADRL_ND
void IURTable(void)
{
void IURYMRL(void);
void IURV(void);
void IURYMLR(void);
void IURDLR(void);
void IURXMLR(void);
void IURH(void);
void IURDRL(void);
void IURXMRL(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
IURYMRL();
break;
case 1:
IURV();
break;
case 2:
IURYMLR();
break;
case 3:
IURDLR();
break;
case 4:
IURXMLR();
break;
case 5:
IURH();
break;
case 6:
IURDRL();
break;
case 7:
IURXMRL();
break;
}
return;
}
void IMRTable(void)
{
void IMRYMRL(void);
void IMRV(void);
void IMRYMLR(void);
void IMRDLR(void);
void IMRXMLR(void);
void IMRH(void);
void IMRDRL(void);
void IMRXMRL(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
IMRYMRL();
break;
case 1:
IMRV();
break;
case 2:
IMRYMLR();
break;
case 3:
IMRDLR();
break;
case 4:
IMRXMLR();
break;
case 5:
IMRH();
break;
case 6:
IMRDRL();
break;
case 7:
IMRXMRL();
break;
}
return;
}
void IMOTable(void)
{
void IMOYMRL(void);
void IMOV(void);
void IMOYMLR(void);
void IMODLR(void);
void IMOXMLR(void);
void IMOH(void);
void IMODRL(void);
void IMOXMRL(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
IMOYMRL();
break;
case 1:
IMOV();
break;
case 2:
IMOYMLR();
break;
case 3:
IMODLR();
break;
case 4:
IMOXMLR();
break;
case 5:
IMOH();
break;
case 6:
IMODRL();
break;
case 7:
IMOXMRL();
break;
}
return;
}
void IUXTable(void)
{
void IUXYMRL(void);
void IUXV(void);
void IUXYMLR(void);
void IUXDLR(void);
void IUXXMLR(void);
void IUXH(void);
void IUXDRL(void);
void IUXXMRL(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
IUXYMRL();
break;
case 1:
IUXV();
break;
case 2:
IUXYMLR();
break;
case 3:
IUXDLR();
break;
case 4:
IUXXMLR();
break;
case 5:
IUXH();
break;
case 6:
IUXDRL();
break;
case 7:
IUXXMRL();
break;
}
return;
}
void IMXTable(void)
{
void IMXYMRL(void);
void IMXV(void);
void IMXYMLR(void);
void IMXDLR(void);
void IMXXMLR(void);
void IMXH(void);
void IMXDRL(void);
void IMXXMRL(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
IMXYMRL();
break;
case 1:
IMXV();
break;
case 2:
IMXYMLR();
break;
case 3:
IMXDLR();
break;
case 4:
IMXXMLR();
break;
case 5:
IMXH();
break;
case 6:
IMXDRL();
break;
case 7:
IMXXMRL();
break;
}
return;
}
void IMATable(void)
{
void IMAYMRL(void);
void IMAV(void);
void IMAYMLR(void);
void IMADLR(void);
void IMAXMLR(void);
void IMAH(void);
void IMADRL(void);
void IMAXMRL(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
IMAYMRL();
break;
case 1:
IMAV();
break;
case 2:
IMAYMLR();
break;
case 3:
IMADLR();
break;
case 4:
IMAXMLR();
break;
case 5:
IMAH();
break;
case 6:
IMADRL();
break;
case 7:
IMAXMRL();
break;
}
return;
}
void IMO_NDTable(void)
{
void IMOYMRL_ND(void);
void IMOV_ND(void);
void IMOYMLR_ND(void);
void IMODLR_ND(void);
void IMOXMLR_ND(void);
void IMOH_ND(void);
void IMODRL_ND(void);
void IMOXMRL_ND(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
IMOYMRL_ND();
break;
case 1:
IMOV_ND();
break;
case 2:
IMOYMLR_ND();
break;
case 3:
IMODLR_ND();
break;
case 4:
IMOXMLR_ND();
break;
case 5:
IMOH_ND();
break;
case 6:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -