DIRECTORY Rope USING [ROPE], Imager USING [Context, ContextRep, SetT, black], ImagerBasic USING [IntRectangle, Transformation, Color, CIEColor], -- Imager1bitDisplay USING [SetUp], Imager8bitDisplay USING [SetUp], ImagerDisplay USING [Mask, MaskRep, ContextData, ContextDataRep]; ImagerDisplayContextImpl: CEDAR PROGRAM IMPORTS Imager, Imager8bitDisplay -- , Imager1bitDisplay EXPORTS Imager, ImagerDisplay = BEGIN UnImplementedDisplayDevice: PUBLIC SIGNAL = CODE; NotImplementedYet: PUBLIC SIGNAL = CODE; IncompatibleContexts: PUBLIC SIGNAL = CODE; Create: PUBLIC PROC [deviceType: ATOM, name: Rope.ROPE _ NIL] RETURNS [Imager.Context] = { RETURN [ OpenContext[deviceType, TRUE, NIL] ]; }; Flush: PUBLIC PROC [context: Imager.Context] = { displayContext: ImagerDisplay.ContextData = NARROW[context.data]; displayContext.deviceProcs.loadTrapezoid[ displayContext, displayContext.clipper.sMin + displayContext.clipper.sSize - 1, displayContext.clipper.sMin, displayContext.clipper.fMin, displayContext.clipper.fMin, displayContext.clipper.fMin + displayContext.clipper.fSize - 1, displayContext.clipper.fMin + displayContext.clipper.fSize - 1, displayContext.currentPxlValue ]; }; Close: PUBLIC PROC [context: Imager.Context] = { displayContext: ImagerDisplay.ContextData; IF context = NIL THEN RETURN[]; displayContext _ NARROW[context.data]; displayContext.deviceProcs.shutDown[displayContext]; }; DoSaveAll: PUBLIC PROC [context: Imager.Context, action: PROC] = { ERROR NotImplementedYet[]; }; DoSave: PUBLIC PROC [context: Imager.Context, action: PROC] = { ERROR NotImplementedYet[]; }; CreateBuffer: PUBLIC PROC [deviceType: ATOM, box: ImagerBasic.IntRectangle] RETURNS [Imager.Context] = { boxMask: ImagerDisplay.Mask _ IF box.h <= 0 OR box.w <= 0 THEN NIL ELSE NEW[ ImagerDisplay.MaskRep _ [box.y, box.x, box.h, box.w, NIL] ]; RETURN [ OpenContext[deviceType, FALSE, boxMask] ]; }; TransferBuffer: PUBLIC PROC [context, source: Imager.Context] = { displaySource: ImagerDisplay.ContextData = NARROW[source.data]; displayContext: ImagerDisplay.ContextData = NARROW[context.data]; displayContext.deviceProcs.transferPxls[displaySource, displayContext]; }; NewDisplay: PUBLIC PROC [context: Imager.Context, device: ATOM] = { displayContext: ImagerDisplay.ContextData = NARROW[context.data]; SELECT device FROM $CRT8 => Imager8bitDisplay.SetUp[displayContext, TRUE]; -- $LF => Imager1bitDisplay.SetUp[displayContext, TRUE]; ENDCASE => ERROR IncompatibleContexts[]; IF ISTYPE[displayContext.currentColor, ImagerBasic.CIEColor] THEN displayContext.currentPxlValue _ displayContext.deviceProcs.colortoPixel[ NARROW[displayContext.currentColor, ImagerBasic.CIEColor] ]; }; Reset: PUBLIC PROC [context: Imager.Context] = {}; OpenContext: PROC [deviceType: ATOM, pin: BOOLEAN, box: ImagerDisplay.Mask] RETURNS [Imager.Context] = { context: Imager.Context; displayContext: ImagerDisplay.ContextData _ NEW[ImagerDisplay.ContextDataRep]; SELECT deviceType FROM $CRT8 => Imager8bitDisplay.SetUp[displayContext, pin, box]; -- $LF => Imager1bitDisplay.SetUp[displayContext, pin, box]; ENDCASE => RETURN [NIL]; -- what about new devices?? displayContext.currentColor _ Imager.black; displayContext.currentPxlValue _ displayContext.deviceProcs.colortoPixel[ NARROW[displayContext.currentColor, ImagerBasic.CIEColor] ]; displayContext.currentPosition _ [0, 0]; context _ NEW[ Imager.ContextRep _ [NIL, displayContext] ]; Imager.SetT[context, [1., 0., 0., 0., 1., 0., identity]]; Imager.SetClipper[ context, NEW[ ImagerDisplay.MaskRep _ [ FIRST[INTEGER]/2, FIRST[INTEGER]/2, LAST[INTEGER], LAST[INTEGER] ] ] ]; RETURN [ context ]; }; END. bImagerDisplayContextImpl.mesa Created April 8, 1983 Last Edit By: Plass, April 8, 1983 7:38 pm Last Edited by: Crow, August 23, 1983 3:22 pm Public Signals Client Procedures (exported to Imager) Called by the viewers package, or other utilities, to set up a context. Returns NIL if unable to create the context. Clear inside context. Set to current color Remove all traces of the given context, clean up VM. Moves the image from source to context, subject to the context clipper. May be used to move data from a display to a buffer, from a buffer to a display, or between two buffers. Display Procedures (exported to ImagerDisplay) Internal Procedures Returns NIL if unable to create the context. If pin = FALSE, sets up bit map compatible with deviceType, but doesn't try to find device. Set client xform and clipper to build composite xform and clipper ΚD˜headšœ™J™™ J™—J™-unitšΟk œ˜ Jšœ œœ˜Jšœ œ$˜4Jšœœ1˜EJšœœ ˜%Jšœœ ˜"Jšœœ.˜C——šœ ˜'Jšœ2˜9Jšœ˜Jšœ˜—™Jšœœœœ˜1Jšœœœœ˜(Jšœœœœ˜+—™&Lš Οnœœœœ œœ˜>ašœœ˜ JšœPœ"™uMšœœœ˜.J˜—šžœ œ˜1Jšœ*™*Jšœ,œ˜Ašœ)˜)Mšœ˜Jšœ@˜@Jšœ˜Jšœ˜Jšœ˜Jšœ?˜?Jšœ?˜?Jšœ˜Jšœ˜—Jšœ˜—šžœ œ˜0Jšœ4™4Jšœ*˜*Jšœ œœœ˜Jšœœ˜&Jšœ4˜4Jšœ˜—šž œ œ#œ˜BMšœ˜Mšœ˜—šžœ œ"œ˜?Jšœ˜Jšœ˜—šž œ œœ!œ˜hšœœ œ ˜9Mšœ˜Mšœœ7œ˜F—Mšœœ ˜3M˜—šžœ œ&˜AJ™³Jšœ+œ˜?Jšœ,œ˜ALšœG˜GJšœ˜——™.šž œ œ#œ˜CMšœ,œ˜ALšœ˜Jšœ2œ˜:Jšœ4œ˜˜>Jšœ@˜@JšœœœΟc˜6Lšœ+˜+JšœI˜IMšœ6˜FJšœ(˜(Lšœ œœ˜;Jšœ9˜9šœ˜Jšœ ˜ šœ˜Jšœœœœœœœœ˜@Jšœ˜—Jšœ˜JšŸA™A—Lšœ ˜J˜——Jšœ˜—…—v