Exemplo n.º 1
0
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;
   Outbuf *ob;
   Render_Engine_Merge_Mode merge_mode = MERGE_SMART;
   const char *s;

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

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

   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 (!ob) goto on_error;

   /* 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(ob, debug);
   if (!evas_render_engine_software_generic_init(&re->generic, ob, NULL,
                                                 evas_software_xlib_outbuf_get_rot,
                                                 evas_software_xlib_outbuf_reconfigure,
                                                 NULL,
                                                 evas_software_xlib_outbuf_new_region_for_update,
                                                 evas_software_xlib_outbuf_push_updated_region,
                                                 evas_software_xlib_outbuf_free_region_for_update,
                                                 evas_software_xlib_outbuf_idle_flush,
                                                 evas_software_xlib_outbuf_flush,
                                                 evas_software_xlib_outbuf_free,
                                                 w, h))
     goto on_error;

   if ((s = getenv("EVAS_SOFTWARE_PARTIAL_MERGE")))
     {
        if ((!strcmp(s, "bounding")) ||
            (!strcmp(s, "b")))
          merge_mode = MERGE_BOUNDING;
        else if ((!strcmp(s, "full")) ||
                 (!strcmp(s, "f")))
          merge_mode = MERGE_FULL;
        else if ((!strcmp(s, "smart")) ||
                 (!strcmp(s, "s")))
          merge_mode = MERGE_SMART;
     }

   evas_render_engine_software_generic_merge_mode_set(&re->generic, merge_mode);

   return re;

 on_error:
   if (ob) evas_software_xlib_outbuf_free(ob);
   free(re);
   return NULL;
}
Exemplo n.º 2
0
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;
}