This finishes up the complete rewrite of evas's backend engines to be cleaner,

meaner, faster and more complete - as well as handling clipping too.

Over christmas I added clipping to evas (objects can be clipped by rectangle
objects - the clipped objects are also colours by the clipping object)

I rewrote the GL engine to be a LOT faster - evas_test shows a good 300-400%
speedup. I fixed polygone tessalation in the gl engine (i just wish the gl
book would tell me it uses the data in-place instead of making a tmp copy of
it!)

I made all engines match up pixel-for-pixel with fonts, and the gl engine's
texture mech maping works just fine.

The X11 engine is now fully functional - it does all objects - text included
but it makes serious sacrifices in image quality to get speed (no dithering,
no anti-aliased scaling, no alpha blending etc.).

Some optmizations in the X11 engine too

overall a much more complete implikemntation of evas and its renderers - you
shoudl see massiv eimprovements in GL rendeirng and be able to actualyl use
the X11 rendering without a problem :)


SVN revision: 4052
This commit is contained in:
Carsten Haitzler 2000-12-29 20:43:48 +00:00
parent 84ca5f1326
commit a084ff527e
8 changed files with 819 additions and 460 deletions

View File

@ -613,13 +613,15 @@ __evas_gl_make_image_textures(Evas_GL_Window *w, Evas_GL_Image *image)
/* end edge */ /* end edge */
else if (ty == tm->tiles.y) else if (ty == tm->tiles.y)
{ {
iy = ty * (w->context->max_texture_size - 2) + 1; iy = (w->context->max_texture_size - 1) - 1 +
((ty - 1) * (w->context->max_texture_size - 2));
ih = image->h - iy; ih = image->h - iy;
} }
/* middle tex */ /* middle tex */
else else
{ {
iy = ty * (w->context->max_texture_size - 2) + 1; iy = (w->context->max_texture_size - 1) - 1 +
((ty - 1) * (w->context->max_texture_size - 2));
ih = w->context->max_texture_size; ih = w->context->max_texture_size;
} }
for (tx = 0; tx <= tm->tiles.x; tx++) for (tx = 0; tx <= tm->tiles.x; tx++)
@ -640,13 +642,15 @@ __evas_gl_make_image_textures(Evas_GL_Window *w, Evas_GL_Image *image)
/* end edge */ /* end edge */
else if (tx == tm->tiles.x) else if (tx == tm->tiles.x)
{ {
ix = tx * (w->context->max_texture_size - 2) + 1; ix = (w->context->max_texture_size - 1) - 1 +
((tx - 1) * (w->context->max_texture_size - 2));
iw = image->w - ix; iw = image->w - ix;
} }
/* middle tex */ /* middle tex */
else else
{ {
ix = tx * (w->context->max_texture_size - 2) + 1; ix = (w->context->max_texture_size - 1) - 1 +
((tx - 1) * (w->context->max_texture_size - 2));
iw = w->context->max_texture_size; iw = w->context->max_texture_size;
} }
if (image->im) if (image->im)
@ -1076,7 +1080,7 @@ __evas_gl_font_load(char *font, int size)
const int dpi = 96; const int dpi = 96;
file = __evas_gl_font_find(font); file = __evas_gl_font_find(font);
if (!file) return; if (!file) return NULL;
if (!__evas_have_tt_engine) if (!__evas_have_tt_engine)
{ {
error = TT_Init_FreeType(&__evas_tt_engine); error = TT_Init_FreeType(&__evas_tt_engine);
@ -1238,19 +1242,13 @@ __evas_gl_text_font_cache_flush(void)
} }
} }
/*****************************************************************************/
/* image externals ***********************************************************/
/*****************************************************************************/
void void
__evas_gl_image_draw(Evas_GL_Image *im, __evas_gl_image_intern_draw(Evas_GL_Image *im,
Display *disp, Imlib_Image dstim, Evas_GL_Window *glw,
Window w, int win_w, int win_h, int src_x, int src_y, int src_w, int src_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 dst_x, int dst_y, int dst_w, int dst_h, int allow_smooth)
int cr, int cg, int cb, int ca)
{ {
Evas_GL_Window *glw;
Evas_List l; Evas_List l;
Evas_GL_Texmesh *tm; Evas_GL_Texmesh *tm;
@ -1258,26 +1256,10 @@ __evas_gl_image_draw(Evas_GL_Image *im,
double x0, y0, w0, h0; double x0, y0, w0, h0;
int go; int go;
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;
if (src_w < 1) src_w = 1; if (src_w < 1) src_w = 1;
if (src_h < 1) src_h = 1; if (src_h < 1) src_h = 1;
if (dst_w < 1) return; if (dst_w < 1) return;
if (dst_h < 1) return; if (dst_h < 1) return;
glw = __evas_gl_window_current(disp, w, win_w, win_h);
if (!glw) return;
__evas_gl_window_texture(glw, 1);
__evas_gl_window_blend(glw, im->has_alpha);
__evas_gl_window_write_buf(glw, GL_BACK);
__evas_gl_window_read_buf(glw, GL_BACK);
__evas_gl_window_color(glw, cr, cg, cb, ca);
__evas_gl_window_dither(glw, 1);
tm = __evas_gl_make_image_textures(glw, im); tm = __evas_gl_make_image_textures(glw, im);
scx = (double)dst_w / (double)src_w; scx = (double)dst_w / (double)src_w;
@ -1347,7 +1329,7 @@ __evas_gl_image_draw(Evas_GL_Image *im,
double x1, x2, y1, y2; double x1, x2, y1, y2;
int smooth = 0; int smooth = 0;
if (__evas_smooth) if ((__evas_smooth) && (allow_smooth))
{ {
if ((dst_w == src_w) && (dst_h == src_h)) if ((dst_w == src_w) && (dst_h == src_h))
smooth = 0; smooth = 0;
@ -1358,45 +1340,52 @@ __evas_gl_image_draw(Evas_GL_Image *im,
t = 0; t = 0;
for (ty = 0; ty <= tm->tiles.y; ty++) for (ty = 0; ty <= tm->tiles.y; ty++)
{ {
if ((ty == 0) && (ty < tm->tiles.y)) if ((ty == 0) && (ty < tm->tiles.y))
{ {
y1 = y0; y1 = y0;
y2 = y1 + ((double)(glw->context->max_texture_size - 1) * scy); y2 = y1 + ((double)(glw->context->max_texture_size - 1) * scy);
ty1 = 0.0; ty1 = 0.0;
ty2 = (double)(glw->context->max_texture_size - 1) / (double)glw->context->max_texture_size; ty2 = (double)(glw->context->max_texture_size - 2) / (double)(glw->context->max_texture_size - 1);
} }
else if (ty < tm->tiles.y) else if (ty < tm->tiles.y)
{ {
y1 = y0 + (((double)(glw->context->max_texture_size - 1) + ((double)(ty - 1) * (double)(glw->context->max_texture_size - 2))) * scy); y1 = y0 + (((double)(glw->context->max_texture_size - 1) + ((double)(ty - 1) * (double)(glw->context->max_texture_size - 2))) * scy);
y2 = y1 + ((double)(glw->context->max_texture_size - 2) * scy); y2 = y1 + ((double)(glw->context->max_texture_size - 2) * scy);
ty1 = 1.0 / (double)glw->context->max_texture_size; ty1 = 1.0 / (double)(glw->context->max_texture_size - 1);
ty2 = (double)(glw->context->max_texture_size - 1) / (double)glw->context->max_texture_size; ty2 = (double)(glw->context->max_texture_size - 2) / (double)(glw->context->max_texture_size - 1);
} }
else else
{ {
if (ty == 0) y1 = y0; if (ty == 0) y1 = y0;
else else
y1 = y0 + h0 - ((double)tm->tiles.y_left * scy); y1 = y0 + h0 - ((double)tm->tiles.y_left * scy);
y2 = y0 + h0; y2 = y0 + h0;
if (ty == 0) ty1 = 0; if (ty == 0)
else ty1 = 1 / (double)tm->tiles.y_edge; {
ty2 = (double)tm->tiles.y_left / (double)tm->tiles.y_edge; ty1 = 0.0;
ty2 = (double)(tm->tiles.y_left - 1) / (double)(tm->tiles.y_edge - 1);
}
else
{
ty1 = 1.0 / (double)(tm->tiles.y_edge - 1);
ty2 = (double)(1 + tm->tiles.y_left - 1) / (double)(tm->tiles.y_edge - 1);
}
} }
for (tx = 0; tx <= tm->tiles.x; tx++) for (tx = 0; tx <= tm->tiles.x; tx++)
{ {
if ((tx == 0) && (tx < tm->tiles.x)) if ((tx == 0) && (tx < tm->tiles.x))
{ {
x1 = x0; x1 = x0;
x2 = x1 + (255 * scx); x2 = x1 + (255 * scx);
tx1 = 0.0; tx1 = 0.0;
tx2 = (double)(glw->context->max_texture_size - 1) / (double)glw->context->max_texture_size; tx2 = (double)(glw->context->max_texture_size - 2) / (double)(glw->context->max_texture_size - 1);
} }
else if (tx < tm->tiles.x) else if (tx < tm->tiles.x)
{ {
x1 = x0 + (((double)(glw->context->max_texture_size - 1) + ((double)(tx - 1) * (double)(glw->context->max_texture_size - 2))) * scx); x1 = x0 + (((double)(glw->context->max_texture_size - 1) + ((double)(tx - 1) * (double)(glw->context->max_texture_size - 2))) * scx);
x2 = x1 + ((double)(glw->context->max_texture_size - 2) * scx); x2 = x1 + ((double)(glw->context->max_texture_size - 2) * scx);
tx1 = 1.0 / (double)glw->context->max_texture_size; tx1 = 1.0 / (double)(glw->context->max_texture_size - 1);
tx2 = (double)(glw->context->max_texture_size - 1) / (double)glw->context->max_texture_size; tx2 = (double)(glw->context->max_texture_size - 2) / (double)(glw->context->max_texture_size - 1);
} }
else else
{ {
@ -1404,9 +1393,16 @@ __evas_gl_image_draw(Evas_GL_Image *im,
else else
x1 = x0 + w0 - ((double)tm->tiles.x_left * scx); x1 = x0 + w0 - ((double)tm->tiles.x_left * scx);
x2 = x0 + w0; x2 = x0 + w0;
if (tx == 0) tx1 = 0; if (tx == 0)
else tx1 = 1 / (double)tm->tiles.x_edge; {
tx2 = (double)tm->tiles.x_left / (double)tm->tiles.x_edge; tx1 = 0.0;
tx2 = (double)(tm->tiles.x_left - 1) / (double)(tm->tiles.x_edge - 1);
}
else
{
tx1 = 1.0 / (double)(tm->tiles.x_edge - 1);
tx2 = (double)(1 + tm->tiles.x_left - 1) / (double)(tm->tiles.x_edge - 1);
}
} }
__evas_gl_window_use_texture(glw, tm->textures[t++], smooth); __evas_gl_window_use_texture(glw, tm->textures[t++], smooth);
glBegin(GL_QUADS); glBegin(GL_QUADS);
@ -1423,6 +1419,153 @@ __evas_gl_image_draw(Evas_GL_Image *im,
#endif #endif
} }
/*****************************************************************************/
/* image externals ***********************************************************/
/*****************************************************************************/
void
__evas_gl_image_draw(Evas_GL_Image *im,
Display *disp, Imlib_Image dstim,
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 cr, int cg, int cb, int ca)
{
Evas_GL_Window *glw;
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;
if (src_w < 1) src_w = 1;
if (src_h < 1) src_h = 1;
if (dst_w < 1) return;
if (dst_h < 1) return;
glw = __evas_gl_window_current(disp, w, win_w, win_h);
if (!glw) return;
__evas_gl_window_texture(glw, 1);
__evas_gl_window_blend(glw, im->has_alpha);
__evas_gl_window_write_buf(glw, GL_BACK);
__evas_gl_window_read_buf(glw, GL_BACK);
__evas_gl_window_color(glw, cr, cg, cb, ca);
__evas_gl_window_dither(glw, 1);
if ((im->border.l == 0) && (im->border.r == 0) &&
(im->border.t == 0) && (im->border.b == 0))
__evas_gl_image_intern_draw(im, glw, src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h,
1);
else
{
double scx, scy;
double x0, y0, w0, h0;
int ecx, ecy, ecw, ech, ec;
int x, y, w, h, dx, dy, dw, dh;
int smooth;
scx = (double)dst_w / (double)src_w;
scy = (double)dst_h / (double)src_h;
x0 = (double)dst_x - ((double)src_x * scx);
y0 = (double)dst_y - ((double)src_y * scy);
w0 = (double)im->w * scx;
h0 = (double)im->h * scy;
ec = __evas_clip;
ecx = __evas_clip_x;
ecy = __evas_clip_y;
ecw = __evas_clip_w;
ech = __evas_clip_h;
if (__evas_clip)
{
CLIP_TO(dst_x, dst_y, dst_w, dst_h,
__evas_clip_x, __evas_clip_y,
__evas_clip_w, __evas_clip_h);
}
__evas_clip = 1;
__evas_clip_x = dst_x;
__evas_clip_y = dst_y;
__evas_clip_w = dst_w;
__evas_clip_h = dst_h;
dst_x = x0;
dst_y = y0;
dst_w = w0;
dst_h = h0;
x = 0; y = 0;
w = im->border.l; h = im->border.t;
dx = dst_x; dy = dst_y;
dw = w; dh = h;
__evas_gl_image_intern_draw(im, glw, x, y, w, h, dx, dy, dw, dh, 0);
smooth = 0; if (scx > 1.0) smooth = 1;
x = im->border.l; y = 0;
w = im->w - (im->border.l + im->border.r); h = im->border.t;
dx = dst_x + im->border.l; dy = dst_y;
dw = dst_w - (im->border.l + im->border.r); dh = h;
__evas_gl_image_intern_draw(im, glw, x, y, w, h, dx, dy, dw, dh, smooth);
x = im->w - im->border.r; y = 0;
w = im->border.r; h = im->border.t;
dx = dst_x + dst_w - im->border.r;
dy = dst_y; dw = w; dh = h;
__evas_gl_image_intern_draw(im, glw, x, y, w, h, dx, dy, dw, dh, 0);
smooth = 0; if (scy > 1.0) smooth = 1;
x = 0; y = im->border.t;
w = im->border.l; h = im->h - (im->border.t + im->border.b);
dx = dst_x; dy = dst_y + im->border.t; dw = w;
dh = dst_h - (im->border.t + im->border.b);
__evas_gl_image_intern_draw(im, glw, x, y, w, h, dx, dy, dw, dh, smooth);
smooth = 0; if ((scx > 1.0) && (scy > 1.0)) smooth = 1;
x = im->border.l; y = im->border.t;
w = im->w - (im->border.l + im->border.r); h = im->h - (im->border.t + im->border.b);
dx = dst_x + im->border.l; dy = dst_y + im->border.t;
dw = dst_w - (im->border.l + im->border.r); dh = dst_h - (im->border.t + im->border.b);
__evas_gl_image_intern_draw(im, glw, x, y, w, h, dx, dy, dw, dh, smooth);
smooth = 0; if (scy > 1.0) smooth = 1;
x = im->w - im->border.r; y = im->border.t;
w = im->border.r; h = im->h - (im->border.t + im->border.b);
dx = dst_x + dst_w - im->border.r; dy = dst_y + im->border.t;
dw = w; dh = dst_h - (im->border.t + im->border.b);
__evas_gl_image_intern_draw(im, glw, x, y, w, h, dx, dy, dw, dh, smooth);
x = 0; y = im->h - im->border.b;
w = im->border.l; h = im->border.b;
dx = dst_x; dy = dst_y + dst_h - im->border.b;
dw = w; dh = h;
__evas_gl_image_intern_draw(im, glw, x, y, w, h, dx, dy, dw, dh, 0);
smooth = 0; if (scx > 1.0) smooth = 1;
x = im->border.l; y = im->h - im->border.b;
w = im->w - (im->border.l + im->border.r); h = im->border.b;
dx = dst_x + im->border.l; dy = dst_y + dst_h - im->border.b;
dw = dst_w - (im->border.l + im->border.r); dh = h;
__evas_gl_image_intern_draw(im, glw, x, y, w, h, dx, dy, dw, dh, smooth);
x = im->w - im->border.r; y = im->h - im->border.b;
w = im->border.r; h = im->border.b;
dx = dst_x + dst_w - im->border.r; dy = dst_y + dst_h - im->border.b;
dw = w; dh = h;
__evas_gl_image_intern_draw(im, glw, x, y, w, h, dx, dy, dw, dh, 0);
__evas_clip = ec;
__evas_clip_x = ecx;
__evas_clip_y = ecy;
__evas_clip_w = ecw;
__evas_clip_h = ech;
}
}
Evas_GL_Image * Evas_GL_Image *
__evas_gl_image_new_from_file(Display *disp, char *file) __evas_gl_image_new_from_file(Display *disp, char *file)
{ {
@ -1617,19 +1760,57 @@ __evas_gl_text_font_get_advances(Evas_GL_Font *fn, char *text,
int *advance_horiz, int *advance_horiz,
int *advance_vert) int *advance_vert)
{ {
int i, ascent, descent, pw, ph;
if (advance_horiz) *advance_horiz = 0; if (advance_horiz) *advance_horiz = 0;
if (advance_horiz) *advance_vert = 0; if (advance_horiz) *advance_vert = 0;
if (!fn) return; if (!fn) return;
if (!text) return; if (!text) return;
if (text[0] == 0) return; if (text[0] == 0) return;
ascent = fn->ascent;
descent = fn->descent;
pw = 0;
ph = ascent + descent;
for (i = 0; text[i]; i++)
{
Evas_GL_Glyph *g;
int glyph;
glyph = ((unsigned char *)text)[i];
g = __evas_gl_text_font_get_glyph(fn, glyph);
if (!g) continue;
if (!TT_VALID(g->glyph)) continue;
if (i == 0)
pw += ((-g->metrics.bearingX) / 64);
pw += g->metrics.advance / 64;
}
*advance_horiz = pw;
*advance_vert = ph;
} }
int int
__evas_gl_text_font_get_first_inset(Evas_GL_Font *fn, char *text) __evas_gl_text_font_get_first_inset(Evas_GL_Font *fn, char *text)
{ {
int i;
if (!fn) return 0; if (!fn) return 0;
if (!text) return 0; if (!text) return 0;
if (text[0] == 0) return 0; if (text[0] == 0) return 0;
for (i = 0; text[i]; i++)
{
Evas_GL_Glyph *g;
int glyph;
glyph = ((unsigned char *)text)[i];
g = __evas_gl_text_font_get_glyph(fn, glyph);
if (!g) continue;
if (!TT_VALID(g->glyph)) continue;
return ((-g->metrics.bearingX) / 64);
}
return 0;
} }
void void
@ -1881,8 +2062,8 @@ __evas_gl_text_get_size(Evas_GL_Font *fn, char *text, int *w, int *h)
else else
pw += g->metrics.advance / 64; pw += g->metrics.advance / 64;
} }
if (w) *w = pw + 1; if (w) *w = pw;
if (h) *h = ph + 1; if (h) *h = ph;
} }
int int
@ -2385,6 +2566,49 @@ __evas_gl_gradient_draw(Evas_GL_Graident *gr,
#endif #endif
} }
/* something is wrong here - GL experts? the polys dont get tesselated */
/* correctly */
#ifdef HAVE_GLU
static void
__evas_gl_tess_begin_cb(GLenum which)
{
glBegin(which);
}
static void
__evas_gl_tess_end_cb(void)
{
glEnd();
}
static void
__evas_gl_tess_error_cb(GLenum errorcode)
{
}
static void
__evas_gl_tess_vertex_cb(GLvoid *vertex)
{
GLdouble *v;
v = vertex;
glVertex2d(v[0], v[1]);
}
static void
__evas_gl_tess_combine_cb(GLdouble coords[3],
GLdouble *vertex_data[4],
GLfloat weight[4], GLdouble **data_out)
{
GLdouble *vertex;
vertex = (GLdouble *) malloc(6 * sizeof(GLdouble));
vertex[0] = coords[0];
vertex[1] = coords[1];
*data_out = vertex;
}
#endif
/************/ /************/
/* polygons */ /* polygons */
/************/ /************/
@ -2466,17 +2690,56 @@ __evas_gl_poly_draw (Display *disp, Imlib_Image dstim, Window win,
/* render poly here */ /* render poly here */
if (go) if (go)
{ {
Evas_List l; Evas_List l2;
#ifdef HAVE_GLU
{
static void *tess = NULL;
GLdouble *glp = NULL;
int i, num;
if (!tess)
{
tess = gluNewTess();
gluTessCallback(tess, GLU_TESS_BEGIN, __evas_gl_tess_begin_cb);
gluTessCallback(tess, GLU_TESS_END, __evas_gl_tess_end_cb);
gluTessCallback(tess, GLU_TESS_ERROR, __evas_gl_tess_error_cb);
gluTessCallback(tess, GLU_TESS_VERTEX, __evas_gl_tess_vertex_cb);
gluTessCallback(tess, GLU_TESS_COMBINE, __evas_gl_tess_combine_cb);
}
gluTessNormal(tess, 0, 0, 1);
gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
gluTessBeginPolygon(tess, NULL);
gluTessBeginContour(tess);
num = 0;
for (l2 = points; l2; l2 = l2->next) num++;
i = 0;
glp = malloc(num * 3 * sizeof(GLdouble));
for (l2 = points; l2; l2 = l2->next)
{
Evas_Point p;
p = l2->data;
glp[i++] = p->x;
glp[i++] = p->y;
glp[i++] = 0;
gluTessVertex(tess, &(glp[i - 3]), &(glp[i - 3]));
}
gluTessEndContour(tess);
gluTessEndPolygon(tess);
free(glp);
}
#else
glBegin(GL_POLYGON); glBegin(GL_POLYGON);
for (l = points; l; l = l->next) for (l2 = points; l2; l2 = l2->next)
{ {
Evas_Point p; Evas_Point p;
p = l->data; p = l2->data;
glVertex2d(p->x, p->y); glVertex2d(p->x, p->y);
} }
glEnd(); glEnd();
#endif
} }
#ifndef GLNOCLIP #ifndef GLNOCLIP
} }

View File

@ -1,6 +1,7 @@
#include "evas_image_routines.h"
static void __evas_image_image_cache_flush(Display *disp); #include "evas_imlib_routines.h"
static void __evas_imlib_image_cache_flush(Display *disp);
static int __evas_anti_alias = 1; static int __evas_anti_alias = 1;
static Evas_List drawable_list = NULL; static Evas_List drawable_list = NULL;
@ -20,7 +21,7 @@ static int __evas_clip_a = 0;
/*****************************************************************************/ /*****************************************************************************/
static void static void
__evas_image_image_cache_flush(Display *disp) __evas_imlib_image_cache_flush(Display *disp)
{ {
int size; int size;
@ -33,21 +34,21 @@ __evas_image_image_cache_flush(Display *disp)
/* image externals ***********************************************************/ /* image externals ***********************************************************/
/*****************************************************************************/ /*****************************************************************************/
Evas_Image_Image * Evas_Imlib_Image *
__evas_image_image_new_from_file(Display *disp, char *file) __evas_imlib_image_new_from_file(Display *disp, char *file)
{ {
return (Evas_Image_Image *)imlib_load_image(file); return (Evas_Imlib_Image *)imlib_load_image(file);
} }
void void
__evas_image_image_free(Evas_Image_Image *im) __evas_imlib_image_free(Evas_Imlib_Image *im)
{ {
imlib_context_set_image((Imlib_Image)im); imlib_context_set_image((Imlib_Image)im);
imlib_free_image(); imlib_free_image();
} }
void void
__evas_image_image_cache_empty(Display *disp) __evas_imlib_image_cache_empty(Display *disp)
{ {
int size; int size;
@ -57,19 +58,19 @@ __evas_image_image_cache_empty(Display *disp)
} }
void void
__evas_image_image_cache_set_size(Display *disp, int size) __evas_imlib_image_cache_set_size(Display *disp, int size)
{ {
imlib_set_cache_size(size); imlib_set_cache_size(size);
} }
int int
__evas_image_image_cache_get_size(Display *disp) __evas_imlib_image_cache_get_size(Display *disp)
{ {
return imlib_get_cache_size(); return imlib_get_cache_size();
} }
void void
__evas_image_image_draw(Evas_Image_Image *im, __evas_imlib_image_draw(Evas_Imlib_Image *im,
Display *disp, Imlib_Image dstim, Window w, int win_w, int win_h, Display *disp, Imlib_Image dstim, Window w, int win_w, int win_h,
int src_x, int src_y, int src_w, int src_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 dst_x, int dst_y, int dst_w, int dst_h,
@ -78,7 +79,14 @@ __evas_image_image_draw(Evas_Image_Image *im,
Evas_List l; Evas_List l;
Imlib_Color_Modifier cm = NULL; Imlib_Color_Modifier cm = NULL;
if (ca == 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;
if ((cr != 255) || (cg != 255) || (cb != 255) || (ca != 255)) if ((cr != 255) || (cg != 255) || (cb != 255) || (ca != 255))
{ {
DATA8 r[256], g[256], b[256], a[256]; DATA8 r[256], g[256], b[256], a[256];
@ -99,23 +107,23 @@ __evas_image_image_draw(Evas_Image_Image *im,
imlib_context_set_color_modifier(NULL); imlib_context_set_color_modifier(NULL);
imlib_context_set_angle(0.0); imlib_context_set_angle(0.0);
imlib_context_set_blend(1);
imlib_context_set_operation(IMLIB_OP_COPY); imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT); imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT);
imlib_context_set_anti_alias(__evas_anti_alias); imlib_context_set_anti_alias(__evas_anti_alias);
imlib_context_set_blend(1);
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Image_Drawable *dr; Evas_Imlib_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->im == dstim) && (dr->disp == disp)) if ((dr->win == w) && (dr->disp == disp))
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Image_Update *up; Evas_Imlib_Update *up;
up = ll->data; up = ll->data;
@ -123,27 +131,19 @@ __evas_image_image_draw(Evas_Image_Image *im,
if (RECTS_INTERSECT(up->x, up->y, up->w, up->h, if (RECTS_INTERSECT(up->x, up->y, up->w, up->h,
dst_x, dst_y, dst_w, dst_h)) dst_x, dst_y, dst_w, dst_h))
{ {
if (__evas_clip)
imlib_context_set_cliprect(__evas_clip_x - up->x,
__evas_clip_y - up->y,
__evas_clip_w,
__evas_clip_h);
else imlib_context_set_cliprect(0, 0, 0, 0);
if (!up->image) if (!up->image)
{ up->image = imlib_create_image(up->w, up->h);
DATA32 *data; imlib_context_set_image(up->image);
imlib_blend_image_onto_image(im, 0,
up->image = imlib_create_image(up->w, up->h); src_x, src_y, src_w, src_h,
if (up->image) dst_x - up->x, dst_y - up->y, dst_w, dst_h);
{
imlib_context_set_image(up->image);
data = imlib_image_get_data();
memset(data, 0, up->w * up->h * sizeof(DATA32));
imlib_image_put_back_data(data);
imlib_image_set_has_alpha(1);
}
}
if (up->image)
{
imlib_context_set_image(up->image);
imlib_blend_image_onto_image(im, 1,
src_x, src_y, src_w, src_h,
dst_x - up->x, dst_y - up->y, dst_w, dst_h);
}
} }
} }
} }
@ -156,21 +156,21 @@ __evas_image_image_draw(Evas_Image_Image *im,
} }
int int
__evas_image_image_get_width(Evas_Image_Image *im) __evas_imlib_image_get_width(Evas_Imlib_Image *im)
{ {
imlib_context_set_image((Imlib_Image)im); imlib_context_set_image((Imlib_Image)im);
return imlib_image_get_width(); return imlib_image_get_width();
} }
int int
__evas_image_image_get_height(Evas_Image_Image *im) __evas_imlib_image_get_height(Evas_Imlib_Image *im)
{ {
imlib_context_set_image((Imlib_Image)im); imlib_context_set_image((Imlib_Image)im);
return imlib_image_get_height(); return imlib_image_get_height();
} }
void void
__evas_image_image_set_borders(Evas_Image_Image *im, int left, int right, __evas_imlib_image_set_borders(Evas_Imlib_Image *im, int left, int right,
int top, int bottom) int top, int bottom)
{ {
Imlib_Border bd; Imlib_Border bd;
@ -184,7 +184,7 @@ __evas_image_image_set_borders(Evas_Image_Image *im, int left, int right,
} }
void void
__evas_image_image_set_smooth_scaling(int on) __evas_imlib_image_set_smooth_scaling(int on)
{ {
__evas_anti_alias = on; __evas_anti_alias = on;
} }
@ -223,52 +223,52 @@ __evas_image_image_set_smooth_scaling(int on)
/* font externals ************************************************************/ /* font externals ************************************************************/
/*****************************************************************************/ /*****************************************************************************/
Evas_Image_Font * Evas_Imlib_Font *
__evas_image_text_font_new(Display *disp, char *font, int size) __evas_imlib_text_font_new(Display *disp, char *font, int size)
{ {
char buf[4096]; char buf[4096];
sprintf(buf, "%s/%i", font, size); sprintf(buf, "%s/%i", font, size);
return (Evas_Image_Font *)imlib_load_font(buf); return (Evas_Imlib_Font *)imlib_load_font(buf);
} }
void void
__evas_image_text_font_free(Evas_Image_Font *fn) __evas_imlib_text_font_free(Evas_Imlib_Font *fn)
{ {
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
imlib_free_font(); imlib_free_font();
} }
int int
__evas_image_text_font_get_ascent(Evas_Image_Font *fn) __evas_imlib_text_font_get_ascent(Evas_Imlib_Font *fn)
{ {
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
return imlib_get_font_ascent(); return imlib_get_font_ascent();
} }
int int
__evas_image_text_font_get_descent(Evas_Image_Font *fn) __evas_imlib_text_font_get_descent(Evas_Imlib_Font *fn)
{ {
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
return imlib_get_font_descent(); return imlib_get_font_descent();
} }
int int
__evas_image_text_font_get_max_ascent(Evas_Image_Font *fn) __evas_imlib_text_font_get_max_ascent(Evas_Imlib_Font *fn)
{ {
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
return imlib_get_maximum_font_ascent(); return imlib_get_maximum_font_ascent();
} }
int int
__evas_image_text_font_get_max_descent(Evas_Image_Font *fn) __evas_imlib_text_font_get_max_descent(Evas_Imlib_Font *fn)
{ {
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
return imlib_get_maximum_font_descent(); return imlib_get_maximum_font_descent();
} }
void void
__evas_image_text_font_get_advances(Evas_Image_Font *fn, char *text, __evas_imlib_text_font_get_advances(Evas_Imlib_Font *fn, char *text,
int *advance_horiz, int *advance_horiz,
int *advance_vert) int *advance_vert)
{ {
@ -277,32 +277,32 @@ __evas_image_text_font_get_advances(Evas_Image_Font *fn, char *text,
} }
int int
__evas_image_text_font_get_first_inset(Evas_Image_Font *fn, char *text) __evas_imlib_text_font_get_first_inset(Evas_Imlib_Font *fn, char *text)
{ {
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
return imlib_get_text_inset(text); return imlib_get_text_inset(text);
} }
void void
__evas_image_text_font_add_path(char *path) __evas_imlib_text_font_add_path(char *path)
{ {
imlib_add_path_to_font_path(path); imlib_add_path_to_font_path(path);
} }
void void
__evas_image_text_font_del_path(char *path) __evas_imlib_text_font_del_path(char *path)
{ {
imlib_remove_path_from_font_path(path); imlib_remove_path_from_font_path(path);
} }
char ** char **
__evas_image_text_font_list_paths(int *count) __evas_imlib_text_font_list_paths(int *count)
{ {
return imlib_list_font_path(count); return imlib_list_font_path(count);
} }
void void
__evas_image_text_cache_empty(Display *disp) __evas_imlib_text_cache_empty(Display *disp)
{ {
int size; int size;
@ -312,27 +312,35 @@ __evas_image_text_cache_empty(Display *disp)
} }
void void
__evas_image_text_cache_set_size(Display *disp, int size) __evas_imlib_text_cache_set_size(Display *disp, int size)
{ {
imlib_set_font_cache_size(size); imlib_set_font_cache_size(size);
} }
int int
__evas_image_text_cache_get_size(Display *disp) __evas_imlib_text_cache_get_size(Display *disp)
{ {
return imlib_get_font_cache_size(); return imlib_get_font_cache_size();
} }
void void
__evas_image_text_draw(Evas_Image_Font *fn, Display *disp, Imlib_Image dstim, Window win, __evas_imlib_text_draw(Evas_Imlib_Font *fn, Display *disp, Imlib_Image dstim, Window win,
int win_w, int win_h, int x, int y, char *text, int win_w, int win_h, int x, int y, char *text,
int r, int g, int b, int a) int cr, int cg, int cb, int ca)
{ {
Evas_List l; Evas_List l;
int w, h; int w, h;
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 ((!fn) || (!text)) return; if ((!fn) || (!text)) return;
imlib_context_set_color(r, g, b, a); if (ca == 0) return;
imlib_context_set_color(cr, cg, cb, ca);
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
imlib_context_set_angle(0.0); imlib_context_set_angle(0.0);
imlib_context_set_operation(IMLIB_OP_COPY); imlib_context_set_operation(IMLIB_OP_COPY);
@ -343,17 +351,17 @@ __evas_image_text_draw(Evas_Image_Font *fn, Display *disp, Imlib_Image dstim, Wi
imlib_get_text_size(text, &w, &h); imlib_get_text_size(text, &w, &h);
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Image_Drawable *dr; Evas_Imlib_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->im == dstim) && (dr->disp == disp)) if ((dr->win == win) && (dr->disp == disp))
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Image_Update *up; Evas_Imlib_Update *up;
up = ll->data; up = ll->data;
@ -361,20 +369,14 @@ __evas_image_text_draw(Evas_Image_Font *fn, Display *disp, Imlib_Image dstim, Wi
if (RECTS_INTERSECT(up->x, up->y, up->w, up->h, if (RECTS_INTERSECT(up->x, up->y, up->w, up->h,
x, y, w, h)) x, y, w, h))
{ {
if (__evas_clip)
imlib_context_set_cliprect(__evas_clip_x - up->x,
__evas_clip_y - up->y,
__evas_clip_w,
__evas_clip_h);
else imlib_context_set_cliprect(0, 0, 0, 0);
if (!up->image) if (!up->image)
{ up->image = imlib_create_image(up->w, up->h);
DATA32 *data;
up->image = imlib_create_image(up->w, up->h);
if (up->image)
{
imlib_context_set_image(up->image);
data = imlib_image_get_data();
memset(data, 0, up->w * up->h * sizeof(DATA32));
imlib_image_put_back_data(data);
imlib_image_set_has_alpha(1);
}
}
imlib_context_set_image(up->image); imlib_context_set_image(up->image);
imlib_text_draw(x - up->x, y - up->y, text); imlib_text_draw(x - up->x, y - up->y, text);
} }
@ -384,7 +386,7 @@ __evas_image_text_draw(Evas_Image_Font *fn, Display *disp, Imlib_Image dstim, Wi
} }
void void
__evas_image_text_get_size(Evas_Image_Font *fn, char *text, int *w, int *h) __evas_imlib_text_get_size(Evas_Imlib_Font *fn, char *text, int *w, int *h)
{ {
if ((!fn) || (!text)) if ((!fn) || (!text))
{ {
@ -396,7 +398,7 @@ __evas_image_text_get_size(Evas_Image_Font *fn, char *text, int *w, int *h)
} }
int int
__evas_image_text_get_character_at_pos(Evas_Image_Font *fn, char *text, __evas_imlib_text_get_character_at_pos(Evas_Imlib_Font *fn, char *text,
int x, int y, int x, int y,
int *cx, int *cy, int *cw, int *ch) int *cx, int *cy, int *cw, int *ch)
{ {
@ -405,7 +407,7 @@ __evas_image_text_get_character_at_pos(Evas_Image_Font *fn, char *text,
} }
void void
__evas_image_text_get_character_number(Evas_Image_Font *fn, char *text, __evas_imlib_text_get_character_number(Evas_Imlib_Font *fn, char *text,
int num, int num,
int *cx, int *cy, int *cw, int *ch) int *cx, int *cy, int *cw, int *ch)
{ {
@ -441,14 +443,22 @@ __evas_image_text_get_character_number(Evas_Image_Font *fn, char *text,
/* rectangle externals *******************************************************/ /* rectangle externals *******************************************************/
/*****************************************************************************/ /*****************************************************************************/
void __evas_image_rectangle_draw(Display *disp, Imlib_Image dstim, Window win, void __evas_imlib_rectangle_draw(Display *disp, Imlib_Image dstim, Window win,
int win_w, int win_h, int win_w, int win_h,
int x, int y, int w, int h, int x, int y, int w, int h,
int r, int g, int b, int a) int cr, int cg, int cb, int ca)
{ {
Evas_List l; Evas_List l;
imlib_context_set_color(r, g, b, a); 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;
imlib_context_set_color(cr, cg, cb, ca);
imlib_context_set_angle(0.0); imlib_context_set_angle(0.0);
imlib_context_set_operation(IMLIB_OP_COPY); imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_color_modifier(NULL); imlib_context_set_color_modifier(NULL);
@ -457,17 +467,17 @@ void __evas_image_rectangle_draw(Display *disp, Imlib_Image dstim,
imlib_context_set_blend(1); imlib_context_set_blend(1);
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Image_Drawable *dr; Evas_Imlib_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->im == dstim) && (dr->disp == disp)) if ((dr->win == win) && (dr->disp == disp))
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Image_Update *up; Evas_Imlib_Update *up;
up = ll->data; up = ll->data;
@ -475,25 +485,12 @@ void __evas_image_rectangle_draw(Display *disp, Imlib_Image dstim,
if (RECTS_INTERSECT(up->x, up->y, up->w, up->h, if (RECTS_INTERSECT(up->x, up->y, up->w, up->h,
x, y, w, h)) x, y, w, h))
{ {
if (__evas_clip) imlib_context_set_cliprect(__evas_clip_x - up->x, __evas_clip_y - up->y, __evas_clip_w, __evas_clip_h);
else imlib_context_set_cliprect(0, 0, 0, 0);
if (!up->image) if (!up->image)
{ up->image = imlib_create_image(up->w, up->h);
DATA32 *data; imlib_context_set_image(up->image);
imlib_image_fill_rectangle(x - up->x, y - up->y, w, h);
up->image = imlib_create_image(up->w, up->h);
if (up->image)
{
imlib_context_set_image(up->image);
data = imlib_image_get_data();
memset(data, 0, up->w * up->h * sizeof(DATA32));
imlib_image_put_back_data(data);
imlib_image_set_has_alpha(1);
}
}
if (up->image)
{
imlib_context_set_image(up->image);
imlib_image_fill_rectangle(x - up->x, y - up->y, w, h);
}
} }
} }
} }
@ -520,15 +517,23 @@ void __evas_image_rectangle_draw(Display *disp, Imlib_Image dstim,
/* rectangle externals *******************************************************/ /* rectangle externals *******************************************************/
/*****************************************************************************/ /*****************************************************************************/
void __evas_image_line_draw(Display *disp, Imlib_Image dstim, Window win, void __evas_imlib_line_draw(Display *disp, Imlib_Image dstim, Window win,
int win_w, int win_h, int win_w, int win_h,
int x1, int y1, int x2, int y2, int x1, int y1, int x2, int y2,
int r, int g, int b, int a) int cr, int cg, int cb, int ca)
{ {
Evas_List l; Evas_List l;
int x, y, w, h; int x, y, w, h;
imlib_context_set_color(r, g, b, a); 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;
imlib_context_set_color(cr, cg, cb, ca);
imlib_context_set_angle(0.0); imlib_context_set_angle(0.0);
imlib_context_set_operation(IMLIB_OP_COPY); imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_color_modifier(NULL); imlib_context_set_color_modifier(NULL);
@ -546,17 +551,17 @@ void __evas_image_line_draw(Display *disp, Imlib_Image dstim, Windo
w++; h++; w++; h++;
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Image_Drawable *dr; Evas_Imlib_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->im == dstim) && (dr->disp == disp)) if ((dr->win == win) && (dr->disp == disp))
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Image_Update *up; Evas_Imlib_Update *up;
up = ll->data; up = ll->data;
@ -564,25 +569,12 @@ void __evas_image_line_draw(Display *disp, Imlib_Image dstim, Windo
if (RECTS_INTERSECT(up->x, up->y, up->w, up->h, if (RECTS_INTERSECT(up->x, up->y, up->w, up->h,
x, y, w, h)) x, y, w, h))
{ {
if (__evas_clip) imlib_context_set_cliprect(__evas_clip_x - up->x, __evas_clip_y - up->y, __evas_clip_w, __evas_clip_h);
else imlib_context_set_cliprect(0, 0, 0, 0);
if (!up->image) if (!up->image)
{ up->image = imlib_create_image(up->w, up->h);
DATA32 *data; imlib_context_set_image(up->image);
imlib_image_draw_line(x1 - up->x, y1 - up->y, x2 - up->x, y2 - up->y, 0);
up->image = imlib_create_image(up->w, up->h);
if (up->image)
{
imlib_context_set_image(up->image);
data = imlib_image_get_data();
memset(data, 0, up->w * up->h * sizeof(DATA32));
imlib_image_put_back_data(data);
imlib_image_set_has_alpha(1);
}
}
if (up->image)
{
imlib_context_set_image(up->image);
imlib_image_draw_line(x1 - up->x, y1 - up->y, x2 - up->x, y2 - up->y, 0);
}
} }
} }
} }
@ -605,57 +597,96 @@ void __evas_image_line_draw(Display *disp, Imlib_Image dstim, Windo
/*****************************************************************************/ /****************************************************************************/
/* gradient externals ********************************************************/ /* gradient externals ********************************************************/
/*****************************************************************************/ /*****************************************************************************/
Evas_Image_Graident * Evas_Imlib_Graident *
__evas_image_gradient_new(Display *disp) __evas_imlib_gradient_new(Display *disp)
{ {
return (Evas_Image_Graident *)imlib_create_color_range(); Evas_Imlib_Graident *gr;
gr = malloc(sizeof(Evas_Imlib_Graident));
gr->colors = NULL;
} }
void void
__evas_image_gradient_free(Evas_Image_Graident *gr) __evas_imlib_gradient_free(Evas_Imlib_Graident *gr)
{
imlib_context_set_color_range((Imlib_Color_Range)gr);
imlib_free_color_range();
}
void
__evas_image_gradient_color_add(Evas_Image_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_image_gradient_draw(Evas_Image_Graident *gr, Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, int x, int y, int w, int h, double angle)
{ {
Evas_List l; Evas_List l;
if (gr->colors)
{
for (l = gr->colors; l; l = l->next)
{
free(l->data);
}
evas_list_free(gr->colors);
}
free(gr);
}
void
__evas_imlib_gradient_color_add(Evas_Imlib_Graident *gr, int r, int g, int b, int a, int dist)
{
Evas_Imlib_Color *cl;
cl = malloc(sizeof(Evas_Imlib_Color));
cl->r = r;
cl->g = g;
cl->b = b;
cl->a = a;
cl->dist = dist;
gr->colors = evas_list_append(gr->colors, cl);
}
void
__evas_imlib_gradient_draw(Evas_Imlib_Graident *gr, Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, int x, int y, int w, int h, double angle)
{
Evas_List l;
Imlib_Color_Range cr;
if ((__evas_clip) && (__evas_clip_a == 0)) return;
imlib_context_set_angle(angle); imlib_context_set_angle(angle);
imlib_context_set_operation(IMLIB_OP_COPY); imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_color_modifier(NULL); imlib_context_set_color_modifier(NULL);
imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT); imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT);
imlib_context_set_color_range((Imlib_Color_Range)gr);
imlib_context_set_anti_alias(1); imlib_context_set_anti_alias(1);
imlib_context_set_blend(1); imlib_context_set_blend(1);
cr = imlib_create_color_range();
imlib_context_set_color_range(cr);
{
Evas_List l;
for (l = gr->colors; l; l = l->next)
{
Evas_Imlib_Color *cl;
cl = l->data;
if (__evas_clip)
imlib_context_set_color((cl->r * __evas_clip_r) / 255,
(cl->g * __evas_clip_g) / 255,
(cl->b * __evas_clip_b) / 255,
(cl->a * __evas_clip_a) / 255);
else
imlib_context_set_color(cl->r, cl->g, cl->b, cl->a);
imlib_add_color_to_color_range(cl->dist);
}
}
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Image_Drawable *dr; Evas_Imlib_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->im == dstim) && (dr->disp == disp)) if ((dr->win == win) && (dr->disp == disp))
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Image_Update *up; Evas_Imlib_Update *up;
up = ll->data; up = ll->data;
@ -663,50 +694,43 @@ __evas_image_gradient_draw(Evas_Image_Graident *gr, Display *disp, Imlib_Image d
if (RECTS_INTERSECT(up->x, up->y, up->w, up->h, if (RECTS_INTERSECT(up->x, up->y, up->w, up->h,
x, y, w, h)) x, y, w, h))
{ {
if (__evas_clip) imlib_context_set_cliprect(__evas_clip_x - up->x, __evas_clip_y - up->y, __evas_clip_w, __evas_clip_h);
else imlib_context_set_cliprect(0, 0, 0, 0);
if (!up->image) if (!up->image)
{ up->image = imlib_create_image(up->w, up->h);
DATA32 *data; imlib_context_set_image(up->image);
imlib_image_fill_color_range_rectangle(x - up->x, y - up->y, w, h, angle);
up->image = imlib_create_image(up->w, up->h);
if (up->image)
{
imlib_context_set_image(up->image);
data = imlib_image_get_data();
memset(data, 0, up->w * up->h * sizeof(DATA32));
imlib_image_put_back_data(data);
imlib_image_set_has_alpha(1);
}
}
if (up->image)
{
imlib_context_set_image(up->image);
imlib_image_fill_color_range_rectangle(x - up->x, y - up->y, w, h, angle);
}
} }
} }
} }
} }
imlib_free_color_range();
} }
/************/ /************/
/* polygons */ /* polygons */
/************/ /************/
void void
__evas_image_poly_draw (Display *disp, Imlib_Image dstim, Window win, __evas_imlib_poly_draw (Display *disp, Imlib_Image dstim, Window win,
int win_w, int win_h, int win_w, int win_h,
Evas_List points, Evas_List points,
int r, int g, int b, int a) int cr, int cg, int cb, int ca)
{ {
Evas_List l, l2; Evas_List l, l2;
int x, y, w, h; int x, y, w, h;
imlib_context_set_color(r, g, b, a); 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;
imlib_context_set_color(cr, cg, cb, ca);
imlib_context_set_angle(0.0); imlib_context_set_angle(0.0);
imlib_context_set_operation(IMLIB_OP_COPY); imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_color_modifier(NULL); imlib_context_set_color_modifier(NULL);
@ -747,17 +771,17 @@ __evas_image_poly_draw (Display *disp, Imlib_Image dstim, Window win,
} }
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Image_Drawable *dr; Evas_Imlib_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->im == dstim) && (dr->disp == disp)) if ((dr->win == win) && (dr->disp == disp))
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Image_Update *up; Evas_Imlib_Update *up;
up = ll->data; up = ll->data;
@ -767,34 +791,22 @@ __evas_image_poly_draw (Display *disp, Imlib_Image dstim, Window win,
{ {
ImlibPolygon pol; ImlibPolygon pol;
if (__evas_clip) imlib_context_set_cliprect(__evas_clip_x - up->x, __evas_clip_y - up->y, __evas_clip_w, __evas_clip_h);
else imlib_context_set_cliprect(0, 0, 0, 0);
if (!up->image) if (!up->image)
up->image = imlib_create_image(up->w, up->h);
imlib_context_set_image(up->image);
pol = imlib_polygon_new();
for (l2 = points; l2; l2 = l2->next)
{ {
DATA32 *data; Evas_Point p;
up->image = imlib_create_image(up->w, up->h); p = l2->data;
if (up->image) imlib_polygon_add_point(pol, p->x - up->x, p->y - up->y);
{
imlib_context_set_image(up->image);
data = imlib_image_get_data();
memset(data, 0, up->w * up->h * sizeof(DATA32));
imlib_image_put_back_data(data);
imlib_image_set_has_alpha(1);
}
}
if (up->image)
{
imlib_context_set_image(up->image);
pol = imlib_polygon_new();
for (l2 = points; l2; l2 = l2->next)
{
Evas_Point p;
p = l2->data;
imlib_polygon_add_point(pol, p->x - up->x, p->y - up->y);
}
imlib_image_fill_polygon(pol);
imlib_polygon_free(pol);
} }
imlib_image_fill_polygon(pol);
imlib_polygon_free(pol);
} }
} }
} }
@ -810,6 +822,9 @@ __evas_image_poly_draw (Display *disp, Imlib_Image dstim, Window win,
/*****************************************************************************/ /*****************************************************************************/
/* general externals *********************************************************/ /* general externals *********************************************************/
/*****************************************************************************/ /*****************************************************************************/
@ -818,7 +833,7 @@ static Visual *__evas_visual = NULL;
static Colormap __evas_cmap = 0; static Colormap __evas_cmap = 0;
void void
__evas_image_set_clip_rect(int on, int x, int y, int w, int h, int r, int g, int b, int a) __evas_imlib_set_clip_rect(int on, int x, int y, int w, int h, int r, int g, int b, int a)
{ {
__evas_clip = on; __evas_clip = on;
__evas_clip_x = x; __evas_clip_x = x;
@ -832,44 +847,43 @@ __evas_image_set_clip_rect(int on, int x, int y, int w, int h, int r, int g, int
} }
void void
__evas_image_sync(Display *disp) __evas_imlib_sync(Display *disp)
{ {
XSync(disp, False); XSync(disp, False);
} }
void void
__evas_image_flush_draw(Display *disp, Imlib_Image dstim, Window win) __evas_imlib_flush_draw(Display *disp, Imlib_Image dstim, Window win)
{ {
Evas_List l; Evas_List l;
imlib_context_set_blend(1); imlib_context_set_display(disp);
imlib_context_set_visual(__evas_visual);
imlib_context_set_colormap(__evas_cmap);
imlib_context_set_drawable(win);
imlib_context_set_dither(1);
imlib_context_set_blend(0);
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Image_Drawable *dr; Evas_Imlib_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->im == dstim)) if ((dr->win == win) && (dr->disp == disp))
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Image_Update *up; Evas_Imlib_Update *up;
up = ll->data; up = ll->data;
if (up->image) if (up->image)
{ {
int w, h;
w = up->w; h = up->h;
imlib_context_set_image(dr->im);
imlib_blend_image_onto_image(up->image, 1,
0, 0, w, h,
up->x, up->y, w, h);
imlib_context_set_image(up->image); imlib_context_set_image(up->image);
imlib_render_image_on_drawable(up->x, up->y);
imlib_free_image(); imlib_free_image();
} }
free(up); free(up);
@ -884,15 +898,15 @@ __evas_image_flush_draw(Display *disp, Imlib_Image dstim, Window win)
drawable_list = NULL; drawable_list = NULL;
} }
int int
__evas_image_capable(Display *disp) __evas_imlib_capable(Display *disp)
{ {
return 1; return 1;
} }
Visual * Visual *
__evas_image_get_visual(Display *disp, int screen) __evas_imlib_get_visual(Display *disp, int screen)
{ {
int depth; int depth;
@ -901,21 +915,21 @@ __evas_image_get_visual(Display *disp, int screen)
} }
XVisualInfo * XVisualInfo *
__evas_image_get_visual_info(Display *disp, int screen) __evas_imlib_get_visual_info(Display *disp, int screen)
{ {
static XVisualInfo *vi = NULL; static XVisualInfo *vi = NULL;
XVisualInfo vi_template; XVisualInfo vi_template;
int n; int n;
if (vi) return vi; if (vi) return vi;
vi_template.visualid = (__evas_image_get_visual(disp, screen))->visualid; vi_template.visualid = (__evas_imlib_get_visual(disp, screen))->visualid;
vi_template.screen = screen; vi_template.screen = screen;
vi = XGetVisualInfo(disp, VisualIDMask | VisualScreenMask, &vi_template ,&n); vi = XGetVisualInfo(disp, VisualIDMask | VisualScreenMask, &vi_template ,&n);
return vi; return vi;
} }
Colormap Colormap
__evas_image_get_colormap(Display *disp, int screen) __evas_imlib_get_colormap(Display *disp, int screen)
{ {
Visual *v; Visual *v;
@ -928,35 +942,37 @@ __evas_image_get_colormap(Display *disp, int screen)
} }
void void
__evas_image_init(Display *disp, int screen, int colors) __evas_imlib_init(Display *disp, int screen, int colors)
{ {
static int initted = 0; static int initted = 0;
if (!initted) if (!initted)
{ {
imlib_set_color_usage(colors);
imlib_set_font_cache_size(1024 * 1024); imlib_set_font_cache_size(1024 * 1024);
imlib_set_cache_size(8 * 1024 * 1024); imlib_set_cache_size(8 * 1024 * 1024);
initted = 1; initted = 1;
} }
imlib_set_color_usage(colors);
} }
void void
__evas_image_draw_add_rect(Display *disp, Imlib_Image dstim, Window win, __evas_imlib_draw_add_rect(Display *disp, Imlib_Image dstim, Window win,
int x, int y, int w, int h) int x, int y, int w, int h)
{ {
Evas_List l; Evas_List l;
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Image_Drawable *dr; Evas_Imlib_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->im == dstim) && (dr->disp == disp)) if ((dr->win == win) && (dr->disp == disp))
{ {
Evas_Image_Update *up; Evas_Imlib_Update *up;
up = malloc(sizeof(Evas_Image_Update)); up = malloc(sizeof(Evas_Imlib_Update));
up->x = x; up->x = x;
up->y = y; up->y = y;
up->w = w; up->w = w;
@ -967,14 +983,14 @@ __evas_image_draw_add_rect(Display *disp, Imlib_Image dstim, Window win,
return; return;
} }
{ {
Evas_Image_Drawable *dr; Evas_Imlib_Drawable *dr;
Evas_Image_Update *up; Evas_Imlib_Update *up;
dr = malloc(sizeof(Evas_Image_Drawable)); dr = malloc(sizeof(Evas_Imlib_Drawable));
dr->im = dstim; dr->win = win;
dr->disp = disp; dr->disp = disp;
dr->tmp_images = NULL; dr->tmp_images = NULL;
up = malloc(sizeof(Evas_Image_Update)); up = malloc(sizeof(Evas_Imlib_Update));
up->x = x; up->x = x;
up->y = y; up->y = y;
up->w = w; up->w = w;

View File

@ -18,7 +18,7 @@
#include <Imlib2.h> #include <Imlib2.h>
#ifndef SPANS_COMMON #ifndef SPANS_COMMON
#define SPANS_COMMON(x1, w1, x2, w2) \ # define SPANS_COMMON(x1, w1, x2, w2) \
(!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1))))) (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1)))))
#define RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) \ #define RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) \
((SPANS_COMMON((x), (w), (xx), (ww))) && (SPANS_COMMON((y), (h), (yy), (hh)))) ((SPANS_COMMON((x), (w), (xx), (ww))) && (SPANS_COMMON((y), (h), (yy), (hh))))
@ -26,14 +26,14 @@
typedef void Evas_Image_Image; typedef void Evas_Image_Image;
typedef void Evas_Image_Font; typedef void Evas_Image_Font;
typedef void Evas_Image_Graident;
typedef struct _evas_image_drawable Evas_Image_Drawable; typedef struct _evas_image_drawable Evas_Image_Drawable;
typedef struct _evas_image_update Evas_Image_Update; typedef struct _evas_image_update Evas_Image_Update;
typedef struct _evas_image_color Evas_Image_Color;
typedef struct _evas_image_gradient Evas_Image_Graident;
struct _evas_image_drawable struct _evas_image_drawable
{ {
Display *disp;
Imlib_Image im; Imlib_Image im;
Evas_List tmp_images; Evas_List tmp_images;
}; };
@ -44,6 +44,17 @@ struct _evas_image_update
int x, y, w, h; int x, y, w, h;
}; };
struct _evas_image_color
{
int r, g, b, a;
int dist;
};
struct _evas_image_gradient
{
Evas_List colors;
};
/***************/ /***************/
/* image stuff */ /* image stuff */
/***************/ /***************/

