📄 srvfunc.c
字号:
GdEllipse(dp->psd, dp->x + x, dp->y + y, rx, ry, FALSE); break; } SERVER_UNLOCK();}/* * Fill an ellipse in the specified drawable using the specified * graphics context. Integer only. */voidGrFillEllipse(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE rx, GR_SIZE ry){ GR_DRAWABLE *dp; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: GdEllipse(dp->psd, dp->x + x, dp->y + y, rx, ry, TRUE); break; } SERVER_UNLOCK();}/* * Draw an arc, pie or ellipse in the specified drawable using * the specified graphics context. Integer only. */void GrArc(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE rx, GR_SIZE ry, GR_COORD ax, GR_COORD ay, GR_COORD bx, GR_COORD by, int type){ GR_DRAWABLE *dp; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: GdArc(dp->psd, dp->x + x, dp->y + y, rx, ry, ax, ay, bx, by, type); break; } SERVER_UNLOCK();}/* * Draw an arc or pie in the specified drawable using * the specified graphics context. Requires floating point. */voidGrArcAngle(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE rx, GR_SIZE ry, GR_COORD angle1, GR_COORD angle2, int type){ GR_DRAWABLE *dp; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: GdArcAngle(dp->psd, dp->x + x, dp->y + y, rx, ry, angle1, angle2, type); break; } SERVER_UNLOCK();}/* * Draw a rectangular area in the specified drawable using the specified * graphics, as determined by the specified bit map. This differs from * rectangle drawing in that the rectangle is drawn using the foreground * color and possibly the background color as determined by the bit map. * Each row of bits is aligned to the next bitmap word boundary (so there * is padding at the end of the row). The background bit values are only * written if the usebackground flag is set in the GC. */voidGrBitmap(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height, GR_BITMAP *imagebits){ GR_DRAWABLE *dp; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: GdBitmap(dp->psd, dp->x + x, dp->y + y, width, height, imagebits); break; } SERVER_UNLOCK();}/* draw a multicolor image at x, y*/voidGrDrawImageBits(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_IMAGE_HDR *pimage){ GR_DRAWABLE *dp; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: GdDrawImage(dp->psd, dp->x + x, dp->y + y, pimage); break; } SERVER_UNLOCK();}#if MW_FEATURE_IMAGES && defined(HAVE_FILEIO)/* Load an image file from disk and display it at the specified coordinates*/voidGrDrawImageFromFile(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height, char* path, int flags){ GR_DRAWABLE *dp; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: GdDrawImageFromFile(dp->psd, dp->x + x, dp->y + y, width, height, path, flags); break; } SERVER_UNLOCK();}/* load image from file and cache it*/GR_IMAGE_IDGrLoadImageFromFile(char *path, int flags){ GR_IMAGE_ID id; GR_IMAGE * imagep; SERVER_LOCK(); id = GdLoadImageFromFile(&scrdev, path, flags); if (!id) { SERVER_UNLOCK(); return 0; } imagep = (GR_IMAGE *) malloc(sizeof(GR_IMAGE)); if (!imagep) { GsError(GR_ERROR_MALLOC_FAILED, 0); GdFreeImage(id); SERVER_UNLOCK(); return 0; } imagep->id = id; imagep->owner = curclient; imagep->next = listimagep; listimagep = imagep; SERVER_UNLOCK(); return id;}#endif /* MW_FEATURE_IMAGES && defined(HAVE_FILEIO) */#if MW_FEATURE_IMAGES/* Draw an image from a buffer */voidGrDrawImageFromBuffer(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height, void *buffer, int size, int flags){ GR_DRAWABLE *dp; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: GdDrawImageFromBuffer(dp->psd, dp->x + x, dp->y + y, width, height, buffer, size, flags); break; } SERVER_UNLOCK();}/* load image from the given buffer and cache it*/GR_IMAGE_IDGrLoadImageFromBuffer(void *buffer, int size, int flags){ GR_IMAGE_ID id; GR_IMAGE * imagep; SERVER_LOCK(); id = GdLoadImageFromBuffer(&scrdev, buffer, size, flags); if (!id) { SERVER_UNLOCK(); return 0; } imagep = (GR_IMAGE *) malloc(sizeof(GR_IMAGE)); if (!imagep) { GsError(GR_ERROR_MALLOC_FAILED, 0); GdFreeImage(id); SERVER_UNLOCK(); return 0; } imagep->id = id; imagep->owner = curclient; imagep->next = listimagep; listimagep = imagep; SERVER_UNLOCK(); return id;}/* draw cached image*/voidGrDrawImageToFit(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height, GR_IMAGE_ID imageid){ GR_DRAWABLE *dp; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: GdDrawImageToFit(dp->psd, dp->x + x, dp->y + y, width, height, imageid); break; } SERVER_UNLOCK();}/* free cached image*/voidGrFreeImage(GR_IMAGE_ID id){ GR_IMAGE *imagep; GR_IMAGE *previmagep; SERVER_LOCK(); for (imagep = listimagep; imagep; imagep = imagep->next) { if (imagep->id == id) { if (listimagep == imagep) listimagep = imagep->next; else { previmagep = listimagep; while (previmagep->next != imagep) previmagep = previmagep->next; previmagep->next = imagep->next; } GdFreeImage(imagep->id); free(imagep); SERVER_UNLOCK(); return; } } SERVER_UNLOCK();}/* return cached image information*/voidGrGetImageInfo(GR_IMAGE_ID id, GR_IMAGE_INFO *iip){ SERVER_LOCK(); GdGetImageInfo(id, iip); SERVER_UNLOCK();}#endif /* MW_FEATURE_IMAGES *//* * Draw a rectangular area in the specified drawable using the specified * graphics context. This differs from rectangle drawing in that the * color values for each pixel in the rectangle are specified. * The color table is indexed row by row. */voidGrArea(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height, void *pixels, int pixtype){ GR_DRAWABLE *dp; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: GdArea(dp->psd, dp->x + x, dp->y + y, width, height, pixels, pixtype); break; } SERVER_UNLOCK();}/* * Copy a rectangle from one drawable to another or the same */voidGrCopyArea(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height, GR_DRAW_ID srcid, GR_COORD srcx, GR_COORD srcy, unsigned long op){ GR_GC *gcp; GR_BOOL exposure = GR_TRUE; GR_DRAWABLE *dp; GR_WINDOW *swp; GR_PIXMAP *spp = NULL; GR_DRAW_TYPE type; PSD srcpsd; SERVER_LOCK(); srcpsd = NULL; swp = GsFindWindow(srcid); type = GsPrepareDrawing(id, gc, &dp); if (type == GR_DRAW_TYPE_NONE) { SERVER_UNLOCK(); return; } if (swp) { srcpsd = swp->psd; srcx += swp->x; srcy += swp->y; } else { spp = GsFindPixmap(srcid); if (spp) srcpsd = spp->psd; } if (!srcpsd) { SERVER_UNLOCK(); return; }#if DYNAMICREGIONS gcp = GsFindGC(gc); if (gcp) exposure = gcp->exposure; /* * Skip blit and send expose event if window is partly * obscured and source and destination are onscreen. * Also check that receiving window's first client has * selected for expose events. This keeps brain-dead * programs that don't process exposure events somewhat working. */ if (exposure && swp && (srcpsd == dp->psd) && swp->eventclients && (swp->eventclients->eventmask & GR_EVENT_MASK_EXPOSURE)) { MWRECT rc; extern MWCLIPREGION *clipregion; /* clip blit rectangle to source screen/bitmap size*/ if(srcx+width > srcpsd->xvirtres) width = srcpsd->xvirtres - srcx; if(srcy+height > srcpsd->yvirtres) height = srcpsd->yvirtres - srcy; rc.left = srcx; rc.top = srcy; rc.right = srcx + width; rc.bottom = srcy + height; /* * if source isn't entirely within clip region, then * the blit is partly obscured and will copy some garbage. * In this case, skip the blit, punt, and deliver an * exposure event instead for proper display. */ if (GdRectInRegion(clipregion, &rc) != MWRECT_ALLIN) {EPRINTF("nano-X: skipping blit, sending expose event\n"); GsDeliverExposureEvent(swp, dp->x+x, dp->y+y, width, height); SERVER_UNLOCK(); return; } }#endif if (op == MWROP_USE_GC_MODE) { GR_GC *gcp = GsFindGC(gc); if (gcp == NULL) { op = MWROP_COPY; } else { op = MWMODE_TO_ROP(gcp->mode); } } /* perform blit*/ GdCheckCursor(srcpsd, srcx, srcy, srcx+width, srcy+height); /* FIXME*/ GdBlit(dp->psd, dp->x+x, dp->y+y, width, height, srcpsd, srcx, srcy,op); GdFixCursor(srcpsd); /* FIXME*/ SERVER_UNLOCK();}/* * Read the color values from the specified rectangular area of the * specified drawable into a supplied buffer. If the drawable is a * window which is obscured by other windows, then the returned values * will include the values from the covering windows. Regions outside * of the screen boundaries, or unmapped windows will return black. */voidGrReadArea(GR_DRAW_ID id,GR_COORD x,GR_COORD y,GR_SIZE width,GR_SIZE height, GR_PIXELVAL *pixels){ GR_WINDOW *wp; GR_PIXMAP *pp = NULL; SERVER_LOCK(); if ((wp = GsFindWindow(id)) == NULL && (pp = GsFindPixmap(id)) == NULL){ GsError(GR_ERROR_BAD_WINDOW_ID, id); SERVER_UNLOCK(); return; } if (wp != NULL) { if (!wp->realized || (x >= wp->width) || (y >= wp->height) || (x + width <= 0) || (y + height <= 0)) { /* long count; * GR_PIXELVAL black; * * black = GdFindColor(BLACK); * count = width * height; * while (count-- > 0) * *pixels++ = black; */ SERVER_UNLOCK(); return; } GdReadArea(wp->psd, wp->x+x, wp->y+y, width, height, pixels); } if (pp != NULL) { if ((x >= pp->width) || (y >= pp->height) || (x + width <= 0) || (y + height <= 0)) { SERVER_UNLOCK(); return; } GdReadArea(pp->psd, x, y, width, height, pixels); } SERVER_UNLOCK();}/* * Draw a point in the specified drawable using the specified * graphics context. */voidGrPoint(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y){ GR_DRAWABLE *dp; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: GdPoint(dp->psd, dp->x + x, dp->y + y); break; } SERVER_UNLOCK();}/* * Draw points in the specified drawable using the specified * graphics context. */voidGrPoints(GR_DRAW_ID id, GR_GC_ID gc, GR_COUNT count, GR_POINT *pointtable){ GR_DRAWABLE *dp; GR_POINT *pp; GR_COUNT i; PSD psd; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: psd = dp->psd; break; default: SERVER_UNLOCK(); return; } pp = pointtable; for (i = count; i-- > 0; pp++) { GdPoint(psd, pp->x + dp->x, pp->y + dp->y); } SERVER_UNLOCK();}/* * Draw a polygon in the specified drawable using the specified * graphics context. The polygon is only complete if the first * point is repeated at the end. */voidGrPoly(GR_DRAW_ID id, GR_GC_ID gc, GR_COUNT count, GR_POINT *pointtable){ GR_DRAWABLE *dp; GR_POINT *pp; GR_COUNT i; PSD psd; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: psd = dp->psd; break; default: SERVER_UNLOCK(); return; } /* * Here for drawing to a window. * Relocate all the points relative to the window. */ pp = pointtable; for (i = count; i-- > 0; pp++) { pp->x += dp->x; pp->y += dp->y; } GdPoly(psd, count, pointtable);#ifdef NONETWORK /* * The following is only necessary when the server * isn't a separate process. We don't want to change the * user's arguments! */ pp = pointtable; for (i = count; i-- > 0; pp++) { pp->x -= dp->x; pp->y -= dp->y; }#endif SERVER_UNLOCK();}/* * Draw a filled polygon in the specified drawable using the specified * graphics context. The last point may be a duplicate of the first * point, but this is not required. */voidGrFillPoly(GR_DRAW_ID id, GR_GC_ID gc, GR_COUNT count, GR_POINT *pointtable){ GR_DRAWABLE *dp; GR_POINT *pp; GR_COUNT i; PSD psd; SERVER_LOCK(); switch (GsPrepareDrawing(id, gc, &dp)) { case GR_DRAW_TYPE_WINDOW: case GR_DRAW_TYPE_PIXMAP: psd = dp->psd; break; default: SERVER_UNLOCK(); return; } /* * Here for drawing to a window. * Relocate all the points relative to the window. */ pp = pointtable; for (i = count; i-- > 0; pp++) { pp->x += dp->x; pp->y += dp->y; } GdFillPoly(psd, count, pointtable);#ifdef NONETWORK /* * The following is only necessary when the server * isn't a separate process. We don't want to change the * user's arguments! */ pp = pointtable; for (i = count; i-- > 0; pp++) { pp->x -= dp->x; pp->y -= dp->y; }#endif SERVER_UNLOCK();}/* * Draw a text string in the specified drawable using the * specified graphics context. */voidGrText(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, void *str, GR_COUNT count, GR_TEXTFLAGS flags){ GR_DRAWABLE *dp; SERVER_LOCK(); /* default to baseline alignment if none specified*/ if((flags&(MWTF_TOP|MWTF_BASELINE|MWTF_BOTTOM)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -