CDVDraw.mesa
Copyright © 1983, 1986 by Xerox Corporation. All rights reserved.
Created by: Christian Jacobi, August 5, 1983 11:07 am
Last edited by: Christian Jacobi, September 4, 1986 4:23:12 pm PDT
DIRECTORY
Basics USING [BITSHIFT, BITAND, LongMult, logBitsPerWord],
CD,
CDBasics,
CDColors,
CDInstances,
CDOps,
CDOrient,
CDPrivate,
CDTexts,
CDVPrivate,
CDVScale,
CedarProcess,
Imager,
ImagerFont USING [RopeWidth],
ImagerColor USING [ColorFromRGB],
ImagerTransformation USING [Create],
PrincOps USING [BBptr, BitAddress, BBTable, SrcDesc, BitBltFlags, GrayParm],
PrincOpsUtils USING [BITBLT],
Rope,
RuntimeError USING [UNCAUGHT],
Terminal,
VFonts USING [DefaultFont];
CDVDraw:
CEDAR
MONITOR
IMPORTS Basics, CD, CDBasics, CDColors, CDInstances, CDOps, CDOrient, CDVPrivate, CDVScale, CedarProcess, Imager, ImagerColor, ImagerFont, ImagerTransformation, PrincOpsUtils, RuntimeError, Terminal, VFonts
EXPORTS CDVPrivate, CD --DrawRef's private fields-- =
BEGIN
VRef: TYPE = CDVPrivate.VRef;
PainterRec: TYPE = CDVPrivate.PainterRec;
ViewerPrivateRep: PUBLIC TYPE = CDVPrivate.VRec;
virtual: Terminal.Virtual = Terminal.Current[];
blackBrick: REF CDColors.Brick = NEW[CDColors.Brick←ALL[LAST[CARDINAL]]];
whiteBrick: REF CDColors.Brick = NEW[CDColors.Brick←ALL[0]];
defaultFont: Imager.Font = VFonts.DefaultFont[];
maskModBitsPerWord: CARDINAL = 15;
--I don't trust List using loopholes's
DRemove:
PROC [ref:
REF PainterRec, list: CDVPrivate.PainterList]
RETURNS [CDVPrivate.PainterList] = {
l, l1: CDVPrivate.PainterList ← NIL;
l ← list;
UNTIL l =
NIL
DO
IF l.first = ref
THEN {
IF l1 = NIL THEN RETURN[l.rest]; -- ref was first object on list
l1.rest ← l.rest;
RETURN[list];
};
l1 ← l;
l ← l.rest;
ENDLOOP;
RETURN [list];
};
Memb:
PROC [ref:
REF PainterRec, list: CDVPrivate.PainterList]
RETURNS [
BOOL] = {
FOR l: CDVPrivate.PainterList ← list, l.rest
WHILE l#
NIL
DO
IF l.first=ref THEN RETURN [TRUE]
ENDLOOP;
RETURN [FALSE]
};
IncludeAPainterRec:
PUBLIC
ENTRY
PROC [me: VRef, pr:
REF PainterRec] = {
ENABLE UNWIND => NULL;
DOIT:
PROC [] =
TRUSTED {
IF ~Memb[ref: pr, list: me.painterList]
THEN
me.painterList ← CONS[pr, me.painterList];
};
DOIT[];--indirection to make sure catching UNWIND works
};
RemoveAPainterRec:
PUBLIC
ENTRY
PROC [me: VRef, pr:
REF PainterRec] = {
ENABLE UNWIND => NULL;
DOIT:
PROC [] =
TRUSTED {
me.painterList ← DRemove[ref: pr, list: me.painterList];
};
DOIT[];--indirection to make sure catching UNWIND works
};
CheckPriority:
PUBLIC
CD.CheckPriorityProc = {
--the priority business is a hint only
IF pr.checkPriority
THEN {
WITH pr.devicePrivate
SELECT
FROM
vRef: VRef => {
pr.checkPriority ← FALSE;
IF vRef.slowDown
THEN {
vRef.slowDown ← FALSE;
CedarProcess.SetPriority[CedarProcess.Priority[background]];
};
IF vRef.hurryUp
THEN {
--this will be executed only after the other slowed down ...
vRef.hurryUp ← FALSE;
CedarProcess.SetPriority[CedarProcess.Priority[normal]];
};
};
ENDCASE => NULL;
};
};
BitBlitDraw:
PROC[vRef: VRef, r:
CD.Rect, color:
REF CDColors.Brick] = {
InlineBitBlitDraw[vRef, r, color];
};
InlineBitBlitDraw:
PROC[vRef: VRef, r:
CD.Rect, color:
REF CDColors.Brick] =
-- DONE OUTSIDE r ← CDBasics.Intersection[r, vRef.deviceDrawRef.interestClip];
-- this guarantees no arithmetic overflows if non empty; but there are nasty guys
-- calling this procedure with empty rects.
-- This is not a complete clip yet
TRUSTED INLINE BEGIN
ENABLE RuntimeError.
UNCAUGHT => {
IF CDVPrivate.ShallContinue[vRef, TRUE, "CDVDraw.bblt"] THEN GOTO oops;
};
xBit, x1, x2, y1, y2: CARDINAL;
vr: CD.Rect;
IF r.x1>r.x2 OR r.y1>r.y2 THEN RETURN; --silly bad guys could cause overflow
vr ← CDVScale.DesignToViewerRect[vRef.scale, r];
x1 ← MAX[vr.x1, 0];
y1 ← MAX[vr.y1, 0];
x2 ← MIN[vr.x2, vRef.vw];
y2 ← MIN[vr.y2, vRef.vh];
IF x1>=x2
OR y1>=y2
THEN
RETURN;
--Arbitrary: rectangles smaller than 1 pixel are not drawn.
xBit ← Basics.BITSHIFT[x1+vRef.vx, vRef.logbpp];
vRef.pBBptr.width ← Basics.BITSHIFT[x2-x1, vRef.logbpp];
vRef.pBBptr.height ← y2-y1;
y1 ← vRef.vy-y2;
vRef.pBBptr.dst ← [
vRef.screen
+ Basics.LongMult[y1, vRef.scWidthWords]
+ LONG[Basics.BITSHIFT[xBit, -Basics.logBitsPerWord]],,
Basics.BITAND[xBit, maskModBitsPerWord]
];
vRef.pBBptr.src ← [
LOOPHOLE[
LOOPHOLE[color, LONG CARDINAL] + Basics.BITAND[y1, 3], LONG POINTER],,
Basics.BITAND[xBit, maskModBitsPerWord]
];
vRef.pBBptr.srcDesc.gray.yOffset ← Basics.BITAND[y1, 3];
IF vRef.display=bw THEN PrincOpsUtils.BITBLT[vRef.pBBptr]
ELSE {
Blit:
PROC [] =
TRUSTED {
PrincOpsUtils.BITBLT[vRef.pBBptr];
};
Terminal.ModifyColorFrame[vt: virtual,
action: Blit,
xmin: x1+vRef.vx,
ymin: y1,
xmax: x2+vRef.vx,
ymax: y1+vRef.pBBptr.height
];
};
EXITS oops => NULL;
END;
InlineBitBlitOutLine:
ENTRY
PROC[vRef: VRef, r:
CD.Rect, color:
REF CDColors.Brick] =
TRUSTED INLINE BEGIN
--r in design coordinates
ENABLE {
UNWIND => NULL;
RuntimeError.
UNCAUGHT => {
IF CDVPrivate.ShallContinue[vRef, TRUE, "CDVDraw.bbout"] THEN GOTO oops;
};
};
vr: CD.Rect; --in viewer coordinates
clipVr: CD.Rect; --in viewer coordinates
DrawGrey:
PROC[vRef: VRef, x1, y1, x2, y2:
INTEGER] =
TRUSTED INLINE BEGIN
--no empty test; is guaranteed by caller
xBits: CARDINAL = Basics.BITSHIFT[x1+INTEGER[vRef.vx], vRef.logbpp];
vRef.pBBptr.width ← Basics.BITSHIFT[x2-x1, vRef.logbpp];
vRef.pBBptr.height ← y2-y1;
y1 ← vRef.vy-y2;
vRef.pBBptr.dst ← [
vRef.screen
+ Basics.LongMult[y1, vRef.scWidthWords]
+ LONG[Basics.BITSHIFT[xBits, -Basics.logBitsPerWord]],,
Basics.BITAND[xBits, maskModBitsPerWord]
];
vRef.pBBptr.src ← [
LOOPHOLE[
LOOPHOLE[color, LONG CARDINAL] + Basics.BITAND[y1, 3], LONG POINTER],,
Basics.BITAND[xBits, maskModBitsPerWord]
];
vRef.pBBptr.srcDesc.gray.yOffset ← Basics.BITAND[y1, 3];
PrincOpsUtils.BITBLT[vRef.pBBptr];
END;
DoIt:
PROC [] =
TRUSTED BEGIN
IF vr.x1>=clipVr.x1 THEN DrawGrey[vRef, clipVr.x1, clipVr.y1, clipVr.x1+1, clipVr.y2]; --left
IF vr.y2<=clipVr.y2 THEN DrawGrey[vRef, clipVr.x1, clipVr.y2-1, clipVr.x2, clipVr.y2]; --top
IF vr.x2<=clipVr.x2 THEN DrawGrey[vRef, clipVr.x2-1, clipVr.y1, clipVr.x2, clipVr.y2]; --right
IF vr.y1>=clipVr.y1 THEN DrawGrey[vRef, clipVr.x1, clipVr.y1, clipVr.x2, clipVr.y1+1]; --bot
END;
--clip to area where
--1) small enough: it does not crash on scaling later
--2) big enough: if drawn, it does not draw artificial lines
IF r.x2>vRef.dClip.x2 THEN r.x2 ← vRef.dClip.x2+1;
IF r.y2>vRef.dClip.y2 THEN r.y2 ← vRef.dClip.y2+1;
IF r.x1<vRef.dClip.x1 THEN r.x1 ← vRef.dClip.x1-1;
IF r.y1<vRef.dClip.y1 THEN r.y1 ← vRef.dClip.y1-1;
vr ← CDVScale.DesignToViewerRect[vRef.scale, r];
clipVr ← CDBasics.Intersection[
--remember: interestClip can be smaller than viewer
CDVScale.DesignToViewerRect[vRef.scale, vRef.deviceDrawRef.interestClip],
vr
];
clipVr.x1 ← MAX[clipVr.x1, 0];
clipVr.y1 ← MAX[clipVr.y1, 0];
clipVr.x2 ← MIN[clipVr.x2, LONG[vRef.vw]];
clipVr.y2 ← MIN[clipVr.y2, LONG[vRef.vh]];
IF clipVr.x1>=clipVr.x2
OR clipVr.y1>=clipVr.y2
THEN
RETURN;
harder empty test than CDBasics
necessary because we add/subtract one
vRef.pBBptr^ ← PrincOps.BBTable[
dst: TRASH,
dstBpl: vRef.frame.width*vRef.frame.bitsPerPixel,
src: TRASH,
srcDesc: PrincOps.SrcDesc[gray[PrincOps.GrayParm[
yOffset: 0, --is actually trash
widthMinusOne: 0, --words
heightMinusOne: 3 --lines
]]],
width: TRASH,
height: TRASH,
flags: PrincOps.BitBltFlags[
direction: forward,
disjoint: TRUE,
disjointItems: TRUE,
gray: TRUE,
srcFunc: null,
dstFunc: or
]
];
IF vRef.display=bw
THEN {
DoIt[]
}
ELSE {
Terminal.ModifyColorFrame[vt: virtual,
action: DoIt,
xmin: clipVr.x1+vRef.vx,
ymin: vRef.vy+1-clipVr.y2,
xmax: clipVr.x2+vRef.vx-1,
ymax: vRef.vy-clipVr.y1
];
}
EXITS oops => NULL;
END;
InvertArea:
PUBLIC
ENTRY PROC[me: VRef, x1, y1, x2, y2:
INT] =
BEGIN
ENABLE {
UNWIND => NULL;
RuntimeError.
UNCAUGHT =>
IF CDVPrivate.ShallContinue[me, TRUE, "CDVDraw.IA"] THEN GOTO oops;
};
--proc to make the unwind really catching the errors
SafetyProc:
PROC [] =
TRUSTED BEGIN
xBit: CARDINAL;
xc1: CARDINAL ← MIN[MAX[x1, 0], LONG[me.vw-2]];
yc1: CARDINAL ← MIN[MAX[y1, 1], LONG[me.vh-1]];
xc2: CARDINAL ← MIN[MAX[x2, 0], LONG[me.vw-2]];
yc2: CARDINAL ← MIN[MAX[y2, 1], LONG[me.vh-1]];
IF xc1>xc2 THEN {t: CARDINAL=xc1; xc1←xc2; xc2←t};
IF yc1>yc2 THEN {t: CARDINAL=yc1; yc1←yc2; yc2←t};
me.xBBptr.width ← Basics.BITSHIFT[(xc2+1-xc1), me.logbpp];
me.xBBptr.height ← (yc2+1-yc1);
xBit ← Basics.BITSHIFT[(xc1+me.vx), me.logbpp];
yc1 ← me.vy-yc2; --yc2>me.vy impossible ??
me.xBBptr.dst ← [
me.screen
+ Basics.LongMult[yc1, me.scWidthWords]
+ LONG[Basics.BITSHIFT[xBit, -Basics.logBitsPerWord]],,
Basics.BITAND[xBit, maskModBitsPerWord]
];
me.xBBptr.flags.dstFunc ← xor;
me.xBBptr.src ← [LOOPHOLE[blackBrick, LONG POINTER],,0];
me.xBBptr.srcDesc ← PrincOps.SrcDesc[gray[PrincOps.GrayParm[
yOffset: 0,
widthMinusOne: 0, --words
heightMinusOne: 0 --lines
]]];
IF me.display=bw THEN PrincOpsUtils.BITBLT[me.xBBptr]
ELSE {
Blit:
PROC [] =
TRUSTED {
PrincOpsUtils.BITBLT[me.xBBptr];
};
Terminal.ModifyColorFrame[vt: virtual,
action: Blit,
xmin: xc1+me.vx,
ymin: yc1 ,
xmax: xc2+me.vx+1,
ymax: yc1+me.xBBptr.height
];
};
END;
SafetyProc[];
EXITS oops => NULL;
END;
OutLine:
PROC[r:
CD.Rect, l:
CD.Layer, pr:
CD.DrawRef] = {
WITH pr.viewerPrivate
SELECT
FROM
vRef: VRef => InlineBitBlitOutLine[vRef: vRef, r: r, color: vRef.colorTable.bricks[l]];
ENDCASE => NULL;
};
BitBlitDrawRectForViewers:
ENTRY
PROC[r:
CD.Rect, l:
CD.Layer, pr:
CD.DrawRef] = {
ENABLE UNWIND => NULL;
WITH pr.viewerPrivate
SELECT
FROM
vRef: VRef =>
InlineBitBlitDraw[vRef, CDBasics.Intersection[r, pr.interestClip], vRef.colorTable.bricks[l]];
ENDCASE => NULL;
};
SetGround:
--CD.SetGroundProc--
PROC [pr:
CD.DrawRef, pushedOut:
BOOL] = {
WITH pr.devicePrivate
SELECT
FROM
vRef: VRef =>
vRef.colorTable ← vRef.personalColors[vRef.display][IF pushedOut THEN pushedOut ELSE normal]
ENDCASE => NULL;
};
DrawCommentForViewers:
PUBLIC
PROC[r:
CD.Rect, comment: Rope.
ROPE, pr:
CD.DrawRef] = {
topToFontLine: NAT = 9+2;
fontHeight: NAT = 10;
leftMargin: NAT = 2;
bothMargin: NAT = 2*leftMargin;
vRef: VRef ← NARROW[pr.devicePrivate];
vr: CD.Rect ← CDVScale.DesignToViewerRect[vRef.scale, r];
IF vr.y2-vr.y1>fontHeight
THEN {
xw: REAL = ImagerFont.RopeWidth[font: defaultFont, rope: comment].x;
IF vr.x2-vr.x1>xw+bothMargin
THEN {
Imager.SetColor[vRef.viewContext, Imager.black];
Imager.SetFont[vRef.viewContext, defaultFont];
Imager.SetXY[vRef.viewContext, [vr.x1+leftMargin, vr.y2-topToFontLine]];
Imager.ShowRope[vRef.viewContext, comment];
}
};
};
RepaintRectAreaInViewer:
PUBLIC
PROC [me: VRef, rect:
CD.Rect, eraseFirst:
BOOL] =
BEGIN
ENABLE RuntimeError.
UNCAUGHT =>
IF CDVPrivate.ShallContinue[me, TRUE, "CDVDraw.rep1"] THEN GOTO oops;
interestRect: CD.Rect;
ReUseDrawInformation[me];
me.deviceDrawRef.interestClip ← interestRect ← CDBasics.Intersection[rect, me.dClip];
IF CDBasics.NonEmpty[interestRect]
THEN {
RepaintBackground[me, interestRect, eraseFirst];
CDOps.QuickDrawDesign[me.actualDesign, me.deviceDrawRef];
FOR pl: CDVPrivate.PainterList ← me.painterList, pl.rest
WHILE pl#
NIL
DO
IF CDBasics.Intersect[interestRect, pl.first.rect]
THEN
pl.first.proc[me, pl.first, interestRect ! RuntimeError.
UNCAUGHT =>
IF CDVPrivate.ShallContinue[me, TRUE, "CDVDraw.rep2"] THEN CONTINUE
]
ENDLOOP
}
EXITS oops=> NULL
END;
RepaintBackground:
PUBLIC
ENTRY
PROC[vRef: VRef, r:
CD.Rect, eraseFirst:
BOOL] =
BEGIN
ENABLE {
UNWIND => NULL;
RuntimeError.
UNCAUGHT =>
IF CDVPrivate.ShallContinue[vRef, TRUE, "CDVDraw.back"] THEN GOTO oops;
};
DrawOutside:
PROC [r:
CD.Rect] = {
BitBlitDraw[vRef, CDBasics.Intersection[r, vRef.dClip], vRef.colorTable.bricks[CD.backgroundLayer]];
};
--RepaintBackground
IF eraseFirst
THEN {
TRUSTED {vRef.pBBptr.flags.dstFunc ← null};
BitBlitDraw[vRef, CDBasics.Intersection[r, vRef.dClip], whiteBrick];
TRUSTED {vRef.pBBptr.flags.dstFunc ← or};
};
IF vRef.actualDesign.actual.first.mightReplace#
NIL
AND vRef.environment
AND
vRef.actualDesign.actual.first.mightReplace.ob#NIL THEN
CDBasics.DecomposeRect[r: r,
test: CDInstances.InstRectO[vRef.actualDesign.actual.first.mightReplace],
outside: DrawOutside
];
EXITS oops => NULL;
END;
InitForBBLT:
INTERNAL PROC [vRef: VRef] =
INLINE --called only from one place..-- BEGIN
IF vRef.viewer.column=color
THEN
TRUSTED {
colorMode: Terminal.ColorMode = Terminal.GetColorMode[virtual];
IF colorMode.full THEN ERROR CDVPrivate.notSupportedColorMode;
SELECT colorMode.bitsPerPixelChannelA
FROM
8 => {vRef.display ← bit8; vRef.logbpp ← 3};
1 => {vRef.display ← bit1; vRef.logbpp ← 0};
4 => {vRef.display ← bit4; vRef.logbpp ← 2};
2 => {vRef.display ← bit2; vRef.logbpp ← 1};
ENDCASE => ERROR CDVPrivate.notSupportedColorMode;
vRef.frame ← Terminal.GetColorFrameBufferA[virtual];
}
ELSE {
-- b+w
vRef.display ← bw;
vRef.logbpp ← 0;
vRef.frame ← Terminal.GetBWFrameBuffer[virtual];
};
vRef.bpp ← vRef.frame.bitsPerPixel;
vRef.screen ← vRef.frame.base;
vRef.colorTable ← vRef.personalColors[vRef.display][normal];
vRef.scWidthWords ← vRef.frame.wordsPerLine;
-- vRef.vx ← distance from left of screen to left most pixel
-- vRef.vy ← distance from top of screen to bottom most pixel
-- in pixels
-- vRef.vw, vRef.vh copied to avoid race conditions
vRef.vw ← vRef.viewer.cw;
vRef.vh ← vRef.viewer.ch;
vRef.vx ← vRef.viewer.cx+vRef.viewer.wx;
vRef.vy ← vRef.frame.height-(vRef.viewer.cy+vRef.viewer.wy);
--fixed fooBBptr initializations
--done in "viewer" process: vRef.fooBBptr ← PrincOpsUtils.AlignedBBTable[@fooBTableSpace];
TRUSTED {
vRef.xBBptr^ ← vRef.pBBptr^ ← PrincOps.BBTable[
dst: TRASH,
dstBpl: vRef.frame.width*vRef.frame.bitsPerPixel,
src: [LOOPHOLE[blackBrick, LONG POINTER],,0],
srcDesc: PrincOps.SrcDesc[gray[PrincOps.GrayParm[
yOffset: 0, --is actually trash
widthMinusOne: 0, --words
heightMinusOne: 3 --lines
]]],
width: TRASH,
height: TRASH,
flags: PrincOps.BitBltFlags[
direction: forward,
disjoint: TRUE, disjointItems: TRUE,
gray: TRUE,
srcFunc: null,
dstFunc: or
]
];
};
END;
CreateTransform:
PROC [
cellSize: CD.Position,
cellInstOrient: CD.Orientation,
cellInstPos: CD.Position ← [0,0]]
RETURNS [Imager.Transformation] =
-- Given the size of a cell,
-- the position and orientation of an instance of that cell in "world"
-- co-ordinates, returns the transformation to be applied to
-- cell points to get world points.
INLINE BEGIN
RETURN [
SELECT cellInstOrient
FROM
--original--0 => ImagerTransformation.Create[1, 0, cellInstPos.x, 0, 1, cellInstPos.y],
1 => ImagerTransformation.Create[-1, 0, cellInstPos.x+cellSize.x, 0, 1, cellInstPos.y], -- reflection in x
--rotate90-- 2 => ImagerTransformation.Create[0, -1, cellInstPos.x+cellSize.y, 1, 0, cellInstPos.y], -- 90 degrees clockwise
3 => ImagerTransformation.Create[0, 1, cellInstPos.x, 1, 0, cellInstPos.y], -- 90 degrees clockwise followed by reflection in x
--rotate180-- 4 => ImagerTransformation.Create[-1, 0, cellInstPos.x+cellSize.x, 0, -1, cellInstPos.y+cellSize.y], -- 180 degrees clockwise
5 => ImagerTransformation.Create[1, 0, cellInstPos.x, 0, -1, cellInstPos.y+cellSize.y], -- 180 degrees clockwise followed by reflection in x
--rotate270-- 6 => ImagerTransformation.Create[0, 1, cellInstPos.x, -1, 0, cellInstPos.y+cellSize.x], -- 270 degrees clockwise
7 => ImagerTransformation.Create[0, -1, cellInstPos.x+cellSize.y, -1, 0, cellInstPos.y+cellSize.x], -- 270 degrees clockwise followed by reflection in x
ENDCASE => ERROR
];
END;
ViewerDrawContext:
PROC [pr:
CD.DrawRef, proc:
CD.DrawContextLayerProc, ob:
CD.Object, pos:
CD.Position, orient:
CD.Orientation, layer:
CD.Layer] = {
--calls proc which may use context; mode and color are set to layer's need
--call is suppressed if layer does not need drawing; this is default.
--on recursive calls, the context may or may not include previous transformations
IF pr.deviceContext#
NIL
AND pr.contextFilter#
NIL
AND pr.contextFilter[layer]
THEN {
Action:
PROC [] = {
vRef: VRef = NARROW[pr.viewerPrivate];
Imager.ScaleT[pr.deviceContext, CDVScale.DesignToViewerFactor[vRef.scale]];
Imager.TranslateT[pr.deviceContext, [-vRef.scale.off.x, -vRef.scale.off.y]];
IF ob#
NIL
THEN {
IF orient=CD.original THEN Imager.TranslateT[pr.deviceContext, [pos.x, pos.y]]
ELSE Imager.ConcatT[pr.deviceContext, CreateTransform[
cellSize: ob.size,
cellInstOrient: orient,
cellInstPos: pos
]];
};
Imager.SetColor[pr.deviceContext, vRef.colorTable.cols[layer]];
proc[pr.deviceContext, ob, layer];
};
Imager.DoSave[pr.deviceContext, Action];
}
};
ICreateDrawRef:
INTERNAL
PROC [vRef: VRef] = {
pr:
CD.DrawRef =
CD.CreateDrawRef[[
drawRect: BitBlitDrawRectForViewers,
drawOutLine: OutLine,
drawComment: DrawCommentForViewers,
drawContext: ViewerDrawContext,
setGround: SetGround,
priorityChecker: CheckPriority,
devicePrivate: vRef,
stopFlag: vRef.stoprequest,
symbolics: vRef.symbolics,
borders: vRef.borders,
environment: vRef.environment,
specialFonts: vRef.specialFonts,
checkPriority: vRef.checkPriority,
b4: vRef.b4,
b5: vRef.b5,
design: vRef.actualDesign
]];
InitForBBLT[vRef];
vRef.deviceDrawRef ← pr;
pr.interestClip ← vRef.dClip ← CDVScale.GetClipRecord[vRef.intendedScale, vRef.vw, vRef.vh];
pr.scaleHint ← CDVScale.DesignToViewerFactor[vRef.intendedScale]*vRef.suppressFactorForCells;
pr.contextFilter ← vRef.contextFilter ← vRef.colorTable.filter;
pr.viewerPrivate ← vRef; -- this line last! it tells DummyNotify that the rest is initialized
};
ReUseContext:
PROC [pr:
CD.DrawRef, vRef: VRef] =
INLINE {
pr.deviceContext ← vRef.viewContext;
Imager.SetColor[vRef.viewContext, Imager.black];
Imager.SetFont[vRef.viewContext, defaultFont];
};
ReUseDrawInformation:
ENTRY
PROC [vRef: VRef] =
INLINE {
ENABLE UNWIND => NULL;
IF vRef.deviceDrawRef=NIL THEN --usually not-- ICreateDrawRef[vRef];
ReUseContext[vRef.deviceDrawRef, vRef];
};
CreateDrawInformation:
PUBLIC
ENTRY
PROC [me: VRef] = {
ICreateDrawRef[me];
ReUseContext[me.deviceDrawRef, me];
};
DoInsideMonitor:
PUBLIC
ENTRY
PROC [proc:
PROC [VRef], vRef: VRef] = {
ENABLE UNWIND => NULL;
proc[vRef ! RuntimeError.
UNCAUGHT =>
IF CDVPrivate.ShallContinue[vRef, TRUE, "CDVDraw.XXX"] THEN CONTINUE;
]
};
CDColors.DefineColor[CD.undefLayer, NIL, bw];
CDColors.DefineColor[CD.undefLayer, NIL, bit4];
CDColors.DefineColor[CD.undefLayer, NIL, bit8];
CDColors.DefineColor[CD.backgroundLayer, NEW[CDColors.Brick←[257,0,0,0]], bw];
CDColors.DefineColor[CD.backgroundLayer, NEW[CDColors.Brick←[0,10,0,11*256]], bit4];
CDColors.DefineColor[CD.backgroundLayer, NEW[CDColors.Brick←[8, 0, 800h, 0]], bit8];
CDColors.DefineColor[CD.shadeLayer, NEW[CDColors.Brick←[101H, 0, 0, 0]], bw];
CDColors.DefineColor[CD.shadeLayer, NEW[CDColors.Brick←[0, 0F0FH, 0, 0]], bit4];
CDColors.DefineColor[CD.shadeLayer, NEW[CDColors.Brick←[255, 0, 255, 0]], bit8];
CDColors.DefineColor[CD.errorLayer, NEW[CDColors.Brick←[101H, 0, 101H, 0]], bw];
CDColors.DefineColor[CD.errorLayer, NEW[CDColors.Brick←[0, 0F0FH, 0, 0F0FH]], bit4];
CDColors.DefineColor[CD.errorLayer, NEW[CDColors.Brick←[0, 255, 0, 0]], bit8];
CDColors.DefineColor[CD.outlineLayer, NEW[CDColors.Brick←[8888h, 4444h, 2222h, 1111h]], bw];
CDColors.DefineColor[CD.outlineLayer, NEW[CDColors.Brick←[07C7CH, 07C7CH, 07C7CH, 07C7CH]], bit4];
CDColors.DefineColor[CD.outlineLayer, NEW[CDColors.Brick←[07C7CH, 07C7CH, 07C7CH, 07C7CH]], bit8];
CDColors.DefineColor[CD.selectionLayer, NEW[CDColors.Brick←[0ffffH, 0ffffH, 0ffffH, 0ffffH]], bw];
CDColors.DefineColor[CD.selectionLayer, NEW[CDColors.Brick←[0ffffH, 0ffffH, 0ffffH, 0ffffH]], bit4];
CDColors.DefineColor[CD.selectionLayer, NEW[CDColors.Brick←[0ffffH, 0ffffH, 0ffffH, 0ffffH]], bit8];
CDColors.DefineColor[CD.commentLayer, NEW[CDColors.Brick←[07777h, 0bbbbH, 0ddddH, 0eeeeH]], bw];
CDColors.DefineColor[CD.commentLayer, NEW[CDColors.Brick←[0bbbbH, 0bbbbH, 0bbbbH, 0bbbbH]], bit4];
CDColors.DefineColor[CD.commentLayer, NEW[CDColors.Brick←[07f7fh, 07f7fh, 07f7fh, 07f7fh]], bit8];
CDColors.DefineColor[CD.commentLayer, NEW[CDColors.Brick←[07f00h, 0007fh, 07f00h, 0007fh]], bit8, pushedOut];
CDColors.DefineColor[CD.FetchLayer[NIL, $blue], NEW[CDColors.Brick←[1028, 1028, 1028, 1028]], bw];
CDColors.DefineColor[CD.FetchLayer[NIL, $red], NEW[CDColors.Brick←[4112, 4112, 4112, 4112]], bw];
CDColors.DefineColor[CD.FetchLayer[NIL, $green], NEW[CDColors.Brick←[257, 257, 257, 257]], bw];
CDColors.DefineColor[CD.FetchLayer[NIL, $yellow], NEW[CDColors.Brick←[8224, 8224, 8224, 8224]], bw];
CDColors.DefineColor[CD.FetchLayer[NIL, $blue], NEW[CDColors.Brick←[1028, 1028, 1028, 1028]], bit8];
CDColors.DefineColor[CD.FetchLayer[NIL, $red], NEW[CDColors.Brick←[4112, 4112, 4112, 4112]], bit8];
CDColors.DefineColor[CD.FetchLayer[NIL, $green], NEW[CDColors.Brick←[257, 257, 257, 257]], bit8];
CDColors.DefineColor[CD.FetchLayer[NIL, $yellow], NEW[CDColors.Brick←[8224, 8224, 8224, 8224]], bit8];
CDColors.DefineIColor[CD.commentLayer, ImagerColor.ColorFromRGB[[0, 0, 0]], bit8];
CDColors.DefineIColor[CD.commentLayer, ImagerColor.ColorFromRGB[[0, 0, 0]], bw];
CDColors.DefineIColor[CD.FetchLayer[NIL, $green], ImagerColor.ColorFromRGB[[0, 1, 0]], bit8];
CDColors.DefineIColor[CD.FetchLayer[NIL, $green], ImagerColor.ColorFromRGB[[0, 1, 0]], bw];
CDColors.DefineIColor[CD.FetchLayer[NIL, $blue], ImagerColor.ColorFromRGB[[0, 0, 1]], bit8];
CDColors.DefineIColor[CD.FetchLayer[NIL, $blue], ImagerColor.ColorFromRGB[[0, 0, 1]], bw];
CDColors.DefineIColor[CD.FetchLayer[NIL, $red], ImagerColor.ColorFromRGB[[1, 0, 0]], bit8];
CDColors.DefineIColor[CD.FetchLayer[NIL, $red], ImagerColor.ColorFromRGB[[1, 0, 0]], bw];
CDColors.DefineIColor[CD.FetchLayer[NIL, $yellow], ImagerColor.ColorFromRGB[[1, 1, 0]], bit8];
CDColors.DefineIColor[CD.FetchLayer[NIL, $yellow], ImagerColor.ColorFromRGB[[1, 1, 0]], bw];
END.