dissalow resizing for line and text objects - doesnt make sense -

change the font or string to resize text, and chnage line coords.

add ability for color settings to apply to image objects too (image colors get
multiplid by color set on image - 255, 255, 255, 255 is "normal" so it's fast
path rendering - all other colors go thru color modifiers in the imlib engines
and gl handles it int he gl engine. if alpha is 0 the object draw is aborted
immediately for fast path.


SVN revision: 3468
This commit is contained in:
Carsten Haitzler 2000-09-15 13:49:14 +00:00
parent a751ec1b21
commit e2ffcf313c
12 changed files with 113 additions and 31 deletions

View File

@ -182,6 +182,9 @@ struct _Evas_Object_Image
struct {
int l, r, t, b;
} border;
struct {
int r, g, b, a;
} color;
} current, previous;
};
@ -259,7 +262,7 @@ void evas_del_object(Evas e, Evas_Object o);
/* adding objects */
Evas_Object evas_add_image_from_file(Evas e, char *file);
Evas_Object evas_add_image_from_data(Evas e, void *data, Evas_Image_Format format, int w, int h);
/* ** ** not implimented yet ** ** */Evas_Object evas_add_image_from_data(Evas e, void *data, Evas_Image_Format format, int w, int h);
Evas_Object evas_add_text(Evas e, char *font, int size, char *text);
Evas_Object evas_add_rectangle(Evas e);
Evas_Object evas_add_line(Evas e);
@ -267,7 +270,7 @@ Evas_Object evas_add_gradient_box(Evas e);
/* set object settings */
void evas_set_image_file(Evas e, Evas_Object o, char *file);
void evas_set_image_data(Evas e, Evas_Object o, void *data, Evas_Image_Format format, int w, int h);
/* ** ** not implimented yet ** ** */void evas_set_image_data(Evas e, Evas_Object o, void *data, Evas_Image_Format format, int w, int h);
void evas_set_image_fill(Evas e, Evas_Object o, double x, double y, double w, double h);
void evas_set_image_border(Evas e, Evas_Object o, int l, int r, int t, int b);
void evas_set_color(Evas e, Evas_Object o, int r, int g, int b, int a);
@ -293,8 +296,8 @@ void evas_font_del_path(Evas e, char *path);
/* layer stacking for object */
void evas_set_layer(Evas e, Evas_Object o, int l);
void evas_set_layer_store(Evas e, int l, int store);
/* ** ** not implimented yet ** ** */void evas_set_layer_store(Evas e, int l, int store);
/* gradient creating / deletion / modification */
Evas_Gradient evas_gradient_new(void);
void evas_gradient_free(Evas_Gradient grad);
@ -304,9 +307,9 @@ void evas_gradient_add_color(Evas_Gradient grad, int r, int g, int b, int a, int
void evas_raise(Evas e, Evas_Object o);
void evas_lower(Evas e, Evas_Object o);
void evas_stack_above(Evas e, Evas_Object o, Evas_Object above);
void evas_stack_below(Evas e, Evas_Object o, Evas_Object above);
void evas_stack_below(Evas e, Evas_Object o, Evas_Object below);
/* object geoemtry */
/* object geometry */
void evas_move(Evas e, Evas_Object o, double x, double y);
void evas_resize(Evas e, Evas_Object o, double w, double h);
void evas_get_geometry(Evas e, Evas_Object o, double *x, double *y, double *w, double *h);

View File

@ -453,11 +453,13 @@ 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 dst_x, int dst_y, int dst_w, int dst_h,
int cr, int cg, int cb, int ca)
{
int x, y, i;
double dx, dy, dw, dh;
if (ca == 0) return;
if ((src_w <= 0) || (src_h <= 0) || (dst_w <= 0) || (dst_h <= 0)) return;
if (im->state != EVAS_STATE_TEXTURE)
__evas_gl_image_move_state_data_to_texture(im);
@ -504,8 +506,11 @@ __evas_gl_image_draw(Evas_GL_Image *im,
im->buffer.dest_w = win_w;
im->buffer.dest_h = win_h;
glColor4d(((double)cr) / 255.0,
((double)cg) / 255.0,
((double)cb) / 255.0,
((double)ca) / 255.0);
/* project src and dst rects to overall dest rect */
glColor4f(1.0, 1.0, 1.0, 1.0);
if ((im->direct) ||
((im->bl == 0) && (im->br == 0) && (im->bt == 0) && (im->bb == 0)))
{
@ -563,33 +568,33 @@ __evas_gl_image_draw(Evas_GL_Image *im,
}
__evas_gl_image_draw(im, disp, dstim, w, win_w, win_h,
0, 0, bl, bt,
dx, dy, bl, bt);
dx, dy, bl, bt, cr, cg, cb, ca);
__evas_gl_image_draw(im, disp, dstim, w, win_w, win_h,
bl, 0, im->w - bl - br, bt,
dx + bl, dy, dw - bl - br, bt);
dx + bl, dy, dw - bl - br, bt, cr, cg, cb, ca);
__evas_gl_image_draw(im, disp, dstim, w, win_w, win_h,
im->w - br, 0, br, bt,
dx + dw - br, dy, br, bt);
dx + dw - br, dy, br, bt, cr, cg, cb, ca);
__evas_gl_image_draw(im, disp, dstim, w, win_w, win_h,
0, bt, bl, im->h - bt - bb,
dx, dy + bt, bl, dh - bt - bb);
dx, dy + bt, bl, dh - bt - bb, cr, cg, cb, ca);
__evas_gl_image_draw(im, disp, dstim, 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);
dx + bl, dy + bt, dw - bl - br, dh - bt - bb, cr, cg, cb, ca);
__evas_gl_image_draw(im, disp, dstim, w, win_w, win_h,
im->w - br, bt, br, im->h - bt - bb,
dx + dw - br, dy + bt, br, dh - bt - bb);
dx + dw - br, dy + bt, br, dh - bt - bb, cr, cg, cb, ca);
__evas_gl_image_draw(im, disp, dstim, w, win_w, win_h,
0, im->h - bb, bl, bb,
dx, dy + dh - bb, bl, bb);
dx, dy + dh - bb, bl, bb, cr, cg, cb, ca);
__evas_gl_image_draw(im, disp, dstim, w, win_w, win_h,
bl, im->h - bb, im->w - bl - br, bb,
dx + bl, dy + dh - bb, dw - bl - br, bb);
dx + bl, dy + dh - bb, dw - bl - br, bb, cr, cg, cb, ca);
__evas_gl_image_draw(im, disp, dstim, w, win_w, win_h,
im->w - br, im->h - bb, br, bb,
dx + dw - br, dy + dh - bb, br, bb);
dx + dw - br, dy + dh - bb, br, bb, cr, cg, cb, ca);
im->direct = 0;
}
}