View File

@ -1,7 +1,6 @@
#include "evas_image_routines.h"
#include "evas_imlib_routines.h" static void __evas_image_image_cache_flush(Display *disp);
static void __evas_imlib_image_cache_flush(Display *disp);
static int __evas_anti_alias = 1; static int __evas_anti_alias = 1;
static Evas_List drawable_list = NULL; static Evas_List drawable_list = NULL;
@ -21,7 +20,7 @@ static int __evas_clip_a = 0;
/*****************************************************************************/ /*****************************************************************************/
static void static void
__evas_imlib_image_cache_flush(Display *disp) __evas_image_image_cache_flush(Display *disp)
{ {
int size; int size;
@ -34,21 +33,21 @@ __evas_imlib_image_cache_flush(Display *disp)
/* image externals ***********************************************************/ /* image externals ***********************************************************/
/*****************************************************************************/ /*****************************************************************************/
Evas_Imlib_Image * Evas_Image_Image *
__evas_imlib_image_new_from_file(Display *disp, char *file) __evas_image_image_new_from_file(Display *disp, char *file)
{ {
return (Evas_Imlib_Image *)imlib_load_image(file); return (Evas_Image_Image *)imlib_load_image(file);
} }
void void
__evas_imlib_image_free(Evas_Imlib_Image *im) __evas_image_image_free(Evas_Image_Image *im)
{ {
imlib_context_set_image((Imlib_Image)im); imlib_context_set_image((Imlib_Image)im);
imlib_free_image(); imlib_free_image();
} }
void void
__evas_imlib_image_cache_empty(Display *disp) __evas_image_image_cache_empty(Display *disp)
{ {
int size; int size;
@ -58,19 +57,19 @@ __evas_imlib_image_cache_empty(Display *disp)
} }
void void
__evas_imlib_image_cache_set_size(Display *disp, int size) __evas_image_image_cache_set_size(Display *disp, int size)
{ {
imlib_set_cache_size(size); imlib_set_cache_size(size);
} }
int int
__evas_imlib_image_cache_get_size(Display *disp) __evas_image_image_cache_get_size(Display *disp)
{ {
return imlib_get_cache_size(); return imlib_get_cache_size();
} }
void void
__evas_imlib_image_draw(Evas_Imlib_Image *im, __evas_image_image_draw(Evas_Image_Image *im,
Display *disp, Imlib_Image dstim, Window w, int win_w, int win_h, Display *disp, Imlib_Image dstim, Window w, int win_w, int win_h,
int src_x, int src_y, int src_w, int src_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 dst_x, int dst_y, int dst_w, int dst_h,
@ -113,17 +112,17 @@ __evas_imlib_image_draw(Evas_Imlib_Image *im,
imlib_context_set_blend(1); imlib_context_set_blend(1);
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Imlib_Drawable *dr; Evas_Image_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->win == w) && (dr->disp == disp)) if (dr->im == dstim)
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Imlib_Update *up; Evas_Image_Update *up;
up = ll->data; up = ll->data;
@ -138,8 +137,20 @@ __evas_imlib_image_draw(Evas_Imlib_Image *im,
__evas_clip_h); __evas_clip_h);
else imlib_context_set_cliprect(0, 0, 0, 0); else imlib_context_set_cliprect(0, 0, 0, 0);
if (!up->image) if (!up->image)
up->image = imlib_create_image(up->w, up->h); {
DATA32 *data;
up->image = imlib_create_image(up->w, up->h);
if (up->image)
{
imlib_context_set_image(up->image);
data = imlib_image_get_data();
memset(data, 0, up->w * up->h * sizeof(DATA32));
imlib_image_put_back_data(data);
imlib_image_set_has_alpha(1);
}
}
imlib_context_set_image(up->image); imlib_context_set_image(up->image);
imlib_blend_image_onto_image(im, 0, imlib_blend_image_onto_image(im, 0,
src_x, src_y, src_w, src_h, src_x, src_y, src_w, src_h,
@ -156,21 +167,21 @@ __evas_imlib_image_draw(Evas_Imlib_Image *im,
} }
int int
__evas_imlib_image_get_width(Evas_Imlib_Image *im) __evas_image_image_get_width(Evas_Image_Image *im)
{ {
imlib_context_set_image((Imlib_Image)im); imlib_context_set_image((Imlib_Image)im);
return imlib_image_get_width(); return imlib_image_get_width();
} }
int int
__evas_imlib_image_get_height(Evas_Imlib_Image *im) __evas_image_image_get_height(Evas_Image_Image *im)
{ {
imlib_context_set_image((Imlib_Image)im); imlib_context_set_image((Imlib_Image)im);
return imlib_image_get_height(); return imlib_image_get_height();
} }
void void
__evas_imlib_image_set_borders(Evas_Imlib_Image *im, int left, int right, __evas_image_image_set_borders(Evas_Image_Image *im, int left, int right,
int top, int bottom) int top, int bottom)
{ {
Imlib_Border bd; Imlib_Border bd;
@ -184,7 +195,7 @@ __evas_imlib_image_set_borders(Evas_Imlib_Image *im, int left, int right,
} }
void void
__evas_imlib_image_set_smooth_scaling(int on) __evas_image_image_set_smooth_scaling(int on)
{ {
__evas_anti_alias = on; __evas_anti_alias = on;
} }
@ -223,52 +234,52 @@ __evas_imlib_image_set_smooth_scaling(int on)
/* font externals ************************************************************/ /* font externals ************************************************************/
/*****************************************************************************/ /*****************************************************************************/
Evas_Imlib_Font * Evas_Image_Font *
__evas_imlib_text_font_new(Display *disp, char *font, int size) __evas_image_text_font_new(Display *disp, char *font, int size)
{ {
char buf[4096]; char buf[4096];
sprintf(buf, "%s/%i", font, size); sprintf(buf, "%s/%i", font, size);
return (Evas_Imlib_Font *)imlib_load_font(buf); return (Evas_Image_Font *)imlib_load_font(buf);
} }
void void
__evas_imlib_text_font_free(Evas_Imlib_Font *fn) __evas_image_text_font_free(Evas_Image_Font *fn)
{ {
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
imlib_free_font(); imlib_free_font();
} }
int int
__evas_imlib_text_font_get_ascent(Evas_Imlib_Font *fn) __evas_image_text_font_get_ascent(Evas_Image_Font *fn)
{ {
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
return imlib_get_font_ascent(); return imlib_get_font_ascent();
} }
int int
__evas_imlib_text_font_get_descent(Evas_Imlib_Font *fn) __evas_image_text_font_get_descent(Evas_Image_Font *fn)
{ {
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
return imlib_get_font_descent(); return imlib_get_font_descent();
} }
int int
__evas_imlib_text_font_get_max_ascent(Evas_Imlib_Font *fn) __evas_image_text_font_get_max_ascent(Evas_Image_Font *fn)
{ {
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
return imlib_get_maximum_font_ascent(); return imlib_get_maximum_font_ascent();
} }
int int
__evas_imlib_text_font_get_max_descent(Evas_Imlib_Font *fn) __evas_image_text_font_get_max_descent(Evas_Image_Font *fn)
{ {
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
return imlib_get_maximum_font_descent(); return imlib_get_maximum_font_descent();
} }
void void
__evas_imlib_text_font_get_advances(Evas_Imlib_Font *fn, char *text, __evas_image_text_font_get_advances(Evas_Image_Font *fn, char *text,
int *advance_horiz, int *advance_horiz,
int *advance_vert) int *advance_vert)
{ {
@ -277,32 +288,32 @@ __evas_imlib_text_font_get_advances(Evas_Imlib_Font *fn, char *text,
} }
int int
__evas_imlib_text_font_get_first_inset(Evas_Imlib_Font *fn, char *text) __evas_image_text_font_get_first_inset(Evas_Image_Font *fn, char *text)
{ {
imlib_context_set_font((Imlib_Font)fn); imlib_context_set_font((Imlib_Font)fn);
return imlib_get_text_inset(text); return imlib_get_text_inset(text);
} }
void void
__evas_imlib_text_font_add_path(char *path) __evas_image_text_font_add_path(char *path)
{ {
imlib_add_path_to_font_path(path); imlib_add_path_to_font_path(path);
} }
void void
__evas_imlib_text_font_del_path(char *path) __evas_image_text_font_del_path(char *path)
{ {
imlib_remove_path_from_font_path(path); imlib_remove_path_from_font_path(path);
} }
char ** char **
__evas_imlib_text_font_list_paths(int *count) __evas_image_text_font_list_paths(int *count)
{ {
return imlib_list_font_path(count); return imlib_list_font_path(count);
} }
void void
__evas_imlib_text_cache_empty(Display *disp) __evas_image_text_cache_empty(Display *disp)
{ {
int size; int size;
@ -312,19 +323,19 @@ __evas_imlib_text_cache_empty(Display *disp)
} }
void void
__evas_imlib_text_cache_set_size(Display *disp, int size) __evas_image_text_cache_set_size(Display *disp, int size)
{ {
imlib_set_font_cache_size(size); imlib_set_font_cache_size(size);
} }
int int
__evas_imlib_text_cache_get_size(Display *disp) __evas_image_text_cache_get_size(Display *disp)
{ {
return imlib_get_font_cache_size(); return imlib_get_font_cache_size();
} }
void void
__evas_imlib_text_draw(Evas_Imlib_Font *fn, Display *disp, Imlib_Image dstim, Window win, __evas_image_text_draw(Evas_Image_Font *fn, Display *disp, Imlib_Image dstim, Window win,
int win_w, int win_h, int x, int y, char *text, int win_w, int win_h, int x, int y, char *text,
int cr, int cg, int cb, int ca) int cr, int cg, int cb, int ca)
{ {
@ -351,17 +362,17 @@ __evas_imlib_text_draw(Evas_Imlib_Font *fn, Display *disp, Imlib_Image dstim, Wi
imlib_get_text_size(text, &w, &h); imlib_get_text_size(text, &w, &h);
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Imlib_Drawable *dr; Evas_Image_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->win == win) && (dr->disp == disp)) if (dr->im == dstim)
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Imlib_Update *up; Evas_Image_Update *up;
up = ll->data; up = ll->data;
@ -375,8 +386,20 @@ __evas_imlib_text_draw(Evas_Imlib_Font *fn, Display *disp, Imlib_Image dstim, Wi
__evas_clip_w, __evas_clip_w,
__evas_clip_h); __evas_clip_h);
else imlib_context_set_cliprect(0, 0, 0, 0); else imlib_context_set_cliprect(0, 0, 0, 0);
if (!up->image) if (!up->image)
up->image = imlib_create_image(up->w, up->h); {
DATA32 *data;
up->image = imlib_create_image(up->w, up->h);
if (up->image)
{
imlib_context_set_image(up->image);
data = imlib_image_get_data();
memset(data, 0, up->w * up->h * sizeof(DATA32));
imlib_image_put_back_data(data);
imlib_image_set_has_alpha(1);
}
}
imlib_context_set_image(up->image); imlib_context_set_image(up->image);
imlib_text_draw(x - up->x, y - up->y, text); imlib_text_draw(x - up->x, y - up->y, text);
} }
@ -386,7 +409,7 @@ __evas_imlib_text_draw(Evas_Imlib_Font *fn, Display *disp, Imlib_Image dstim, Wi
} }
void void
__evas_imlib_text_get_size(Evas_Imlib_Font *fn, char *text, int *w, int *h) __evas_image_text_get_size(Evas_Image_Font *fn, char *text, int *w, int *h)
{ {
if ((!fn) || (!text)) if ((!fn) || (!text))
{ {
@ -398,7 +421,7 @@ __evas_imlib_text_get_size(Evas_Imlib_Font *fn, char *text, int *w, int *h)
} }
int int
__evas_imlib_text_get_character_at_pos(Evas_Imlib_Font *fn, char *text, __evas_image_text_get_character_at_pos(Evas_Image_Font *fn, char *text,
int x, int y, int x, int y,
int *cx, int *cy, int *cw, int *ch) int *cx, int *cy, int *cw, int *ch)
{ {
@ -407,7 +430,7 @@ __evas_imlib_text_get_character_at_pos(Evas_Imlib_Font *fn, char *text,
} }
void void
__evas_imlib_text_get_character_number(Evas_Imlib_Font *fn, char *text, __evas_image_text_get_character_number(Evas_Image_Font *fn, char *text,
int num, int num,
int *cx, int *cy, int *cw, int *ch) int *cx, int *cy, int *cw, int *ch)
{ {
@ -443,7 +466,7 @@ __evas_imlib_text_get_character_number(Evas_Imlib_Font *fn, char *text,
/* rectangle externals *******************************************************/ /* rectangle externals *******************************************************/
/*****************************************************************************/ /*****************************************************************************/
void __evas_imlib_rectangle_draw(Display *disp, Imlib_Image dstim, Window win, void __evas_image_rectangle_draw(Display *disp, Imlib_Image dstim, Window win,
int win_w, int win_h, int win_w, int win_h,
int x, int y, int w, int h, int x, int y, int w, int h,
int cr, int cg, int cb, int ca) int cr, int cg, int cb, int ca)
@ -467,17 +490,17 @@ void __evas_imlib_rectangle_draw(Display *disp, Imlib_Image dstim,
imlib_context_set_blend(1); imlib_context_set_blend(1);
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Imlib_Drawable *dr; Evas_Image_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->win == win) && (dr->disp == disp)) if (dr->im == dstim)
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Imlib_Update *up; Evas_Image_Update *up;
up = ll->data; up = ll->data;
@ -487,8 +510,20 @@ void __evas_imlib_rectangle_draw(Display *disp, Imlib_Image dstim,
{ {
if (__evas_clip) imlib_context_set_cliprect(__evas_clip_x - up->x, __evas_clip_y - up->y, __evas_clip_w, __evas_clip_h); if (__evas_clip) imlib_context_set_cliprect(__evas_clip_x - up->x, __evas_clip_y - up->y, __evas_clip_w, __evas_clip_h);
else imlib_context_set_cliprect(0, 0, 0, 0); else imlib_context_set_cliprect(0, 0, 0, 0);
if (!up->image) if (!up->image)
up->image = imlib_create_image(up->w, up->h); {
DATA32 *data;
up->image = imlib_create_image(up->w, up->h);
if (up->image)
{
imlib_context_set_image(up->image);
data = imlib_image_get_data();
memset(data, 0, up->w * up->h * sizeof(DATA32));
imlib_image_put_back_data(data);
imlib_image_set_has_alpha(1);
}
}
imlib_context_set_image(up->image); imlib_context_set_image(up->image);
imlib_image_fill_rectangle(x - up->x, y - up->y, w, h); imlib_image_fill_rectangle(x - up->x, y - up->y, w, h);
} }
@ -517,7 +552,7 @@ void __evas_imlib_rectangle_draw(Display *disp, Imlib_Image dstim,
/* rectangle externals *******************************************************/ /* rectangle externals *******************************************************/
/*****************************************************************************/ /*****************************************************************************/
void __evas_imlib_line_draw(Display *disp, Imlib_Image dstim, Window win, void __evas_image_line_draw(Display *disp, Imlib_Image dstim, Window win,
int win_w, int win_h, int win_w, int win_h,
int x1, int y1, int x2, int y2, int x1, int y1, int x2, int y2,
int cr, int cg, int cb, int ca) int cr, int cg, int cb, int ca)
@ -551,17 +586,17 @@ void __evas_imlib_line_draw(Display *disp, Imlib_Image dstim, Windo
w++; h++; w++; h++;
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Imlib_Drawable *dr; Evas_Image_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->win == win) && (dr->disp == disp)) if (dr->im == dstim)
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Imlib_Update *up; Evas_Image_Update *up;
up = ll->data; up = ll->data;
@ -571,8 +606,20 @@ void __evas_imlib_line_draw(Display *disp, Imlib_Image dstim, Windo
{ {
if (__evas_clip) imlib_context_set_cliprect(__evas_clip_x - up->x, __evas_clip_y - up->y, __evas_clip_w, __evas_clip_h); if (__evas_clip) imlib_context_set_cliprect(__evas_clip_x - up->x, __evas_clip_y - up->y, __evas_clip_w, __evas_clip_h);
else imlib_context_set_cliprect(0, 0, 0, 0); else imlib_context_set_cliprect(0, 0, 0, 0);
if (!up->image) if (!up->image)
up->image = imlib_create_image(up->w, up->h); {
DATA32 *data;
up->image = imlib_create_image(up->w, up->h);
if (up->image)
{
imlib_context_set_image(up->image);
data = imlib_image_get_data();
memset(data, 0, up->w * up->h * sizeof(DATA32));
imlib_image_put_back_data(data);
imlib_image_set_has_alpha(1);
}
}
imlib_context_set_image(up->image); imlib_context_set_image(up->image);
imlib_image_draw_line(x1 - up->x, y1 - up->y, x2 - up->x, y2 - up->y, 0); imlib_image_draw_line(x1 - up->x, y1 - up->y, x2 - up->x, y2 - up->y, 0);
} }
@ -602,17 +649,17 @@ void __evas_imlib_line_draw(Display *disp, Imlib_Image dstim, Windo
/*****************************************************************************/ /*****************************************************************************/
Evas_Imlib_Graident * Evas_Image_Graident *
__evas_imlib_gradient_new(Display *disp) __evas_image_gradient_new(Display *disp)
{ {
Evas_Imlib_Graident *gr; Evas_Image_Graident *gr;
gr = malloc(sizeof(Evas_Imlib_Graident)); gr = malloc(sizeof(Evas_Image_Graident));
gr->colors = NULL; gr->colors = NULL;
} }
void void
__evas_imlib_gradient_free(Evas_Imlib_Graident *gr) __evas_image_gradient_free(Evas_Image_Graident *gr)
{ {
Evas_List l; Evas_List l;
@ -628,11 +675,11 @@ __evas_imlib_gradient_free(Evas_Imlib_Graident *gr)
} }
void void
__evas_imlib_gradient_color_add(Evas_Imlib_Graident *gr, int r, int g, int b, int a, int dist) __evas_image_gradient_color_add(Evas_Image_Graident *gr, int r, int g, int b, int a, int dist)
{ {
Evas_Imlib_Color *cl; Evas_Image_Color *cl;
cl = malloc(sizeof(Evas_Imlib_Color)); cl = malloc(sizeof(Evas_Image_Color));
cl->r = r; cl->r = r;
cl->g = g; cl->g = g;
cl->b = b; cl->b = b;
@ -642,7 +689,7 @@ __evas_imlib_gradient_color_add(Evas_Imlib_Graident *gr, int r, int g, int b, in
} }
void void
__evas_imlib_gradient_draw(Evas_Imlib_Graident *gr, Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, int x, int y, int w, int h, double angle) __evas_image_gradient_draw(Evas_Image_Graident *gr, Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, int x, int y, int w, int h, double angle)
{ {
Evas_List l; Evas_List l;
Imlib_Color_Range cr; Imlib_Color_Range cr;
@ -661,7 +708,7 @@ __evas_imlib_gradient_draw(Evas_Imlib_Graident *gr, Display *disp, Imlib_Image d
for (l = gr->colors; l; l = l->next) for (l = gr->colors; l; l = l->next)
{ {
Evas_Imlib_Color *cl; Evas_Image_Color *cl;
cl = l->data; cl = l->data;
if (__evas_clip) if (__evas_clip)
@ -676,17 +723,17 @@ __evas_imlib_gradient_draw(Evas_Imlib_Graident *gr, Display *disp, Imlib_Image d
} }
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Imlib_Drawable *dr; Evas_Image_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->win == win) && (dr->disp == disp)) if (dr->im == dstim)
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Imlib_Update *up; Evas_Image_Update *up;
up = ll->data; up = ll->data;
@ -696,8 +743,20 @@ __evas_imlib_gradient_draw(Evas_Imlib_Graident *gr, Display *disp, Imlib_Image d
{ {
if (__evas_clip) imlib_context_set_cliprect(__evas_clip_x - up->x, __evas_clip_y - up->y, __evas_clip_w, __evas_clip_h); if (__evas_clip) imlib_context_set_cliprect(__evas_clip_x - up->x, __evas_clip_y - up->y, __evas_clip_w, __evas_clip_h);
else imlib_context_set_cliprect(0, 0, 0, 0); else imlib_context_set_cliprect(0, 0, 0, 0);
if (!up->image) if (!up->image)
up->image = imlib_create_image(up->w, up->h); {
DATA32 *data;
up->image = imlib_create_image(up->w, up->h);
if (up->image)
{
imlib_context_set_image(up->image);
data = imlib_image_get_data();
memset(data, 0, up->w * up->h * sizeof(DATA32));
imlib_image_put_back_data(data);
imlib_image_set_has_alpha(1);
}
}
imlib_context_set_image(up->image); imlib_context_set_image(up->image);
imlib_image_fill_color_range_rectangle(x - up->x, y - up->y, w, h, angle); imlib_image_fill_color_range_rectangle(x - up->x, y - up->y, w, h, angle);
} }
@ -714,7 +773,7 @@ __evas_imlib_gradient_draw(Evas_Imlib_Graident *gr, Display *disp, Imlib_Image d
/* polygons */ /* polygons */
/************/ /************/
void void
__evas_imlib_poly_draw (Display *disp, Imlib_Image dstim, Window win, __evas_image_poly_draw (Display *disp, Imlib_Image dstim, Window win,
int win_w, int win_h, int win_w, int win_h,
Evas_List points, Evas_List points,
int cr, int cg, int cb, int ca) int cr, int cg, int cb, int ca)
@ -771,17 +830,17 @@ __evas_imlib_poly_draw (Display *disp, Imlib_Image dstim, Window win,
} }
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Imlib_Drawable *dr; Evas_Image_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->win == win) && (dr->disp == disp)) if (dr->im == dstim)
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Imlib_Update *up; Evas_Image_Update *up;
up = ll->data; up = ll->data;
@ -794,8 +853,20 @@ __evas_imlib_poly_draw (Display *disp, Imlib_Image dstim, Window win,
if (__evas_clip) imlib_context_set_cliprect(__evas_clip_x - up->x, __evas_clip_y - up->y, __evas_clip_w, __evas_clip_h); if (__evas_clip) imlib_context_set_cliprect(__evas_clip_x - up->x, __evas_clip_y - up->y, __evas_clip_w, __evas_clip_h);
else imlib_context_set_cliprect(0, 0, 0, 0); else imlib_context_set_cliprect(0, 0, 0, 0);
if (!up->image) if (!up->image)
up->image = imlib_create_image(up->w, up->h); {
DATA32 *data;
up->image = imlib_create_image(up->w, up->h);
if (up->image)
{
imlib_context_set_image(up->image);
data = imlib_image_get_data();
memset(data, 0, up->w * up->h * sizeof(DATA32));
imlib_image_put_back_data(data);
imlib_image_set_has_alpha(1);
}
}
imlib_context_set_image(up->image); imlib_context_set_image(up->image);
pol = imlib_polygon_new(); pol = imlib_polygon_new();
for (l2 = points; l2; l2 = l2->next) for (l2 = points; l2; l2 = l2->next)
@ -833,7 +904,7 @@ static Visual *__evas_visual = NULL;
static Colormap __evas_cmap = 0; static Colormap __evas_cmap = 0;
void void
__evas_imlib_set_clip_rect(int on, int x, int y, int w, int h, int r, int g, int b, int a) __evas_image_set_clip_rect(int on, int x, int y, int w, int h, int r, int g, int b, int a)
{ {
__evas_clip = on; __evas_clip = on;
__evas_clip_x = x; __evas_clip_x = x;
@ -847,43 +918,43 @@ __evas_imlib_set_clip_rect(int on, int x, int y, int w, int h, int r, int g, int
} }
void void
__evas_imlib_sync(Display *disp) __evas_image_sync(Display *disp)
{ {
XSync(disp, False);
} }
void void
__evas_imlib_flush_draw(Display *disp, Imlib_Image dstim, Window win) __evas_image_flush_draw(Display *disp, Imlib_Image dstim, Window win)
{ {
Evas_List l; Evas_List l;
imlib_context_set_display(disp); imlib_context_set_blend(1);
imlib_context_set_visual(__evas_visual);
imlib_context_set_colormap(__evas_cmap);
imlib_context_set_drawable(win);
imlib_context_set_dither(1);
imlib_context_set_blend(0);
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Imlib_Drawable *dr; Evas_Image_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->win == win) && (dr->disp == disp)) if (dr->im == dstim)
{ {
Evas_List ll; Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next) for (ll = dr->tmp_images; ll; ll = ll->next)
{ {
Evas_Imlib_Update *up; Evas_Image_Update *up;
up = ll->data; up = ll->data;
if (up->image) if (up->image)
{ {
int w, h;
w = up->w; h = up->h;
imlib_context_set_image(dr->im);
imlib_blend_image_onto_image(up->image, 1,
0, 0, w, h,
up->x, up->y, w, h);
imlib_context_set_image(up->image); imlib_context_set_image(up->image);
imlib_render_image_on_drawable(up->x, up->y);
imlib_free_image(); imlib_free_image();
} }
free(up); free(up);
@ -899,14 +970,14 @@ __evas_imlib_flush_draw(Display *disp, Imlib_Image dstim, Window win)
} }
int int
__evas_imlib_capable(Display *disp) __evas_image_capable(Display *disp)
{ {
return 1; return 1;
} }
Visual * Visual *
__evas_imlib_get_visual(Display *disp, int screen) __evas_image_get_visual(Display *disp, int screen)
{ {
int depth; int depth;
@ -915,26 +986,26 @@ __evas_imlib_get_visual(Display *disp, int screen)
} }
XVisualInfo * XVisualInfo *
__evas_imlib_get_visual_info(Display *disp, int screen) __evas_image_get_visual_info(Display *disp, int screen)
{ {
static XVisualInfo *vi = NULL; static XVisualInfo *vi = NULL;
XVisualInfo vi_template; XVisualInfo vi_template;
int n; int n;
if (vi) return vi; if (vi) return vi;
vi_template.visualid = (__evas_imlib_get_visual(disp, screen))->visualid; vi_template.visualid = (__evas_image_get_visual(disp, screen))->visualid;
vi_template.screen = screen; vi_template.screen = screen;
vi = XGetVisualInfo(disp, VisualIDMask | VisualScreenMask, &vi_template ,&n); vi = XGetVisualInfo(disp, VisualIDMask | VisualScreenMask, &vi_template ,&n);
return vi; return vi;
} }
Colormap Colormap
__evas_imlib_get_colormap(Display *disp, int screen) __evas_image_get_colormap(Display *disp, int screen)
{ {
Visual *v; Visual *v;
if (__evas_cmap) return __evas_cmap; if (__evas_cmap) return __evas_cmap;
v = __evas_imlib_get_visual(disp, screen); v = __evas_image_get_visual(disp, screen);
__evas_cmap = DefaultColormap(disp, screen); __evas_cmap = DefaultColormap(disp, screen);
return __evas_cmap; return __evas_cmap;
__evas_cmap = XCreateColormap(disp, RootWindow(disp, screen), v, AllocNone); __evas_cmap = XCreateColormap(disp, RootWindow(disp, screen), v, AllocNone);
@ -942,37 +1013,35 @@ __evas_imlib_get_colormap(Display *disp, int screen)
} }
void void
__evas_imlib_init(Display *disp, int screen, int colors) __evas_image_init(Display *disp, int screen, int colors)
{ {
static int initted = 0; static int initted = 0;
if (!initted) if (!initted)
{ {
imlib_set_color_usage(colors);
imlib_set_font_cache_size(1024 * 1024); imlib_set_font_cache_size(1024 * 1024);
imlib_set_cache_size(8 * 1024 * 1024); imlib_set_cache_size(8 * 1024 * 1024);
initted = 1; initted = 1;
} }
imlib_set_color_usage(colors);
} }
void void
__evas_imlib_draw_add_rect(Display *disp, Imlib_Image dstim, Window win, __evas_image_draw_add_rect(Display *disp, Imlib_Image dstim, Window win,
int x, int y, int w, int h) int x, int y, int w, int h)
{ {
Evas_List l; Evas_List l;
for(l = drawable_list; l; l = l->next) for(l = drawable_list; l; l = l->next)
{ {
Evas_Imlib_Drawable *dr; Evas_Image_Drawable *dr;
dr = l->data; dr = l->data;
if ((dr->win == win) && (dr->disp == disp)) if (dr->im == dstim)
{ {
Evas_Imlib_Update *up; Evas_Image_Update *up;
up = malloc(sizeof(Evas_Imlib_Update)); up = malloc(sizeof(Evas_Image_Update));
up->x = x; up->x = x;
up->y = y; up->y = y;
up->w = w; up->w = w;
@ -983,14 +1052,13 @@ __evas_imlib_draw_add_rect(Display *disp, Imlib_Image dstim, Window win,
return; return;
} }
{ {
Evas_Imlib_Drawable *dr; Evas_Image_Drawable *dr;
Evas_Imlib_Update *up; Evas_Image_Update *up;
dr = malloc(sizeof(Evas_Imlib_Drawable)); dr = malloc(sizeof(Evas_Image_Drawable));
dr->win = win; dr->im = dstim;
dr->disp = disp;
dr->tmp_images = NULL; dr->tmp_images = NULL;
up = malloc(sizeof(Evas_Imlib_Update)); up = malloc(sizeof(Evas_Image_Update));
up->x = x; up->x = x;
up->y = y; up->y = y;
up->w = w; up->w = w;

View File

@ -237,7 +237,9 @@ __evas_x11_image_draw(Evas_X11_Image *im,
imlib_context_set_drawable(w); imlib_context_set_drawable(w);
imlib_context_set_dither_mask(0); imlib_context_set_dither_mask(0);
imlib_context_set_anti_alias(0); imlib_context_set_anti_alias(0);
imlib_context_set_dither(__evas_anti_alias); if (imlib_get_visual_depth(disp, __evas_visual) < 8)
imlib_context_set_dither(__evas_anti_alias);
else imlib_context_set_dither(0);
imlib_context_set_blend(0); imlib_context_set_blend(0);
imlib_context_set_angle(0.0); imlib_context_set_angle(0.0);
imlib_context_set_operation(IMLIB_OP_COPY); imlib_context_set_operation(IMLIB_OP_COPY);
@ -275,8 +277,8 @@ __evas_x11_image_draw(Evas_X11_Image *im,
ih = im->h; ih = im->h;
ww = (iw * dw) / src_w; ww = (iw * dw) / src_w;
hh = (ih * dh) / src_h; hh = (ih * dh) / src_h;
xx = (src_x * src_w) / dw; xx = (src_x * dw) / src_w;
yy = (src_y * src_h) / dh; yy = (src_y * dh) / src_h;
if (__evas_clip) if (__evas_clip)
{ {
int px, py; int px, py;
@ -429,8 +431,6 @@ static int __evas_fpath_num = 0;
static int __evas_font_cache = 0; static int __evas_font_cache = 0;
static int __evas_font_cache_max = 512 * 1024; static int __evas_font_cache_max = 512 * 1024;
static int __evas_rend_lut[9] = { 0, 1, 1, 1, 1, 1, 1, 1, 1 };
static int __evas_have_tt_engine = 0; static int __evas_have_tt_engine = 0;
static TT_Engine __evas_tt_engine; static TT_Engine __evas_tt_engine;
@ -521,6 +521,8 @@ __evas_x11_text_font_render_glyph(Window win, Evas_X11_Font *fn, Evas_X11_Glyph
g->pw = tw; g->pw = tw;
g->ph = th; g->ph = th;
fn->mem_use += (((g->pw -1) | 0x7) + 1) * g->ph / 8;
rmap = __evas_x11_text_font_raster_new(tw, th); rmap = __evas_x11_text_font_raster_new(tw, th);
if (rmap) if (rmap)
{ {
@ -540,7 +542,6 @@ __evas_x11_text_font_render_glyph(Window win, Evas_X11_Font *fn, Evas_X11_Glyph
rval = (DATA8)(((unsigned char *)(rmap->bitmap))[((rmap->rows - y - 1) * rmap->cols) + (x >> 3)]); rval = (DATA8)(((unsigned char *)(rmap->bitmap))[((rmap->rows - y - 1) * rmap->cols) + (x >> 3)]);
rval >>= (7 - (x - ((x >> 3) << 3))); rval >>= (7 - (x - ((x >> 3) << 3)));
/* data[(y * tw) + x] = __evas_rend_lut[rval];*/
XPutPixel(xim, x, y, rval); XPutPixel(xim, x, y, rval);
} }
} }
@ -595,7 +596,7 @@ __evas_x11_font_load(char *font, int size)
const int dpi = 96; const int dpi = 96;
file = __evas_x11_font_find(font); file = __evas_x11_font_find(font);
if (!file) return; if (!file) return NULL;
if (!__evas_have_tt_engine) if (!__evas_have_tt_engine)
{ {
error = TT_Init_FreeType(&__evas_tt_engine); error = TT_Init_FreeType(&__evas_tt_engine);
@ -606,6 +607,7 @@ __evas_x11_font_load(char *font, int size)
fn->font = strdup(font); fn->font = strdup(font);
fn->size = size; fn->size = size;
fn->engine = __evas_tt_engine; fn->engine = __evas_tt_engine;
fn->mem_use = 0;
error = TT_Open_Face(fn->engine, file, &fn->face); error = TT_Open_Face(fn->engine, file, &fn->face);
if (error) if (error)
{ {
@ -701,18 +703,8 @@ __evas_x11_text_font_cache_flush(void)
if (fn_last) if (fn_last)
{ {
int i; int i;
Evas_List l;
for (i = 0; i < 256; i++) __evas_font_cache -= fn->mem_use;
{
for (l = fn->glyphs[i]; l; l = l->next)
{
Evas_X11_Glyph *g;
g = l->data;
__evas_font_cache -= (((g->pw -1) | 0x7) + 1) * g->ph / 8;
}
}
TT_Done_Instance(fn_last->instance); TT_Done_Instance(fn_last->instance);
TT_Close_Face(fn_last->face); TT_Close_Face(fn_last->face);
if (fn_last->font) free(fn_last->font); if (fn_last->font) free(fn_last->font);
@ -762,21 +754,7 @@ __evas_x11_text_font_new(Display *disp, char *font, int size)
__evas_fonts = evas_list_prepend(__evas_fonts, fn); __evas_fonts = evas_list_prepend(__evas_fonts, fn);
} }
if (fn->references == 0) if (fn->references == 0)
{ __evas_font_cache -= fn->mem_use;
int i;
Evas_List l;
for (i = 0; i < 256; i++)
{
for (l = fn->glyphs[i]; l; l = l->next)
{
Evas_X11_Glyph *g;
g = l->data;
__evas_font_cache -= (((g->pw -1) | 0x7) + 1) * g->ph / 8;
}
}
}
fn->references++; fn->references++;
return fn; return fn;
} }
@ -795,21 +773,7 @@ __evas_x11_text_font_free(Evas_X11_Font *fn)
{ {
fn->references--; fn->references--;
if (fn->references == 0) if (fn->references == 0)
{ __evas_font_cache += fn->mem_use;
int i;
Evas_List l;
for (i = 0; i < 256; i++)
{
for (l = fn->glyphs[i]; l; l = l->next)
{
Evas_X11_Glyph *g;
g = l->data;
__evas_font_cache += (((g->pw -1) | 0x7) + 1) * g->ph / 8;
}
}
}
} }
__evas_x11_text_font_cache_flush(); __evas_x11_text_font_cache_flush();
} }
@ -847,21 +811,57 @@ __evas_x11_text_font_get_advances(Evas_X11_Font *fn, char *text,
int *advance_horiz, int *advance_horiz,
int *advance_vert) int *advance_vert)
{ {
int i, ascent, descent, pw, ph;
if (advance_horiz) *advance_horiz = 0; if (advance_horiz) *advance_horiz = 0;
if (advance_horiz) *advance_vert = 0; if (advance_horiz) *advance_vert = 0;
if (!fn) return; if (!fn) return;
if (!text) return; if (!text) return;
if (text[0] == 0) return; if (text[0] == 0) return;
/* FIXME */
ascent = fn->ascent;
descent = fn->descent;
pw = 0;
ph = ascent + descent;
for (i = 0; text[i]; i++)
{
Evas_X11_Glyph *g;
int glyph;
glyph = ((unsigned char *)text)[i];
g = __evas_x11_text_font_get_glyph(fn, glyph);
if (!g) continue;
if (!TT_VALID(g->glyph)) continue;
if (i == 0)
pw += ((-g->metrics.bearingX) / 64);
pw += g->metrics.advance / 64;
}
*advance_horiz = pw;
*advance_vert = ph;
} }
int int
__evas_x11_text_font_get_first_inset(Evas_X11_Font *fn, char *text) __evas_x11_text_font_get_first_inset(Evas_X11_Font *fn, char *text)
{ {
int i;
if (!fn) return 0; if (!fn) return 0;
if (!text) return 0; if (!text) return 0;
if (text[0] == 0) return 0; if (text[0] == 0) return 0;
/* FIXME */
for (i = 0; text[i]; i++)
{
Evas_X11_Glyph *g;
int glyph;
glyph = ((unsigned char *)text)[i];
g = __evas_x11_text_font_get_glyph(fn, glyph);
if (!g) continue;
if (!TT_VALID(g->glyph)) continue;
return ((-g->metrics.bearingX) / 64);
}
return 0;
} }
void void
@ -1108,8 +1108,8 @@ __evas_x11_text_get_size(Evas_X11_Font *fn, char *text, int *w, int *h)
else else
pw += g->metrics.advance / 64; pw += g->metrics.advance / 64;
} }
if (w) *w = pw + 1; if (w) *w = pw;
if (h) *h = ph + 1; if (h) *h = ph;
} }
int int

View File

@ -101,6 +101,8 @@ struct _evas_x11_font
int max_descent; int max_descent;
int max_ascent; int max_ascent;
int mem_use;
int references; int references;
}; };

View File

@ -913,13 +913,13 @@ setup_view(Evas_Render_Method method)
evas_view = e; evas_view = e;
o = evas_add_text(e, "andover", 20, "FPS: ???"); o = evas_add_text(e, "andover", 20, "FPS: ???");
evas_set_color(e, o, 255, 255, 255, 100); evas_set_color(e, o, 255, 255, 255, 140);
evas_move(e, o, 0, 0); evas_move(e, o, 0, 0);
evas_show(e, o); evas_show(e, o);
o_fps = o; o_fps = o;
o = evas_add_text(e, "andover", 20, "Total Average FPS: ???"); o = evas_add_text(e, "andover", 20, "Total Average FPS: ???");
evas_set_color(e, o, 255, 255, 255, 100); evas_set_color(e, o, 255, 255, 255, 140);
evas_get_geometry(e, o, NULL, NULL, NULL, &y); evas_get_geometry(e, o, NULL, NULL, NULL, &y);
evas_move(e, o, 0, 768 - y); evas_move(e, o, 0, 768 - y);
evas_show(e, o); evas_show(e, o);

View File

@ -202,7 +202,6 @@ main(int argc, char **argv)
o[0] = evas_add_image_from_file(e, IMGDIR"sky001.png"); o[0] = evas_add_image_from_file(e, IMGDIR"sky001.png");
evas_show(e, o[0]); evas_show(e, o[0]);
o[1] = evas_add_image_from_file(e, IMGDIR"logo001.png"); o[1] = evas_add_image_from_file(e, IMGDIR"logo001.png");
evas_get_image_size(e, o[1], &w, &h);
evas_callback_add(e, o[1], CALLBACK_MOUSE_DOWN, mouse_down, NULL); evas_callback_add(e, o[1], CALLBACK_MOUSE_DOWN, mouse_down, NULL);
evas_callback_add(e, o[1], CALLBACK_MOUSE_UP, mouse_up, NULL); evas_callback_add(e, o[1], CALLBACK_MOUSE_UP, mouse_up, NULL);
evas_callback_add(e, o[1], CALLBACK_MOUSE_MOVE, mouse_move, NULL); evas_callback_add(e, o[1], CALLBACK_MOUSE_MOVE, mouse_move, NULL);
@ -399,7 +398,7 @@ main(int argc, char **argv)
evas_set_image_file(e, o[i], imgs[(i) & 0x7]); evas_set_image_file(e, o[i], imgs[(i) & 0x7]);
evas_move(e, o[i], x, y); evas_move(e, o[i], x, y);
/* /*
ww = ((1.2 + cos((double)(a + j + m) * 2 * 3.141592654 / 1000)) * 24); ww = ((1.2 + cos((double)(a + j + m) * 2 * 3.141592654 / 1000)) * 48);
hh = ww; hh = ww;
evas_resize(e, o[i], ww, hh); evas_resize(e, o[i], ww, hh);
evas_set_image_fill(e, o[i], 0, 0, ww, hh); evas_set_image_fill(e, o[i], 0, 0, ww, hh);