ImagerColorTranslateWorks.mesa
Copyright Ó 1994 by Xerox Corporation. All rights reserved.
Michael Plass, January 19, 1994 11:53 am PST
This interface provides a mechanism for registering fast cases for performing color-space conversions on large numbers of pixels (as for a sampled image). The semantics of the conversion should be encapsulated as a ColorTransform (see ImagerColorPrivate), which provides the single-point conversion that is useful for constant colors and for a fallback case.
The accelerators will generally come in a couple of different categories - those that work for only one ColorTransform (and know about its private data), and those that work for a large variety of ColorTransforms, typically adding a table lookup or cache. Both of these kinds may use the same registration, and we don't try to distinguish between them at this level.
To control the order in which the accelerators get tried, each one is assigned a slot number. The accelerators are tried in ascending slot number order. Only one accelerator may be registered with a given slot number (this is to make it easy to re-run a new version of the accelerator during testing, and have it reliably take the old version out of service). The more specific accelerators should be given lower slot numbers, so that they get tried before the more generally-applicable numbers. The slot LAST[INT] is reserved for the general fallback case. Refer to the file ImagerColorTranslateSlots.tioga for information about slot numbers that are already in use. Choose slot numbers sparsely so that there is room to insert new ones in an appropriate priority ordering.
The accelerators may be written to do the whole PixelArray -> PixelMap conversion, or via the FastTranslatePixelsProc, or both. Usually, if only one is done, it should be the FastTranslatePixelsProc, because MakeAccelerator will provide a FastTranslateProc that layers on top of it.
DIRECTORY
ImagerColor USING [ColorOperator],
ImagerColorPrivate USING [ColorTransform, TranslateProc],
ImagerPixel USING [PixelMap, PixelProc],
ImagerPixelArray USING [PixelArray],
Prop USING [PropList];
ImagerColorTranslateWorks: CEDAR DEFINITIONS
~ BEGIN OPEN ImagerColorPrivate, ImagerColor, ImagerPixel, ImagerPixelArray;
ColorTransformAccelerator: TYPE = REF ColorTransformAcceleratorRep;
Use MakeAccelerator to create these.
ColorTransformAcceleratorRep: TYPE = RECORD [
slot: INT,  -- determines probe order; choose sparsely
name: ATOM, -- for human consumption
fastTranslate: FastTranslateProc ¬,
fastTranslatePixels: FastTranslatePixelsProc ¬ NIL,
propList: Prop.PropList ¬ NIL
];
FastTranslateProc: TYPE = PROC [self: ColorTransformAccelerator, colorOperator: ColorOperator, transform: ColorTransform, pa: PixelArray] RETURNS [PixelMap];
Should return NIL if not applicable.
FastTranslatePixelsProc: TYPE = PROC [self: ColorTransformAccelerator, colorOperator: ColorOperator, transform: ColorTransform, maxIn: PixelProc, translateAction: PROC [translate: TranslateProc]] RETURNS [done: BOOL ¬ TRUE];
Should NOP and return FALSE if not applicable.
MakeAccelerator: PROC [
slot: INT,
name: ATOM,
fastTranslate: FastTranslateProc ¬ NIL,
fastTranslatePixels: FastTranslatePixelsProc ¬ NIL,
propList: Prop.PropList ¬ NIL]
RETURNS [ColorTransformAccelerator];
RegisterAccelerator: PROC [ColorTransformAccelerator];
RemoveAccelerator: PROC [slot: INT] RETURNS [ColorTransformAccelerator];
For taking a specific accelerator out of action - returns NIL if the slot was empty.
UnregisterAccelerators: PROC;
Resets registry to the initial set
GetAccelerators: PROC RETURNS [LIST OF READONLY ColorTransformAccelerator];
DO NOT CHANGE THE LIST
END.