Ejemplo n.º 1
0
func (t *textureImpl) Release() {
	t.releasedMu.Lock()
	released := t.released
	t.released = true
	t.releasedMu.Unlock()

	if released {
		return
	}
	render.FreePicture(t.s.xc, t.xp)
	xproto.FreePixmap(t.s.xc, t.xm)
}
Ejemplo n.º 2
0
func icon2md5(xid xproto.Window) []byte {
	pixmap, _ := xproto.NewPixmapId(TrayXU.Conn())
	defer xproto.FreePixmap(TrayXU.Conn(), pixmap)
	if err := composite.NameWindowPixmapChecked(TrayXU.Conn(), xid, pixmap).Check(); err != nil {
		logger.Warning("NameWindowPixmap failed:", err, xid)
		return nil
	}
	im, err := xgraphics.NewDrawable(TrayXU, xproto.Drawable(pixmap))
	if err != nil {
		logger.Warning("Create xgraphics.Image failed:", err, pixmap)
		return nil
	}
	buf := bytes.NewBuffer(nil)
	im.WritePng(buf)
	hasher := md5.New()
	hasher.Write(buf.Bytes())
	return hasher.Sum(nil)
}
Ejemplo n.º 3
0
// Destroy frees the pixmap resource being used by this image.
// It should be called whenever the image will no longer be drawn or painted.
func (im *Image) Destroy() {
	if im.Pixmap != 0 {
		xproto.FreePixmap(im.X.Conn(), im.Pixmap)
		im.Pixmap = 0
	}
}
Ejemplo n.º 4
0
// FreePixmap is a convenience function for destroying a pixmap resource
// on the X server.
// If you're using an xgraphics.Image value, then its Destroy method will call
// this for you.
func FreePixmap(X *xgbutil.XUtil, pixid xproto.Pixmap) {
	xproto.FreePixmap(X.Conn(), pixid)
}