static void *
_output_xlib_setup(int      w,
                   int      h,
                   int      rot,
                   Display *disp,
                   Drawable draw,
                   Visual  *vis,
                   Colormap cmap,
                   int      depth,
                   int      debug,
                   int      grayscale,
                   int      max_colors,
                   Pixmap   mask,
                   int      shape_dither,
                   int      destination_alpha)
{
   Render_Engine *re;

   re = calloc(1, sizeof(Render_Engine));
   if (!re)
     return NULL;

   evas_software_xlib_x_init();
   evas_software_xlib_x_color_init();
   evas_software_xlib_outbuf_init();

     {
        int status;
        char *type = NULL;
        XrmValue val;
        
        re->xr.dpi = 75000; // dpy * 1000

	status = xrdb_user_query("Xft.dpi", "Xft.Dpi", &type, &val);
	if ((!status) || (!type))
	  {
	     if (!re->xrdb) re->xrdb = XrmGetDatabase(disp);
	     if (re->xrdb)
	       status = XrmGetResource(re->xrdb,
				       "Xft.dpi", "Xft.Dpi", &type, &val);
	  }

        if ((status) && (type))
          {
             if (!strcmp(type, "String"))
               {
                  const char *str, *dp;
                  
                  str = val.addr;
                  dp = strchr(str, '.');
                  if (!dp) dp = strchr(str, ',');
                  
                  if (dp)
                    {
                       int subdpi, len, i;
                       char *buf;
                       
                       buf = alloca(dp - str + 1);
                       strncpy(buf, str, dp - str);
                       buf[dp - str] = 0;
                       len = strlen(dp + 1);
                       subdpi = atoi(dp + 1);
                       
                       if (len < 3)
                         {
                            for (i = len; i < 3; i++) subdpi *= 10;
                         }
                       else if (len > 3)
                         {
                            for (i = len; i > 3; i--) subdpi /= 10;
                         }
                       re->xr.dpi = atoi(buf) * 1000;
                    }
                  else
                    re->xr.dpi = atoi(str) * 1000;
                  evas_common_font_dpi_set(re->xr.dpi / 1000);
               }
          }
     }
   
   re->ob = evas_software_xlib_outbuf_setup_x(w,
                                              h,
                                              rot,
                                              OUTBUF_DEPTH_INHERIT,
                                              disp,
                                              draw,
                                              vis,
                                              cmap,
                                              depth,
                                              grayscale,
                                              max_colors,
                                              mask,
                                              shape_dither,
                                              destination_alpha);
   if (!re->ob)
     {
	free(re);
	return NULL;
     }

   /* for updates return 1 big buffer, but only use portions of it, also cache
    it and keepit around until an idle_flush */
   /* disable for now - i am hunting down why some expedite tests are slower,
    * as well as shaped stuff is broken and probable non-32bpp is broken as
    * convert funcs dont do the right thing
    *
   re->ob->onebuf = 1;
    */

   evas_software_xlib_outbuf_debug_set(re->ob, debug);
   re->tb = evas_common_tilebuf_new(w, h);
   if (!re->tb)
     {
	evas_software_xlib_outbuf_free(re->ob);
	free(re);
	return NULL;
     }
   /* in preliminary tests 16x16 gave highest framerates */
   evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
   return re;
}
Example #2
0
/*
 * version that reads pixmap data as well as bitmap data
 */
Pixmap
XmuLocatePixmapFile(Screen *screen, _Xconst char *name,
			    unsigned long fore, unsigned long back,
			    unsigned int depth,
			    char *srcname, int srcnamelen,
			    int *widthp, int *heightp, int *xhotp, int *yhotp)
{

#ifndef BITMAPDIR
#define BITMAPDIR "/usr/include/X11/bitmaps"
#endif

    Display *dpy = DisplayOfScreen (screen);
    Window root = RootWindowOfScreen (screen);
    Bool try_plain_name = True;
    XmuCvtCache *cache = _XmuCCLookupDisplay (dpy);
    char **file_paths = (char **) NULL;
    char filename[PATH_MAX];
#if 0
    char* bitmapdir = BITMAPDIR;
#endif
    unsigned int width, height;
    int xhot, yhot;
    int i;

    /*
     * look in cache for bitmap path
     */
    if (cache) {
	if (!cache->string_to_bitmap.bitmapFilePath) {
	    XrmName xrm_name[2];
	    XrmClass xrm_class[2];
	    XrmRepresentation rep_type;
	    XrmValue value;

	    xrm_name[0] = XrmPermStringToQuark ("bitmapFilePath");
	    xrm_name[1] = NULLQUARK;
	    xrm_class[0] = XrmPermStringToQuark ("BitmapFilePath");
	    xrm_class[1] = NULLQUARK;
	    if (!XrmGetDatabase(dpy)) {
		/* what a hack; need to initialize it */
		(void) XGetDefault (dpy, "", "");
	    }
	    if (XrmQGetResource (XrmGetDatabase(dpy), xrm_name, xrm_class,
				 &rep_type, &value) &&
		rep_type == XrmPermStringToQuark("String")) {
		cache->string_to_bitmap.bitmapFilePath =
		  split_path_string (value.addr);
	    }
	}
	file_paths = cache->string_to_bitmap.bitmapFilePath;
    }

    /*
     * Search order:
     *    1.  name if it begins with / or ./
     *    2.  "each prefix in file_paths"/name
     *    3.  BITMAPDIR/name
     *    4.  name if didn't begin with / or .
     */

    for (i = 1; i <= 4; i++) {
	const char *fn = filename;
	Pixmap pixmap;
	unsigned char *data;

	switch (i) {
	  case 1:
	    if (!(name[0] == '/' || ((name[0] == '.') && name[1] == '/')))
	      continue;
	    fn = name;
	    try_plain_name = False;
	    break;
	  case 2:
	    if (file_paths && *file_paths) {
		XmuSnprintf(filename, sizeof(filename),
			    "%s/%s", *file_paths, name);
		file_paths++;
		i--;
		break;
	    }
	    continue;
	  case 3:
	    XmuSnprintf(filename, sizeof(filename), "%s/%s", BITMAPDIR, name);
	    break;
	  case 4:
	    if (!try_plain_name) continue;
	    fn = name;
	    break;
	}

	data = NULL;
	pixmap = None;
	if (XmuReadBitmapDataFromFile (fn, &width, &height, &data,
				       &xhot, &yhot) == BitmapSuccess) {
	    pixmap = XCreatePixmapFromBitmapData (dpy, root, (char *) data,
						  width, height,
						  fore, back, depth);
	    XFree ((char *)data);
	}

	if (pixmap) {
	    if (widthp) *widthp = (int)width;
	    if (heightp) *heightp = (int)height;
	    if (xhotp) *xhotp = xhot;
	    if (yhotp) *yhotp = yhot;
	    if (srcname && srcnamelen > 0) {
		strncpy (srcname, fn, srcnamelen - 1);
		srcname[srcnamelen - 1] = '\0';
	    }
	    return pixmap;
	}
    }

    return None;
}