/* invoked by main tree code to update bitmap into screen */
const char *x11_window_update_display(mame_bitmap *bitmap,
  rectangle *vis_in_dest_out, rectangle *dirty_area,
  struct sysdep_palette_struct *palette, int flags)
{
   x11_window_update_display_func(bitmap, vis_in_dest_out, dirty_area,
     palette, (unsigned char *)image->data, image->width);
   
   switch (x11_window_update_method)
   {
      case X11_MITSHM:
#ifdef USE_MITSHM
         XShmPutImage (display, window, gc, image,
           vis_in_dest_out->min_x, vis_in_dest_out->min_y,
           startx+vis_in_dest_out->min_x, starty+vis_in_dest_out->min_y,
           vis_in_dest_out->max_x - vis_in_dest_out->min_x,
           vis_in_dest_out->max_y - vis_in_dest_out->min_y, False);
#endif
         break;
      case X11_NORMAL:
         XPutImage (display, window, gc, image,
           vis_in_dest_out->min_x, vis_in_dest_out->min_y,
           startx+vis_in_dest_out->min_x, starty+vis_in_dest_out->min_y,
           vis_in_dest_out->max_x - vis_in_dest_out->min_x,
           vis_in_dest_out->max_y - vis_in_dest_out->min_y);
         break;
   }

   /* some games "flickers" with XFlush, so command line option is provided */
   if (use_xsync)
      XSync (display, False);   /* be sure to get request processed */
   else
      XFlush (display);         /* flush buffer to server */
      
   return NULL;
}
Example #2
0
Bool
put_xshm_image (Display *dpy, Drawable d, GC gc, XImage *image,
                int src_x, int src_y, int dest_x, int dest_y,
                unsigned int width, unsigned int height,
                XShmSegmentInfo *shm_info)
{
#ifdef HAVE_XSHM_EXTENSION
  assert (shm_info); /* Don't just s/XShmPutImage/put_xshm_image/. */
  if (shm_info->shmid != -1) {
    /* XShmPutImage is asynchronous; the contents of the XImage must not be
       modified until the server has placed the pixels on the screen and the
       client has received an XShmCompletionEvent. Breaking this rule can cause
       tearing. That said, put_xshm_image doesn't provide a send_event
       parameter, so we're always breaking this rule. Not that it seems to
       matter; everything (so far) looks fine without it.

       ####: Add a send_event parameter. And fake it for XPutImage.
     */
    return XShmPutImage (dpy, d, gc, image, src_x, src_y, dest_x, dest_y,
                         width, height, False);
  }
#endif /* HAVE_XSHM_EXTENSION */

  return XPutImage (dpy, d, gc, image, src_x, src_y, dest_x, dest_y,
                    width, height);
}
static void fill_rect(struct test_display *dpy,
		      Drawable d, XRenderPictFormat *format,
		      int use_shm,
		      uint8_t alu, int x, int y, int w, int h, uint32_t fg)
{
	XImage image;
	XGCValues val;
	GC gc;

	test_init_image(&image, &dpy->shm, format, w, h);

	pixman_fill((uint32_t*)image.data,
		    image.bytes_per_line/sizeof(uint32_t),
		    image.bits_per_pixel,
		    0, 0, w, h, fg);

	val.function = alu;
	gc = XCreateGC(dpy->dpy, d, GCFunction, &val);
	if (use_shm) {
		XShmPutImage(dpy->dpy, d, gc, &image, 0, 0, x, y, w, h, 0);
		XSync(dpy->dpy, 1);
	} else {
		XPutImage(dpy->dpy, d, gc, &image, 0, 0, x, y, w, h);
	}
	XFreeGC(dpy->dpy, gc);
}
Example #4
0
File: x11.c Project: aki5/libdraw3
void
drawflush(Rect r)
{
	if(shmimage->bits_per_pixel == 16){
		int i;
		uchar *src, *dst;
		int dvoff, svoff;
		int iend;

		src = screen.img;
		dst = (uchar*)shmimage->data;
		iend = screen.r.vend;
		svoff = 0;
		dvoff = 0;
		for(i = 0; i < iend; i++){
			pixcpy_dst16(dst+dvoff, src+svoff, screen.stride);
			svoff += screen.stride;
			dvoff += shmimage->bytes_per_line;
		}
	}
	XShmPutImage(
		display, window, DefaultGC(display, 0),
		shmimage,
		r.u0, r.v0,
		r.u0, r.v0, rectw(&r), recth(&r),
		True // generate completion event
	);
}
Example #5
0
File: vo_x11.c Project: kax4/mpv
static void Display_Image(struct priv *p, XImage *myximage, uint8_t *ImageData)
{
    struct vo *vo = p->vo;

    int x = (vo->dwidth - p->dst_width) / 2;
    int y = (vo->dheight - p->myximage->height) / 2;

    // do not draw if the image needs rescaling
    if ((p->old_vo_dwidth != vo->dwidth ||
         p->old_vo_dheight != vo->dheight) && p->zoomFlag)
        return;

    if (WinID == 0) {
        x = vo->dx;
        y = vo->dy;
    }
    p->myximage->data += p->out_offset;
#ifdef HAVE_SHM
    if (p->Shmem_Flag) {
        XShmPutImage(vo->x11->display, vo->x11->window, vo->x11->vo_gc,
                     p->myximage, 0, 0, x, y, p->dst_width, p->myximage->height,
                     True);
    } else
#endif
    {
        XPutImage(vo->x11->display, vo->x11->window, vo->x11->vo_gc,
                  p->myximage, 0, 0, x, y, p->dst_width, p->myximage->height);
    }
    p->myximage->data -= p->out_offset;
}
Example #6
0
/*
 * do an XPutImage or XShmPutImage, depending on the current flags
 */
