ImagerBridgeImpl.mesa
Michael Plass, April 9, 1984 4:19:25 pm PST
DIRECTORY Atom, CGContext, Imager, ImagerBridge, ImagerDisplay, ImagerPrivate, Graphics, GraphicsOps, Real, Terminal;
ImagerBridgeImpl: CEDAR PROGRAM
IMPORTS Atom, Imager, Graphics, GraphicsOps, Real, Terminal
EXPORTS ImagerBridge
~ BEGIN
colorDisplayDevice: ATOM ← $Gray8bpp;
Set this with the debugger to try out other color display impls.
lfGraphicsData: CGContext.Ref ~ NARROW[Graphics.NewContext[].data];
OnLFDisplay: PROC [graphics: Graphics.Context] RETURNS [BOOLEAN] ~ {
data: CGContext.Ref ~ NARROW[graphics.data];
RETURN [data.device.Show = lfGraphicsData.device.Show]
};
ColorDisplayProps: PROC RETURNS [props: Atom.PropList ← NIL] ~ {
vt: Terminal.Virtual ← Terminal.Current[];
colorHeight: NAT ← vt.colorHeight;
IF colorHeight > 25 THEN {
props ← Atom.PutPropOnList[props, $pixelsPerInch, NEW[REAL ← (colorHeight-14)/11]];
};
};
SetViewFromGraphicsContext: PUBLIC PROC [imager: Imager.Context, graphics: Graphics.Context] ~ {
x, y, w, h: REAL;
IF NARROW[imager.class, ImagerPrivate.Class].deviceType = $PD THEN Imager.Error[$CannotUseAHardcopyContextOnADisplay];
[x, y] ← GraphicsOps.UserToDevice[graphics,0,0];
IF GraphicsOps.UserToDevice[graphics,0,1].ty > y THEN Imager.Error[$YFlipNotSupported];
[[xmax: w, ymax: h]] ← Graphics.GetBounds[graphics];
IF OnLFDisplay[graphics] THEN {
IF NARROW[imager.class, ImagerPrivate.Class].deviceType # $LFDisplay THEN {
temp: Imager.Context ← Imager.Create[$LFDisplay];
imager.class ← temp.class;
imager.data ← temp.data;
};
}
ELSE {
Must be on Color Display
displayData: ImagerDisplay.DisplayData;
IF NARROW[imager.class, ImagerPrivate.Class].deviceType # colorDisplayDevice THEN {
temp: Imager.Context ← Imager.Create[colorDisplayDevice, ColorDisplayProps[]];
imager.class ← temp.class;
imager.data ← temp.data;
};
displayData ← NARROW[imager.data];
x ← x*displayData.displayClass.viewUnitsPerPixel;
y ← y*displayData.displayClass.viewUnitsPerPixel;
w ← w*displayData.displayClass.viewUnitsPerPixel;
h ← h*displayData.displayClass.viewUnitsPerPixel;
};
imager.SetViewOrigin[[Real.RoundLI[x], imager.GetSurfaceBounds.h-Real.RoundLI[y]]];
imager.SetViewBox[[0, 0, Real.RoundLI[w], Real.RoundLI[h]]];
};
END.