DrawSprite(SimView *view, SimSprite *sprite) { Pixmap pict, mask; int x, y, i; if (sprite->frame == 0) return; i = (sprite->frame - 1) * 2; pict = view->x->objects[sprite->type][i]; mask = view->x->objects[sprite->type][i + 1]; x = sprite->x - ((view->tile_x <<4) - view->screen_x) + sprite->x_offset; y = sprite->y - ((view->tile_y <<4) - view->screen_y) + sprite->y_offset; XSetClipMask(view->x->dpy, view->x->gc, mask); XSetClipOrigin(view->x->dpy, view->x->gc, x, y); XCopyArea(view->x->dpy, pict, view->pixmap2, view->x->gc, 0, 0, sprite->width, sprite->height, x, y); XSetClipMask(view->x->dpy, view->x->gc, None); XSetClipOrigin(view->x->dpy, view->x->gc, 0, 0); }
/*************************************************************************** ... ***************************************************************************/ Pixmap create_overlay_unit(const struct unit_type *punittype) { Pixmap pm; enum color_std bg_color; pm=XCreatePixmap(display, root_window, tileset_full_tile_width(tileset), tileset_full_tile_height(tileset), display_depth); /* Give tile a background color, based on the type of unit */ /* Should there be colors like COLOR_MAPVIEW_LAND etc? -ev */ switch (unit_color_type(punittype)) { case UNIT_BG_LAND: bg_color = COLOR_OVERVIEW_LAND; break; case UNIT_BG_SEA: bg_color = COLOR_OVERVIEW_OCEAN; break; case UNIT_BG_HP_LOSS: case UNIT_BG_AMPHIBIOUS: bg_color = COLOR_OVERVIEW_MY_UNIT; break; case UNIT_BG_FLYING: bg_color = COLOR_OVERVIEW_ENEMY_CITY; break; default: bg_color = COLOR_OVERVIEW_UNKNOWN; break; } XSetForeground(display, fill_bg_gc, get_color(tileset, bg_color)->color.pixel); XFillRectangle(display, pm, fill_bg_gc, 0,0, tileset_full_tile_width(tileset), tileset_full_tile_height(tileset)); /* If we're using flags, put one on the tile */ if(!solid_color_behind_units) { struct sprite *flag = get_nation_flag_sprite(tileset, nation_of_player(client.conn.playing)); XSetClipOrigin(display, civ_gc, 0,0); XSetClipMask(display, civ_gc, flag->mask); XCopyArea(display, flag->pixmap, pm, civ_gc, 0,0, flag->width,flag->height, 0,0); XSetClipMask(display, civ_gc, None); } /* Finally, put a picture of the unit in the tile */ /* if(i<utype_count()) */ { struct sprite *s = get_unittype_sprite(tileset, punittype, direction8_invalid()); XSetClipOrigin(display,civ_gc,0,0); XSetClipMask(display,civ_gc,s->mask); XCopyArea(display, s->pixmap, pm, civ_gc, 0,0, s->width,s->height, 0,0 ); XSetClipMask(display,civ_gc,None); } return(pm); }
void bt::drawBitmap(const bt::Bitmap &bitmap, const bt::Pen &pen, ::Drawable drawable, const bt::Rect &rect) { assert(bitmap.screen() == pen.screen()); const int x = rect.x() + (rect.width() - bitmap.width()) / 2; const int y = rect.y() + (rect.height() - bitmap.height()) / 2; XSetClipMask(pen.XDisplay(), pen.gc(), bitmap.drawable()); XSetClipOrigin(pen.XDisplay(), pen.gc(), x, y); XFillRectangle(pen.XDisplay(), drawable, pen.gc(), x, y, bitmap.width(), bitmap.height()); XSetClipOrigin(pen.XDisplay(), pen.gc(), 0, 0); XSetClipMask(pen.XDisplay(), pen.gc(), None); }
void wAppIconPaint(WAppIcon *aicon) { WApplication *wapp; WScreen *scr = aicon->icon->core->screen_ptr; if (aicon->icon->owner) wapp = wApplicationOf(aicon->icon->owner->main_window); else wapp = NULL; wIconPaint(aicon->icon); # ifdef WS_INDICATOR if (aicon->docked && scr->dock && scr->dock==aicon->dock && aicon->yindex==0) updateDockNumbers(scr); # endif if (scr->dock_dots && aicon->docked && !aicon->running && aicon->command!=NULL) { XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask); XSetClipOrigin(dpy, scr->copy_gc, 0, 0); XCopyArea(dpy, scr->dock_dots->image, aicon->icon->core->window, scr->copy_gc, 0, 0, scr->dock_dots->width, scr->dock_dots->height, 0, 0); } #ifdef HIDDENDOT if (wapp && wapp->flags.hidden) { XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask); XSetClipOrigin(dpy, scr->copy_gc, 0, 0); XCopyArea(dpy, scr->dock_dots->image, aicon->icon->core->window, scr->copy_gc, 0, 0, 7, scr->dock_dots->height, 0, 0); } #endif /* HIDDENDOT */ if (aicon->omnipresent) drawCorner(aicon->icon); XSetClipMask(dpy, scr->copy_gc, None); if (aicon->launching) { XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc, 0, 0, wPreferences.icon_size, wPreferences.icon_size); } }
void X11FilterContext::renderTextImageX11(QImage *img, const QPointF &pos) { if (img) { destroyX11Resources(); mask_q = img->createAlphaMask(); if (mask_q.isNull()) { qWarning("mask image is null"); return; } XWindowAttributes xwa; XGetWindowAttributes((::Display*)display, (::Window)drawable, &xwa); // force the stride to ensure we can safely set ximage data ptr to qimage data ptr mask_img = (XImage*)XCreateImage((::Display*)display, xwa.visual, 1, ZPixmap, 0, NULL, mask_q.width(), mask_q.height(), 8, mask_q.bytesPerLine()); if (!mask_img) { qWarning("error create mask image"); return; } ((::XImage*)mask_img)->data = (char*)mask_q.constBits(); // force the stride to ensure we can safely set ximage data ptr to qimage data ptr text_img = (XImage*)XCreateImage((::Display*)display, xwa.visual, xwa.depth, ZPixmap, 0, NULL, img->width(), img->height(), 8, img->bytesPerLine()); ((::XImage*)text_img)->data = (char*)img->constBits(); mask_pix = XCreatePixmap((::Display*)display, drawable, ((::XImage*)mask_img)->width, ((::XImage*)mask_img)->height, ((::XImage*)mask_img)->depth); ::GC mask_gc = XCreateGC((::Display*)display, (::Pixmap)mask_pix, 0, NULL); XPutImage((::Display*)display, mask_pix, mask_gc, (::XImage*)mask_img, 0,0,0,0, ((::XImage*)mask_img)->width, ((::XImage*)mask_img)->height); } XSetClipMask((::Display*)display, (::GC)gc, (::Pixmap)mask_pix); XSetClipOrigin((::Display*)display, (::GC)gc, pos.x(), pos.y()); XPutImage((::Display*)display, drawable, (::GC)gc, (::XImage*)text_img, 0, 0, pos.x(), pos.y(), ((::XImage*)text_img)->width, ((::XImage*)text_img)->height); XSetClipMask((::Display*)display, (::GC)gc, None); XSync((::Display*)display, False); }
/* Draws text with a texture * * d - target drawable * font - font to draw text * x,y - position of text * gradient - texture pixmap. size must be at least as large as text * text - text to draw * chars - chars in text */ void DrawTexturedText(Display *dpy, Drawable d, XFontStruct *font, int x, int y, Pixmap gradient, char *text, int chars) { Pixmap mask; int w,h; GC gc; XGCValues gcv; /* make the mask pixmap */ w = XTextWidth(font,text,chars); h = font->ascent+font->descent; mask=XCreatePixmap(dpy,main_win,w+1,h+1,1); gcv.foreground = 0; gcv.function = GXcopy; gcv.font = font->fid; gc = fvwmlib_XCreateGC(dpy,mask,GCFunction|GCForeground|GCFont,&gcv); XFillRectangle(dpy,mask,gc,0,0,w,h); XSetForeground(dpy,gc,1); XDrawString(dpy,mask,gc,0,font->ascent,text,chars); XFreeGC(dpy,gc); /* draw the texture */ gcv.function=GXcopy; gc = fvwmlib_XCreateGC(dpy,d,GCFunction,&gcv); XSetClipOrigin(dpy,gc,x,y); XSetClipMask(dpy,gc,mask); XCopyArea(dpy,gradient,d,gc,0,0,w,h,x,y); XFreeGC(dpy,gc); XFreePixmap(dpy,mask); }
void drawTreeLamps(void) { if(showTree==false) return; XSetClipMask(display,gc,treePixmap[ONMASK]); XSetClipOrigin(display,gc,treeX,treeY); XCopyArea(display,treePixmap[ONPIXMAP],drawOnThis,gc,0,0,treeWidth,treeHeight,treeX,treeY); if(showTreeLamps==true) { XSetClipMask(display,gc,treeLampsPixmap[treeOnOff][ONMASK]); XCopyArea(display,treeLampsPixmap[treeOnOff][ONPIXMAP],drawOnThis,gc,0,0,treeWidth,treeHeight,treeX,treeY); } if(showStar==true) { XSetClipMask(display,gc,starPixmap[_SELECTPIXMAP(ONMASK,starOnOff)]); XCopyArea(display,starPixmap[_SELECTPIXMAP(ONPIXMAP,starOnOff)],drawOnThis,gc,0,0,treeWidth,treeHeight,treeX,treeY); } if(showTinsel==true) { XSetClipMask(display,gc,tinselPixmap[ONMASK]); XCopyArea(display,tinselPixmap[ONPIXMAP],drawOnThis,gc,0,0,treeWidth,treeHeight,treeX,treeY); } }
void drawWindowSnow(void) { XWindowAttributes attr; XSync(display, true) ; XFlush(display) ; old_handler=XSetErrorHandler(ApplicationErrorHandler) ; for(int j=0;j<MAXWINDOWS;j++) { if(windowSnow[j].showing==false) continue; if(windowSnow[j].wid>0) { windowid=j; XGetWindowAttributes(display,windowSnow[j].wid,&attr); XSetClipMask(display,gc,windowSnow[j].mask); XSetClipOrigin(display,gc,windowSnow[j].x,windowSnow[j].y-windowSnow[j].maxHeight-windowYOffset); XCopyArea(display,windowSnow[j].pixmap,drawOnThis,gc,0,0,windowSnow[j].width,windowSnow[j].maxHeight,windowSnow[j].x,windowSnow[j].y-windowSnow[j].maxHeight-windowYOffset); } } XFlush(display); XSync(display,false); XSetErrorHandler(old_handler); }
void drawFalling(void) { if(showFalling==false) return; for(int j=0; j<numberOfFalling; j++) { XSetClipMask(display,gc,*(moving[j].object->mask[moving[j].imageNum])); XSetClipOrigin(display,gc,moving[j].x,moving[j].y); XCopyArea(display,*(moving[j].object->pixmap[moving[j].imageNum]),drawOnThis,gc,0,0,moving[j].object->w[0],moving[j].object->h[0],moving[j].x,moving[j].y); // imlib_context_set_blend(1); // imlib_context_set_image(moving[j].object->image); // imlib_render_image_on_drawable(moving[j].x,moving[j].y); moving[j].countDown--; if(moving[j].countDown==0) { moving[j].countDown=fallingAnimSpeed; if(moving[j].direction==true) { moving[j].imageNum++; if(moving[j].imageNum==moving[j].object->anims) moving[j].imageNum=0; } else { moving[j].imageNum--; if(moving[j].imageNum<0) moving[j].imageNum=moving[j].object->anims-1; } } } }
/** * gdk_pixbuf_xlib_render_to_drawable_alpha: * @pixbuf: A pixbuf. * @drawable: Destination drawable. * @src_x: Source X coordinate within pixbuf. * @src_y: Source Y coordinates within pixbuf. * @dest_x: Destination X coordinate within drawable. * @dest_y: Destination Y coordinate within drawable. * @width: Width of region to render, in pixels. * @height: Height of region to render, in pixels. * @alpha_mode: If the image does not have opacity information, this is ignored. * Otherwise, specifies how to handle transparency when rendering. * @alpha_threshold: If the image does have opacity information and @alpha_mode * is GDK_PIXBUF_ALPHA_BILEVEL, specifies the threshold value for opacity * values. * @dither: Dithering mode for XlibRGB. * @x_dither: X offset for dither. * @y_dither: Y offset for dither. * * Renders a rectangular portion of a pixbuf to a drawable. This is done using * XlibRGB, so the specified drawable must have the XlibRGB visual and colormap. * * When used with #GDK_PIXBUF_ALPHA_BILEVEL, this function has to create a bitmap * out of the thresholded alpha channel of the image and, it has to set this * bitmap as the clipping mask for the GC used for drawing. This can be a * significant performance penalty depending on the size and the complexity of * the alpha channel of the image. If performance is crucial, consider handling * the alpha channel yourself (possibly by caching it in your application) and * using gdk_pixbuf_xlib_render_to_drawable() or GdkRGB directly instead. **/ void gdk_pixbuf_xlib_render_to_drawable_alpha (GdkPixbuf *pixbuf, Drawable drawable, int src_x, int src_y, int dest_x, int dest_y, int width, int height, GdkPixbufAlphaMode alpha_mode, int alpha_threshold, XlibRgbDither dither, int x_dither, int y_dither) { Pixmap bitmap = 0; GC gc; XGCValues gcv; g_return_if_fail (pixbuf != NULL); g_return_if_fail (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB); g_return_if_fail (gdk_pixbuf_get_n_channels (pixbuf) == 3 || gdk_pixbuf_get_n_channels (pixbuf) == 4); g_return_if_fail (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8); g_return_if_fail (drawable != 0); g_return_if_fail (width >= 0 && height >= 0); g_return_if_fail (src_x >= 0 && src_x + width <= gdk_pixbuf_get_width (pixbuf)); g_return_if_fail (src_y >= 0 && src_y + height <= gdk_pixbuf_get_height (pixbuf)); if (width == 0 || height == 0) return; gc = XCreateGC (gdk_pixbuf_dpy, drawable, 0, &gcv); if (gdk_pixbuf_get_has_alpha (pixbuf)) { /* Right now we only support GDK_PIXBUF_ALPHA_BILEVEL, so we * unconditionally create the clipping mask. */ bitmap = XCreatePixmap (gdk_pixbuf_dpy, RootWindow (gdk_pixbuf_dpy, gdk_pixbuf_screen), width, height, 1); gdk_pixbuf_xlib_render_threshold_alpha (pixbuf, bitmap, src_x, src_y, 0, 0, width, height, alpha_threshold); XSetClipMask (gdk_pixbuf_dpy, gc, bitmap); XSetClipOrigin (gdk_pixbuf_dpy, gc, dest_x, dest_y); } gdk_pixbuf_xlib_render_to_drawable (pixbuf, drawable, gc, src_x, src_y, dest_x, dest_y, width, height, dither, x_dither, y_dither); if (bitmap) XFreePixmap (gdk_pixbuf_dpy, bitmap); XFreeGC (gdk_pixbuf_dpy, gc); }
static void paintSplitView(WMSplitView * sPtr) { W_SplitViewSubview *p; W_Screen *scr = sPtr->view->screen; int x, y, i, count; WMPixmap *dimple = scr->scrollerDimple; #if 0 printf("---- (paintSplitView - 1) ----\n"); dumpSubviews(sPtr); #endif if (!sPtr->view->flags.mapped || !sPtr->view->flags.realized) return; XClearWindow(scr->display, sPtr->view->window); count = _GetSubviewsCount(); if (count == 0) return; if (sPtr->flags.adjustOnPaint) { handleViewResized(sPtr, NULL); sPtr->flags.adjustOnPaint = 0; } XSetClipMask(scr->display, scr->clipGC, dimple->mask); if (sPtr->flags.vertical) { x = ((DIVIDER_THICKNESS - dimple->width) / 2); y = (sPtr->view->size.height - dimple->height) / 2; } else { x = (sPtr->view->size.width - dimple->width) / 2; y = ((DIVIDER_THICKNESS - dimple->height) / 2); } for (i = 0; i < count - 1; i++) { p = _GetPSubviewStructAt(i); if (sPtr->flags.vertical) x += p->size; else y += p->size; XSetClipOrigin(scr->display, scr->clipGC, x, y); XCopyArea(scr->display, dimple->pixmap, sPtr->view->window, scr->clipGC, 0, 0, dimple->width, dimple->height, x, y); if (sPtr->flags.vertical) x += DIVIDER_THICKNESS; else y += DIVIDER_THICKNESS; } #if 0 printf("---- (paintSplitView - 2) ----\n"); dumpSubviews(sPtr); #endif }
void DrawImage(Display* dpy, Drawable drawable, LightUIImage* image, int x, int y, int w, int h) { GC gc = XCreateGC(dpy, drawable, 0, NULL); XSetClipMask(dpy, gc, image->pixmask); XSetClipOrigin(dpy, gc, x, y); XPutImage(dpy, drawable, gc, image->image, 0, 0, x, y, w, h); XFreeGC(dpy, gc); }
void WMDrawPixmap(WMPixmap * pixmap, Drawable d, int x, int y) { WMScreen *scr = pixmap->screen; XSetClipMask(scr->display, scr->clipGC, pixmap->mask); XSetClipOrigin(scr->display, scr->clipGC, x, y); XCopyArea(scr->display, pixmap->pixmap, d, scr->clipGC, 0, 0, pixmap->width, pixmap->height, x, y); }
void drawSettled(void) { if(maxBottomHeight==0) return; XSetClipMask(display,gc,bottomSnow.mask); XSetClipOrigin(display,gc,0,displayHeight-bottomSnow.maxHeight-bottomYOffset); XCopyArea(display,bottomSnow.pixmap,drawOnThis,gc,0,0,displayWidth,bottomSnow.maxHeight,0,displayHeight-bottomSnow.maxHeight-bottomYOffset); }
/*----------------------------------------------------------------------*/ static void DrawPixmap(Widget w,XEvent *event,Region region) { XfeBmCascadePart * bmc = _XfeBmCascadePart(w); XmLabelPart * lp = _XfeXmLabelPart(w); Pixmap pixmap = XmUNSPECIFIED_PIXMAP; Pixmap mask = XmUNSPECIFIED_PIXMAP; Boolean armed = CB_IsArmed(w); if (armed && _XfePixmapGood(bmc->arm_pixmap)) { pixmap = bmc->arm_pixmap; if (_XfePixmapGood(bmc->arm_pixmap_mask)) { mask = bmc->arm_pixmap_mask; } } else if (_XfePixmapGood(lp->pixmap) && bmc->pixmap_width && bmc->pixmap_height) { pixmap = lp->pixmap; if (_XfePixmapGood(bmc->label_pixmap_mask)) { mask = bmc->label_pixmap_mask; } } if (_XfePixmapGood(pixmap)) { Position x = _XfePrimitiveOffset(w) + lp->margin_width; Position y = (_XfeHeight(w) - bmc->pixmap_height) / 2; if (_XfePixmapGood(mask)) { XSetClipOrigin(XtDisplay(w),bmc->pixmap_GC,x,y); XSetClipMask(XtDisplay(w),bmc->pixmap_GC,mask); } else { XSetClipMask(XtDisplay(w),bmc->pixmap_GC,None); } XCopyArea(XtDisplay(w), pixmap, _XfeWindow(w), bmc->pixmap_GC, 0,0, bmc->pixmap_width, bmc->pixmap_height, x, y); } }
static void update_display (p_state *state, Bool changed_only) { int x, y; for (y = 0; y < state->grid_height; y++) for (x = 0; x < state->grid_width; x++) { p_cell *cell = &state->cells[state->grid_width * y + x]; int width, height, tx, ty; if (changed_only && !cell->changed) continue; width = state->char_width * state->scale; height = state->char_height * state->scale; tx = x * width; ty = y * height; if (cell->state == BLANK || cell->p_char->blank_p) { XFillRectangle (state->dpy, state->window, state->gcs[BLANK], tx, ty, width, height); } else { #ifdef FUZZY_BORDER GC gc1 = state->gcs[cell->state]; GC gc2 = ((cell->state + 2) < state->ticks ? state->gcs[cell->state + 2] : 0); GC gc3 = (gc2 ? gc2 : gc1); if (gc3) XCopyPlane (state->dpy, cell->p_char->pixmap, state->window, gc3, 0, 0, width, height, tx, ty, 1L); if (gc2) { XSetClipMask (state->dpy, gc1, cell->p_char->pixmap2); XSetClipOrigin (state->dpy, gc1, tx, ty); XFillRectangle (state->dpy, state->window, gc1, tx, ty, width, height); XSetClipMask (state->dpy, gc1, None); } #else /* !FUZZY_BORDER */ XCopyPlane (state->dpy, cell->p_char->pixmap, state->window, state->gcs[cell->state], 0, 0, width, height, tx, ty, 1L); #endif /* !FUZZY_BORDER */ } cell->changed = False; } }
void SetClipOrigin(Bitmap *bitmap, GC clip_gc, int clip_x, int clip_y) { #if defined(TARGET_X11) if (clip_gc) { bitmap->clip_gc = clip_gc; XSetClipOrigin(display, bitmap->clip_gc, clip_x, clip_y); } #endif }
void clearWindowSnow(int winid,bool newrsrc) { if(newrsrc==true) { if(windowSnow[winid].lasty!=NULL) free(windowSnow[winid].lasty); if(windowSnow[winid].pixmap!=0) XFreePixmap(display,windowSnow[winid].pixmap); if(windowSnow[winid].mask!=0) XFreePixmap(display,windowSnow[winid].mask); if(windowSnow[winid].maskgc!=0) XFreeGC(display,windowSnow[winid].maskgc); windowSnow[winid].pixmap=XCreatePixmap(display,drawOnThis,windowSnow[winid].width,windowSnow[winid].maxHeight,depth); windowSnow[winid].mask=XCreatePixmap(display,drawOnThis,windowSnow[winid].width,windowSnow[winid].maxHeight,1); windowSnow[winid].maskgc=XCreateGC(display,windowSnow[winid].mask,0,NULL); windowSnow[winid].lasty=(int*)malloc(sizeof(int)*windowSnow[winid].width); } for(int j=0; j<windowSnow[winid].width; j++) windowSnow[winid].lasty[j]=windowSnow[winid].maxHeight; if(windowSnow[winid].mask!=0) { XSetClipMask(display,windowSnow[winid].maskgc,0); XSetClipOrigin(display,windowSnow[winid].maskgc,0,0); XSetForeground(display,windowSnow[winid].maskgc,blackColor); //XSetForeground(display,windowSnow[winid].maskgc,whiteColor); XSetFillStyle(display,windowSnow[winid].maskgc,FillSolid); XFillRectangle(display,windowSnow[winid].mask,windowSnow[winid].maskgc,0,0,windowSnow[winid].width,windowSnow[winid].maxHeight); XSetClipMask(display,gc,0); XSetClipOrigin(display,gc,0,0); XSetForeground(display,gc,blackColor); //XSetForeground(display,gc,whiteColor); XSetFillStyle(display,gc,FillSolid); XFillRectangle(display,windowSnow[winid].pixmap,gc,0,0,windowSnow[winid].width,windowSnow[winid].maxHeight); windowSnow[winid].keepSettling=true; } }
static void ImgBmapDisplay( ClientData clientData, /* Pointer to BitmapInstance structure for * instance to be displayed. */ Display *display, /* Display on which to draw image. */ Drawable drawable, /* Pixmap or window in which to draw image. */ int imageX, int imageY, /* Upper-left corner of region within image to * draw. */ int width, int height, /* Dimensions of region within image to draw. */ int drawableX, int drawableY) /* Coordinates within drawable that correspond * to imageX and imageY. */ { BitmapInstance *instancePtr = clientData; int masking; /* * If there's no graphics context, it means that an error occurred while * creating the image instance so it can't be displayed. */ if (instancePtr->gc == None) { return; } /* * If masking is in effect, must modify the mask origin within the * graphics context to line up with the image's origin. Then draw the * image and reset the clip origin, if there's a mask. */ masking = (instancePtr->mask != None) || (instancePtr->bg == NULL); if (masking) { XSetClipOrigin(display, instancePtr->gc, drawableX - imageX, drawableY - imageY); } XCopyPlane(display, instancePtr->bitmap, drawable, instancePtr->gc, imageX, imageY, (unsigned) width, (unsigned) height, drawableX, drawableY, 1); if (masking) { XSetClipOrigin(display, instancePtr->gc, 0, 0); } }
int BC_Pixmap::write_drawable(Drawable &pixmap, int dest_x, int dest_y, int dest_w, int dest_h, int src_x, int src_y) { //printf("BC_Pixmap::write_drawable 1\n"); if(dest_w < 0) { dest_w = w; src_x = 0; } if(dest_h < 0) { dest_h = h; src_y = 0; } if(use_alpha()) { XSetClipOrigin(top_level->display, alpha_gc, dest_x - src_x, dest_y - src_y); XCopyArea(top_level->display, this->opaque_pixmap, pixmap, alpha_gc, src_x, src_y, dest_w, dest_h, dest_x, dest_y); } else if(use_opaque()) { XCopyArea(top_level->display, this->opaque_pixmap, pixmap, top_level->gc, src_x, src_y, dest_w, dest_h, dest_x, dest_y); } //printf("BC_Pixmap::write_drawable 2\n"); return 0; }
void updateWindowSnow(movement *mov,int windownum) { int downx; Pixmap *pmm; if(maxWindowHeight==0) return; if((windowSnow[windownum].showing==true) && (windowSnow[windownum].keepSettling==true)) { downx=mov->x; if((downx>windowSnow[windownum].x) && (downx<(windowSnow[windownum].width+windowSnow[windownum].x))) { pmm=mov->object->mask[0]; downx=mov->x-windowSnow[windownum].x; if(windowSnow[windownum].lasty[downx]-settleRate<=0) { if(clearOnMaxHeight==true) clearWindowSnow(windownum,false); else windowSnow[windownum].lasty[downx]=windowSnow[windownum].maxHeight; } windowSnow[windownum].lasty[downx]=windowSnow[windownum].lasty[downx]-settleRate; if(windowSnow[windownum].lasty[downx]<=0) windowSnow[windownum].keepSettling=false; XSetClipMask(display,windowSnow[windownum].maskgc,*(pmm)); XSetClipOrigin(display,windowSnow[windownum].maskgc,downx,windowSnow[windownum].lasty[downx]); XCopyArea(display,*(mov->object->mask[0]),windowSnow[windownum].mask,windowSnow[windownum].maskgc,0,0,mov->object->w[0],mov->object->h[0],downx,windowSnow[windownum].lasty[downx]); XSetClipMask(display,gc,*(pmm)); XSetClipOrigin(display,gc,downx,windowSnow[windownum].lasty[downx]); XCopyArea(display,*(mov->object->pixmap[0]),windowSnow[windownum].pixmap,gc,0,0,mov->object->w[0],mov->object->h[0],downx,windowSnow[windownum].lasty[downx]); } } }
// Blit a surface in a window void llwl_blit_surface(lApp *app, lSurface *surface) { GC gc = app->wingc; if (surface->gc) { gc = surface->gc; XSetClipOrigin(app->display, gc, 0, 0); } XPutImage(app->display,surface->pix, app->wingc, surface->image, 0, 0, 0, 0, app->width, app->height); XCopyArea(app->display,surface->pix, app->window, gc, 0, 0, app->width, app->height, 0, 0); XFlush(app->display); }
void DrawTrayWindow(int f_state, int x, int y, int w, int h) { if ( !bUseTrayIcon ) return; if (!tray_mapped) { tray_mapped = True; if (!tray_find_dock(dpy, tray.window)) return; } if (!tray_get_visual(dpy, &tray)) { XClearArea (dpy, tray.window, x, y, w, h, False); XSetClipOrigin(dpy, tray.gc, x, y); XPutImage(dpy, tray.window, tray.gc, tray.icon[f_state], x, y, x, y, w, h); } else { Picture trayw, mask, icon; XWindowAttributes attrs; XGetWindowAttributes( dpy, tray.window , &attrs ); XRenderPictFormat* format = XRenderFindVisualFormat( dpy, attrs.visual ); XRenderPictFormat *pformat = XRenderFindStandardFormat( dpy, PictStandardA1 ); XRenderPictFormat *pformat2 = XRenderFindStandardFormat( dpy, PictStandardRGB24 ); XRenderPictureAttributes pattrs; trayw = XRenderCreatePicture(dpy, tray.window, format, 0, NULL); mask = XRenderCreatePicture(dpy, tray.icon_mask[f_state], pformat, 0, NULL); pattrs.alpha_map = mask; icon = XRenderCreatePicture(dpy, tray.picon[f_state], pformat2, CPAlphaMap, &pattrs); XRenderComposite(dpy, PictOpOver, icon, None, trayw, x,y , x,y,x,y,w,h); XRenderFreePicture(dpy,trayw); XRenderFreePicture(dpy,mask); XRenderFreePicture(dpy,icon); } }
value caml_gr_draw_image(value im, value vx, value vy) { int x = Int_val(vx); int y = Int_val(vy); int wy = Wcvt(y) + 1 - Height_im(im); int by = Bcvt(y) + 1 - Height_im(im); caml_gr_check_open(); if (Mask_im(im) != None) { if(caml_gr_remember_modeflag) { XSetClipOrigin(caml_gr_display, caml_gr_bstore.gc, x, by); XSetClipMask(caml_gr_display, caml_gr_bstore.gc, Mask_im(im)); } if(caml_gr_display_modeflag) { XSetClipOrigin(caml_gr_display, caml_gr_window.gc, x, wy); XSetClipMask(caml_gr_display, caml_gr_window.gc, Mask_im(im)); } } if(caml_gr_remember_modeflag) XCopyArea(caml_gr_display, Data_im(im), caml_gr_bstore.win, caml_gr_bstore.gc, 0, 0, Width_im(im), Height_im(im), x, by); if(caml_gr_display_modeflag) XCopyArea(caml_gr_display, Data_im(im), caml_gr_window.win, caml_gr_window.gc, 0, 0, Width_im(im), Height_im(im), x, wy); if (Mask_im(im) != None) { if(caml_gr_remember_modeflag) XSetClipMask(caml_gr_display, caml_gr_bstore.gc, None); if(caml_gr_display_modeflag) XSetClipMask(caml_gr_display, caml_gr_window.gc, None); } if(caml_gr_display_modeflag) XFlush(caml_gr_display); return Val_unit; }
void clearBottomSnow(void) { if(maxBottomHeight==0) return; for(int j=0; j<displayWidth; j++) bottomSnow.lasty[j]=maxBottomHeight; XSetClipMask(display,bottomSnow.maskgc,0); XSetClipOrigin(display,bottomSnow.maskgc,0,0); XSetForeground(display,bottomSnow.maskgc,blackColor); XSetFillStyle(display,bottomSnow.maskgc,FillSolid); XFillRectangle(display,bottomSnow.mask,bottomSnow.maskgc,0,0,displayWidth,bottomSnow.maxHeight); XSetClipMask(display,gc,0); XSetClipOrigin(display,gc,0,0); XSetForeground(display,gc,blackColor); XSetFillStyle(display,gc,FillSolid); XFillRectangle(display,bottomSnow.pixmap,gc,0,0,displayWidth,bottomSnow.maxHeight); bottomSnow.keepSettling=true; }
void updateBottomSnow(movement *mov) { int downx; Pixmap *pmm; if(maxBottomHeight==0) return; if(bottomSnow.keepSettling==true) { downx=mov->x; if((downx>=0) && (downx<displayWidth) && (maxBottomHeight>0)) { pmm=mov->object->mask[0]; if(bottomSnow.lasty[downx]-settleRate<=0) { if(clearOnMaxHeight==true) clearBottomSnow(); else bottomSnow.lasty[downx]=maxBottomHeight; } bottomSnow.lasty[downx]=bottomSnow.lasty[downx]-settleRate; if(bottomSnow.lasty[downx]<=0) bottomSnow.keepSettling=false; XSetClipMask(display,bottomSnow.maskgc,*(pmm)); XSetClipOrigin(display,bottomSnow.maskgc,downx,bottomSnow.lasty[downx]); XCopyArea(display,*(mov->object->mask[0]),bottomSnow.mask,bottomSnow.maskgc,0,0,mov->object->w[0],mov->object->h[0],downx,bottomSnow.lasty[downx]); XSetClipMask(display,gc,*(pmm)); XSetClipOrigin(display,gc,downx,bottomSnow.lasty[downx]); XCopyArea(display,*(mov->object->pixmap[0]),bottomSnow.pixmap,gc,0,0,mov->object->w[0],mov->object->h[0],downx,bottomSnow.lasty[downx]); } } }
static void draw_passwd_window (saver_info *si) { passwd_dialog_data *pw = si->pw_data; XGCValues gcv; GC gc1, gc2; /* Force redraw */ pw->passwd_changed_p = True; gcv.foreground = pw->foreground; gc1 = XCreateGC (si->dpy, si->passwd_dialog, GCForeground, &gcv); gc2 = XCreateGC (si->dpy, si->passwd_dialog, GCForeground, &gcv); if (pw->logo_pixmap) { Window root; int x, y; unsigned int w, h, bw, d; XGetGeometry (si->dpy, pw->logo_pixmap, &root, &x, &y, &w, &h, &bw, &d); XSetForeground (si->dpy, gc1, pw->foreground); XSetBackground (si->dpy, gc1, pw->background); XSetClipMask (si->dpy, gc1, pw->logo_clipmask); /* [email protected] - Let's auto center / crop this background image */ if (w > pw->width) { x = MAX((w - pw->width) / 2, 0); w = pw->width; } if (h > pw->height) { y = MAX((h - pw->height)/ 2, 0); h = pw->height; } XSetClipOrigin (si->dpy, gc1, pw->x, pw->y); if (d == 1) XCopyPlane (si->dpy, pw->logo_pixmap, si->passwd_dialog, gc1, x, y, w, h, pw->x, pw->y, 1); else XCopyArea (si->dpy, pw->logo_pixmap, si->passwd_dialog, gc1, x, y, w, h, pw->x, pw->y); } XFreeGC (si->dpy, gc1); XFreeGC (si->dpy, gc2); update_passwd_window (si, pw->passwd_string, pw->ratio); }
void drawFigure(void) { if(figureNumber==0) return; // imlib_context_set_drawable(drawOnThis); // imlib_context_set_blend(0); // imlib_context_set_filter(NULL); // imlib_context_set_mask(figurePixmap[_SELECTPIXMAP(ONMASK,figureOnOff)]); // imlib_context_set_image(figureImage[figureOnOff]); // imlib_context_set_operation(IMLIB_OP_SUBTRACT); // imlib_render_image_on_drawable(figureX,figureY); XSetClipMask(display,gc,figurePixmap[_SELECTPIXMAP(ONMASK,figureOnOff)]); XSetClipOrigin(display,gc,figureX,figureY); XCopyArea(display,figurePixmap[_SELECTPIXMAP(ONPIXMAP,figureOnOff)],drawOnThis,gc,0,0,figureW,figureH,figureX,figureY); }
/**************************************************************************** Fill the area covered by the sprite with the given color. ****************************************************************************/ void canvas_fill_sprite_area(struct canvas *pcanvas, struct sprite *psprite, struct color *pcolor, int canvas_x, int canvas_y) { if (psprite->has_mask) { XSetClipOrigin(display, fill_tile_gc, canvas_x, canvas_y); XSetClipMask(display, fill_tile_gc, psprite->mask); } XSetForeground(display, fill_tile_gc, pcolor->color.pixel); XFillRectangle(display, pcanvas->pixmap, fill_tile_gc, canvas_x, canvas_y, psprite->width, psprite->height); if (psprite->has_mask) { XSetClipMask(display, fill_tile_gc, None); } }
/* Render a single word object to the screen. */ static void draw_word (state *s, sentence *se, word *w) { if (! w->pixmap) return; if (w->x + w->width < 0 || w->y + w->height < 0 || w->x > s->xgwa.width || w->y > s->xgwa.height) return; XSetClipMask (s->dpy, se->fg_gc, w->mask); XSetClipOrigin (s->dpy, se->fg_gc, w->x, w->y); XCopyPlane (s->dpy, w->pixmap, s->b, se->fg_gc, 0, 0, w->width, w->height, w->x, w->y, 1L); }