forked from enlightenment/efl
evas sw x11: formatting
This commit is contained in:
parent
736c63be34
commit
9a56b267cd
|
@ -24,8 +24,8 @@
|
|||
#include <Ecore.h>
|
||||
#include <Eina.h>
|
||||
|
||||
Evas_Native_Tbm_Surface_Image_Set_Call glsym__evas_native_tbm_surface_image_set = NULL;
|
||||
Evas_Native_Tbm_Surface_Stride_Get_Call glsym__evas_native_tbm_surface_stride_get = NULL;
|
||||
Evas_Native_Tbm_Surface_Image_Set_Call glsym__evas_native_tbm_surface_image_set = NULL;
|
||||
Evas_Native_Tbm_Surface_Stride_Get_Call glsym__evas_native_tbm_surface_stride_get = NULL;
|
||||
int _evas_engine_soft_x11_log_dom = -1;
|
||||
|
||||
/* function tables - filled in later (func and parent func) */
|
||||
|
@ -37,9 +37,10 @@ typedef struct _Render_Engine Render_Engine;
|
|||
struct _Render_Engine
|
||||
{
|
||||
Render_Engine_Software_Generic generic;
|
||||
Eina_Bool (*outbuf_alpha_get)(Outbuf *ob);
|
||||
Eina_Bool (*outbuf_alpha_get)(Outbuf *ob);
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
void *disp;
|
||||
void *config;
|
||||
void *surface;
|
||||
|
@ -47,9 +48,9 @@ struct _Render_Engine
|
|||
};
|
||||
|
||||
/* prototypes we will use here */
|
||||
static void *_best_visual_get(int backend, void *connection, int screen);
|
||||
static void *_best_visual_get(int backend, void *connection, int screen);
|
||||
static unsigned int _best_colormap_get(int backend, void *connection, int screen);
|
||||
static int _best_depth_get(int backend, void *connection, int screen);
|
||||
static int _best_depth_get(int backend, void *connection, int screen);
|
||||
|
||||
static Eina_List *_outbufs = NULL;
|
||||
|
||||
|
@ -129,7 +130,7 @@ _output_xlib_setup(int w, int h, int rot, Display *disp, Drawable draw,
|
|||
|
||||
return re;
|
||||
|
||||
on_error:
|
||||
on_error:
|
||||
if (ob) evas_software_xlib_outbuf_free(ob);
|
||||
free(re);
|
||||
return NULL;
|
||||
|
@ -175,7 +176,7 @@ _output_swapbuf_setup(int w, int h, int rot, Display *disp, Drawable draw,
|
|||
goto on_error;
|
||||
return re;
|
||||
|
||||
on_error:
|
||||
on_error:
|
||||
if (ob) evas_software_xlib_swapbuf_free(ob);
|
||||
free(re);
|
||||
return NULL;
|
||||
|
@ -220,7 +221,7 @@ _symbols(void)
|
|||
if (done) return;
|
||||
|
||||
#define LINK2GENERIC(sym) \
|
||||
glsym_##sym = dlsym(RTLD_DEFAULT, #sym);
|
||||
glsym_##sym = dlsym(RTLD_DEFAULT, #sym);
|
||||
|
||||
// Get function pointer to native_common that is now provided through the link of SW_Generic.
|
||||
LINK2GENERIC(_evas_native_tbm_surface_image_set);
|
||||
|
@ -264,7 +265,7 @@ eng_setup(void *engine EINA_UNUSED, void *in, unsigned int w, unsigned int h)
|
|||
Evas_Engine_Info_Software_X11 *info = in;
|
||||
Render_Engine *re = NULL;
|
||||
static int try_swapbuf = -1;
|
||||
char* s;
|
||||
char *s;
|
||||
|
||||
if (info->info.backend != EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB)
|
||||
return NULL;
|
||||
|
@ -304,7 +305,7 @@ eng_setup(void *engine EINA_UNUSED, void *in, unsigned int w, unsigned int h)
|
|||
re->outbuf_alpha_get = evas_software_xlib_outbuf_alpha_get;
|
||||
}
|
||||
|
||||
_outbufs = eina_list_append(_outbufs, re->generic.ob);
|
||||
_outbufs = eina_list_append(_outbufs, re->generic.ob);
|
||||
|
||||
return re;
|
||||
}
|
||||
|
@ -363,7 +364,7 @@ eng_update(void *engine EINA_UNUSED, void *data, void *in, unsigned int w, unsig
|
|||
evas_render_engine_software_generic_update(&re->generic, ob, w, h);
|
||||
}
|
||||
|
||||
_outbufs = eina_list_append(_outbufs, re->generic.ob);
|
||||
_outbufs = eina_list_append(_outbufs, re->generic.ob);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -389,7 +390,7 @@ eng_canvas_alpha_get(void *engine)
|
|||
|
||||
re = (Render_Engine *)engine;
|
||||
return (re->generic.ob->priv.destination_alpha) ||
|
||||
(re->outbuf_alpha_get(re->generic.ob));
|
||||
(re->outbuf_alpha_get(re->generic.ob));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -398,10 +399,10 @@ _native_evasgl_free(void *image)
|
|||
RGBA_Image *im = image;
|
||||
Native *n = im->native.data;
|
||||
|
||||
im->native.data = NULL;
|
||||
im->native.func.bind = NULL;
|
||||
im->native.data = NULL;
|
||||
im->native.func.bind = NULL;
|
||||
im->native.func.unbind = NULL;
|
||||
im->native.func.free = NULL;
|
||||
im->native.func.free = NULL;
|
||||
//im->image.data = NULL;
|
||||
free(n);
|
||||
}
|
||||
|
@ -414,10 +415,12 @@ eng_image_native_init(void *engine EINA_UNUSED, Evas_Native_Surface_Type type)
|
|||
#ifdef GL_GLES
|
||||
case EVAS_NATIVE_SURFACE_TBM:
|
||||
return _evas_native_tbm_init();
|
||||
|
||||
#endif
|
||||
case EVAS_NATIVE_SURFACE_X11:
|
||||
case EVAS_NATIVE_SURFACE_EVASGL:
|
||||
return 1;
|
||||
|
||||
default:
|
||||
ERR("Native surface type %d not supported!", type);
|
||||
return 0;
|
||||
|
@ -433,10 +436,12 @@ eng_image_native_shutdown(void *engine EINA_UNUSED, Evas_Native_Surface_Type typ
|
|||
case EVAS_NATIVE_SURFACE_TBM:
|
||||
_evas_native_tbm_shutdown();
|
||||
return;
|
||||
|
||||
#endif
|
||||
case EVAS_NATIVE_SURFACE_X11:
|
||||
case EVAS_NATIVE_SURFACE_OPENGL:
|
||||
return;
|
||||
|
||||
default:
|
||||
ERR("Native surface type %d not supported!", type);
|
||||
return;
|
||||
|
@ -496,8 +501,8 @@ eng_image_native_set(void *engine, void *image, void *native)
|
|||
{
|
||||
stride = glsym__evas_native_tbm_surface_stride_get(re->generic.ob, ns);
|
||||
ie2 = evas_cache_image_copied_data(evas_common_image_cache_get(),
|
||||
stride, ie->h, NULL, ie->flags.alpha,
|
||||
EVAS_COLORSPACE_ARGB8888);
|
||||
stride, ie->h, NULL, ie->flags.alpha,
|
||||
EVAS_COLORSPACE_ARGB8888);
|
||||
}
|
||||
else
|
||||
ie2 = evas_cache_image_data(evas_common_image_cache_get(),
|
||||
|
@ -515,15 +520,15 @@ eng_image_native_set(void *engine, void *image, void *native)
|
|||
evas_cache2_image_close(ie);
|
||||
else
|
||||
#endif
|
||||
evas_cache_image_drop(ie);
|
||||
evas_cache_image_drop(ie);
|
||||
ie = ie2;
|
||||
|
||||
if (ns->type == EVAS_NATIVE_SURFACE_X11)
|
||||
{
|
||||
RGBA_Image *ret_im = NULL;
|
||||
ret_im = evas_xlib_image_dri_native_set(re->generic.ob, ie, ns);
|
||||
if (!ret_im)
|
||||
ret_im = evas_xlib_image_native_set(re->generic.ob, ie, ns);
|
||||
if (!ret_im)
|
||||
ret_im = evas_xlib_image_native_set(re->generic.ob, ie, ns);
|
||||
return ret_im;
|
||||
}
|
||||
else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
|
||||
|
@ -537,7 +542,7 @@ eng_image_native_set(void *engine, void *image, void *native)
|
|||
if (n)
|
||||
{
|
||||
n->ns_data.evasgl.surface = ns->data.evasgl.surface;
|
||||
im = (RGBA_Image *) ie;
|
||||
im = (RGBA_Image *)ie;
|
||||
n->ns.type = EVAS_NATIVE_SURFACE_EVASGL;
|
||||
n->ns.version = EVAS_NATIVE_SURFACE_VERSION;
|
||||
n->ns.data.evasgl.surface = ns->data.evasgl.surface;
|
||||
|
@ -562,7 +567,6 @@ eng_image_native_get(void *engine EINA_UNUSED, void *image)
|
|||
return &(n->ns);
|
||||
}
|
||||
|
||||
|
||||
/* module advertising code */
|
||||
static int
|
||||
module_open(Evas_Module *em)
|
||||
|
@ -572,7 +576,7 @@ module_open(Evas_Module *em)
|
|||
/* get whatever engine module we inherit from */
|
||||
if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
|
||||
|
||||
_evas_engine_soft_x11_log_dom =
|
||||
_evas_engine_soft_x11_log_dom =
|
||||
eina_log_domain_register("evas-software_x11", EVAS_DEFAULT_LOG_COLOR);
|
||||
|
||||
if (_evas_engine_soft_x11_log_dom < 0)
|
||||
|
@ -617,8 +621,8 @@ static Evas_Module_Api evas_modapi =
|
|||
{
|
||||
EVAS_MODULE_API_VERSION, "software_x11", "none",
|
||||
{
|
||||
module_open,
|
||||
module_close
|
||||
module_open,
|
||||
module_close
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "evas_macros.h"
|
||||
|
||||
#ifdef HAVE_DLSYM
|
||||
# include <dlfcn.h> /* dlopen,dlclose,etc */
|
||||
# include <dlfcn.h> /* dlopen,dlclose,etc */
|
||||
#else
|
||||
# undef BUILD_ENGINE_SOFTWARE_XLIB
|
||||
#endif
|
||||
|
@ -17,19 +17,19 @@
|
|||
#ifdef BUILD_ENGINE_SOFTWARE_XLIB
|
||||
#include "evas_x_egl.h"
|
||||
|
||||
#define EGL_SURFACE_TYPE 0x3033
|
||||
#define EGL_WINDOW_BIT 0x0004
|
||||
#define EGL_RENDERABLE_TYPE 0x3040
|
||||
#define EGL_ALPHA_SIZE 0x3021
|
||||
#define EGL_BLUE_SIZE 0x3022
|
||||
#define EGL_GREEN_SIZE 0x3023
|
||||
#define EGL_RED_SIZE 0x3024
|
||||
#define EGL_DEPTH_SIZE 0x3025
|
||||
#define EGL_STENCIL_SIZE 0x3026
|
||||
#define EGL_SURFACE_TYPE 0x3033
|
||||
#define EGL_NONE 0x3038
|
||||
#define EGL_FALSE 0
|
||||
#define EGL_TRUE 1
|
||||
#define EGL_SURFACE_TYPE 0x3033
|
||||
#define EGL_WINDOW_BIT 0x0004
|
||||
#define EGL_RENDERABLE_TYPE 0x3040
|
||||
#define EGL_ALPHA_SIZE 0x3021
|
||||
#define EGL_BLUE_SIZE 0x3022
|
||||
#define EGL_GREEN_SIZE 0x3023
|
||||
#define EGL_RED_SIZE 0x3024
|
||||
#define EGL_DEPTH_SIZE 0x3025
|
||||
#define EGL_STENCIL_SIZE 0x3026
|
||||
#define EGL_SURFACE_TYPE 0x3033
|
||||
#define EGL_NONE 0x3038
|
||||
#define EGL_FALSE 0
|
||||
#define EGL_TRUE 1
|
||||
|
||||
#define EGL_LOCK_SURFACE_BIT_KHR 0x0080
|
||||
#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100
|
||||
|
@ -56,22 +56,23 @@
|
|||
static int egl_found = -1;
|
||||
static void *egl_lib = NULL;
|
||||
|
||||
static struct {
|
||||
void * (*GetProcAddress) (const char *name);
|
||||
void * (*GetDisplay) (void *d);
|
||||
unsigned int (*Initialize) (void *ed, int *vmaj, int *vmin);
|
||||
unsigned int (*Terminate) (void *ed);
|
||||
const char * (*QueryString) (void *ed, int name);
|
||||
unsigned int (*ChooseConfig) (void *ed, int *attr, void **configs, int config_size, int *num_config);
|
||||
unsigned int (*GetConfigAttrib) (void *ed, void *config, int attr, int *val);
|
||||
unsigned int (*QuerySurface) (void *ed, void *surf, int attr, int *val);
|
||||
void * (*CreateWindowSurface) (void *ed, void *config, Window win, int *attr);
|
||||
unsigned int (*DestroySurface) (void *ed, void *surf);
|
||||
unsigned int (*SwapBuffers) (void *ed, void *surf);
|
||||
unsigned int (*SwapInterval) (void *ed, int interval);
|
||||
|
||||
unsigned int (*LockSurface) (void *ed, void *surf, int *attr);
|
||||
unsigned int (*UnlockSurface) (void *ed, void *surf);
|
||||
static struct
|
||||
{
|
||||
void * (*GetProcAddress)(const char *name);
|
||||
void * (*GetDisplay)(void *d);
|
||||
unsigned int (*Initialize)(void *ed, int *vmaj, int *vmin);
|
||||
unsigned int (*Terminate)(void *ed);
|
||||
const char * (*QueryString)(void *ed, int name);
|
||||
unsigned int (*ChooseConfig)(void *ed, int *attr, void **configs, int config_size, int *num_config);
|
||||
unsigned int (*GetConfigAttrib)(void *ed, void *config, int attr, int *val);
|
||||
unsigned int (*QuerySurface)(void *ed, void *surf, int attr, int *val);
|
||||
void * (*CreateWindowSurface)(void *ed, void *config, Window win, int *attr);
|
||||
unsigned int (*DestroySurface)(void *ed, void *surf);
|
||||
unsigned int (*SwapBuffers)(void *ed, void *surf);
|
||||
unsigned int (*SwapInterval)(void *ed, int interval);
|
||||
|
||||
unsigned int (*LockSurface)(void *ed, void *surf, int *attr);
|
||||
unsigned int (*UnlockSurface)(void *ed, void *surf);
|
||||
} egl;
|
||||
|
||||
static int
|
||||
|
@ -86,31 +87,32 @@ _egl_find(void)
|
|||
}
|
||||
if (!(egl.GetProcAddress = dlsym(egl_lib, "eglGetProcAddress"))) goto err;
|
||||
|
||||
#define SYM(x, y) if (!(egl.x = egl.GetProcAddress(y))) goto err
|
||||
#define SYM(x, y) if (!(egl.x = egl.GetProcAddress(y))) \
|
||||
goto err
|
||||
// core syms used
|
||||
SYM(GetDisplay , "eglGetDisplay");
|
||||
SYM(Initialize, "eglInitialize");
|
||||
SYM(Terminate, "eglTerminate");
|
||||
SYM(QueryString, "eglQueryString");
|
||||
SYM(ChooseConfig, "eglChooseConfig");
|
||||
SYM(UnlockSurface, "eglGetConfigAttrib");
|
||||
SYM(QuerySurface, "eglQuerySurface");
|
||||
SYM(GetDisplay, "eglGetDisplay");
|
||||
SYM(Initialize, "eglInitialize");
|
||||
SYM(Terminate, "eglTerminate");
|
||||
SYM(QueryString, "eglQueryString");
|
||||
SYM(ChooseConfig, "eglChooseConfig");
|
||||
SYM(UnlockSurface, "eglGetConfigAttrib");
|
||||
SYM(QuerySurface, "eglQuerySurface");
|
||||
SYM(CreateWindowSurface, "eglCreateWindowSurface");
|
||||
SYM(DestroySurface, "eglDestroySurface");
|
||||
SYM(SwapBuffers, "eglSwapBuffers");
|
||||
SYM(SwapInterval, "eglSwapInterval");
|
||||
SYM(DestroySurface, "eglDestroySurface");
|
||||
SYM(SwapBuffers, "eglSwapBuffers");
|
||||
SYM(SwapInterval, "eglSwapInterval");
|
||||
|
||||
#undef SYM
|
||||
#define SYM(x, y) egl.x = egl.GetProcAddress(y)
|
||||
// extns
|
||||
// extns
|
||||
SYM(LockSurface, "eglLockSurface");
|
||||
if (!egl.LockSurface) SYM(LockSurface, "eglLockSurfaceKHR");
|
||||
SYM(UnlockSurface, "eglUnlockSurface");
|
||||
if (!egl.UnlockSurface) SYM(UnlockSurface, "eglUnlockSurfaceKHR");
|
||||
|
||||
|
||||
if (!egl.LockSurface) goto err;
|
||||
if (!egl.UnlockSurface) goto err;
|
||||
|
||||
|
||||
egl_found = 1;
|
||||
return 1;
|
||||
err:
|
||||
|
@ -118,6 +120,7 @@ err:
|
|||
egl_lib = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void *
|
||||
|
@ -163,7 +166,7 @@ _egl_x_disp_choose_config(void *ed)
|
|||
#ifdef BUILD_ENGINE_SOFTWARE_XLIB
|
||||
int config_attrs[40], n = 0, num_config = 0;
|
||||
void *eglconfig = NULL;
|
||||
|
||||
|
||||
if (!_egl_find()) return NULL;
|
||||
config_attrs[n++] = EGL_SURFACE_TYPE;
|
||||
config_attrs[n++] = EGL_WINDOW_BIT;
|
||||
|
@ -183,9 +186,9 @@ _egl_x_disp_choose_config(void *ed)
|
|||
config_attrs[n++] = EGL_LOCK_SURFACE_BIT_KHR;
|
||||
config_attrs[n++] = EGL_MATCH_FORMAT_KHR;
|
||||
config_attrs[n++] = EGL_FORMAT_RGBA_8888_KHR;
|
||||
|
||||
|
||||
config_attrs[n++] = EGL_NONE;
|
||||
|
||||
|
||||
if (!egl.ChooseConfig(ed, config_attrs, &eglconfig, 1, &num_config))
|
||||
return NULL;
|
||||
return eglconfig;
|
||||
|
@ -202,6 +205,7 @@ _egl_x_win_surf_new(void *ed, Window win, void *config)
|
|||
if (!_egl_find()) return NULL;
|
||||
return egl.CreateWindowSurface(ed, config, win, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
|
@ -222,17 +226,17 @@ _egl_x_surf_map(void *ed, void *surf, int *stride)
|
|||
#ifdef BUILD_ENGINE_SOFTWARE_XLIB
|
||||
int config_attrs[40], n = 0;
|
||||
void *ptr = NULL;
|
||||
int pitch = 0, origin = 0;
|
||||
int pitch = 0, origin = 0;
|
||||
int r_offset = 0, g_offset = 0, b_offset = 0;
|
||||
|
||||
|
||||
if (!_egl_find()) return NULL;
|
||||
|
||||
|
||||
config_attrs[n++] = EGL_MAP_PRESERVE_PIXELS_KHR;
|
||||
config_attrs[n++] = EGL_TRUE;
|
||||
config_attrs[n++] = EGL_LOCK_USAGE_HINT_KHR;
|
||||
config_attrs[n++] = EGL_READ_SURFACE_BIT_KHR | EGL_WRITE_SURFACE_BIT_KHR;
|
||||
config_attrs[n++] = EGL_NONE;
|
||||
|
||||
|
||||
if (!egl.LockSurface(ed, surf, config_attrs)) return NULL;
|
||||
if (!egl.QuerySurface(ed, surf, EGL_BITMAP_POINTER_KHR, (int *)&ptr)) goto err;
|
||||
if (!egl.QuerySurface(ed, surf, EGL_BITMAP_PITCH_KHR, &pitch)) goto err;
|
||||
|
@ -240,7 +244,7 @@ _egl_x_surf_map(void *ed, void *surf, int *stride)
|
|||
if (!egl.QuerySurface(ed, surf, EGL_BITMAP_PIXEL_RED_OFFSET_KHR, &r_offset)) goto err;
|
||||
if (!egl.QuerySurface(ed, surf, EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR, &g_offset)) goto err;
|
||||
if (!egl.QuerySurface(ed, surf, EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR, &b_offset)) goto err;
|
||||
|
||||
|
||||
if (!ptr) goto err;
|
||||
if (pitch <= 0) goto err;
|
||||
// must be top-left to bottom-right ordered
|
||||
|
@ -294,20 +298,21 @@ evas_software_egl_outbuf_setup_x(int w, int h, int rot, Outbuf_Depth depth,
|
|||
int grayscale, int max_colors, Pixmap mask,
|
||||
int shape_dither, int destination_alpha)
|
||||
{
|
||||
(void) w;
|
||||
(void) h;
|
||||
(void) rot;
|
||||
(void) depth;
|
||||
(void) draw;
|
||||
(void) cmap;
|
||||
(void) x_depth;
|
||||
(void) grayscale;
|
||||
(void) max_colors;
|
||||
(void) mask;
|
||||
(void) shape_dither;
|
||||
(void) destination_alpha;
|
||||
(void) disp;
|
||||
(void) vis;
|
||||
(void)w;
|
||||
(void)h;
|
||||
(void)rot;
|
||||
(void)depth;
|
||||
(void)draw;
|
||||
(void)cmap;
|
||||
(void)x_depth;
|
||||
(void)grayscale;
|
||||
(void)max_colors;
|
||||
(void)mask;
|
||||
(void)shape_dither;
|
||||
(void)destination_alpha;
|
||||
(void)disp;
|
||||
(void)vis;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,43 +18,43 @@ evas_software_xlib_x_write_mask_line(Outbuf *buf, X_Output_Buffer *xob, DATA32 *
|
|||
w -= 7;
|
||||
if (buf->priv.x11.xlib.bit_swap)
|
||||
{
|
||||
for (x = 0; x < w; x += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[0])) >> 7) << 7) |
|
||||
((A_VAL(&(src_ptr[1])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[2])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[3])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[4])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[5])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[6])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[7])) >> 7) << 0);
|
||||
src_ptr += 8;
|
||||
dst_ptr++;
|
||||
}
|
||||
for (x = 0; x < w; x += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[0])) >> 7) << 7) |
|
||||
((A_VAL(&(src_ptr[1])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[2])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[3])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[4])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[5])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[6])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[7])) >> 7) << 0);
|
||||
src_ptr += 8;
|
||||
dst_ptr++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (x = 0; x < w; x += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[0])) >> 7) << 0) |
|
||||
((A_VAL(&(src_ptr[1])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[2])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[3])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[4])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[5])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[6])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[7])) >> 7) << 7);
|
||||
src_ptr += 8;
|
||||
dst_ptr++;
|
||||
}
|
||||
for (x = 0; x < w; x += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[0])) >> 7) << 0) |
|
||||
((A_VAL(&(src_ptr[1])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[2])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[3])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[4])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[5])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[6])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[7])) >> 7) << 7);
|
||||
src_ptr += 8;
|
||||
dst_ptr++;
|
||||
}
|
||||
}
|
||||
w += 7;
|
||||
for (; x < w; x ++)
|
||||
for (; x < w; x++)
|
||||
{
|
||||
XPutPixel(xob->xim, x, y, A_VAL(src_ptr) >> 7);
|
||||
src_ptr++;
|
||||
XPutPixel(xob->xim, x, y, A_VAL(src_ptr) >> 7);
|
||||
src_ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,49 +72,49 @@ evas_software_xlib_x_write_mask_line_rev(Outbuf *buf, X_Output_Buffer *xob, DATA
|
|||
w -= 7;
|
||||
if (buf->priv.x11.xlib.bit_swap)
|
||||
{
|
||||
for (x = 0; x < w; x += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[ 0])) >> 7) << 7) |
|
||||
((A_VAL(&(src_ptr[-1])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[-2])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[-3])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[-4])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[-5])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[-6])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[-7])) >> 7) << 0);
|
||||
src_ptr -= 8;
|
||||
dst_ptr++;
|
||||
}
|
||||
for (x = 0; x < w; x += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[ 0])) >> 7) << 7) |
|
||||
((A_VAL(&(src_ptr[-1])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[-2])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[-3])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[-4])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[-5])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[-6])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[-7])) >> 7) << 0);
|
||||
src_ptr -= 8;
|
||||
dst_ptr++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (x = 0; x < w; x += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[ 0])) >> 7) << 0) |
|
||||
((A_VAL(&(src_ptr[-1])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[-2])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[-3])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[-4])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[-5])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[-6])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[-7])) >> 7) << 7);
|
||||
src_ptr -= 8;
|
||||
dst_ptr++;
|
||||
}
|
||||
for (x = 0; x < w; x += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[ 0])) >> 7) << 0) |
|
||||
((A_VAL(&(src_ptr[-1])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[-2])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[-3])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[-4])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[-5])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[-6])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[-7])) >> 7) << 7);
|
||||
src_ptr -= 8;
|
||||
dst_ptr++;
|
||||
}
|
||||
}
|
||||
w += 7;
|
||||
for (; x < w; x ++)
|
||||
for (; x < w; x++)
|
||||
{
|
||||
XPutPixel(xob->xim, x, y, A_VAL(src_ptr) >> 7);
|
||||
src_ptr--;
|
||||
XPutPixel(xob->xim, x, y, A_VAL(src_ptr) >> 7);
|
||||
src_ptr--;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
evas_software_xlib_x_write_mask_line_vert(Outbuf *buf, X_Output_Buffer *xob,
|
||||
DATA32 *src,
|
||||
evas_software_xlib_x_write_mask_line_vert(Outbuf *buf, X_Output_Buffer *xob,
|
||||
DATA32 *src,
|
||||
int h, int ym, int w)
|
||||
{
|
||||
int y;
|
||||
|
@ -128,49 +128,49 @@ evas_software_xlib_x_write_mask_line_vert(Outbuf *buf, X_Output_Buffer *xob,
|
|||
h -= 7;
|
||||
if (buf->priv.x11.xlib.bit_swap)
|
||||
{
|
||||
for (y = 0; y < h; y += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[0 * w])) >> 7) << 7) |
|
||||
((A_VAL(&(src_ptr[1 * w])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[2 * w])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[3 * w])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[4 * w])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[5 * w])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[6 * w])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[7 * w])) >> 7) << 0);
|
||||
src_ptr += 8 * w;
|
||||
dst_ptr++;
|
||||
}
|
||||
for (y = 0; y < h; y += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[0 * w])) >> 7) << 7) |
|
||||
((A_VAL(&(src_ptr[1 * w])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[2 * w])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[3 * w])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[4 * w])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[5 * w])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[6 * w])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[7 * w])) >> 7) << 0);
|
||||
src_ptr += 8 * w;
|
||||
dst_ptr++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (y = 0; y < h; y += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[0 * w])) >> 7) << 0) |
|
||||
((A_VAL(&(src_ptr[1 * w])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[2 * w])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[3 * w])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[4 * w])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[5 * w])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[6 * w])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[7 * w])) >> 7) << 7);
|
||||
src_ptr += 8 * w;
|
||||
dst_ptr++;
|
||||
}
|
||||
for (y = 0; y < h; y += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[0 * w])) >> 7) << 0) |
|
||||
((A_VAL(&(src_ptr[1 * w])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[2 * w])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[3 * w])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[4 * w])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[5 * w])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[6 * w])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[7 * w])) >> 7) << 7);
|
||||
src_ptr += 8 * w;
|
||||
dst_ptr++;
|
||||
}
|
||||
}
|
||||
h += 7;
|
||||
for (; y < h; y ++)
|
||||
for (; y < h; y++)
|
||||
{
|
||||
XPutPixel(xob->xim, y, ym, A_VAL(src_ptr) >> 7);
|
||||
src_ptr += w;
|
||||
XPutPixel(xob->xim, y, ym, A_VAL(src_ptr) >> 7);
|
||||
src_ptr += w;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
evas_software_xlib_x_write_mask_line_vert_rev(Outbuf *buf, X_Output_Buffer *xob,
|
||||
DATA32 *src,
|
||||
evas_software_xlib_x_write_mask_line_vert_rev(Outbuf *buf, X_Output_Buffer *xob,
|
||||
DATA32 *src,
|
||||
int h, int ym, int w)
|
||||
{
|
||||
int y;
|
||||
|
@ -184,43 +184,43 @@ evas_software_xlib_x_write_mask_line_vert_rev(Outbuf *buf, X_Output_Buffer *xob,
|
|||
h -= 7;
|
||||
if (buf->priv.x11.xlib.bit_swap)
|
||||
{
|
||||
for (y = 0; y < h; y += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[ 0 * w])) >> 7) << 7) |
|
||||
((A_VAL(&(src_ptr[-1 * w])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[-2 * w])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[-3 * w])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[-4 * w])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[-5 * w])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[-6 * w])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[-7 * w])) >> 7) << 0);
|
||||
src_ptr -= 8 * w;
|
||||
dst_ptr++;
|
||||
}
|
||||
for (y = 0; y < h; y += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[ 0 * w])) >> 7) << 7) |
|
||||
((A_VAL(&(src_ptr[-1 * w])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[-2 * w])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[-3 * w])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[-4 * w])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[-5 * w])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[-6 * w])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[-7 * w])) >> 7) << 0);
|
||||
src_ptr -= 8 * w;
|
||||
dst_ptr++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (y = 0; y < h; y += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[ 0 * w])) >> 7) << 0) |
|
||||
((A_VAL(&(src_ptr[-1 * w])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[-2 * w])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[-3 * w])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[-4 * w])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[-5 * w])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[-6 * w])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[-7 * w])) >> 7) << 7);
|
||||
src_ptr -= 8 * w;
|
||||
dst_ptr++;
|
||||
}
|
||||
for (y = 0; y < h; y += 8)
|
||||
{
|
||||
*dst_ptr =
|
||||
((A_VAL(&(src_ptr[ 0 * w])) >> 7) << 0) |
|
||||
((A_VAL(&(src_ptr[-1 * w])) >> 7) << 1) |
|
||||
((A_VAL(&(src_ptr[-2 * w])) >> 7) << 2) |
|
||||
((A_VAL(&(src_ptr[-3 * w])) >> 7) << 3) |
|
||||
((A_VAL(&(src_ptr[-4 * w])) >> 7) << 4) |
|
||||
((A_VAL(&(src_ptr[-5 * w])) >> 7) << 5) |
|
||||
((A_VAL(&(src_ptr[-6 * w])) >> 7) << 6) |
|
||||
((A_VAL(&(src_ptr[-7 * w])) >> 7) << 7);
|
||||
src_ptr -= 8 * w;
|
||||
dst_ptr++;
|
||||
}
|
||||
}
|
||||
h += 7;
|
||||
for (; y < h; y ++)
|
||||
for (; y < h; y++)
|
||||
{
|
||||
XPutPixel(xob->xim, y, ym, A_VAL(src_ptr) >> 7);
|
||||
src_ptr -= w;
|
||||
XPutPixel(xob->xim, y, ym, A_VAL(src_ptr) >> 7);
|
||||
src_ptr -= w;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,24 +229,24 @@ evas_software_xlib_x_can_do_shm(Display *d)
|
|||
{
|
||||
static Display *cached_d = NULL;
|
||||
static int cached_result = 0;
|
||||
|
||||
|
||||
if (d == cached_d) return cached_result;
|
||||
cached_d = d;
|
||||
if (XShmQueryExtension(d))
|
||||
{
|
||||
X_Output_Buffer *xob;
|
||||
X_Output_Buffer *xob;
|
||||
|
||||
xob = evas_software_xlib_x_output_buffer_new
|
||||
(d, DefaultVisual(d, DefaultScreen(d)),
|
||||
DefaultDepth(d, DefaultScreen(d)), 16, 16, 2, NULL);
|
||||
if (!xob)
|
||||
{
|
||||
cached_result = 0;
|
||||
return 0;
|
||||
}
|
||||
evas_software_xlib_x_output_buffer_unref(xob, 1);
|
||||
cached_result = 1;
|
||||
return 1;
|
||||
xob = evas_software_xlib_x_output_buffer_new
|
||||
(d, DefaultVisual(d, DefaultScreen(d)),
|
||||
DefaultDepth(d, DefaultScreen(d)), 16, 16, 2, NULL);
|
||||
if (!xob)
|
||||
{
|
||||
cached_result = 0;
|
||||
return 0;
|
||||
}
|
||||
evas_software_xlib_x_output_buffer_unref(xob, 1);
|
||||
cached_result = 1;
|
||||
return 1;
|
||||
}
|
||||
cached_result = 0;
|
||||
return 0;
|
||||
|
@ -279,26 +279,26 @@ evas_software_xlib_x_output_buffer_new(Display *d, Visual *v, int depth, int w,
|
|||
|
||||
if (try_shm > 0)
|
||||
{
|
||||
xob->shm_info = malloc(sizeof(XShmSegmentInfo));
|
||||
if (xob->shm_info)
|
||||
{
|
||||
xob->xim = XShmCreateImage(d, v, depth, ZPixmap, NULL,
|
||||
xob->shm_info, w, h);
|
||||
if (xob->xim)
|
||||
{
|
||||
xob->shm_info->shmid = shmget(IPC_PRIVATE,
|
||||
xob->xim->bytes_per_line *
|
||||
xob->xim->height,
|
||||
IPC_CREAT | 0600);
|
||||
if (xob->shm_info->shmid >= 0)
|
||||
{
|
||||
xob->shm_info->readOnly = False;
|
||||
xob->shm_info->shmaddr = xob->xim->data =
|
||||
shmat(xob->shm_info->shmid, 0, 0);
|
||||
if (xob->shm_info->shmaddr != ((void *)-1))
|
||||
{
|
||||
XErrorHandler ph;
|
||||
|
||||
xob->shm_info = malloc(sizeof(XShmSegmentInfo));
|
||||
if (xob->shm_info)
|
||||
{
|
||||
xob->xim = XShmCreateImage(d, v, depth, ZPixmap, NULL,
|
||||
xob->shm_info, w, h);
|
||||
if (xob->xim)
|
||||
{
|
||||
xob->shm_info->shmid = shmget(IPC_PRIVATE,
|
||||
xob->xim->bytes_per_line *
|
||||
xob->xim->height,
|
||||
IPC_CREAT | 0600);
|
||||
if (xob->shm_info->shmid >= 0)
|
||||
{
|
||||
xob->shm_info->readOnly = False;
|
||||
xob->shm_info->shmaddr = xob->xim->data =
|
||||
shmat(xob->shm_info->shmid, 0, 0);
|
||||
if (xob->shm_info->shmaddr != ((void *)-1))
|
||||
{
|
||||
XErrorHandler ph;
|
||||
|
||||
if (try_shm == 2) // only needed during testing
|
||||
{
|
||||
XSync(d, False);
|
||||
|
@ -307,38 +307,38 @@ evas_software_xlib_x_output_buffer_new(Display *d, Visual *v, int depth, int w,
|
|||
x_output_tmp_x_err);
|
||||
}
|
||||
#if defined(LIBXEXT_VERSION_LOW)
|
||||
/* workaround for libXext of lower then 1.1.1 */
|
||||
if (evas_common_frameq_enabled())
|
||||
XLockDisplay(d);
|
||||
/* workaround for libXext of lower then 1.1.1 */
|
||||
if (evas_common_frameq_enabled())
|
||||
XLockDisplay(d);
|
||||
#endif
|
||||
XShmAttach(d, xob->shm_info);
|
||||
XShmAttach(d, xob->shm_info);
|
||||
#if defined(LIBXEXT_VERSION_LOW)
|
||||
/* workaround for libXext of lower then 1.1.1 */
|
||||
if (evas_common_frameq_enabled())
|
||||
XUnlockDisplay(d);
|
||||
/* workaround for libXext of lower then 1.1.1 */
|
||||
if (evas_common_frameq_enabled())
|
||||
XUnlockDisplay(d);
|
||||
#endif
|
||||
|
||||
if (try_shm == 2) // only needed during testing
|
||||
{
|
||||
XSync(d, False);
|
||||
XSync(d, False);
|
||||
XSetErrorHandler((XErrorHandler)ph);
|
||||
}
|
||||
if (!_x_err)
|
||||
{
|
||||
xob->bpl = xob->xim->bytes_per_line;
|
||||
xob->psize = xob->bpl * xob->h;
|
||||
return xob;
|
||||
}
|
||||
}
|
||||
shmdt(xob->shm_info->shmaddr);
|
||||
shmctl(xob->shm_info->shmid, IPC_RMID, 0);
|
||||
}
|
||||
if (xob->xim) XDestroyImage(xob->xim);
|
||||
xob->xim = NULL;
|
||||
}
|
||||
if (xob->shm_info) free(xob->shm_info);
|
||||
xob->shm_info = NULL;
|
||||
}
|
||||
xob->bpl = xob->xim->bytes_per_line;
|
||||
xob->psize = xob->bpl * xob->h;
|
||||
return xob;
|
||||
}
|
||||
}
|
||||
shmdt(xob->shm_info->shmaddr);
|
||||
shmctl(xob->shm_info->shmid, IPC_RMID, 0);
|
||||
}
|
||||
if (xob->xim) XDestroyImage(xob->xim);
|
||||
xob->xim = NULL;
|
||||
}
|
||||
if (xob->shm_info) free(xob->shm_info);
|
||||
xob->shm_info = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (try_shm > 1)
|
||||
|
@ -350,21 +350,21 @@ evas_software_xlib_x_output_buffer_new(Display *d, Visual *v, int depth, int w,
|
|||
xob->xim = XCreateImage(d, v, depth, ZPixmap, 0, data, w, h, 32, 0);
|
||||
if (!xob->xim)
|
||||
{
|
||||
free(xob);
|
||||
return NULL;
|
||||
free(xob);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xob->data = data;
|
||||
|
||||
if (!xob->xim->data)
|
||||
{
|
||||
xob->xim->data = malloc(xob->xim->bytes_per_line * xob->xim->height);
|
||||
if (!xob->xim->data)
|
||||
{
|
||||
XDestroyImage(xob->xim);
|
||||
free(xob);
|
||||
return NULL;
|
||||
}
|
||||
xob->xim->data = malloc(xob->xim->bytes_per_line * xob->xim->height);
|
||||
if (!xob->xim->data)
|
||||
{
|
||||
XDestroyImage(xob->xim);
|
||||
free(xob);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
xob->bpl = xob->xim->bytes_per_line;
|
||||
xob->psize = xob->bpl * xob->h;
|
||||
|
@ -390,17 +390,17 @@ evas_software_xlib_x_output_buffer_unref(X_Output_Buffer *xob, int psync)
|
|||
return;
|
||||
if (xob->shm_info)
|
||||
{
|
||||
if (psync) XSync(xob->display, False);
|
||||
XShmDetach(xob->display, xob->shm_info);
|
||||
XDestroyImage(xob->xim);
|
||||
shmdt(xob->shm_info->shmaddr);
|
||||
shmctl(xob->shm_info->shmid, IPC_RMID, 0);
|
||||
free(xob->shm_info);
|
||||
if (psync) XSync(xob->display, False);
|
||||
XShmDetach(xob->display, xob->shm_info);
|
||||
XDestroyImage(xob->xim);
|
||||
shmdt(xob->shm_info->shmaddr);
|
||||
shmctl(xob->shm_info->shmid, IPC_RMID, 0);
|
||||
free(xob->shm_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xob->data) xob->xim->data = NULL;
|
||||
XDestroyImage(xob->xim);
|
||||
if (xob->data) xob->xim->data = NULL;
|
||||
XDestroyImage(xob->xim);
|
||||
}
|
||||
free(xob);
|
||||
}
|
||||
|
@ -410,14 +410,14 @@ evas_software_xlib_x_output_buffer_paste(X_Output_Buffer *xob, Drawable d, GC gc
|
|||
{
|
||||
if (xob->shm_info)
|
||||
{
|
||||
XShmPutImage(xob->display, d, gc, xob->xim, 0, 0, x, y,
|
||||
xob->w, xob->h, False);
|
||||
if (psync) XSync(xob->display, False);
|
||||
XShmPutImage(xob->display, d, gc, xob->xim, 0, 0, x, y,
|
||||
xob->w, xob->h, False);
|
||||
if (psync) XSync(xob->display, False);
|
||||
}
|
||||
else
|
||||
{
|
||||
XPutImage(xob->display, d, gc, xob->xim, 0, 0, x, y,
|
||||
xob->w, xob->h);
|
||||
XPutImage(xob->display, d, gc, xob->xim, 0, 0, x, y,
|
||||
xob->w, xob->h);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,3 +445,4 @@ evas_software_xlib_x_output_buffer_bit_order(X_Output_Buffer *xob)
|
|||
{
|
||||
return xob->xim->bitmap_bit_order;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,27 +14,27 @@ struct _Convert_Pal_Priv
|
|||
Visual *vis;
|
||||
};
|
||||
|
||||
typedef DATA8 * (*X_Func_Alloc_Colors) (Display *d, Colormap cmap, Visual *v);
|
||||
typedef DATA8 * (*X_Func_Alloc_Colors)(Display *d, Colormap cmap, Visual *v);
|
||||
|
||||
static X_Func_Alloc_Colors x_color_alloc[PAL_MODE_LAST + 1];
|
||||
static int x_color_count[PAL_MODE_LAST + 1];
|
||||
static Eina_List *palettes = NULL;
|
||||
static int x_color_count[PAL_MODE_LAST + 1];
|
||||
static Eina_List *palettes = NULL;
|
||||
|
||||
static DATA8 * x_color_alloc_rgb(int nr, int ng, int nb, Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 * x_color_alloc_gray(int ng, Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_rgb(int nr, int ng, int nb, Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_gray(int ng, Display *d, Colormap cmap, Visual *v);
|
||||
|
||||
static DATA8 * x_color_alloc_rgb_332(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 * x_color_alloc_rgb_666(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 * x_color_alloc_rgb_232(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 * x_color_alloc_rgb_222(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 * x_color_alloc_rgb_221(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 * x_color_alloc_rgb_121(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 * x_color_alloc_rgb_111(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 * x_color_alloc_gray_256(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 * x_color_alloc_gray_64(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 * x_color_alloc_gray_16(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 * x_color_alloc_gray_4(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 * x_color_alloc_mono(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_rgb_332(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_rgb_666(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_rgb_232(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_rgb_222(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_rgb_221(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_rgb_121(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_rgb_111(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_gray_256(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_gray_64(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_gray_16(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_gray_4(Display *d, Colormap cmap, Visual *v);
|
||||
static DATA8 *x_color_alloc_mono(Display *d, Colormap cmap, Visual *v);
|
||||
|
||||
static DATA8 *
|
||||
x_color_alloc_rgb(int nr, int ng, int nb, Display *d, Colormap cmap, Visual *v)
|
||||
|
@ -43,7 +43,8 @@ x_color_alloc_rgb(int nr, int ng, int nb, Display *d, Colormap cmap, Visual *v)
|
|||
DATA8 *color_lut;
|
||||
int sig_mask = 0, delt = 0;
|
||||
|
||||
for (i = 0; i < v->bits_per_rgb; i++) sig_mask |= (0x1 << i);
|
||||
for (i = 0; i < v->bits_per_rgb; i++)
|
||||
sig_mask |= (0x1 << i);
|
||||
sig_mask <<= (16 - v->bits_per_rgb);
|
||||
i = 0;
|
||||
color_lut = malloc((nr) * (ng) * (nb));
|
||||
|
@ -51,69 +52,69 @@ x_color_alloc_rgb(int nr, int ng, int nb, Display *d, Colormap cmap, Visual *v)
|
|||
delt = 0x0101 * 3;
|
||||
for (r = 0; r < (nr); r++)
|
||||
{
|
||||
for (g = 0; g < (ng); g++)
|
||||
{
|
||||
for (b = 0; b < (nb); b++)
|
||||
{
|
||||
XColor xcl;
|
||||
XColor xcl_in;
|
||||
int val;
|
||||
Status ret;
|
||||
int dr, dg, db;
|
||||
for (g = 0; g < (ng); g++)
|
||||
{
|
||||
for (b = 0; b < (nb); b++)
|
||||
{
|
||||
XColor xcl;
|
||||
XColor xcl_in;
|
||||
int val;
|
||||
Status ret;
|
||||
int dr, dg, db;
|
||||
|
||||
val = (int)(((r * 255) / ((nr) - 1)));
|
||||
val = (val << 8) | val;
|
||||
xcl.red = (unsigned short)(val);
|
||||
val = (int)(((g * 255) / ((ng) - 1)));
|
||||
val = (val << 8) | val;
|
||||
xcl.green = (unsigned short)(val);
|
||||
val = (int)(((b * 255) / ((nb) - 1)));
|
||||
val = (val << 8) | val;
|
||||
xcl.blue = (unsigned short)(val);
|
||||
val = (val << 8) | val;
|
||||
xcl.red = (unsigned short)(val);
|
||||
val = (int)(((g * 255) / ((ng) - 1)));
|
||||
val = (val << 8) | val;
|
||||
xcl.green = (unsigned short)(val);
|
||||
val = (int)(((b * 255) / ((nb) - 1)));
|
||||
val = (val << 8) | val;
|
||||
xcl.blue = (unsigned short)(val);
|
||||
xcl.pixel = 0;
|
||||
xcl.flags = 0;
|
||||
xcl.pad = 0;
|
||||
xcl_in = xcl;
|
||||
ret = XAllocColor(d, cmap, &xcl);
|
||||
dr = (int)xcl_in.red - (int)xcl.red;
|
||||
if (dr < 0) dr = -dr;
|
||||
dg = (int)xcl_in.green - (int)xcl.green;
|
||||
if (dg < 0) dg = -dg;
|
||||
db = (int)xcl_in.blue - (int)xcl.blue;
|
||||
if (db < 0) db = -db;
|
||||
/*
|
||||
printf("ASK [%i]: %04x %04x %04x = %04x %04x %04x | dif = %04x / %04x\n",
|
||||
ret,
|
||||
xcl_in.red, xcl_in.green, xcl_in.blue,
|
||||
xcl.red, xcl.green, xcl.blue,
|
||||
(dr + dg +db), delt);
|
||||
*/
|
||||
if ((ret == 0) ||
|
||||
((dr + dg + db) > delt)
|
||||
xcl_in = xcl;
|
||||
ret = XAllocColor(d, cmap, &xcl);
|
||||
dr = (int)xcl_in.red - (int)xcl.red;
|
||||
if (dr < 0) dr = -dr;
|
||||
dg = (int)xcl_in.green - (int)xcl.green;
|
||||
if (dg < 0) dg = -dg;
|
||||
db = (int)xcl_in.blue - (int)xcl.blue;
|
||||
if (db < 0) db = -db;
|
||||
/*
|
||||
||
|
||||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
|
||||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
|
||||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask))
|
||||
printf("ASK [%i]: %04x %04x %04x = %04x %04x %04x | dif = %04x / %04x\n",
|
||||
ret,
|
||||
xcl_in.red, xcl_in.green, xcl_in.blue,
|
||||
xcl.red, xcl.green, xcl.blue,
|
||||
(dr + dg +db), delt);
|
||||
*/
|
||||
)
|
||||
{
|
||||
unsigned long pixels[256];
|
||||
int j;
|
||||
if ((ret == 0) ||
|
||||
((dr + dg + db) > delt)
|
||||
/*
|
||||
||
|
||||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
|
||||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
|
||||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask))
|
||||
*/
|
||||
)
|
||||
{
|
||||
unsigned long pixels[256];
|
||||
int j;
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
for (j = 0; j < i; j++)
|
||||
pixels[j] = (unsigned long) color_lut[j];
|
||||
XFreeColors(d, cmap, pixels, i, 0);
|
||||
}
|
||||
free(color_lut);
|
||||
return NULL;
|
||||
}
|
||||
color_lut[i] = xcl.pixel;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
for (j = 0; j < i; j++)
|
||||
pixels[j] = (unsigned long)color_lut[j];
|
||||
XFreeColors(d, cmap, pixels, i, 0);
|
||||
}
|
||||
free(color_lut);
|
||||
return NULL;
|
||||
}
|
||||
color_lut[i] = xcl.pixel;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return color_lut;
|
||||
}
|
||||
|
@ -125,47 +126,48 @@ x_color_alloc_gray(int ng, Display *d, Colormap cmap, Visual *v)
|
|||
DATA8 *color_lut;
|
||||
int sig_mask = 0;
|
||||
|
||||
for (i = 0; i < v->bits_per_rgb; i++) sig_mask |= (0x1 << i);
|
||||
for (i = 0; i < v->bits_per_rgb; i++)
|
||||
sig_mask |= (0x1 << i);
|
||||
sig_mask <<= (16 - v->bits_per_rgb);
|
||||
i = 0;
|
||||
color_lut = malloc(ng);
|
||||
if (!color_lut) return NULL;
|
||||
for (g = 0; g < (ng); g++)
|
||||
{
|
||||
XColor xcl;
|
||||
XColor xcl_in;
|
||||
int val;
|
||||
Status ret;
|
||||
XColor xcl;
|
||||
XColor xcl_in;
|
||||
int val;
|
||||
Status ret;
|
||||
|
||||
val = (int)(((g * 255) / ((ng) - 1)));
|
||||
val = (val << 8) | val;
|
||||
xcl.red = (unsigned short)(val);
|
||||
xcl.green = (unsigned short)(val);
|
||||
xcl.blue = (unsigned short)(val);
|
||||
val = (int)(((g * 255) / ((ng) - 1)));
|
||||
val = (val << 8) | val;
|
||||
xcl.red = (unsigned short)(val);
|
||||
xcl.green = (unsigned short)(val);
|
||||
xcl.blue = (unsigned short)(val);
|
||||
xcl.pixel = 0;
|
||||
xcl.flags = 0;
|
||||
xcl.pad = 0;
|
||||
xcl_in = xcl;
|
||||
ret = XAllocColor(d, cmap, &xcl);
|
||||
if ((ret == 0) ||
|
||||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
|
||||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
|
||||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
|
||||
{
|
||||
unsigned long pixels[256];
|
||||
int j;
|
||||
xcl_in = xcl;
|
||||
ret = XAllocColor(d, cmap, &xcl);
|
||||
if ((ret == 0) ||
|
||||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
|
||||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
|
||||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
|
||||
{
|
||||
unsigned long pixels[256];
|
||||
int j;
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
for (j = 0; j < i; j++)
|
||||
pixels[j] = (unsigned long) color_lut[j];
|
||||
XFreeColors(d, cmap, pixels, i, 0);
|
||||
}
|
||||
free(color_lut);
|
||||
return NULL;
|
||||
}
|
||||
color_lut[i] = xcl.pixel;
|
||||
i++;
|
||||
if (i > 0)
|
||||
{
|
||||
for (j = 0; j < i; j++)
|
||||
pixels[j] = (unsigned long)color_lut[j];
|
||||
XFreeColors(d, cmap, pixels, i, 0);
|
||||
}
|
||||
free(color_lut);
|
||||
return NULL;
|
||||
}
|
||||
color_lut[i] = xcl.pixel;
|
||||
i++;
|
||||
}
|
||||
return color_lut;
|
||||
}
|
||||
|
@ -248,83 +250,83 @@ evas_software_xlib_x_color_init(void)
|
|||
static int initialised = 0;
|
||||
|
||||
if (initialised) return;
|
||||
x_color_alloc[PAL_MODE_NONE] = NULL;
|
||||
x_color_count[PAL_MODE_NONE] = 0;
|
||||
x_color_alloc[PAL_MODE_NONE] = NULL;
|
||||
x_color_count[PAL_MODE_NONE] = 0;
|
||||
|
||||
x_color_alloc[PAL_MODE_MONO] = x_color_alloc_mono;
|
||||
x_color_count[PAL_MODE_MONO] = 2;
|
||||
x_color_alloc[PAL_MODE_MONO] = x_color_alloc_mono;
|
||||
x_color_count[PAL_MODE_MONO] = 2;
|
||||
|
||||
x_color_alloc[PAL_MODE_GRAY4] = x_color_alloc_gray_4;
|
||||
x_color_count[PAL_MODE_GRAY4] = 4;
|
||||
x_color_alloc[PAL_MODE_GRAY4] = x_color_alloc_gray_4;
|
||||
x_color_count[PAL_MODE_GRAY4] = 4;
|
||||
|
||||
x_color_alloc[PAL_MODE_GRAY16] = x_color_alloc_gray_16;
|
||||
x_color_count[PAL_MODE_GRAY16] = 16;
|
||||
x_color_alloc[PAL_MODE_GRAY16] = x_color_alloc_gray_16;
|
||||
x_color_count[PAL_MODE_GRAY16] = 16;
|
||||
|
||||
x_color_alloc[PAL_MODE_GRAY64] = x_color_alloc_gray_64;
|
||||
x_color_count[PAL_MODE_GRAY64] = 64;
|
||||
x_color_alloc[PAL_MODE_GRAY64] = x_color_alloc_gray_64;
|
||||
x_color_count[PAL_MODE_GRAY64] = 64;
|
||||
|
||||
x_color_alloc[PAL_MODE_GRAY256] = x_color_alloc_gray_256;
|
||||
x_color_count[PAL_MODE_GRAY256] = 256;
|
||||
|
||||
x_color_alloc[PAL_MODE_RGB111] = x_color_alloc_rgb_111;
|
||||
x_color_count[PAL_MODE_RGB111] = 2 * 2 * 2;
|
||||
x_color_alloc[PAL_MODE_RGB111] = x_color_alloc_rgb_111;
|
||||
x_color_count[PAL_MODE_RGB111] = 2 * 2 * 2;
|
||||
|
||||
x_color_alloc[PAL_MODE_RGB121] = x_color_alloc_rgb_121;
|
||||
x_color_count[PAL_MODE_RGB121] = 2 * 4 * 2;
|
||||
x_color_alloc[PAL_MODE_RGB121] = x_color_alloc_rgb_121;
|
||||
x_color_count[PAL_MODE_RGB121] = 2 * 4 * 2;
|
||||
|
||||
x_color_alloc[PAL_MODE_RGB221] = x_color_alloc_rgb_221;
|
||||
x_color_count[PAL_MODE_RGB221] = 4 * 4 * 2;
|
||||
x_color_alloc[PAL_MODE_RGB221] = x_color_alloc_rgb_221;
|
||||
x_color_count[PAL_MODE_RGB221] = 4 * 4 * 2;
|
||||
|
||||
x_color_alloc[PAL_MODE_RGB222] = x_color_alloc_rgb_222;
|
||||
x_color_count[PAL_MODE_RGB222] = 4 * 4 * 4;
|
||||
x_color_alloc[PAL_MODE_RGB222] = x_color_alloc_rgb_222;
|
||||
x_color_count[PAL_MODE_RGB222] = 4 * 4 * 4;
|
||||
|
||||
x_color_alloc[PAL_MODE_RGB232] = x_color_alloc_rgb_232;
|
||||
x_color_count[PAL_MODE_RGB232] = 4 * 8 * 4;
|
||||
x_color_alloc[PAL_MODE_RGB232] = x_color_alloc_rgb_232;
|
||||
x_color_count[PAL_MODE_RGB232] = 4 * 8 * 4;
|
||||
|
||||
x_color_alloc[PAL_MODE_RGB666] = x_color_alloc_rgb_666;
|
||||
x_color_count[PAL_MODE_RGB666] = 6 * 6 * 6;
|
||||
x_color_alloc[PAL_MODE_RGB666] = x_color_alloc_rgb_666;
|
||||
x_color_count[PAL_MODE_RGB666] = 6 * 6 * 6;
|
||||
|
||||
x_color_alloc[PAL_MODE_RGB332] = x_color_alloc_rgb_332;
|
||||
x_color_count[PAL_MODE_RGB332] = 8 * 8 * 4;
|
||||
x_color_alloc[PAL_MODE_RGB332] = x_color_alloc_rgb_332;
|
||||
x_color_count[PAL_MODE_RGB332] = 8 * 8 * 4;
|
||||
|
||||
x_color_alloc[PAL_MODE_LAST] = NULL;
|
||||
x_color_count[PAL_MODE_LAST] = 0;
|
||||
x_color_alloc[PAL_MODE_LAST] = NULL;
|
||||
x_color_count[PAL_MODE_LAST] = 0;
|
||||
initialised = 1;
|
||||
}
|
||||
|
||||
Convert_Pal *
|
||||
evas_software_xlib_x_color_allocate(Display *disp,
|
||||
Colormap cmap,
|
||||
Visual *vis,
|
||||
evas_software_xlib_x_color_allocate(Display *disp,
|
||||
Colormap cmap,
|
||||
Visual *vis,
|
||||
Convert_Pal_Mode colors)
|
||||
{
|
||||
Convert_Pal_Priv *palpriv;
|
||||
Convert_Pal *pal;
|
||||
Convert_Pal_Mode c;
|
||||
Eina_List *l;
|
||||
Convert_Pal *pal;
|
||||
Convert_Pal_Mode c;
|
||||
Eina_List *l;
|
||||
|
||||
/* printf("ALLOC cmap=%i vis=%p\n", cmap, vis);*/
|
||||
EINA_LIST_FOREACH(palettes, l, pal)
|
||||
{
|
||||
palpriv = pal->data;
|
||||
if ((disp == palpriv->disp) &&
|
||||
(vis == palpriv->vis) &&
|
||||
(cmap == palpriv->cmap))
|
||||
{
|
||||
pal->references++;
|
||||
return pal;
|
||||
}
|
||||
palpriv = pal->data;
|
||||
if ((disp == palpriv->disp) &&
|
||||
(vis == palpriv->vis) &&
|
||||
(cmap == palpriv->cmap))
|
||||
{
|
||||
pal->references++;
|
||||
return pal;
|
||||
}
|
||||
}
|
||||
pal = calloc(1, sizeof(struct _Convert_Pal));
|
||||
if (!pal) return NULL;
|
||||
for (c = colors; c > PAL_MODE_NONE; c--)
|
||||
{
|
||||
if (x_color_alloc[c])
|
||||
{
|
||||
if (x_color_alloc[c])
|
||||
{
|
||||
/* printf("TRY PAL %i\n", c);*/
|
||||
pal->lookup = (x_color_alloc[c])(disp, cmap, vis);
|
||||
if (pal->lookup) break;
|
||||
}
|
||||
pal->lookup = (x_color_alloc[c])(disp, cmap, vis);
|
||||
if (pal->lookup) break;
|
||||
}
|
||||
}
|
||||
pal->references = 1;
|
||||
pal->colors = c;
|
||||
|
@ -333,9 +335,9 @@ evas_software_xlib_x_color_allocate(Display *disp,
|
|||
pal->data = palpriv;
|
||||
if (!palpriv)
|
||||
{
|
||||
if (pal->lookup) free(pal->lookup);
|
||||
free(pal);
|
||||
return NULL;
|
||||
if (pal->lookup) free(pal->lookup);
|
||||
free(pal);
|
||||
return NULL;
|
||||
}
|
||||
palpriv->disp = disp;
|
||||
palpriv->vis = vis;
|
||||
|
@ -352,9 +354,9 @@ evas_software_xlib_x_color_allocate(Display *disp,
|
|||
}
|
||||
|
||||
void
|
||||
evas_software_xlib_x_color_deallocate(Display *disp,
|
||||
Colormap cmap,
|
||||
Visual *vis EINA_UNUSED,
|
||||
evas_software_xlib_x_color_deallocate(Display *disp,
|
||||
Colormap cmap,
|
||||
Visual *vis EINA_UNUSED,
|
||||
Convert_Pal *pal)
|
||||
{
|
||||
unsigned long pixels[256];
|
||||
|
@ -364,12 +366,13 @@ evas_software_xlib_x_color_deallocate(Display *disp,
|
|||
if (pal->references > 0) return;
|
||||
if (pal->lookup)
|
||||
{
|
||||
for(j = 0; j < pal->count; j++)
|
||||
pixels[j] = (unsigned long) pal->lookup[j];
|
||||
XFreeColors(disp, cmap, pixels, pal->count, 0);
|
||||
free(pal->lookup);
|
||||
for (j = 0; j < pal->count; j++)
|
||||
pixels[j] = (unsigned long)pal->lookup[j];
|
||||
XFreeColors(disp, cmap, pixels, pal->count, 0);
|
||||
free(pal->lookup);
|
||||
}
|
||||
free(pal->data);
|
||||
palettes = eina_list_remove(palettes, pal);
|
||||
free(pal);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,39 +6,37 @@
|
|||
#include "evas_xlib_dri_image.h"
|
||||
#include "../software_generic/evas_native_common.h"
|
||||
|
||||
# include <dlfcn.h> /* dlopen,dlclose,etc */
|
||||
# include <dlfcn.h> /* dlopen,dlclose,etc */
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
|
||||
static Eina_Bool tried = EINA_FALSE;
|
||||
////////////////////////////////////
|
||||
//libdrm.so.2
|
||||
static void *drm_lib = NULL;
|
||||
|
||||
typedef unsigned int drm_magic_t;
|
||||
static int (*sym_drmGetMagic) (int fd, drm_magic_t *magic) = NULL;
|
||||
static int (*sym_drmGetMagic)(int fd, drm_magic_t *magic) = NULL;
|
||||
|
||||
////////////////////////////////////
|
||||
// libtbm.so.1
|
||||
#define TBM_DEVICE_CPU 1
|
||||
#define TBM_OPTION_READ (1 << 0)
|
||||
#define TBM_OPTION_WRITE (1 << 1)
|
||||
#define TBM_DEVICE_CPU 1
|
||||
#define TBM_OPTION_READ (1 << 0)
|
||||
#define TBM_OPTION_WRITE (1 << 1)
|
||||
static void *lib_tbm = NULL;
|
||||
|
||||
|
||||
static tbm_bo (*sym_tbm_bo_import) (tbm_bufmgr bufmgr, unsigned int key) = NULL;
|
||||
static tbm_bo_handle (*sym_tbm_bo_map) (tbm_bo bo, int device, int opt) = NULL;
|
||||
static int (*sym_tbm_bo_unmap) (tbm_bo bo) = NULL;
|
||||
static void (*sym_tbm_bo_unref) (tbm_bo bo) = NULL;
|
||||
static tbm_bufmgr (*sym_tbm_bufmgr_init) (int fd) = NULL;
|
||||
static void (*sym_tbm_bufmgr_deinit) (tbm_bufmgr bufmgr) = NULL;
|
||||
static tbm_bo (*sym_tbm_bo_import)(tbm_bufmgr bufmgr, unsigned int key) = NULL;
|
||||
static tbm_bo_handle (*sym_tbm_bo_map)(tbm_bo bo, int device, int opt) = NULL;
|
||||
static int (*sym_tbm_bo_unmap)(tbm_bo bo) = NULL;
|
||||
static void (*sym_tbm_bo_unref)(tbm_bo bo) = NULL;
|
||||
static tbm_bufmgr (*sym_tbm_bufmgr_init)(int fd) = NULL;
|
||||
static void (*sym_tbm_bufmgr_deinit)(tbm_bufmgr bufmgr) = NULL;
|
||||
|
||||
// legacy compatibility
|
||||
static void *(*sym_drm_slp_bo_map) (tbm_bo bo, int device, int opt) = NULL;
|
||||
static int (*sym_drm_slp_bo_unmap) (tbm_bo bo, int device) = NULL;
|
||||
static tbm_bufmgr (*sym_drm_slp_bufmgr_init) (int fd, void *arg) = NULL;
|
||||
static void *(*sym_drm_slp_bo_map)(tbm_bo bo, int device, int opt) = NULL;
|
||||
static int (*sym_drm_slp_bo_unmap)(tbm_bo bo, int device) = NULL;
|
||||
static tbm_bufmgr (*sym_drm_slp_bufmgr_init)(int fd, void *arg) = NULL;
|
||||
|
||||
////////////////////////////////////
|
||||
// libdri2.so.0
|
||||
|
@ -47,23 +45,22 @@ static void *dri_lib = NULL;
|
|||
|
||||
typedef unsigned long long CD64;
|
||||
|
||||
static DRI2Buffer *(*sym_DRI2GetBuffers) (Display *display, XID drawable, int *width, int *height, unsigned int *attachments, int count, int *outCount) = NULL;
|
||||
static Bool (*sym_DRI2QueryExtension) (Display *display, int *eventBase, int *errorBase) = NULL;
|
||||
static Bool (*sym_DRI2QueryVersion) (Display *display, int *major, int *minor) = NULL;
|
||||
static Bool (*sym_DRI2Connect) (Display *display, XID window, char **driverName, char **deviceName) = NULL;
|
||||
static Bool (*sym_DRI2Authenticate) (Display *display, XID window, unsigned int magic) = NULL;
|
||||
static void (*sym_DRI2CreateDrawable) (Display *display, XID drawable) = NULL;
|
||||
static void (*sym_DRI2DestroyDrawable) (Display *display, XID handle) = NULL;
|
||||
static DRI2Buffer *(*sym_DRI2GetBuffers)(Display * display, XID drawable, int *width, int *height, unsigned int *attachments, int count, int *outCount) = NULL;
|
||||
static Bool (*sym_DRI2QueryExtension)(Display *display, int *eventBase, int *errorBase) = NULL;
|
||||
static Bool (*sym_DRI2QueryVersion)(Display *display, int *major, int *minor) = NULL;
|
||||
static Bool (*sym_DRI2Connect)(Display *display, XID window, char **driverName, char **deviceName) = NULL;
|
||||
static Bool (*sym_DRI2Authenticate)(Display *display, XID window, unsigned int magic) = NULL;
|
||||
static void (*sym_DRI2CreateDrawable)(Display *display, XID drawable) = NULL;
|
||||
static void (*sym_DRI2DestroyDrawable)(Display *display, XID handle) = NULL;
|
||||
|
||||
////////////////////////////////////
|
||||
// libXfixes.so.3
|
||||
static void *xfixes_lib = NULL;
|
||||
|
||||
static Bool (*sym_XFixesQueryExtension) (Display *display, int *event_base_return, int *error_base_return) = NULL;
|
||||
static Status (*sym_XFixesQueryVersion) (Display *display, int *major_version_return, int *minor_version_return) = NULL;
|
||||
static XID (*sym_XFixesCreateRegion) (Display *display, XRectangle *rectangles, int nrectangles) = NULL;
|
||||
static void (*sym_XFixesDestroyRegion) (Display *dpy, XID region) = NULL;
|
||||
|
||||
static Bool (*sym_XFixesQueryExtension)(Display *display, int *event_base_return, int *error_base_return) = NULL;
|
||||
static Status (*sym_XFixesQueryVersion)(Display *display, int *major_version_return, int *minor_version_return) = NULL;
|
||||
static XID (*sym_XFixesCreateRegion)(Display *display, XRectangle *rectangles, int nrectangles) = NULL;
|
||||
static void (*sym_XFixesDestroyRegion)(Display *dpy, XID region) = NULL;
|
||||
|
||||
static int inits = 0;
|
||||
static int xfixes_ev_base = 0, xfixes_err_base = 0;
|
||||
|
@ -88,54 +85,54 @@ _drm_init(Display *disp, int scr)
|
|||
tried = EINA_TRUE;
|
||||
drm_lib = dlopen("libdrm.so.2", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!drm_lib)
|
||||
{
|
||||
{
|
||||
ERR("Can't load libdrm.so.2");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
slp_mode = EINA_FALSE;
|
||||
lib_tbm = dlopen("libtbm.so.1", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!lib_tbm)
|
||||
{
|
||||
{
|
||||
ERR("Can't load libtbm.so.1");
|
||||
lib_tbm = dlopen("libdrm_slp.so.1", RTLD_NOW | RTLD_LOCAL);
|
||||
if (lib_tbm) slp_mode = EINA_TRUE;
|
||||
else goto err;
|
||||
}
|
||||
}
|
||||
dri_lib = dlopen("libdri2.so.0", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!dri_lib)
|
||||
{
|
||||
{
|
||||
ERR("Can't load libdri2.so.0");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
xfixes_lib = dlopen("libXfixes.so.3", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!xfixes_lib)
|
||||
{
|
||||
{
|
||||
ERR("Can't load libXfixes.so.3");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
#define SYM(l, x) \
|
||||
do { sym_ ## x = dlsym(l, #x); \
|
||||
if (!sym_ ## x) { \
|
||||
ERR("Can't load symbol "#x); \
|
||||
goto err; \
|
||||
} \
|
||||
} while (0)
|
||||
#define SYM(l, x) \
|
||||
do { sym_ ## x = dlsym(l, #x); \
|
||||
if (!sym_ ## x) { \
|
||||
ERR("Can't load symbol " #x); \
|
||||
goto err; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
SYM(drm_lib, drmGetMagic);
|
||||
|
||||
if (!slp_mode)
|
||||
{
|
||||
{
|
||||
SYM(lib_tbm, tbm_bo_import);
|
||||
SYM(lib_tbm, tbm_bo_map);
|
||||
SYM(lib_tbm, tbm_bo_unmap);
|
||||
SYM(lib_tbm, tbm_bo_unref);
|
||||
SYM(lib_tbm, tbm_bufmgr_init);
|
||||
SYM(lib_tbm, tbm_bufmgr_deinit);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
// Looking up the legacy DRM SLP symbols. I don't believe this will
|
||||
// ever happen, this code is here "just in case".
|
||||
sym_tbm_bo_import = dlsym(lib_tbm, "drm_slp_bo_import");
|
||||
|
@ -146,11 +143,11 @@ _drm_init(Display *disp, int scr)
|
|||
sym_tbm_bufmgr_deinit = dlsym(lib_tbm, "drm_slp_bufmgr_destroy");
|
||||
if (!sym_tbm_bo_import || !sym_drm_slp_bo_map || !sym_drm_slp_bo_unmap ||
|
||||
!sym_tbm_bo_unref || !sym_drm_slp_bufmgr_init || !sym_tbm_bufmgr_deinit)
|
||||
{
|
||||
{
|
||||
ERR("Can't load symbols from libdrm_slp.so.1");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SYM(dri_lib, DRI2GetBuffers);
|
||||
SYM(dri_lib, DRI2QueryExtension);
|
||||
|
@ -165,34 +162,34 @@ _drm_init(Display *disp, int scr)
|
|||
SYM(xfixes_lib, XFixesCreateRegion);
|
||||
SYM(xfixes_lib, XFixesDestroyRegion);
|
||||
if (!sym_XFixesQueryExtension(disp, &xfixes_ev_base, &xfixes_err_base))
|
||||
{
|
||||
{
|
||||
if (exim_debug) ERR("XFixes extension not in xserver");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
sym_XFixesQueryVersion(disp, &xfixes_major, &xfixes_minor);
|
||||
|
||||
|
||||
if (!sym_DRI2QueryExtension(disp, &dri2_ev_base, &dri2_err_base))
|
||||
{
|
||||
{
|
||||
if (exim_debug) ERR("DRI2 extension not in xserver");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!sym_DRI2QueryVersion(disp, &dri2_major, &dri2_minor))
|
||||
{
|
||||
{
|
||||
if (exim_debug) ERR("DRI2 query version failed");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (dri2_minor < 99)
|
||||
{
|
||||
if (exim_debug) ERR("Not supported by DRI2 version(%i.%i)",
|
||||
dri2_major, dri2_minor);
|
||||
{
|
||||
if (exim_debug)
|
||||
ERR("Not supported by DRI2 version(%i.%i)",
|
||||
dri2_major, dri2_minor);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!sym_DRI2Connect(disp, RootWindow(disp, scr), &drv_name, &dev_name))
|
||||
{
|
||||
{
|
||||
if (exim_debug) ERR("DRI2 connect failed on screen %i", scr);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!dev_name)
|
||||
{
|
||||
if (exim_debug) ERR("DRI2 connect - cannot find dev name");
|
||||
|
@ -200,73 +197,73 @@ _drm_init(Display *disp, int scr)
|
|||
}
|
||||
drm_fd = open(dev_name, O_RDWR);
|
||||
if (drm_fd < 0)
|
||||
{
|
||||
{
|
||||
if (exim_debug) ERR("DRM FD open of '%s' failed", dev_name);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (sym_drmGetMagic(drm_fd, &magic))
|
||||
{
|
||||
{
|
||||
if (exim_debug) ERR("DRM get magic failed");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!sym_DRI2Authenticate(disp, RootWindow(disp, scr),
|
||||
(unsigned int)magic))
|
||||
{
|
||||
(unsigned int)magic))
|
||||
{
|
||||
if (exim_debug) ERR("DRI2 authenticate failed with magic 0x%x on screen %i", (unsigned int)magic, scr);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!slp_mode)
|
||||
bufmgr = sym_tbm_bufmgr_init(drm_fd);
|
||||
bufmgr = sym_tbm_bufmgr_init(drm_fd);
|
||||
else
|
||||
bufmgr = sym_drm_slp_bufmgr_init(drm_fd, NULL);
|
||||
bufmgr = sym_drm_slp_bufmgr_init(drm_fd, NULL);
|
||||
if (!bufmgr)
|
||||
{
|
||||
{
|
||||
if (exim_debug) ERR("DRM bufmgr init failed");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (drv_name)
|
||||
{
|
||||
{
|
||||
XFree(drv_name);
|
||||
}
|
||||
}
|
||||
if (dev_name)
|
||||
{
|
||||
{
|
||||
XFree(dev_name);
|
||||
}
|
||||
}
|
||||
return EINA_TRUE;
|
||||
err:
|
||||
err:
|
||||
if (drm_fd >= 0)
|
||||
{
|
||||
{
|
||||
close(drm_fd);
|
||||
drm_fd = -1;
|
||||
}
|
||||
}
|
||||
if (drm_lib)
|
||||
{
|
||||
{
|
||||
dlclose(drm_lib);
|
||||
drm_lib = NULL;
|
||||
}
|
||||
}
|
||||
if (lib_tbm)
|
||||
{
|
||||
{
|
||||
dlclose(lib_tbm);
|
||||
lib_tbm = NULL;
|
||||
}
|
||||
}
|
||||
if (dri_lib)
|
||||
{
|
||||
{
|
||||
dlclose(dri_lib);
|
||||
dri_lib = NULL;
|
||||
}
|
||||
}
|
||||
if (xfixes_lib)
|
||||
{
|
||||
{
|
||||
dlclose(xfixes_lib);
|
||||
xfixes_lib = NULL;
|
||||
}
|
||||
}
|
||||
if (drv_name)
|
||||
{
|
||||
{
|
||||
XFree(drv_name);
|
||||
}
|
||||
}
|
||||
if (dev_name)
|
||||
{
|
||||
{
|
||||
XFree(dev_name);
|
||||
}
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
@ -274,10 +271,10 @@ static void
|
|||
_drm_shutdown(void)
|
||||
{
|
||||
if (bufmgr)
|
||||
{
|
||||
{
|
||||
sym_tbm_bufmgr_deinit(bufmgr);
|
||||
bufmgr = NULL;
|
||||
}
|
||||
}
|
||||
if (drm_fd >= 0) close(drm_fd);
|
||||
tried = EINA_FALSE;
|
||||
drm_fd = -1;
|
||||
|
@ -308,30 +305,30 @@ evas_xlib_image_dri_init(Evas_DRI_Image *exim,
|
|||
{
|
||||
exim->dis = display;
|
||||
if (inits <= 0)
|
||||
{
|
||||
if(!_drm_init(display, 0)) return EINA_FALSE;
|
||||
}
|
||||
{
|
||||
if (!_drm_init(display, 0)) return EINA_FALSE;
|
||||
}
|
||||
inits++;
|
||||
|
||||
if(!_drm_setup(display, exim))
|
||||
{
|
||||
if (!_drm_setup(display, exim))
|
||||
{
|
||||
inits--;
|
||||
if (inits == 0) _drm_shutdown();
|
||||
free(exim);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(getenv("EVAS_NO_DRI2_CACHE"))
|
||||
{
|
||||
if (getenv("EVAS_NO_DRI2_CACHE"))
|
||||
{
|
||||
use_cache = EINA_FALSE;
|
||||
}
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
evas_xlib_image_dri_used()
|
||||
{
|
||||
if(inits > 0) return EINA_TRUE;
|
||||
if (inits > 0) return EINA_TRUE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
@ -339,9 +336,9 @@ void
|
|||
evas_xlib_image_buffer_unmap(Evas_DRI_Image *exim)
|
||||
{
|
||||
if (!slp_mode)
|
||||
sym_tbm_bo_unmap(exim->buf_bo);
|
||||
sym_tbm_bo_unmap(exim->buf_bo);
|
||||
else
|
||||
sym_drm_slp_bo_unmap(exim->buf_bo, TBM_DEVICE_CPU);
|
||||
sym_drm_slp_bo_unmap(exim->buf_bo, TBM_DEVICE_CPU);
|
||||
if (exim_debug) DBG("Unmap buffer name %i\n", exim->buf->name);
|
||||
free(exim->buf);
|
||||
exim->buf = NULL;
|
||||
|
@ -355,33 +352,33 @@ _evas_xlib_image_cache_import(Evas_DRI_Image *exim)
|
|||
exim->buf_bo = NULL;
|
||||
flags = (DRI2BufferFlags *)(&(exim->buf->flags));
|
||||
if (!flags->data.is_reused)
|
||||
{
|
||||
{
|
||||
if (exim_debug) DBG("Buffer cache not reused - clear cache\n");
|
||||
if (exim->buf_cache)
|
||||
{
|
||||
{
|
||||
sym_tbm_bo_unref(exim->buf_cache->buf_bo);
|
||||
free(exim->buf_cache);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if (exim->buf_cache && exim->buf_cache->name == exim->buf->name)
|
||||
{
|
||||
{
|
||||
if (exim_debug) DBG("Cached buf name %i found\n", exim->buf_cache->name);
|
||||
exim->buf_bo = exim->buf_cache->buf_bo;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if (exim->buf_cache)
|
||||
{
|
||||
{
|
||||
sym_tbm_bo_unref(exim->buf_cache->buf_bo);
|
||||
free(exim->buf_cache);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!exim->buf_bo)
|
||||
{
|
||||
{
|
||||
exim->buf_bo = sym_tbm_bo_import(bufmgr, exim->buf->name);
|
||||
if (!exim->buf_bo) return EINA_FALSE;
|
||||
// cache the buf entry
|
||||
|
@ -390,7 +387,7 @@ _evas_xlib_image_cache_import(Evas_DRI_Image *exim)
|
|||
exim->buf_cache->name = exim->buf->name;
|
||||
exim->buf_cache->buf_bo = exim->buf_bo;
|
||||
if (exim_debug) DBG("Buffer cache added name %i\n", exim->buf_cache->name);
|
||||
}
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
@ -419,13 +416,13 @@ evas_xlib_image_get_buffers(RGBA_Image *im)
|
|||
Evas_DRI_Image *exim;
|
||||
|
||||
if (im->native.data)
|
||||
n = im->native.data;
|
||||
n = im->native.data;
|
||||
if (!n) return EINA_FALSE;
|
||||
|
||||
exim = n->ns_data.x11.exim;
|
||||
d = n->ns_data.x11.display;
|
||||
|
||||
if(!exim) return EINA_FALSE;
|
||||
if (!exim) return EINA_FALSE;
|
||||
|
||||
unsigned int attach = DRI2BufferFrontLeft;
|
||||
int num;
|
||||
|
@ -440,58 +437,57 @@ evas_xlib_image_get_buffers(RGBA_Image *im)
|
|||
if (!exim->buf->name) return _evas_xlib_image_x_free(d);
|
||||
|
||||
if (use_cache)
|
||||
{
|
||||
{
|
||||
if (!_evas_xlib_image_cache_import(exim)) return _evas_xlib_image_x_free(d);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if (!_evas_xlib_image_no_cache_import(exim)) return _evas_xlib_image_x_free(d);
|
||||
}
|
||||
}
|
||||
|
||||
if (!slp_mode)
|
||||
{
|
||||
bo_handle = sym_tbm_bo_map(exim->buf_bo, TBM_DEVICE_CPU, TBM_OPTION_READ |TBM_OPTION_WRITE);
|
||||
{
|
||||
bo_handle = sym_tbm_bo_map(exim->buf_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
|
||||
if (bo_handle.ptr == NULL) return _evas_xlib_image_x_free(d);
|
||||
exim->buf_data = bo_handle.ptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
exim->buf_data = sym_drm_slp_bo_map(exim->buf_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
|
||||
}
|
||||
}
|
||||
if (!exim->buf_data)
|
||||
{
|
||||
{
|
||||
ERR("Buffer map name %i failed", exim->buf->name);
|
||||
return _evas_xlib_image_x_free(d);
|
||||
}
|
||||
}
|
||||
|
||||
XUngrabServer(d);
|
||||
XSync(d, 0);
|
||||
|
||||
im->image.data = exim->buf_data;
|
||||
im->cache_entry.w = exim->buf->pitch/4;
|
||||
im->cache_entry.w = exim->buf->pitch / 4;
|
||||
|
||||
evas_xlib_image_buffer_unmap(exim);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
evas_xlib_image_dri_free(Evas_DRI_Image *exim)
|
||||
{
|
||||
if(use_cache)
|
||||
{
|
||||
if (use_cache)
|
||||
{
|
||||
if (exim->buf_cache)
|
||||
{
|
||||
{
|
||||
if (exim_debug) DBG("Cached buf name %i freed\n", exim->buf_cache->name);
|
||||
sym_tbm_bo_unref(exim->buf_cache->buf_bo);
|
||||
free(exim->buf_cache);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(exim->buf_bo) sym_tbm_bo_unref(exim->buf_bo);
|
||||
}
|
||||
{
|
||||
if (exim->buf_bo) sym_tbm_bo_unref(exim->buf_bo);
|
||||
}
|
||||
|
||||
_drm_cleanup(exim);
|
||||
free(exim);
|
||||
|
@ -506,7 +502,7 @@ evas_xlib_image_dri_new(int w, int h, Visual *vis, int depth)
|
|||
|
||||
exim = calloc(1, sizeof(Evas_DRI_Image));
|
||||
if (!exim)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
exim->w = w;
|
||||
exim->h = h;
|
||||
|
@ -522,12 +518,12 @@ _native_bind_cb(void *image, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UN
|
|||
Native *n = im->native.data;
|
||||
|
||||
if ((n) && (n->ns.type == EVAS_NATIVE_SURFACE_X11))
|
||||
{
|
||||
{
|
||||
if (evas_xlib_image_get_buffers(im))
|
||||
{
|
||||
{
|
||||
evas_common_image_colorspace_dirty(im);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -537,17 +533,17 @@ _native_free_cb(void *image)
|
|||
Native *n = im->native.data;
|
||||
if (!n) return;
|
||||
if (n->ns_data.x11.exim)
|
||||
{
|
||||
{
|
||||
evas_xlib_image_dri_free(n->ns_data.x11.exim);
|
||||
n->ns_data.x11.exim = NULL;
|
||||
}
|
||||
}
|
||||
n->ns_data.x11.visual = NULL;
|
||||
n->ns_data.x11.display = NULL;
|
||||
|
||||
im->native.data = NULL;
|
||||
im->native.func.bind = NULL;
|
||||
im->native.func.free = NULL;
|
||||
im->image.data = NULL;
|
||||
im->native.data = NULL;
|
||||
im->native.func.bind = NULL;
|
||||
im->native.func.free = NULL;
|
||||
im->image.data = NULL;
|
||||
free(n);
|
||||
}
|
||||
|
||||
|
@ -555,9 +551,9 @@ void *
|
|||
evas_xlib_image_dri_native_set(void *data, void *image, void *native)
|
||||
{
|
||||
Display *d = NULL;
|
||||
Visual *vis = NULL;
|
||||
Pixmap pm = 0;
|
||||
Native *n = NULL;
|
||||
Visual *vis = NULL;
|
||||
Pixmap pm = 0;
|
||||
Native *n = NULL;
|
||||
RGBA_Image *im = image;
|
||||
int w, h;
|
||||
Evas_DRI_Image *exim;
|
||||
|
|
|
@ -57,11 +57,11 @@ _native_free_cb(void *image)
|
|||
}
|
||||
n->ns_data.x11.visual = NULL;
|
||||
|
||||
im->native.data = NULL;
|
||||
im->native.func.bind = NULL;
|
||||
im->native.data = NULL;
|
||||
im->native.func.bind = NULL;
|
||||
im->native.func.unbind = NULL;
|
||||
im->native.func.free = NULL;
|
||||
im->image.data = NULL;
|
||||
im->native.func.free = NULL;
|
||||
im->image.data = NULL;
|
||||
free(n);
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,10 @@ evas_xlib_image_native_set(void *data EINA_UNUSED, void *image, void *native)
|
|||
{
|
||||
RGBA_Image *im = image;
|
||||
Evas_Native_Surface *ns = native;
|
||||
Native *n = NULL;
|
||||
Native *n = NULL;
|
||||
Ecore_X_Image *exim = NULL;
|
||||
Visual *vis = NULL;
|
||||
Pixmap pm = 0;
|
||||
Visual *vis = NULL;
|
||||
Pixmap pm = 0;
|
||||
int w, h, depth;
|
||||
|
||||
if ((ns) && (ns->type == EVAS_NATIVE_SURFACE_X11))
|
||||
|
@ -109,3 +109,4 @@ evas_xlib_image_native_set(void *data EINA_UNUSED, void *image, void *native)
|
|||
}
|
||||
return im;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,3 +5,4 @@ void
|
|||
evas_software_xlib_x_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -15,15 +15,15 @@
|
|||
#include "evas_xlib_color.h"
|
||||
#include "evas_xlib_swapper.h"
|
||||
|
||||
typedef struct _Outbuf_Region Outbuf_Region;
|
||||
typedef struct _Outbuf_Region Outbuf_Region;
|
||||
|
||||
struct _Outbuf_Region
|
||||
{
|
||||
RGBA_Image *im;
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
RGBA_Image *im;
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -38,8 +38,8 @@ evas_software_xlib_swapbuf_free(Outbuf *buf)
|
|||
evas_software_xlib_swapbuf_idle_flush(buf);
|
||||
if (buf->priv.pal)
|
||||
evas_software_xlib_x_color_deallocate
|
||||
(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.cmap,
|
||||
buf->priv.x11.xlib.vis, buf->priv.pal);
|
||||
(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.cmap,
|
||||
buf->priv.x11.xlib.vis, buf->priv.pal);
|
||||
evas_xlib_swapper_free(buf->priv.swapper);
|
||||
eina_array_flush(&buf->priv.onebuf_regions);
|
||||
free(buf);
|
||||
|
@ -47,21 +47,21 @@ evas_software_xlib_swapbuf_free(Outbuf *buf)
|
|||
|
||||
Outbuf *
|
||||
evas_software_xlib_swapbuf_setup_x(int w, int h, int rot, Outbuf_Depth depth,
|
||||
Display *disp, Drawable draw, Visual *vis,
|
||||
Colormap cmap, int x_depth,
|
||||
int grayscale, int max_colors,
|
||||
Pixmap mask EINA_UNUSED,
|
||||
int shape_dither, int destination_alpha)
|
||||
Display *disp, Drawable draw, Visual *vis,
|
||||
Colormap cmap, int x_depth,
|
||||
int grayscale, int max_colors,
|
||||
Pixmap mask EINA_UNUSED,
|
||||
int shape_dither, int destination_alpha)
|
||||
{
|
||||
Outbuf *buf;
|
||||
Gfx_Func_Convert conv_func = NULL;
|
||||
int d;
|
||||
|
||||
Outbuf *buf;
|
||||
Gfx_Func_Convert conv_func = NULL;
|
||||
int d;
|
||||
|
||||
buf = calloc(1, sizeof(Outbuf));
|
||||
if (!buf) return NULL;
|
||||
|
||||
if (x_depth < 15) rot = 0;
|
||||
|
||||
|
||||
buf->onebuf = 1;
|
||||
buf->w = w;
|
||||
buf->h = h;
|
||||
|
@ -92,9 +92,9 @@ evas_software_xlib_swapbuf_setup_x(int w, int h, int rot, Outbuf_Depth depth,
|
|||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
eina_array_step_set(&buf->priv.onebuf_regions, sizeof (Eina_Array), 8);
|
||||
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (evas_xlib_swapper_byte_order_get(buf->priv.swapper) == LSBFirst)
|
||||
buf->priv.x11.xlib.swap = 1;
|
||||
|
@ -109,9 +109,9 @@ evas_software_xlib_swapbuf_setup_x(int w, int h, int rot, Outbuf_Depth depth,
|
|||
if (((vis->class == TrueColor) || (vis->class == DirectColor)) &&
|
||||
(x_depth > 8))
|
||||
{
|
||||
buf->priv.mask.r = (DATA32) vis->red_mask;
|
||||
buf->priv.mask.g = (DATA32) vis->green_mask;
|
||||
buf->priv.mask.b = (DATA32) vis->blue_mask;
|
||||
buf->priv.mask.r = (DATA32)vis->red_mask;
|
||||
buf->priv.mask.g = (DATA32)vis->green_mask;
|
||||
buf->priv.mask.b = (DATA32)vis->blue_mask;
|
||||
if (buf->priv.x11.xlib.swap)
|
||||
{
|
||||
SWAP32(buf->priv.mask.r);
|
||||
|
@ -124,32 +124,42 @@ evas_software_xlib_swapbuf_setup_x(int w, int h, int rot, Outbuf_Depth depth,
|
|||
(x_depth <= 8))
|
||||
{
|
||||
Convert_Pal_Mode pm = PAL_MODE_RGB332;
|
||||
|
||||
|
||||
if ((vis->class == GrayScale) || (vis->class == StaticGray))
|
||||
grayscale = 1;
|
||||
if (grayscale)
|
||||
{
|
||||
if (max_colors >= 256) pm = PAL_MODE_GRAY256;
|
||||
else if (max_colors >= 64) pm = PAL_MODE_GRAY64;
|
||||
else if (max_colors >= 16) pm = PAL_MODE_GRAY16;
|
||||
else if (max_colors >= 4) pm = PAL_MODE_GRAY4;
|
||||
else if (max_colors >= 64)
|
||||
pm = PAL_MODE_GRAY64;
|
||||
else if (max_colors >= 16)
|
||||
pm = PAL_MODE_GRAY16;
|
||||
else if (max_colors >= 4)
|
||||
pm = PAL_MODE_GRAY4;
|
||||
else pm = PAL_MODE_MONO;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (max_colors >= 256) pm = PAL_MODE_RGB332;
|
||||
else if (max_colors >= 216) pm = PAL_MODE_RGB666;
|
||||
else if (max_colors >= 128) pm = PAL_MODE_RGB232;
|
||||
else if (max_colors >= 64) pm = PAL_MODE_RGB222;
|
||||
else if (max_colors >= 32) pm = PAL_MODE_RGB221;
|
||||
else if (max_colors >= 16) pm = PAL_MODE_RGB121;
|
||||
else if (max_colors >= 8) pm = PAL_MODE_RGB111;
|
||||
else if (max_colors >= 4) pm = PAL_MODE_GRAY4;
|
||||
else if (max_colors >= 216)
|
||||
pm = PAL_MODE_RGB666;
|
||||
else if (max_colors >= 128)
|
||||
pm = PAL_MODE_RGB232;
|
||||
else if (max_colors >= 64)
|
||||
pm = PAL_MODE_RGB222;
|
||||
else if (max_colors >= 32)
|
||||
pm = PAL_MODE_RGB221;
|
||||
else if (max_colors >= 16)
|
||||
pm = PAL_MODE_RGB121;
|
||||
else if (max_colors >= 8)
|
||||
pm = PAL_MODE_RGB111;
|
||||
else if (max_colors >= 4)
|
||||
pm = PAL_MODE_GRAY4;
|
||||
else pm = PAL_MODE_MONO;
|
||||
}
|
||||
/* FIXME: only alloc once per display+cmap */
|
||||
buf->priv.pal = evas_software_xlib_x_color_allocate
|
||||
(disp, cmap, vis, pm);
|
||||
(disp, cmap, vis, pm);
|
||||
if (!buf->priv.pal)
|
||||
{
|
||||
evas_xlib_swapper_free(buf->priv.swapper);
|
||||
|
@ -160,7 +170,6 @@ evas_software_xlib_swapbuf_setup_x(int w, int h, int rot, Outbuf_Depth depth,
|
|||
d = evas_xlib_swapper_depth_get(buf->priv.swapper);
|
||||
if (buf->priv.pal)
|
||||
{
|
||||
|
||||
if (buf->rot == 0 || buf->rot == 180)
|
||||
conv_func = evas_common_convert_func_get(0, buf->w, buf->h, d,
|
||||
buf->priv.mask.r,
|
||||
|
@ -232,21 +241,21 @@ evas_software_xlib_swapbuf_new_region_for_update(Outbuf *buf, int x, int y, int
|
|||
d = evas_xlib_swapper_depth_get(buf->priv.swapper);
|
||||
bpp = d / 8;
|
||||
|
||||
data = evas_xlib_swapper_buffer_map(buf->priv.swapper, &bpl,
|
||||
data = evas_xlib_swapper_buffer_map(buf->priv.swapper, &bpl,
|
||||
&(ww), &(hh));
|
||||
// To take stride into account, we do use bpl as the real image width, but return the real useful one.
|
||||
// To take stride into account, we do use bpl as the real image width, but return the real useful one.
|
||||
#ifdef EVAS_CSERVE2
|
||||
if (evas_cserve2_use_get())
|
||||
im = (RGBA_Image *)evas_cache2_image_data(evas_common_image_cache2_get(),
|
||||
bpl/bpp, hh, data,
|
||||
bpl / bpp, hh, data,
|
||||
buf->priv.destination_alpha,
|
||||
EVAS_COLORSPACE_ARGB8888);
|
||||
else
|
||||
#endif
|
||||
im = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
|
||||
bpl/bpp, hh, data,
|
||||
buf->priv.destination_alpha,
|
||||
EVAS_COLORSPACE_ARGB8888);
|
||||
im = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
|
||||
bpl / bpp, hh, data,
|
||||
buf->priv.destination_alpha,
|
||||
EVAS_COLORSPACE_ARGB8888);
|
||||
buf->priv.onebuf = im;
|
||||
if (!im) return NULL;
|
||||
}
|
||||
|
@ -258,11 +267,11 @@ evas_software_xlib_swapbuf_new_region_for_update(Outbuf *buf, int x, int y, int
|
|||
evas_cache2_image_close(&im->cache_entry);
|
||||
else
|
||||
#endif
|
||||
evas_cache_image_drop(&im->cache_entry);
|
||||
evas_cache_image_drop(&im->cache_entry);
|
||||
eina_rectangle_free(rect);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// the clip region of the onebuf to render
|
||||
*cx = x;
|
||||
*cy = y;
|
||||
|
@ -272,9 +281,9 @@ evas_software_xlib_swapbuf_new_region_for_update(Outbuf *buf, int x, int y, int
|
|||
}
|
||||
else
|
||||
{
|
||||
RGBA_Image *im;
|
||||
RGBA_Image *im;
|
||||
Eina_Rectangle *rect;
|
||||
|
||||
|
||||
rect = eina_rectangle_new(x, y, w, h);
|
||||
if (!rect) return NULL;
|
||||
#ifdef EVAS_CSERVE2
|
||||
|
@ -282,7 +291,7 @@ evas_software_xlib_swapbuf_new_region_for_update(Outbuf *buf, int x, int y, int
|
|||
im = (RGBA_Image *)evas_cache2_image_empty(evas_common_image_cache2_get());
|
||||
else
|
||||
#endif
|
||||
im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
|
||||
im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
|
||||
if (!im)
|
||||
{
|
||||
eina_rectangle_free(rect);
|
||||
|
@ -294,10 +303,10 @@ evas_software_xlib_swapbuf_new_region_for_update(Outbuf *buf, int x, int y, int
|
|||
evas_cache2_image_surface_alloc(&im->cache_entry, w, h);
|
||||
else
|
||||
#endif
|
||||
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
|
||||
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
|
||||
im->extended_info = rect;
|
||||
buf->priv.pending_writes = eina_list_append(buf->priv.pending_writes, im);
|
||||
|
||||
|
||||
// the region is the update image
|
||||
*cx = 0;
|
||||
*cy = 0;
|
||||
|
@ -330,10 +339,10 @@ evas_software_xlib_swapbuf_flush(Outbuf *buf, Tilebuf_Rect *surface_damage EINA_
|
|||
if (n == 0) return;
|
||||
result = alloca(n * sizeof(Eina_Rectangle));
|
||||
EINA_ARRAY_ITER_NEXT(&buf->priv.onebuf_regions, i, rect, it)
|
||||
{
|
||||
result[i] = *rect;
|
||||
eina_rectangle_free(rect);
|
||||
}
|
||||
{
|
||||
result[i] = *rect;
|
||||
eina_rectangle_free(rect);
|
||||
}
|
||||
evas_xlib_swapper_buffer_unmap(buf->priv.swapper);
|
||||
evas_xlib_swapper_swap(buf->priv.swapper, result, n);
|
||||
eina_array_clean(&buf->priv.onebuf_regions);
|
||||
|
@ -346,7 +355,7 @@ evas_software_xlib_swapbuf_flush(Outbuf *buf, Tilebuf_Rect *surface_damage EINA_
|
|||
evas_cache2_image_close(&im->cache_entry);
|
||||
else
|
||||
#endif
|
||||
evas_cache_image_drop(&im->cache_entry);
|
||||
evas_cache_image_drop(&im->cache_entry);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -354,7 +363,7 @@ evas_software_xlib_swapbuf_flush(Outbuf *buf, Tilebuf_Rect *surface_damage EINA_
|
|||
RGBA_Image *im;
|
||||
Eina_Rectangle *result;
|
||||
unsigned int n, i = 0;
|
||||
|
||||
|
||||
n = eina_list_count(buf->priv.pending_writes);
|
||||
if (n == 0) return;
|
||||
result = alloca(n * sizeof(Eina_Rectangle));
|
||||
|
@ -362,7 +371,7 @@ evas_software_xlib_swapbuf_flush(Outbuf *buf, Tilebuf_Rect *surface_damage EINA_
|
|||
{
|
||||
Eina_Rectangle *rect = im->extended_info;
|
||||
int x, y, w, h;
|
||||
|
||||
|
||||
x = rect->x; y = rect->y; w = rect->w; h = rect->h;
|
||||
if (buf->rot == 0)
|
||||
{
|
||||
|
@ -400,7 +409,7 @@ evas_software_xlib_swapbuf_flush(Outbuf *buf, Tilebuf_Rect *surface_damage EINA_
|
|||
evas_cache2_image_close(&im->cache_entry);
|
||||
else
|
||||
#endif
|
||||
evas_cache_image_drop(&im->cache_entry);
|
||||
evas_cache_image_drop(&im->cache_entry);
|
||||
i++;
|
||||
}
|
||||
evas_xlib_swapper_buffer_unmap(buf->priv.swapper);
|
||||
|
@ -430,36 +439,36 @@ evas_software_xlib_swapbuf_push_updated_region(Outbuf *buf, RGBA_Image *update,
|
|||
if (bpp <= 0) return;
|
||||
if (buf->priv.pal)
|
||||
{
|
||||
if ((buf->rot == 0) || (buf->rot == 180))
|
||||
conv_func = evas_common_convert_func_get(0, w, h, d,
|
||||
if ((buf->rot == 0) || (buf->rot == 180))
|
||||
conv_func = evas_common_convert_func_get(0, w, h, d,
|
||||
buf->priv.mask.r,
|
||||
buf->priv.mask.g,
|
||||
buf->priv.mask.g,
|
||||
buf->priv.mask.b,
|
||||
buf->priv.pal->colors,
|
||||
buf->priv.pal->colors,
|
||||
buf->rot);
|
||||
else if ((buf->rot == 90) || (buf->rot == 270))
|
||||
conv_func = evas_common_convert_func_get(0, h, w, d,
|
||||
buf->priv.mask.r,
|
||||
buf->priv.mask.g,
|
||||
else if ((buf->rot == 90) || (buf->rot == 270))
|
||||
conv_func = evas_common_convert_func_get(0, h, w, d,
|
||||
buf->priv.mask.r,
|
||||
buf->priv.mask.g,
|
||||
buf->priv.mask.b,
|
||||
buf->priv.pal->colors,
|
||||
buf->priv.pal->colors,
|
||||
buf->rot);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((buf->rot == 0) || (buf->rot == 180))
|
||||
conv_func = evas_common_convert_func_get(0, w, h, d,
|
||||
buf->priv.mask.r,
|
||||
buf->priv.mask.g,
|
||||
if ((buf->rot == 0) || (buf->rot == 180))
|
||||
conv_func = evas_common_convert_func_get(0, w, h, d,
|
||||
buf->priv.mask.r,
|
||||
buf->priv.mask.g,
|
||||
buf->priv.mask.b,
|
||||
PAL_MODE_NONE,
|
||||
PAL_MODE_NONE,
|
||||
buf->rot);
|
||||
else if ((buf->rot == 90) || (buf->rot == 270))
|
||||
conv_func = evas_common_convert_func_get(0, h, w, d,
|
||||
buf->priv.mask.r,
|
||||
buf->priv.mask.g,
|
||||
else if ((buf->rot == 90) || (buf->rot == 270))
|
||||
conv_func = evas_common_convert_func_get(0, h, w, d,
|
||||
buf->priv.mask.r,
|
||||
buf->priv.mask.g,
|
||||
buf->priv.mask.b,
|
||||
PAL_MODE_NONE,
|
||||
PAL_MODE_NONE,
|
||||
buf->rot);
|
||||
}
|
||||
if (!conv_func) return;
|
||||
|
@ -497,7 +506,7 @@ evas_software_xlib_swapbuf_push_updated_region(Outbuf *buf, RGBA_Image *update,
|
|||
if (!src_data) return;
|
||||
if ((buf->rot == 0) || (buf->rot == 180))
|
||||
{
|
||||
dst_data = evas_xlib_swapper_buffer_map(buf->priv.swapper, &bpl,
|
||||
dst_data = evas_xlib_swapper_buffer_map(buf->priv.swapper, &bpl,
|
||||
&(ww), &(hh));
|
||||
if (!dst_data) return;
|
||||
if (buf->rot == 0)
|
||||
|
@ -517,7 +526,7 @@ evas_software_xlib_swapbuf_push_updated_region(Outbuf *buf, RGBA_Image *update,
|
|||
}
|
||||
else
|
||||
{
|
||||
dst_data = evas_xlib_swapper_buffer_map(buf->priv.swapper, &bpl,
|
||||
dst_data = evas_xlib_swapper_buffer_map(buf->priv.swapper, &bpl,
|
||||
&(ww), &(hh));
|
||||
if (!dst_data) return;
|
||||
if (buf->rot == 90)
|
||||
|
@ -541,14 +550,14 @@ evas_software_xlib_swapbuf_push_updated_region(Outbuf *buf, RGBA_Image *update,
|
|||
wid = bpl / bpp;
|
||||
dst_data += (bpl * r.y) + (r.x * bpp);
|
||||
if (buf->priv.pal)
|
||||
conv_func(src_data, dst_data,
|
||||
conv_func(src_data, dst_data,
|
||||
update->cache_entry.w - w,
|
||||
wid - r.w,
|
||||
r.w, r.h,
|
||||
x + rx, y + ry,
|
||||
buf->priv.pal->lookup);
|
||||
else
|
||||
conv_func(src_data, dst_data,
|
||||
conv_func(src_data, dst_data,
|
||||
update->cache_entry.w - w,
|
||||
wid - r.w,
|
||||
r.w, r.h,
|
||||
|
@ -582,7 +591,7 @@ evas_software_xlib_swapbuf_reconfigure(Outbuf *buf, int w, int h, int rot,
|
|||
}
|
||||
|
||||
int
|
||||
evas_software_xlib_swapbuf_get_rot(Outbuf * buf)
|
||||
evas_software_xlib_swapbuf_get_rot(Outbuf *buf)
|
||||
{
|
||||
return buf->rot;
|
||||
}
|
||||
|
@ -601,3 +610,4 @@ evas_software_xlib_swapbuf_buffer_state_get(Outbuf *buf)
|
|||
mode = evas_xlib_swapper_buffer_state_get(buf->priv.swapper);
|
||||
return mode;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "evas_xlib_swapper.h"
|
||||
|
||||
#ifdef HAVE_DLSYM
|
||||
# include <dlfcn.h> /* dlopen,dlclose,etc */
|
||||
# include <dlfcn.h> /* dlopen,dlclose,etc */
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# include <fcntl.h>
|
||||
|
@ -16,12 +16,12 @@
|
|||
// X(shm)image emulation of multiple buffers + swapping /////////////////////
|
||||
typedef struct
|
||||
{
|
||||
XImage *xim;
|
||||
XShmSegmentInfo shm_info;
|
||||
void *data;
|
||||
int w, h, bpl;
|
||||
Eina_Bool shm : 1;
|
||||
Eina_Bool valid : 1;
|
||||
XImage *xim;
|
||||
XShmSegmentInfo shm_info;
|
||||
void *data;
|
||||
int w, h, bpl;
|
||||
Eina_Bool shm : 1;
|
||||
Eina_Bool valid : 1;
|
||||
} Buffer;
|
||||
|
||||
struct _X_Swapper
|
||||
|
@ -33,7 +33,7 @@ struct _X_Swapper
|
|||
Buffer buf[3];
|
||||
int w, h, depth;
|
||||
int buf_cur, buf_num;
|
||||
Eina_Bool mapped: 1;
|
||||
Eina_Bool mapped : 1;
|
||||
};
|
||||
|
||||
static Eina_Bool _x_err = EINA_FALSE;
|
||||
|
@ -64,7 +64,7 @@ _buf_new(X_Swapper *swp, Buffer *buf)
|
|||
{
|
||||
buf->shm_info.readOnly = False;
|
||||
buf->shm_info.shmaddr = buf->data = buf->xim->data =
|
||||
shmat(buf->shm_info.shmid, 0, 0);
|
||||
shmat(buf->shm_info.shmid, 0, 0);
|
||||
if (buf->shm_info.shmaddr != ((void *)-1))
|
||||
{
|
||||
XErrorHandler ph;
|
||||
|
@ -146,7 +146,7 @@ _buf_put(X_Swapper *swp, Buffer *buf, Eina_Rectangle *rects, int nrects)
|
|||
|
||||
if (!buf->xim) return;
|
||||
tmpr = XCreateRegion();
|
||||
if ((rects)/* && 0*/) // set to 0 to test buffer stuff
|
||||
if ((rects) /* && 0*/) // set to 0 to test buffer stuff
|
||||
{
|
||||
for (i = 0; i < nrects; i++)
|
||||
{
|
||||
|
@ -273,8 +273,10 @@ evas_xlib_swapper_buffer_state_get(X_Swapper *swp)
|
|||
if (count == swp->buf_num)
|
||||
{
|
||||
if (count == 1) return MODE_COPY;
|
||||
else if (count == 2) return MODE_DOUBLE;
|
||||
else if (count == 3) return MODE_TRIPLE;
|
||||
else if (count == 2)
|
||||
return MODE_DOUBLE;
|
||||
else if (count == 3)
|
||||
return MODE_TRIPLE;
|
||||
}
|
||||
return MODE_FULL;
|
||||
}
|
||||
|
@ -299,7 +301,6 @@ evas_xlib_swapper_bit_order_get(X_Swapper *swp)
|
|||
|
||||
#else
|
||||
|
||||
|
||||
// DRM/DRI buffer swapping+access (driver specific) /////////////////////
|
||||
|
||||
static Eina_Bool tried = EINA_FALSE;
|
||||
|
@ -308,39 +309,38 @@ static Eina_Bool tried = EINA_FALSE;
|
|||
static void *drm_lib = NULL;
|
||||
|
||||
typedef unsigned int drm_magic_t;
|
||||
static int (*sym_drmGetMagic) (int fd, drm_magic_t *magic) = NULL;
|
||||
static int (*sym_drmGetMagic)(int fd, drm_magic_t *magic) = NULL;
|
||||
|
||||
////////////////////////////////////
|
||||
// libtbm.so.1
|
||||
#define TBM_DEVICE_CPU 1
|
||||
#define TBM_OPTION_READ (1 << 0)
|
||||
#define TBM_OPTION_WRITE (1 << 1)
|
||||
#define TBM_DEVICE_CPU 1
|
||||
#define TBM_OPTION_READ (1 << 0)
|
||||
#define TBM_OPTION_WRITE (1 << 1)
|
||||
static void *tbm_lib = NULL;
|
||||
|
||||
typedef struct _tbm_bufmgr *tbm_bufmgr;
|
||||
typedef struct _tbm_bo *tbm_bo;
|
||||
typedef struct _tbm_bo *tbm_bo;
|
||||
|
||||
typedef union _tbm_bo_handle
|
||||
{
|
||||
void *ptr;
|
||||
void *ptr;
|
||||
int32_t s32;
|
||||
uint32_t u32;
|
||||
int64_t s64;
|
||||
uint64_t u64;
|
||||
} tbm_bo_handle;
|
||||
|
||||
|
||||
static tbm_bo (*sym_tbm_bo_import) (tbm_bufmgr bufmgr, unsigned int key) = NULL;
|
||||
static tbm_bo_handle (*sym_tbm_bo_map) (tbm_bo bo, int device, int opt) = NULL;
|
||||
static int (*sym_tbm_bo_unmap) (tbm_bo bo) = NULL;
|
||||
static void (*sym_tbm_bo_unref) (tbm_bo bo) = NULL;
|
||||
static tbm_bufmgr (*sym_tbm_bufmgr_init) (int fd) = NULL;
|
||||
static void (*sym_tbm_bufmgr_deinit) (tbm_bufmgr bufmgr) = NULL;
|
||||
static tbm_bo (*sym_tbm_bo_import)(tbm_bufmgr bufmgr, unsigned int key) = NULL;
|
||||
static tbm_bo_handle (*sym_tbm_bo_map)(tbm_bo bo, int device, int opt) = NULL;
|
||||
static int (*sym_tbm_bo_unmap)(tbm_bo bo) = NULL;
|
||||
static void (*sym_tbm_bo_unref)(tbm_bo bo) = NULL;
|
||||
static tbm_bufmgr (*sym_tbm_bufmgr_init)(int fd) = NULL;
|
||||
static void (*sym_tbm_bufmgr_deinit)(tbm_bufmgr bufmgr) = NULL;
|
||||
|
||||
// legacy compatibility
|
||||
static void *(*sym_drm_slp_bo_map) (tbm_bo bo, int device, int opt) = NULL;
|
||||
static int (*sym_drm_slp_bo_unmap) (tbm_bo bo, int device) = NULL;
|
||||
static tbm_bufmgr (*sym_drm_slp_bufmgr_init) (int fd, void *arg) = NULL;
|
||||
static void *(*sym_drm_slp_bo_map)(tbm_bo bo, int device, int opt) = NULL;
|
||||
static int (*sym_drm_slp_bo_unmap)(tbm_bo bo, int device) = NULL;
|
||||
static tbm_bufmgr (*sym_drm_slp_bufmgr_init)(int fd, void *arg) = NULL;
|
||||
|
||||
////////////////////////////////////
|
||||
// libdri2.so.0
|
||||
|
@ -366,34 +366,34 @@ typedef union
|
|||
{
|
||||
unsigned int flags;
|
||||
struct
|
||||
{
|
||||
unsigned int type:1;
|
||||
unsigned int is_framebuffer:1;
|
||||
unsigned int is_mapped:1;
|
||||
unsigned int is_reused:1;
|
||||
unsigned int idx_reuse:3;
|
||||
}
|
||||
{
|
||||
unsigned int type : 1;
|
||||
unsigned int is_framebuffer : 1;
|
||||
unsigned int is_mapped : 1;
|
||||
unsigned int is_reused : 1;
|
||||
unsigned int idx_reuse : 3;
|
||||
}
|
||||
data;
|
||||
} DRI2BufferFlags;
|
||||
|
||||
static DRI2Buffer *(*sym_DRI2GetBuffers) (Display *display, XID drawable, int *width, int *height, unsigned int *attachments, int count, int *outCount) = NULL;
|
||||
static Bool (*sym_DRI2QueryExtension) (Display *display, int *eventBase, int *errorBase) = NULL;
|
||||
static Bool (*sym_DRI2QueryVersion) (Display *display, int *major, int *minor) = NULL;
|
||||
static Bool (*sym_DRI2Connect) (Display *display, XID window, char **driverName, char **deviceName) = NULL;
|
||||
static Bool (*sym_DRI2Authenticate) (Display *display, XID window, unsigned int magic) = NULL;
|
||||
static void (*sym_DRI2CreateDrawable) (Display *display, XID drawable) = NULL;
|
||||
static void (*sym_DRI2SwapBuffersWithRegion) (Display *display, XID drawable, XID region, CD64 *count) = NULL;
|
||||
static void (*sym_DRI2SwapBuffers) (Display *display, XID drawable, CD64 target_msc, CD64 divisor, CD64 remainder, CD64 *count) = NULL;
|
||||
static void (*sym_DRI2DestroyDrawable) (Display *display, XID handle) = NULL;
|
||||
static DRI2Buffer *(*sym_DRI2GetBuffers)(Display * display, XID drawable, int *width, int *height, unsigned int *attachments, int count, int *outCount) = NULL;
|
||||
static Bool (*sym_DRI2QueryExtension)(Display *display, int *eventBase, int *errorBase) = NULL;
|
||||
static Bool (*sym_DRI2QueryVersion)(Display *display, int *major, int *minor) = NULL;
|
||||
static Bool (*sym_DRI2Connect)(Display *display, XID window, char **driverName, char **deviceName) = NULL;
|
||||
static Bool (*sym_DRI2Authenticate)(Display *display, XID window, unsigned int magic) = NULL;
|
||||
static void (*sym_DRI2CreateDrawable)(Display *display, XID drawable) = NULL;
|
||||
static void (*sym_DRI2SwapBuffersWithRegion)(Display *display, XID drawable, XID region, CD64 *count) = NULL;
|
||||
static void (*sym_DRI2SwapBuffers)(Display *display, XID drawable, CD64 target_msc, CD64 divisor, CD64 remainder, CD64 *count) = NULL;
|
||||
static void (*sym_DRI2DestroyDrawable)(Display *display, XID handle) = NULL;
|
||||
|
||||
////////////////////////////////////
|
||||
// libXfixes.so.3
|
||||
static void *xfixes_lib = NULL;
|
||||
|
||||
static Bool (*sym_XFixesQueryExtension) (Display *display, int *event_base_return, int *error_base_return) = NULL;
|
||||
static Status (*sym_XFixesQueryVersion) (Display *display, int *major_version_return, int *minor_version_return) = NULL;
|
||||
static XID (*sym_XFixesCreateRegion) (Display *display, XRectangle *rectangles, int nrectangles) = NULL;
|
||||
static void (*sym_XFixesDestroyRegion) (Display *dpy, XID region) = NULL;
|
||||
static Bool (*sym_XFixesQueryExtension)(Display *display, int *event_base_return, int *error_base_return) = NULL;
|
||||
static Status (*sym_XFixesQueryVersion)(Display *display, int *major_version_return, int *minor_version_return) = NULL;
|
||||
static XID (*sym_XFixesCreateRegion)(Display *display, XRectangle *rectangles, int nrectangles) = NULL;
|
||||
static void (*sym_XFixesDestroyRegion)(Display *dpy, XID region) = NULL;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
#define MAX_BO_CACHE 4
|
||||
|
@ -416,7 +416,7 @@ struct _X_Swapper
|
|||
int buf_w, buf_h;
|
||||
Eina_List *buf_cache;
|
||||
int last_count;
|
||||
Eina_Bool mapped: 1;
|
||||
Eina_Bool mapped : 1;
|
||||
};
|
||||
|
||||
static int inits = 0;
|
||||
|
@ -472,13 +472,13 @@ _drm_init(Display *disp, int scr)
|
|||
goto err;
|
||||
}
|
||||
|
||||
#define SYM(l, x) \
|
||||
do { sym_ ## x = dlsym(l, #x); \
|
||||
if (!sym_ ## x) { \
|
||||
if (swap_debug) ERR("Can't load symbol "#x); \
|
||||
goto err; \
|
||||
} \
|
||||
} while (0)
|
||||
#define SYM(l, x) \
|
||||
do { sym_ ## x = dlsym(l, #x); \
|
||||
if (!sym_ ## x) { \
|
||||
if (swap_debug) ERR("Can't load symbol " #x); \
|
||||
goto err; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
SYM(drm_lib, drmGetMagic);
|
||||
|
||||
|
@ -543,8 +543,9 @@ _drm_init(Display *disp, int scr)
|
|||
}
|
||||
if (dri2_minor < 99)
|
||||
{
|
||||
if (swap_debug) ERR("Not supported by DRI2 version(%i.%i)",
|
||||
dri2_major, dri2_minor);
|
||||
if (swap_debug)
|
||||
ERR("Not supported by DRI2 version(%i.%i)",
|
||||
dri2_major, dri2_minor);
|
||||
goto err;
|
||||
}
|
||||
if (!sym_DRI2Connect(disp, RootWindow(disp, scr), &drv_name, &dev_name))
|
||||
|
@ -569,7 +570,7 @@ _drm_init(Display *disp, int scr)
|
|||
if (swap_debug) ERR("DRI2 authenticate failed with magic 0x%x on screen %i", (unsigned int)magic, scr);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
if (!slp_mode)
|
||||
bufmgr = sym_tbm_bufmgr_init(drm_fd);
|
||||
else
|
||||
|
@ -680,8 +681,8 @@ evas_xlib_swapper_new(Display *disp, Drawable draw, Visual *vis,
|
|||
free(swp);
|
||||
return NULL;
|
||||
}
|
||||
if (swp->depth == 24)
|
||||
{ // need to adjust to 32bpp?? have to check
|
||||
if (swp->depth == 24) // need to adjust to 32bpp?? have to check
|
||||
{
|
||||
swp->depth = 32;
|
||||
}
|
||||
if (swap_debug) printf("Swapper allocated OK\n");
|
||||
|
@ -868,10 +869,14 @@ evas_xlib_swapper_buffer_state_get(X_Swapper *swp)
|
|||
}
|
||||
if (swap_debug) printf("Swap state idx_reuse = %i (0=FULL, 1=COPY, 2=DOUBLE, 3=TRIPLE, 4=QUAD)\n", flags->data.idx_reuse);
|
||||
if (flags->data.idx_reuse == 0) return MODE_FULL;
|
||||
else if (flags->data.idx_reuse == 1) return MODE_COPY;
|
||||
else if (flags->data.idx_reuse == 2) return MODE_DOUBLE;
|
||||
else if (flags->data.idx_reuse == 3) return MODE_TRIPLE;
|
||||
else if (flags->data.idx_reuse == 4) return MODE_QUADRUPLE;
|
||||
else if (flags->data.idx_reuse == 1)
|
||||
return MODE_COPY;
|
||||
else if (flags->data.idx_reuse == 2)
|
||||
return MODE_DOUBLE;
|
||||
else if (flags->data.idx_reuse == 3)
|
||||
return MODE_TRIPLE;
|
||||
else if (flags->data.idx_reuse == 4)
|
||||
return MODE_QUADRUPLE;
|
||||
return MODE_FULL;
|
||||
}
|
||||
|
||||
|
@ -897,43 +902,6 @@ evas_xlib_swapper_bit_order_get(X_Swapper *swp EINA_UNUSED)
|
|||
|
||||
#else
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
X_Swapper *
|
||||
evas_xlib_swapper_new(Display *disp EINA_UNUSED, Drawable draw EINA_UNUSED,
|
||||
Visual *vis EINA_UNUSED, int depth EINA_UNUSED,
|
||||
|
@ -986,4 +954,5 @@ evas_xlib_swapper_bit_order_get(X_Swapper *swp EINA_UNUSED)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue