/* @(#)cscript.h 9.4 88/01/19 */ /* * Copyright (c) 1985 by Sun Microsystems, Inc. */ /*- PostScript imaging in C cscript.h, Thu Sep 19 10:56:10 1985 James Gosling, Sun Microsystems */ #ifndef cs_frmoveto #ifndef MOVE_TO_FLAG #include "shape.h" #endif #ifndef cv_is_canvas #include "canvas.h" #endif #ifndef FONTHASHSIZE #include "fontcache.h" #endif #ifndef qtfree #include "qalloc.h" #endif #define cs_frmoveto(gc,x,y) (sh_frtransform(&(gc)->transform,x,y),sh_frmoveto(gc)) #define cs_moveto(gc,x,y) (sh_frtransform(&(gc)->transform,fracti(x),fracti(y)), \ sh_frmoveto(gc)) #define cs_flmoveto(gc,x,y) (sh_fltransform(&(gc)->transform,(double)(x),(double)(y)), \ sh_frmoveto(gc)) #define cs_frlineby(gc,x,y,v) (sh_frtransform(&(gc)->transform,x,y),sh_frlineby(gc,v)) #define cs_lineby(gc,x,y,v) (sh_frtransform(&(gc)->transform,fracti(x),fracti(y)), \ sh_frlineby(gc,v)) #define cs_fllineby(gc,x,y,v) (sh_fltransform(&(gc)->transform,(double)(x),(double)(y)), \ sh_frlineby(gc,v)) #define cs_frlineto(gc,x,y) (sh_frtransform(&(gc)->transform,x,y),sh_frlineby(gc,0)) #define cs_lineto(gc,x,y) (sh_frtransform(&(gc)->transform,fracti(x),fracti(y)), \ sh_frlineby(gc,0)) #define cs_fllineto(gc,x,y) (sh_fltransform(&(gc)->transform,(double)(x),(double)(y)), \ sh_frlineby(gc,0)) #define cs_frrmoveto(gc,X,Y) (sh_frdtransform(&(gc)->transform,X,Y), \ (shape_point.x += (gc)->currentpoint.x), \ (shape_point.y += (gc)->currentpoint.y), \ sh_frmoveto(gc)) #define cs_rmoveto(gc,X,Y) (sh_frdtransform(&(gc)->transform,fracti(X),fracti(Y)), \ (shape_point.x += (gc)->currentpoint.x), \ (shape_point.y += (gc)->currentpoint.y), \ sh_frmoveto(gc)) #define cs_flrmoveto(gc,X,Y) (sh_fldtransform(&(gc)->transform,(double)(X),(double)(Y)), \ (shape_point.x += (gc)->currentpoint.x), \ (shape_point.y += (gc)->currentpoint.y), \ sh_frmoveto(gc)) #define cs_frrlineby(gc,X,Y,v) (sh_frdtransform(&(gc)->transform,X,Y), \ (shape_point.x += (gc)->currentpoint.x), \ (shape_point.y += (gc)->currentpoint.y), \ sh_frlineby(gc,v)) #define cs_rlineby(gc,X,Y,v) (sh_frdtransform(&(gc)->transform,fracti(X),fracti(Y)), \ (shape_point.x += (gc)->currentpoint.x), \ (shape_point.y += (gc)->currentpoint.y), \ sh_frlineby(gc,v)) #define cs_flrlineby(gc,X,Y,v) (sh_fldtransform(&(gc)->transform,(double)(X),(double)(Y)), \ (shape_point.x += (gc)->currentpoint.x), \ (shape_point.y += (gc)->currentpoint.y), \ sh_frlineby(gc,v)) #define cs_frrlineto(gc,X,Y) (sh_frdtransform(&(gc)->transform,X,Y), \ (shape_point.x += (gc)->currentpoint.x), \ (shape_point.y += (gc)->currentpoint.y), \ sh_frlineby(gc,0)) #define cs_rlineto(gc,X,Y) (sh_frdtransform(&(gc)->transform,fracti(X),fracti(Y)), \ (shape_point.x += (gc)->currentpoint.x), \ (shape_point.y += (gc)->currentpoint.y), \ sh_frlineby(gc,0)) #define cs_flrlineto(gc,X,Y) (sh_fldtransform(&(gc)->transform,(double)(X),(double)(Y)), \ (shape_point.x += (gc)->currentpoint.x), \ (shape_point.y += (gc)->currentpoint.y), \ sh_frlineby(gc,0)) #define cs_closepath(gc) sh_closepath(gc) #define cs_setlinecap(gc,c) ((gc)->linecap = (enum cs_linecap)(c)) #define cs_currentlinecap(gc) ((gc)->linecap) #define cs_setlinejoin(gc,c) ((gc)->linejoin = (enum cs_linejoin)(c)) #define cs_currentlinejoin(gc) ((gc)->linejoin) #define cs_setmiterlimit(gc,c) ((gc)->miterlimit = c) #define cs_currentmiterlimit(gc) ((gc)->miterlimit) #define cs_setflat(gc, n) (((gc)->flatness = (n)) <= 0 \ ? (gc)->flatness = 1 \ : (n) > 127 ? (gc)->flatness = 127 : 0) #define cs_currentflat(gc) ((gc)->flatness) #define cs_setstrokequality(gc,q) (((gc)->strokequality = q) \ ? cv_evaluatestrokequality(gc) : 0) #define cs_currentstrokequality(gc) ((gc)->strokequality) #define cs_frsetlinewidth(gc,c) (((gc)->linewidth = (c)), \ ((gc)->strokequality \ ? cv_evaluatestrokequality(gc) : 0), \ ((gc)->newwidth = 1)) #define cs_frcurrentlinewidth(gc) ((gc)->linewidth) #define cs_setlinewidth(gc,c) cs_frsetlinewidth(gc,fracti(c)) #define cs_currentlinewidth(gc) roundfr(cs_frcurrentlinewidth(gc)) #define cs_frsetrgbcolor(gc,r,g,b) \ cs_setcolor(gc,cs_frrgbcolor(r,g,b)) #define cs_frsethsbcolor(gc,r,g,b) \ cs_setcolor(gc,cs_frhsbcolor(r,g,b)) #define cs_setrasteropcode(gc,rop) (((gc)->pattern = 0), ((gc)->func = (rop)<<1)) #define cs_currentrasteropcode(gc) (((gc)->func >> 1) & 0xF) #define cs_frsetgray(gc,gl) cs_frsetrgbcolor(gc,gl,gl,gl) /* #define cs_frcurrentgray(gc) (((gc)->red+(gc)->green+(gc)->blue)/3) */ #define cs_setgray(gc,gl) cs_frsetrgbcolor(gc,fracti(gl)/100,fracti(gl)/100,fracti(gl)/100) #define cs_currentgray(gc) roundfr(cs_frcurrentgray(gc)*100) #define cs_currentcolor(gc) (gc)->color #define cs_frcurrentrgbcolor(gc,r,g,b) \ ((*r) = fraction((gc)->color.red,0xFF), \ (*g) = fraction((gc)->color.green,0xFF), \ (*b) = fraction((gc)->color.blue,0xFF)) #define cs_frcurrenthsbcolor(gc,h,s,b) cs_frcolortohsb(cs_currentcolor(gc),h,s,b) #define cs_frcurrentpoint(gc,X,Y) cs_fritransform(gc, \ (gc)->currentpoint.x, (gc)->currentpoint.y, \ X, Y) #define cs_currentpoint(gc,X,Y) (cs_fritransform(gc, \ (gc)->currentpoint.x, (gc)->currentpoint.y, \ &shape_point.x, &shape_point.y), \ *(X) = shape_point.x/(1<<16), *(Y) = shape_point.y/(1<<16)) #define cs_flcurrentpoint(gc,X,Y) (cs_fritransform(gc, \ (gc)->currentpoint.x, (gc)->currentpoint.y, \ &shape_point.x, &shape_point.y), \ *(X) = floatfr(shape_point.x), *(Y) = floatfr(shape_point.y)) #define cs_hascurrentpoint(gc) (gc)->hascurrentpoint #define cs_frarc(gc, x, y, r, a1, a2) shape_arc(gc, x, y, r, a1, a2, 1) #define cs_frarcn(gc, x, y, r, a1, a2) shape_arc(gc, x, y, r, a1, a2, 0) #define cs_arc(gc, x, y, r, a1, a2) shape_arc(gc, fracti(x), fracti(y), \ fracti(r), fracti(a1), fracti(a2), 0) #define cs_arcn(gc, x, y, r, a1, a2) shape_arc(gc, fracti(x), fracti(y), \ fracti(r), fracti(a1), fracti(a2), 1) #define cs_currentcanvas(gc) ((struct canvas *)(gc)->canvas) #define cs_currentscene(gc) (((struct canvas *)(gc)->canvas)->scene) #define cs_currentpr(gc) ((struct pixrect *)((gc)->canvas)) #define cs_fill(gc) shape_fill(gc,~0) #define cs_eofill(gc) shape_fill(gc,1) #define cs_copyarea(gc,dx,dy) shape_frcopyarea(gc,~0,fracti(dx),fract(dy)) #define cs_frcopyarea(gc,dx,dy) shape_frcopyarea(gc,~0,dx,dy) #define cs_eocopyarea(gc,dx,dy) shape_frcopyarea(gc,1,fracti(dx),fract(dy)) #define cs_eofrcopyarea(gc,dx,dy) shape_frcopyarea(gc,1,dx,dy) #define cs_extenddamage(gc) cv_DO_extenddamage(gc,~0) #define cs_eoextenddamage(gc) cv_DO_extenddamage(gc,1) #define cs_clip(gc) sh_clip(gc,~0) #define cs_eoclip(gc) sh_clip(gc,1) #define cs_clipcanvas(gc) sh_clipcanvas(gc,~0) #define cs_eoclipcanvas(gc) sh_clipcanvas(gc,1) #define cs_setcanvasshape(gc,cv) cs_masksetcanvasshape(gc,cv,~0) #define cs_eosetcanvasshape(gc,cv) cs_masksetcanvasshape(gc,cv,1) #define cs_rotate(gc,a) cs_frrotate(gc,fracti(a)) #define cs_translate(gc,a,b) cs_frtranslate(gc,fracti(a),fracti(b)) #define cs_scale(gc,sx,sy) cs_frscale(gc,fracti(sx),fracti(sy)) #define cs_flrotate(gc,a) cs_frrotate(gc,fracti(a)) #define cs_fltranslate(gc,a,b) cs_frtranslate(gc,fracti(a),fracti(b)) #define cs_flscale(gc,sx,sy) cs_frscale(gc,fracti(sx),fracti(sy)) struct canvas *cv_make_screen_canvas(/*pr_open("/dev/fb")*/); struct canvas *cv_make_canvas(/*mem_create(x,y,z)*/); struct graphics_context *cs_newcontext(/*canvas*/); #define cs_canvasabove(cv) ((cv)->next) #define cs_canvasbelow(cv) ((cv)->prev) /* topcanvas returns the highest sibling of cv */ #define cs_topcanvas(cv) ((cv)->parent \ ? (cv)->parent->topchild \ ? (cv)->parent->topchild \ : (cv)->parent \ : (cv)->topchild ? (cv)->topchild : (cv)) #define cs_topchild(cv) ((cv)->topchild) #define cs_parent(cv) ((cv)->parent) #define cs_transparent(cv) ((cv)->transparent) #define cs_mapped(cv) ((cv)->map_req) #define cs_map(cv, savebits) ((cv)->map_req = 1, cv_map(cv, savebits)) #define cs_unmap(cv, savebits) ((cv)->map_req = 0, cv_unmap(cv, savebits)) #define cs_setsaveback(cv,v) (!(cv)->retained ? (cv)->saveback = (v)!=0 : 0) #define cs_retained(cv) ((cv)->retained) /* bottomcanvas returns the lowest sibling of cv */ extern struct canvas *cs_bottomcanvas(/*cv*/); /* cs_insertcanvasabove(cv,below,x,y) */ #define cs_insertcanvasbelow(cv,above,x,y) cs_insertcanvasabove(cv,cs_canvasbelow(above),x,y) #define cs_removecanvas(cv) cv_remove(cv,1) #define cs_pointinshape(sh,X,Y) \ ((X) >= (sh)->pos.x \ && (Y) >= (sh)->pos.y \ && (X) < (sh)->pos.x + (sh)->size.x \ && (Y) < (sh)->pos.y + (sh)->size.y \ && ((sh)->is_rect || cv_pointinnonrectshape((sh),(X),(Y)))) extern struct canvas *cs_locatecanvasinscene(/* scene, x, y */); extern struct canvas *cs_nextcanvasforpoint(/* canvas, x, y */); #define cs_canvasshape(cv) ((cv)->outerclip) #define cs_currentcanvasshape(gc) cs_canvasshape(cs_currentcanvas(gc)) #define cs_screentocanvas(cv,X,Y,dx,dy) \ (cv_findcanvasoffset(cv), \ (*(dx) = (X) - cfloorfr(shape_point.x)), \ (*(dy) = (Y) - cfloorfr(shape_point.y))) #define cs_canvastoscreen(cv,X,Y,dx,dy) \ (cv_findcanvasoffset(cv), \ (*(dx) = (X) + cfloorfr(shape_point.x)), \ (*(dy) = (Y) + cfloorfr(shape_point.y))) #define cs_currentcanvasspare(cv) ((cv)->spare) #define cs_setcanvasspare(cv,value) ((cv)->spare = (char *)(value)) #define cs_setcanvasdestructionhook(proc) (cv_canvasdestructionhook=(proc)) extern int (*cv_canvasdestructionhook)(); #define cs_currentpath(gc) cv_pathtoshape(gc,~0) #define cs_eocurrentpath(gc) cv_pathtoshape(gc,1) #define cs_emptyshape(sh) ((sh)==0 || (sh)->size.x<=0 || (sh)->size.y<=0) #define cs_emptypath(gc) (cs_emptyshape((gc)->shape) && \ (gc)->path.used == (gc)->path.startpos) #define cs_setprintermatch(gc,val) (((gc)->printermatch = (val)), \ ((val) ? ((gc)->transform.revision |= 1) \ : ((gc)->transform.revision &= ~1))) #define cs_currentprintermatch(gc) ((gc)->printermatch) extern struct shape *cs_cstringbbox(/*gc,string,len*/); #define cs_stringbbox(gc,string) cs_cstringbbox(gc,string,-1) extern struct text_modifiers show_modifiers; extern struct text_modifiers ashow_modifiers; extern struct text_modifiers widthshow_modifiers; extern struct text_modifiers awidthshow_modifiers; #define cs_show(gc, string) cv_show(gc, string, -1, &show_modifiers) #define cs_ashow(gc, ax, ay, string) \ ( sh_frdtransform(&(gc)->transform,fracti(ax),fracti(ay)), \ ashow_modifiers.alldelta = shape_point, \ cv_show(gc, string, strlen(string), &ashow_modifiers)) #define cs_widthshow(gc, cx, cy, ch, string) \ ( sh_frdtransform(&(gc)->transform,fracti(cx),fracti(cy)), \ widthshow_modifiers.cdelta = shape_point, \ (widthshow_modifiers.c = ch), \ cv_show(gc, string, strlen(string), &widthshow_modifiers)) #define cs_awidthshow(gc, cx, cy, ch, ax, ay, string) \ ( sh_frdtransform(&(gc)->transform, fracti(cx), fracti(cy)), \ awidthshow_modifiers.cdelta = shape_point, \ sh_frdtransform(&(gc)->transform,fracti(ax),fracti(ay)), \ awidthshow_modifiers.alldelta = shape_point, \ (awidthshow_modifiers.c = ch), \ cv_show(gc, string, strlen(string), &awidthshow_modifiers)) #define cs_cashow(gc, ax, ay, string, length) \ ( sh_frdtransform(&(gc)->transform,fracti(ax),fracti(ay)), \ ashow_modifiers.alldelta = shape_point, \ cv_show(gc, string, length, &ashow_modifiers)) #define cs_cwidthshow(gc, cx, cy, ch, string, length) \ ( sh_frdtransform(&(gc)->transform,fracti(cx),fracti(cy)), \ widthshow_modifiers.cdelta = shape_point, \ (widthshow_modifiers.c = ch), \ cv_show(gc, string, length, &widthshow_modifiers)) #define cs_cawidthshow(gc, cx, cy, ch, ax, ay, string, length) \ ( sh_frdtransform(&(gc)->transform, fracti(cx), fracti(cy)), \ awidthshow_modifiers.cdelta = shape_point, \ sh_frdtransform(&(gc)->transform,fracti(ax),fracti(ay)), \ awidthshow_modifiers.alldelta = shape_point, \ (awidthshow_modifiers.c = ch), \ cv_show(gc, string, length, &awidthshow_modifiers)) #define cs_frashow(gc, ax, ay, string) \ ( sh_frdtransform(&(gc)->transform, ax, ay), \ ashow_modifiers.alldelta = shape_point, \ cv_show(gc, string, strlen(string), &ashow_modifiers)) #define cs_frwidthshow(gc, cx, cy, ch, string) \ ( sh_frdtransform(&(gc)->transform, cx, cy), \ widthshow_modifiers.cdelta = shape_point, \ (widthshow_modifiers.c = ch), \ cv_show(gc, string, strlen(string), &widthshow_modifiers)) #define cs_frawidthshow(gc, cx, cy, ch, ax, ay, string) \ ( sh_frdtransform(&(gc)->transform, cx, cy), \ awidthshow_modifiers.cdelta = shape_point, \ sh_frdtransform(&(gc)->transform, ax, ay), \ awidthshow_modifiers.alldelta = shape_point, \ (awidthshow_modifiers.c = ch), \ cv_show(gc, string, strlen(string), &awidthshow_modifiers)) #define cs_frcashow(gc, ax, ay, string, length) \ ( sh_frdtransform(&(gc)->transform, ax, ay), \ ashow_modifiers.alldelta = shape_point, \ cv_show(gc, string, length, &ashow_modifiers)) #define cs_frcwidthshow(gc, cx, cy, ch, string, length) \ ( sh_frdtransform(&(gc)->transform, cx, cy), \ widthshow_modifiers.cdelta = shape_point, \ (widthshow_modifiers.c = ch), \ cv_show(gc, string, length, &widthshow_modifiers)) #define cs_frcawidthshow(gc, cx, cy, ch, ax, ay, string, length) \ ( sh_frdtransform(&(gc)->transform, cx, cy), \ awidthshow_modifiers.cdelta = shape_point, \ sh_frdtransform(&(gc)->transform, ax, ay), \ awidthshow_modifiers.alldelta = shape_point, \ (awidthshow_modifiers.c = ch), \ cv_show(gc, string, length, &awidthshow_modifiers)) #define cs_cshow(gc, string, length) cv_show(gc, string, length, &show_modifiers) #define cs_frtransform(gc,ix,iy,dx,dy) \ (sh_frtransform(&(gc)->transform,ix,iy),*(dx)=shape_point.x,*(dy)=shape_point.y) #define cs_fltransform(gc,ix,iy,dx,dy) \ (sh_fltransform(&(gc)->transform,ix,iy),*(dx)=shape_point.x,*(dy)=shape_point.y) #define cs_transform(gc,ix,iy,dx,dy) \ (sh_frtransform(&(gc)->transform,fracti(ix),fracti(iy)), \ *(dx)=roundfr(shape_point.x),*(dy)=roundfr(shape_point.y)) #define cs_frdtransform(gc,ix,iy,dx,dy) \ (sh_frdtransform(&(gc)->transform,ix,iy),*(dx)=shape_point.x,*(dy)=shape_point.y) #define cs_fldtransform(gc,ix,iy,dx,dy) \ (sh_fldtransform(&(gc)->transform,ix,iy), \ *(dx)=shape_point.x,*(dy)=shape_point.y) #define cs_dtransform(gc,ix,iy,dx,dy) \ (sh_frdtransform(&(gc)->transform,fracti(ix),fracti(iy)), \ *(dx)=roundfr(shape_point.x),*(dy)=roundfr(shape_point.y)) #define cs_fritransform(gc,ix,iy,dx,dy) \ (sh_fritransform(&(gc)->transform,ix,iy),*(dx)=shape_point.x,*(dy)=shape_point.y) #define cs_flitransform(gc,ix,iy,dx,dy) \ (sh_flitransform(&(gc)->transform,ix,iy), \ *(dx)=shape_rpoint.x,*(dy)=shape_rpoint.y) #define cs_itransform(gc,ix,iy,dx,dy) \ (sh_frdtransform(&(gc)->transform,fracti(ix),fracti(iy)), \ *(dx)=roundfr(shape_point.x),*(dy)=roundfr(shape_point.y)) #define cs_fridtransform(gc,ix,iy,dx,dy) \ (sh_fridtransform(&(gc)->transform,ix,iy),*(dx)=shape_point.x,*(dy)=shape_point.y) #define cs_flidtransform(gc,ix,iy,dx,dy) \ (sh_flidtransform(&(gc)->transform,ix,iy), \ *(dx)=shape_rpoint.x,*(dy)=shape_rpoint.y) #define cs_idtransform(gc,ix,iy,dx,dy) \ (sh_fridtransform(&(gc)->transform,fracti(ix),fracti(iy)), \ *(dx)=roundfr(shape_point.x),*(dy)=roundfr(shape_point.y)) FMATRIX *cs_defaultmatrix(/*pixrect*/); struct psfont *cs_findfont(/* char *name; int name_length */); struct psfont *cs_frscalefont(/*struct psfont *font; fract scale */); struct psfont *cs_frmakefont(/*struct psfont *font; MATRIX matrix */); #define cs_scalefont(font,scale) cs_frscalefont(font,fracti(scale)) #define cs_setfont(gc,FONT) { if (FONT) psf_incref(FONT); \ if ((gc)->font) psf_decref((gc)->font); \ (gc)->font = FONT;} #define cs_currentfont(gc) ((gc)->font) #define cs_frcstringwidth(gc, string, size, wx, wy) \ (cv_stringwidth(gc,string,size), \ *(wx) = shape_point.x, \ *(wy) = shape_point.y) #define cs_frstringwidth(gc,string,wx,wy) \ cs_frcstringwidth(gc,string,-1,wx,wy) #define cs_cstringwidth(gc,string,size) \ (cv_stringwidth(gc,string,size), \ roundfr(shape_point.x)) #define cs_stringwidth(gc,string) cs_cstringwidth(gc,string,-1) struct font *cs_concretefont(/*struct psfont *pf*/); #define cs_firstdamaged() cv_damage_list #define cs_nextdamaged() (cv_damage_list->indamqueue = 0, \ cv_damage_list = cv_damage_list->damnext) #define cs_damageinterest(cv,flag) ((cv)->reportdamage = (flag)) #define cs_getdamageshape(cv) ((cv)->damage) #define cs_cleardamageshape(cv) ((cv)->damage = 0) #define cs_indamagequeue(cv) ((cv)->indamqueue) #define cs_addtodamqueue(cv) { \ if (!(cv)->indamqueue) { \ (cv)->damnext = cv_damage_list; \ (cv)->indamqueue = 1; \ cv_damage_list = (cv); \ } \ } #endif