View File

@ -151,7 +151,7 @@ int __evas_gl_image_get_width(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);
void __evas_gl_image_set_smooth_scaling(int on);
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);
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);
/********/
/* text */

View File

@ -66,6 +66,10 @@ evas_add_image_from_file(Evas e, char *file)
oo->current.fill.y = 0;
oo->current.fill.w = (double)oo->current.image.w;
oo->current.fill.h = (double)oo->current.image.h;
oo->current.color.r = 255;
oo->current.color.g = 255;
oo->current.color.b = 255;
oo->current.color.a = 255;
o->current.x = 0;
o->current.y = 0;
o->current.w = (double)oo->current.image.w;

View File

@ -61,14 +61,35 @@ void
__evas_image_image_draw(Evas_Image_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 dst_x, int dst_y, int dst_w, int dst_h,
int cr, int cg, int cb, int ca)
{
Evas_List l;
Imlib_Color_Modifier cm = NULL;
if (ca == 0) return;
if ((cr != 255) || (cg != 255) || (cb != 255) || (ca != 255))
{
DATA8 r[256], g[256], b[256], a[256];
int i;
cm = imlib_create_color_modifier();
imlib_context_set_color_modifier(cm);
for (i = 0; i < 256; i++)
{
r[i] = (i * cr) / 255;
g[i] = (i * cg) / 255;
b[i] = (i * cb) / 255;
a[i] = (i * ca) / 255;
}
imlib_set_color_modifier_tables(r, g, b, a);
}
else
imlib_context_set_color_modifier(NULL);
imlib_context_set_angle(0.0);
imlib_context_set_blend(1);
imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_color_modifier(NULL);
imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT);
imlib_context_set_anti_alias(__evas_anti_alias);
for(l = drawable_list; l; l = l->next)
@ -116,6 +137,8 @@ __evas_image_image_draw(Evas_Image_Image *im,
}
}
}
if (cm)
imlib_context_set_color_modifier(NULL);
}
int

