ImagerContextImpl.mesa
Created April 8, 1983
Last Edit By:
Plass, April 8, 1983 7:38 pm
Last Edited by: Crow, June 10, 1983 5:22 pm
DIRECTORY
ImagerBasic USING [Context, ImagingDevice, ContextRep],
Imager  USING [Mark, nullMark, Inclusions, ResetTransform],
Imager8bitDisplay USING [SetUp];
ImagerContextImpl: CEDAR PROGRAM
IMPORTS Imager, Imager8bitDisplay
EXPORTS Imager
= BEGIN OPEN ImagerBasic;
Client-called Procedures
CreateContext: PUBLIC PROC [device: ImagingDevice] RETURNS [Context] = {
Called by the viewers package, or other utilities, to set up a context. Returns NIL if unable to create the context.
context: Context ← NEW[ContextRep];
context.device ← device;
SELECT device FROM
$CRT8 => { [ context.deviceTransform,
     context.deviceClipper,
     context.deviceProcs ] ← Imager8bitDisplay.SetUp[];
    context.interactive ← TRUE; };
ENDCASE => ERROR;  -- attempt to scrounge up procs record from somewhere
context.currentSource ← [white, [1., 1., 1.], 255, NIL];
context.currentFont ← NIL;
context.currentIntPosition ← [0, 0];
context.currentPosition ← [0., 0.];
context.viewerTransform ← [0, 0, identity, NIL];
Imager.ResetTransform[context];   -- Set client xform to identity and build composite xform
context.clipper ← context.clientClipper ← context.viewerClipper ← context.deviceClipper;
context.noClipArmed ← context.noClip ← FALSE;
RETURN [ context ];
};
DestroyContext: PUBLIC PROC [context: Context] = {
Remove all traces of the given context, clean up VM.
};
Save: PUBLIC PROC [context: Context, what: Imager.Inclusions] RETURNS [Imager.Mark] = {
Note the current state of the display context, and return a mark value which can later be passed to Restore.
RETURN [ Imager.nullMark ];
};
Restore: PUBLIC PROC [context: Context, mark: Imager.Mark ← Imager.nullMark] = {};
Restore the state of the display context to its condition prior to the call on Save that returned the given mark. Defaulting the mark means restore to the most recent Save.
Clear, Next Page, etc.
NewFrame: PUBLIC PROC [context: Context] = {  -- who keeps the background color??
If printer or InterPress, start new page; if double-buffering, display newly completed image; otherwise clear inside context.
IF context.interactive
THEN {
context.deviceProcs.loadPxls[NIL, [0, 0]];
context.deviceProcs.loadTrapezoid[ context.clipper.yMax, context.clipper.yMin,
          context.clipper.xMin, context.clipper.xMin,
          context.clipper.xMax, context.clipper.xMax,
          context.currentSource.pxlValue ];
-- top, bottom, leftTop, leftBot, rightTop, rightBot: CARDINAL, pxlValue: PxlValue
};
};
Unpublicized Procedures
Internal Procedures
END.