allow x11 engines to get x resource that sets dpi.

SVN revision: 44965
This commit is contained in:
Carsten Haitzler 2010-01-08 07:10:53 +00:00
parent 83e8cfc7fc
commit 45d79a15cb
10 changed files with 244 additions and 13 deletions

View File

@ -29,7 +29,7 @@ EAPI int evas_common_font_glyph_search (RGBA_Font *fn, RGB
EAPI RGBA_Font_Glyph *evas_common_font_int_cache_glyph_get (RGBA_Font_Int *fi, FT_UInt index);
/* load */
EAPI void evas_common_font_dpi_set (int dpi);
EAPI RGBA_Font_Source *evas_common_font_source_memory_load (const char *name, const void *data, int data_size);
EAPI RGBA_Font_Source *evas_common_font_source_load (const char *name);
EAPI int evas_common_font_source_load_complete (RGBA_Font_Source *fs);

View File

@ -11,6 +11,7 @@ extern FT_Library evas_ft_lib;
static int font_cache_usage = 0;
static int font_cache = 0;
static int font_dpi = 75;
static Eina_Hash * fonts_src = NULL;
static Eina_Hash * fonts = NULL;
@ -114,6 +115,12 @@ evas_common_font_load_shutdown(void)
fonts_src = NULL;
}
EAPI void
evas_common_font_dpi_set(int dpi)
{
font_dpi = dpi;
}
EAPI RGBA_Font_Source *
evas_common_font_source_memory_load(const char *name, const void *data, int data_size)
{
@ -366,7 +373,7 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi)
FT_Activate_Size(fi->ft.size);
}
fi->real_size = fi->size * 64;
error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, 75, 75);
error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi, font_dpi);
if (error)
{
fi->real_size = fi->size;

View File

@ -19,6 +19,11 @@ struct _Render_Engine
{
Evas_GL_X11_Window *win;
int end;
XrmDatabase xrdb; // xres - dpi
struct { // xres - dpi
int dpi; // xres - dpi
} xr; // xres - dpi
};
static void *
@ -75,9 +80,55 @@ eng_setup(Evas *e, void *in)
e->engine.data.output = NULL;
return 0;
}
{
int status;
char *type = NULL;
XrmValue val;
re->xr.dpi = 75000; // dpy * 1000
re->xrdb = XrmGetDatabase(info->info.display);
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);
}
evas_common_cpu_init();
evas_common_blend_init();
evas_common_image_init();
evas_common_convert_init();

View File

@ -13,13 +13,7 @@
# include <X11/Xatom.h>
# include <X11/Xutil.h>
# include <X11/extensions/Xrender.h>
//// this changed. this was the old style. above the new style
//# include <EGL/egl.h>
//# include <GLES/gl.h>
//# include <X11/Xlib.h>
//# include <X11/Xatom.h>
//# include <X11/Xutil.h>
//# include <X11/extensions/Xrender.h>
# include <X11/Xresource.h> // xres - dpi
# elif defined(GLES_VARIETY_SGX)
# define SUPPORT_X11 1
# include <EGL/egl.h>
@ -29,13 +23,15 @@
# include <X11/Xatom.h>
# include <X11/Xutil.h>
# include <X11/extensions/Xrender.h>
# endif
# include <X11/Xresource.h> // xres - dpi
#endif
# else
# include <GL/glx.h>
# include <X11/Xlib.h>
# include <X11/Xatom.h>
# include <X11/Xutil.h>
# include <X11/extensions/Xrender.h>
# include <X11/Xresource.h> // xres - dpi
# include <GL/gl.h>
# include <GL/glext.h>
# include <GL/glx.h>

View File