void ImageDisplay::put(Drawable d, int src_x, int src_y, int dest_x, int dest_y,
                       int width, int height)
{
    if (! xImage_)
        return;

    // make sure arguments are in range
    if (src_x < 0)
        src_x = 0;
    if (src_y < 0)
        src_y = 0;;

    width = min(width, xImage_->width - src_x);
    height = min(height, xImage_->height - src_y);
    if (width <= 0 || height <= 0)
        return;

    if (usingXShm_) {
        XShmPutImage(display_, d, gc_, xImage_, src_x, src_y, dest_x, dest_y,
                     width, height, False /*True = send event*/);
    }
    else {
        XPutImage(display_, d, gc_, xImage_, src_x, src_y, dest_x, dest_y,
                  width, height);
    }
    return;
}
Example #7
0
void X11_RefreshDisplay(_THIS)
{
	/* Don't refresh a display that doesn't have an image (like GL) */
	if ( ! SDL_Ximage || (enable_autorefresh <= 0) ) {
		return;
	}
#ifndef NO_SHARED_MEMORY
	if ( this->UpdateRects == X11_MITSHMUpdate ) {
		XShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
				0, 0, 0, 0, this->screen->w, this->screen->h,
				False);
	} else {
#else
	{
#endif /* ! NO_SHARED_MEMORY */
		/* Check for endian-swapped X server, swap if necessary */
		if ( swap_pixels &&
		     ((this->screen->format->BytesPerPixel%2) == 0) ) {
			X11_SwapAllPixels(this->screen);
			XPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
				0, 0, 0, 0, this->screen->w, this->screen->h);
			X11_SwapAllPixels(this->screen);
		} else {
			XPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
				0, 0, 0, 0, this->screen->w, this->screen->h);
		}
	}
	XSync(SDL_Display, False);
}
void rebcmp_blit_region(REBCMP_CTX* ctx, Region reg)
{
	//RL_Print("rebcmp_blit_region, ctx: %x\n", ctx);
	XSetRegion(global_x_info->display, ctx->x_gc, reg);
	/*
	XRectangle rect;
	XClipBox(ctx->Win_Region, &rect);
	RL_Print("Setting window region at: %dx%d, size:%dx%d\n",
			 rect.x, rect.y, rect.width, rect.height);
			 */

#ifdef USE_XSHM
	if (global_x_info->has_xshm) {
		//RL_Print("XshmPutImage\n");
		XShmPutImage(global_x_info->display, 
				ctx->host_window->x_id, 
				ctx->x_gc, 
				ctx->x_image,
				0, 0, 	//src x, y
				0, 0, 	//dest x, y
				ctx->x_image->width, ctx->x_image->height,
				False);
		XFlush(global_x_info->display); //x_image could change if we don't flush here
	} else {
#endif
		Drawable dest = global_x_info->has_double_buffer ? 
			ctx->host_window->x_back_buffer :
			ctx->host_window->x_id;

		if (global_x_info->sys_pixmap_format == pix_format_bgra32){
			XPutImage (global_x_info->display,
					dest,
					ctx->x_gc,
					ctx->x_image,
					0, 0,	//src x, y
					0, 0,	//dest x, y
					ctx->x_image->width, ctx->x_image->height);
		} else {
			put_image(global_x_info->display,
					dest,
					ctx->x_gc,
					ctx->x_image,
					ctx->x_image->width, ctx->x_image->height,
					global_x_info->sys_pixmap_format);
		}

		if (global_x_info->has_double_buffer) {
			//RL_Print("Swapping...\n");
			XdbeSwapInfo swapInfo;
			swapInfo.swap_window = ctx->host_window->x_id;
			swapInfo.swap_action = XdbeUndefined;
			XdbeSwapBuffers(global_x_info->display, &swapInfo, 1);
		}
#ifdef USE_XSHM
	}
#endif

	//RL_Print("rebcmp_blit done\n");
}
Example #9
0
void 
XWindow::PutFrame (uint8_t* frame, 
                    uint16_t width, 
                    uint16_t height)
{
  if (!_XImage) 
    return;

  if (width != _imageWidth || height != _imageHeight) {
    PTRACE (1, "X11\tDynamic switching of resolution not supported\n");
    return;
  }

  XLockDisplay (_display);


  if ((_state.curWidth != _XImage->width) || (_state.curHeight!=_XImage->height))
    CreateXImage(_state.curWidth, _state.curHeight);

  _colorConverter->Convert((BYTE*)frame, (BYTE*)_frameBuffer.get ());

  pixops_scale ((guchar*) _XImage->data,
                 0,0,
                 _state.curWidth, _state.curHeight,
                 _state.curWidth * _planes, //dest_rowstride
                 _planes,                   //dest_channels,
                 FALSE,                     //dest_has_alpha,

		(const guchar*) _frameBuffer.get (),
                 width,
                 height,
                 width * _planes,           //src_rowstride
                 _planes,                   //src_channels,
                 FALSE,                     //src_has_alpha,

                 (double) _state.curWidth / width,
                 (double) _state.curHeight / height,
                 (PixopsInterpType) _scalingAlgorithm);

       _XImage->data += _outOffset;
#ifdef HAVE_SHM
  if (_useShm)
  {
    XShmPutImage(_display, _XWindow, _gc, _XImage,
                 0, 0,
                 _state.curX, _state.curY,
                 _state.curWidth, _state.curHeight, false);
  } else
#endif
  {
    XPutImage(_display, _XWindow, _gc, _XImage,
              0, 0,
              _state.curX, _state.curY,
              _state.curWidth,_state.curHeight);
  }
  _XImage->data -= _outOffset;

  XUnlockDisplay (_display);
}
Example #10
0
/**
 * Display/copy the image in the surface into the X window specified
 * by the XMesaBuffer.
 */
