forked from enlightenment/efl
oooops.. i forgot one lump of logic for adding new object if currently the
object inthe evas are in layers above the new one.. fix fix oops.. that was a silly bug... :) and well.. while i was at it.. some actual code in the render extension support in the render engine in evas.. it onyl does image objects right now.. and it doesnt do it very optimally.. consider that engine a work in progres.. i'm finding what does and doesnt work well in the render extension and noticing some holes in it... this one wont be ready any time soon though... and the gl engine is still about 10 times faster on the same hardware... and in theory both are hardware accelerated... anyway only time will tell. the render extension doesnt do image transforms.. so this wont help speed it up at all that much :( SVN revision: 5267
This commit is contained in:
parent
38f08f9b0d
commit
0d7a6252be
|
@ -30,16 +30,6 @@ LDFLAGS="$LDFLAGS -L$withval/lib";
|
|||
LIBS_TTF="-L"$withval"/lib"
|
||||
])
|
||||
|
||||
AC_ARG_WITH(gl,
|
||||
[
|
||||
--with-gl=DIR use DIR where opengl was installed (eg /usr/X11R6)
|
||||
],
|
||||
[
|
||||
CPPFLAGS="$CPPFLAGS -I$withval/include";
|
||||
LDFLAGS="$LDFLAGS -L$withval/lib";
|
||||
LIBS_GL="-L"$withval"/lib"
|
||||
])
|
||||
|
||||
gl=yes
|
||||
AC_ARG_ENABLE(gl,
|
||||
[--disable-gl disable building with opengl support],
|
||||
|
@ -52,6 +42,18 @@ AC_ARG_ENABLE(gl,
|
|||
]
|
||||
)
|
||||
|
||||
AC_ARG_WITH(gl,
|
||||
[
|
||||
--with-gl=DIR use DIR where opengl was installed (eg /usr/X11R6)
|
||||
],
|
||||
[
|
||||
if test x$gl = xyes; then
|
||||
CPPFLAGS="$CPPFLAGS -I$withval/include";
|
||||
LDFLAGS="$LDFLAGS -L$withval/lib";
|
||||
LIBS_GL="-L"$withval"/lib"
|
||||
fi
|
||||
])
|
||||
|
||||
AC_C_BIGENDIAN
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_STDC
|
||||
|
@ -105,15 +107,15 @@ $x_libs)
|
|||
|
||||
x_libs="$x_libs -lX11"
|
||||
|
||||
#AC_CHECK_LIB(
|
||||
#Xrender,
|
||||
#XRenderCreatePicture,
|
||||
#[
|
||||
#x_libs=" -lXrender -lXext $x_libs";
|
||||
#AC_DEFINE(HAVE_RENDER)
|
||||
#],
|
||||
#[],
|
||||
#$x_libs)
|
||||
AC_CHECK_LIB(
|
||||
Xrender,
|
||||
XRenderCreatePicture,
|
||||
[
|
||||
x_libs=" -lXrender -lXext $x_libs";
|
||||
AC_DEFINE(HAVE_RENDER)
|
||||
],
|
||||
[],
|
||||
$x_libs)
|
||||
|
||||
AC_CHECK_LIB(
|
||||
ttf,
|
||||
|
|
|
@ -84,6 +84,17 @@ evas_add_gradient_box(Evas e)
|
|||
layer->objects = evas_list_append(layer->objects, o);
|
||||
return o;
|
||||
}
|
||||
if (layer->layer > o->current.layer)
|
||||
{
|
||||
Evas_Layer layer_new;
|
||||
|
||||
layer_new = malloc(sizeof(struct _Evas_Layer));
|
||||
memset(layer_new, 0, sizeof(struct _Evas_Layer));
|
||||
e->layers = evas_list_prepend_relative(e->layers, layer_new, layer);
|
||||
layer_new->objects = evas_list_append(layer_new->objects, o);
|
||||
layer_new->layer = o->current.layer;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
layer = malloc(sizeof(struct _Evas_Layer));
|
||||
|
|
|
@ -108,6 +108,17 @@ evas_add_image_from_file(Evas e, char *file)
|
|||
layer->objects = evas_list_append(layer->objects, o);
|
||||
return o;
|
||||
}
|
||||
if (layer->layer > o->current.layer)
|
||||
{
|
||||
Evas_Layer layer_new;
|
||||
|
||||
layer_new = malloc(sizeof(struct _Evas_Layer));
|
||||
memset(layer_new, 0, sizeof(struct _Evas_Layer));
|
||||
e->layers = evas_list_prepend_relative(e->layers, layer_new, layer);
|
||||
layer_new->objects = evas_list_append(layer_new->objects, o);
|
||||
layer_new->layer = o->current.layer;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
layer = malloc(sizeof(struct _Evas_Layer));
|
||||
|
|
|
@ -68,6 +68,17 @@ evas_add_line(Evas e)
|
|||
layer->objects = evas_list_append(layer->objects, o);
|
||||
return o;
|
||||
}
|
||||
if (layer->layer > o->current.layer)
|
||||
{
|
||||
Evas_Layer layer_new;
|
||||
|
||||
layer_new = malloc(sizeof(struct _Evas_Layer));
|
||||
memset(layer_new, 0, sizeof(struct _Evas_Layer));
|
||||
e->layers = evas_list_prepend_relative(e->layers, layer_new, layer);
|
||||
layer_new->objects = evas_list_append(layer_new->objects, o);
|
||||
layer_new->layer = o->current.layer;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
layer = malloc(sizeof(struct _Evas_Layer));
|
||||
|
|
|
@ -284,18 +284,25 @@ evas_set_layer(Evas e, Evas_Object o, int layer_num)
|
|||
o->changed = 1;
|
||||
e->changed = 1;
|
||||
o->current.layer = layer_num;
|
||||
printf("object at layer %i\n", layer_num);
|
||||
for (l = e->layers; l; l = l->next)
|
||||
{
|
||||
layer = l->data;
|
||||
printf("have a layer %i\n", layer->layer);
|
||||
if (layer->layer == o->current.layer)
|
||||
{
|
||||
printf("same layer..\n");
|
||||
layer->objects = evas_list_append(layer->objects, o);
|
||||
if ((o->current.visible) &&
|
||||
(_evas_point_in_object(e, o, e->mouse.x, e->mouse.y)))
|
||||
evas_event_move(e, e->mouse.x, e->mouse.y);
|
||||
return;
|
||||
}
|
||||
if (layer->layer > o->current.layer)
|
||||
{
|
||||
Evas_Layer layer_new;
|
||||
|
||||
printf("insert before this layer\n");
|
||||
layer_new = malloc(sizeof(struct _Evas_Layer));
|
||||
memset(layer_new, 0, sizeof(struct _Evas_Layer));
|
||||
e->layers = evas_list_prepend_relative(e->layers, layer_new, layer);
|
||||
|
@ -307,7 +314,7 @@ evas_set_layer(Evas e, Evas_Object o, int layer_num)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
printf("put at end of layers\n");
|
||||
layer = malloc(sizeof(struct _Evas_Layer));
|
||||
memset(layer, 0, sizeof(struct _Evas_Layer));
|
||||
e->layers = evas_list_append(e->layers, layer);
|
||||
|
|
|
@ -72,6 +72,17 @@ evas_add_poly(Evas e)
|
|||
layer->objects = evas_list_append(layer->objects, o);
|
||||
return o;
|
||||
}
|
||||
if (layer->layer > o->current.layer)
|
||||
{
|
||||
Evas_Layer layer_new;
|
||||
|
||||
layer_new = malloc(sizeof(struct _Evas_Layer));
|
||||
memset(layer_new, 0, sizeof(struct _Evas_Layer));
|
||||
e->layers = evas_list_prepend_relative(e->layers, layer_new, layer);
|
||||
layer_new->objects = evas_list_append(layer_new->objects, o);
|
||||
layer_new->layer = o->current.layer;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
layer = malloc(sizeof(struct _Evas_Layer));
|
||||
|
|
|
@ -63,6 +63,17 @@ evas_add_rectangle(Evas e)
|
|||
layer->objects = evas_list_append(layer->objects, o);
|
||||
return o;
|
||||
}
|
||||
if (layer->layer > o->current.layer)
|
||||
{
|
||||
Evas_Layer layer_new;
|
||||
|
||||
layer_new = malloc(sizeof(struct _Evas_Layer));
|
||||
memset(layer_new, 0, sizeof(struct _Evas_Layer));
|
||||
e->layers = evas_list_prepend_relative(e->layers, layer_new, layer);
|
||||
layer_new->objects = evas_list_append(layer_new->objects, o);
|
||||
layer_new->layer = o->current.layer;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
layer = malloc(sizeof(struct _Evas_Layer));
|
||||
|
|
|
@ -389,6 +389,7 @@ evas_render_updates(Evas e)
|
|||
Evas_Layer layer;
|
||||
|
||||
layer = l->data;
|
||||
printf("layer->layer %i\n", layer->layer);
|
||||
for (ll = layer->objects; ll; ll = ll->next)
|
||||
{
|
||||
Evas_Object_Any o;
|
||||
|
|
|
@ -32,6 +32,363 @@ __evas_render_image_cache_flush(Display *disp)
|
|||
imlib_set_cache_size(size);
|
||||
}
|
||||
|
||||
static char x_does_shm = -1;
|
||||
static int list_num = 0;
|
||||
static XImage **list_xim = NULL;
|
||||
static XShmSegmentInfo **list_si = NULL;
|
||||
static Display **list_d = NULL;
|
||||
static char *list_used = NULL;
|
||||
static int list_mem_use = 0;
|
||||
static int list_max_mem = 0;
|
||||
static int list_max_count = 0;
|
||||
static char _x_err = 0;
|
||||
|
||||
static Visual *__evas_visual = NULL;
|
||||
static Colormap __evas_cmap = 0;
|
||||
|
||||
/* the fucntion we use for catching the error */
|
||||
static void
|
||||
__evas_render_image_ximage_tmp_x_error(Display * d, XErrorEvent * ev)
|
||||
{
|
||||
_x_err = 1;
|
||||
return;
|
||||
d = NULL;
|
||||
ev = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
__evas_render_image_ximage_flush(Display *d)
|
||||
{
|
||||
int i;
|
||||
XImage *xim;
|
||||
char did_free = 1;
|
||||
|
||||
while (((list_mem_use > list_max_mem) || (list_num > list_max_count)) &&
|
||||
(did_free))
|
||||
{
|
||||
did_free = 0;
|
||||
for (i = 0; i < list_num; i++)
|
||||
{
|
||||
if (list_used[i] == 0)
|
||||
{
|
||||
int j;
|
||||
|
||||
xim = list_xim[i];
|
||||
list_mem_use -= xim->bytes_per_line * xim->height;
|
||||
if (list_si[i])
|
||||
XShmDetach(d, list_si[i]);
|
||||
XDestroyImage(xim);
|
||||
if (list_si[i])
|
||||
{
|
||||
shmdt(list_si[i]->shmaddr);
|
||||
shmctl(list_si[i]->shmid, IPC_RMID, 0);
|
||||
free(list_si[i]);
|
||||
}
|
||||
list_num--;
|
||||
for (j = i; j < list_num; j++)
|
||||
{
|
||||
list_xim[j] = list_xim[j + 1];
|
||||
list_si[j] = list_si[j + 1];
|
||||
list_used[j] = list_used[j + 1];
|
||||
list_d[j] = list_d[j + 1];
|
||||
}
|
||||
if (list_num == 0)
|
||||
{
|
||||
if (list_xim) free(list_xim);
|
||||
if (list_si) free(list_si);
|
||||
if (list_used) free(list_used);
|
||||
if (list_d) free(list_d);
|
||||
list_xim = NULL;
|
||||
list_si = NULL;
|
||||
list_used = NULL;
|
||||
list_d = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
list_xim = realloc(list_xim, sizeof(XImage *) * list_num);
|
||||
list_si = realloc(list_si, sizeof(XShmSegmentInfo *) * list_num);
|
||||
list_used = realloc(list_used, sizeof(char) * list_num);
|
||||
list_d = realloc(list_d, sizeof(Display *) * list_num);
|
||||
}
|
||||
did_free = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XImage *
|
||||
__evas_render_image_ximage_new(Display *d, Visual *v, int depth, int w, int h, char *shared)
|
||||
{
|
||||
XImage *xim;
|
||||
int i;
|
||||
|
||||
if (x_does_shm < 0)
|
||||
{
|
||||
if (XShmQueryExtension(d))
|
||||
x_does_shm = 1;
|
||||
else
|
||||
x_does_shm = 0;
|
||||
}
|
||||
*shared = 0;
|
||||
for (i = 0; i < list_num; i++)
|
||||
{
|
||||
if ((list_xim[i]->bits_per_pixel == depth) &&
|
||||
(list_xim[i]->width >= w) &&
|
||||
(list_xim[i]->height >= h) &&
|
||||
(!list_used[i]))
|
||||
{
|
||||
list_used[i] = 1;
|
||||
if (list_si[i])
|
||||
*shared = 1;
|
||||
return list_xim[i];
|
||||
}
|
||||
}
|
||||
list_num++;
|
||||
if (list_num == 1)
|
||||
{
|
||||
list_xim = malloc(sizeof(XImage *) * list_num);
|
||||
list_si = malloc(sizeof(XShmSegmentInfo *) * list_num);
|
||||
list_used = malloc(sizeof(char) * list_num);
|
||||
list_d = malloc(sizeof(Display *) * list_num);
|
||||
}
|
||||
else
|
||||
{
|
||||
list_xim = realloc(list_xim, sizeof(XImage *) * list_num);
|
||||
list_si = realloc(list_si, sizeof(XShmSegmentInfo *) * list_num);
|
||||
list_used = realloc(list_used, sizeof(char) * list_num);
|
||||
list_d = realloc(list_d, sizeof(Display *) * list_num);
|
||||
}
|
||||
list_si[list_num - 1] = malloc(sizeof(XShmSegmentInfo));
|
||||
|
||||
xim = NULL;
|
||||
if (x_does_shm)
|
||||
{
|
||||
xim = XShmCreateImage(d, v, depth, ZPixmap, NULL,
|
||||
list_si[list_num - 1], w, h);
|
||||
if (xim)
|
||||
{
|
||||
list_xim[list_num - 1] = xim;
|
||||
list_si[list_num - 1]->shmid =
|
||||
shmget(IPC_PRIVATE, xim->bytes_per_line * xim->height,
|
||||
IPC_CREAT | 0777);
|
||||
if (list_si[list_num - 1]->shmid != -1)
|
||||
{
|
||||
list_si[list_num - 1]->readOnly = False;
|
||||
list_si[list_num - 1]->shmaddr = xim->data =
|
||||
shmat(list_si[list_num - 1]->shmid, 0, 0);
|
||||
if (xim->data != (char *)-1)
|
||||
{
|
||||
XErrorHandler ph;
|
||||
|
||||
_x_err = 0;
|
||||
ph = XSetErrorHandler((XErrorHandler) __evas_render_image_ximage_tmp_x_error);
|
||||
XShmAttach(d, list_si[list_num - 1]);
|
||||
XSync(d, False);
|
||||
XSetErrorHandler((XErrorHandler) ph);
|
||||
if (!_x_err)
|
||||
{
|
||||
list_used[list_num - 1] = 1;
|
||||
list_mem_use += xim->bytes_per_line * xim->height;
|
||||
*shared = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
x_does_shm = 0;
|
||||
XDestroyImage(xim);
|
||||
shmdt(list_si[list_num - 1]->shmaddr);
|
||||
shmctl(list_si[list_num - 1]->shmid, IPC_RMID, 0);
|
||||
xim = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XDestroyImage(xim);
|
||||
shmctl(list_si[list_num - 1]->shmid, IPC_RMID, 0);
|
||||
xim = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XDestroyImage(xim);
|
||||
xim = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!xim)
|
||||
{
|
||||
free(list_si[list_num - 1]);
|
||||
list_si[list_num - 1] = NULL;
|
||||
xim = XCreateImage(d, v, depth, ZPixmap, 0, NULL, w, h, 32, 0);
|
||||
xim->data = malloc(xim->bytes_per_line * xim->height);
|
||||
list_xim[list_num - 1] = xim;
|
||||
list_mem_use += xim->bytes_per_line * xim->height;
|
||||
list_used[list_num - 1] = 1;
|
||||
list_d[list_num - 1] = d;
|
||||
}
|
||||
__evas_render_image_ximage_flush(d);
|
||||
return xim;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
__evas_render_image_ximage_free(Display *d, XImage *xim)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < list_num; i++)
|
||||
{
|
||||
if (list_xim[i] == xim)
|
||||
{
|
||||
list_used[i] = 0;
|
||||
__evas_render_image_ximage_flush(d);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
__evas_render_image_ximage_put(Display *d, Drawable dst, GC gc, XImage *xim,
|
||||
int sx, int sy, int dx, int dy, int w, int h,
|
||||
int shm)
|
||||
{
|
||||
if (shm)
|
||||
XShmPutImage(d, dst, gc, xim, sx, sy, dx, dy, w, h, False);
|
||||
else
|
||||
XPutImage(d, dst, gc, xim, sx, sy, dx, dy, w, h);
|
||||
if (shm)
|
||||
XSync(d, False);
|
||||
}
|
||||
|
||||
|
||||
static Picture
|
||||
__evas_render_create_picuture(Display *d, Drawable dst,
|
||||
XRenderPictFormat *format)
|
||||
{
|
||||
Picture pic;
|
||||
XRenderPictureAttributes att;
|
||||
|
||||
att.repeat = True;
|
||||
att.dither = True;
|
||||
att.component_alpha = True;
|
||||
pic = XRenderCreatePicture (d, dst, format,
|
||||
/*
|
||||
CPRepeat |
|
||||
CPDither |
|
||||
CPComponentAlpha,
|
||||
*/
|
||||
0,
|
||||
&att);
|
||||
return pic;
|
||||
}
|
||||
|
||||
static void
|
||||
__evas_render_populate_update(Evas_Render_Update *up)
|
||||
{
|
||||
XRenderPictFormat fmt, *format, *format_color;
|
||||
Visual *visual;
|
||||
int screen;
|
||||
|
||||
screen = 0;
|
||||
visual = __evas_visual;
|
||||
format = XRenderFindVisualFormat (up->disp, visual);
|
||||
if (!format) printf("eek no format!\n");
|
||||
fmt.depth = 32;
|
||||
fmt.type = PictTypeDirect;
|
||||
format_color = XRenderFindFormat(up->disp, PictFormatType | PictFormatDepth,
|
||||
&fmt, 0);
|
||||
if (!format_color) printf("eek no format_color\n");
|
||||
up->pmap = XCreatePixmap (up->disp, up->drawable,
|
||||
up->w, up->h, fmt.depth);
|
||||
up->pic = __evas_render_create_picuture(up->disp, up->pmap, format_color);
|
||||
}
|
||||
|
||||
static void
|
||||
__evas_render_dump_current_image_to_pixmap(Display *disp, Pixmap pmap,
|
||||
Visual *v, int depth, int w, int h)
|
||||
{
|
||||
DATA32 *data, *buf;
|
||||
int x, y;
|
||||
XImage *xim;
|
||||
char shm;
|
||||
static GC gc = 0;
|
||||
XGCValues gcv;
|
||||
int has_alpha;
|
||||
|
||||
data = imlib_image_get_data_for_reading_only();
|
||||
shm = 0;
|
||||
xim = __evas_render_image_ximage_new(disp, v, depth, w, h, &shm);
|
||||
if (!xim) return;
|
||||
if (!gc)
|
||||
{
|
||||
gcv.graphics_exposures = False;
|
||||
gc = XCreateGC(disp, pmap, GCGraphicsExposures, &gcv);
|
||||
}
|
||||
has_alpha = imlib_image_has_alpha();
|
||||
if (has_alpha)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
buf = xim->data + (y * (xim->bytes_per_line));
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
int r, g, b, a;
|
||||
|
||||
r = ((*data) >> 16) & 0xff;
|
||||
g = ((*data) >> 8 ) & 0xff;
|
||||
b = ((*data) ) & 0xff;
|
||||
a = ((*data) >> 24) & 0xff;
|
||||
r = (r * a) / 255;
|
||||
g = (g * a) / 255;
|
||||
b = (b * a) / 255;
|
||||
|
||||
*buf = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
buf++;
|
||||
data++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
buf = xim->data + (y * (xim->bytes_per_line));
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
int r, g, b, a;
|
||||
|
||||
r = ((*data) >> 16) & 0xff;
|
||||
g = ((*data) >> 8 ) & 0xff;
|
||||
b = ((*data) ) & 0xff;
|
||||
a = 255;
|
||||
*buf = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
buf++;
|
||||
data++;
|
||||
}
|
||||
}
|
||||
}
|
||||
__evas_render_image_ximage_put(disp, pmap, gc, xim, 0, 0, 0, 0, w, h, shm);
|
||||
__evas_render_image_ximage_free(disp, xim);
|
||||
imlib_image_put_back_data(data);
|
||||
}
|
||||
|
||||
static int
|
||||
__evas_render_create_dest_buf(Display *disp, Visual *v, int w, int h,
|
||||
int screen, Pixmap *pmap_ret, Picture *pic_ret)
|
||||
{
|
||||
XRenderPictFormat fmt, *format, *format_color;
|
||||
|
||||
format = XRenderFindVisualFormat(disp, v);
|
||||
if (!format) printf("eek no format!\n");
|
||||
fmt.depth = 32;
|
||||
fmt.type = PictTypeDirect;
|
||||
format_color = XRenderFindFormat(disp, PictFormatType | PictFormatDepth,
|
||||
&fmt, 0);
|
||||
if (!format_color) printf("eek no format_color\n");
|
||||
*pmap_ret = XCreatePixmap(disp, RootWindow(disp, screen), w, h, fmt.depth);
|
||||
*pic_ret = __evas_render_create_picuture(disp, *pmap_ret, format_color);
|
||||
return format_color->depth;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* image externals ***********************************************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -41,24 +398,17 @@ __evas_render_image_new_from_file(Display *disp, char *file)
|
|||
{
|
||||
Evas_Render_Image *im;
|
||||
Imlib_Image i;
|
||||
XRenderPictFormat fmt, *format, *format_color;
|
||||
Visual *visual;
|
||||
int screen;
|
||||
int screen, depth;
|
||||
|
||||
/* need to look for image i local cache */
|
||||
/* not found - load */
|
||||
screen = 0;
|
||||
i = imlib_load_image(file);
|
||||
if (!i) return NULL;
|
||||
imlib_context_set_image(i);
|
||||
im = malloc(sizeof(Evas_Render_Image));
|
||||
memset(im, 0, sizeof(Evas_Render_Image));
|
||||
/* this stuff needs to become a context lookup for the display pointer */
|
||||
visual = DefaultVisual (disp, screen);
|
||||
format = XRenderFindVisualFormat (disp, visual);
|
||||
fmt.depth = 32;
|
||||
fmt.type = PictTypeDirect;
|
||||
format_color = XRenderFindFormat(disp, PictFormatType | PictFormatDepth, &fmt, 0);
|
||||
|
||||
im->image = i;
|
||||
im->file = malloc(strlen(file) + 1);
|
||||
strcpy(im->file, file);
|
||||
im->references = 1;
|
||||
|
@ -66,10 +416,12 @@ __evas_render_image_new_from_file(Display *disp, char *file)
|
|||
im->has_alpha = imlib_image_has_alpha();
|
||||
im->w = imlib_image_get_width();
|
||||
im->h = imlib_image_get_height();
|
||||
im->pmap = XCreatePixmap (disp, RootWindow (disp, screen), im->w, im->h, fmt.depth);
|
||||
im->pic = XRenderCreatePicture (disp, im->pmap, &fmt, 0, 0);
|
||||
|
||||
/* need to xshmputimage to the pixmap */
|
||||
/*
|
||||
depth = __evas_render_create_dest_buf(disp, __evas_visual, im->w, im->h,
|
||||
screen, &(im->pmap), &(im->pic));
|
||||
__evas_render_dump_current_image_to_pixmap(disp, im->pmap, __evas_visual,
|
||||
depth, im->w, im->h);
|
||||
*/
|
||||
/* need to add to local cache list */
|
||||
return im;
|
||||
}
|
||||
|
@ -114,9 +466,18 @@ __evas_render_image_draw(Evas_Render_Image *im,
|
|||
int cr, int cg, int cb, int ca)
|
||||
{
|
||||
Evas_List l;
|
||||
|
||||
if (ca == 0) return;
|
||||
|
||||
if (ca == 0) return;
|
||||
if ((src_w == 0) || (src_h == 0) || (dst_w == 0) || (dst_w == 0)) return;
|
||||
|
||||
if (__evas_clip)
|
||||
{
|
||||
cr = (cr * __evas_clip_r) / 255;
|
||||
cg = (cg * __evas_clip_g) / 255;
|
||||
cb = (cb * __evas_clip_b) / 255;
|
||||
ca = (ca * __evas_clip_a) / 255;
|
||||
}
|
||||
if (ca == 0) return;
|
||||
for(l = drawable_list; l; l = l->next)
|
||||
{
|
||||
Evas_Render_Drawable *dr;
|
||||
|
@ -137,6 +498,163 @@ __evas_render_image_draw(Evas_Render_Image *im,
|
|||
if (RECTS_INTERSECT(up->x, up->y, up->w, up->h,
|
||||
dst_x, dst_y, dst_w, dst_h))
|
||||
{
|
||||
int xx, yy, ww, hh, iw, ih, dx, dy, dw, dh;
|
||||
|
||||
if (!up->pmap)
|
||||
__evas_render_populate_update(up);
|
||||
dx = dst_x;
|
||||
dy = dst_y;
|
||||
dw = dst_w;
|
||||
dh = dst_h;
|
||||
iw = im->w;
|
||||
ih = im->h;
|
||||
ww = (iw * dw) / src_w;
|
||||
hh = (ih * dh) / src_h;
|
||||
xx = (src_x * dw) / src_w;
|
||||
yy = (src_y * dh) / src_h;
|
||||
if (__evas_clip)
|
||||
{
|
||||
int px, py;
|
||||
|
||||
px = dx;
|
||||
py = dy;
|
||||
CLIP_TO(dx, dy, dw, dh,
|
||||
__evas_clip_x, __evas_clip_y,
|
||||
__evas_clip_w, __evas_clip_h);
|
||||
xx += dx - px;
|
||||
yy += dy - py;
|
||||
}
|
||||
if ((dw > 1) && (dh > 1))
|
||||
{
|
||||
if ((im->current.w != ww) ||
|
||||
(im->current.h != hh) ||
|
||||
(cr != im->current.pr) ||
|
||||
(cg != im->current.pg) ||
|
||||
(cb != im->current.pb) ||
|
||||
(ca != im->current.pa) ||
|
||||
(__evas_anti_alias != im->current.smooth)
|
||||
)
|
||||
{
|
||||
if (im->pmap) XFreePixmap(im->disp, im->pmap);
|
||||
if (im->pic) XRenderFreePicture(im->disp, im->pic);
|
||||
im->pmap = 0;
|
||||
im->pic = 0;
|
||||
}
|
||||
if (!im->pmap)
|
||||
{
|
||||
int screen = 0;
|
||||
int depth;
|
||||
|
||||
im->current.w = ww;
|
||||
im->current.h = hh;
|
||||
im->current.pr = cr;
|
||||
im->current.pg = cg;
|
||||
im->current.pb = cb;
|
||||
im->current.pa = ca;
|
||||
im->current.smooth = __evas_anti_alias;
|
||||
if ((im->current.border.l != 0) ||
|
||||
(im->current.border.r != 0) ||
|
||||
(im->current.border.t != 0) ||
|
||||
(im->current.border.b != 0) ||
|
||||
(im->current.pr != 255) ||
|
||||
(im->current.pg != 255) ||
|
||||
(im->current.pb != 255) ||
|
||||
(im->current.pa != 255)
|
||||
)
|
||||
{
|
||||
Imlib_Image i;
|
||||
Imlib_Border bd;
|
||||
Imlib_Color_Modifier cm = NULL;
|
||||
|
||||
cm = imlib_create_color_modifier();
|
||||
imlib_context_set_color_modifier(cm);
|
||||
if ((cr != 255) || (cg != 255) || (cb != 255) || (ca != 255))
|
||||
{
|
||||
DATA8 r[256], g[256], b[256], a[256];
|
||||
int j;
|
||||
|
||||
cm = imlib_create_color_modifier();
|
||||
imlib_context_set_color_modifier(cm);
|
||||
for (j = 0; j < 256; j++)
|
||||
{
|
||||
r[j] = (j * cr) / 255;
|
||||
g[j] = (j * cg) / 255;
|
||||
b[j] = (j * cb) / 255;
|
||||
a[j] = (j * ca) / 255;
|
||||
}
|
||||
imlib_set_color_modifier_tables(r, g, b, a);
|
||||
}
|
||||
else
|
||||
imlib_context_set_color_modifier(NULL);
|
||||
|
||||
i = imlib_create_image(im->current.w, im->current.h);
|
||||
imlib_context_set_image(i);
|
||||
imlib_image_set_has_alpha(1);
|
||||
imlib_image_clear();
|
||||
bd.left = im->current.border.l;
|
||||
bd.right = im->current.border.r;
|
||||
bd.top = im->current.border.t;
|
||||
bd.bottom = im->current.border.b;
|
||||
imlib_image_set_border(&bd);
|
||||
imlib_context_set_anti_alias(__evas_anti_alias);
|
||||
imlib_context_set_blend(1);
|
||||
imlib_context_set_operation(IMLIB_OP_COPY);
|
||||
imlib_context_set_angle(0.0);
|
||||
|
||||
imlib_blend_image_onto_image(im->image, 1,
|
||||
0, 0, im->w, im->h,
|
||||
0, 0, dst_w, dst_h);
|
||||
if (cm)
|
||||
{
|
||||
imlib_free_color_modifier();
|
||||
imlib_context_set_color_modifier(NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Imlib_Image i;
|
||||
|
||||
imlib_context_set_image(im->image);
|
||||
i = imlib_create_cropped_scaled_image(0, 0,
|
||||
im->w, im->h,
|
||||
dst_w, dst_h);
|
||||
imlib_context_set_image(i);
|
||||
}
|
||||
depth = __evas_render_create_dest_buf(disp,
|
||||
__evas_visual,
|
||||
im->current.w,
|
||||
im->current.h,
|
||||
screen,
|
||||
&(im->pmap),
|
||||
&(im->pic));
|
||||
__evas_render_dump_current_image_to_pixmap(disp,
|
||||
im->pmap,
|
||||
__evas_visual,
|
||||
depth,
|
||||
im->current.w,
|
||||
im->current.h);
|
||||
imlib_free_image();
|
||||
}
|
||||
/* if (im->has_alpha)*/
|
||||
XRenderComposite (disp,
|
||||
PictOpOver,
|
||||
im->pic,
|
||||
None,
|
||||
up->pic,
|
||||
xx, yy, 0, 0,
|
||||
dx - up->x, dy - up->y,
|
||||
dw, dh);
|
||||
/* WOW... PictOpSrc is SLOOOOOOOOW
|
||||
else
|
||||
XRenderComposite (disp,
|
||||
PictOpSrc,
|
||||
im->pic,
|
||||
None,
|
||||
up->pic,
|
||||
xx, yy, 0, 0,
|
||||
dx - up->x, dy - up->y,
|
||||
dw, dh);
|
||||
*/ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,19 +664,31 @@ __evas_render_image_draw(Evas_Render_Image *im,
|
|||
int
|
||||
__evas_render_image_get_width(Evas_Render_Image *im)
|
||||
{
|
||||
return 0;
|
||||
return im->w;
|
||||
}
|
||||
|
||||
int
|
||||
__evas_render_image_get_height(Evas_Render_Image *im)
|
||||
{
|
||||
return 0;
|
||||
return im->h;
|
||||
}
|
||||
|
||||
void
|
||||
__evas_render_image_set_borders(Evas_Render_Image *im, int left, int right,
|
||||
int top, int bottom)
|
||||
{
|
||||
if ((left == im->current.border.l) &&
|
||||
(right == im->current.border.r) &&
|
||||
(top == im->current.border.t) &&
|
||||
(bottom == im->current.border.b)) return;
|
||||
if (im->pmap) XFreePixmap(im->disp, im->pmap);
|
||||
if (im->pic) XRenderFreePicture(im->disp, im->pic);
|
||||
im->pmap = 0;
|
||||
im->pic = 0;
|
||||
im->current.border.l = left;
|
||||
im->current.border.r = right;
|
||||
im->current.border.t = top;
|
||||
im->current.border.b = bottom;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -620,9 +1150,6 @@ __evas_render_poly_draw (Display *disp, Imlib_Image dstim, Window win,
|
|||
/* general externals *********************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static Visual *__evas_visual = NULL;
|
||||
static Colormap __evas_cmap = 0;
|
||||
|
||||
void
|
||||
__evas_render_set_clip_rect(int on, int x, int y, int w, int h, int r, int g, int b, int a)
|
||||
{
|
||||
|
@ -651,9 +1178,13 @@ __evas_render_flush_draw(Display *disp, Imlib_Image dstim, Window win)
|
|||
for(l = drawable_list; l; l = l->next)
|
||||
{
|
||||
Evas_Render_Drawable *dr;
|
||||
XRenderPictFormat *format, *format_color;
|
||||
Picture picture;
|
||||
|
||||
dr = l->data;
|
||||
|
||||
format = XRenderFindVisualFormat (disp, __evas_visual);
|
||||
if (!format) printf("eek no format!\n");
|
||||
picture = __evas_render_create_picuture(disp, win, format);
|
||||
if ((dr->win == win) && (dr->disp == disp))
|
||||
{
|
||||
Evas_List ll;
|
||||
|
@ -663,14 +1194,29 @@ __evas_render_flush_draw(Display *disp, Imlib_Image dstim, Window win)
|
|||
Evas_Render_Update *up;
|
||||
|
||||
up = ll->data;
|
||||
|
||||
if (up->pmap)
|
||||
{
|
||||
/* WOW. PictOpSrc is slooow!
|
||||
XRenderComposite(disp, PictOpSrc,
|
||||
up->pic, None, picture,
|
||||
0, 0, 0, 0, up->x, up->y,
|
||||
up->w, up->h);
|
||||
*/ XRenderComposite(disp, PictOpOver,
|
||||
up->pic, None, picture,
|
||||
0, 0, 0, 0, up->x, up->y,
|
||||
up->w, up->h);
|
||||
XRenderFreePicture(disp, up->pic);
|
||||
XFreePixmap(disp, up->pmap);
|
||||
}
|
||||
free(up);
|
||||
}
|
||||
if (dr->tmp_images)
|
||||
dr->tmp_images = evas_list_free(dr->tmp_images);
|
||||
}
|
||||
XRenderFreePicture(disp, picture);
|
||||
free(dr);
|
||||
}
|
||||
__evas_render_sync(disp);
|
||||
if (drawable_list)
|
||||
drawable_list = evas_list_free(drawable_list);
|
||||
drawable_list = NULL;
|
||||
|
@ -757,6 +1303,9 @@ __evas_render_draw_add_rect(Display *disp, Imlib_Image dstim, Window win,
|
|||
up->y = y;
|
||||
up->w = w;
|
||||
up->h = h;
|
||||
up->drawable = win;
|
||||
up->disp = disp;
|
||||
up->pmap = 0;
|
||||
dr->tmp_images = evas_list_append(dr->tmp_images, up);
|
||||
}
|
||||
return;
|
||||
|
@ -774,6 +1323,9 @@ __evas_render_draw_add_rect(Display *disp, Imlib_Image dstim, Window win,
|
|||
up->y = y;
|
||||
up->w = w;
|
||||
up->h = h;
|
||||
up->drawable = win;
|
||||
up->disp = disp;
|
||||
up->pmap = 0;
|
||||
drawable_list = evas_list_append(drawable_list, dr);
|
||||
dr->tmp_images = evas_list_append(dr->tmp_images, up);
|
||||
}
|
||||
|
|
|
@ -2,15 +2,19 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
|
||||
#include "Evas_private.h"
|
||||
#include "Evas.h"
|
||||
|
@ -38,16 +42,22 @@ typedef void Evas_Render_Graident;
|
|||
struct _evas_render_image
|
||||
{
|
||||
char *file;
|
||||
Imlib_Image image;
|
||||
int references;
|
||||
int w, h;
|
||||
Display *disp;
|
||||
struct {
|
||||
int w, h;
|
||||
struct
|
||||
{
|
||||
int l, r, t, b;
|
||||
} border;
|
||||
int smooth;
|
||||
int pr, pg, pb, pa;
|
||||
} current;
|
||||
Picture pic;
|
||||
Pixmap pmap;
|
||||
int has_alpha;
|
||||
struct
|
||||
{
|
||||
int l, r, t, b;
|
||||
} border;
|
||||
};
|
||||
|
||||
typedef struct _evas_render_drawable Evas_Render_Drawable;
|
||||
|
@ -62,6 +72,8 @@ struct _evas_render_drawable
|
|||
|
||||
struct _evas_render_update
|
||||
{
|
||||
Display *disp;
|
||||
Drawable drawable;
|
||||
Picture pic;
|
||||
Pixmap pmap;
|
||||
int x, y, w, h;
|
||||
|
|
|
@ -175,6 +175,17 @@ evas_add_text(Evas e, char *font, int size, char *text)
|
|||
layer->objects = evas_list_append(layer->objects, o);
|
||||
return o;
|
||||
}
|
||||
if (layer->layer > o->current.layer)
|
||||
{
|
||||
Evas_Layer layer_new;
|
||||
|
||||
layer_new = malloc(sizeof(struct _Evas_Layer));
|
||||
memset(layer_new, 0, sizeof(struct _Evas_Layer));
|
||||
e->layers = evas_list_prepend_relative(e->layers, layer_new, layer);
|
||||
layer_new->objects = evas_list_append(layer_new->objects, o);
|
||||
layer_new->layer = o->current.layer;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
layer = malloc(sizeof(struct _Evas_Layer));
|
||||
|
|
|
@ -115,7 +115,7 @@ main(int argc, char **argv)
|
|||
i++;
|
||||
if (!strcmp(argv[i], "x11"))
|
||||
evas_set_output_method(e, RENDER_METHOD_BASIC_HARDWARE);
|
||||
else if (!strcmp(argv[i], "alpha"))
|
||||
else if (!strcmp(argv[i], "render"))
|
||||
evas_set_output_method(e, RENDER_METHOD_ALPHA_HARDWARE);
|
||||
else if (!strcmp(argv[i], "soft"))
|
||||
evas_set_output_method(e, RENDER_METHOD_ALPHA_SOFTWARE);
|
||||
|
|
Loading…
Reference in New Issue