SampleArrayDisplay.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Provides facilities for blasting pictures onto the color screen at 24 Bits/Pixel.
Eric Nickell, December 15, 1985 0:12:38 am PST
DIRECTORY
ImagerPixelMap USING [DeviceRectangle],
ImagerTransformation USING [Transformation],
SampleArrays USING [SampleArray],
SampleMapOps USING [SampleMap],
TIPUser USING [TIPScreenCoordsRec],
ViewerClasses USING [Viewer];
SampleArrayDisplay: CEDAR DEFINITIONS = BEGIN
DeviceRectangle: TYPE ~ ImagerPixelMap.DeviceRectangle;
SampleArray: TYPE ~ SampleArrays.SampleArray;
TIPScreenCoordsRec: TYPE ~ TIPUser.TIPScreenCoordsRec;
Transformation: TYPE ~ ImagerTransformation.Transformation;
SampleMap: TYPE ~ SampleMapOps.SampleMap;
Screen: TYPE ~ {bw, color};
Sampler: TYPE ~ REF SamplerRep;
SamplerRep: TYPE ~ RECORD [
min: NAT,
form: SamplerForm,
offset: INTEGER ← 0,  --valid for all rational forms
expand, reduce: INTEGER ← 1, --valid for all rational forms (i.e. expand=1 for offset and reduce forms, reduce=1 for offset and expand forms)
samples: SEQUENCE size: NAT OF CARDINAL
];
SamplerForm: TYPE ~ {general, offset, expand, reduce, rational} ← general;
nullRectangle: DeviceRectangle ~ [sMin: LAST[NAT], fMin: LAST[NAT], sSize: LAST[NAT], fSize: LAST[NAT]];
Display: PROC [screen: Screen, rect: DeviceRectangle, sa: SampleArray ← NIL, sm: SampleMap ← NIL, slow, fast: Sampler, picRect, onlyPaintIn: DeviceRectangle ← nullRectangle];
Display the sa at the given location.
m should be of the form ImagerTransformation.Scale[s: scale].Concat[ImagerTransformation.Translate[t: [xOffset, yOffset]]] (i.e. b and d are zero).
ChangeMaskPixel: PROC [screen: Screen, rect: DeviceRectangle, sm: SampleMap, m: Transformation, s, f: INT, value: [0..2)];
Perform sm[s][f] ← value, and reflect the change in the mask separation of the screen.
ViewerInformation: PROC [v: ViewerClasses.Viewer] RETURNS [screen: Screen, rect: DeviceRectangle];
Returns the rectangle corresponding to the client region of the screen.
BuildSampler: PROC [min, size: NAT, m, b: REAL] RETURNS [s: Sampler];
LookupSampler: PROC [s: Sampler, index: NAT] RETURNS [sample: CARDINAL] ~ INLINE {
RETURN [s.samples[index-s.min]];
};
SameSampleAsPrevious: PROC [s: Sampler, index: NAT] RETURNS [BOOL] ~ INLINE {
RETURN [index>s.min AND s.samples[index-s.min]=s.samples[index-s.min-1]]
};
END.