PDInterpPageImpl.mesa
Michael Plass, November 14, 1983 1:01 pm
DIRECTORY Environment, PDFileFormat, PDInterpReader, PDInterpOutput, PDInterpPage, PDInterpBitmap, Space;
PDInterpPageImpl: PROGRAM
IMPORTS PDInterpReader, PDInterpOutput, PDInterpBitmap, Space
EXPORTS PDInterpPage
= BEGIN
CommandBuffer: TYPE = PDInterpReader.CommandBuffer;
bitsPerWord: NAT = Environment.bitsPerWord;
InterpretPage: PUBLIC PROC [handle: PDInterpReader.Handle] RETURNS [ok: BOOLEAN] ~ {
band: PDInterpBitmap.BitmapDesc;
cachedColorTile: PDInterpBitmap.Tile;
cachedColorReference: INT ← -1;
GetColorTile: PROC ~ {
IF handle.colorTileLoadAddress # cachedColorReference THEN {
cachedColorTile ← PDInterpReader.ColorTileFromLoad[handle, cachedColorReference ← handle.colorTileLoadAddress, scratchPointer, scratchWords];
};
};
TransferRectangle: PROC [rectangle: PDInterpBitmap.Rectangle] ~ {
SELECT handle.colorType FROM
none => ERROR;
clear => PDInterpBitmap.Fill[band, rectangle, 0];
ink => PDInterpBitmap.Fill[band, rectangle, 1];
opaqueTile => {
GetColorTile[];
PDInterpBitmap.TransferTile[band.Clip[rectangle], cachedColorTile];
};
transparentTile => {
GetColorTile[];
PDInterpBitmap.TransferTile[band.Clip[rectangle], cachedColorTile, [or, null]];
};
ENDCASE => ERROR;
};
TempColor: PROC [rectangle: PDInterpBitmap.Rectangle] ~ {
SELECT handle.colorType FROM
none => ERROR;
clear => PDInterpBitmap.Fill[band, rectangle, 0, [xor, complement]];
ink => NULL;
opaqueTile => {
GetColorTile[];
PDInterpBitmap.TransferTile[band.Clip[rectangle], cachedColorTile, [xor, complement]];
};
transparentTile => ERROR;
transparent tiles currently implemented only for rectangles.
ENDCASE => ERROR;
};
DO commandBuffer: CommandBuffer ← PDInterpReader.Get[handle];
WITH commandBuffer SELECT FROM
stateChange: CommandBuffer.stateChange => {
SELECT stateChange.whatChanged FROM
imageStart => {
band ← PDInterpOutput.StartImage[handle.herald, handle.image];
};
imageEnd => {
PDInterpOutput.EndImage[];
RETURN [TRUE];
};
priorityChange => {
Supporting only banded files today, so ignore priority.
};
colorChange => NULL;
bandChange => {
band ← PDInterpOutput.EndBand[];
};
loadChange => NULL;
documentEnd => RETURN [FALSE];
ENDCASE => ERROR;
};
maskRectangle: CommandBuffer.maskRectangle => {
TransferRectangle[[maskRectangle.sMin, maskRectangle.fMin, maskRectangle.sSize, maskRectangle.fSize]];
};
maskTrapezoid: CommandBuffer.maskTrapezoid => {
};
maskRunGroup: CommandBuffer.maskRunGroup => {
s: CARDINAL ← maskRunGroup.sMin;
sMinBand: CARDINALMIN[band.sOrigin+band.sMin, maskRunGroup.sMin+maskRunGroup.sSize];
sMaxBand: CARDINALMIN[band.sOrigin+band.sMin+band.sSize, maskRunGroup.sMin+maskRunGroup.sSize];
run: LONG POINTER TO PDFileFormat.Run ← maskRunGroup.pointer;
TempColor[[maskRunGroup.sMin, maskRunGroup.fMin, maskRunGroup.sSize, maskRunGroup.fSize]];
WHILE s < sMinBand DO
IF run.lastRun THEN s ← s + 1;
run ← run + SIZE[PDFileFormat.Run];
ENDLOOP;
WHILE s < sMaxBand DO
PDInterpBitmap.Fill[band, [s, run.fMin+maskRunGroup.fOffset, 1, run.fSize], 1];
IF run.lastRun THEN s ← s + 1;
run ← run + SIZE[PDFileFormat.Run];
ENDLOOP;
TempColor[[maskRunGroup.sMin, maskRunGroup.fMin, maskRunGroup.sSize, maskRunGroup.fSize]];
};
maskSamples: CommandBuffer.maskSamples => {
rectangle: PDInterpBitmap.Rectangle ← PDInterpBitmap.Window[maskSamples.samples];
TempColor[rectangle];
PDInterpBitmap.Transfer[band, maskSamples.samples, [or, null]];
TempColor[rectangle];
};
colorSamples: CommandBuffer.colorSamples => {
PDInterpBitmap.Transfer[band, colorSamples.samples];
};
deviceCommand: CommandBuffer.deviceCommand => {
};
ENDCASE => NULL;
ENDLOOP;
};
scratchPointer: LONG POINTERNIL;
scratchWords: INT ← 0;
scratchPages: INT = 4;
scratchSpace: Space.Handle ← Space.Create[size: scratchPages, parent: Space.virtualMemory];
Space.Map[scratchSpace];
scratchPointer ← Space.LongPointer[scratchSpace];
scratchWords ← scratchPages*Environment.wordsPerPage;
END.