MaskWithColor.mesa
Copyright Ó 1989, 1991 by Xerox Corporation. All rights reserved.
Russ Atkinson (RRA) August 4, 1989 6:00:06 pm PDT
MaskWithColor: DEFINITIONS = BEGIN
Ptr: TYPE = LONG POINTER TO WORD;
bitsPerUnit: NAT = BITS[UNIT];
bitsPerWord: NAT = BITS[WORD];
unitsPerWord: NAT = UNITS[WORD];
BitOffset: TYPE = [0..bitsPerWord);
LogBitOffset: TYPE = [0..BITS[BitOffset]];
RunSeq: TYPE = LONG POINTER TO RunSeqRep;
RunSeqRep: TYPE = RECORD [PACKED SEQUENCE len: CARDINAL OF RunByte];
RunByte: TYPE = WORD8 MACHINE DEPENDENT RECORD [
count: RunCount, -- the number of pixels to color or skip
color: BOOL,  -- color => store the color, else skip
last: BOOL  -- last => last run in the line
];
RunCount: TYPE = [1..64];
LongRunSeq: TYPE = LONG POINTER TO LongRunSeqRep;
LongRunSeqRep: TYPE = RECORD [PACKED SEQUENCE len: CARDINAL OF LongRun];
LongRun: TYPE = MACHINE DEPENDENT RECORD [
fMin: CARD16, -- fMin is relative to the line start
lastRun: BOOL, -- lastRun is TRUE for the last run in the line
fSize: NAT15]; -- fSize is the length of the run
Must be compatible with the runs variant of ImagerMaskCache
MakeColorWord: PROC [sampleColor: WORD, logDepth: LogBitOffset] RETURNS [WORD];
Takes a pixel value (in the low-order bits) and propagates it through the word as required by other operations, returning the filled word.
StoreWithColorMask: PROC [
maskBase: Ptr, maskOffset: CARDINAL, maskWpl: CARDINAL,
dstBase: Ptr, dstOffset: CARDINAL, dstWpl: CARDINAL,
height: CARDINAL, width: CARDINAL, logDepth: LogBitOffset, colorWord: WORD];
In the rectangle given by width & height, for each "one" in the mask (specified by maskBase, maskOffset, and maskWpl), the specified color is stored into the corresponding pixel in the the destination (specified by dstBase, dstOffset, and dstWpl).
Argument interpretations
maskBase: a word pointer to the base of the mask
maskOffset: a bit offset into the mask
maskWpl: the # of words between lines in the mask
dstBase: a word pointer to the base of the destination
dstOffset: a pixel index into the destination
dstWpl: a # of words between lines in the destination
height: the # of lines in the rectangle to color
width: the # of pixels per line in the rectangle to color
logDepth: 2**logDepth = the number of bits in a pixel
colorWord: a word filled with the color (as by MakeColorWord)
StoreWithColorRuns: PROC [
mask: RunSeq,
dstBase: Ptr, dstOffset: CARDINAL, dstWpl: CARDINAL,
logDepth: LogBitOffset, colorWord: WORD];
For each "one" in the run-encoded mask the specified color is stored into the corresponding pixel in the the destination (specified by dstBase, dstOffset, and dstWpl). The height and width are implicit in the mask.
Argument interpretations
mask: the runs encoded as a byte sequence
dstBase: a word pointer to the base of the destination
dstOffset: a pixel index into the destination
dstWpl: a # of words between lines in the destination
logDepth: 2**logDepth = the number of bits in a pixel
colorWord: a word filled with the color (as by MakeColorWord)
StoreWithLongColorRuns: PROC [
mask: LongRunSeq,
dstBase: Ptr, dstOffset: CARDINAL, dstWpl: CARDINAL,
logDepth: LogBitOffset, colorWord: WORD];
For each "one" in the run-encoded mask the specified color is stored into the corresponding pixel in the the destination (specified by dstBase, dstOffset, and dstWpl). The height and width are implicit in the mask.
Argument interpretations
mask: the runs encoded as a long run sequence
dstBase: a word pointer to the base of the destination
dstOffset: a pixel index into the destination
dstWpl: a # of words between lines in the destination
logDepth: 2**logDepth = the number of bits in a pixel
colorWord: a word filled with the color (as by MakeColorWord)
BadRun: ERROR;
MaskToRun: PROC
[run: RunSeq,
maskPtr: Ptr, offset: CARDINAL, wpl: CARDINAL,
height: CARDINAL, width: CARDINAL]
RETURNS [CARDINAL];
Takes a mask specification and calculates the length of run required to describe the mask. If run = NIL, then it calculates the size of the run. If run # NIL, then it fills in the run, raising BadRun if the length is not correct.
MaskToLongRun: PROC
[run: LongRunSeq,
maskPtr: Ptr, offset: CARDINAL, wpl: CARDINAL,
height: CARDINAL, width: CARDINAL]
RETURNS [CARDINAL];
Takes a mask specification and calculates the length of run required to describe the mask. If run = NIL, then it calculates the size of the run. If run # NIL, then it fills in the run, raising BadRun if the length is not correct.
END.