static void
xlib_softpipe_display_surface(struct xmesa_buffer *b,
                              struct pipe_surface *surf)
{
   XImage *ximage;
   struct softpipe_texture *spt = softpipe_texture(surf->texture);
   struct xm_buffer *xm_buf = xm_buffer(spt->buffer);
   static boolean no_swap = 0;
   static boolean firsttime = 1;

   if (firsttime) {
      no_swap = getenv("SP_NO_RAST") != NULL;
      firsttime = 0;
   }

   if (no_swap)
      return;

#ifdef USE_XSHM
   if (xm_buf->shm)
   {
      if (xm_buf->tempImage == NULL) 
      {
         assert(surf->texture->block.width == 1);
         assert(surf->texture->block.height == 1);
         alloc_shm_ximage(xm_buf, b, spt->stride[surf->level] /
                          surf->texture->block.size, surf->height);
      }

      ximage = xm_buf->tempImage;
      ximage->data = xm_buf->data;

      /* _debug_printf("XSHM\n"); */
      XShmPutImage(b->xm_visual->display, b->drawable, b->gc,
                   ximage, 0, 0, 0, 0, surf->width, surf->height, False);
   }
   else
#endif
   {
      /* display image in Window */
      ximage = b->tempImage;
      ximage->data = xm_buf->data;

      /* check that the XImage has been previously initialized */
      assert(ximage->format);
      assert(ximage->bitmap_unit);

      /* update XImage's fields */
      ximage->width = surf->width;
      ximage->height = surf->height;
      ximage->bytes_per_line = spt->stride[surf->level];

      /* _debug_printf("XPUT\n"); */
      XPutImage(b->xm_visual->display, b->drawable, b->gc,
                ximage, 0, 0, 0, 0, surf->width, surf->height);
   }
}
Example #11
0
/**
 * Display/copy the image in the surface into the X window specified
 * by the XMesaBuffer.
 */
