-- CGPoolImpl.mesa -- Last changed by Doug Wyatt, September 1, 1982 12:50 pm DIRECTORY CGClipper USING [Assign, Copy], CGContext, CGMatrix USING [Assign, Copy], CGPrivate USING [Context], CGSource USING [Ref], CGStorage USING [pZone, qZone], GraphicsBasic USING [black, Mark, nullMark]; CGPoolImpl: CEDAR PROGRAM IMPORTS CGClipper, CGMatrix, CGStorage EXPORTS CGContext, CGPrivate = { OPEN CGContext; Mark: TYPE = GraphicsBasic.Mark; nullMark: Mark = GraphicsBasic.nullMark; Context: TYPE = CGPrivate.Context; dataZone: ZONE = CGStorage.pZone; nodeZone: ZONE = CGStorage.qZone; nil: Level = LAST[Level]; nullNode: PoolNodeRep = [matrixLevel: nil, clipperLevel: nil, fillLevel: nil, cpLevel: nil, yUp: FALSE, mode: opaque, fat: FALSE, color: GraphicsBasic.black, matrix: NIL, clipper: NIL, cp: [0,0]]; Save: PUBLIC PROC[self: Context] RETURNS[Mark] = { ctx: Ref _ NARROW[self.data]; oldlev: Level _ ctx.level; -- current level newlev: Level _ oldlev + 1; data: PoolData _ ctx.pooldata; space: NAT _ IF data=NIL THEN 0 ELSE data.space; node: PoolNode _ NIL; IF newlev=nil THEN ERROR; IF space0 THEN oldlev _ lev - 1 ELSE RETURN } ELSE { [oldlev] _ mark; IF oldlev>=lev THEN RETURN }; WHILE lev>oldlev DO node: PoolNode _ data[lev _ lev - 1]; IF node.matrixLevel#nil THEN { IF node.matrixLevel<=lev THEN { CGMatrix.Assign[ctx.matrix, node.matrix]; ctx.yUp _ node.yUp; ctx.matrixLevel _ node.matrixLevel; }; node.matrixLevel _ nil; }; IF node.clipperLevel#nil THEN { IF node.clipperLevel<=lev THEN { CGClipper.Assign[ctx.clipper, node.clipper]; ctx.clipperLevel _ node.clipperLevel; }; node.clipperLevel _ nil; }; IF node.fillLevel#nil THEN { IF node.fillLevel<=lev THEN { src: CGSource.Ref _ ctx.src; src.mode _ node.mode; src.fat _ node.fat; src.color _ node.color; ctx.fillLevel _ node.fillLevel; }; node.fillLevel _ nil; }; ENDLOOP; ctx.poolnode _ IF lev>0 THEN data[lev-1] ELSE NIL; ctx.level _ lev; }; SaveClipper: PUBLIC PROC[self: Ref] = { node: PoolNode _ self.poolnode; IF node.clipper=NIL THEN node.clipper _ CGClipper.Copy[self.clipper] ELSE CGClipper.Assign[node.clipper,self.clipper]; node.clipperLevel _ self.clipperLevel; self.clipperLevel _ self.level; }; SaveMatrix: PUBLIC PROC[self: Ref] = { node: PoolNode _ self.poolnode; IF node.matrix=NIL THEN node.matrix _ CGMatrix.Copy[self.matrix] ELSE CGMatrix.Assign[node.matrix,self.matrix]; node.yUp _ self.yUp; node.yUp _ self.yUp; node.matrixLevel _ self.matrixLevel; self.matrixLevel _ self.level; }; SaveFill: PUBLIC PROC[self: Ref] = { node: PoolNode _ self.poolnode; src: CGSource.Ref _ self.src; node.mode _ src.mode; node.fat _ src.fat; node.color _ src.color; node.fillLevel _ self.fillLevel; self.fillLevel _ self.level; }; SaveCP: PUBLIC PROC[self: Ref] = { node: PoolNode _ self.poolnode; node.cp _ self.cp; node.cpLevel _ self.cpLevel; self.cpLevel _ self.level; }; ResetPool: PUBLIC PROC[self: Ref] = { self.matrixLevel _ 0; self.clipperLevel _ 0; self.fillLevel _ 0; self.cpLevel _ 0; self.poolnode _ NIL; self.level _ 0; }; }.