CDDrawQueue.mesa (a ChipNDale module)
Copyright © 1983, 1984 by Xerox Corporation. All rights reserved.
by Christian Jacobi, May 3, 1983 10:40 am
last edited by Christian Jacobi, September 19, 1985 2:58:03 am PDT
DIRECTORY
CD USING [Rect, Design];
CDDrawQueue: CEDAR DEFINITIONS =
BEGIN
This module dispatches view refresh requests onto different queues which may be
querried by different viewer implementation.
DrawQueue: TYPE = REF DrawQueueRep;
--Think a DrawQueue representing a viewer
--one DrawQueue is executed (emptied) by max one process
--but arbitrary (typically only one) processes may fill the DrawQueue
DrawQueueRep: TYPE;
Request: TYPE = RECORD [key: REF, rect: CD.Rect];
--$redraw:  completely redraw this rect
--$draw:  draw this rect (over what's there)
--queueEmpty: generated implicitely; hint that some lower priority stuff might be done; Do not insert this key explicitely.
--finishedForEver: generated implicitely; hint that this is the last request for ever in this table; Do not insert this key explicitely.
queueEmpty: PRIVATE READONLY REF;
finishedForEver: PRIVATE READONLY REF;
Create: PROC [design: CD.Design, stopFlag: REF BOOL, clip: CD.Rect ← [1,1,0,0] ] RETURNS [DrawQueue];
--Creates a DrawQueue
--stopFlag^ tells any drawing process to stop volunterly and to fetch the next request.
--stopFlag^ must not be modified any more outside this monitor!! until Delete is called
--clip: initial clip area.
--Users may request a stop by calling Flush.
ChangeClipArea: PROC [dq: DrawQueue, clip: CD.Rect ← [1,1,0,0] ];
--changes the clipping aera for this DrawQueue
Destroy: PROC [dq: DrawQueue];
--no more calls of QueueInsertDrawCommand on dq allowed!!
--redraw process must disapear from itself,
--when redraw process dispears and contains nomore
--reference of dq, it is subject for garbage collection
--The stopFlag is immediately set to TRUE and later
--reset to FALSE when the redraw
--process stopped the current command, if it then fetches another
--command it gets the disapearforever command.
Flush: PROC [dq: DrawQueue];
--the drawing may stop after some time only,
--and NOT immediately with procedure return
QueueInsertDrawCommand: PROC [dq: DrawQueue, req: Request];
--insert request into particular DrawQueue
InsertDrawCommand: PROC [design: CD.Design, req: Request];
--insert request into all DrawQueue's of this design
FetchCommand: PROC [dq: DrawQueue] RETURNS [req: Request];
--returns next request
--If not available waits until request is available or DrawQueue deleted
END.