static void
xm_llvmpipe_display(struct xmesa_buffer *xm_buffer,
                    struct llvmpipe_displaytarget *dt)
{
   XImage *ximage;
   struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
   static boolean no_swap = 0;
   static boolean firsttime = 1;

   if (firsttime) {
      no_swap = getenv("SP_NO_RAST") != NULL;
      firsttime = 0;
   }

   if (no_swap)
      return;

#ifdef USE_XSHM
   if (xm_dt->shm)
   {
      if (xm_dt->tempImage == NULL)
      {
         assert(xm_dt->block.width == 1);
         assert(xm_dt->block.height == 1);
         alloc_shm_ximage(xm_dt, xm_buffer,
                          xm_dt->stride / xm_dt->block.size,
                          xm_dt->height);
      }

      ximage = xm_dt->tempImage;
      ximage->data = xm_dt->data;

      /* _debug_printf("XSHM\n"); */
      XShmPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc,
                   ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False);
   }
   else
#endif
   {
      /* display image in Window */
      ximage = xm_dt->tempImage;
      ximage->data = xm_dt->data;

      /* check that the XImage has been previously initialized */
      assert(ximage->format);
      assert(ximage->bitmap_unit);

      /* update XImage's fields */
      ximage->width = xm_dt->width;
      ximage->height = xm_dt->height;
      ximage->bytes_per_line = xm_dt->stride;

      /* _debug_printf("XPUT\n"); */
      XPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc,
                ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height);
   }
}
Example #12
0
int BC_XShmImage::write_drawable(Drawable &pixmap, GC &gc,
	int source_x, int source_y, int source_w, int source_h,
	int dest_x, int dest_y, int dest_w, int dest_h)
{
	XShmPutImage(top_level->display, pixmap, gc,
		ximage, source_x, source_y,
		dest_x, dest_y, dest_w, dest_h, bitmap->shm_reply);
	return 0;
}
Example #13
0
int image_put( IMAGE_CONTEXT *img_ctx )
{

	if( img_ctx->xImage == NULL ) return -1;

	XShmPutImage( img_ctx->display, img_ctx->window, img_ctx->gc, img_ctx->xImage, 0, 0, 0, 0, g_width, g_height, false );

	return 0;
}
Example #14
0
void VID_Finish (void)
{
	vid_usevsync = vid_vsync.integer && !cls.timedemo && qglXSwapIntervalSGI;
	switch(vid.renderpath)
	{
		case RENDERPATH_SOFT:
			if(vidx11_shmevent >= 0) {
				vidx11_ximage_pos = !vidx11_ximage_pos;
				vid.softpixels = (unsigned int *) vidx11_ximage[vidx11_ximage_pos]->data;
				DPSOFTRAST_SetRenderTargets(vid.width, vid.height, vid.softdepthpixels, vid.softpixels, NULL, NULL, NULL);

				// save mouse motion so we can deal with it later
				in_mouse_x = 0;
				in_mouse_y = 0;
				while(vidx11_shmwait)
					HandleEvents();
				in_mouse_x_save += in_mouse_x;
				in_mouse_y_save += in_mouse_y;
				in_mouse_x = 0;
				in_mouse_y = 0;

				++vidx11_shmwait;
				XShmPutImage(vidx11_display, win, vidx11_gc, vidx11_ximage[!vidx11_ximage_pos], 0, 0, 0, 0, vid.width, vid.height, True);
			} else {
				// no buffer switching here, we just flush the renderer
				DPSOFTRAST_Finish();
				XPutImage(vidx11_display, win, vidx11_gc, vidx11_ximage[vidx11_ximage_pos], 0, 0, 0, 0, vid.width, vid.height);
			}
			break;

		case RENDERPATH_GL11:
		case RENDERPATH_GL13:
		case RENDERPATH_GL20:
		case RENDERPATH_GLES1:
		case RENDERPATH_GLES2:
			if (vid_usingvsync != vid_usevsync)
			{
				vid_usingvsync = vid_usevsync;
				if (qglXSwapIntervalSGI && qglXSwapIntervalSGI (vid_usevsync))
					Con_Print("glXSwapIntervalSGI didn't accept the vid_vsync change, it will take effect on next vid_restart (GLX_SGI_swap_control does not allow turning off vsync)\n");
			}

			if (!vid_hidden)
			{
				CHECKGLERROR
				if (r_speeds.integer == 2 || gl_finish.integer)
					GL_Finish();
				qglXSwapBuffers(vidx11_display, win);CHECKGLERROR
			}
			break;

		case RENDERPATH_D3D9:
		case RENDERPATH_D3D10:
		case RENDERPATH_D3D11:
			break;
	}
Example #15
0
/*
 * flush_block() buffer method for shm image buffer (no dithering and not low-bandwidth)
 */
static void x11_flush_block_mitshm (struct vidbuf_description *gfxinfo, int first_line, int last_line)
{
    XShmPutImage (display, mywin, mygc,
		  ami_dinfo.ximg,
		  0, first_line,
		  0, first_line,
		  gfxinfo->width,
		  last_line - first_line + 1,
		  0);
}
Example #16
0
extern int fbunlock(struct fb *fb)
{
	if(!fb->hw) return 0;
#ifdef HAVE_X11_XSHM
	XShmPutImage(fb->hw->display, fb->hw->window, fb->hw->gc, fb->hw->image, 0, 0, 0, 0, fb->pitch, fb->height, False);
#else
	XPutImage(fb->hw->display, fb->hw->window, fb->hw->gc, fb->hw->image, 0, 0, 0, 0, fb->pitch, fb->height);
#endif
	return 0;
}
Example #17
0
void
DoShmPutImage(XParms xp, Parms p, int reps)
{
    int i, size;
    XSegment *sa, *sb;

    size = p->special;
    for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) {
	XShmPutImage(xp->d, xp->w, xp->fggc, &shm_image,
	    sa->x1, sa->y1, sa->x2, sa->y2, size, size, False);
	XShmPutImage(xp->d, xp->w, xp->fggc, &shm_image,
	    sa->x2, sa->y2, sa->x1, sa->y1, size, size, False);
	XShmPutImage(xp->d, xp->w, xp->fggc, &shm_image,
	    sb->x2, sb->y2, sb->x2, sb->y2, size, size, False);
	XShmPutImage(xp->d, xp->w, xp->fggc, &shm_image,
	    sb->x1, sb->y1, sb->x2, sb->y2, size, size, False);
	CheckAbort ();
    }
}
Example #18
0
File: xm_api.c Project: RAOF/mesa
/*
 * Copy the back buffer to the front buffer.  If there's no back buffer
 * this is a no-op.
 */
