static void _dxf_WRITE_BUFFER (void *ctx, int llx, int lly, int urx, int ury, void *buff) { ENTRY(("_dxf_WRITE_BUFFER(0x%x, %d, %d, %d, %d, 0x%x)", ctx, llx, lly, urx, ury, buff)); lrectwrite (llx, lly, urx, ury, (const unsigned long *)buff) ; EXIT(("")); }
static void _dxf_restoreZoomBox(tdmInteractor I, void *udata, float rot[4][4]) { register long *bp, *image ; register int i, iw, ih, n, y2 ; int x1, x2, y1 ; static long buff[4096] ; DEFDATA(I, tdmZoomData) ; iw = CDATA(iw) ; ih = CDATA(ih) ; image = (long *)CDATA(image) ; /* clip coords to image to avoid invalid raster positions */ x1 = (PDATA(x1)<0 ? 0 : (PDATA(x1)>(iw-1) ? iw-1 : PDATA(x1))) ; x2 = (PDATA(x2)<0 ? 0 : (PDATA(x2)>(iw-1) ? iw-1 : PDATA(x2))) ; y1 = (PDATA(y1)<0 ? 0 : (PDATA(y1)>(ih-1) ? ih-1 : PDATA(y1))) ; y2 = (PDATA(y2)<0 ? 0 : (PDATA(y2)>(ih-1) ? ih-1 : PDATA(y2))) ; lrectwrite (x1, y1, x2, y1, (const unsigned long *)image+(x1 + y1*iw)) ; if (y1 < (ih+1)) lrectwrite (x1, y1+1, x2, y1+1, (const unsigned long *)image+(x1 + (y1+1)*iw)) ; lrectwrite (x1, y2, x2, y2, (const unsigned long *)image+(x1 + y2*iw)) ; if (y2 < (ih+1)) lrectwrite (x1, y1+1, x2, y1+1, (const unsigned long *)image+(x1 + (y1+1)*iw)) ; for (bp=buff, n=x1+(y1*iw), i=y1 ; i<=y2 ; i++, n+=iw) *bp++ = image[n] ; lrectwrite (x1, y1, x1, y2, (const unsigned long *)buff) ; if (x1 < iw-1) { for (bp=buff, n=x1+1+(y1*iw), i=y1 ; i<=y2 ; i++, n+=iw) *bp++ = image[n] ; lrectwrite (x1+1, y1, x1+1, y2, (const unsigned long *)buff) ; } for (bp=buff, n=x2+(y1*iw), i=y1 ; i<=y2 ; i++, n+=iw) *bp++ = image[n] ; lrectwrite (x2, y1, x2, y2, (const unsigned long *)buff) ; if (x2 < iw-1) { for (bp=buff, n=x2+1+(y1*iw), i=y1 ; i<=y2 ; i++, n+=iw) *bp++ = image[n] ; lrectwrite (x2+1, y1, x2+1, y2, (const unsigned long *)buff) ; } }
static PyObject * svc_lrectwrite(captureobject *self, PyObject *args) { Screencoord x1, x2, y1, y2; if (!PyArg_Parse(args, "(hhhh)", &x1, &x2, &y1, &y2)) return NULL; lrectwrite(x1, x2, y1, y2, (unsigned long *) self->ob_capture); Py_INCREF(Py_None); return Py_None; }
void CosmoWindowDecoder::decode(const u_char* vh, const u_char* frame, int cc) { /*XXX*/ if (window_->width() < 300) return; #ifdef notdef static int n = 0; char wrk[8]; sprintf(wrk, "f%d", n++); int fd = open(wrk, O_WRONLY|O_CREAT|O_TRUNC, 0644); if (fd < 0) { perror(wrk); exit(1); } write(fd, frame, cc); close(fd); #endif const jpeghdr* p = (const jpeghdr*)vh; /*XXX need to handle p->type changes too!*/ if (p->q != inq_ || ch_ == 0) reset(p->q, rcvr_.width(), rcvr_.height()); static char wrk[64*1024]; memcpy(wrk, jfifhdr, sizeof(jfifhdr)); memcpy(wrk + sizeof(jfifhdr), frame, cc); cc += sizeof(jfifhdr); frame = wrk; if (vbx_ == 0) abort(); /*Single frame decompression*/ int s = clDecompress(ch_, 1, cc, frame, (void*)vbx_->buffer()); if (s != 1) { /*XXX*/ printf("clDecompress failed (%d)\n", s); exit(1); } #ifdef notdef window_->render(vbx_); window_->complete(); #endif window_->render(vbx_); #ifdef notdef lrectwrite(0, 0, window_->width() - 1, window_->height() - 1, (const u_long*)fb_); #endif }
static void _dxf_ERASE_PREVIOUS_MARKS (tdmInteractor I) { DEFDATA(I,CursorData) ; long i, mx, my, m[9] ; ENTRY(("_dxf_ERASE_PREVIOUS_MARKS(0x%x)",I)); if (!PDATA(visible)) { EXIT(("not visible")); return ; } m[0]=m[1]=m[2]=m[3]=m[4]=m[5]=m[6]=m[7]=m[8] = 0 ; /* Restore the image over the previous marks */ for ( i = 0 ; i < PDATA(piMark) ; i++ ) { /* round mark coordinates */ mx = (long)(PDATA(pXmark[i])+0.5) ; my = (long)(PDATA(pYmark[i])+0.5) ; if (!CLIPPED(mx,my)) { /* copy image to array m */ m[0] = IMAGE(long, mx-1, my-1) ; m[1] = IMAGE(long, mx, my-1) ; m[2] = IMAGE(long, mx+1, my-1) ; m[3] = IMAGE(long, mx-1, my ) ; m[4] = IMAGE(long, mx, my ) ; m[5] = IMAGE(long, mx+1, my ) ; m[6] = IMAGE(long, mx-1, my+1) ; m[7] = IMAGE(long, mx, my+1) ; m[8] = IMAGE(long, mx+1, my+1) ; /* blit m to the screen */ lrectwrite (mx-1, my-1, mx+1, my+1, (const unsigned long *)m) ; } }
static void _dxf_DRAW_GNOMON (tdmInteractor I, void *udata, float rot[4][4], int draw) { /* * draw == 1 to draw gnomon, draw == 0 to undraw. This is done with * two separate calls in order to support explicit erasure of edges for * some implementations. A draw is always preceded by an undraw and * the pair of invocations is atomic. * * Computations are done in normalized screen coordinates in order to * render arrow heads correctly. */ DEFDATA(I,tdmRotateData) ; DEFPORT(I_PORT_HANDLE) ; int dummy = 0 ; float origin[2] ; float xaxis[2], yaxis[2], zaxis[2] ; float xlabel[2], ylabel[2], zlabel[2] ; ENTRY(("_dxf_DRAW_GNOMON (0x%x, 0x%x, 0x%x, %d)",I, udata, rot, draw)); if (PDATA(font) == -1) { /* font width for axes labels in normalized coordinates */ font(0) ; PDATA(font) = 0 ; PDATA(swidth) = (float)strwidth("Z")/(float)GNOMONRADIUS ; /* 1 pixel in normalized coordinates */ PDATA(nudge) = 1.0/(float)GNOMONRADIUS ; } else font(PDATA(font)) ; if (draw) { lmcolor(LMC_COLOR) ; cpack(0xffffffff) ; linewidth(1) ; } else { if (PDATA(redrawmode) != tdmViewEchoMode) { /* * In tdmViewEchoMode (DX's Execute On Change), we are drawing * the gnomon echo on top of a background image that is redrawn * with every frame of a direct interaction. * * If we're not in that mode, the background image is static * while the gnomon echo rotates in front of it, so erasing the * gnomon means we have to repair damage to the background. We * do this by blitting a portion of the static image to the * back buffer, drawing the gnomon over that, then blitting the * combined results back to the front buffer. */ /* force graphics output into back buffer */ frontbuffer(FALSE) ; backbuffer(TRUE) ; /* erase gnomon background */ lrectwrite (PDATA(illx), PDATA(illy), PDATA(iurx), PDATA(iury), PDATA(background)) ; } #ifndef NOSHADOW /* draw wide black lines to ensure visibility against background */ lmcolor(LMC_COLOR) ; cpack(0x0) ; linewidth(2) ; #else EXIT(("No shadow")); return ; #endif } origin[0] = 0 ; origin[1] = 0 ; xaxis[0] = 0.7 * rot[0][0] ; xaxis[1] = 0.7 * rot[0][1] ; yaxis[0] = 0.7 * rot[1][0] ; yaxis[1] = 0.7 * rot[1][1] ; zaxis[0] = 0.7 * rot[2][0] ; zaxis[1] = 0.7 * rot[2][1] ; xlabel[0] = 0.8 * rot[0][0] ; xlabel[1] = 0.8 * rot[0][1] ; ylabel[0] = 0.8 * rot[1][0] ; ylabel[1] = 0.8 * rot[1][1] ; zlabel[0] = 0.8 * rot[2][0] ; zlabel[1] = 0.8 * rot[2][1] ; pushmatrix() ; loadmatrix(identity) ; bgnline() ; v2f(origin) ; v2f(xaxis) ; endline() ; _dxf_DRAW_ARROWHEAD(PORT_CTX, xaxis[0], xaxis[1]) ; bgnline() ; v2f(origin) ; v2f(yaxis) ; endline() ; _dxf_DRAW_ARROWHEAD(PORT_CTX, yaxis[0], yaxis[1]) ; bgnline() ; v2f(origin) ; v2f(zaxis) ; endline() ; _dxf_DRAW_ARROWHEAD(PORT_CTX, zaxis[0], zaxis[1]) ; if (xlabel[0] <= 0) xlabel[0] -= PDATA(swidth) ; if (xlabel[1] <= 0) xlabel[1] -= PDATA(swidth) ; if (ylabel[0] <= 0) ylabel[0] -= PDATA(swidth) ; if (ylabel[1] <= 0) ylabel[1] -= PDATA(swidth) ; if (zlabel[0] <= 0) zlabel[0] -= PDATA(swidth) ; if (zlabel[1] <= 0) zlabel[1] -= PDATA(swidth) ; #ifndef NOSHADOW if (!draw) { /* offset text slightly for shadow */ xlabel[0] += PDATA(nudge) ; xlabel[1] -= PDATA(nudge) ; ylabel[0] += PDATA(nudge) ; ylabel[1] -= PDATA(nudge) ; zlabel[0] += PDATA(nudge) ; zlabel[1] -= PDATA(nudge) ; } #endif font(0) ; cmov2 (xlabel[0], xlabel[1]) ; charstr ("X") ; cmov2 (ylabel[0], ylabel[1]) ; charstr ("Y") ; cmov2 (zlabel[0], zlabel[1]) ; charstr ("Z") ; popmatrix() ; if (draw && PDATA(redrawmode) != tdmViewEchoMode) { /* copy rendered gnomon from back buffer to front buffer */ readsource(SRC_BACK) ; frontbuffer(TRUE) ; backbuffer(FALSE) ; rectcopy (PDATA(illx), PDATA(illy), PDATA(iurx), PDATA(iury), PDATA(illx), PDATA(illy)) ; /* restore original buffer config from current tdmFrontBufferDraw */ _dxf_BUFFER_RESTORE_CONFIG (PORT_CTX, dummy, PDATA(buffermode), tdmFrontBufferDraw) ; } EXIT(("")); }
static void _dxf_DRAW_GLOBE (tdmInteractor I, void *udata, float rot[4][4], int draw) { /* * draw == 1 to draw globe, draw == 0 to undraw. This is done with two * separate calls in order to support explicit erasure of edges for * some implementations. A draw is always preceded by an undraw and * the pair of invocations is atomic. */ DEFDATA(I,tdmRotateData) ; DEFPORT(I_PORT_HANDLE) ; int u, v, on, dummy = 0 ; /* globe edge visibility flags. all globe instance share this data. */ static struct { int latvis, longvis ; } edges[LATS][LONGS] ; /* globe and globeface defined in tdmGlobeEchoDef.h */ register const float (*Globe)[LONGS][3] = globe ; register const struct Face (*Globeface)[LONGS] = globeface ; /* view normal */ register float z0, z1, z2 ; z0 = rot[0][2] ; z1 = rot[1][2] ; z2 = rot[2][2] ; #define FACEVISIBLE(u,v,z0,z1,z2) \ (Globeface[u][v].norm[0] * z0 + \ Globeface[u][v].norm[1] * z1 + \ Globeface[u][v].norm[2] * z2 > 0.0) ENTRY(("_dxf_DRAW_GLOBE (0x%x, 0x%x, 0x%x, %d)",I, udata, rot, draw)); if (draw) { lmcolor(LMC_COLOR) ; cpack(0xffffffff) ; linewidth(1) ; } else { if (PDATA(redrawmode) != tdmViewEchoMode) { /* * In tdmViewEchoMode (DX's Execute On Change), we are drawing * the globe echo on top of a background image that is redrawn * with every frame of a direct interaction. * * If we're not in that mode, the background image is static * while the globe echo rotates in front of it, so erasing the * globe means we have to repair damage to the background. We * do this by blitting a portion of the static image to the * back buffer, drawing the globe over that, then blitting the * combined results back to the front buffer. */ /* force graphics output into back (draw) buffer */ frontbuffer(FALSE) ; backbuffer(TRUE) ; /* erase globe background */ lrectwrite (PDATA(illx), PDATA(illy), PDATA(iurx), PDATA(iury), PDATA(background)) ; } #ifndef NOSHADOW /* draw wide black lines to ensure visibility against background */ lmcolor(LMC_COLOR) ; cpack(0x0) ; linewidth(2) ; #else EXIT(("No shadow")); return ; #endif } #ifndef FACEVIS /* * Compute visible edges explicitly. This method might be faster and * works in XOR mode but as implemented here is applicable only for a * globe-type object rendered with latitude and longitude lines. */ #ifndef NOSHADOW if (!draw) #endif for (u=0 ; u<LATS-1 ; u++) { if (FACEVISIBLE(u, 0, z0, z1, z2)) { edges[u][LONGS-1].latvis++ ; edges[u+1][LONGS-1].latvis++ ; edges[u][0].longvis++ ; edges[u][LONGS-1].longvis++ ; } for (v=1 ; v<LONGS ; v++) if (FACEVISIBLE(u, v, z0, z1, z2)) { edges[u][v-1].latvis++ ; edges[u+1][v-1].latvis++ ; edges[u][v].longvis++ ; edges[u][v-1].longvis++ ; } } /* north pole */ if (z1 > 0.0) for (v=0 ; v<LONGS ; v++) edges[LATS-1][v].latvis++ ; /* south pole */ if (z1 < 0.0) for (v=0 ; v<LONGS ; v++) edges[0][v].latvis++ ; /* * Draw each visible edge exactly once. */ for (u=0 ; u<LATS ; u++) { for (v=0, on=0 ; v<LONGS-1 ; v++) if (edges[u][v].latvis) { if (!on) { on = 1 ; bgnline() ; v3f(Globe[u][v]) ; } v3f (Globe[u][v+1]) ; #ifndef NOSHADOW if (draw) #endif edges[u][v].latvis = 0 ; } else if (on) { on = 0 ; endline() ; } /* close latitude line if necessary */ if (edges[u][LONGS-1].latvis) { if (!on) { bgnline() ; v3f(Globe[u][LONGS-1]) ; } v3f (Globe[u][0]) ; endline() ; #ifndef NOSHADOW if (draw) #endif edges[u][LONGS-1].latvis = 0 ; } else if (on) endline() ; } /* longitude lines */ for (v=0 ; v<LONGS ; v++) { for (u=0, on=0 ; u<LATS-1 ; u++) if (edges[u][v].longvis) { if (!on) { on = 1 ; bgnline() ; v3f(Globe[u][v]) ; } v3f(Globe[u+1][v]) ; #ifndef NOSHADOW if (draw) #endif edges[u][v].longvis = 0 ; } else if (on) { on = 0 ; endline() ; } if (on) endline() ; } #else /* * Do it the easy way: draw all visible faces regardless of shared * edges. Most edges are drawn twice, so this is slower and not * compatible with XOR rendering. */ for (u=0 ; u<LATS-1 ; u++) for (v=0 ; v<LONGS ; v++) if (FACEVISIBLE(u, v, z0, z1, z2)) poly (4, Globeface[u][v].face) ; /* north pole */ if (z1 > 0.0) poly (LONGS, Globe[LATS-1]) ; /* south pole */ if (z1 < 0.0) poly (LONGS, Globe[0]) ; #endif /* ifndef FACEVIS */ if (draw && PDATA(redrawmode) != tdmViewEchoMode) { /* copy rendered globe from back buffer to front buffer */ readsource(SRC_BACK) ; frontbuffer(TRUE) ; backbuffer(FALSE) ; rectcopy (PDATA(illx), PDATA(illy), PDATA(iurx), PDATA(iury), PDATA(illx), PDATA(illy)) ; /* restore original buffer config from current tdmFrontBufferDraw */ _dxf_BUFFER_RESTORE_CONFIG (PORT_CTX, dummy, PDATA(buffermode), tdmFrontBufferDraw) ; } EXIT(("")); }