CIIHTDImpl.mesa
Copyright Ó 1993 by Xerox Corporation. All rights reserved.
Michael Plass, October 28, 1993 2:29 pm PDT
DIRECTORY CII, CIIPrivate, ImagerPrintContext, PrintColor, ImagerRaster, ImagerDeviceInterchange, Vector2, Imager, ImagerDevice, ImagerSample, ImagerTransformation, ImagerManhattan, ImagerDeviceVector, ImagerPrintDevice, UnsafeStorage;
CIIHTDImpl: PROGRAM
IMPORTS CII, CIIPrivate, Imager, ImagerDeviceInterchange, ImagerManhattan, ImagerPrintContext, ImagerRaster, ImagerSample, ImagerTransformation, ImagerPrintDevice, UnsafeStorage
~
BEGIN
ExternalNames:
PROC =
MACHINE
CODE {
"^ExternalNames
SetDefaults CII←HTD←SetDefaults
Create CII←HTD𡤌reate
SetBitmap CII←HTD←SetBitmap
Destroy CII←HTDstroy
Defaults CII←HTDults
DefaultsDestroy CII←HTDultsDestroy
";
};
Handle:
TYPE ~ CII.Handle;
HTDParamRep:
TYPE ~
RECORD [
sSizeDevice: CARDINAL ¬ 0,
fSizeDevice: CARDINAL ¬ 0,
scanMode: CIIPrivate.ScanMode ¬ slowRightFastUp,
surfaceUnitsPerInch: Vector2.VEC ¬ [1, 1],
logicalDevice: PrintColor.LogicalDevice ¬ 0,
raster: POINTER TO CII.RasterRep ¬ NIL
];
SetDefaults:
PUBLIC
PROC [paramRepResult:
POINTER
TO HTDParamRep]
RETURNS [res:
CII.
RES¬ok] ~ {
paramRepResult ¬ [];
};
Defaults:
PUBLIC
PROC [paramResult:
POINTER
TO
POINTER
TO HTDParamRep]
RETURNS [res:
CII.
RES] ~ {
res ¬ SetDefaults[paramResult ¬ UnsafeStorage.GetSystemUZone[].NEW[HTDParamRep]];
};
DefaultsDestroy:
PUBLIC
PROC [p:
POINTER
TO HTDParamRep]
RETURNS [res:
CII.
RES ¬ ok] ~ {
UnsafeStorage.GetSystemUZone[].FREE[@p];
};
MakeBlackOnly:
PROC
RETURNS [PrintColor.TonerUniverse] ~
INLINE {
u: PrintColor.TonerUniverse ¬ [];
u[black] ¬ TRUE;
RETURN [u]
};
Create:
PUBLIC PROC [param:
POINTER
TO HTDParamRep, hResult:
POINTER
TO Handle]
RETURNS [res:
CII.
RES¬ok] ~ {
ENABLE Imager.Error => {res ¬ CII.RESFromErrorCode[error.code]; CONTINUE};
hResult ¬ NIL;
{
context: Imager.Context ~ ImagerPrintContext.SimpleCreate[
deviceSpaceSize: [s: param.sSizeDevice, f: param.fSizeDevice],
scanMode: CIIPrivate.ScanModeTranslate[param.scanMode],
surfaceUnitsPerInch: param.surfaceUnitsPerInch,
logicalDevice: param.logicalDevice,
pixelsPerHalftoneDot: 5.657,
toners: MakeBlackOnly[]
];
ImagerPrintContext.SetSeparation[context, $black];
[] ¬ ImagerPrintContext.SetBitmap[context, CIIPrivate.MakeSampleMap[param.raster]];
{
iState: ImagerDeviceInterchange.InterchangeState ~ ImagerRaster.GetInterchangeState[context];
device: ImagerDevice.Device ~ iState.device;
state:
REF CIIPrivate.StateRep ~
NEW[CIIPrivate.StateRep ¬ [
device: iState.device,
color: Imager.MakeGray[1.0],
dcolor: NIL,
transformation: ImagerTransformation.Scale[1],
viewClipper: NEW[ImagerDevice.DeviceClipperRep ¬ [clipBox: device.state.bounds, clipMask: ImagerManhattan.CreateFromBox[device.state.bounds]]],
clientClipper: NIL,
cp: NEW[ImagerDeviceVector.DVecRep]
]];
iState.device ¬ NIL;
ImagerDeviceInterchange.DestroyInterchangeState[iState];
hResult ¬ CII.MakeHandle[data: state, SetOutputBuffers: SetOutputBuffers];
};
};
};
Destroy:
PUBLIC
PROC [h:
CII.Handle]
RETURNS [res:
CII.
RES¬ok] ~ {};
SetBitmap:
PROC [h: Handle, raster:
POINTER
TO
CII.RasterRep]
RETURNS [res:
CII.
RES¬ok] ~ {
ENABLE Imager.Error => {res ¬ CII.RESFromErrorCode[error.code]; CONTINUE};
state: REF CIIPrivate.StateRep = NARROW[h.data];
[] ¬ ImagerPrintDevice.SetDeviceBitmap[state.device, CIIPrivate.MakeSampleMap[raster]];
};
SetOutputBuffers:
PROC [h: Handle, nBuffers:
INT, outputBuffers:
POINTER
TO
ARRAY [0..0)
OF
CII.RasterRep]
RETURNS [res:
CII.
RES¬ok] = {
IF nBuffers # 1
THEN
RETURN [
CII.RESFromErrorCode[$wrongShape]]
ELSE {
state: REF CIIPrivate.StateRep = NARROW[h.data];
old: ImagerSample.SampleMap = ImagerPrintDevice.GetDeviceBitmap[state.device];
new: ImagerSample.SampleMap = CIIPrivate.MakeSampleMap[@(outputBuffers[0])];
IF old = NIL OR old.GetBox # new.GetBox THEN RETURN [CII.RESFromErrorCode[$wrongShape]];
[] ¬ ImagerPrintDevice.SetDeviceBitmap[state.device, new];
};
};
END.