ImagerTerminalImpl.mesa
Copyright © 1984, 1985, 1986 by Xerox Corporation. All rights reserved.
Michael Plass, July 22, 1985 11:33:48 am PDT
Doug Wyatt, March 20, 1986 2:07:20 pm PST
DIRECTORY
Imager USING [Context],
ImagerCache USING [GetNamedCache, Ref],
ImagerColorMap USING [SetStandardColorMap],
ImagerDevice USING [Device],
ImagerDitheredDevice USING [ContextFromColorTerminal],
ImagerFastShow USING [Create],
ImagerSample USING [SampleMap, MapFromFrameBuffer],
ImagerRaster USING [AmbushDevice, Ambusher, AmbusherRep, Create, NewBitmapDevice, NewColor24Device],
ImagerTerminal USING [],
SF USING [Box],
Terminal;
ImagerTerminalImpl: CEDAR PROGRAM
IMPORTS ImagerCache, ImagerColorMap, ImagerDitheredDevice, ImagerFastShow, ImagerRaster, ImagerSample, Terminal
EXPORTS ImagerTerminal
~ BEGIN
Context: TYPE ~ Imager.Context;
Lg: PROC [n: NAT] RETURNS [NAT] ~ {
RETURN[SELECT n FROM 1 => 0, 2 => 1, 4 => 2, 8 => 3, 16 => 4, ENDCASE => ERROR]
};
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];
frame: ImagerSample.SampleMap ~ ImagerSample.MapFromFrameBuffer[frameBuffer];
RETURN[ImagerFastShow.Create[bitmap: frame, pixelsPerInch: vt.bwPixelsPerInch,
pixelUnits: pixelUnits, fontTuner: NIL]];
};
colorCacheID: ATOM ~ $ColorDisplay;
colorCacheSize: NAT ~ 4000;
colorRastWeight: REAL ~ 0.0;
OneBitPerPixelMasker: PROC [self: ImagerRaster.Ambusher, box: SF.Box, action: PROC] ~ {
vt: Terminal.Virtual ~ NARROW[self.data];
Terminal.ModifyColorFrame[vt: vt, action: action,
xmin: box.min.f, ymin: box.min.s, xmax: box.max.f, ymax: box.max.s];
};
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: ImagerDevice.Device ~ ImagerRaster.NewColor24Device[vt];
colorFontCache: ImagerCache.Ref ~ ImagerCache.GetNamedCache[
atom: colorCacheID, createSize: colorCacheSize];
[] ← Terminal.SetColorCursorPresentation[vt, onesAreBlack];
RETURN[ImagerRaster.Create[device: device, pixelUnits: pixelUnits,
fontCache: colorFontCache, rastWeight: colorRastWeight]];
}
ELSE {
frameBuffer: Terminal.FrameBuffer ~ Terminal.GetColorFrameBufferA[vt];
IF mode.bitsPerPixelChannelA = 1 THEN {
frame: ImagerSample.SampleMap ~ ImagerSample.MapFromFrameBuffer[frameBuffer];
ambusher: ImagerRaster.Ambusher ~ NEW[ImagerRaster.AmbusherRep ← [
maskProc: OneBitPerPixelMasker,
device: ImagerRaster.NewBitmapDevice[
frame: frame, pixelsPerInch: vt.colorPixelsPerInch],
data: vt
]];
device: ImagerDevice.Device ~ ImagerRaster.AmbushDevice[ambusher];
bitmapFontCache: ImagerCache.Ref ~ ImagerCache.GetNamedCache[
atom: bitmapCacheID, createSize: bitmapCacheSize];
[] ← Terminal.SetColorCursorPresentation[vt, onesAreWhite];
They are really black because we have an unconventional frame buffer.
RETURN[ImagerRaster.Create[device: device, pixelUnits: pixelUnits,
fontCache: bitmapFontCache, rastWeight: bitmapRastWeight]];
}
ELSE {
[] ← Terminal.SetColorCursorPresentation[vt, onesAreBlack];
RETURN[ImagerDitheredDevice.ContextFromColorTerminal[vt, pixelUnits]];
};
};
};
SetStandardColorMap: PUBLIC PROC [vt: Terminal.Virtual] ~ {
ImagerColorMap.SetStandardColorMap[vt];
};
END.