ColorTrixBasicsImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Plass and Bloomenthal, May 13, 1986 6:31:03 pm PDT
ColorTrixBasicsImpl:
CEDAR
MONITOR
IMPORTS ColorDisplay, Imager, ImagerColorMap, ImagerOps, ImagerPixelMap, ImagerRaster, ImagerSmooth, ImagerTerminal, InterminalBackdoor, Terminal
EXPORTS ColorTrixBasics
Basic Color Display Procedures:
VtMode: TYPE ~ ColorTrixBasics.VtMode;
ColorDisplayNotReady: PUBLIC ERROR = CODE;
SetVtMode:
PUBLIC PROC [vtMode: VtMode]
RETURNS [Terminal.Virtual] ~ {
ENABLE UNWIND => NULL;
vt: Terminal.Virtual ← GetVt[];
IF NOT vt.hasColorDisplay THEN ERROR ColorDisplayNotReady;
IF vtMode = gray
THEN ColorDisplay.SetColorDisplayStatus[on: TRUE, gray: TRUE, bpp: 8]
ELSE ColorDisplay.SetColorDisplayStatus[on: TRUE];
RETURN[InterminalBackdoor.terminal];
};
GetVt:
PUBLIC
PROC
RETURNS [Terminal.Virtual] ~ {
RETURN[InterminalBackdoor.terminal];
};
InitCd:
PUBLIC
PROC [type: ColorTrixBasics.CdType, pixelUnits:
BOOL ←
TRUE, clear:
BOOL ←
FALSE, cmapInit:
BOOL ←
TRUE]
RETURNS [Imager.Context] ~ {
cd: Imager.Context;
cd ←
SELECT type
FROM
gray => InitGrayCd[GetVt[], pixelUnits, cmapInit],
smooth => InitSmoothCd[GetVt[], pixelUnits, cmapInit],
color => InitColorCd[GetVt[], pixelUnits, cmapInit],
ENDCASE => NIL;
IF clear AND cd # NIL THEN ClearCd[cd];
RETURN[cd];
};
InitGrayCd:
PROC [vt: Terminal.Virtual ← InterminalBackdoor.terminal, pixelUnits:
BOOL ←
TRUE, cmapInit:
BOOL ←
TRUE]
RETURNS [cd: Imager.Context] ~ {
[] ← SetVtMode[gray];
cd ← ImagerRaster.Create[
-- the color display
ImagerRaster.NewGrayDevice[vt],
TRUE, NIL, 0];
IF cmapInit THEN ImagerColorMap.SetStandardGrayMap[vt]; -- g corrected cmap
IF NOT pixelUnits THEN Imager.ScaleT[cd, screenPixelsPerMeter];
};
InitSmoothCd:
PROC [vt: Terminal.Virtual ← InterminalBackdoor.terminal, pixelUnits:
BOOL ←
FALSE, cmapInit:
BOOL ←
TRUE]
RETURNS [cd: Imager.Context] ~ {
cd ← ImagerSmooth.Create[
ImagerOps.PixelMapFromFrameBuffer[Terminal.GetColorFrameBufferA[vt]],
$Intensity,
ImagerSmooth.LikeScreen[vt.colorHeight],
IF pixelUnits THEN 1.0 ELSE screenPixelsPerMeter];
IF cmapInit THEN ImagerColorMap.SetStandardGrayMap[vt]; -- g corrected cmap
};
InitColorCd:
PROC [vt: Terminal.Virtual ← InterminalBackdoor.terminal, pixelUnits:
BOOL ←
TRUE, cmapInit:
BOOL ←
TRUE]
RETURNS [cd: Imager.Context] ~ {
[] ← SetVtMode[dither];
cd ← ImagerTerminal.ColorContext[vt, TRUE];
IF cmapInit THEN ImagerColorMap.SetStandardColorMap[vt]; -- dither colormap
IF NOT pixelUnits THEN Imager.ScaleT[cd, screenPixelsPerMeter];
};
ClearCd:
PUBLIC PROC [cd: Imager.Context, color: Imager.ConstantColor ← Imager.black] ~ {
Imager.SetColor[cd, color]; -- clear buffer
Imager.MaskRectangle[cd, [0, 0, 1024, 768]]; -- visibilize
Terminal.TurnOnColorDisplay[InterminalBackdoor.terminal];
};
ClearVt:
PUBLIC
PROC [vt: Terminal.Virtual ←
NIL, val:
INTEGER ← 0] ~ {
pm: ImagerPixelMap.PixelMap;
IF vt = NIL THEN vt ← GetVt[];
pm ← ImagerOps.PixelMapFromFrameBuffer[Terminal.GetColorFrameBufferA[vt: vt]];
ImagerPixelMap.Fill[pm, ImagerPixelMap.Window[pm], val];
};
GetPm:
PUBLIC
PROC
RETURNS [ImagerPixelMap.PixelMap] ~ {
RETURN[ImagerOps.PixelMapFromFrameBuffer[Terminal.GetColorFrameBufferA[GetVt[]]]];
};
}.