PUBLIC
void XMesaSwapBuffers( XMesaBuffer b )
{
   GET_CURRENT_CONTEXT(ctx);

   if (!b->backxrb) {
      /* single buffered */
      return;
   }

   /* If we're swapping the buffer associated with the current context
    * we have to flush any pending rendering commands first.
    */
   if (ctx && ctx->DrawBuffer == &(b->mesa_buffer))
      _mesa_notifySwapBuffers(ctx);

   if (b->db_mode) {
      if (b->backxrb->ximage) {
	 /* Copy Ximage (back buf) from client memory to server window */
#if defined(USE_XSHM) 
	 if (b->shm) {
            /*_glthread_LOCK_MUTEX(_xmesa_lock);*/
	    XShmPutImage( b->xm_visual->display, b->frontxrb->drawable,
			  b->swapgc,
			  b->backxrb->ximage, 0, 0,
			  0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height,
                          False );
            /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
	 }
	 else
#endif
         {
            /*_glthread_LOCK_MUTEX(_xmesa_lock);*/
            XMesaPutImage( b->xm_visual->display, b->frontxrb->drawable,
			   b->swapgc,
			   b->backxrb->ximage, 0, 0,
			   0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height );
            /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
         }
      }
      else if (b->backxrb->pixmap) {
	 /* Copy pixmap (back buf) to window (front buf) on server */
         /*_glthread_LOCK_MUTEX(_xmesa_lock);*/
	 XMesaCopyArea( b->xm_visual->display,
			b->backxrb->pixmap,   /* source drawable */
			b->frontxrb->drawable,  /* dest. drawable */
			b->swapgc,
			0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height,
			0, 0                 /* dest region */
		      );
         /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
      }
   }
   XSync( b->xm_visual->display, False );
}
Example #19
0
int vs_show (void *ctx, const uint8_t *const data[4], int stride[4])
{
	// 首选检查 sws 是否有效, 根据当前窗口大小决定
	Ctx *c = (Ctx*)ctx;
	Window root;
	int x, y;
	unsigned int cx, cy, border, depth;
	XGetGeometry(c->display, c->window, &root, &x, &y, &cx, &cy, &border, &depth);
	if (cx != c->curr_width || cy != c->curr_height) {
		avpicture_free(&c->pic_target);
		sws_freeContext(c->sws);

		c->sws = sws_getContext(c->v_width, c->v_height, PIX_FMT_YUV420P,
				cx, cy, c->target_pixfmt, 
				SWS_FAST_BILINEAR, 0, 0, 0);
		avpicture_alloc(&c->pic_target, c->target_pixfmt, cx, cy);

		c->curr_width = cx;
		c->curr_height = cy;

		// re create image
		XShmDetach(c->display, &c->segment);
		shmdt(c->segment.shmaddr);
		shmctl(c->segment.shmid, IPC_RMID, 0);
		XDestroyImage(c->image);

		c->image = XShmCreateImage(c->display, c->vinfo.visual, depth, ZPixmap, 0,
			&c->segment, cx, cy);

		c->segment.shmid = shmget(IPC_PRIVATE,
				c->image->bytes_per_line * c->image->height,
				IPC_CREAT | 0777);
		c->segment.shmaddr = (char*)shmat(c->segment.shmid, 0, 0);
		c->image->data = c->segment.shmaddr;
		c->segment.readOnly = 0;
		XShmAttach(c->display, &c->segment);
	}

	// 
	sws_scale(c->sws, data, stride, 0, c->v_height, c->pic_target.data, c->pic_target.linesize);

	// cp to image
	unsigned char *p = c->pic_target.data[0], *q = (unsigned char*)c->image->data;
	int xx = MIN(c->image->bytes_per_line, c->pic_target.linesize[0]);
	for (int i = 0; i < c->curr_height; i++) {
		memcpy(q, p, xx);
		p += c->image->bytes_per_line;
		q += c->pic_target.linesize[0];
	}

	// 显示到 X 上
	XShmPutImage(c->display, c->window, c->gc, c->image, 0, 0, 0, 0, c->curr_width, c->curr_height, 1);

	return 1;
}
Example #20
0
static int display(struct vidisp_st *st, const char *title,
		   const struct vidframe *frame)
{
	struct vidframe frame_rgb;
	int err = 0;

	if (!vidsz_cmp(&st->size, &frame->size)) {
		char capt[256];

		if (st->size.w && st->size.h) {
			info("x11: reset: %u x %u  --->  %u x %u\n",
			     st->size.w, st->size.h,
			     frame->size.w, frame->size.h);
		}

		if (st->internal && !st->win)
			err = create_window(st, &frame->size);

		err |= x11_reset(st, &frame->size);
		if (err)
			return err;

		if (title) {
			re_snprintf(capt, sizeof(capt), "%s - %u x %u",
				    title, frame->size.w, frame->size.h);
		}
		else {
			re_snprintf(capt, sizeof(capt), "%u x %u",
				    frame->size.w, frame->size.h);
		}

		XStoreName(st->disp, st->win, capt);
	}

	/* Convert from YUV420P to RGB */

	vidframe_init_buf(&frame_rgb, st->pixfmt, &frame->size,
			  (uint8_t *)st->shm.shmaddr);

	vidconv(&frame_rgb, frame, 0);

	/* draw */
	if (st->xshmat)
		XShmPutImage(st->disp, st->win, st->gc, st->image,
			     0, 0, 0, 0, st->size.w, st->size.h, false);
	else
		XPutImage(st->disp, st->win, st->gc, st->image,
			  0, 0, 0, 0, st->size.w, st->size.h);

	XSync(st->disp, false);

	return err;
}
Example #21
0
void wsPutImage(wsTWindow *win)
{
    if (wsUseXShm) {
        XShmPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage,
                     0, 0,
                     (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2,
                     win->xImage->width, win->xImage->height, 0);
    } else {
        XPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage,
                  0, 0,
                  (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2,
                  win->xImage->width, win->xImage->height);
    }
}
Example #22
0
File: xm_api.c Project: RAOF/mesa
/*
 * Copy sub-region of back buffer to front buffer
 */
void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
{
   GET_CURRENT_CONTEXT(ctx);

   /* If we're swapping the buffer associated with the current context
    * we have to flush any pending rendering commands first.
    */
   if (ctx && ctx->DrawBuffer == &(b->mesa_buffer))
      _mesa_notifySwapBuffers(ctx);

   if (!b->backxrb) {
      /* single buffered */
      return; 
   }

   if (b->db_mode) {
      int yTop = b->mesa_buffer.Height - y - height;
      if (b->backxrb->ximage) {
         /* Copy Ximage from host's memory to server's window */
#if defined(USE_XSHM) 
         if (b->shm) {
            /* XXX assuming width and height aren't too large! */
            XShmPutImage( b->xm_visual->display, b->frontxrb->drawable,
                          b->swapgc,
                          b->backxrb->ximage, x, yTop,
                          x, yTop, width, height, False );
            /* wait for finished event??? */
         }
         else
#endif
         {
            /* XXX assuming width and height aren't too large! */
            XMesaPutImage( b->xm_visual->display, b->frontxrb->drawable,
			   b->swapgc,
			   b->backxrb->ximage, x, yTop,
			   x, yTop, width, height );
         }
      }
      else {
         /* Copy pixmap to window on server */
         XMesaCopyArea( b->xm_visual->display,
			b->backxrb->pixmap,           /* source drawable */
			b->frontxrb->drawable,        /* dest. drawable */
			b->swapgc,
			x, yTop, width, height,  /* source region */
			x, yTop                  /* dest region */
                      );
      }
   }
}
void
NestedClientUpdateScreen(NestedClientPrivatePtr pPriv, int16_t x1,
                          int16_t y1, int16_t x2, int16_t y2) {
    if (pPriv->usingShm) {
        XShmPutImage(pPriv->display, pPriv->window, pPriv->gc, pPriv->img,
                     x1, y1, x1, y1, x2 - x1, y2 - y1, FALSE);
        /* Without this sync we get some freezes, probably due to some lock
         * in the shm usage */
        XSync(pPriv->display, FALSE);
    } else {
        XPutImage(pPriv->display, pPriv->window, pPriv->gc, pPriv->img,
                  x1, y1, x1, y1, x2 - x1, y2 - y1);
    }
}
void QXlibWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
    Q_UNUSED(widget);
    Q_UNUSED(region);
    Q_UNUSED(offset);

    if (!painted)
        return;

    QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(widget);
    GC gc = xw->graphicsContext();
    Window window = xw->xWindow();
#ifdef DONT_USE_MIT_SHM
    // just convert the image every time...
    if (!shm_img.isNull()) {
        QXlibWindow *win = static_cast<QXlibWindow*>(window()->platformWindow());

        QImage image = shm_img;
        //img.convertToFormat(
        XImage *xi = XCreateImage(screen->display(), win->visual(), win->depth(), ZPixmap,
                                  0, (char *) image.scanLine(0), image.width(), image.height(),
                                  32, image.bytesPerLine());

        int x = 0;
        int y = 0;

        /*int r =*/  XPutImage(screen->display(), window, gc, xi, 0, 0, x, y, image.width(), image.height());

        xi->data = 0; // QImage owns these bits
        XDestroyImage(xi);
    }
#else
    // Use MIT_SHM
    if (image_info && image_info->image) {
        //qDebug() << "Here we go" << image_info->image->width << image_info->image->height;
        int x = 0;
        int y = 0;

        // We could set send_event to true, and then use the ShmCompletion to synchronize,
        // but let's do like Qt/11 and just use XSync
        XShmPutImage (screen->display()->nativeDisplay(), window, gc, image_info->image, 0, 0,
                      x, y, image_info->image->width, image_info->image->height,
                      /*send_event*/ False);

        screen->display()->sync();
    }
#endif
}
Example #25
0
void up_x11update(void)
{
#ifndef CONFIG_SIM_X11NOSHM
  if (b_useshm)
    {
      XShmPutImage(g_display, g_window, g_gc, g_image, 0, 0, 0, 0,
                   g_fbpixelwidth, g_fbpixelheight, 0);
    }
  else
#endif
    {
      XPutImage(g_display, g_window, g_gc, g_image, 0, 0, 0, 0,
                g_fbpixelwidth, g_fbpixelheight);
    }
  XSync(g_display, 0);
}
Example #26
0
void wsImageDraw(wsWindow *win)
{
#ifdef HAVE_SHM
    if (wsUseXShm) {
        XShmPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage,
                     0, 0,
                     (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2,
                     win->xImage->width, win->xImage->height, 0);
    } else
#endif
    {
        XPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage,
                  0, 0,
                  (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2,
                  win->xImage->width, win->xImage->height);
    }
}
Example #27
0
static void
swrastXPutImage(__DRIdrawable * draw, int op,
                int srcx, int srcy, int x, int y,
                int w, int h, int stride,
                int shmid, char *data, void *loaderPrivate)
{
   struct drisw_drawable *pdp = loaderPrivate;
   __GLXDRIdrawable *pdraw = &(pdp->base);
   Display *dpy = pdraw->psc->dpy;
   Drawable drawable;
   XImage *ximage;
   GC gc;

   if (!pdp->ximage || shmid != pdp->shminfo.shmid) {
      if (!XCreateDrawable(pdp, shmid, dpy))
         return;
   }

   switch (op) {
   case __DRI_SWRAST_IMAGE_OP_DRAW:
      gc = pdp->gc;
      break;
   case __DRI_SWRAST_IMAGE_OP_SWAP:
      gc = pdp->swapgc;
      break;
   default:
      return;
   }

   drawable = pdraw->xDrawable;
   ximage = pdp->ximage;
   ximage->bytes_per_line = stride ? stride : bytes_per_line(w * ximage->bits_per_pixel, 32);
   ximage->data = data;

   if (pdp->shminfo.shmid >= 0) {
      ximage->width = ximage->bytes_per_line / ((ximage->bits_per_pixel + 7)/ 8);
      ximage->height = h;
      XShmPutImage(dpy, drawable, gc, ximage, srcx, srcy, x, y, w, h, False);
      XSync(dpy, False);
   } else {
      ximage->width = w;
      ximage->height = h;
      XPutImage(dpy, drawable, gc, ximage, srcx, srcy, x, y, w, h);
   }
   ximage->data = NULL;
}
Example #28
0
// Memory leak is here
void wicked_blit() {

  #ifdef X11GFX
      if (can_use_mitshm)
				XShmPutImage (d, win, gc, ximg, 0, 0, 0, 0, WIN_W, WIN_H, True);
      else
				XPutImage (d, win, gc, ximg, 0, 0, 0, 0, WIN_W, WIN_H);
			XFlush(d);
	    XSync (d, 0); // this stopped it going mad
		  // wait(0.01);
		sched_yield();
			// printf(".\n");
  #endif
  #ifdef ALLEGRO
    img2.blit();
  #endif

}
Example #29
0
void
RPutXImage(RContext *context, Drawable d, GC gc, RXImage *ximage, int src_x,
           int src_y, int dest_x, int dest_y,
           unsigned int width, unsigned int height)
{
#ifndef XSHM
    XPutImage(context->dpy, d, gc, ximage->image, src_x, src_y, dest_x,
              dest_y, width, height);
#else
    if (ximage->is_shared) {
        XShmPutImage(context->dpy, d, gc, ximage->image, src_x, src_y,
                     dest_x, dest_y, width, height, False);
    } else {
        XPutImage(context->dpy, d, gc, ximage->image, src_x, src_y, dest_x,
                  dest_y, width, height);
    }
    XFlush(context->dpy);
#endif /* XSHM */
}
Example #30
-1
static void Display_Image(XImage * myximage, uint8_t * ImageData)
{
    int x = (vo_dwidth - dst_width) / 2;
    int y = (vo_dheight - myximage->height) / 2;

    // do not draw if the image needs rescaling
    if ((old_vo_dwidth != vo_dwidth || old_vo_dheight != vo_dheight) && zoomFlag)
      return;

    if (WinID == 0) {
      x = vo_dx;
      y = vo_dy;
    }
    myximage->data += out_offset;
#ifdef HAVE_SHM
    if (Shmem_Flag)
    {
        XShmPutImage(mDisplay, vo_window, vo_gc, myximage,
                     0, 0,
                     x, y, dst_width,
                     myximage->height, True);
    } else
#endif
    {
        XPutImage(mDisplay, vo_window, vo_gc, myximage,
                  0, 0,
                  x, y, dst_width,
                  myximage->height);
    }
    myximage->data -= out_offset;
}