📄 regclip.c
字号:
/* remember bottom edge of this YX band */
bandYmax = regionRectPtr->Ymax;
do { /* clipping and drawing loop */
/* set Y extent of dest rect, clipped to the Y extent of this YX band */
if (bRect.Ymin < regionRectPtr->Ymin)
{
dYminTemp = regionRectPtr->Ymin;
sYminTemp = bsRect.Ymin - (bRect.Ymin - dYminTemp);
}
else
{
dYminTemp = bRect.Ymin;
sYminTemp = bsRect.Ymin;
}
if (bRect.Ymax > regionRectPtr->Ymax)
{
dYmaxTemp = regionRectPtr->Ymax;
sYmaxTemp = bsRect.Ymax - (bRect.Ymax - dYmaxTemp);
}
else
{
dYmaxTemp = bRect.Ymax;
sYmaxTemp = bsRect.Ymax;
}
/* skip region rects in this band that are fully to the right of
dest rect */
while (bRect.Xmax <= regionRectPtr->Xmin)
{
regionRectPtr--;
/* switch to next band if we just changed bands */
if (regionRectPtr->Ymax != bandYmax) goto BandBottom;
}
/* start clipping and drawing */
while (bRect.Xmin < regionRectPtr->Xmax)
{
/* set the Y extent of the rectangle to draw (base rect clipped
to YX band) */
dRect.Ymin = dYminTemp;
dRect.Ymax = dYmaxTemp;
/* set the Y extent of the rectangle from which to draw (base
source rect clipped to YX band) */
sRect->Ymin = sYminTemp;
sRect->Ymax = sYmaxTemp;
if (bRect.Xmax > regionRectPtr->Xmax)
{
dRect.Xmax = regionRectPtr->Xmax;
sRect->Xmax = bsRect.Xmax - (bRect.Xmax - dRect.Xmax);
}
else
{
dRect.Xmax = bRect.Xmax;
sRect->Xmax = bsRect.Xmax;
}
if (bRect.Xmin < regionRectPtr->Xmin)
{
dRect.Xmin = regionRectPtr->Xmin;
sRect->Xmin = bsRect.Xmin - (bRect.Xmin - dRect.Xmin);
}
else
{
dRect.Xmin = bRect.Xmin;
sRect->Xmin = bsRect.Xmin;
}
/* fill the dest rect clipped to the region rect */
FillDrawer(fcRec);
regionRectPtr--;
/* switch to next band if we just changed bands */
if (regionRectPtr->Ymax != bandYmax) goto BandBottom;
}
/* skip region rects in this band that are fully to the left of
dest rect; basically, scan to the next YX band */
do {
regionRectPtr--;
} while (regionRectPtr->Ymax == bandYmax);
/* continue as long as the dest rect's bottom is above the region
rect's bottom (they overlap vertically) */
BandBottom:
/* remember bottom edge of this YX band */
bandYmax = regionRectPtr->Ymax;
} while (bRect.Ymin < bandYmax);
#endif
return;
}
/* Function Fill_Clip_Region_BT_RL fills a rectangle, clipped to a
region, processing the region from bottom->top, and right->left within
each band for the non-blit routines.
Parameters:
fcRec = pointer to blitRcd
fillRect = pointer rect to draw, already clipped to the clip rect
The following regclipv.h common variables are required:
FillDrawer = routine to call to draw each region-clipped rect
nextRegionPtrB must be set to the point at which to start scanning
backward through the region rect list (on exit, updated to start
point for scanning next time)
bXmin, bYmin, bXmax, bYmax, bandYmin, dYminTemp, dYmaxTemp */
void Fill_Clip_Region_BT_RL(blitRcd *fcRec, rect *fillRect)
{
#ifndef NO_REGION_CLIP
rect *regionRectPtr;
regionRectPtr = nextRegionPtrB; /* point to the first region rect at
which to start clipping */
/* Find a region band not entirely below dest rect. */
while (fillRect->Ymax <= regionRectPtr->Ymin)
{
regionRectPtr--;
}
/* Skip if the band is entirely above dest rect. */
if (fillRect->Ymin >= regionRectPtr->Ymax) return;
/* So long as we're in a band that overlaps vertically with destRect,
scan across from the right until we find a region rect that overlaps
horizontally or we move to another band, then draw destRect clipped
to each region rect until we either find a region rect that doesn't
overlap or we move to another band, then scan until we move to another
band. If the next band isn't past the top of destRect, repeat. */
bRect = *fillRect; /* make a copy of dest rect, because we're going
to alter the standard copy each time we clip it
to a region rect */
/* remember bottom edge of this YX band */
bandYmax = regionRectPtr->Ymax;
do { /* clipping and drawing loop */
/* set Y extent of dest rect, clipped to the Y extent of this YX band */
if (bRect.Ymin < regionRectPtr->Ymin)
{
dYminTemp = regionRectPtr->Ymin;
}
else
{
dYminTemp = bRect.Ymin;
}
if (bRect.Ymax > regionRectPtr->Ymax)
{
dYmaxTemp = regionRectPtr->Ymax;
}
else
{
dYmaxTemp = bRect.Ymax;
}
/* skip region rects in this band that are fully to the right of
dest rect */
while (bRect.Xmax <= regionRectPtr->Xmin)
{
regionRectPtr--;
/* switch to next band if we just changed bands */
if (regionRectPtr->Ymax != bandYmax) goto BandBottom;
}
/* start clipping and drawing */
while (bRect.Xmin < regionRectPtr->Xmax)
{
/* set the Y extent of the rectangle to draw (base rect clipped
to YX band) */
dRect.Ymin = dYminTemp;
dRect.Ymax = dYmaxTemp;
if (bRect.Xmax > regionRectPtr->Xmax)
{
dRect.Xmax = regionRectPtr->Xmax;
}
else
{
dRect.Xmax = bRect.Xmax;
}
if (bRect.Xmin < regionRectPtr->Xmin)
{
dRect.Xmin = regionRectPtr->Xmin;
}
else
{
dRect.Xmin = bRect.Xmin;
}
/* fill the dest rect clipped to the region rect */
FillDrawer(fcRec);
regionRectPtr--;
/* switch to next band if we just changed bands */
if (regionRectPtr->Ymax != bandYmax) goto BandBottom;
}
/* skip region rects in this band that are fully to the left of
dest rect; basically, scan to the next YX band */
do {
regionRectPtr--;
} while (regionRectPtr->Ymax == bandYmax);
/* continue as long as the dest rect's bottom is above the region
rect's bottom (they overlap vertically) */
BandBottom:
/* remember bottom edge of this YX band */
bandYmax = regionRectPtr->Ymax;
} while (bRect.Ymin < bandYmax);
#endif
return;
}
/* Function Blit_Clip_Region_BT_LR fills/blits a rectangle, clipped to a
region, processing the region from bottom->top, and left->right within
each band for the blit routines.
Parameters:
fcRec = pointer to blitRcd
fillRect = pointer rect to draw, already clipped to the clip rect
sRect = pointer rect to draw from, already clipped to the clip rect; Ymin
must be less than 0x7fff
The following regclipv.h common variables are required:
FillDrawer = routine to call to draw each region-clipped rect
nextRegionPtrB must be set to the point at which to start scanning
backward through the region rect list (on exit, updated to start
point for scanning next time)
tempRegionPtr, bXmin, bYmin, bXmax, bYmax, bandYmin, dYminTemp, dYmaxTemp,
bsXmin, bsYmin, bsXmax and bsYmax, sYminTemp and sYmaxTemp */
void Blit_Clip_Region_BT_LR(blitRcd *fcRec, rect *fillRect, rect *sRect)
{
#ifndef NO_REGION_CLIP
rect *regionRectPtr;
regionRectPtr = nextRegionPtrB; /* point to the first region rect at
which to start clipping */
/* Find a region band not entirely below dest rect. */
while (fillRect->Ymax <= regionRectPtr->Ymin)
{
regionRectPtr--;
}
/* Skip if the band is entirely above dest rect. */
if (fillRect->Ymin >= regionRectPtr->Ymax) return;
/* Scan across from the right until we find the start of the band, then
so long as we're in a band that overlaps vertically with destRect, scan
back from there to the right until we find a region rect that overlaps
horizontally or we move to another band, then draw destRect clipped
to each region rect until we either find a region rect that doesn't
overlap or we move to another band, then scan until we move to another
band. If the next band isn't past the top of destRect, repeat. */
bRect = *fillRect; /* make a copy of dest rect, because we're going
to alter the standard copy each time we clip it
to a region rect */
bsRect = *sRect; /* likewise, make a copy of the source rect */
do { /* clipping and drawing loop */
/* remember bottom edge of this YX band */
bandYmin = regionRectPtr->Ymin;
/* set Y extent of dest rect, clipped to the Y extent of this YX band */
if (bRect.Ymin < regionRectPtr->Ymin)
{
dYminTemp = regionRectPtr->Ymin;
sYminTemp = bsRect.Ymin - (bRect.Ymin - dYminTemp);
}
else
{
dYminTemp = bRect.Ymin;
sYminTemp = bsRect.Ymin;
}
if (bRect.Ymax > regionRectPtr->Ymax)
{
dYmaxTemp = regionRectPtr->Ymax;
sYmaxTemp = bsRect.Ymax - (bRect.Ymax - dYmaxTemp);
}
else
{
dYmaxTemp = bRect.Ymax;
sYmaxTemp = bsRect.Ymax;
}
/* Find the left end of the YX band by scanning to the left until
the band changes. Actually overscans by one, ending up pointing
to the rightmost rect in the next YX band. */
do{
regionRectPtr--;
} while (regionRectPtr->Ymin == bandYmin);
tempRegionPtr = regionRectPtr; /* remember where the next band
starts */
regionRectPtr++; /* point to the leftmost region rect in the
current YX band */
/* skip region rects in this band that are fully to the left of
dest rect */
while (bRect.Xmin >= regionRectPtr->Xmax)
{
regionRectPtr++;
/* switch to next band if we just changed bands */
if (regionRectPtr->Ymin != bandYmin) goto BandBottom;
}
/* start clipping and drawing */
while (bRect.Xmax > regionRectPtr->Xmin)
{
/* set the Y extent of the rectangle to draw (base rect clipped
to YX band) */
dRect.Ymin = dYminTemp;
dRect.Ymax = dYmaxTemp;
/* set the Y extent of the rectangle from which to draw (base
source rect clipped to YX band) */
sRect->Ymin = sYminTemp;
sRect->Ymax = sYmaxTemp;
if (bRect.Xmax > regionRectPtr->Xmax)
{
dRect.Xmax = regionRectPtr->Xmax;
sRect->Xmax = bsRect.Xmax - (bRect.Xmax - dRect.Xmax);
}
else
{
dRect.Xmax = bRect.Xmax;
sRect->Xmax = bsRect.Xmax;
}
if (bRect.Xmin < regionRectPtr->Xmin)
{
dRect.Xmin = regionRectPtr->Xmin;
sRect->Xmin = bsRect.Xmin - (bRect.Xmin - dRect.Xmin);
}
else
{
dRect.Xmin = bRect.Xmin;
sRect->Xmin = bsRect.Xmin;
}
/* fill the dest rect clipped to the region rect */
FillDrawer(fcRec);
regionRectPtr++;
/* switch to next band if we just changed bands */
if (regionRectPtr->Ymin != bandYmin) goto BandBottom;
}
/* skip region rects in this band that are fully to the right of
dest rect; basically, scan to the next YX band */
BandBottom:
regionRectPtr = tempRegionPtr; /* point to the rightmost end of
the next YX band */
/* continue as long as the dest rect's top is above the region
rect's bottom (they overlap vertically) */
} while (bRect.Ymin < regionRectPtr->Ymax);
#endif
return;
}
/* Function Fill_Clip_Region_BT_LR fills a rectangle, clipped to a
region, processing the region from bottom->top, and left->right within
each band for the non-blit routines.
Parameters:
fcRec = pointer to blitRcd
fillRect = pointer rect to draw, already clipped to the clip rect
The following regclipv.h common variables are required:
FillDrawer = routine to call to draw each region-clipped rect
nextRegionPtrB must be set to the point at which to start scanning
backward through the region rect list (on exit, updated to start
point for scanning next time)
tempRegionPtr, bXmin, bYmin, bXmax, bYmax, bandYmin, dYminTemp,
dYmaxTemp */
void Fill_Clip_Region_BT_LR(blitRcd *fcRec, rect *fillRect)
{
#ifndef NO_REGION_CLIP
rect *regionRectPtr;
regionRectPtr = nextRegionPtrB; /* point to the first region rect at
which to start clipping */
/* Find a region band not entirely below dest rect. */
while (fillRect->Ymax <= regionRectPtr->Ymin)
{
regionRectPtr--;
}
/* Skip if the band is entirely above dest rect. */
if (fillRect->Ymin >= regionRectPtr->Ymax) return;
/* Scan across from the right until we find the start of the band, then
so long as we're in a band that overlaps vertically with destRect, scan
back from there to the right until we find a region rect that overlaps
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -