ImagerTerminalImpl.mesa
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Doug Wyatt, July 22, 1985 3:29:47 pm PDT
Michael Plass, July 22, 1985 11:33:48 am PDT
DIRECTORY
II USING [Context],
IICache USING [GetNamedCache, Ref],
IIColorMap USING [SetStandardColorMap],
IIDevice USING [Device, DeviceBox],
IIDitheredDevice USING [ContextFromColorTerminal],
IIFastShow USING [Create],
IIPixelMap USING [PixelMap, PixelMapRep],
IIRaster USING [AmbushDevice, Ambusher, AmbusherRep, Create, NewBitmapDevice, NewColor24Device],
IITerminal USING [],
Terminal;
IITerminalImpl: CEDAR PROGRAM
IMPORTS IICache, IIColorMap, IIDitheredDevice, IIFastShow, IIRaster, Terminal
EXPORTS IITerminal
~ BEGIN
Context: TYPE ~ II.Context;
Lg: PROC [n: NAT] RETURNS [NAT] ~ {
RETURN[SELECT n FROM 1 => 0, 2 => 1, 4 => 2, 8 => 3, 16 => 4, ENDCASE => ERROR]
};
PixelMapFromFrameBuffer: PROC [frameBuffer: Terminal.FrameBuffer]
RETURNS
[IIPixelMap.PixelMap] ~ {
refRep: REF IIPixelMap.PixelMapRep ~ NEW[IIPixelMap.PixelMapRep ← [
ref: frameBuffer,
pointer: frameBuffer.base,
words: INT[frameBuffer.wordsPerLine]*INT[frameBuffer.height],
lgBitsPerPixel: Lg[frameBuffer.bitsPerPixel],
rast: frameBuffer.wordsPerLine,
lines: frameBuffer.height
]];
frame: IIPixelMap.PixelMap ~ [
sOrigin: 0, fOrigin: 0, sMin: 0, fMin: 0,
sSize: frameBuffer.height, fSize: frameBuffer.width, refRep: refRep
];
RETURN[frame];
};
bitmapCacheID: ATOM ~ $Bitmap;
bitmapCacheSize: NAT ~ 4000;
bitmapRastWeight: REAL ~ 2.0;
BWContext: PUBLIC PROC [vt: Terminal.Virtual, pixelUnits: BOOL] RETURNS [Context] ~ {
frameBuffer: Terminal.FrameBuffer ~ Terminal.GetBWFrameBuffer[vt];
RETURN[IIFastShow.Create[pm: PixelMapFromFrameBuffer[frameBuffer], pixelsPerInch: vt.bwPixelsPerInch, pixelUnits: pixelUnits, fontTuner: NIL]];
};
colorCacheID: ATOM ~ $ColorDisplay;
colorCacheSize: NAT ~ 4000;
colorRastWeight: REAL ~ 0.0;
OneBitPerPixelMasker: PROC [self: IIRaster.Ambusher, box: IIDevice.DeviceBox, action: PROC] ~ {
vt: Terminal.Virtual ~ NARROW[self.data];
Terminal.ModifyColorFrame[vt: vt, action: action, xmin: box.fmin, ymin: box.smin, xmax: box.fmax, ymax: box.smax];
};
ColorContext: PUBLIC PROC [vt: Terminal.Virtual, pixelUnits: BOOL] RETURNS [Context] ~ {
mode: Terminal.ColorMode ~ Terminal.GetColorMode[vt];
IF Terminal.GetColorBitmapState[vt]=none THEN RETURN[NIL];
IF mode.full THEN {
device: IIDevice.Device ~ IIRaster.NewColor24Device[vt];
colorFontCache: IICache.Ref ~ IICache.GetNamedCache[
atom: colorCacheID, createSize: colorCacheSize];
[] ← Terminal.SetColorCursorPresentation[vt, onesAreBlack];
RETURN[IIRaster.Create[device: device, pixelUnits: pixelUnits,
fontCache: colorFontCache, rastWeight: colorRastWeight]];
}
ELSE {
frameBuffer: Terminal.FrameBuffer ~ Terminal.GetColorFrameBufferA[vt];
IF mode.bitsPerPixelChannelA = 1 THEN {
frame: IIPixelMap.PixelMap ~ PixelMapFromFrameBuffer[frameBuffer];
ambusher: IIRaster.Ambusher ~ NEW[IIRaster.AmbusherRep ← [
maskProc: OneBitPerPixelMasker,
device: IIRaster.NewBitmapDevice[
frame: frame, pixelsPerInch: vt.colorPixelsPerInch],
data: vt
]];
device: IIDevice.Device ~ IIRaster.AmbushDevice[ambusher];
bitmapFontCache: IICache.Ref ~ IICache.GetNamedCache[
atom: bitmapCacheID, createSize: bitmapCacheSize];
[] ← Terminal.SetColorCursorPresentation[vt, onesAreWhite];
They are really black because we have an unconventional frame buffer.
RETURN[IIRaster.Create[device: device, pixelUnits: pixelUnits,
fontCache: bitmapFontCache, rastWeight: bitmapRastWeight]];
}
ELSE {
[] ← Terminal.SetColorCursorPresentation[vt, onesAreBlack];
RETURN[IIDitheredDevice.ContextFromColorTerminal[vt, pixelUnits]];
};
};
};
SetStandardColorMap: PUBLIC PROC [vt: Terminal.Virtual] ~ {
IIColorMap.SetStandardColorMap[vt];
};
END.