View File

@ -53,7 +53,7 @@ int __evas_image_image_get_width(Evas_Image_Image *im);
int __evas_image_image_get_height(Evas_Image_Image *im);
void __evas_image_image_set_borders(Evas_Image_Image *im, int left, int right, int top, int bottom);
void __evas_image_image_set_smooth_scaling(int on);
void __evas_image_image_draw(Evas_Image_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);
void __evas_image_image_draw(Evas_Image_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);
/********/
/* text */

View File

@ -61,13 +61,34 @@ void
__evas_imlib_image_draw(Evas_Imlib_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 dst_x, int dst_y, int dst_w, int dst_h,
int cr, int cg, int cb, int ca)
{
Evas_List l;
Imlib_Color_Modifier cm = NULL;
if (ca == 0) return;
if ((cr != 255) || (cg != 255) || (cb != 255) || (ca != 255))
{
DATA8 r[256], g[256], b[256], a[256];
int i;
cm = imlib_create_color_modifier();
imlib_context_set_color_modifier(cm);
for (i = 0; i < 256; i++)
{
r[i] = (i * cr) / 255;
g[i] = (i * cg) / 255;
b[i] = (i * cb) / 255;
a[i] = (i * ca) / 255;
}
imlib_set_color_modifier_tables(r, g, b, a);
}
else
imlib_context_set_color_modifier(NULL);
imlib_context_set_angle(0.0);
imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_color_modifier(NULL);
imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT);
imlib_context_set_anti_alias(__evas_anti_alias);
imlib_context_set_blend(1);
@ -101,6 +122,8 @@ __evas_imlib_image_draw(Evas_Imlib_Image *im,
}
}
}
if (cm)
imlib_context_set_color_modifier(NULL);
}
int

View File

