ImagerRasterAmbushImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Michael Plass, July 20, 1985 9:58:32 am PDT
DIRECTORY
ImagerColorDefs USING [Color],
ImagerDevice USING [BoxProc, CharMask, Class, ClassRep, Device, DeviceBox, DeviceRep, HalftoneParameters, RunProc, Transformation],
ImagerRaster USING [Ambusher];
ImagerRasterAmbushImpl: CEDAR PROGRAM
EXPORTS ImagerRaster
~ BEGIN OPEN ImagerDevice;
Ambusher: TYPE ~ ImagerRaster.Ambusher;
MakeClass: PROC [old: Class] RETURNS [new: Class] ~ {
new ← NEW[ClassRep ← [
type: $Ambush,
SetColor: AmbushSetColor,
SetPriority: AmbushSetPriority,
SetHalftone: AmbushSetHalftone,
MaskRuns: AmbushMaskRuns,
MaskBoxes: AmbushMaskBoxes,
MaskBits: AmbushMaskBits,
DrawBits: AmbushDrawBits,
MoveBoxes: AmbushMoveBoxes,
MaskChar: AmbushMaskChar
]];
IF old.SetColor = NIL THEN new.SetColor ← NIL;
IF old.SetPriority = NIL THEN new.SetPriority ← NIL;
IF old.SetHalftone = NIL THEN new.SetHalftone ← NIL;
IF old.MaskRuns = NIL THEN new.MaskRuns ← NIL;
IF old.MaskBoxes = NIL THEN new.MaskBoxes ← NIL;
IF old.MaskBits = NIL THEN new.MaskBits ← NIL;
IF old.DrawBits = NIL THEN new.DrawBits ← NIL;
IF old.MoveBoxes = NIL THEN new.MoveBoxes ← NIL;
IF old.MaskChar = NIL THEN new.MaskChar ← NIL;
};
AmbushDevice: PUBLIC PROC [ambusher: Ambusher] RETURNS [Device] ~ {
RETURN[NEW[ImagerDevice.DeviceRep ← [class: MakeClass[ambusher.device.class],
box: ambusher.device.box,
surfaceToDevice: ambusher.device.surfaceToDevice,
surfaceUnitsPerInch: ambusher.device.surfaceUnitsPerInch,
surfaceUnitsPerPixel: ambusher.device.surfaceUnitsPerPixel,
data: ambusher]]];
};
AmbushSetColor: PROC[device: Device, color: ImagerColorDefs.Color, viewToDevice: Transformation] ~ {
data: Ambusher ~ NARROW[device.data];
data.device.class.SetColor[data.device, color, viewToDevice];
};
AmbushSetPriority: PROC[device: Device, priorityImportant: BOOL] ~ {
data: Ambusher ~ NARROW[device.data];
data.device.class.SetPriority[data.device, priorityImportant];
};
AmbushSetHalftone: PROC[device: Device, halftone: HalftoneParameters] ~ {
data: Ambusher ~ NARROW[device.data];
data.device.class.SetHalftone[data.device, halftone];
};
AmbushMaskRuns: PROC[device: Device, bounds: DeviceBox, runs: PROC[RunProc]] ~ {
data: Ambusher ~ NARROW[device.data];
action: PROC ~ {data.device.class.MaskRuns[data.device, bounds, runs]};
data.maskProc[data, bounds, action];
};
AmbushMaskBoxes: PROC[device: Device, bounds: DeviceBox, boxes: PROC[BoxProc]] ~ {
data: Ambusher ~ NARROW[device.data];
action: PROC ~ {data.device.class.MaskBoxes[data.device, bounds, boxes]};
data.maskProc[data, bounds, action];
};
AmbushMaskBits: PROC[device: Device, srcBase: LONG POINTER, srcWordsPerLine: NAT,
ts, tf: INTEGER, boxes: PROC[BoxProc]] ~ {
data: Ambusher ~ NARROW[device.data];
bb: DeviceBox ← [smin: CARDINAL.LAST, fmin: CARDINAL.LAST, smax: 0, fmax: 0];
bbBox: PROC [b: DeviceBox] ~ {
IF b.smin < bb.smin THEN bb.smin ← b.smin;
IF b.fmin < bb.fmin THEN bb.fmin ← b.fmin;
IF b.smax > bb.smax THEN bb.smax ← b.smax;
IF b.fmax > bb.fmax THEN bb.fmax ← b.fmax;
};
action: PROC ~ {data.device.class.MaskBits[data.device, srcBase, srcWordsPerLine, ts, tf, boxes]};
boxes[bbBox];
IF bb.smin < bb.smax THEN data.maskProc[data, bb, action];
};
AmbushDrawBits: PROC[device: Device, srcBase: LONG POINTER, srcWordsPerLine: NAT,
ts, tf: INTEGER, boxes: PROC[BoxProc]] ~ {
data: Ambusher ~ NARROW[device.data];
bb: DeviceBox ← [smin: CARDINAL.LAST, fmin: CARDINAL.LAST, smax: 0, fmax: 0];
bbBox: PROC [b: DeviceBox] ~ {
IF b.smin < bb.smin THEN bb.smin ← b.smin;
IF b.fmin < bb.fmin THEN bb.fmin ← b.fmin;
IF b.smax > bb.smax THEN bb.smax ← b.smax;
IF b.fmax > bb.fmax THEN bb.fmax ← b.fmax;
};
action: PROC ~ {data.device.class.DrawBits[data.device, srcBase, srcWordsPerLine, ts, tf, boxes]};
boxes[bbBox];
IF bb.smin < bb.smax THEN data.maskProc[data, bb, action];
};
AmbushMoveBoxes: PROC[device: Device, ts, tf: INTEGER, boxes: PROC[BoxProc]] ~ {
data: Ambusher ~ NARROW[device.data];
bb: DeviceBox ← [smin: CARDINAL.LAST, fmin: CARDINAL.LAST, smax: 0, fmax: 0];
bs, bf: INTEGER ← 0;
bbBox: PROC [b: DeviceBox] ~ {
IF (b.smin ← NAT[NAT[b.smin] + bs]) < bb.smin THEN bb.smin ← b.smin;
IF (b.fmin ← NAT[NAT[b.fmin] + bf]) < bb.fmin THEN bb.fmin ← b.fmin;
IF (b.smax ← NAT[NAT[b.smax] + bs]) > bb.smax THEN bb.smax ← b.smax;
IF (b.fmax ← NAT[NAT[b.fmax] + bf]) > bb.fmax THEN bb.fmax ← b.fmax;
};
action: PROC ~ {data.device.class.MoveBoxes[data.device, ts, tf, boxes]};
boxes[bbBox]; bs ← ts; bf ← tf; boxes[bbBox];
IF bb.smin < bb.smax THEN data.maskProc[data, bb, action];
};
AmbushMaskChar: PROC[device: Device, s, f: INTEGER, mask: CharMask] ~ {
data: Ambusher ~ NARROW[device.data];
action: PROC ~ {data.device.class.MaskChar[data.device, s, f, mask]};
bb: DeviceBox ← [smin: s+mask.sMinBB, fmin: f+mask.fMinBB, smax: 0, fmax: 0];
bb.smax ← bb.smin + mask.sSizeBB;
bb.fmax ← bb.fmin + mask.fSizeBB;
data.maskProc[data, bb, action];
};
END.