📄 reg10.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. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* REG10.c 1.9 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* This file contains the OpenRegion, CloseRegion and mwRCR */
/* functions. */
/* */
/* AUTHOR */
/* */
/* Giac Dinh, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* None */
/* */
/* DEPENDENCIES */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* */
/*************************************************************************/
#include "meta_wnd.h"
#include "metconst.h" /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h" /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"
#include "metmacs3.h"
/* Function OpenRegion allocates a capture buffer and re-vectors the fill
drawing primitive of the active grafMap to a routine that captures the
rectangle lists (passed to these primitives) to the capture buffer.
Lines are forced wide such that they will always generate rect lists that
call the filler. */
void OpenRegion( void )
{
void mwRCR();
void mwLIT(blitRcd *LINEREC);
void *GrafAlloc(int memSize);
short grafErrValue;
/* Test for already opened region */
if((gFlags & gfRgnOpen) != 0)
{
grafErrValue = (short) (c_OpenRegi + c_RgnOflow);
nuGrafErr(grafErrValue);
return;
}
/* Find how big of a capture buffer we can get */
regCapPtr = (rect *) GrafAlloc(0x8000);
/* Test allocate pointer for null */
if(regCapPtr == 0)
{
grafErrValue =(short) (c_OpenRegi + c_OutofMem);
nuGrafErr(grafErrValue);
return;
}
regCapSize = 0x8000;
regCapNdx = 0;
/* Replace fill prim with the capture processor */
regSaveFill = grafPort.portMap->prFill;
grafPort.portMap->prFill = mwRCR;
/* Force lines to go wide so they will call the filler */
regPenFlags = grafPort.pnFlags;
if((regPenFlags & pnSizeFlg) == 0)
{
linePattIDV = (long) mwLIT;
grafPort.pnSize.X = 1;
grafPort.pnSize.Y = 1;
grafPort.pnFlags = (grafPort.pnFlags | pnSizeFlg);
/* refresh current line style vector */
SETLINESTYLE(grafPort.pnFlags);
}
gFlags = (gFlags | gfRgnOpen);
return;
}
/* Function mwRCR fills capture */
void mwRCR(blitRcd *BlitRec)
{
short tem;
short grafErrValue;
rect *regRectPtr;
rect *regBlitPtr;
tem = (short) (regCapNdx + (BlitRec->blitCnt << 3));
if(tem > regCapSize )
{
grafErrValue = (short) (c_OpenRegi + c_RgnOflow);
nuGrafErr(grafErrValue);
return;
}
/* move the data */
regRectPtr = (rect *) ((long)regCapPtr + regCapNdx);
regCapNdx = tem;
regBlitPtr = (rect *) BlitRec->blitList;
for (tem = 0; tem < BlitRec->blitCnt; tem++)
{
*regRectPtr++ = *regBlitPtr++;
}
return;
}
/* Function CloseRegion allocates a region buffer, converts the capture buffer to the
region buffer, deallocates the capture buffer, and restores the fill
and line drawing of the active grafMap. It returns a pointer to the allocated
region buffer that the user should deallocate via GrafFree when they no longer
need it. */
region *CloseRegion( void )
{
unsigned int mwMergeRegion (int numRects1, rect *rectList1,
int numRects2, rect *rectList2,
int sizeRGN, region *destRGN, int rgnOP );
void *GrafAlloc(int memSize);
void GrafFree(void *freePtr);
void mwRLSRT(int numRects, rect *srcRects, rect *destRects);
int regSize;
region *regPtr;
short grafErrValue;
if((gFlags & gfRgnOpen) == 0)
{
grafErrValue = (short) (c_CloseReg + c_RgnOflow);
nuGrafErr(grafErrValue);
return(0);
}
/* Restore grafMap operations */
/* If the pen was thin, store to the thin pen */
if((regPenFlags & pnSizeFlg) == 0)
{
grafPort.pnFlags = (grafPort.pnFlags & ~pnSizeFlg);
grafPort.pnSize.X = 0;
grafPort.pnSize.Y = 0 ;
thePort->pnFlags = (thePort->pnFlags & ~pnSizeFlg);
thePort->pnSize.X = 0;
thePort->pnSize.Y = 0 ;
/* Reset current line vector */
SETLINESTYLE(grafPort.pnFlags);
}
/* Pen is wide */
grafPort.portMap->prFill = regSaveFill;
/* sort capture buffer rect list in place */
regCapNdx = regCapNdx >> 3;
globalLevel--; /* already in global */
mwRLSRT(regCapNdx, regCapPtr, 0 );
globalLevel++;
/* Compute region size */
regSize = mwMergeRegion((int)regCapNdx, regCapPtr, 0, 0, 0, 0, 0);
/* Allocate region buffer */
regPtr = (region *) GrafAlloc(regSize);
if(regPtr == 0)
{
grafErrValue = (short) (c_CloseReg + c_OutofMem);
nuGrafErr(grafErrValue);
return(0);
}
/* Convert rect list to region */
mwMergeRegion((int)regCapNdx, regCapPtr, 0, 0, regSize, regPtr , 0);
/* Close up, free capture buffer */
GrafFree(regCapPtr);
/* Clear open region flag */
gFlags = gFlags & ~gfRgnOpen;
/* Return region buffer pointer */
return(regPtr);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -