changeset 904:f838e5207ec4

Remove XSHM support from DirectFB backend.
author Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
date Sun, 03 Oct 2010 17:00:31 +0800
parents 4c7f0ec97ad9
children e3a5e05f00c1
files src/dfb_supp.c
diffstat 1 files changed, 11 insertions(+), 143 deletions(-) [+]
line wrap: on
line diff
--- a/src/dfb_supp.c	Sun Oct 03 16:54:26 2010 +0800
+++ b/src/dfb_supp.c	Sun Oct 03 17:00:31 2010 +0800
@@ -3,22 +3,13 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <cairo-xlib.h>
+#include <cairo-directfb.h>
 #include "mb_graph_engine.h"
 #include "mb_redraw_man.h"
 #include "mb_timer.h"
 #include "mb_X_supp.h"
 #include "config.h"
 
-#ifdef XSHM
-/* \sa http://www.xfree86.org/current/mit-shm.html */
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <X11/extensions/XShm.h>
-#endif
-
 #define ERR -1
 #define OK 0
 
@@ -65,11 +56,6 @@
     shape_t *last;
 #endif
 
-#ifdef XSHM
-    XImage *ximage;
-    XShmSegmentInfo shminfo;
-#endif
-
     /*
      * Following variables are used by handle_single_x_event()
      */
@@ -81,23 +67,6 @@
     int mbut_state;	       /* Button state of last motion event */
 };
 
-#ifdef XSHM
-static void
-XSHM_update(X_MB_runtime_t *xmb_rt) {
-    GC gc;
-
-    gc = DefaultGC(xmb_rt->display, DefaultScreen(xmb_rt->display));
-    if(xmb_rt->ximage) {	/* support XSHM */
-	XShmPutImage(xmb_rt->display,
-		     xmb_rt->win,
-		     gc,
-		     xmb_rt->ximage,
-		     0, 0, 0, 0,
-		     xmb_rt->w, xmb_rt->h, 0);
-    }
-}
-#endif
-
 /*! \defgroup xkb X Keyboard Handling
  *
  * Accept keyboard events from X server and delivery it to
@@ -234,11 +203,11 @@
     shape_t *shape;
     coord_t *root;
     int in_stroke;
-    
+
     x = rt->mx;
     y = rt->my;
     state = rt->mbut_state;
-    
+
     shape = find_shape_at_pos(rdman, x, y,
 			      &in_stroke);
 #ifdef ONLY_MOUSE_MOVE_RAW
@@ -270,7 +239,7 @@
 	}
     }
 #endif
-    
+
     rt->mflag = 0;
 }
 
@@ -285,9 +254,9 @@
     ey1 = rt->ey1;
     ex2 = rt->ex2;
     ey2 = rt->ey2;
-    
+
     rdman_redraw_area(rdman, ex1, ey1, (ex2 - ex1), (ey2 - ey1));
-    
+
     rt->eflag = 0;
 }
 
@@ -416,10 +385,7 @@
 	handle_single_x_event(rt, &evt);
     }
     no_more_event(rt);
-    
-#ifdef XSHM
-    XSHM_update(rt);
-#endif
+
     XFlush(display);
 }
 
@@ -478,9 +444,6 @@
 	    get_now(&now);
 	    mb_tman_handle_timeout(tman, &now);
 	    rdman_redraw_changed(rdman);
-#ifdef XSHM
-	    XSHM_update(rt);
-#endif
 	    XFlush(display);
 	} else if(FD_ISSET(fd, &rfds)){
 	    handle_x_event(rt);
@@ -571,94 +534,6 @@
     return OK;
 }
 
-#ifdef XSHM
-static void
-xshm_destroy(X_MB_runtime_t *xmb_rt) {
-    XShmSegmentInfo *shminfo;
-
-    shminfo = &xmb_rt->shminfo;
-
-    if(xmb_rt->shminfo.shmaddr) {
-	XShmDetach(xmb_rt->display, shminfo);
-    }
-
-    if(xmb_rt->ximage) {
-	XDestroyImage(xmb_rt->ximage);
-	xmb_rt->ximage = NULL;
-    }
-
-    if(shminfo->shmaddr) {
-	shmdt(shminfo->shmaddr);
-	shminfo->shmaddr = NULL;
-    }
-
-    if(shminfo->shmid) {
-	shmctl(shminfo->shmid, IPC_RMID, 0);
-	shminfo->shmid = 0;
-    }
-}
-
-static void
-xshm_init(X_MB_runtime_t *xmb_rt) {
-    Display *display;
-    Visual *visual;
-    XImage *ximage;
-    int screen;
-    int depth;
-    int support_shm;
-    int mem_sz;
-    XShmSegmentInfo *shminfo;
-    int surf_fmt;
-
-    display = xmb_rt->display;
-    visual = xmb_rt->visual;
-    shminfo = &xmb_rt->shminfo;
-
-    support_shm = XShmQueryExtension(display);
-    if(!support_shm)
-	return;
-
-    screen = DefaultScreen(display);
-    depth = DefaultDepth(display, screen);
-
-    if(depth != 24 && depth != 32)
-	return;
-
-    xmb_rt->ximage = XShmCreateImage(display, visual, depth,
-				     ZPixmap, NULL, shminfo,
-				     xmb_rt->w, xmb_rt->h);
-    ximage = xmb_rt->ximage;
-
-    mem_sz = ximage->bytes_per_line * ximage->height;
-    shminfo->shmid = shmget(IPC_PRIVATE, mem_sz, IPC_CREAT | 0777);
-    if(shminfo->shmid == -1) {
-	xshm_destroy(xmb_rt);
-	return;
-    }
-
-    shminfo->shmaddr = shmat(shminfo->shmid, 0, 0);
-    ximage->data = shminfo->shmaddr;
-
-    shminfo->readOnly = 0;
-
-    XShmAttach(display, shminfo);
-
-    switch(depth) {
-    case 24: surf_fmt = CAIRO_FORMAT_RGB24; break;
-    case 32: surf_fmt = CAIRO_FORMAT_ARGB32; break;
-    }
-
-    xmb_rt->backend_surface =
-	mbe_image_surface_create_for_data((unsigned char *)ximage->data,
-					  surf_fmt,
-					  xmb_rt->w,
-					  xmb_rt->h,
-					  ximage->bytes_per_line);
-    if(xmb_rt->backend_surface == NULL)
-	xshm_destroy(xmb_rt);
-}
-#endif /* XSHM */
-
 /*! \brief Initialize a MadButterfy runtime for Xlib.
  *
  * This one is very like X_MB_init(), except it accepts a
@@ -679,10 +554,6 @@
     w = xmb_rt->w;
     h = xmb_rt->h;
 
-#ifdef XSHM
-    xshm_init(xmb_rt);
-#endif
-
     xmb_rt->surface =
 	mbe_image_surface_create(MB_IFMT_ARGB32, w, h);
 
@@ -761,7 +632,7 @@
     r = XGetWindowAttributes(display, win, &attrs);
     if(r == 0)
 	return ERR;
-    
+
     memset(xmb_rt, 0, sizeof(X_MB_runtime_t));
 
     xmb_rt->display = display;
@@ -822,7 +693,7 @@
     xmb_rt->win = 0;
 
     X_MB_destroy(xmb_rt);
-    
+
     xmb_rt->display = display;
     xmb_rt->win = win;
 }
@@ -984,9 +855,6 @@
  */
 int _X_MB_flush_x_conn_for_nodejs(void *rt) {
     X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *)rt;
-#ifdef XSHM
-    XSHM_update(xmb_rt);
-#endif
     return XFlush(xmb_rt->display);
 }
 
@@ -995,7 +863,7 @@
 void
 _X_MB_handle_single_event(void *rt, void *evt) {
     X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *)rt;
-    
+
     handle_single_x_event(xmb_rt, (XEvent *)evt);
 }
 
@@ -1004,7 +872,7 @@
 void
 _X_MB_no_more_event(void *rt) {
     X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *)rt;
-    
+
     no_more_event(xmb_rt);
 }