📄 reg02.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 */
/* */
/* REG02.c 1.9 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* This file contains the ClipRegion function. */
/* */
/* 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"
/*ClipRegion() enables the specified region as the current clip region.
Once a region is made the current clipping region (via ClipRegion() ),
the user must not deallocate that memory or modify the region until
that region is no longer the current clip region. MetaWINDOW simply
maintains a pointer to the current clip region, and uses the rects
directly out of the region, so the region must be available for
however long it is the clip region, and should not be modifed in any
way during that time.
--------------------------------------------------------------
Possible enhancements:
=====
Could check to see if the rfRect flag is set; if it is, the region is
rectangular, so don't do regions.
In this case, the normal clip rect could be set to the intersection
of the normal clip rect and the region bounding rect, and region
clipping wouldn't be turned on at all. This would make clipping
happen *much* faster. However, it would require setting a flag to
indicate the "square region" condition; if the user set a new clip
rect, the intersection of the new clip rect and the region rect would
have to be recalculated, and if the user set a new region, the normal
clip rect would have to be restored. I guess there aren't going to
be too many rectangular regions anyway, so no harm done if we skip
this for now; it just seemed like a shame to do region clipping when
it's really only rectangular clipping.
=====
Validating the region's YX band list in ClipRegion().
This would consist of checking that the rect at the address
[rgnList]-(size rect) is a top sentinel (all fields == rgnBOS), and
the rect at address [rgnListEnd]+(size rect) is a bottom sentinel
(all fields == rgnEOS). Then, check that for all rects starting at
[rgnList] and continuing through the rect at [rgnListEnd] */
void ClipRegion(region *RGN)
{
rect *ptr;
short temp;
if(RGN != 0)
{ /* <<make sure region isn't empty first!>> */
ptr = RGN->rgnList - 1;
if(ptr->Ymax != rgnBOS)
return;
ptr = RGN->rgnListEnd + 1;
if(ptr->Ymin != rgnEOS)
return;
temp = grafPort.portFlags | pfRgnClip;
}
else
temp = grafPort.portFlags & (~pfRgnClip);
/* It's a valid region, turn on the grafPort */
thePort->portRegion = RGN;
grafPort.portRegion = RGN;
thePort->portFlags = temp;
grafPort.portFlags = temp;
/* Set the default blit record region clipping info */
grafBlit.blitRegn = RGN;
if((temp & pfRgnClip) != 0)
{
grafBlit.blitFlags = grafBlit.blitFlags | bfClipRegn;
}
else
{
grafBlit.blitFlags = grafBlit.blitFlags & (~bfClipRegn);
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -