gnu@hoptoad.uucp (John Gilmore) (11/04/88)
I have some ideas on better ways to handle color maps in NeWS. Since the color model is already 24 bit, there should be no change to applications. What I'd like to do is have NeWS start off with an empty color map, and add colors to it as they are imaged. This means that unless you use more colors than your color map holds, you would always get exactly the colors you ask for. I find it very frustrating that with the color tools, I can slide the sliders all around and the same damn wrong color stares out at me; or that when sliding the 'saturation' or 'brightness' slider, the hue constantly changes. The hard part is of course what to do if more colors are requested than you can hold. The first is to garbage-collect; scan the screen and throw away any colors that are no longer in use. If you have garbage collected recently and you still have too many colors, it's time to fall back on the old method (pick a close color to what was requested / dither for 24-bit images) though we can probably do better by picking a color map that concentrates on the colors the user is actually using at the moment. For example, if there are no greens but seventy shades of yellow, maybe give them 40 shades of yellow and no greens. If you have to 'reclaim' colors that were in use, canvases which were using those color values become damaged and must repaint. This may cause applications a little trouble if they don't expect damage (e.g. if retained), though all applications 'should' always be willing to repair damage. Judicious choice of which colors to replace with which others should minimize the amount of wierd colors shown on the screen before the damage is repaired. The decision about when to use each algorithm above has a great bearing on performance and on how pretty the screen looks (how faithfully the colors are rendered). If you rebuild the map and damage many canvases each time a new color is used, performance will be poor; better to free up maybe 1/3 of the color map each time you rebuild it, and have 'image' operators look ahead to find the total set of colors used if they end up having to rebuild the color map, rather than do it several times in a single imaging (or end up with inferior color choices). Currently, all canvases of the same depth (8 bits only, in the current NeWS implementation) seem to use the same color map. This probably needs to be extended so that each unmapped canvas had its own color map (requiring color maps to be merged when the canvas is mapped to a screen, or in 'imagecanvas'). You can't assume a single frame buffer (at least in the Mac market, we can't), though currently NeWS won't run on multiple frame buffers. Comments? -- John Gilmore {sun,pacbell,uunet,pyramid,amdahl}!hoptoad!gnu gnu@toad.com Noriega-Bush in '88 -- a *crack* team. Let's put the white powder (CIA = Cocaine Import Agency) in the white house!