@ -53,7 +53,7 @@ int __evas_imlib_image_get_width(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_set_smooth_scaling(int on);
void __evas_imlib_image_draw(Evas_Imlib_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);
void __evas_imlib_image_draw(Evas_Imlib_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);
/********/
/* text */

View File

@ -44,6 +44,19 @@ evas_set_color(Evas e, Evas_Object o, int r, int g, int b, int a)
{
switch (o->type)
{
case OBJECT_IMAGE:
{
Evas_Object_Image oo;
oo = (Evas_Object_Image)o;
oo->current.color.r = r;
oo->current.color.g = g;
oo->current.color.b = b;
oo->current.color.a = a;
}
o->changed = 1;
e->changed = 1;
break;
case OBJECT_TEXT:
{
Evas_Object_Text oo;
@ -294,6 +307,7 @@ evas_flush_image_cache(Evas e)
void
evas_font_add_path(Evas e, char *path)
{
evas_font_del_path(e, path);
switch (e->current.render_method)
{
case RENDER_METHOD_ALPHA_SOFTWARE:

View File

@ -398,6 +398,8 @@ evas_resize(Evas e, Evas_Object o, double w, double h)
{
int event_update = 0;
if ((o->type == OBJECT_LINE)) return;
if ((o->type == OBJECT_TEXT)) return;
if ((o->current.visible) &&
(_evas_point_in_object(e, o, e->mouse.x, e->mouse.y)))
event_update = 1;

View File

@ -83,7 +83,7 @@ evas_render(Evas e)
void (*func_draw_add_rect) (Display *disp, Imlib_Image dstim, Window win, int x, int y, int w, int h);
void * (*func_image_new_from_file) (Display *disp, char *file);
void (*func_image_set_borders) (void *im, int left, int right, int top, int bottom);
void (*func_image_draw) (void *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);
void (*func_image_draw) (void *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);
void (*func_image_free) (void *im);
void (*func_flush_draw) (Display *disp, Imlib_Image dstim, Window w);
void (*func_init) (Display *disp, int screen);
@ -226,7 +226,11 @@ evas_render(Evas e)
(oo->current.fill.x != oo->previous.fill.x) ||
(oo->current.fill.y != oo->previous.fill.y) ||
(oo->current.fill.w != oo->previous.fill.w) ||
(oo->current.fill.h != oo->previous.fill.h)
(oo->current.fill.h != oo->previous.fill.h) ||
(oo->current.color.r != oo->previous.color.r) ||
(oo->current.color.g != oo->previous.color.g) ||
(oo->current.color.b != oo->previous.color.b) ||
(oo->current.color.a != oo->previous.color.a)
)
real_change = 1;
oo->current.new_data = 0;
@ -515,7 +519,11 @@ evas_render(Evas e)
pointsx[xx].in1, pointsy[yy].in1,
pointsx[xx].in2, pointsy[yy].in2,
pointsx[xx].out1, pointsy[yy].out1,
pointsx[xx].out2, pointsy[yy].out2);
pointsx[xx].out2, pointsy[yy].out2,
oo->current.color.r,
oo->current.color.g,
oo->current.color.b,
oo->current.color.a);
}
}
free(pointsx);

View File

@ -163,7 +163,7 @@ main(int argc, char **argv)
h /= 2;
evas_show(e, o[1]);
for (i = 2 ; i < 10; i++)
for (i = 2 ; i < 120; i++)
{
o[i] = evas_add_image_from_file(e, "img/mush.png");
evas_show(e, o[i]);
@ -174,7 +174,6 @@ main(int argc, char **argv)
evas_callback_add(e, o[i], CALLBACK_MOUSE_IN, mouse_in, NULL);
evas_callback_add(e, o[i], CALLBACK_MOUSE_OUT, mouse_out, NULL);
}
/*
for (i = 120; i < 128; i++)
{
o[i] = evas_add_text(e, "notepad", 16, imgs[i & 0x7]);
@ -187,7 +186,6 @@ main(int argc, char **argv)
evas_callback_add(e, o[i], CALLBACK_MOUSE_IN, mouse_in, NULL);
evas_callback_add(e, o[i], CALLBACK_MOUSE_OUT, mouse_out, NULL);
}
*/
o_rect = evas_add_rectangle(e);
evas_show(e, o_rect);
evas_move(e, o_rect, 100, 100);
@ -305,7 +303,7 @@ main(int argc, char **argv)
}
}
/* while (XPending(d));*/
for (i = 2; i < 10; i++)
for (i = 2; i < 128; i++)
{
int j, k;
double ww, hh;
@ -323,6 +321,8 @@ main(int argc, char **argv)
hh = ww;
evas_resize(e, o[i], ww, hh);
evas_set_image_fill(e, o[i], 0, 0, ww, hh);
evas_set_color(e, o[i], 255, 255, 255,
(((1.0 + cos((double)(a + j) * 2 * 3 * 3.141592654 / 1000)) / 2) * 255));
}
}
evas_set_angle(e, o_grad, (double)a * 360 / 1000);