int XInitShades(Display *display, int screen) { char *bits; int count; int chars_bitmap = char_bitmap(); int bit; bits = (char *) malloc(chars_bitmap * sizeof(char)); for (count = 0; count < XShadeMax; count++) { /* Load in the next bitmap */ for (bit = 0; bit < chars_bitmap; bit++) bits[bit] = XShadeBits[count * chars_bitmap + bit]; /* Create it and put it into the Pixmap array */ XShade[count] = XCreatePixmapFromBitmapData(display, RootWindow(display, screen), bits, XShadeWidth, XShadeWidth, BlackPixel(display, screen), WhitePixel(display, screen), DisplayPlanes(display, screen)); } TileGC = XCreateGC(display, RootWindow(display, screen), 0, NULL); XSetFillStyle(display, TileGC, FillTiled); XSetTile(display, TileGC, XShade[XShadeMax / 2]); return XShadeMax; }
cairo_status_t _cairo_xcb_surface_core_fill_boxes (cairo_xcb_surface_t *dst, const cairo_color_t *color, cairo_boxes_t *boxes) { struct _cairo_boxes_chunk *chunk; xcb_gcontext_t gc; cairo_status_t status; status = _cairo_xcb_connection_acquire (dst->connection); if (unlikely (status)) return status; status = _cairo_xcb_connection_take_socket (dst->connection); if (unlikely (status)) { _cairo_xcb_connection_release (dst->connection); return status; } gc = _cairo_xcb_screen_get_gc (dst->screen, dst->drawable, dst->depth); #if 0 xcb_pixmap_t source; source = _dither_source (dst, color); XSetTSOrigin (surface->dpy, gc, 0, 0); XSetTile (surface->dpy, gc, source); #endif for (chunk = &boxes->chunks; chunk != NULL; chunk = chunk->next) { xcb_rectangle_t *xcb_rects; int i; xcb_rects = (xcb_rectangle_t *) chunk->base; for (i = 0; i < chunk->count; i++) { int x1 = _cairo_fixed_integer_round (chunk->base[i].p1.x); int x2 = _cairo_fixed_integer_round (chunk->base[i].p2.x); int y1 = _cairo_fixed_integer_round (chunk->base[i].p1.y); int y2 = _cairo_fixed_integer_round (chunk->base[i].p2.y); xcb_rects[i].x = x1; xcb_rects[i].y = y1; xcb_rects[i].width = x2 - x1; xcb_rects[i].height = y2 - y1; } _cairo_xcb_connection_poly_fill_rectangle (dst->connection, dst->drawable, gc, chunk->count, xcb_rects); } _cairo_xcb_screen_put_gc (dst->screen, dst->depth, gc); _cairo_xcb_connection_release (dst->connection); return CAIRO_STATUS_SUCCESS; }
int XChangeShade(Display *display, int shade) { if (shade >= XShadeMax || shade < 0) { fprintf(stderr, "Shade %d, out of range\n",shade); return (-1); } XSetTile(display, TileGC, XShade[shade]); return (1); }
static void fillbox(int type, short x, short y, short w, short h) { Pixmap till_pmap; till_pmap = XCreatePixmapFromBitmapData(display, main_window, till_bits[type], till_width, till_height, forepix, backpix, DefaultDepth(display, 0)); XSetTile(display, gc, till_pmap); XSetFillStyle(display, gc, FillTiled); XFillRectangle(display, main_window, gc, x, y, w, h); XFreePixmap(display, till_pmap); }
static void fillpoly(XPoint * points, int type, int n) { Pixmap till_pmap; till_pmap = XCreatePixmapFromBitmapData(display, main_window, till_bits[type], till_width, till_height, forepix, backpix, DefaultDepth(display, 0)); XSetTile(display, gc, till_pmap); XSetFillStyle(display, gc, FillTiled); XFillPolygon(display, main_window, gc, points, n, Convex, CoordModeOrigin); XFreePixmap(display, till_pmap); }
void XImlib2Caption::draw() { XDesktopContainer * xContainer = dynamic_cast<XDesktopContainer *>(AbstractImage::container); XIconWithShadow * sIcon = dynamic_cast<XIconWithShadow *>(AbstractImage::iconParent); Display * display = xContainer->getDisplay(); int fX, fY; setXY(fX, fY); Imlib_Image cropImage = xContainer->bg->createCropImage(fX, fY, width, height, width, height); imlib_context_set_image(cropImage); imlib_context_set_drawable(window); imlib_render_image_on_drawable(0, 0); Pixmap shapeMask; imlib_render_pixmaps_for_whole_image (&pixmap, &shapeMask); XSetWindowBackgroundPixmap (display, window, pixmap); imlib_free_image(); imlib_context_set_drawable(xContainer->getRootWindow()); imlib_context_set_image(xContainer->bg->spareRoot); // if the icon shadow is enabled and the shadow is visible underneath the // text window if (sIcon && //TODO Fix this sIcon->getShadowX() > fX - sIcon->getWidth() && sIcon->getShadowY() > fY - sIcon->getHeight() && sIcon->getShadowX() < fX + sIcon->getWidth() && sIcon->getShadowY() < fY + sIcon->getHeight() ) sIcon->renderShadowToImage(pixmap, fX, fY); updateText(); XMoveWindow(display, window, fX, fY ); //apply the buffer to the window XSetFillStyle(display, gc, FillTiled); XSetTile(display, gc, pixmap); XFillRectangle(display, window, gc, 0, 0, width, height); imlib_free_pixmap_and_mask(pixmap); }
static PyObject * PaxGC_SetTile(PaxGCObject *self, PyObject*args) { PyObject *arg1; if (self->shared) { PyErr_SetString(PyExc_TypeError, "can't modify shared GC"); return NULL; } if (!PyArg_ParseTuple(args, "O", &arg1)) return NULL; if (!PaxPixmap_Check(arg1)) { if (!PyErr_Occurred()) PyErr_SetString(PyExc_TypeError, "arg1 should be Pixmap"); return NULL; } XSetTile(self->display, self->gc, PaxPixmap_AsPixmap(arg1)); Py_INCREF(Py_None); return Py_None; }
static unsigned long intermomentary_draw (Display *dpy, Window window, void *closure) { struct state *st = (struct state *) closure; int tempx; if ((st->f->cycles % 10) == 0) { /* Restart if the window size changes */ XGetWindowAttributes(dpy, window, &st->xgwa); if (st->f->height != st->xgwa.height || st->f->width != st->xgwa.width) { st->f->height = st->xgwa.height; st->f->width = st->xgwa.width; st->f->visdepth = st->xgwa.depth; build_img(dpy, window, st->f); } } blank_img(dpy, st->f->off_map, st->xgwa, st->fgc, st->f); for (tempx = 0; tempx < st->f->num; tempx++) { move_disc(st->f, tempx); render_disc(st, st->f->off_map, st->fgc, st->f, tempx); } #if 0 XSetFillStyle(dpy, st->copygc, FillTiled); XSetTile(dpy, st->copygc, st->f->off_map); XFillRectangle(dpy, window, st->copygc, 0, 0, st->f->width, st->f->height); #else if (st->f->off_map != window) XCopyArea (dpy, st->f->off_map, window, st->copygc, 0, 0, st->f->width, st->f->height, 0, 0); #endif st->f->cycles++; return st->draw_delay; }
void MP_Arc (Scene& scene, Pixel2D p, int ra, int rb, int a, int b, int mode) { int patnum; int ab; if (ra < 0) ra = 0; // just don't allow negative radius if (rb < 0) rb = 0; // sector angle ab = b-a; if (ab < 0) ab += 64*360; if (mode) { if ( scene.displaymono ) { // select a pattern with a grayscale with an intensity patnum = (int)( (1.0001-RGBintensity(scene.linecolor)) * MaxFillPattern ); // would be a solid fill if (patnum != MaxFillPattern) { XSetTile(Mp.theDisplay,scene.mpwindow->DrawGC,fill_pattern[patnum]); XSetFillStyle(Mp.theDisplay,scene.mpwindow->DrawGC,FillTiled); } } XFillArc(Mp.theDisplay,scene.mpwindow->Win(),scene.mpwindow->DrawGC, p.px-ra,p.py-rb,2*ra,2*rb,a,ab); // reset fill style if ( scene.displaymono ) XSetFillStyle(Mp.theDisplay,scene.mpwindow->DrawGC,FillSolid); } else XDrawArc(Mp.theDisplay,scene.mpwindow->Win(),scene.mpwindow->DrawGC, p.px-ra,p.py-rb,2*ra,2*rb,a,ab); }
void fillpoly (int numpoints, int *polypoints) { int i; XPoint *Points; Points = malloc (numpoints * sizeof (XPoint)); if (Points == NULL) { TcGraphResult = grNoScanMem; return; } // Convert to viewport coordinates. for (i = 0; i < numpoints; i++) { Points[i].x = TcViewLeft + *polypoints++; Points[i].y = TcViewTop + *polypoints++; } // Now do the actual drawing. XLockDisplay (TcDisplay); XSetFillStyle (TcDisplay, TcGc, FillTiled); XSetTile (TcDisplay, TcGc, TcTile); XFillPolygon (TcDisplay, TcPixmaps[TcActivePage], TcGc, Points, numpoints, Complex, CoordModeOrigin); XDrawLines (TcDisplay, TcPixmaps[TcActivePage], TcGc, Points, numpoints, CoordModeOrigin); if (TcActivePage == TcVisualPage) { XFillPolygon (TcDisplay, TcWindow, TcGc, Points, numpoints, Complex, CoordModeOrigin); XDrawLines (TcDisplay, TcWindow, TcGc, Points, numpoints, CoordModeOrigin); XSync (TcDisplay, False); } XSetFillStyle (TcDisplay, TcGc, FillSolid); XUnlockDisplay (TcDisplay); free (Points); }
void LFSTK_imageClass::LFSTK_clearWindow(void) { if(this->wc->useTile==true) { XSetTSOrigin(this->display,this->gc,0-this->gadgetGeom.x,0-this->gadgetGeom.y); XSetFillStyle(this->display,this->gc,FillTiled); XSetTile(this->display,this->gc,this->wc->tile[0]); XFillRectangle(this->display,this->window,this->gc,0,0,this->gadgetGeom.w,this->gadgetGeom.h); XSetFillStyle(this->display,this->gc,FillSolid); } else { XSetFillStyle(this->display,this->gc,FillSolid); XSetForeground(this->display,this->gc,this->wc->windowColourNames[NORMALCOLOUR].pixel); XFillRectangle(this->display,this->window,this->gc,0,0,this->gadgetGeom.w,this->gadgetGeom.h); } if(this->gotIcon==true) { XSetClipMask(this->display,this->gc,this->icon[1]); XSetClipOrigin(this->display,this->gc,0,0); XCopyArea(this->display,this->icon[0],this->window,this->gc,0,0,this->iconSize,this->iconSize,0,0); XSetClipMask(this->display,this->gc,None); } else if(this->useImage==true) { imlib_context_set_display(this->display); imlib_context_set_visual(this->visual); imlib_context_set_colormap(this->cm); imlib_context_set_drawable(this->window); imlib_context_set_image(this->image); imlib_context_set_blend(1); imlib_render_image_on_drawable_at_size(4,(this->gadgetGeom.h/2)-(this->imageHeight/2),this->imageWidth,this->imageHeight); } }
void xf_gdi_patblt(rdpUpdate* update, PATBLT_ORDER* patblt) { BRUSH* brush; Pixmap pattern; uint32 foreColor; uint32 backColor; xfInfo* xfi = GET_XFI(update); brush = &patblt->brush; xf_set_rop3(xfi, gdi_rop3_code(patblt->bRop)); foreColor = freerdp_color_convert(patblt->foreColor, xfi->srcBpp, 32, xfi->clrconv); backColor = freerdp_color_convert(patblt->backColor, xfi->srcBpp, 32, xfi->clrconv); if (brush->style & CACHED_BRUSH) { brush->data = brush_get(xfi->cache->brush, brush->index, &brush->bpp); brush->style = GDI_BS_PATTERN; } if (brush->style == GDI_BS_SOLID) { XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetForeground(xfi->display, xfi->gc, patblt->foreColor); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } else if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfi->display, xfi->gc, FillTiled); XSetTile(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XSetTile(xfi->display, xfi->gc, xfi->primary); } else { pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); XSetForeground(xfi->display, xfi->gc, backColor); XSetBackground(xfi->display, xfi->gc, foreColor); XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XSetStipple(xfi->display, xfi->gc_mono, pattern); } } else { printf("unimplemented brush style:%d\n", brush->style); } if (xfi->drawing == xfi->primary) { XSetFunction(xfi->display, xfi->gc, GXcopy); if (xfi->remote_app != True) { XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight, patblt->nLeftRect, patblt->nTopRect); } gdi_InvalidateRegion(xfi->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } }
void tedDrawShadedRectangle( AppDrawingData * add, APP_BITMAP_IMAGE shadingPixmaps[DOCsp_COUNT], int pattern, int x0, int y0, int x1, int y1 ) { if ( ! shadingPixmaps[pattern] ) { const int wide= 8; const int high= 8; const int d= 4; int t; int s= 0; int x; int y; AppDrawingData addPat; appInitDrawingData( &addPat ); shadingPixmaps[pattern]= appMakePixmap( add, wide, high );; if ( ! shadingPixmaps[pattern] ) { XDEB(shadingPixmaps[pattern]); return; } appCloneDrawingEnvironment( &addPat, add, 1.0, 0.05, shadingPixmaps[pattern] ); appDrawSetForegroundWhite( &addPat ); appDrawFillRectangle( &addPat, 0, 0, wide, high ); appDrawSetForegroundBlack( &addPat ); switch( pattern ) { case DOCspSOLID: LDEB(pattern); t= 0; s= 0; break; case DOCspBGHORIZ: case DOCspBGVERT: case DOCspBGFDIAG: case DOCspBGBDIAG: case DOCspBGCROSS: case DOCspBGDCROSS: t= 1; s= 0; break; case DOCspBGDKHORIZ: case DOCspBGDKVERT: case DOCspBGDKFDIAG: case DOCspBGDKBDIAG: case DOCspBGDKCROSS: case DOCspBGDKDCROSS: t= 2; s= 1; break; default: LDEB(pattern); return; } if ( t > 0 ) { appDrawSetLineAttributes( &addPat, t, LINEstyleSOLID, LINEcapPROJECTING, LINEjoinMITER, (unsigned char *)0, 0 ); } switch( pattern ) { case DOCspSOLID: LDEB(pattern); break; case DOCspBGHORIZ: case DOCspBGDKHORIZ: y= 0; while( y < high ) { appDrawDrawLine( &addPat, 0, y+ s, wide- 1, y+ s ); y += d; } break; case DOCspBGVERT: case DOCspBGDKVERT: x= 0; while( x < wide ) { appDrawDrawLine( &addPat, x+ s, 0, x+ s, high- 1 ); x += d; } break; case DOCspBGFDIAG: case DOCspBGDKFDIAG: x= -high; while( x < wide ) { appDrawDrawLine( &addPat, x+ s, 0, x+ high+ s, high ); x += d; } break; case DOCspBGBDIAG: case DOCspBGDKBDIAG: x= 0; while( x < wide+ high ) { appDrawDrawLine( &addPat, x, 0, x- high, high ); x += d; } break; case DOCspBGCROSS: case DOCspBGDKCROSS: y= 0; while( y < high ) { appDrawDrawLine( &addPat, 0, y+ s, wide- 1, y+ s ); y += d; } x= 0; while( x < wide ) { appDrawDrawLine( &addPat, x+ s, 0, x+ s, high- 1 ); x += d; } break; case DOCspBGDCROSS: case DOCspBGDKDCROSS: x= -high; while( x < wide ) { /* appDrawDrawLine( &addPat, x+ s, 0, x+ high+ s, high ); */ appDrawDrawLine( &addPat, x, 0, x+ high, high ); x += d; } x= 0; while( x < wide+ high ) { appDrawDrawLine( &addPat, x, 0, x- high, high ); x += d; } break; default: LDEB(pattern); return; } appCleanDrawingData( &addPat ); } # ifdef USE_MOTIF XSetFillStyle( add->addDisplay, add->addGc, FillTiled ); XSetTile( add->addDisplay, add->addGc, shadingPixmaps[pattern] ); # endif # ifdef USE_GTK gdk_gc_set_fill( add->addGc, GDK_TILED ); gdk_gc_set_tile( add->addGc, shadingPixmaps[pattern] ); # endif appDrawFillRectangle( add, x0, y0, x1- x0+ 1, y1- y0+ 1 ); # ifdef USE_MOTIF XSetFillStyle( add->addDisplay, add->addGc, FillSolid ); # endif # ifdef USE_GTK gdk_gc_set_fill( add->addGc, GDK_SOLID ); # endif return; }
void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { Pixmap pattern; rdpBrush* brush; UINT32 foreColor; UINT32 backColor; xfContext* context_ = (xfContext*) context; xfInfo* xfi = context_->xfi; xf_lock_x11(xfi, FALSE); brush = &patblt->brush; xf_set_rop3(xfi, gdi_rop3_code(patblt->bRop)); foreColor = freerdp_color_convert_var(patblt->foreColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); backColor = freerdp_color_convert_var(patblt->backColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); if (brush->style == GDI_BS_SOLID) { XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetForeground(xfi->display, xfi->gc, foreColor); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } else if (brush->style == GDI_BS_HATCHED) { pattern = xf_mono_bitmap_new(xfi, 8, 8, GDI_BS_HATCHED_PATTERNS + 8 * brush->hatch); XSetForeground(xfi->display, xfi->gc, backColor); XSetBackground(xfi->display, xfi->gc, foreColor); XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); XSetStipple(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfi->display, pattern); } else if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfi->display, xfi->gc, FillTiled); XSetTile(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XSetTile(xfi->display, xfi->gc, xfi->primary); XFreePixmap(xfi->display, pattern); } else { pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); XSetForeground(xfi->display, xfi->gc, backColor); XSetBackground(xfi->display, xfi->gc, foreColor); XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); XSetStipple(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfi->display, pattern); } } else { fprintf(stderr, "unimplemented brush style:%d\n", brush->style); } if (xfi->drawing == xfi->primary) { gdi_InvalidateRegion(xfi->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } XSetFunction(xfi->display, xfi->gc, GXcopy); xf_unlock_x11(xfi, FALSE); }
static void setupGC(Display * dpy, GC gc, unsigned long valuemask, XGCValues * values) { if (valuemask & GCFunction) XSetFunction(dpy, gc, values->function); if (valuemask & GCForeground) XSetForeground(dpy, gc, values->foreground); if (valuemask & GCBackground) XSetBackground(dpy, gc, values->background); //FIXME add save gc->ext_data values for each of these... if (valuemask & GCFont) XSetFont(dpy, gc, values->font); if (valuemask & GCGraphicsExposures) XSetGraphicsExposures(dpy, gc, values->graphics_exposures); if ((valuemask & GCClipXOrigin) && (valuemask & GCClipYOrigin)) XSetClipOrigin(dpy, gc, values->clip_x_origin, values->clip_y_origin); if (valuemask & GCClipMask) XSetClipMask(dpy, gc, values->clip_mask); if (valuemask & GCFillStyle) XSetFillStyle(dpy, gc, values->fill_style); if ((valuemask & GCTileStipXOrigin) && (valuemask & GCTileStipYOrigin)) XSetTSOrigin(dpy, gc, values->ts_x_origin, values->ts_y_origin); // FIXME if (valuemask & (GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle)) XSetLineAttributes(dpy, gc, values->line_width, values->line_style, values->cap_style, values->join_style); if (valuemask & GCFillRule) XSetFillStyle(dpy, gc, values->fill_rule); if (valuemask & GCTile) XSetTile(dpy, gc, values->tile); if (valuemask & GCStipple) XSetStipple(dpy, gc, values->stipple); if (valuemask & (GCDashOffset | GCDashList)) { // FIXME is this correct for values->dashes? if (values->dashes) { char d[2]; d[0] = d[1] = values->dashes; XSetDashes(dpy, gc, values->dash_offset, d, 2); } } if (valuemask & GCSubwindowMode) XSetSubwindowMode(dpy, gc, values->subwindow_mode); if (valuemask & GCPlaneMask) DPRINTF("XCreateGC: GCPlaneMask not implemented\n"); if (valuemask & GCArcMode) DPRINTF("XCreateGC: GCArcMode not implemented\n"); }
void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { Drawable dst; Pixmap pattern; rdpBrush* brush; uint32 foreColor; uint32 backColor; xfInfo* xfi = ((xfContext*) context)->xfi; GET_DST(xfi, dst); brush = &patblt->brush; xf_set_rop3(xfi, gdi_rop3_code(patblt->bRop)); foreColor = freerdp_color_convert_rgb(patblt->foreColor, xfi->srcBpp, 32, xfi->clrconv); backColor = freerdp_color_convert_rgb(patblt->backColor, xfi->srcBpp, 32, xfi->clrconv); if (brush->style == GDI_BS_SOLID) { XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetForeground(xfi->display, xfi->gc, foreColor); XFillRectangle(xfi->display, dst, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } else if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfi->display, xfi->gc, FillTiled); XSetTile(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, dst, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XSetTile(xfi->display, xfi->gc, xfi->primary); XFreePixmap(xfi->display, pattern); } else { pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); XSetForeground(xfi->display, xfi->gc, foreColor); XSetBackground(xfi->display, xfi->gc, backColor); XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); XSetStipple(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, dst, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfi->display, pattern); } } else { printf("unimplemented brush style:%d\n", brush->style); } if (xfi->drawing == xfi->primary) { XSetFunction(xfi->display, xfi->gc, GXcopy); if (!xfi->remote_app && !xfi->skip_bs) { XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight, patblt->nLeftRect, patblt->nTopRect); } gdi_InvalidateRegion(xfi->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } XSetFunction(xfi->display, xfi->gc, GXcopy); }
void xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) { rdpBrush* brush; xfBitmap* bitmap; UINT32 foreColor; UINT32 backColor; Pixmap pattern = 0; xfContext* context_ = (xfContext*) context; xfInfo* xfi = context_->xfi; brush = &mem3blt->brush; bitmap = (xfBitmap*) mem3blt->bitmap; xf_set_rop3(xfi, gdi_rop3_code(mem3blt->bRop)); foreColor = freerdp_color_convert_rgb(mem3blt->foreColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); backColor = freerdp_color_convert_rgb(mem3blt->backColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfi->display, xfi->gc, FillTiled); XSetTile(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); } else { pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); XSetForeground(xfi->display, xfi->gc, backColor); XSetBackground(xfi->display, xfi->gc, foreColor); XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); XSetStipple(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); } } else if (brush->style == GDI_BS_SOLID) { XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetForeground(xfi->display, xfi->gc, backColor); XSetBackground(xfi->display, xfi->gc, foreColor); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); } else { printf("Mem3Blt unimplemented brush style:%d\n", brush->style); } XCopyArea(xfi->display, bitmap->pixmap, xfi->drawing, xfi->gc, mem3blt->nXSrc, mem3blt->nYSrc, mem3blt->nWidth, mem3blt->nHeight, mem3blt->nLeftRect, mem3blt->nTopRect); if (xfi->drawing == xfi->primary) { if (xfi->remote_app != TRUE) { XCopyArea(xfi->display, bitmap->pixmap, xfi->drawable, xfi->gc, mem3blt->nXSrc, mem3blt->nYSrc, mem3blt->nWidth, mem3blt->nHeight, mem3blt->nLeftRect, mem3blt->nTopRect); } gdi_InvalidateRegion(xfi->hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight); } XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetTSOrigin(xfi->display, xfi->gc, 0, 0); if (pattern != 0) XFreePixmap(xfi->display, pattern); XSetFunction(xfi->display, xfi->gc, GXcopy); }
static BOOL xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) { int i, npoints; XPoint* points; Pixmap pattern; const rdpBrush* brush; XColor foreColor; XColor backColor; xfContext* xfc = (xfContext*) context; BOOL ret = TRUE; if (!xf_decode_color(xfc, polygon_cb->foreColor, &foreColor)) return FALSE; if (!xf_decode_color(xfc, polygon_cb->backColor, &backColor)) return FALSE; xf_lock_x11(xfc, FALSE); brush = &(polygon_cb->brush); xf_set_rop2(xfc, polygon_cb->bRop2); npoints = polygon_cb->numPoints + 1; points = malloc(sizeof(XPoint) * npoints); if (!points) { xf_unlock_x11(xfc, FALSE); return FALSE; } points[0].x = polygon_cb->xStart; points[0].y = polygon_cb->yStart; for (i = 0; i < polygon_cb->numPoints; i++) { points[i + 1].x = polygon_cb->points[i].x; points[i + 1].y = polygon_cb->points[i].y; } switch (polygon_cb->fillMode) { case GDI_FILL_ALTERNATE: /* alternate */ XSetFillRule(xfc->display, xfc->gc, EvenOddRule); break; case GDI_FILL_WINDING: /* winding */ XSetFillRule(xfc->display, xfc->gc, WindingRule); break; default: WLog_ERR(TAG, "PolygonCB unknown fillMode: %"PRIu32"", polygon_cb->fillMode); break; } if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfc->display, xfc->gc, FillTiled); XSetTile(xfc->display, xfc->gc, pattern); } else { pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data); XSetForeground(xfc->display, xfc->gc, backColor.pixel); XSetBackground(xfc->display, xfc->gc, foreColor.pixel); if (polygon_cb->backMode == BACKMODE_TRANSPARENT) XSetFillStyle(xfc->display, xfc->gc, FillStippled); else if (polygon_cb->backMode == BACKMODE_OPAQUE) XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XSetStipple(xfc->display, xfc->gc, pattern); } XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillPolygon(xfc->display, xfc->drawing, xfc->gc, points, npoints, Complex, CoordModePrevious); XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetTSOrigin(xfc->display, xfc->gc, 0, 0); XFreePixmap(xfc->display, pattern); if (xfc->drawing == xfc->primary) { if (!xf_gdi_invalidate_poly_region(xfc, points, npoints)) ret = FALSE; } } else { WLog_ERR(TAG, "PolygonCB unimplemented brush style:%"PRIu32"", brush->style); } XSetFunction(xfc->display, xfc->gc, GXcopy); free(points); xf_unlock_x11(xfc, FALSE); return ret; }
static BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) { const rdpBrush* brush; xfBitmap* bitmap; XColor foreColor; XColor backColor; Pixmap pattern = 0; xfContext* xfc = (xfContext*) context; BOOL ret = FALSE; if (!xfc->display || !xfc->drawing) return FALSE; if (!xf_decode_color(xfc, mem3blt->foreColor, &foreColor)) return FALSE; if (!xf_decode_color(xfc, mem3blt->backColor, &backColor)) return FALSE; xf_lock_x11(xfc, FALSE); brush = &mem3blt->brush; bitmap = (xfBitmap*) mem3blt->bitmap; if (!xf_set_rop3(xfc, gdi_rop3_code(mem3blt->bRop))) goto fail; switch (brush->style) { case GDI_BS_PATTERN: if (brush->bpp > 1) { pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfc->display, xfc->gc, FillTiled); XSetTile(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); } else { pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data); XSetBackground(xfc->display, xfc->gc, backColor.pixel); XSetForeground(xfc->display, xfc->gc, foreColor.pixel); XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XSetStipple(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); } break; case GDI_BS_SOLID: XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetBackground(xfc->display, xfc->gc, backColor.pixel); XSetForeground(xfc->display, xfc->gc, foreColor.pixel); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); break; default: WLog_ERR(TAG, "Mem3Blt unimplemented brush style:%"PRIu32"", brush->style); goto fail; } XCopyArea(xfc->display, bitmap->pixmap, xfc->drawing, xfc->gc, mem3blt->nXSrc, mem3blt->nYSrc, mem3blt->nWidth, mem3blt->nHeight, mem3blt->nLeftRect, mem3blt->nTopRect); ret = TRUE; if (xfc->drawing == xfc->primary) ret = gdi_InvalidateRegion(xfc->hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight); XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetTSOrigin(xfc->display, xfc->gc, 0, 0); if (pattern != 0) XFreePixmap(xfc->display, pattern); fail: XSetFunction(xfc->display, xfc->gc, GXcopy); xf_unlock_x11(xfc, FALSE); return ret; }
static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { const rdpBrush* brush; xfContext* xfc = (xfContext*) context; BOOL ret = FALSE; XColor xfg, xbg; if (!xf_decode_color(xfc, patblt->foreColor, &xfg)) return FALSE; if (!xf_decode_color(xfc, patblt->backColor, &xbg)) return FALSE; xf_lock_x11(xfc, FALSE); brush = &patblt->brush; if (!xf_set_rop3(xfc, gdi_rop3_code(patblt->bRop))) goto fail; switch (brush->style) { case GDI_BS_SOLID: XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetBackground(xfc->display, xfc->gc, xbg.pixel); XSetForeground(xfc->display, xfc->gc, xfg.pixel); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); break; case GDI_BS_HATCHED: { Pixmap pattern = xf_mono_bitmap_new(xfc, 8, 8, &GDI_BS_HATCHED_PATTERNS[8 * brush->hatch]); XSetBackground(xfc->display, xfc->gc, xbg.pixel); XSetForeground(xfc->display, xfc->gc, xfg.pixel); XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XSetStipple(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfc->display, pattern); } break; case GDI_BS_PATTERN: if (brush->bpp > 1) { Pixmap pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfc->display, xfc->gc, FillTiled); XSetTile(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XSetTile(xfc->display, xfc->gc, xfc->primary); XFreePixmap(xfc->display, pattern); } else { Pixmap pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data); XSetBackground(xfc->display, xfc->gc, xfg.pixel); XSetForeground(xfc->display, xfc->gc, xbg.pixel); XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XSetStipple(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfc->display, pattern); } break; default: WLog_ERR(TAG, "unimplemented brush style:%"PRIu32"", brush->style); goto fail; } ret = TRUE; if (xfc->drawing == xfc->primary) ret = gdi_InvalidateRegion(xfc->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); fail: XSetFunction(xfc->display, xfc->gc, GXcopy); xf_unlock_x11(xfc, FALSE); return ret; }
static void draw_one_image(Imfsample *imfsample, Drawable d, GC gc, Image *img, int sx, int sy, int sw, int sh) { int sx2, sy2; TkImage *tkimg; Tk_Window tkwin = imfsample->tkwin; Display *dpy = Tk_Display(tkwin); XColor *imagecolor = black_color; XColor *maskcolor = white_color; if (!img->istile) { /* Offset the image to draw in the middle of its area, whether larger or smaller than the given area. */ sx2 = sx + (sw - img->w) / 2; sy2 = sy + (sh - img->h) / 2; /* Only change the size of the rectangle being drawn if it's smaller than what was passed in. */ if (img->w < sw) { sx = sx2; sw = img->w; } if (img->h < sh) { sy = sy2; sh = img->h; } } /* Pick out a specific subimage if necessary. */ if (img->numsubimages > 0 && img->subimages) img = img->subimages[img->numsubimages - 1]; tkimg = (TkImage *) img->hook; if (tkimg == NULL) return; XSetClipMask(dpy, gc, None); if (tkimg->colr != None && imfsample->show_color) { if (img->istile) { XSetFillStyle(dpy, gc, FillTiled); XSetTile(dpy, gc, tkimg->colr); XFillRectangle(dpy, d, gc, sx, sy, sw, sh); } else { if (use_clip_mask) { if (tkimg->mask != None && imfsample->show_masks) { XSetClipOrigin(dpy, gc, sx2, sy2); /* Use the image's mask to do clipped drawing. */ XSetClipMask(dpy, gc, tkimg->mask); } } else { if (tkimg->mask != None && imfsample->show_masks) { XSetFunction(dpy, gc, GXand); XCopyArea(dpy, tkimg->mask, d, gc, 0, 0, sw, sh, sx, sy); } XSetFunction(dpy, gc, GXor); } /* Draw the color image. */ XCopyArea(dpy, tkimg->colr, d, gc, 0, 0, sw, sh, sx, sy); if (!use_clip_mask) XSetFunction(dpy, gc, GXcopy); } } else if (tkimg->solid != NULL && imfsample->show_color) { XSetFillStyle(dpy, gc, FillSolid); XSetForeground(dpy, gc, tkimg->solid->pixel); XFillRectangle(dpy, d, gc, sx, sy, sw, sh); } else if (tkimg->mono != None || tkimg->mask != None) { if (use_clip_mask) { /* The XFillRectangle code below does not work when we draw directly to the screen on the Mac, so we use XCopyArea with a small colored offscreen pixmap instead (this method does not work on Unix or during double buffered drawing on the Mac). */ #ifdef MAC if (!imfsample->double_buffer) { Pixmap pm = Tk_GetPixmap(dpy, Tk_WindowId(tkwin), sw, sh, DefaultDepthOfScreen(Tk_Screen(tkwin))); /* Draw the mask. */ if (tkimg->mask && imfsample->show_masks) { XSetClipMask(dpy, gc, tkimg->mask); } else { XSetClipMask(dpy, gc, tkimg->mono); } if (tkimg->mono != None) { Tk_Fill3DRectangle(tkwin, pm, white_border, 0, 0, sw, sh, 0, 0); } else { Tk_Fill3DRectangle(tkwin, pm, black_border, 0, 0, sw, sh, 0, 0); } XCopyArea(dpy, pm, Tk_WindowId(tkwin), gc, 0, 0, sw, sh, sx, sy); /* Draw the image proper. */ if (tkimg->mono != None) { XSetClipMask(dpy, gc, tkimg->mono); Tk_Fill3DRectangle(tkwin, pm, black_border, 0, 0, sw, sh, 0, 0); XCopyArea(dpy, pm, Tk_WindowId(tkwin), gc, 0, 0, sw, sh, sx, sy); } Tk_FreePixmap(dpy, pm); return; } #endif XSetFillStyle(dpy, gc, FillSolid); /* Set the color we're going to use for the mask; use the imagecolor if we'll be using the mask as the only image. */ XSetForeground(dpy, gc, (tkimg->mono == None ? imagecolor : maskcolor)->pixel); XSetClipOrigin(dpy, gc, sx2, sy2); /* Set the clip mask to be explicit mask or unit's image. */ if (tkimg->mask && imfsample->show_masks) { XSetClipMask(dpy, gc, tkimg->mask); } else { XSetClipMask(dpy, gc, tkimg->mono); } /* Draw the mask. */ XFillRectangle(dpy, d, gc, sx, sy, sw, sh); /* Draw the image proper. */ if (tkimg->mono != None) { XSetForeground(dpy, gc, imagecolor->pixel); XSetClipMask(dpy, gc, tkimg->mono); XFillRectangle(dpy, d, gc, sx, sy, sw, sh); } /* The Win32 case. */ } else { if (tkimg->mask != None && imfsample->show_masks) { XSetFunction(dpy, gc, GXand); XCopyArea(dpy, tkimg->mask, d, gc, 0, 0, sw, sh, sx, sy); } if (tkimg->mono != None) { XSetFunction(dpy, gc, GXor); XCopyArea(dpy, tkimg->mono, d, gc, 0, 0, sw, sh, sx, sy); } XSetFunction(dpy, gc, GXcopy); } } }
static void setbrushstyle (wmfAPI* API,wmfDC* dc) { wmf_x_t* ddata = WMF_X_GetData (API); wmfBMP* bmp = 0; wmfRGB pixel; wmfBrush* brush = 0; int opacity; int fill_style; U16 i; U16 j; XGCValues values; brush = WMF_DC_BRUSH (dc); values.function = Our_XROPfunction[WMF_DC_ROP (dc) - 1]; if (values.function == GXinvert) { values.function = GXxor; values.foreground = ddata->black; } else { values.foreground = get_color (API,WMF_BRUSH_COLOR (brush)); } values.background = get_color (API,WMF_DC_BACKGROUND (dc)); switch (WMF_BRUSH_STYLE (brush)) { /* TODO: these arrays are convenient but how SEG-safe are they? */ case BS_HATCHED: if (ddata->hatch != None) XFreePixmap (ddata->display,ddata->hatch); ddata->hatch = XCreateBitmapFromData (ddata->display,ddata->root, HatchBrushes[WMF_BRUSH_HATCH (brush)],8,8); fill_style = ((WMF_DC_OPAQUE (dc)) ? FillOpaqueStippled : FillStippled); XSetStipple (ddata->display,ddata->gc,ddata->hatch); break; case BS_DIBPATTERN: setdefaultstyle (API); bmp = WMF_BRUSH_BITMAP (brush); if (ddata->brush != None) { XFreePixmap (ddata->display,ddata->brush); ddata->brush = None; } if (bmp->data == 0) { fill_style = FillSolid; break; } ddata->brush = XCreatePixmap (ddata->display,ddata->root, bmp->width,bmp->height,ddata->depth); if (ddata->brush == None) { fill_style = FillSolid; break; } for (j = 0; j < bmp->height; j++) { for (i = 0; i < bmp->width; i++) { opacity = wmf_ipa_bmp_color (API,bmp,&pixel,i,j); XSetForeground (ddata->display,ddata->gc,get_color (API,&pixel)); XDrawPoint (ddata->display,ddata->brush,ddata->gc,i,j); } } XSetTile (ddata->display,ddata->gc,ddata->brush); fill_style = FillTiled; break; case BS_NULL: case BS_SOLID: case BS_PATTERN: default: fill_style = FillSolid; break; } XSetFillStyle (ddata->display,ddata->gc,fill_style); switch (WMF_DC_POLYFILL (dc)) { case ALTERNATE: values.fill_rule = EvenOddRule; break; case WINDING: values.fill_rule = WindingRule; break; default: values.fill_rule = EvenOddRule; break; } XChangeGC (ddata->display,ddata->gc,GCFunction|GCForeground|GCBackground|GCFillRule,&values); }
void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) { int i, npoints; XPoint* points; Pixmap pattern; rdpBrush* brush; UINT32 foreColor; UINT32 backColor; xfInfo* xfi = ((xfContext*) context)->xfi; brush = &(polygon_cb->brush); xf_set_rop2(xfi, polygon_cb->bRop2); foreColor = freerdp_color_convert_rgb(polygon_cb->foreColor, ((xfContext*) context)->settings->ColorDepth, xfi->bpp, xfi->clrconv); backColor = freerdp_color_convert_rgb(polygon_cb->backColor, ((xfContext*) context)->settings->ColorDepth, xfi->bpp, xfi->clrconv); npoints = polygon_cb->numPoints + 1; points = malloc(sizeof(XPoint) * npoints); points[0].x = polygon_cb->xStart; points[0].y = polygon_cb->yStart; for (i = 0; i < polygon_cb->numPoints; i++) { points[i + 1].x = polygon_cb->points[i].x; points[i + 1].y = polygon_cb->points[i].y; } switch (polygon_cb->fillMode) { case 1: /* alternate */ XSetFillRule(xfi->display, xfi->gc, EvenOddRule); break; case 2: /* winding */ XSetFillRule(xfi->display, xfi->gc, WindingRule); break; default: printf("PolygonCB unknown fillMode: %d\n", polygon_cb->fillMode); break; } if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfi->display, xfi->gc, FillTiled); XSetTile(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillPolygon(xfi->display, xfi->drawing, xfi->gc, points, npoints, Complex, CoordModePrevious); if (xfi->drawing == xfi->primary) { XFillPolygon(xfi->display, xfi->drawable, xfi->gc, points, npoints, Complex, CoordModePrevious); } XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetTSOrigin(xfi->display, xfi->gc, 0, 0); XFreePixmap(xfi->display, pattern); } else { pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); XSetForeground(xfi->display, xfi->gc, backColor); XSetBackground(xfi->display, xfi->gc, foreColor); if (polygon_cb->backMode == BACKMODE_TRANSPARENT) XSetFillStyle(xfi->display, xfi->gc, FillStippled); else if (polygon_cb->backMode == BACKMODE_OPAQUE) XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); XSetStipple(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillPolygon(xfi->display, xfi->drawing, xfi->gc, points, npoints, Complex, CoordModePrevious); if (xfi->drawing == xfi->primary) { XFillPolygon(xfi->display, xfi->drawable, xfi->gc, points, npoints, Complex, CoordModePrevious); } XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetTSOrigin(xfi->display, xfi->gc, 0, 0); XFreePixmap(xfi->display, pattern); } } else { printf("PolygonCB unimplemented brush style:%d\n", brush->style); } XSetFunction(xfi->display, xfi->gc, GXcopy); free(points); }
void WSetTile(unsigned int Index) { XSetTile (prDisplay, prGC, prPixmap[Index]); }
static void imfsample_display(ClientData cldata) { char *str; int row, col, namex, namey, n, sx, sy, update = FALSE, done; Imfsample *imfsample = (Imfsample *) cldata; Display *dpy = imfsample->display; Tk_Window tkwin = imfsample->tkwin; GC gc; Pixmap pm = None; Drawable d; Tk_Font tkfont; int winwidth = Tk_Width(Tk_Parent(tkwin)); int winheight = Tk_Height(Tk_Parent(tkwin)); char tclbuf[100]; int rslt; imfsample->update_pending = 0; if (!Tk_IsMapped(tkwin)) { return; } /* Check if we need to redraw the entire imfsample. */ if (imfsample->imfapp) { if (imfsample->oldfirst != imfsample->firstvisrow || imfsample->redraw) { imfsample->oldfirst = imfsample->firstvisrow; update = TRUE; } } /* Create a pixmap for double-buffering if necessary. */ if (imfsample->double_buffer) { update = TRUE; pm = Tk_GetPixmap(imfsample->display, Tk_WindowId(tkwin), Tk_Width(tkwin), Tk_Height(tkwin), DefaultDepthOfScreen(Tk_Screen(tkwin))); d = pm; } else { d = Tk_WindowId(tkwin); } if (black_color == NULL) { black_color = Tk_GetColor(interp, tkwin, Tk_GetUid("black")); } if (white_color == NULL) { white_color = Tk_GetColor(interp, tkwin, Tk_GetUid("white")); } if (black_border == NULL) { black_border = Tk_Get3DBorder(interp, tkwin, "black"); } if (white_border == NULL) { white_border = Tk_Get3DBorder(interp, tkwin, "white"); } /* Collect GC and font for subsequent work. */ gc = imfsample->gc; XSetClipMask(dpy, gc, None); if (imfsample->show_names) { #ifdef WIN32 tkfont = Tk_GetFont(interp, tkwin, "-family arial -size 8"); #elif defined (MAC) tkfont = Tk_GetFont(interp, tkwin, "-family helvetica -size 11"); #else tkfont = Tk_GetFont(interp, tkwin, "-family helvetica -size 12"); #endif XSetFont(imfsample->display, gc, Tk_FontId(tkfont)); } /* Redraw the entire widget background/border, but not if we are just updating the selected image. */ if (imfsample->selected == imfsample->previous /* Always redraw if we have only one image (e.g. closeups). */ || (imfsample->numimages == 1 && imfsample->selected == -1) || update) { done = FALSE; if (imfsample->with_terrain >= 0 /* Terrain tiles are not supported on Windows yet. */ && use_clip_mask) { ImageFamily *timf = imfsample->imf_list[imfsample->with_terrain]; Image *timg; TkImage *tkimg; timg = best_image(timf, 64, 64); if (timg) { tkimg = (TkImage *) timg->hook; if (tkimg && tkimg->colr) { XSetFillStyle(dpy, gc, FillTiled); XSetTile(dpy, gc, tkimg->colr); XFillRectangle(dpy, d, gc, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin)); done = TRUE; } } } if (!done) { Tk_Fill3DRectangle(tkwin, d, imfsample->bg_border, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), imfsample->border_width, imfsample->relief); } } #if 0 for (i = 0; i < imfsample->numimages; i++) { if (imf_interp_hook) imfsample->imf_list[i] = (*imf_interp_hook)(imfsample->imf_list[i], NULL, TRUE); } #endif /* Tweak the default item width/height to something better. */ if (imfsample->iheight == 0) { imfsample->iheight = 32; if (imfsample->numimages == 1) imfsample->iheight = imfsample->height; } if (imfsample->iwidth == 0) { imfsample->iwidth = 32; if (imfsample->numimages == 1) imfsample->iwidth = imfsample->width; } imfsample->eltw = imfsample->iwidth; if (imfsample->show_grid) imfsample->eltw += 2; else imfsample->eltw += 2 * imfsample->pad; if (imfsample->show_names && !imfsample->show_grid) imfsample->eltw += 80; imfsample->elth = imfsample->iheight; if (imfsample->show_grid) imfsample->elth += 2; else imfsample->elth += 2 * imfsample->pad; /* Fix a lower bound on the vertical spacing. */ /* (should be determined by choice of app font) */ if (imfsample->elth < 10 && !imfsample->show_grid) imfsample->elth = 10; /* Compute and save the number of columns to use. */ imfsample->cols = winwidth / imfsample->eltw; if (imfsample->cols <= 0) imfsample->cols = 1; /* We can get a little wider spacing by recalculating the element width. */ if (imfsample->show_names && !imfsample->show_grid) imfsample->eltw = (winwidth - 10) / imfsample->cols; imfsample->rows = imfsample->numimages / imfsample->cols; /* Account for a last partial row. */ if (imfsample->rows * imfsample->cols < imfsample->numimages) ++(imfsample->rows); /* Compute the number of visible rows. It would be time-consuming to render all the images, so try to do only the visible ones. */ imfsample->numvisrows = winheight / imfsample->elth; if (imfsample->numvisrows > imfsample->rows) imfsample->numvisrows = imfsample->rows; if (imfsample->numvisrows < 1) imfsample->numvisrows = min(1, imfsample->rows); if (imfsample->firstvisrow + imfsample->numvisrows > imfsample->rows) imfsample->firstvisrow = imfsample->rows - imfsample->numvisrows; /* Imfapp-specific code that adjusts the canvas content to fit a resized window and also sets the canvas scrollregion correctly. */ if (imfsample->imfapp && imfsample->redraw) { imfsample->width = Tk_Width(Tk_Parent(tkwin)); imfsample->height = imfsample->rows * imfsample->elth + 7; Tk_GeometryRequest(tkwin, imfsample->width, imfsample->height); /* There must be a better way to do this ... */ sprintf(tclbuf, ".images.canvas configure -scrollregion [ list 0 0 0 %d ]", imfsample->height); rslt = Tcl_Eval(interp, tclbuf); if (rslt == TCL_ERROR) { fprintf(stderr, "Error: %s\n", Tcl_GetStringResult(interp)); } /* Force a redraw of the scrollbar if the window was resized. */ if (imfsample->numimages) { sprintf(tclbuf, ".images.canvas.content yview scroll 0 units"); } else { sprintf(tclbuf, ".images.scroll set 0 1"); } rslt = Tcl_Eval(interp, tclbuf); if (rslt == TCL_ERROR) { fprintf(stderr, "Error: %s\n", Tcl_GetStringResult(interp)); } } /* Now iterate through all the images we want to draw. */ for (row = imfsample->firstvisrow; row <= (imfsample->firstvisrow + imfsample->numvisrows); ++row) { if (row < 0) continue; for (col = 0; col < imfsample->cols; ++col) { n = row * imfsample->cols + col; if (n >= imfsample->numimages) break; sx = col * imfsample->eltw; sy = (row - imfsample->firstvisrow) * imfsample->elth; /* Erase the old selected imf if we picked a new one. */ if (n == imfsample->previous && n != imfsample->selected) { done = FALSE; if (imfsample->with_terrain >= 0 /* Terrain tiles are not supported on Windows yet. */ && use_clip_mask) { ImageFamily *timf = imfsample->imf_list[imfsample->with_terrain]; Image *timg; TkImage *tkimg; timg = best_image(timf, 64, 64); if (timg) { tkimg = (TkImage *) timg->hook; if (tkimg && tkimg->colr) { XSetFillStyle(dpy, gc, FillTiled); XSetTile(dpy, gc, tkimg->colr); if (imfsample->show_grid) { XFillRectangle(dpy, d, gc, sx, sy + 2, imfsample->eltw, imfsample->elth); } else { XFillRectangle(dpy, d, gc, sx, sy + 7, imfsample->eltw, imfsample->elth); } done = TRUE; } } } if (!done) { if (imfsample->show_grid) { Tk_Fill3DRectangle(tkwin, d, imfsample->bg_border, sx, sy + 2, imfsample->eltw, imfsample->elth, imfsample->border_width, imfsample->relief); } else { Tk_Fill3DRectangle(tkwin, d, imfsample->bg_border, sx, sy + 7, imfsample->eltw, imfsample->elth, imfsample->border_width, imfsample->relief); } } } /* Just draw the old erased image if we selected a new one, else draw every image. */ if (imfsample->selected == imfsample->previous || n == imfsample->previous || update) { if (imfsample->show_grid) { Tk_Fill3DRectangle(tkwin, d, imfsample->cu_border, sx + 2, sy + 2, imfsample->iwidth, imfsample->iheight, imfsample->border_width, imfsample->relief); draw_one_main_image(imfsample, d, gc, imfsample->imf_list[n], sx + 2, sy + 2, imfsample->iwidth, imfsample->iheight); } else { draw_one_main_image(imfsample, d, gc, imfsample->imf_list[n], sx + imfsample->pad, sy + imfsample->pad, imfsample->iwidth, imfsample->iheight); } if (imfsample->show_names && !imfsample->show_grid) { namex = sx + 5; namey = sy + imfsample->elth + 3; XSetClipMask(dpy, gc, None); XSetFillStyle(dpy, gc, FillSolid); XSetForeground(dpy, gc, Tk_3DBorderColor( imfsample->fg_border)->pixel); str = imfsample->imf_list[n]->name; Tk_DrawChars(dpy, d, gc, tkfont, str, strlen(str), namex, namey); } } /* Box the selected imf. */ if (n == imfsample->selected) { XSetClipMask(dpy, gc, None); XSetFillStyle(dpy, gc, FillSolid); XSetForeground(dpy, gc, Tk_3DBorderColor(imfsample->fg_border)->pixel); if (imfsample->show_grid) { /* A rectangle on the Mac is 1 pixel smaller in both directions. */ #ifdef MAC XDrawRectangle(dpy, d, gc, sx + 2, sy + 2, imfsample->eltw - 2, imfsample->elth - 2); #else XDrawRectangle(dpy, d, gc, sx + 2, sy + 2, imfsample->eltw - 3, imfsample->elth - 3); #endif } else { #ifdef MAC XDrawRectangle(dpy, d, gc, sx, sy + 7, imfsample->eltw, imfsample->elth); #else XDrawRectangle(dpy, d, gc, sx, sy + 7, imfsample->eltw - 1, imfsample->elth - 1); #endif } } } } /* Reset the old selected image to the new one if it exists. */ if (imfsample->selected != -1) { imfsample->previous = imfsample->selected; } /* Reset the redraw flag. */ imfsample->redraw = FALSE; /* If double-buffered, copy to the screen and release the pixmap. */ if (imfsample->double_buffer) { XCopyArea(imfsample->display, pm, Tk_WindowId(tkwin), imfsample->copygc, 0, 0, (unsigned) winwidth, (unsigned) winheight, 0, 0); Tk_FreePixmap(imfsample->display, pm); } if (imfsample->show_names) { Tk_FreeFont(tkfont); } /* In theory this shouldn't be necessary, but in practice the interface widgets (esp. the progress bar fill color) are affected by the last value of the foreground left over from drawing, so set to a consistent value. */ /* (Note that as of 2000-09-16, some color errors persist, so this might not really be necessary -sts) */ XSetForeground(imfsample->display, imfsample->gc, black_color->pixel); XSetBackground(imfsample->display, imfsample->gc, white_color->pixel); XSetForeground(imfsample->display, imfsample->copygc, black_color->pixel); XSetBackground(imfsample->display, imfsample->copygc, white_color->pixel); }
void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { Pixmap pattern; rdpBrush* brush; UINT32 foreColor; UINT32 backColor; xfContext* xfc = (xfContext*) context; xf_lock_x11(xfc, FALSE); brush = &patblt->brush; xf_set_rop3(xfc, gdi_rop3_code(patblt->bRop)); foreColor = freerdp_convert_gdi_order_color(patblt->foreColor, context->settings->ColorDepth, xfc->format, xfc->palette); foreColor = xf_gdi_get_color(xfc, foreColor); backColor = freerdp_convert_gdi_order_color(patblt->backColor, context->settings->ColorDepth, xfc->format, xfc->palette); backColor = xf_gdi_get_color(xfc, backColor); if (brush->style == GDI_BS_SOLID) { XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetForeground(xfc->display, xfc->gc, foreColor); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } else if (brush->style == GDI_BS_HATCHED) { pattern = xf_mono_bitmap_new(xfc, 8, 8, GDI_BS_HATCHED_PATTERNS + 8 * brush->hatch); XSetForeground(xfc->display, xfc->gc, backColor); XSetBackground(xfc->display, xfc->gc, foreColor); XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XSetStipple(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfc->display, pattern); } else if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfc->display, xfc->gc, FillTiled); XSetTile(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XSetTile(xfc->display, xfc->gc, xfc->primary); XFreePixmap(xfc->display, pattern); } else { pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data); XSetForeground(xfc->display, xfc->gc, backColor); XSetBackground(xfc->display, xfc->gc, foreColor); XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XSetStipple(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfc->display, pattern); } } else { WLog_ERR(TAG, "unimplemented brush style:%d", brush->style); } if (xfc->drawing == xfc->primary) { XSetFunction(xfc->display, xfc->gc, GXcopy); if (!xfc->remote_app) { XCopyArea(xfc->display, xfc->primary, xfc->drawable, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight, patblt->nLeftRect, patblt->nTopRect); } gdi_InvalidateRegion(xfc->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } XSetFunction(xfc->display, xfc->gc, GXcopy); xf_unlock_x11(xfc, FALSE); }