dont need xcb engine code anymore

SVN revision: 38176
This commit is contained in:
Carsten Haitzler 2008-12-17 08:18:13 +00:00
parent 6fc7c79741
commit 53c9394d3b
9 changed files with 0 additions and 2466 deletions

View File

@ -1,6 +0,0 @@
.deps
.libs
Makefile
Makefile.in
*.lo
*.la

View File

@ -1,43 +0,0 @@
#ifndef _EVAS_ENGINE_SOFTWARE_XCB_H
#define _EVAS_ENGINE_SOFTWARE_XCB_H
#include <xcb/xcb.h>
typedef struct _Evas_Engine_Info_Software_Xcb Evas_Engine_Info_Software_Xcb;
struct _Evas_Engine_Info_Software_Xcb
{
/* PRIVATE - don't mess with this baby or evas will poke its tongue out */
/* at you and make nasty noises */
Evas_Engine_Info magic;
/* engine specific data & parameters it needs to set up */
struct {
xcb_connection_t *conn;
xcb_screen_t *screen;
xcb_drawable_t drawable;
xcb_drawable_t mask;
xcb_visualtype_t *visual;
xcb_colormap_t colormap;
int depth;
int rotation;
int alloc_grayscale : 1;
int debug : 1;
int shape_dither : 1;
int destination_alpha : 1;
int track_mask_changes : 1;
int alloc_colors_max;
} info;
/* engine specific function calls to query stuff about the destination */
struct {
xcb_visualtype_t * (*best_visual_get) (xcb_screen_t *screen);
xcb_colormap_t (*best_colormap_get) (xcb_screen_t *screen);
int (*best_depth_get) (xcb_screen_t *screen);
} func;
int mask_changed;
};
#endif /* _EVAS_ENGINE_SOFTWARE_XCB_H */

View File

@ -1,34 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = \
-I. \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/lib/include \
-I$(top_srcdir)/src/modules/engines \
@FREETYPE_CFLAGS@ \
@EINA_CFLAGS@ \
@evas_engine_software_xcb_cflags@
if BUILD_ENGINE_SOFTWARE_XCB
pkgdir = $(libdir)/evas/modules/engines/software_xcb/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = \
evas_engine.c \
evas_outbuf.c \
evas_xcb_buffer.c \
evas_xcb_color.c \
evas_xcb_main.c
module_la_LIBADD = @EINA_LIBS@ @evas_engine_software_xcb_libs@ $(top_builddir)/src/lib/libevas.la
module_la_LDFLAGS = -module -avoid-version
module_la_LIBTOOLFLAGS = --tag=disable-static
include_HEADERS = Evas_Engine_Software_Xcb.h
endif
EXTRA_DIST = evas_engine.h

View File

@ -1,428 +0,0 @@
#include <xcb/xcb.h>
#include "evas_common.h"
#include "evas_private.h"
#include "evas_engine.h"
#include "Evas_Engine_Software_Xcb.h"
/* function tables - filled in later (func and parent func) */
static Evas_Func func, pfunc;
/* engine struct data */
typedef struct _Render_Engine Render_Engine;
struct _Render_Engine
{
Tilebuf *tb;
Outbuf *ob;
Tilebuf_Rect *rects;
Eina_Inlist *cur_rect;
int end : 1;
};
/* prototypes we will use here */
static void *_output_setup(int w, int h, int rot, xcb_connection_t *conn, xcb_screen_t *screen, xcb_drawable_t draw, xcb_visualtype_t *vis, xcb_colormap_t cmap, int depth, int debug, int grayscale, int max_colors, xcb_drawable_t mask, int shape_dither, int destination_alpha);
static xcb_visualtype_t *_best_visual_get(xcb_screen_t *screen);
static xcb_colormap_t _best_colormap_get(xcb_screen_t *screen);
static int _best_depth_get(xcb_screen_t *screen);
static void *eng_info(Evas *e);
static void eng_info_free(Evas *e, void *info);
static void eng_setup(Evas *e, void *info);
static void eng_output_free(void *data);
static void eng_output_resize(void *data, int w, int h);
static void eng_output_tile_size_set(void *data, int w, int h);
static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
static void eng_output_redraws_clear(void *data);
static void *eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch);
static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h);
static void eng_output_flush(void *data);
static void eng_output_idle_flush(void *data);
static void *
_output_setup(int w,
int h,
int rot,
xcb_connection_t *conn,
xcb_screen_t *screen,
xcb_drawable_t draw,
xcb_visualtype_t *vis,
xcb_colormap_t cmap,
int depth,
int debug,
int grayscale,
int max_colors,
xcb_drawable_t mask,
int shape_dither,
int destination_alpha)
{
Render_Engine *re;
re = calloc(1, sizeof(Render_Engine));
/* if we haven't initialized - init (automatic abort if already done) */
evas_common_cpu_init();
evas_common_blend_init();
evas_common_image_init();
evas_common_convert_init();
evas_common_scale_init();
evas_common_rectangle_init();
evas_common_gradient_init();
evas_common_polygon_init();
evas_common_line_init();
evas_common_font_init();
evas_common_draw_init();
evas_common_tilebuf_init();
evas_software_xcb_x_init();
evas_software_xcb_x_color_init();
evas_software_xcb_outbuf_init();
re->ob = evas_software_xcb_outbuf_setup_x(w, h, rot,
OUTBUF_DEPTH_INHERIT,
conn,
screen,
draw,
vis,
cmap,
depth,
grayscale,
max_colors,
mask,
shape_dither,
destination_alpha);
if (!re->ob)
{
free(re);
return NULL;
}
/* for updates return 1 big buffer, but only use portions of it, also cache
it and keepit around until an idle_flush */
/* disable for now - i am hunting down why some expedite tests are slower,
* as well as shaped stuff is broken and probable non-32bpp is broken as
* convert funcs dont do the right thing
*
re->ob->onebuf = 1;
*/
evas_software_xcb_outbuf_debug_set(re->ob, debug);
re->tb = evas_common_tilebuf_new(w, h);
if (!re->tb)
{
evas_software_xcb_outbuf_free(re->ob);
free(re);
return NULL;
}
/* in preliminary tests 16x16 gave highest framerates */
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
return re;
}
static xcb_visualtype_t *
_best_visual_get(xcb_screen_t *screen)
{
xcb_depth_iterator_t iter_depth;
if (!screen) return NULL;
iter_depth = xcb_screen_allowed_depths_iterator(screen);
for (; iter_depth.rem; xcb_depth_next (&iter_depth))
{
xcb_visualtype_iterator_t iter_vis;
iter_vis = xcb_depth_visuals_iterator(iter_depth.data);
for (; iter_vis.rem; xcb_visualtype_next (&iter_vis))
{
if (screen->root_visual == iter_vis.data->visual_id)
return iter_vis.data;
}
}
return NULL;
}
static xcb_colormap_t
_best_colormap_get(xcb_screen_t *screen)
{
if (!screen)
return 0;
return screen->default_colormap;
}
static int
_best_depth_get(xcb_screen_t *screen)
{
if (!screen)
return 0;
return screen->root_depth;
}
/* engine api this module provides */
static void *
eng_info(Evas *e)
{
Evas_Engine_Info_Software_Xcb *info;
info = calloc(1, sizeof(Evas_Engine_Info_Software_Xcb));
if (!info) return NULL;
info->magic.magic = rand();
info->info.debug = 0;
info->info.alloc_grayscale = 0;
info->info.alloc_colors_max = 216;
info->func.best_visual_get = _best_visual_get;
info->func.best_colormap_get = _best_colormap_get;
info->func.best_depth_get = _best_depth_get;
return info;
e = NULL;
}
static void
eng_info_free(Evas *e, void *info)
{
Evas_Engine_Info_Software_Xcb *in;
in = (Evas_Engine_Info_Software_Xcb *)info;
free(in);
}
static void
eng_setup(Evas *e, void *in)
{
Render_Engine *re;
Evas_Engine_Info_Software_Xcb *info;
info = (Evas_Engine_Info_Software_Xcb *)in;
if (!e->engine.data.output)
e->engine.data.output =
_output_setup(e->output.w,
e->output.h,
info->info.rotation,
info->info.conn,
info->info.screen,
info->info.drawable,
info->info.visual,
info->info.colormap,
info->info.depth,
info->info.debug,
info->info.alloc_grayscale,
info->info.alloc_colors_max,
info->info.mask,
info->info.shape_dither,
info->info.destination_alpha);
else
{
int ponebuf = 0;
re = e->engine.data.output;
ponebuf = re->ob->onebuf;
evas_software_xcb_outbuf_free(re->ob);
re->ob = evas_software_xcb_outbuf_setup_x(e->output.w,
e->output.h,
info->info.rotation,
OUTBUF_DEPTH_INHERIT,
info->info.conn,
info->info.screen,
info->info.drawable,
info->info.visual,
info->info.colormap,
info->info.depth,
info->info.alloc_grayscale,
info->info.alloc_colors_max,
info->info.mask,
info->info.shape_dither,
info->info.destination_alpha);
evas_software_xcb_outbuf_debug_set(re->ob, info->info.debug);
re->ob->onebuf = ponebuf;
}
if (!e->engine.data.output) return;
if (!e->engine.data.context)
e->engine.data.context =
e->engine.func->context_new(e->engine.data.output);
re = e->engine.data.output;
evas_software_xcb_outbuf_drawable_set(re->ob, info->info.drawable);
evas_software_xcb_outbuf_mask_set(re->ob, info->info.mask);
evas_software_xcb_outbuf_rotation_set(re->ob, info->info.rotation);
}
static void
eng_output_free(void *data)
{
Render_Engine *re;
if (!data) return;
re = (Render_Engine *)data;
evas_software_xcb_outbuf_free(re->ob);
evas_common_tilebuf_free(re->tb);
if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
free(re);
evas_common_font_shutdown();
evas_common_image_shutdown();
}
static void
eng_output_resize(void *data, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_software_xcb_outbuf_reconfigure(re->ob, w, h,
evas_software_xcb_outbuf_get_rot(re->ob),
OUTBUF_DEPTH_INHERIT);
evas_common_tilebuf_free(re->tb);
re->tb = evas_common_tilebuf_new(w, h);
if (re->tb)
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
}
static void
eng_output_tile_size_set(void *data, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_set_tile_size(re->tb, w, h);
}
static void
eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
}
static void
eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
}
static void
eng_output_redraws_clear(void *data)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_clear(re->tb);
}
static void *
eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
{
Render_Engine *re;
RGBA_Image *surface;
Tilebuf_Rect *rect;
int ux, uy, uw, uh;
re = (Render_Engine *)data;
if (re->end)
{
re->end = 0;
return NULL;
}
if (!re->rects)
{
re->rects = evas_common_tilebuf_get_render_rects(re->tb);
re->cur_rect = EINA_INLIST_GET(re->rects);
}
if (!re->cur_rect) return NULL;
rect = (Tilebuf_Rect *)re->cur_rect;
ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
re->cur_rect = re->cur_rect->next;
if (!re->cur_rect)
{
evas_common_tilebuf_free_render_rects(re->rects);
re->rects = NULL;
re->end = 1;
}
surface = evas_software_xcb_outbuf_new_region_for_update(re->ob,
ux, uy, uw, uh,
cx, cy, cw, ch);
*x = ux; *y = uy; *w = uw; *h = uh;
return surface;
}
static void
eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_pipe_begin(surface);
evas_common_pipe_flush(surface);
evas_software_xcb_outbuf_push_updated_region(re->ob, surface, x, y, w, h);
evas_software_xcb_outbuf_free_region_for_update(re->ob, surface);
evas_common_cpu_end_opt();
}
static void
eng_output_flush(void *data)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_software_xcb_outbuf_flush(re->ob);
}
static void
eng_output_idle_flush(void *data)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_software_xcb_outbuf_idle_flush(re->ob);
}
/* module advertising code */
EAPI int
module_open(Evas_Module *em)
{
if (!em) return 0;
/* get whatever engine module we inherit from */
if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
/* store it for later use */
func = pfunc;
/* now to override methods */
#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
ORD(info);
ORD(info_free);
ORD(setup);
ORD(output_free);
ORD(output_resize);
ORD(output_tile_size_set);
ORD(output_redraws_rect_add);
ORD(output_redraws_rect_del);
ORD(output_redraws_clear);
ORD(output_redraws_next_update_get);
ORD(output_redraws_next_update_push);
ORD(output_flush);
ORD(output_idle_flush);
/* now advertise out own api */
em->functions = (void *)(&func);
return 1;
}
EAPI void
module_close(void)
{
}
EAPI Evas_Module_Api evas_modapi =
{
EVAS_MODULE_API_VERSION,
EVAS_MODULE_TYPE_ENGINE,
"software_xcb",
"none"
};

View File

@ -1,196 +0,0 @@
#ifndef EVAS_ENGINE_H
#define EVAS_ENGINE_H
#include <sys/ipc.h>
#include <sys/shm.h>
#include <xcb/xcb.h>
#include <xcb/xcb_image.h>
typedef struct _Outbuf Outbuf;
typedef struct _Outbuf_Region Outbuf_Region;
typedef struct _Xcb_Output_Buffer Xcb_Output_Buffer;
typedef enum _Outbuf_Depth Outbuf_Depth;
enum _Outbuf_Depth
{
OUTBUF_DEPTH_NONE,
OUTBUF_DEPTH_INHERIT,
OUTBUF_DEPTH_RGB_16BPP_565_565_DITHERED,
OUTBUF_DEPTH_RGB_16BPP_555_555_DITHERED,
OUTBUF_DEPTH_RGB_16BPP_444_444_DITHERED,
OUTBUF_DEPTH_RGB_16BPP_565_444_DITHERED,
OUTBUF_DEPTH_RGB_32BPP_888_8888,
OUTBUF_DEPTH_LAST
};
struct _Outbuf
{
Outbuf_Depth depth;
int w, h;
int rot;
int onebuf;
struct {
Convert_Pal *pal;
struct {
xcb_connection_t *conn;
xcb_screen_t *screen;
xcb_drawable_t win;
xcb_drawable_t mask;
xcb_visualtype_t *vis;
xcb_colormap_t cmap;
int depth;
int shm;
xcb_gcontext_t gc;
xcb_gcontext_t gcm;
unsigned char swap : 1;
unsigned char bit_swap : 1;
} x;
struct {
DATA32 r, g, b;
} mask;
/* 1 big buffer for updates - flush on idle_flush */
RGBA_Image *onebuf;
Eina_List *onebuf_regions;
/* a list of pending regions to write to the target */
Eina_List *pending_writes;
/* a list of previous frame pending regions to write to the target */
Eina_List *prev_pending_writes;
unsigned char mask_dither : 1;
unsigned char destination_alpha : 1;
unsigned char debug : 1;
unsigned char synced : 1;
} priv;
};
struct _Outbuf_Region
{
Xcb_Output_Buffer *xcbob;
Xcb_Output_Buffer *mxcbob;
int x;
int y;
int w;
int h;
};
struct _Xcb_Output_Buffer
{
xcb_connection_t *connection;
xcb_image_t *image;
xcb_shm_segment_info_t *shm_info;
void *data;
int w;
int h;
int bpl;
int psize;
};
/****/
/* main */
void evas_software_xcb_x_init (void);
/* buffer */
void evas_software_xcb_x_write_mask_line (Outbuf *buf,
Xcb_Output_Buffer *xcbob,
DATA32 *src,
int w,
int y);
int evas_software_xcb_x_can_do_shm (xcb_connection_t *c,
xcb_screen_t *screen);
Xcb_Output_Buffer *evas_software_xcb_x_output_buffer_new (xcb_connection_t *c,
int depth,
int w,
int h,
int try_shm,
void *data);
void evas_software_xcb_x_output_buffer_free (Xcb_Output_Buffer *xcbob,
int sync);
void evas_software_xcb_x_output_buffer_paste (Xcb_Output_Buffer *xcbob,
xcb_drawable_t d,
xcb_gcontext_t gc,
int x,
int y,
int sync);
DATA8 *evas_software_xcb_x_output_buffer_data (Xcb_Output_Buffer *xcbob,
int *bytes_per_line_ret);
int evas_software_xcb_x_output_buffer_depth (Xcb_Output_Buffer *xcbob);
int evas_software_xcb_x_output_buffer_byte_order(Xcb_Output_Buffer *xcbob);
int evas_software_xcb_x_output_buffer_bit_order (Xcb_Output_Buffer *xcbob);
/* color */
void evas_software_xcb_x_color_init (void);
Convert_Pal *evas_software_xcb_x_color_allocate (xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *vis,
Convert_Pal_Mode colors);
void evas_software_xcb_x_color_deallocate (xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *vis,
Convert_Pal *pal);
/* outbuf */
void evas_software_xcb_outbuf_init (void);
void evas_software_xcb_outbuf_free (Outbuf *buf);
Outbuf *evas_software_xcb_outbuf_setup_x (int w,
int h,
int rot,
Outbuf_Depth depth,
xcb_connection_t *conn,
xcb_screen_t *screen,
xcb_drawable_t draw,
xcb_visualtype_t *vis,
xcb_colormap_t cmap,
int x_depth,
int grayscale,
int max_colors,
xcb_drawable_t mask,
int shape_dither,
int destination_alpha);
RGBA_Image *evas_software_xcb_outbuf_new_region_for_update (Outbuf *buf,
int x,
int y,
int w,
int h,
int *cx,
int *cy,
int *cw,
int *ch);
void evas_software_xcb_outbuf_free_region_for_update (Outbuf *buf,
RGBA_Image *update);
void evas_software_xcb_outbuf_flush (Outbuf *buf);
void evas_software_xcb_outbuf_idle_flush (Outbuf *buf);
void evas_software_xcb_outbuf_push_updated_region (Outbuf *buf,
RGBA_Image *update,
int x,
int y,
int w,
int h);
void evas_software_xcb_outbuf_reconfigure (Outbuf *buf,
int w,
int h,
int rot,
Outbuf_Depth depth);
int evas_software_xcb_outbuf_get_width (Outbuf *buf);
int evas_software_xcb_outbuf_get_height (Outbuf *buf);
Outbuf_Depth evas_software_xcb_outbuf_get_depth (Outbuf *buf);
int evas_software_xcb_outbuf_get_rot (Outbuf *buf);
void evas_software_xcb_outbuf_drawable_set (Outbuf *buf, xcb_drawable_t draw);
void evas_software_xcb_outbuf_mask_set (Outbuf *buf, xcb_drawable_t mask);
void evas_software_xcb_outbuf_rotation_set (Outbuf *buf, int rot);
void evas_software_xcb_outbuf_debug_set (Outbuf *buf, int debug);
void evas_software_xcb_outbuf_debug_show (Outbuf *buf,
xcb_drawable_t draw,
int x,
int y,
int w,
int h);
#endif /* EVAS_ENGINE_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,287 +0,0 @@
#include "evas_common.h"
#include "evas_engine.h"
static int _xcb_err = 0;
void
evas_software_xcb_x_write_mask_line(Outbuf *buf,
Xcb_Output_Buffer *xcbob,
DATA32 *src,
int w,
int y)
{
int x;
DATA32 *src_ptr;
DATA8 *dst_ptr;
int bpl = 0;
src_ptr = src;
dst_ptr = evas_software_xcb_x_output_buffer_data(xcbob, &bpl);
dst_ptr = dst_ptr + (bpl * y);
w -= 7;
if (buf->priv.x.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++;
}
}
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++;
}
}
w += 7;
for (; x < w; x ++)
{
xcb_image_put_pixel(xcbob->image, x, y, A_VAL(src_ptr) >> 7);
src_ptr++;
}
}
int
evas_software_xcb_x_can_do_shm(xcb_connection_t *c,
xcb_screen_t *screen)
{
static xcb_connection_t *cached_c = NULL;
static int cached_result = 0;
if (c == cached_c) return cached_result;
cached_c = c;
if (xcb_get_extension_data(c, &xcb_shm_id))
{
Xcb_Output_Buffer *xcbob;
xcbob = evas_software_xcb_x_output_buffer_new(c,
screen->root_depth,
16,
16,
2,
NULL);
if (!xcbob)
{
cached_result = 0;
return 0;
}
evas_software_xcb_x_output_buffer_free(xcbob, 1);
cached_result = 1;
return 1;
}
cached_result = 0;
return 0;
}
/*
* FIXME: no error mechanism
*/
/* static void */
/* x_output_tmp_xcb_err(xcb_connection_t *c, XErrorEvent * ev) */
/* { */
/* _xcb_err = 1; */
/* return; */
/* } */
Xcb_Output_Buffer *
evas_software_xcb_x_output_buffer_new(xcb_connection_t *c,
int depth,
int w,
int h,
int try_shm,
void *data)
{
Xcb_Output_Buffer *xcbob;
xcbob = calloc(1, sizeof(Xcb_Output_Buffer));
if (!xcbob) return NULL;
xcbob->connection = c;
xcbob->image = NULL;
xcbob->shm_info = NULL;
xcbob->w = w;
xcbob->h = h;
try_shm = 0;
if (try_shm > 0)
{
xcbob->shm_info = malloc(sizeof(xcb_shm_segment_info_t));
if (xcbob->shm_info)
{
xcbob->shm_info->shmseg = xcb_generate_id(c);
xcbob->image = xcb_image_create_native(c, w, h,
XCB_IMAGE_FORMAT_Z_PIXMAP,
depth, NULL, ~0, NULL);
if (xcbob->image)
{
xcbob->shm_info->shmid = shmget(IPC_PRIVATE,
xcbob->image->size,
IPC_CREAT | 0777);
if (xcbob->shm_info->shmid >= 0)
{
xcbob->shm_info->shmaddr = xcbob->image->data =
shmat(xcbob->shm_info->shmid, 0, 0);
if (xcbob->shm_info->shmaddr != NULL)
{
/*
* FIXME: no error mechanism
*/
/* XErrorHandler ph; */
/* EventHandlers eh; */
// free(xcb_get_input_focus_reply(c, xcb_get_input_focus_unchecked(c), NULL));
_xcb_err = 0;
/* ph = XSetErrorHandler((XErrorHandler) */
/* x_output_tmp_x_err); */
xcb_shm_attach(c,
xcbob->shm_info->shmseg,
xcbob->shm_info->shmid, 0);
// free(xcb_get_input_focus_reply(c, xcb_get_input_focus_unchecked(c), NULL));
/* XSetErrorHandler((XErrorHandler)ph); */
if (!_xcb_err)
{
xcbob->bpl = xcbob->image->stride;
xcbob->psize = xcbob->bpl * xcbob->h;
return xcbob;
}
}
shmdt(xcbob->shm_info->shmaddr);
shmctl(xcbob->shm_info->shmid, IPC_RMID, 0);
}
if (xcbob->image) xcb_image_destroy(xcbob->image);
xcbob->image = NULL;
}
if (xcbob->shm_info) free(xcbob->shm_info);
xcbob->shm_info = NULL;
}
}
if (try_shm > 1) return NULL;
xcbob->image = xcb_image_create_native(c, w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
depth, NULL, ~0, NULL);
if (!xcbob->image)
{
free(xcbob);
return NULL;
}
xcbob->data = data;
if (!xcbob->image->data)
{
xcbob->image->data = malloc(xcbob->image->size);
if (!xcbob->image->data)
{
xcb_image_destroy(xcbob->image);
free(xcbob);
return NULL;
}
}
xcbob->bpl = xcbob->image->stride;
xcbob->psize = xcbob->image->size;
return xcbob;
}
void
evas_software_xcb_x_output_buffer_free(Xcb_Output_Buffer *xcbob,
int sync)
{
if (xcbob->shm_info)
{
if (sync)
free(xcb_get_input_focus_reply(xcbob->connection,
xcb_get_input_focus_unchecked(xcbob->connection),
NULL));
xcb_shm_detach(xcbob->connection, xcbob->shm_info->shmseg);
xcb_image_destroy(xcbob->image);
shmdt(xcbob->shm_info->shmaddr);
shmctl(xcbob->shm_info->shmid, IPC_RMID, 0);
free(xcbob->shm_info);
}
else
{
if (xcbob->data) xcbob->image->data = NULL;
xcb_image_destroy(xcbob->image);
}
free(xcbob);
}
void
evas_software_xcb_x_output_buffer_paste(Xcb_Output_Buffer *xcbob,
xcb_drawable_t d,
xcb_gcontext_t gc,
int x,
int y,
int sync)
{
if (xcbob->shm_info)
{
xcb_image_shm_put(xcbob->connection, d, gc,
xcbob->image, *xcbob->shm_info,
0, 0,
x, y,
xcbob->image->width, xcbob->image->height,
0);
if (sync)
free(xcb_get_input_focus_reply(xcbob->connection,
xcb_get_input_focus_unchecked(xcbob->connection),
NULL));
}
else
xcb_image_put(xcbob->connection, d, gc,
xcbob->image,
x, y, 0);
}
DATA8 *
evas_software_xcb_x_output_buffer_data(Xcb_Output_Buffer *xcbob,
int *bytes_per_line_ret)
{
if (bytes_per_line_ret) *bytes_per_line_ret = xcbob->image->stride;
return xcbob->image->data;
}
int
evas_software_xcb_x_output_buffer_depth(Xcb_Output_Buffer *xcbob)
{
return xcbob->image->bpp;
}
int
evas_software_xcb_x_output_buffer_byte_order(Xcb_Output_Buffer *xcbob)
{
return xcbob->image->byte_order;
}
int
evas_software_xcb_x_output_buffer_bit_order(Xcb_Output_Buffer *xcbob)
{
return xcbob->image->bit_order;
}

View File

@ -1,425 +0,0 @@
#include "evas_common.h"
#include "evas_engine.h"
#include <xcb/xcb.h>
typedef struct _Convert_Pal_Priv Convert_Pal_Priv;
struct _Convert_Pal_Priv
{
xcb_connection_t *conn;
xcb_colormap_t cmap;
xcb_visualtype_t *vis;
};
typedef DATA8 * (*Xcb_Func_Alloc_Colors) (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static Xcb_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 DATA8 * x_color_alloc_rgb(int nr, int ng, int nb, xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_gray(int ng, xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_rgb_332 (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_rgb_666 (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_rgb_232 (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_rgb_222 (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_rgb_221 (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_rgb_121 (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_rgb_111 (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_gray_256 (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_gray_64 (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_gray_16 (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_gray_4 (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 * x_color_alloc_mono (xcb_connection_t *conn, xcb_colormap_t cmap, xcb_visualtype_t *v);
static DATA8 *
x_color_alloc_rgb(int nr,
int ng,
int nb,
xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
int r, g, b, i;
DATA8 *color_lut;
int sig_mask = 0;
int delt = 0;
for (i = 0; i < v->bits_per_rgb_value; i++) sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb_value);
i = 0;
color_lut = malloc((nr) * (ng) * (nb));
if (!color_lut) return NULL;
delt = 0x0101 * 3;
/* FIXME: remove the round-trip ? */
for (r = 0; r < (nr); r++)
{
for (g = 0; g < (ng); g++)
{
for (b = 0; b < (nb); b++)
{
xcb_coloritem_t xcl;
xcb_coloritem_t xcl_in;
xcb_alloc_color_reply_t *rep;
int val;
int dr, dg, db;
val = (int)((((double)r) / ((nr) - 1)) * 255);
val = (val << 8) | val;
xcl.red = (uint16_t)(val);
val = (int)((((double)g) / ((ng) - 1)) * 255);
val = (val << 8) | val;
xcl.green = (uint16_t)(val);
val = (int)((((double)b) / ((nb) - 1)) * 255);
val = (val << 8) | val;
xcl.blue = (uint16_t)(val);
xcl_in = xcl;
rep = xcb_alloc_color_reply(conn,
xcb_alloc_color_unchecked(conn,
cmap,
xcl.red,
xcl.green,
xcl.blue),
0);
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);
*/
/* TODO: XAllocColor tries to approach the color */
/* in case the allocation fails */
/* XCB does not that (i think). It should be done */
/* So if rep == NULL, the other following tests */
/* should be always satisfied */
if ((!rep) ||
((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))
*/
)
{
uint32_t pixels[256];
int j;
if (i > 0)
{
for (j = 0; j < i; j++)
pixels[j] = (uint32_t)color_lut[j];
xcb_free_colors(conn, cmap, 0, i, pixels);
}
free(color_lut);
return NULL;
}
color_lut[i] = rep->pixel;
i++;
free(rep);
}
}
}
return color_lut;
}
static DATA8 *
x_color_alloc_gray(int ng,
xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
int g, i;
DATA8 *color_lut;
int sig_mask = 0;
for (i = 0; i < v->bits_per_rgb_value; i++) sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb_value);
i = 0;
color_lut = malloc(ng);
if (!color_lut) return NULL;
/* FIXME: remove the round-trip ? */
for (g = 0; g < (ng); g++)
{
xcb_coloritem_t xcl;
xcb_coloritem_t xcl_in;
int val;
xcb_alloc_color_reply_t *rep;
val = (int)((((double)g) / ((ng) - 1)) * 255);
val = (val << 8) | val;
xcl.red = (uint16_t)(val);
xcl.green = (uint16_t)(val);
xcl.blue = (uint16_t)(val);
xcl_in = xcl;
rep = xcb_alloc_color_reply(conn,
xcb_alloc_color_unchecked(conn,
cmap,
xcl.red,
xcl.green,
xcl.blue),
0);
/* FIXME: XAllocColor tries to approach the color */
/* in case the allocation fails */
/* XCB does not that (i think). It should be done */
/* So if rep == NULL, the other following tests */
/* should be always satisfied */
if ((!rep) ||
((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)))
{
uint32_t pixels[256];
int j;
if (i > 0)
{
for (j = 0; j < i; j++)
pixels[j] = (uint32_t) color_lut[j];
xcb_free_colors(conn, cmap, 0, i, pixels);
}
free(color_lut);
return NULL;
}
color_lut[i] = rep->pixel;
i++;
free(rep);
}
return color_lut;
}
static DATA8 *
x_color_alloc_rgb_332(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
return x_color_alloc_rgb(8, 8, 4, conn, cmap, v);
}
static DATA8 *
x_color_alloc_rgb_666(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
return x_color_alloc_rgb(6, 6, 6, conn, cmap, v);
}
static DATA8 *
x_color_alloc_rgb_232(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
return x_color_alloc_rgb(4, 8, 4, conn, cmap, v);
}
static DATA8 *
x_color_alloc_rgb_222(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
return x_color_alloc_rgb(4, 4, 4, conn, cmap, v);
}
static DATA8 *
x_color_alloc_rgb_221(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
return x_color_alloc_rgb(4, 4, 2, conn, cmap, v);
}
static DATA8 *
x_color_alloc_rgb_121(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
return x_color_alloc_rgb(2, 4, 2, conn, cmap, v);
}
static DATA8 *
x_color_alloc_rgb_111(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
return x_color_alloc_rgb(2, 2, 2, conn, cmap, v);
}
static DATA8 *
x_color_alloc_gray_256(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
return x_color_alloc_gray(256, conn, cmap, v);
}
static DATA8 *
x_color_alloc_gray_64(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
return x_color_alloc_gray(64, conn, cmap, v);
}
static DATA8 *
x_color_alloc_gray_16(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
return x_color_alloc_gray(32, conn, cmap, v);
}
static DATA8 *
x_color_alloc_gray_4(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
return x_color_alloc_gray(16, conn, cmap, v);
}
static DATA8 *
x_color_alloc_mono(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *v)
{
return x_color_alloc_gray(2, conn, cmap, v);
}
void
evas_software_xcb_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_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_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_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_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_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_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_LAST] = NULL;
x_color_count[PAL_MODE_LAST] = 0;
initialised = 1;
}
Convert_Pal *
evas_software_xcb_x_color_allocate(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *vis,
Convert_Pal_Mode colors)
{
Convert_Pal_Priv *palpriv;
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 ((conn == palpriv->conn) &&
(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])
{
/* printf("TRY PAL %i\n", c);*/
pal->lookup = (x_color_alloc[c])(conn, cmap, vis);
if (pal->lookup) break;
}
}
pal->references = 1;
pal->colors = c;
pal->count = x_color_count[c];
palpriv = calloc(1, sizeof(Convert_Pal_Priv));
pal->data = palpriv;
if (!palpriv)
{
if (pal->lookup) free(pal->lookup);
free(pal);
return NULL;
}
palpriv->conn = conn;
palpriv->vis = vis;
palpriv->cmap = cmap;
if (pal->colors == PAL_MODE_NONE)
{
if (pal->lookup) free(pal->lookup);
free(pal);
return NULL;
}
palettes = eina_list_append(palettes, pal);
return pal;
}
void
evas_software_xcb_x_color_deallocate(xcb_connection_t *conn,
xcb_colormap_t cmap,
xcb_visualtype_t *vis,
Convert_Pal *pal)
{
uint32_t pixels[256];
int j;
pal->references--;
if (pal->references > 0) return;
if (pal->lookup)
{
for(j = 0; j < pal->count; j++)
pixels[j] = (uint32_t) pal->lookup[j];
xcb_free_colors(conn, cmap, 0, pal->count, pixels);
free(pal->lookup);
}
free(pal->data);
palettes = eina_list_remove(palettes, pal);
free(pal);
}

View File

@ -1,9 +0,0 @@
#include "evas_common.h"
#include "evas_engine.h"
#include <xcb/xcb.h>
void
evas_software_xcb_x_init(void)
{
}