forked from enlightenment/efl
parent
c802275f05
commit
97e973c6e8
|
@ -519,7 +519,17 @@ __evas_gl_image_cache_get_size(Display *disp)
|
|||
disp = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
__evas_gl_image_get_width(Evas_GL_Image *im)
|
||||
{
|
||||
return im->w;
|
||||
}
|
||||
|
||||
int
|
||||
__evas_gl_image_get_height(Evas_GL_Image *im)
|
||||
{
|
||||
return im->h;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -712,3 +722,9 @@ __evas_gl_init(Display *disp)
|
|||
/* __evas_gl_cx = glXCreateContext(disp, __evas_vi, NULL, GL_FALSE);*/
|
||||
}
|
||||
|
||||
void
|
||||
__evas_gl_draw_add_rect(Display *disp, Window win,
|
||||
int x, int y, int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,8 @@ void __evas_gl_image_cache_empty(Display *disp);
|
|||
void __evas_gl_image_cache_set_size(Display *disp, int size);
|
||||
int __evas_gl_image_cache_get_size(Display *disp);
|
||||
void __evas_gl_image_draw(Evas_GL_Image *im, Display *disp, Window w, int win_w, int win_h, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h);
|
||||
int __evas_gl_image_get_width(Evas_GL_Image *im);
|
||||
int __evas_gl_image_get_height(Evas_GL_Image *im);
|
||||
|
||||
/********/
|
||||
/* text */
|
||||
|
@ -117,4 +119,4 @@ void __evas_gl_sync(Display *disp);
|
|||
Visual *__evas_gl_get_visual(Display *disp, int screen);
|
||||
XVisualInfo *__evas_gl_get_visual_info(Display *disp, int screen);
|
||||
Colormap __evas_gl_get_colormap(Display *disp, int screen);
|
||||
|
||||
void __evas_gl_draw_add_rect(Display *disp, Window win, int x, int y, int w, int h);
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
#include "evas_imlib_routines.h"
|
||||
|
||||
#define SPANS_COMMON(x1, w1, x2, w2) \
|
||||
(!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1)))))
|
||||
#define RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) \
|
||||
((SPANS_COMMON((x), (w), (xx), (ww))) && (SPANS_COMMON((y), (h), (yy), (hh))))
|
||||
|
||||
static Evas_List drawable_list = NULL;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* image internals ***********************************************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -59,10 +66,53 @@ __evas_imlib_image_draw(Evas_Imlib_Image *im,
|
|||
int src_x, int src_y, int src_w, int src_h,
|
||||
int dst_x, int dst_y, int dst_w, int dst_h)
|
||||
{
|
||||
Evas_List l;
|
||||
|
||||
for(l = drawable_list; l; l = l->next)
|
||||
{
|
||||
Evas_Imlib_Drawable *dr;
|
||||
|
||||
dr = l->data;
|
||||
|
||||
if ((dr->win == w) && (dr->disp == disp))
|
||||
{
|
||||
Evas_List ll;
|
||||
|
||||
for (ll = dr->tmp_images; ll; ll = ll->next)
|
||||
{
|
||||
Evas_Imlib_Update *up;
|
||||
|
||||
up = ll->data;
|
||||
|
||||
/* if image intersects image update - render */
|
||||
if (RECTS_INTERSECT(up->x, up->y, up->w, up->h,
|
||||
dst_x, dst_y, dst_w, dst_h))
|
||||
{
|
||||
if (!up->image)
|
||||
up->image = imlib_create_image(up->w, up->h);
|
||||
imlib_context_set_image(up->image);
|
||||
imlib_blend_image_onto_image(im, 0,
|
||||
src_x, src_y, src_w, src_h,
|
||||
dst_x, dst_y, dst_w, dst_h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
__evas_imlib_image_get_width(Evas_Imlib_Image *im)
|
||||
{
|
||||
imlib_context_set_image((Imlib_Image)im);
|
||||
return imlib_image_get_width();
|
||||
}
|
||||
|
||||
int
|
||||
__evas_imlib_image_get_height(Evas_Imlib_Image *im)
|
||||
{
|
||||
imlib_context_set_image((Imlib_Image)im);
|
||||
return imlib_image_get_height();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -202,6 +252,9 @@ __evas_imlib_text_draw(Evas_Imlib_Font *fn, Display *disp, Window win, int x, in
|
|||
/* general externals *********************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static Visual *__evas_visual;
|
||||
static Colormap __evas_cmap;
|
||||
|
||||
void
|
||||
__evas_imlib_sync(Display *disp)
|
||||
{
|
||||
|
@ -211,8 +264,47 @@ __evas_imlib_sync(Display *disp)
|
|||
void
|
||||
__evas_imlib_flush_draw(Display *disp, Window win)
|
||||
{
|
||||
Evas_List l;
|
||||
|
||||
imlib_context_set_display(disp);
|
||||
imlib_context_set_visual(__evas_visual);
|
||||
imlib_context_set_colormap(__evas_cmap);
|
||||
imlib_context_set_drawable(win);
|
||||
|
||||
for(l = drawable_list; l; l = l->next)
|
||||
{
|
||||
Evas_Imlib_Drawable *dr;
|
||||
|
||||
dr = l->data;
|
||||
|
||||
if ((dr->win == win) && (dr->disp == disp))
|
||||
{
|
||||
Evas_List ll;
|
||||
|
||||
for (ll = dr->tmp_images; ll; ll = ll->next)
|
||||
{
|
||||
Evas_Imlib_Update *up;
|
||||
|
||||
up = ll->data;
|
||||
|
||||
if (up->image)
|
||||
{
|
||||
imlib_context_set_image(up->image);
|
||||
imlib_render_image_on_drawable(up->x, up->y);
|
||||
imlib_free_image();
|
||||
}
|
||||
free(up);
|
||||
}
|
||||
if (dr->tmp_images)
|
||||
dr->tmp_images = evas_list_free(dr->tmp_images);
|
||||
}
|
||||
free(dr);
|
||||
}
|
||||
if (drawable_list)
|
||||
drawable_list = evas_list_free(drawable_list);
|
||||
drawable_list = NULL;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
__evas_imlib_capable(Display *disp)
|
||||
|
@ -224,7 +316,9 @@ Visual *
|
|||
__evas_imlib_get_visual(Display *disp, int screen)
|
||||
{
|
||||
int depth;
|
||||
return imlib_get_best_visual(disp, screen, &depth);
|
||||
|
||||
__evas_visual = imlib_get_best_visual(disp, screen, &depth);
|
||||
return __evas_visual;
|
||||
}
|
||||
|
||||
XVisualInfo *
|
||||
|
@ -244,12 +338,60 @@ __evas_imlib_get_visual_info(Display *disp, int screen)
|
|||
Colormap
|
||||
__evas_imlib_get_colormap(Display *disp, int screen)
|
||||
{
|
||||
return DefaultColormap(disp, screen);
|
||||
__evas_cmap = DefaultColormap(disp, screen);
|
||||
return __evas_cmap;
|
||||
}
|
||||
|
||||
void
|
||||
__evas_imlib_init(Display *disp)
|
||||
{
|
||||
__evas_imlib_get_visual(disp, 0);
|
||||
__evas_imlib_get_visual(disp, 0);
|
||||
__evas_imlib_get_colormap(disp, 0);
|
||||
imlib_context_set_display(disp);
|
||||
}
|
||||
|
||||
void
|
||||
__evas_imlib_draw_add_rect(Display *disp, Window win,
|
||||
int x, int y, int w, int h)
|
||||
{
|
||||
Evas_List l;
|
||||
|
||||
for(l = drawable_list; l; l = l->next)
|
||||
{
|
||||
Evas_Imlib_Drawable *dr;
|
||||
|
||||
dr = l->data;
|
||||
|
||||
if ((dr->win == win) && (dr->disp == disp))
|
||||
{
|
||||
Evas_Imlib_Update *up;
|
||||
|
||||
up = malloc(sizeof(Evas_Imlib_Update));
|
||||
up->x = x;
|
||||
up->y = y;
|
||||
up->w = w;
|
||||
up->h = h;
|
||||
up->image = NULL;
|
||||
dr->tmp_images = evas_list_append(dr->tmp_images, up);
|
||||
}
|
||||
return;
|
||||
}
|
||||
{
|
||||
Evas_Imlib_Drawable *dr;
|
||||
Evas_Imlib_Update *up;
|
||||
|
||||
dr = malloc(sizeof(Evas_Imlib_Drawable));
|
||||
dr->win = win;
|
||||
dr->disp = disp;
|
||||
dr->tmp_images = NULL;
|
||||
up = malloc(sizeof(Evas_Imlib_Update));
|
||||
up->x = x;
|
||||
up->y = y;
|
||||
up->w = w;
|
||||
up->h = h;
|
||||
up->image = NULL;
|
||||
drawable_list = evas_list_append(drawable_list, dr);
|
||||
dr->tmp_images = evas_list_append(dr->tmp_images, up);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,22 @@
|
|||
typedef void Evas_Imlib_Image;
|
||||
typedef void Evas_Imlib_Font;
|
||||
|
||||
typedef struct _evas_imlib_drawable Evas_Imlib_Drawable;
|
||||
typedef struct _evas_imlib_update Evas_Imlib_Update;
|
||||
|
||||
struct _evas_imlib_drawable
|
||||
{
|
||||
Display *disp;
|
||||
Window win;
|
||||
Evas_List tmp_images;
|
||||
};
|
||||
|
||||
struct _evas_imlib_update
|
||||
{
|
||||
Imlib_Image image;
|
||||
int x, y, w, h;
|
||||
};
|
||||
|
||||
/***************/
|
||||
/* image stuff */
|
||||
/***************/
|
||||
|
@ -27,6 +43,8 @@ void __evas_imlib_image_cache_empty(Display *disp);
|
|||
void __evas_imlib_image_cache_set_size(Display *disp, int size);
|
||||
int __evas_imlib_image_cache_get_size(Display *disp);
|
||||
void __evas_imlib_image_draw(Evas_Imlib_Image *im, Display *disp, Window w, int win_w, int win_h, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h);
|
||||
int __evas_imlib_image_get_width(Evas_Imlib_Image *im);
|
||||
int __evas_imlib_image_get_height(Evas_Imlib_Image *im);
|
||||
|
||||
/********/
|
||||
/* text */
|
||||
|
@ -63,4 +81,5 @@ void __evas_imlib_sync(Display *disp);
|
|||
Visual *__evas_imlib_get_visual(Display *disp, int screen);
|
||||
XVisualInfo *__evas_imlib_get_visual_info(Display *disp, int screen);
|
||||
Colormap __evas_imlib_get_colormap(Display *disp, int screen);
|
||||
void __evas_imlib_draw_add_rect(Display *disp, Window win, int x, int y, int w, int h);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <Evas.h>
|
||||
#include "../src/evas_gl_routines.h"
|
||||
#include "../src/evas_imlib_routines.h"
|
||||
#include <math.h>
|
||||
|
||||
double get_time(void);
|
||||
|
@ -23,9 +23,9 @@ main(int argc, char **argv)
|
|||
int win_w, win_h;
|
||||
|
||||
d = XOpenDisplay(NULL);
|
||||
__evas_gl_init(d);
|
||||
vis = __evas_gl_get_visual(d, DefaultScreen(d));
|
||||
cmap = __evas_gl_get_colormap(d, DefaultScreen(d));
|
||||
__evas_imlib_init(d);
|
||||
vis = __evas_imlib_get_visual(d, DefaultScreen(d));
|
||||
cmap = __evas_imlib_get_colormap(d, DefaultScreen(d));
|
||||
|
||||
win_w = 640; win_h = 480;
|
||||
{
|
||||
|
@ -38,25 +38,25 @@ main(int argc, char **argv)
|
|||
win = XCreateWindow(d,
|
||||
RootWindow(d, DefaultScreen(d)),
|
||||
0, 0, win_w, win_h, 0,
|
||||
(__evas_gl_get_visual_info(d, DefaultScreen(d)))->depth,
|
||||
(__evas_imlib_get_visual_info(d, DefaultScreen(d)))->depth,
|
||||
InputOutput,
|
||||
vis,
|
||||
CWColormap | CWBorderPixel | CWEventMask,
|
||||
&att);
|
||||
XMapWindow(d, win);
|
||||
}
|
||||
if (__evas_gl_capable(d))
|
||||
if (__evas_imlib_capable(d))
|
||||
{
|
||||
int a = 0;
|
||||
double t1, t2;
|
||||
Evas_GL_Image *i[4], *bg, *l;
|
||||
Evas_Imlib_Image *i[4], *bg, *l;
|
||||
|
||||
bg = __evas_gl_image_new_from_file(d, "img/sky001.png");
|
||||
i[0] = __evas_gl_image_new_from_file(d, "img/fog1001.png");
|
||||
i[1] = __evas_gl_image_new_from_file(d, "img/fog2001.png");
|
||||
i[2] = __evas_gl_image_new_from_file(d, "img/fog3001.png");
|
||||
i[3] = __evas_gl_image_new_from_file(d, "img/fog4001.png");
|
||||
l = __evas_gl_image_new_from_file(d, "img/logo001.png");
|
||||
bg = __evas_imlib_image_new_from_file(d, "img/sky001.png");
|
||||
i[0] = __evas_imlib_image_new_from_file(d, "img/fog1001.png");
|
||||
i[1] = __evas_imlib_image_new_from_file(d, "img/fog2001.png");
|
||||
i[2] = __evas_imlib_image_new_from_file(d, "img/fog3001.png");
|
||||
i[3] = __evas_imlib_image_new_from_file(d, "img/fog4001.png");
|
||||
l = __evas_imlib_image_new_from_file(d, "img/logo001.png");
|
||||
if (!bg)
|
||||
{
|
||||
printf("cannot find images!\n");
|
||||
|
@ -69,8 +69,9 @@ main(int argc, char **argv)
|
|||
|
||||
if (a == 0)
|
||||
t1 = get_time();
|
||||
__evas_gl_image_draw(bg, d, win, win_w, win_h,
|
||||
0, 0, bg->w, bg->h,
|
||||
__evas_imlib_draw_add_rect(d, win, 0, 0, win_w, win_h);
|
||||
__evas_imlib_image_draw(bg, d, win, win_w, win_h,
|
||||
0, 0, __evas_imlib_image_get_width(bg), __evas_imlib_image_get_height(bg),
|
||||
0, 0, win_w, win_h);
|
||||
for (k = 0; k < 4; k++)
|
||||
{
|
||||
|
@ -80,17 +81,17 @@ main(int argc, char **argv)
|
|||
xx = (((k + 1) * a) / 2) % win_w;
|
||||
yy = 0;
|
||||
if (k == 2)
|
||||
__evas_gl_image_draw(l, d, win, win_w, win_h,
|
||||
0, 0, l->w, l->h,
|
||||
(win_w - l->w) / 2, (win_h - l->h) /2, l->w, l->h);
|
||||
__evas_gl_image_draw(i[j], d, win, win_w, win_h,
|
||||
0, 0, i[j]->w, i[j]->h,
|
||||
__evas_imlib_image_draw(l, d, win, win_w, win_h,
|
||||
0, 0, __evas_imlib_image_get_width(l), __evas_imlib_image_get_height(l),
|
||||
(win_w - __evas_imlib_image_get_width(l)) / 2, (win_h - __evas_imlib_image_get_height(l)) /2, __evas_imlib_image_get_width(l), __evas_imlib_image_get_height(l));
|
||||
__evas_imlib_image_draw(i[j], d, win, win_w, win_h,
|
||||
0, 0, __evas_imlib_image_get_width(i[j]), __evas_imlib_image_get_height(i[j]),
|
||||
xx, yy, win_w, win_h);
|
||||
__evas_gl_image_draw(i[j], d, win, win_w, win_h,
|
||||
0, 0, i[j]->w, i[j]->h,
|
||||
__evas_imlib_image_draw(i[j], d, win, win_w, win_h,
|
||||
0, 0, __evas_imlib_image_get_width(i[j]), __evas_imlib_image_get_height(i[j]),
|
||||
xx - win_w, yy, win_w, win_h);
|
||||
}
|
||||
__evas_gl_flush_draw(d, win);
|
||||
__evas_imlib_flush_draw(d, win);
|
||||
a++;
|
||||
if (a == (win_w * 4))
|
||||
{
|
||||
|
@ -99,7 +100,7 @@ main(int argc, char **argv)
|
|||
|
||||
t2 = get_time();
|
||||
tim = t2 - t1;
|
||||
pixels = (((((double)k + 1) * (double)win_w * (double)win_h) + ((double)l->w * (double)l->h)) * (double)a);
|
||||
pixels = (((((double)k + 1) * (double)win_w * (double)win_h) + ((double)__evas_imlib_image_get_width(l) * (double)__evas_imlib_image_get_height(l))) * (double)a);
|
||||
printf("%3.0f pixels in %3.3f seconds\n", pixels, tim);
|
||||
printf("..... %4.1f Mpixels/second\n", pixels / (tim * 1000000));
|
||||
a = 0;
|
||||
|
|
Loading…
Reference in New Issue