CDColorsImpl.mesa (Viewer definitions for ChipNDale)
Copyright © 1984, 1986 by Xerox Corporation. All rights reserved.
by Christian Jacobi, September 19, 1984 6:00:17 pm PDT
last edited by Christian Jacobi, March 12, 1986 6:55:24 pm PST
DIRECTORY
CDColors, CDPrivate, CD, Imager;
-- ChipNDale interface defining low layer color handling.
-- (semi-public)
CDColorsImpl:
CEDAR
PROGRAM
IMPORTS Imager
EXPORTS CDColors =
BEGIN
DisplayType:
TYPE = CDColors.DisplayType;
-- {bw, bit1, bit2, bit4, bit8, bit9};
DisplayMode:
TYPE = CDColors.DisplayMode;
-- {normal, pushedOut};
Brick:
TYPE = CDColors.Brick;
-- ARRAY [0..4) OF CARDINAL;
ColorTable:
TYPE = CDColors.ColorTable;
-- RECORD;
-- bricks: ARRAY CD.Layer OF REF Brick;
-- cols: ARRAY CD.Layer OF Imager.Color;
ColorTableSet:
TYPE = CDColors.ColorTableSet;
-- ARRAY DisplayMode OF REF ColorTable;
ColorDefinition:
TYPE = CDColors.ColorDefinition;
-- ARRAY DisplayType OF REF ColorTableSet;
globalColors: PUBLIC REF ColorDefinition ← NEW[ColorDefinition←ALL[NIL]];
emptyBrick: REF Brick = NEW[Brick←ALL[0]];
fullBrick: REF Brick = NEW[Brick←ALL[LAST[CARDINAL]]];
NewColorTab:
PROC []
RETURNS [ct:
REF ColorTable] = {
ct ←
NEW[ColorTable ← [
bricks: NEW[ARRAY CD.Layer OF REF Brick ← ALL[fullBrick]],
filter: NEW[CD.ContextFilter ← ALL[TRUE]],
cols: NEW[ARRAY CD.Layer OF Imager.Color ← ALL[Imager.black]]
]];
ct.filter[CD.backgroundLayer] ← FALSE;
};
GetCTS:
PROC [table:
REF ColorDefinition, display: DisplayType]
RETURNS [cts:
REF ColorTableSet] = {
IF table=NIL THEN table ← globalColors;
IF table[display]=
NIL
THEN {
IF table=globalColors
THEN {
IF display=bit1 THEN display ← bw --color 1 bit/pixel gets same stipples as bw
ELSE IF display=bit9 THEN display ← bit8; --9 bit/pixel uses same stipples as 8 bit/pixel
};
IF table[display]=
NIL
THEN {
table[display] ← NEW[ColorTableSet ← ALL[NIL]];
table[display][normal] ← NewColorTab[];
table[display][pushedOut] ← NewColorTab[];
};
};
cts ← table[display];
};
DefineColor:
PUBLIC
PROC[
layer:
CD.Layer,
brick:
REF Brick ←
NIL,
-- do no more change the values
display: DisplayType ← bw,
mode: DisplayMode ← normal,
table:
REF ColorDefinition ←
NIL
--NIL uses the global table
] =
BEGIN
cts: REF ColorTableSet ← GetCTS[table, display];
IF brick=NIL THEN brick ← fullBrick
ELSE IF brick^=fullBrick^ THEN brick ← fullBrick -- reuse fullbrick; reduce swapping
ELSE IF brick^=emptyBrick^ THEN brick ← emptyBrick;
cts[mode].bricks[layer] ← brick;
IF mode=normal THEN cts[pushedOut].bricks[layer] ← brick;
END;
DefineIColor:
PUBLIC PROC[
layer:
CD.Layer,
col: Imager.Color ←
NIL,
display: DisplayType ← bw,
mode: DisplayMode ← normal,
table:
REF ColorDefinition ←
NIL
--NIL uses the global table
] =
BEGIN
cts: REF ColorTableSet ← GetCTS[table, display];
cts[mode].cols[layer] ← col;
cts[mode].filter[layer] ← col#NIL;
IF mode=normal
THEN {
cts[pushedOut].cols[layer] ← col;
cts[pushedOut].filter[layer] ← col#NIL;
}
END;
END.