<<>> <> <> <> <> <<>> DIRECTORY ImagerBox USING [Rectangle], ImagerBrick USING [HalftoneProperties], ImagerClipper USING [Clipper], ImagerColor USING [Color, ColorOperator], ImagerDeviceVector USING [DVec], ImagerFont USING [Font, XCharProc, XStringProc], ImagerManhattan USING [Polygon], ImagerMaskCache USING [CharFlags, CharMask, MaskCache, Parameters], ImagerPath USING [PathProc], ImagerPen USING [Pen], ImagerPixel USING [PixelMap], ImagerPixelArray USING [PixelArray], ImagerSample USING [EdgeAction, RawDescriptor, SampleMap], ImagerTransformation USING [ScanMode, Transformation], Prop USING [PropList], SF USING [Box, BoxGenerator, Vec], Vector2 USING [VEC]; ImagerDevice: CEDAR DEFINITIONS ~ BEGIN OPEN ImagerBox, ImagerPath, ImagerPen, ImagerPixelArray, ImagerSample, ImagerTransformation, Vector2; <> MakeDevice: PUBLIC PROC [class: DeviceClass, parm: DeviceParm, state: DeviceState ¬ NIL, data: REF] RETURNS [Device]; -- provides standard works class Device: TYPE ~ REF DeviceRepr; -- NOTE: Use MakeDevice to allocate this DeviceRepr: TYPE ~ RECORD [ works: WorksClass, -- higher-level masking operations worksState: WorksState, -- state information for the works level class: DeviceClass, -- class operations parm: DeviceParm, -- static data state: DeviceState, -- dynamic, non-class-specific data data: REF -- class-specific data ]; DeviceState: TYPE ~ REF DeviceStateRep; DeviceStateRep: TYPE ~ RECORD [ allow: AllowedMasks, -- allowed mask operations for current color bounds: SF.Box, -- works level allows no masking outside of these bounds scratchRawBitmapList: LIST OF ImagerSample.RawDescriptor ]; <> <> <<>> AllowedMasks: TYPE ~ PACKED RECORD [ unorderedBoxes: BOOL ¬ FALSE, <= a.max.s-1. This invariant is needed, for instance, by certain anti-aliasing implementations.>> multipleCoverage: BOOL ¬ FALSE, <> regionFill: BOOL ¬ FALSE, <> bitmap: BOOL ¬ FALSE, <> rawBitmaps: BOOL ¬ FALSE, <> runGroupChar: BOOL ¬ FALSE, <> rasterChar: BOOL ¬ FALSE, <> pixelArray: BOOL ¬ FALSE <> ]; DeviceClass: TYPE ~ REF DeviceClassRep; DeviceClassRep: TYPE ~ RECORD [ SetColor: PROC [device: Device, color: ImagerColor.Color, viewToDevice: ImagerTransformation.Transformation] ¬, <> SetPriority: PROC [device: Device, priorityImportant: BOOL] ¬ NIL, <> SetHalftoneProperties: PROC [device: Device, halftoneProperties: ImagerBrick.HalftoneProperties] ¬ NIL, <> MaskBoxes: PROC [device: Device, bounds: SF.Box, boxes: SF.BoxGenerator] ¬ , <> <> MaskRegion: PROC [device: Device, bounds: SF.Box, edgeGenerator: PROC [ImagerSample.EdgeAction]] ¬ NIL, <> MaskBitmap: PROC [device: Device, bitmap: ImagerSample.SampleMap, delta: SF.Vec, bounds: SF.Box, boxes: SF.BoxGenerator] ¬ NIL, <> MaskPixelArray: PROC [device: Device, bitmap: PixelArray, clientToDevice: Transformation, bounds: SF.Box, boxes: SF.BoxGenerator] ¬ NIL, <> MaskRawBitmaps: PROC [device: Device, list: LIST OF ImagerSample.RawDescriptor] ¬ NIL, <> DrawBitmap: PROC [device: Device, bitmap: ImagerSample.SampleMap, delta: SF.Vec, bounds: SF.Box, boxes: SF.BoxGenerator] ¬ NIL, <> MaskChar: PROC [device: Device, delta: SF.Vec, mask: ImagerMaskCache.CharMask] ¬ NIL, <> MoveBox: PROC [device: Device, dstMin, srcMin, size: SF.Vec] ¬ NIL, <> SwitchBuffer: PROC [device: Device, bounds: SF.Box, copy: BOOL, alt: BOOL] ¬ NIL, <> <> <> GetBufferColorOperator: PROC [device: Device] RETURNS [ImagerColor.ColorOperator] ¬ NIL, <> AccessBuffer: PROC [device: Device, box: SF.Box, action: PROC [pixelMap: ImagerPixel.PixelMap]] ¬ NIL, <> propList: Prop.PropList ¬ NIL ]; <> <> <<>> MakeDeviceParm: PROC [class: DeviceClass, sSize, fSize: NAT, scanMode: ImagerTransformation.ScanMode, surfaceUnitsPerInch: Vector2.VEC, surfaceUnitsPerPixel: NAT ¬ 1, fontCache: ImagerMaskCache.MaskCache ¬ NIL, parameters: ImagerMaskCache.Parameters ¬ NIL, propList: Prop.PropList ¬ NIL] RETURNS [DeviceParm]; ClassOption: TYPE = { SetPriority, DrawBitmap, MoveBox, SwitchBuffer, AccessBuffer }; ClassHas: TYPE = PACKED ARRAY ClassOption OF BOOL; DeviceParm: TYPE ~ REF DeviceParmRepr; -- Note: Use MakeDeviceParm to allocate this DeviceParmRepr: TYPE ~ RECORD [ classHas: ClassHas, -- class operations sSize, fSize: NAT, -- size of device coordinate system scanMode: ImagerTransformation.ScanMode, -- orientation of device coordinate system surfaceUnitsPerInch: Vector2.VEC, -- x and y scale factors surfaceUnitsPerPixel: NAT, -- surface resolution may be a multiple of pixel resolution fontCache: ImagerMaskCache.MaskCache ¬ NIL, -- cache for device-dependent character masks parameters: ImagerMaskCache.Parameters ¬ NIL, -- Parameters for non-font applications (i.e., stroke thickening) propList: Prop.PropList ¬ NIL ]; <> <> <<>> WorksState: TYPE = RECORD [ clipper: DeviceClipper, -- the composite clipper, in device coordinates clipperToDevice: Transformation, -- coordinate system for client clipper clientClipper: ImagerClipper.Clipper -- The client clipping region ]; DeviceClipper: TYPE = REF DeviceClipperRep; DeviceClipperRep: TYPE = RECORD [clipBox: SF.Box, clipMask: ImagerManhattan.Polygon]; ordinaryMetrics: ImagerMaskCache.CharFlags ~ [amplified: FALSE, correction: mask, missing: FALSE]; EasyMetrics: TYPE = {all, ordinary, none}; ClipWorksProc: TYPE ~ PROC [ device: Device, viewClipper: DeviceClipper, -- clipping region for the view clipperToDevice: Transformation, -- coordinate system for client clipper clientClipper: ImagerClipper.Clipper -- client clipping region ]; MaskFillWorksProc: TYPE ~ PROC [ device: Device, path: PathProc, oddWrap: BOOL, pathToDevice: Transformation ]; MaskRectangleWorksProc: TYPE ~ PROC [ device: Device, rectangle: Rectangle, rectangleToDevice: Transformation ]; MaskStrokeWorksProc: TYPE ~ PROC [ device: Device, path: PathProc, closed: BOOL, pathToDevice: Transformation, end: INT, joint: INT, miterLimit: REAL, pen: Pen ]; MaskVectorWorksProc: TYPE ~ PROC [ device: Device, p1, p2: VEC, pointsToDevice: Transformation, end: INT, pen: Pen ]; MaskDashedStrokeWorksProc: TYPE ~ PROC [ device: Device, path: PathProc, patternLen: NAT, pattern: PROC [NAT] RETURNS [REAL], offset: REAL, length: REAL, closed: BOOL, pathToDevice: Transformation, end: INT, joint: INT, miterLimit: REAL, pen: Pen ]; MaskBitmapWorksProc: TYPE ~ PROC [ device: Device, bitmap: SampleMap, bitsToDevice: Transformation ]; MaskPixelArrayWorksProc: TYPE ~ PROC [ device: Device, bitmap: PixelArray, clientToDevice: Transformation ]; MaskBoxesWorksProc: TYPE ~ PROC [ device: Device, bounds: SF.Box, boxes: SF.BoxGenerator ]; MaskCharMaskWorksProc: TYPE ~ PROC [ device: Device, charMask: ImagerMaskCache.CharMask, cp: ImagerDeviceVector.DVec ] RETURNS [ok: BOOL ¬ TRUE]; ShowWorksProc: TYPE ~ PROC [ device: Device, fontAtom: ImagerFont.Font, string: ImagerFont.XStringProc, cp: ImagerDeviceVector.DVec, -- Gets side-effected hardChar: ImagerFont.XCharProc, -- side-effects cp hardMetrics: PROC [charMask: ImagerMaskCache.CharMask], -- side-effects cp easyMetrics: EasyMetrics, -- says when we should call hardMetrics noImage: BOOL -- says whether to skip masking ]; WorksClass: TYPE ~ REF WorksClassRep; WorksClassRep: TYPE ~ RECORD [ Clip: ClipWorksProc, MaskFill: MaskFillWorksProc, MaskRectangle: MaskRectangleWorksProc, MaskStroke: MaskStrokeWorksProc, MaskVector: MaskVectorWorksProc, MaskDashedStroke: MaskDashedStrokeWorksProc, MaskBitmap: MaskBitmapWorksProc, MaskPixelArray: MaskPixelArrayWorksProc, MaskBoxes: MaskBoxesWorksProc, MaskCharMask: MaskCharMaskWorksProc, Show: ShowWorksProc ]; END.