@ -20,6 +20,12 @@ struct _Render_Engine
Tilebuf *tb;
Tilebuf_Rect *rects;
Tilebuf_Rect *cur_rect;
XrmDatabase xrdb; // xres - dpi
struct { // xres - dpi
int dpi; // xres - dpi
} xr; // xres - dpi
X_Output_Buffer *shbuf;
Soft16_Image *tmp_out; /* used by indirect render, like rotation */
Region clip_rects;
@ -175,6 +181,54 @@ eng_setup(Evas *e, void *in)
}
}
if (!e->engine.data.output) return 0;
{
int status;
char *type = NULL;
XrmValue val;
re->xr.dpi = 75000; // dpy * 1000
re->xrdb = XrmGetDatabase(re->disp);
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);
}
/* add a draw context if we dont have one */
if (!e->engine.data.context)
e->engine.data.context =
@ -191,6 +245,9 @@ eng_output_free(void *data)
Render_Engine *re;
re = (Render_Engine *)data;
if (re->xrdb) XrmDestroyDatabase(re->xrdb);
if (re->shbuf) evas_software_x11_x_output_buffer_free(re->shbuf, 0);
if (re->clip_rects) XDestroyRegion(re->clip_rects);
if (re->gc) XFreeGC(re->disp, re->gc);

View File

@ -5,6 +5,7 @@
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/XShm.h>
#include <X11/Xresource.h> // xres - dpi
#include <sys/ipc.h>
#include <sys/shm.h>
#include "evas_common.h"

View File

@ -30,7 +30,14 @@ struct _Render_Engine
Tilebuf_Rect *rects;
Eina_Inlist *cur_rect;
int end : 1;
#ifdef BUILD_ENGINE_SOFTWARE_XLIB
XrmDatabase xrdb; // xres - dpi
struct { // xres - dpi
int dpi; // xres - dpi
} xr; // xres - dpi
#endif
void (*outbuf_free)(Outbuf *ob);
void (*outbuf_reconfigure)(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth);
int (*outbuf_get_rot)(Outbuf *ob);
@ -91,6 +98,52 @@ _output_xlib_setup(int w,
evas_software_xlib_x_color_init();
evas_software_xlib_outbuf_init();
{
int status;
char *type = NULL;
XrmValue val;
re->xr.dpi = 75000; // dpy * 1000
re->xrdb = XrmGetDatabase(disp);
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,
@ -162,6 +215,8 @@ _output_xcb_setup(int w,
evas_software_xcb_x_color_init();
evas_software_xcb_outbuf_init();
// FIXME: re->xrdb
re->ob = evas_software_xcb_outbuf_setup_x(w,
h,
rot,
@ -498,6 +553,10 @@ eng_output_free(void *data)
if (!data) return;
#ifdef BUILD_ENGINE_SOFTWARE_XLIB
if (re->xrdb) XrmDestroyDatabase(re->xrdb);
#endif
re = (Render_Engine *)data;
re->outbuf_free(re->ob);
evas_common_tilebuf_free(re->tb);

View File

@ -9,6 +9,7 @@
# include <X11/Xutil.h>
# include <X11/Xatom.h>
# include <X11/extensions/XShm.h>
# include <X11/Xresource.h>
#endif
#ifdef BUILD_ENGINE_SOFTWARE_XCB

View File

@ -30,6 +30,13 @@ struct _Render_Engine
} x11;
unsigned char destination_alpha : 1;
#ifdef BUILD_ENGINE_XRENDER_X11
XrmDatabase xrdb; // xres - dpi
struct { // xres - dpi
int dpi; // xres - dpi
} xr; // xres - dpi
#endif
Ximage_Info *xinf;
Xrender_Surface *output;
Xrender_Surface *mask_output;
@ -217,6 +224,52 @@ _output_xlib_setup(int width,
re->render_surface_line_draw = _xr_xlib_render_surface_line_draw;
re->render_surface_polygon_draw = _xr_xlib_render_surface_polygon_draw;
{
int status;
char *type = NULL;
XrmValue val;
re->xr.dpi = 75000; // dpy * 1000
re->xrdb = XrmGetDatabase((Display *)re->x11.connection);
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);
}
return re;
}
@ -446,6 +499,11 @@ eng_output_free(void *data)
Render_Engine *re;
re = (Render_Engine *)data;
#ifdef BUILD_ENGINE_XRENDER_X11
if (re->xrdb) XrmDestroyDatabase(re->xrdb);
#endif
evas_common_font_shutdown();
evas_common_image_shutdown();
while (re->updates)

View File

@ -9,6 +9,7 @@
#include <X11/Xatom.h>
#include <X11/extensions/XShm.h>
#include <X11/extensions/Xrender.h>
#include <X11/Xresource.h> // xres - dpi
#ifdef BUILD_ENGINE_XRENDER_XCB
# include <xcb/xcb.h>