📄 m1b_fil.c
字号:
/*************************************************************************/
/* */
/* Copyright (c) 1997 - 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. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FLLE NAME VERSION */
/* */
/* m1b_fil.c 1.9 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* This file contains the mwFL1Bit function. */
/* */
/* AUTHOR */
/* */
/* Bob Burrill, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* None */
/* */
/* DEPENDENCIES */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* BobB 5/14/99 Fixed compiler warnings */
/* */
/*************************************************************************/
#include "meta_wnd.h"
#include "metconst.h" /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h" /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"
#include "metmacs3.h"
#include "fill_5.h"
/* Function mwFL1Bit is a special case optimization for MultiFill, monochrome
to 1 bit memory, rectangular and/or region clipping with color translation.
mwFL1Bit forms the outer processing loop for this mode which internally
dispatches to one of several other optimizations based upon the specific
rasterOp transfer mode and memory destination. */
void mwFL1Bit(blitRcd *fillRec)
{
void SolidFillM1Bit(blitRcd *fillRec);
void MonoPatternFillM1Bit(blitRcd *fillRec);
lclPortMask = fillRec->blitMask;
/* save the pattern header address here temporarily */
if (fillRec->blitPat > 1)
{ /* it's a patterned fill */
patStart = fillRec->blitPatl->patPtr[fillRec->blitPat];
MonoPatternFillM1Bit(fillRec);
return;
}
else
{
SolidFillM1Bit(fillRec);
return;
}
}
void SolidFillM1Bit(blitRcd *fillRec )
{
int Check_YX_Band(rect *bandRect, rect *blitRectPtr, rect *clipR,
int *rectCnt);
void SolidFillRectM1Bit(blitRcd *fillRec);
int Set_Up_Clip(blitRcd *clipBlit, rect *clipR, int blitMayOverlap,
int isLine);
int Fill_Clip_Region(blitRcd *fillRec, rect *fillRect);
void SetDestM1Bit(void);
void FillOXADestM1Bit(void);
void NotDestFillM1Bit(void);
void InvertDestM1Bit(void);
void QuickEnd(void);
void nuResume(grafMap *dstBmap);
rect clipR; /* Clip rect */
rect *rListPtr; /* list pointer */
int blitMayOverlap = 0; /* Set false for region clipping*/
int isLine = 0; /* Set false */
rectCnt = fillRec->blitCnt;
rListPtr = (rect *) fillRec->blitList;
dstBmap = fillRec->blitDmap;
if(fillRec->blitPat == 0)
{
if((fillRec->blitRop & 0x10) != 0)
{ /* transparent with background color is a NOP */
nuResume(dstBmap);
return;
}
pnColr = (char) fillRec->blitBack;
}
else
{
pnColr = (char) fillRec->blitFore;
}
M_PAUSE(dstBmap);
dstWidth = dstBmap->pixBytes;
shfCnt = 1; /* determine number of bits per pixel */
flipMask = 3;
shiftMask = 0x80;
firstOffset = 0x07;
pnColr = pnColr & 0x01;
dstClass = fillRec->blitRop & 0x0f;
switch (dstClass)
{ /* look up the optimization routine */
/* Memory non-transparent */
case 0: /* zREPz : src */
case 4: /* zNREPz : (NOT src) */
case 8: /* zCLEARz : 0's */
case 12: /* zSETz : 1's */
optPtr = &SetDestM1Bit;
break;
case 1: /* zORz : src OR dst */
case 2: /* zXORz : src XOR dst */
case 3: /* zNANDz : (NOT src) AND dst */
case 5: /* zNORz : (NOT src) OR dst */
case 6: /* zNXORz : (NOT src) XOR dst */
case 7: /* zANDz : src AND dst */
optPtr = &FillOXADestM1Bit;
break;
case 9: /* zORNz : src OR (NOT dst) */
case 11: /* zANDNz : src AND (NOT dst) */
case 13: /* zNORNz : (NOT src) OR (NOT dst) */
case 15: /* zNANDNz : (NOT src) AND (NOT dst) */
optPtr = &NotDestFillM1Bit;
break;
case 10: /* zNOPz : dst <NOP> */
optPtr = &QuickEnd;
break;
case 14: /* zINVERTz: (NOT dst) */
optPtr = &InvertDestM1Bit;
break;
}
/* set up clipping */
if (Set_Up_Clip(fillRec, &clipR, blitMayOverlap, isLine))
{
nuResume(dstBmap);
return;
}
while (--rectCnt >= 0 )
{
dRect = *rListPtr++;
if (clipToRectFlag != 0) /* do we need to worry about clipping */
{ /* yes, do trivial reject */
if (dRect.Xmin < clipR.Xmin) dRect.Xmin = clipR.Xmin;
if (dRect.Ymin < clipR.Ymin) dRect.Ymin = clipR.Ymin;
if (dRect.Xmax > clipR.Xmax) dRect.Xmax = clipR.Xmax;
if (dRect.Ymax > clipR.Ymax) dRect.Ymax = clipR.Ymax;
if (dRect.Ymin >= dRect.Ymax)
{ /* Check to see whether the rectangle was trivially
clipped because it was fully below the clip rect,
in which case we can discard the rest of a YX banded
blitList, or because it was fully above the clip
rect, in which case we can whiz ahead through a YX
banded blitList until we run out of rects or find a
rect that isn't fully above the clip rect. */
if (Check_YX_Band(&dRect, rListPtr, &clipR,
&rectCnt)) break;
continue;
}
if (dRect.Xmin >= dRect.Xmax) continue;
/* do we need to worry about region clipping? */
if (clipToRegionFlag != 0)
{ /* yes, decide whether to copy top->bottom
or bottom->top */
FillDrawer = &SolidFillRectM1Bit;
if (Fill_Clip_Region(fillRec, &dRect) == 0) break;
continue;
}
}
SolidFillRectM1Bit(fillRec); /* blit the rectangle */
}
nuResume(dstBmap);
return;
}
/* Set up for monocolor pattern fill. */
void MonoPatternFillM1Bit(blitRcd *fillRec )
{
int Check_YX_Band(rect *bandRect, rect *blitRectPtr, rect *clipR,
int *rectCnt);
void SolidFillRectM1Bit(blitRcd *fillRec);
int Set_Up_Clip(blitRcd *clipBlit, rect *clipR, int blitMayOverlap,
int isLine);
int Fill_Clip_Region(blitRcd *fillRec, rect *fillRect);
void MonoFillDestM1Bit(void);
void MonoFillOXADestM1Bit(void);
void NotDestMonoFillM1Bit(void);
void InvertDestM1Bit(void);
void QuickEnd(void);
void nuResume(grafMap *dstBmap);
rect clipR; /* Clip rect */
rect *rListPtr; /* list pointer */
int blitMayOverlap = 0; /* Set false for region clipping*/
int isLine = 0; /* Set false */
rectCnt = fillRec->blitCnt;
rListPtr = (rect *) fillRec->blitList;
dstBmap = fillRec->blitDmap;
pnColr = (char) fillRec->blitFore;
bkColr = (char) fillRec->blitBack;
savePat = (image *) patStart;/* retrieve the pattern header address */
ptrnData = savePat->imData;/* skip over the pattern header to
the bit pattern */
patHeight = savePat->imHeight;/* height in rows */
patWidthInBytes = savePat->imWidth >> 3;
patLength = patWidthInBytes * patHeight;
patPlaneOffset = patLength;/* distance from one plane to the next */
M_PAUSE(dstBmap);
dstWidth = dstBmap->pixBytes;
shfCnt = 1; /* determine number of bits per pixel */
flipMask = 3;
shiftMask = 0x80;
firstOffset = 0x07;
dstClass = fillRec->blitRop & 0x0f;
switch (dstClass)
{ /* look up the optimization routine */
/* Memory non-transparent */
case 0: /* zREPz : src */
case 4: /* zNREPz : (NOT src) */
case 8: /* zCLEARz : 0's */
case 12: /* zSETz : 1's */
optPtr = &MonoFillDestM1Bit;
break;
case 1: /* zORz : src OR dst */
case 2: /* zXORz : src XOR dst */
case 3: /* zNANDz : (NOT src) AND dst */
case 5: /* zNORz : (NOT src) OR dst */
case 6: /* zNXORz : (NOT src) XOR dst */
case 7: /* zANDz : src AND dst */
optPtr = &MonoFillOXADestM1Bit;
break;
case 9: /* zORNz : src OR (NOT dst) */
case 11: /* zANDNz : src AND (NOT dst) */
case 13: /* zNORNz : (NOT src) OR (NOT dst) */
case 15: /* zNANDNz : (NOT src) AND (NOT dst) */
optPtr = &NotDestMonoFillM1Bit;
break;
case 10: /* zNOPz : dst <NOP> */
optPtr = &QuickEnd;
break;
case 14: /* zINVERTz: (NOT dst) */
optPtr = &InvertDestM1Bit;
break;
}
/* modify the pen color as necessary */
switch (dstClass)
{
case 3: /* zNANDz */
case 4: /* zNREPz */
case 5: /* zNORz */
case 6: /* zNXORz */
case 13: /* zNORNz */
case 15: /* zNANDNz */
bkColr = ~bkColr; /* this has the effect of notting the
pen color for all operations during this call */
pnColr = ~pnColr;
case 0: /* zREPz */
case 1: /* zORz */
case 2: /* zXORz */
case 7: /* zANDz */
case 9: /* zORNz */
case 10: /* zNOPz */
case 11: /* zANDNz */
break;
case 8: /* zCLEARz */
bkColr = 0; /* sets all source bits to 0 */
pnColr = 0;
break;
case 12: /* zSETz */
case 14: /* zINVERTz */
bkColr = (char)-1; /* sets all source bits to 1 */
pnColr = (char)-1;
}
/* set up clipping */
if (Set_Up_Clip(fillRec, &clipR, blitMayOverlap, isLine))
{
nuResume(dstBmap);
return;
}
while (--rectCnt >= 0 )
{
dRect = *rListPtr++;
if (clipToRectFlag != 0) /* do we need to worry about clipping */
{ /* yes, do trivial reject */
if (dRect.Xmin < clipR.Xmin) dRect.Xmin = clipR.Xmin;
if (dRect.Ymin < clipR.Ymin) dRect.Ymin = clipR.Ymin;
if (dRect.Xmax > clipR.Xmax) dRect.Xmax = clipR.Xmax;
if (dRect.Ymax > clipR.Ymax) dRect.Ymax = clipR.Ymax;
if (dRect.Ymin >= dRect.Ymax)
{ /* Check to see whether the rectangle was trivially
clipped because it was fully below the clip rect,
in which case we can discard the rest of a YX banded
blitList, or because it was fully above the clip
rect, in which case we can whiz ahead through a YX
banded blitList until we run out of rects or find a
rect that isn't fully above the clip rect. */
if (Check_YX_Band(&dRect, rListPtr, &clipR,
&rectCnt)) break;
continue;
}
if (dRect.Xmin >= dRect.Xmax) continue;
/* do we need to worry about region clipping? */
if (clipToRegionFlag != 0)
{ /* yes, decide whether to copy top->bottom
or bottom->top */
FillDrawer = &SolidFillRectM1Bit;
if (Fill_Clip_Region(fillRec, &dRect) == 0) break;
continue;
}
}
SolidFillRectM1Bit(fillRec); /* blit the rectangle */
}
nuResume(dstBmap);
return;
}
/* Function SolidFillRect fills the rectangle in memory */
void SolidFillRectM1Bit(blitRcd *blitRec)
{
lineCntM1 = dRect.Ymax - dRect.Ymin - 1;
dstBgnByte = (dRect.Xmin >> flipMask);
byteCntM1 = dRect.Xmax - dRect.Xmin - 1;
pnColr = pnColr & 0x01;
/* BobB 5/14/99 - corrected the following line to remove a compiler warning
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -