forked from enlightenment/efl
whooooppppppeeeeeeeeeeeeeeeeee!
gl image enign handles disparate src and dest rects fine. it also handles border scaling for images.... after a lot fo work and fiddling. SVN revision: 3082
This commit is contained in:
parent
90931dce51
commit
905635f680
|
@ -3,6 +3,7 @@ AM_CONFIG_HEADER(config.h)
|
||||||
AM_INIT_AUTOMAKE(evas, 0.0.1)
|
AM_INIT_AUTOMAKE(evas, 0.0.1)
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AM_PROG_CC_STDC
|
AM_PROG_CC_STDC
|
||||||
|
AM_WITH_DMALLOC
|
||||||
AC_C_CONST
|
AC_C_CONST
|
||||||
AM_ENABLE_SHARED
|
AM_ENABLE_SHARED
|
||||||
AM_PROG_LIBTOOL
|
AM_PROG_LIBTOOL
|
||||||
|
|
|
@ -16,7 +16,6 @@ static int __evas_gl_configuration[] =
|
||||||
static void __evas_gl_image_copy_image_rect_to_texture(Evas_GL_Image *im, int x, int y, int w, int h, int tw, int th, GLuint texture);
|
static void __evas_gl_image_copy_image_rect_to_texture(Evas_GL_Image *im, int x, int y, int w, int h, int tw, int th, GLuint texture);
|
||||||
static void __evas_gl_image_move_state_data_to_texture(Evas_GL_Image *im);
|
static void __evas_gl_image_move_state_data_to_texture(Evas_GL_Image *im);
|
||||||
static void __evas_gl_image_calc_tex_and_poly(Evas_GL_Image *im, int x, double *x1, double *x2, int *tx, int *txx, double *dtx, double *dtxx, int tw, int w, int edge);
|
static void __evas_gl_image_calc_tex_and_poly(Evas_GL_Image *im, int x, double *x1, double *x2, int *tx, int *txx, double *dtx, double *dtxx, int tw, int w, int edge);
|
||||||
static void __evas_gl_image_set_context_for_dest(Evas_GL_Image *im, Display *disp, Window w, int win_w, int win_h);
|
|
||||||
static Evas_GL_Image *__evas_gl_create_image(void);
|
static Evas_GL_Image *__evas_gl_create_image(void);
|
||||||
static Evas_GL_Image *__evas_gl_image_create_from_file(Display *disp, char *file);
|
static Evas_GL_Image *__evas_gl_image_create_from_file(Display *disp, char *file);
|
||||||
static void __evas_gl_image_destroy(Evas_GL_Image *im);
|
static void __evas_gl_image_destroy(Evas_GL_Image *im);
|
||||||
|
@ -114,9 +113,22 @@ __evas_gl_image_copy_image_rect_to_texture(Evas_GL_Image *im, int x, int y,
|
||||||
((*p1 & 0x000000ff) << 16);
|
((*p1 & 0x000000ff) << 16);
|
||||||
p2++; p1++;
|
p2++; p1++;
|
||||||
}
|
}
|
||||||
|
if (tx < tw)
|
||||||
|
*p2 = p2[-1];
|
||||||
}
|
}
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0,
|
if (ty < th)
|
||||||
|
{
|
||||||
|
p1 = data + ((ty - 1) * tw);
|
||||||
|
p2 = data + (ty * tw);
|
||||||
|
for (tx = 0; tx < w; tx++)
|
||||||
|
{
|
||||||
|
*p2 = *p1;
|
||||||
|
p2++; p1++;
|
||||||
|
}
|
||||||
|
if (tx < tw)
|
||||||
|
*p2 = p2[-1];
|
||||||
|
}
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tw, th, 0,
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +147,6 @@ __evas_gl_image_move_state_data_to_texture(Evas_GL_Image *im)
|
||||||
{
|
{
|
||||||
imlib_context_set_image(image);
|
imlib_context_set_image(image);
|
||||||
im->data = imlib_image_get_data_for_reading_only();
|
im->data = imlib_image_get_data_for_reading_only();
|
||||||
imlib_free_image();
|
|
||||||
image_data = 1;
|
image_data = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,52 +296,6 @@ __evas_gl_image_calc_tex_and_poly(Evas_GL_Image *im, int x, double *x1, double *
|
||||||
*x2 = (double)w;
|
*x2 = (double)w;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
__evas_gl_image_set_context_for_dest(Evas_GL_Image *im, Display *disp, Window w,
|
|
||||||
int win_w, int win_h)
|
|
||||||
{
|
|
||||||
if ((__evas_current_win != w) || (__evas_current_disp != disp))
|
|
||||||
{
|
|
||||||
glXMakeCurrent(disp, w, im->context);
|
|
||||||
__evas_current_disp = disp;
|
|
||||||
__evas_current_win = w;
|
|
||||||
im->buffer.dest = w;
|
|
||||||
}
|
|
||||||
if (im->alpha)
|
|
||||||
{
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
}
|
|
||||||
glEnable(GL_DITHER);
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glShadeModel(GL_FLAT);
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
|
||||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
|
||||||
/* why doesnt scissor work ? */
|
|
||||||
/*
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
|
||||||
glScissor(dst_x, win_h - dst_y - 1, dst_w, dst_h);
|
|
||||||
*/
|
|
||||||
if ((win_w != im->buffer.dest_w) || (win_h != im->buffer.dest_h))
|
|
||||||
{
|
|
||||||
glViewport(0, 0, win_w, win_h);
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
glOrtho(0, win_w, 0, win_h, -1, 1);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glLoadIdentity();
|
|
||||||
glScalef(1, -1, 1);
|
|
||||||
glTranslatef(0, -win_h, 0);
|
|
||||||
im->buffer.dest_w = win_w;
|
|
||||||
im->buffer.dest_h = win_h;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Evas_GL_Image *
|
static Evas_GL_Image *
|
||||||
__evas_gl_create_image(void)
|
__evas_gl_create_image(void)
|
||||||
{
|
{
|
||||||
|
@ -437,16 +402,57 @@ __evas_gl_image_draw(Evas_GL_Image *im,
|
||||||
int x, y, i;
|
int x, y, i;
|
||||||
double dx, dy, dw, dh;
|
double dx, dy, dw, dh;
|
||||||
|
|
||||||
|
if ((src_w <= 0) || (src_h <= 0) || (dst_w <= 0) || (dst_h <= 0)) return;
|
||||||
if (im->state != EVAS_STATE_TEXTURE)
|
if (im->state != EVAS_STATE_TEXTURE)
|
||||||
__evas_gl_image_move_state_data_to_texture(im);
|
__evas_gl_image_move_state_data_to_texture(im);
|
||||||
__evas_gl_image_set_context_for_dest(im, disp, w, win_w, win_h);
|
if ((__evas_current_win != w) || (__evas_current_disp != disp))
|
||||||
/* project src and dst rects to overall dest rect */
|
{
|
||||||
|
glXMakeCurrent(disp, w, im->context);
|
||||||
|
__evas_current_disp = disp;
|
||||||
|
__evas_current_win = w;
|
||||||
|
im->buffer.dest = w;
|
||||||
|
}
|
||||||
|
if (im->alpha)
|
||||||
|
{
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
}
|
||||||
|
|
||||||
|
src_y = im->h - src_h - src_y;
|
||||||
|
|
||||||
dw = (((double)dst_w * (double)im->w)/ (double)src_w);
|
dw = (((double)dst_w * (double)im->w)/ (double)src_w);
|
||||||
dx = (double)dst_x - (((double)dst_w * (double)src_x)/ (double)src_w);
|
dx = (double)dst_x - (((double)dst_w * (double)src_x)/ (double)src_w);
|
||||||
|
|
||||||
dh = (((double)dst_h * (double)im->h)/ (double)src_h);
|
dh = (((double)dst_h * (double)im->h)/ (double)src_h);
|
||||||
dy = (double)dst_y - (((double)dst_h * (double)src_y)/ (double)src_h);
|
dy = (double)dst_y - (((double)dst_h * (double)src_y)/ (double)src_h);
|
||||||
|
|
||||||
|
glEnable(GL_DITHER);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glShadeModel(GL_FLAT);
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||||
|
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||||
|
|
||||||
|
glViewport(dst_x, win_h - dst_y - dst_h, dst_w, dst_h);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(0, dst_w, 0, dst_h, -1, 1);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
glScalef(1, -1, 1);
|
||||||
|
glTranslatef((double)(-dst_x), (dst_y - dy) -dy - dh
|
||||||
|
, 0);
|
||||||
|
im->buffer.dest_w = win_w;
|
||||||
|
im->buffer.dest_h = win_h;
|
||||||
|
|
||||||
|
/* project src and dst rects to overall dest rect */
|
||||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||||
|
if ((im->direct) ||
|
||||||
|
((im->bl == 0) && (im->br == 0) && (im->bt == 0) && (im->bb == 0)))
|
||||||
|
{
|
||||||
for (y = 0, i = 0; y < im->texture.h; y++)
|
for (y = 0, i = 0; y < im->texture.h; y++)
|
||||||
{
|
{
|
||||||
for (x = 0; x < im->texture.w; x++, i++)
|
for (x = 0; x < im->texture.w; x++, i++)
|
||||||
|
@ -456,11 +462,13 @@ __evas_gl_image_draw(Evas_GL_Image *im,
|
||||||
double dtx, dtxx, dty, dtyy;
|
double dtx, dtxx, dty, dtyy;
|
||||||
|
|
||||||
|
|
||||||
__evas_gl_image_calc_tex_and_poly(im, x, &x1, &x2, &tx, &txx,
|
__evas_gl_image_calc_tex_and_poly(im, x, &x1, &x2,
|
||||||
|
&tx, &txx,
|
||||||
&dtx, &dtxx,
|
&dtx, &dtxx,
|
||||||
im->texture.w, im->w,
|
im->texture.w, im->w,
|
||||||
im->texture.edge_w);
|
im->texture.edge_w);
|
||||||
__evas_gl_image_calc_tex_and_poly(im, y, &y1, &y2, &ty, &tyy,
|
__evas_gl_image_calc_tex_and_poly(im, y, &y1, &y2,
|
||||||
|
&ty, &tyy,
|
||||||
&dty, &dtyy,
|
&dty, &dtyy,
|
||||||
im->texture.h, im->h,
|
im->texture.h, im->h,
|
||||||
im->texture.edge_h);
|
im->texture.edge_h);
|
||||||
|
@ -477,7 +485,57 @@ __evas_gl_image_draw(Evas_GL_Image *im,
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* glDisable(GL_SCISSOR_TEST);*/
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int bl, br, bt, bb;
|
||||||
|
|
||||||
|
im->direct = 1;
|
||||||
|
bl = im->bl;
|
||||||
|
br = im->br;
|
||||||
|
bt = im->bt;
|
||||||
|
bb = im->bb;
|
||||||
|
if ((bl + br) > (int)dw)
|
||||||
|
{
|
||||||
|
bl = (int)dw / 2;
|
||||||
|
br = (int)dw - bl;
|
||||||
|
}
|
||||||
|
if ((bt + bb) > (int)dh)
|
||||||
|
{
|
||||||
|
bt = (int)dh / 2;
|
||||||
|
bb = (int)dh - bt;
|
||||||
|
}
|
||||||
|
__evas_gl_image_draw(im, disp, w, win_w, win_h,
|
||||||
|
0, 0, bl, bt,
|
||||||
|
dx, dy, bl, bt);
|
||||||
|
__evas_gl_image_draw(im, disp, w, win_w, win_h,
|
||||||
|
bl, 0, im->w - bl - br, bt,
|
||||||
|
dx + bl, dy, dw - bl - br, bt);
|
||||||
|
__evas_gl_image_draw(im, disp, w, win_w, win_h,
|
||||||
|
im->w - br, 0, br, bt,
|
||||||
|
dx + dw - br, dy, br, bt);
|
||||||
|
|
||||||
|
__evas_gl_image_draw(im, disp, w, win_w, win_h,
|
||||||
|
0, bt, bl, im->h - bt - bb,
|
||||||
|
dx, dy + bt, bl, dh - bt - bb);
|
||||||
|
__evas_gl_image_draw(im, disp, w, win_w, win_h,
|
||||||
|
bl, bt, im->w - bl - br, im->h - bt - bb,
|
||||||
|
dx + bl, dy + bt, dw - bl - br, dh - bt - bb);
|
||||||
|
__evas_gl_image_draw(im, disp, w, win_w, win_h,
|
||||||
|
im->w - br, bt, br, im->h - bt - bb,
|
||||||
|
dx + dw - br, dy + bt, br, dh - bt - bb);
|
||||||
|
|
||||||
|
__evas_gl_image_draw(im, disp, w, win_w, win_h,
|
||||||
|
0, im->h - bb, bl, bb,
|
||||||
|
dx, dy + dh - bb, bl, bb);
|
||||||
|
__evas_gl_image_draw(im, disp, w, win_w, win_h,
|
||||||
|
bl, im->h - bb, im->w - bl - br, bb,
|
||||||
|
dx + bl, dy + dh - bb, dw - bl - br, bb);
|
||||||
|
__evas_gl_image_draw(im, disp, w, win_w, win_h,
|
||||||
|
im->w - br, im->h - bb, br, bb,
|
||||||
|
dx + dw - br, dy + dh - bb, br, bb);
|
||||||
|
im->direct = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Evas_GL_Image *
|
Evas_GL_Image *
|
||||||
|
@ -569,7 +627,25 @@ __evas_gl_image_get_height(Evas_GL_Image *im)
|
||||||
return im->h;
|
return im->h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
__evas_gl_image_set_borders(Evas_GL_Image *im, int left, int right,
|
||||||
|
int top, int bottom)
|
||||||
|
{
|
||||||
|
im->bl = left;
|
||||||
|
im->br = right;
|
||||||
|
im->bt = top;
|
||||||
|
im->bb = bottom;
|
||||||
|
if ((im->bl + im->br) > im->w)
|
||||||
|
{
|
||||||
|
im->bl = im->w / 2;
|
||||||
|
im->br = im->w - im->bl;
|
||||||
|
}
|
||||||
|
if ((im->bt + im->bb) > im->h)
|
||||||
|
{
|
||||||
|
im->bt = im->h / 2;
|
||||||
|
im->bb = im->h - im->bt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -642,8 +718,6 @@ __evas_gl_text_paste(Evas_GL_Font *f, char *text,
|
||||||
bb = (float)b / 255;
|
bb = (float)b / 255;
|
||||||
aa = (float)a / 255;
|
aa = (float)a / 255;
|
||||||
glColor4f(rr, gg, bb, aa);
|
glColor4f(rr, gg, bb, aa);
|
||||||
if ((win_w != f->buffer.dest_w) || (win_h != f->buffer.dest_h))
|
|
||||||
{
|
|
||||||
glViewport(0, 0, win_w, win_h);
|
glViewport(0, 0, win_w, win_h);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -654,7 +728,6 @@ __evas_gl_text_paste(Evas_GL_Font *f, char *text,
|
||||||
glTranslatef(0, -win_h, 0);
|
glTranslatef(0, -win_h, 0);
|
||||||
f->buffer.dest_w = win_w;
|
f->buffer.dest_w = win_w;
|
||||||
f->buffer.dest_h = win_h;
|
f->buffer.dest_h = win_h;
|
||||||
}
|
|
||||||
|
|
||||||
__evas_gl_text_calc_size(f, &w, &h, text);
|
__evas_gl_text_calc_size(f, &w, &h, text);
|
||||||
rows = h;
|
rows = h;
|
||||||
|
@ -1387,8 +1460,6 @@ void __evas_gl_rectangle_draw(Display *disp, Window win,
|
||||||
bb = (float)b / 255;
|
bb = (float)b / 255;
|
||||||
aa = (float)a / 255;
|
aa = (float)a / 255;
|
||||||
glColor4f(rr, gg, bb, aa);
|
glColor4f(rr, gg, bb, aa);
|
||||||
if ((win_w != dest_w) || (win_h != dest_h))
|
|
||||||
{
|
|
||||||
glViewport(0, 0, win_w, win_h);
|
glViewport(0, 0, win_w, win_h);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -1399,7 +1470,6 @@ void __evas_gl_rectangle_draw(Display *disp, Window win,
|
||||||
glTranslatef(0, -win_h, 0);
|
glTranslatef(0, -win_h, 0);
|
||||||
dest_w = win_w;
|
dest_w = win_w;
|
||||||
dest_h = win_h;
|
dest_h = win_h;
|
||||||
}
|
|
||||||
if (a < 255)
|
if (a < 255)
|
||||||
{
|
{
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
@ -1466,8 +1536,6 @@ void __evas_gl_line_draw(Display *disp, Window win,
|
||||||
bb = (float)b / 255;
|
bb = (float)b / 255;
|
||||||
aa = (float)a / 255;
|
aa = (float)a / 255;
|
||||||
glColor4f(rr, gg, bb, aa);
|
glColor4f(rr, gg, bb, aa);
|
||||||
if ((win_w != dest_w) || (win_h != dest_h))
|
|
||||||
{
|
|
||||||
glViewport(0, 0, win_w, win_h);
|
glViewport(0, 0, win_w, win_h);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -1478,7 +1546,7 @@ void __evas_gl_line_draw(Display *disp, Window win,
|
||||||
glTranslatef(0, -win_h, 0);
|
glTranslatef(0, -win_h, 0);
|
||||||
dest_w = win_w;
|
dest_w = win_w;
|
||||||
dest_h = win_h;
|
dest_h = win_h;
|
||||||
}
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_DITHER);
|
glEnable(GL_DITHER);
|
||||||
|
@ -1622,6 +1690,13 @@ __evas_gl_gradient_gen_texture(Evas_GL_Graident *gr)
|
||||||
map[j++] = b;
|
map[j++] = b;
|
||||||
map[j++] = a;
|
map[j++] = a;
|
||||||
}
|
}
|
||||||
|
for (i = ll; i < gr->max_texture_size; i++)
|
||||||
|
{
|
||||||
|
map[j++] = r;
|
||||||
|
map[j++] = g;
|
||||||
|
map[j++] = b;
|
||||||
|
map[j++] = a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!__evas_context_window)
|
if (!__evas_context_window)
|
||||||
{
|
{
|
||||||
|
@ -1661,7 +1736,7 @@ __evas_gl_gradient_gen_texture(Evas_GL_Graident *gr)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, gr->max_texture_size, 1, 0,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, gr->max_texture_size, 1, 0,
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, map);
|
GL_RGBA, GL_UNSIGNED_BYTE, map);
|
||||||
gr->texture_w = ll;
|
gr->texture_w = ll;
|
||||||
gr->texture_h = 1;
|
gr->texture_h = 1;
|
||||||
|
@ -1743,8 +1818,6 @@ __evas_gl_gradient_draw(Evas_GL_Graident *gr,
|
||||||
__evas_current_win = win;
|
__evas_current_win = win;
|
||||||
}
|
}
|
||||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||||
if ((win_w != dest_w) || (win_h != dest_h))
|
|
||||||
{
|
|
||||||
glViewport(0, 0, win_w, win_h);
|
glViewport(0, 0, win_w, win_h);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -1755,7 +1828,7 @@ __evas_gl_gradient_draw(Evas_GL_Graident *gr,
|
||||||
glTranslatef(0, -win_h, 0);
|
glTranslatef(0, -win_h, 0);
|
||||||
dest_w = win_w;
|
dest_w = win_w;
|
||||||
dest_h = win_h;
|
dest_h = win_h;
|
||||||
}
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_DITHER);
|
glEnable(GL_DITHER);
|
||||||
|
|
|
@ -39,6 +39,8 @@ struct _evas_gl_image
|
||||||
{
|
{
|
||||||
Evas_GL_Image_State state;
|
Evas_GL_Image_State state;
|
||||||
int w, h;
|
int w, h;
|
||||||
|
int direct;
|
||||||
|
int bl, br, bt, bb;
|
||||||
int alpha;
|
int alpha;
|
||||||
char *file;
|
char *file;
|
||||||
/* data specific params */
|
/* data specific params */
|
||||||
|
@ -139,6 +141,7 @@ 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);
|
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_width(Evas_GL_Image *im);
|
||||||
int __evas_gl_image_get_height(Evas_GL_Image *im);
|
int __evas_gl_image_get_height(Evas_GL_Image *im);
|
||||||
|
void __evas_gl_image_set_borders(Evas_GL_Image *im, int left, int right, int top, int bottom);
|
||||||
|
|
||||||
/********/
|
/********/
|
||||||
/* text */
|
/* text */
|
||||||
|
|
|
@ -120,7 +120,19 @@ __evas_imlib_image_get_height(Evas_Imlib_Image *im)
|
||||||
return imlib_image_get_height();
|
return imlib_image_get_height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
__evas_imlib_image_set_borders(Evas_Imlib_Image *im, int left, int right,
|
||||||
|
int top, int bottom)
|
||||||
|
{
|
||||||
|
Imlib_Border bd;
|
||||||
|
|
||||||
|
imlib_context_set_image((Imlib_Image)im);
|
||||||
|
bd.left = left;
|
||||||
|
bd.right = right;
|
||||||
|
bd.top = top;
|
||||||
|
bd.bottom = bottom;
|
||||||
|
imlib_image_set_border(&bd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -409,7 +421,7 @@ void __evas_imlib_line_draw(Display *disp, Window win,
|
||||||
if (!up->image)
|
if (!up->image)
|
||||||
up->image = imlib_create_image(up->w, up->h);
|
up->image = imlib_create_image(up->w, up->h);
|
||||||
imlib_context_set_image(up->image);
|
imlib_context_set_image(up->image);
|
||||||
imlib_image_draw_line(x1 - up->x, y - up->x, x2 - up->x, y2 - up->y, 0);
|
imlib_image_draw_line(x1 - up->x, y1 - up->x, x2 - up->x, y2 - up->y, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -432,6 +444,81 @@ void __evas_imlib_line_draw(Display *disp, Window win,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* gradient externals ********************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
Evas_Imlib_Graident *
|
||||||
|
__evas_imlib_gradient_new(Display *disp)
|
||||||
|
{
|
||||||
|
return (Evas_Imlib_Graident *)imlib_create_color_range();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
__evas_imlib_gradient_free(Evas_Imlib_Graident *gr)
|
||||||
|
{
|
||||||
|
imlib_context_set_color_range((Imlib_Color_Range)gr);
|
||||||
|
imlib_free_color_range();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
__evas_imlib_gradient_color_add(Evas_Imlib_Graident *gr, int r, int g, int b, int a, int dist)
|
||||||
|
{
|
||||||
|
imlib_context_set_color_range((Imlib_Color_Range)gr);
|
||||||
|
imlib_context_set_color(r, g, b, a);
|
||||||
|
imlib_add_color_to_color_range(dist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
__evas_imlib_gradient_draw(Evas_Imlib_Graident *gr, Display *disp, Window win, int win_w, int win_h, int x, int y, int w, int h, double angle)
|
||||||
|
{
|
||||||
|
Evas_List l;
|
||||||
|
|
||||||
|
imlib_context_set_angle(angle);
|
||||||
|
imlib_context_set_operation(IMLIB_OP_COPY);
|
||||||
|
imlib_context_set_color_modifier(NULL);
|
||||||
|
imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT);
|
||||||
|
imlib_context_set_color_range((Imlib_Color_Range)gr);
|
||||||
|
imlib_context_set_anti_alias(1);
|
||||||
|
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 image intersects image update - render */
|
||||||
|
if (RECTS_INTERSECT(up->x, up->y, up->w, up->h,
|
||||||
|
x, y, w, h))
|
||||||
|
{
|
||||||
|
if (!up->image)
|
||||||
|
up->image = imlib_create_image(up->w, up->h);
|
||||||
|
imlib_context_set_image(up->image);
|
||||||
|
imlib_image_fill_color_range_rectangle(x - up->x, y - up->y, w, h, angle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -462,6 +549,7 @@ __evas_imlib_flush_draw(Display *disp, Window win)
|
||||||
imlib_context_set_visual(__evas_visual);
|
imlib_context_set_visual(__evas_visual);
|
||||||
imlib_context_set_colormap(__evas_cmap);
|
imlib_context_set_colormap(__evas_cmap);
|
||||||
imlib_context_set_drawable(win);
|
imlib_context_set_drawable(win);
|
||||||
|
imlib_context_set_dither(1);
|
||||||
|
|
||||||
for(l = drawable_list; l; l = l->next)
|
for(l = drawable_list; l; l = l->next)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
typedef void Evas_Imlib_Image;
|
typedef void Evas_Imlib_Image;
|
||||||
typedef void Evas_Imlib_Font;
|
typedef void Evas_Imlib_Font;
|
||||||
|
typedef void Evas_Imlib_Graident;
|
||||||
|
|
||||||
typedef struct _evas_imlib_drawable Evas_Imlib_Drawable;
|
typedef struct _evas_imlib_drawable Evas_Imlib_Drawable;
|
||||||
typedef struct _evas_imlib_update Evas_Imlib_Update;
|
typedef struct _evas_imlib_update Evas_Imlib_Update;
|
||||||
|
@ -43,9 +44,10 @@ void __evas_imlib_image_free(Evas_Imlib_Image *im);
|
||||||
void __evas_imlib_image_cache_empty(Display *disp);
|
void __evas_imlib_image_cache_empty(Display *disp);
|
||||||
void __evas_imlib_image_cache_set_size(Display *disp, int size);
|
void __evas_imlib_image_cache_set_size(Display *disp, int size);
|
||||||
int __evas_imlib_image_cache_get_size(Display *disp);
|
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_width(Evas_Imlib_Image *im);
|
||||||
int __evas_imlib_image_get_height(Evas_Imlib_Image *im);
|
int __evas_imlib_image_get_height(Evas_Imlib_Image *im);
|
||||||
|
void __evas_imlib_image_set_borders(Evas_Imlib_Image *im, int left, int right, int top, int bottom);
|
||||||
|
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);
|
||||||
|
|
||||||
/********/
|
/********/
|
||||||
/* text */
|
/* text */
|
||||||
|
@ -76,6 +78,10 @@ void __evas_imlib_line_draw(Display *disp, Window win, int win_w, i
|
||||||
/*************/
|
/*************/
|
||||||
/* gradients */
|
/* gradients */
|
||||||
/*************/
|
/*************/
|
||||||
|
Evas_Imlib_Graident *__evas_imlib_gradient_new(Display *disp);
|
||||||
|
void __evas_imlib_gradient_free(Evas_Imlib_Graident *gr);
|
||||||
|
void __evas_imlib_gradient_color_add(Evas_Imlib_Graident *gr, int r, int g, int b, int a, int dist);
|
||||||
|
void __evas_imlib_gradient_draw(Evas_Imlib_Graident *gr, Display *disp, Window win, int win_w, int win_h, int x, int y, int w, int h, double angle);
|
||||||
|
|
||||||
/***********/
|
/***********/
|
||||||
/* drawing */
|
/* drawing */
|
||||||
|
|
|
@ -54,7 +54,7 @@ main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int a = 0;
|
int a = 0;
|
||||||
double t1, t2;
|
double t1, t2;
|
||||||
Evas_GL_Image *i[4], *bg, *l;
|
Evas_GL_Image *i[4], *bg, *l, *sel, *ic, *tm;
|
||||||
Evas_GL_Font *fn[4];
|
Evas_GL_Font *fn[4];
|
||||||
Evas_GL_Graident *gr;
|
Evas_GL_Graident *gr;
|
||||||
|
|
||||||
|
@ -63,7 +63,11 @@ main(int argc, char **argv)
|
||||||
i[1] = __evas_gl_image_new_from_file(d, "img/fog2001.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[2] = __evas_gl_image_new_from_file(d, "img/fog3001.png");
|
||||||
i[3] = __evas_gl_image_new_from_file(d, "img/fog4001.png");
|
i[3] = __evas_gl_image_new_from_file(d, "img/fog4001.png");
|
||||||
|
ic = __evas_gl_image_new_from_file(d, "img/mush.png");
|
||||||
|
tm = __evas_gl_image_new_from_file(d, "img/tm.png");
|
||||||
l = __evas_gl_image_new_from_file(d, "img/logo001.png");
|
l = __evas_gl_image_new_from_file(d, "img/logo001.png");
|
||||||
|
sel = __evas_gl_image_new_from_file(d, "img/sel.png");
|
||||||
|
__evas_gl_image_set_borders(sel, 3, 3, 3, 3);
|
||||||
__evas_gl_text_font_add_path("./fnt");
|
__evas_gl_text_font_add_path("./fnt");
|
||||||
fn[0] = __evas_gl_text_font_new(d, "cinema", 24);
|
fn[0] = __evas_gl_text_font_new(d, "cinema", 24);
|
||||||
fn[1] = __evas_gl_text_font_new(d, "grunge", 16);
|
fn[1] = __evas_gl_text_font_new(d, "grunge", 16);
|
||||||
|
@ -147,10 +151,56 @@ main(int argc, char **argv)
|
||||||
__evas_gl_line_draw(d, win, win_w, win_h,
|
__evas_gl_line_draw(d, win, win_w, win_h,
|
||||||
10, 20, 10, 200,
|
10, 20, 10, 200,
|
||||||
255, 255, 0, 100);
|
255, 255, 0, 100);
|
||||||
|
__evas_gl_image_draw(tm, d, win, win_w, win_h,
|
||||||
|
|
||||||
|
(__evas_gl_image_get_width(tm) / 2) - (((a / 4) + 4) / 2),
|
||||||
|
(__evas_gl_image_get_height(tm) / 2) - (((a / 4) + 4) / 2),
|
||||||
|
(a / 4) + 4, (a / 4) + 4,
|
||||||
|
|
||||||
|
360, 220,
|
||||||
|
200, 250);
|
||||||
|
__evas_gl_image_draw(tm, d, win, win_w, win_h,
|
||||||
|
|
||||||
|
0, 0,
|
||||||
|
(a / 4) + 4, (a / 4) + 4,
|
||||||
|
|
||||||
|
110, 320,
|
||||||
|
100, 100);
|
||||||
|
__evas_gl_image_draw(sel, d, win, win_w, win_h,
|
||||||
|
0, 0, __evas_gl_image_get_width(sel), __evas_gl_image_get_height(sel),
|
||||||
|
10, 50,
|
||||||
|
abs(sin((double)a / win_w) * 300) + 20, abs(cos((double)a / win_w) * 300) + 20);
|
||||||
__evas_gl_gradient_draw(gr,
|
__evas_gl_gradient_draw(gr,
|
||||||
d, win, win_w, win_h,
|
d, win, win_w, win_h,
|
||||||
300, 100, 200, 200,
|
300, 100, 200, 200,
|
||||||
((double)a * 360) / (double)win_w);
|
((double)a * 360) / (double)win_w);
|
||||||
|
__evas_gl_image_draw(ic, d, win, win_w, win_h,
|
||||||
|
|
||||||
|
0, 0,
|
||||||
|
__evas_gl_image_get_width(ic),
|
||||||
|
__evas_gl_image_get_height(ic),
|
||||||
|
|
||||||
|
a / 4, a / 8,
|
||||||
|
__evas_gl_image_get_width(ic),
|
||||||
|
__evas_gl_image_get_height(ic));
|
||||||
|
__evas_gl_image_draw(ic, d, win, win_w, win_h,
|
||||||
|
|
||||||
|
0, 0,
|
||||||
|
__evas_gl_image_get_width(ic),
|
||||||
|
__evas_gl_image_get_height(ic),
|
||||||
|
|
||||||
|
a / 4, a / 4,
|
||||||
|
__evas_gl_image_get_width(ic),
|
||||||
|
__evas_gl_image_get_height(ic));
|
||||||
|
__evas_gl_image_draw(ic, d, win, win_w, win_h,
|
||||||
|
|
||||||
|
0, 0,
|
||||||
|
__evas_gl_image_get_width(ic),
|
||||||
|
__evas_gl_image_get_height(ic),
|
||||||
|
|
||||||
|
a / 8, a / 4,
|
||||||
|
__evas_gl_image_get_width(ic),
|
||||||
|
__evas_gl_image_get_height(ic));
|
||||||
__evas_gl_flush_draw(d, win);
|
__evas_gl_flush_draw(d, win);
|
||||||
a++;
|
a++;
|
||||||
if (a == (win_w * 4))
|
if (a == (win_w * 4))
|
||||||
|
|
Loading…
Reference in New Issue