start of polygon drawing support...


			
			
				devs/devilhorns/wayland_egl
			
			
		
Carsten Haitzler 23 years ago
parent 3a3ebbca58
commit 53b3a6face
  1. 2
      legacy/evas/doc/Makefile.am
  2. 7
      legacy/evas/src/Evas.h
  3. 17
      legacy/evas/src/Evas_private.h
  4. 1
      legacy/evas/src/Makefile.am
  5. 21
      legacy/evas/src/evas_gl_routines.c
  6. 5
      legacy/evas/src/evas_gl_routines.h
  7. 10
      legacy/evas/src/evas_image_routines.c
  8. 5
      legacy/evas/src/evas_image_routines.h
  9. 98
      legacy/evas/src/evas_imlib_routines.c
  10. 5
      legacy/evas/src/evas_imlib_routines.h
  11. 13
      legacy/evas/src/evas_misc.c
  12. 27
      legacy/evas/src/evas_object.c
  13. 158
      legacy/evas/src/evas_poly.c
  14. 41
      legacy/evas/src/evas_render.c
  15. 14
      legacy/evas/src/evas_x11_routines.c
  16. 5
      legacy/evas/src/evas_x11_routines.h
  17. 19
      legacy/evas/test/evas_test_old.c

@ -1,3 +1,3 @@
EXTRA_DIST = \
index.html \
loogo.gif
logo.gif

@ -104,7 +104,8 @@ 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);
Evas_Object evas_add_gradient_box(Evas e);
Evas_Object evas_add_poly(Evas e);
/* set object settings */
void evas_set_image_file(Evas e, Evas_Object o, char *file);
/* ** ** not implimented yet ** ** */void evas_set_image_data(Evas e, Evas_Object o, void *data, Evas_Image_Format format, int w, int h);
@ -118,7 +119,8 @@ void evas_set_angle(Evas e, Evas_Object o, double angle);
void evas_set_zoom_scale(Evas e, Evas_Object o, int scale);
void evas_set_line_xy(Evas e, Evas_Object o, double x1, double y1, double x2, double y2);
void evas_set_pass_events(Evas e, Evas_Object o, int pass_events);
void evas_add_point(Evas e, Evas_Object o, double x, double y);
/* cache settings for performance */
void evas_set_font_cache(Evas e, int size);
int evas_get_font_cache(Evas e);
@ -159,6 +161,7 @@ Evas_Object evas_object_at_position(Evas e, double x, double y);
Evas_Object evas_object_get_named(Evas e, char *name);
void evas_object_set_name(Evas e, Evas_Object o, char *name);
char *evas_object_get_name(Evas e, Evas_Object o);
Evas_List evas_get_points(Evas e, Evas_Object o);
/* object visibility */
void evas_show(Evas e, Evas_Object o);

@ -11,6 +11,7 @@ typedef struct _Evas_Object_Any * Evas_Object_Any;
typedef struct _Evas_Render_Data Evas_Render_Data;
typedef struct _Evas_Data * Evas_Data;
typedef struct _Evas_Layer * Evas_Layer;
typedef struct _Evas_Point * Evas_Point;
typedef struct _Evas_Color_Point * Evas_Color_Point;
typedef struct _Evas_Callback * Evas_Callback;
typedef struct _Evas_Rectangle * Evas_Rectangle;
@ -19,12 +20,14 @@ typedef struct _Evas_Object_Text * Evas_Object_Text;
typedef struct _Evas_Object_Rectangle * Evas_Object_Rectangle;
typedef struct _Evas_Object_Line * Evas_Object_Line;
typedef struct _Evas_Object_Gradient_Box * Evas_Object_Gradient_Box;
typedef struct _Evas_Object_Poly * Evas_Object_Poly;
#define OBJECT_IMAGE 1230
#define OBJECT_TEXT 1231
#define OBJECT_RECTANGLE 1232
#define OBJECT_LINE 1233
#define OBJECT_GRADIENT_BOX 1234
#define OBJECT_POLYGON 1235
#define IF_OBJ(_o, _t) if (((Evas_Object)_o)->type != _t)
@ -74,6 +77,11 @@ struct _Evas
Imlib_Updates updates;
};
struct _Evas_Point
{
double x, y;
};
struct _Evas_Color_Point
{
int r, g, b, a;
@ -207,6 +215,15 @@ struct _Evas_Object_Gradient_Box
} current, previous;
};
struct _Evas_Object_Poly
{
struct _Evas_Object_Any object;
struct {
int r, g, b, a;
Evas_List points;
} current, previous;
};
#endif

@ -43,6 +43,7 @@ evas_line.c \
evas_list.c \
evas_misc.c \
evas_object.c \
evas_poly.c \
evas_rectangle.c \
evas_render.c \
evas_text.c \

@ -2181,6 +2181,22 @@ __evas_gl_gradient_draw(Evas_GL_Graident *gr,
/************/
/* polygons */
/************/
void
__evas_gl_poly_draw (Display *disp, Imlib_Image dstim, Window win,
int win_w, int win_h,
Evas_List points,
int r, int g, int b, int a)
{
}
@ -2328,6 +2344,11 @@ void __evas_gl_gradient_free(Evas_GL_Graident *gr){}
void __evas_gl_gradient_color_add(Evas_GL_Graident *gr, int r, int g, int b, int a, int dist){}
void __evas_gl_gradient_draw(Evas_GL_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){}
/************/
/* polygons */
/************/
void __evas_gl_poly_draw (Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, Evas_List points, int r, int g, int b, int a) {}
/***********/
/* drawing */
/***********/

@ -194,6 +194,11 @@ void __evas_gl_gradient_free(Evas_GL_Graident *gr);
void __evas_gl_gradient_color_add(Evas_GL_Graident *gr, int r, int g, int b, int a, int dist);
void __evas_gl_gradient_draw(Evas_GL_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);
/************/
/* polygons */
/************/
void __evas_gl_poly_draw (Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, Evas_List points, int r, int g, int b, int a);
/***********/
/* drawing */
/***********/

@ -683,6 +683,16 @@ __evas_image_gradient_draw(Evas_Image_Graident *gr, Display *disp, Imlib_Image d
/************/
/* polygons */
/************/
void
__evas_image_poly_draw (Display *disp, Imlib_Image dstim, Window win,
int win_w, int win_h,
Evas_List points,
int r, int g, int b, int a)
{
}

@ -100,6 +100,11 @@ void __evas_image_gradient_free(Evas_Image_Graident *gr);
void __evas_image_gradient_color_add(Evas_Image_Graident *gr, int r, int g, int b, int a, int 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);
/************/
/* polygons */
/************/
void __evas_image_poly_draw (Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, Evas_List points, int r, int g, int b, int a);
/***********/
/* drawing */
/***********/

@ -1,3 +1,4 @@
#include "evas_imlib_routines.h"
static void __evas_imlib_image_cache_flush(Display *disp);
@ -481,8 +482,8 @@ void __evas_imlib_line_draw(Display *disp, Imlib_Image dstim, Windo
imlib_context_set_color_modifier(NULL);
imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT);
imlib_context_set_anti_alias(1);
imlib_context_set_blend(1);
w = x2 - x1;
imlib_context_set_blend(1);
w = x2 - x1;
if (w < 0) w = -w;
h = y2 - y1;
if (h < 0) h = -h;
@ -537,7 +538,7 @@ void __evas_imlib_line_draw(Display *disp, Imlib_Image dstim, Windo
/*****************************************************************************/
/****************************************************************************/
/* gradient externals ********************************************************/
/*****************************************************************************/
@ -608,6 +609,97 @@ __evas_imlib_gradient_draw(Evas_Imlib_Graident *gr, Display *disp, Imlib_Image d
/************/
/* polygons */
/************/
void
__evas_imlib_poly_draw (Display *disp, Imlib_Image dstim, Window win,
int win_w, int win_h,
Evas_List points,
int r, int g, int b, int a)
{
Evas_List l, l2;
int x, y, w, h;
imlib_context_set_color(r, g, b, a);
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(1);
imlib_context_set_blend(1);
x = y = w = h = 0;
if (points)
{
Evas_Point p;
p = points->data;
x = p->x;
y = p->y;
w = 1;
h = 1;
}
for (l2 = points; l2; l2 = l2->next)
{
Evas_Point p;
p = l2->data;
if (p->x < x)
{
w += x - p->x;
x = p->x;
}
if (p->x > (x + w))
w = p->x - x;
if (p->y < y)
{
h += y - p->y;
y = p->y;
}
if (p->y > (y + h))
h = p->y - y;
}
for(l = drawable_list; l; l = l->next)
{
Evas_Imlib_Drawable *dr;
dr = l->data;
if ((dr->win == win) && (dr->disp == disp))
{
Evas_List ll;
for (ll = dr->tmp_images; ll; ll = ll->next)
{
Evas_Imlib_Update *up;
up = ll->data;
/* if image intersects image update - render */
if (RECTS_INTERSECT(up->x, up->y, up->w, up->h,
x, y, w, h))
{
ImlibPolygon pol;
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)
{
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);
}
}
}
}
}

@ -100,6 +100,11 @@ void __evas_imlib_gradient_free(Evas_Imlib_Graident *gr);
void __evas_imlib_gradient_color_add(Evas_Imlib_Graident *gr, int r, int g, int b, int a, int dist);
void __evas_imlib_gradient_draw(Evas_Imlib_Graident *gr, Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, int x, int y, int w, int h, double angle);
/************/
/* polygons */
/************/
void __evas_imlib_poly_draw (Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, Evas_List points, int r, int g, int b, int a);
/***********/
/* drawing */
/***********/

@ -219,6 +219,19 @@ evas_set_color(Evas e, Evas_Object o, int r, int g, int b, int a)
o->changed = 1;
e->changed = 1;
break;
case OBJECT_POLYGON:
{
Evas_Object_Poly oo;
oo = (Evas_Object_Poly)o;
oo->current.r = r;
oo->current.g = g;
oo->current.b = b;
oo->current.a = a;
}
o->changed = 1;
e->changed = 1;
break;
default:
break;
}

@ -410,8 +410,30 @@ evas_move(Evas e, Evas_Object o, double x, double y)
if ((o->current.visible) &&
(_evas_point_in_object(e, o, e->mouse.x, e->mouse.y)))
event_update = 1;
o->current.x = x;
o->current.y = y;
if ((o->type == OBJECT_POLYGON))
{
Evas_Object_Poly oo;
Evas_List l;
Evas_Point p;
double dx, dy;
dx = x - o->current.x;
dy = y - o->current.y;
o->current.x = x;
o->current.y = y;
oo = o;
for (l = oo->current.points; l; l = l->next)
{
p = l->data;
p->x += dx;
p->y += dy;
}
}
else
{
o->current.x = x;
o->current.y = y;
}
o->changed = 1;
e->changed = 1;
if ((o->current.visible) &&
@ -429,6 +451,7 @@ evas_resize(Evas e, Evas_Object o, double w, double h)
if (!o) return;
if ((o->type == OBJECT_LINE)) return;
if ((o->type == OBJECT_TEXT)) return;
if ((o->type == OBJECT_POLYGON)) return;
if ((o->current.visible) &&
(_evas_point_in_object(e, o, e->mouse.x, e->mouse.y)))
event_update = 1;

@ -0,0 +1,158 @@
#include "Evas_private.h"
#include "Evas.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
static void
_evas_free_poly(Evas_Object o)
{
Evas_Object_Poly oo;
Evas_List l;
Evas_Point p;
IF_OBJ(o, OBJECT_POLYGON) return;
oo = o;
for (l = oo->current.points; l; l = l->next)
{
p = l->data;
free(p);
}
evas_list_free(oo->current.points);
free(o);
}
static void
_evas_free_poly_renderer_data(Evas e, Evas_Object o)
{
switch (e->current.render_method)
{
case RENDER_METHOD_ALPHA_SOFTWARE:
break;
case RENDER_METHOD_BASIC_HARDWARE:
break;
case RENDER_METHOD_3D_HARDWARE:
break;
case RENDER_METHOD_ALPHA_HARDWARE:
break;
case RENDER_METHOD_IMAGE:
break;
default:
break;
}
}
/* adding objects */
Evas_Object
evas_add_poly(Evas e)
{
Evas_Object_Poly oo;
Evas_Object_Any o;
Evas_List l;
Evas_Layer layer;
if (!e) return NULL;
o = oo = malloc(sizeof(struct _Evas_Object_Poly));
memset(o, 0, sizeof(struct _Evas_Object_Poly));
o->type = OBJECT_POLYGON;
o->object_free = _evas_free_poly;
o->object_renderer_data_free = _evas_free_poly_renderer_data;
o->current.x = 0;
o->current.y = 0;
o->current.w = 0;
o->current.h = 0;
for (l = e->layers; l; l = l->next)
{
layer = l->data;
if (layer->layer == o->current.layer)
{
layer->objects = evas_list_append(layer->objects, o);
return o;
}
}
layer = malloc(sizeof(struct _Evas_Layer));
memset(layer, 0, sizeof(struct _Evas_Layer));
e->layers = evas_list_append(e->layers, layer);
layer->objects = evas_list_append(layer->objects, o);
return o;
}
/* modifying object */
evas_clear_points(Evas e, Evas_Object o)
{
Evas_Point p;
Evas_Object_Poly oo;
Evas_List l;
IF_OBJ(o, OBJECT_POLYGON) return;
oo = o;
if (oo->current.points)
{
for (l = oo->current.points; l; l = l->next)
{
p = l->data;
free(p);
}
evas_list_free(oo->current.points);
oo->current.points = NULL;
o->current.w = 0;
o->current.h = 0;
o->changed = 1;
e->changed = 1;
}
}
Evas_List
evas_get_points(Evas e, Evas_Object o)
{
Evas_Object_Poly oo;
IF_OBJ(o, OBJECT_POLYGON) return NULL;
oo = o;
return oo->current.points;
}
void
evas_add_point(Evas e, Evas_Object o, double x, double y)
{
Evas_Point p;
Evas_Object_Poly oo;
IF_OBJ(o, OBJECT_POLYGON) return;
oo = o;
p = malloc(sizeof(struct _Evas_Point));
p->x = x;
p->y = y;
oo->previous.points = NULL;
if (!oo->current.points)
{
oo->current.points = evas_list_append(oo->current.points, p);
o->current.x = x;
o->current.y = y;
o->current.w = 1;
o->current.h = 1;
}
else
{
oo->current.points = evas_list_append(oo->current.points, p);
if (x > (o->current.x + o->current.w)) o->current.w = x - o->current.x + 1;
else if (x < o->current.x)
{
o->current.w += o->current.x - x;
o->current.x = x;
}
if (y > (o->current.y + o->current.h)) o->current.h = y - o->current.y + 1;
else if (y < o->current.y)
{
o->current.h += o->current.y - y;
o->current.y = y;
}
}
o->changed = 1;
e->changed = 1;
}

@ -82,6 +82,7 @@ evas_render(Evas e)
void (*func_rectangle_draw) (Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, int x, int y, int w, int h, int r, int g, int b, int a);
void (*func_line_draw) (Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, int x1, int y1, int x2, int y2, int r, int g, int b, int a);
void (*func_gradient_draw) (void *gr, Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, int x, int y, int w, int h, double angle);
void (*func_poly_draw) (Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, Evas_List points, int r, int g, int b, int a);
if (!e) return;
if ((!e->changed) ||
@ -111,6 +112,7 @@ evas_render(Evas e)
func_rectangle_draw = __evas_imlib_rectangle_draw;
func_line_draw = __evas_imlib_line_draw;
func_gradient_draw = __evas_imlib_gradient_draw;
func_poly_draw = __evas_imlib_poly_draw;
break;
case RENDER_METHOD_BASIC_HARDWARE:
func_draw_add_rect = __evas_x11_draw_add_rect;
@ -128,6 +130,7 @@ evas_render(Evas e)
func_rectangle_draw = __evas_x11_rectangle_draw;
func_line_draw = __evas_x11_line_draw;
func_gradient_draw = __evas_x11_gradient_draw;
func_poly_draw = __evas_x11_poly_draw;
break;
case RENDER_METHOD_3D_HARDWARE:
func_draw_add_rect = __evas_gl_draw_add_rect;
@ -145,6 +148,7 @@ evas_render(Evas e)
func_rectangle_draw = __evas_gl_rectangle_draw;
func_line_draw = __evas_gl_line_draw;
func_gradient_draw = __evas_gl_gradient_draw;
func_poly_draw = __evas_gl_poly_draw;
break;
case RENDER_METHOD_ALPHA_HARDWARE:
break;
@ -164,6 +168,7 @@ evas_render(Evas e)
func_rectangle_draw = __evas_image_rectangle_draw;
func_line_draw = __evas_image_line_draw;
func_gradient_draw = __evas_image_gradient_draw;
func_poly_draw = __evas_image_poly_draw;
break;
default:
break;
@ -192,6 +197,7 @@ evas_render(Evas e)
real_change = 0;
o = ll->data;
if (o->delete_me)
delete_objects = evas_list_append(delete_objects, o);
if (o->changed)
@ -208,6 +214,8 @@ evas_render(Evas e)
(o->current.stacking)))
)
real_change = 1;
o->current.stacking = 0;
if ((!real_change) && (o->current.visible))
{
@ -301,6 +309,20 @@ evas_render(Evas e)
oo->previous = oo->current;
}
break;
case OBJECT_POLYGON:
{
Evas_Object_Poly oo;
oo = o;
if ((oo->previous.points != oo->current.points) ||
(oo->current.r != oo->previous.r) ||
(oo->current.g != oo->previous.g) ||
(oo->current.b != oo->previous.b) ||
(oo->current.a != oo->previous.a))
real_change = 1;
oo->previous = oo->current;
}
break;
default:
break;
}
@ -621,6 +643,25 @@ evas_render(Evas e)
oo->current.angle);
}
break;
case OBJECT_POLYGON:
{
Evas_Object_Poly oo;
oo = o;
if (oo->current.points)
func_poly_draw(e->current.display,
e->current.image,
e->current.drawable,
e->current.drawable_width,
e->current.drawable_height,
oo->current.points,
oo->current.r,
oo->current.g,
oo->current.b,
oo->current.a);
}
break;
default:
break;
}

@ -807,6 +807,20 @@ __evas_x11_gradient_draw(Evas_X11_Graident *gr, Display *disp, Imlib_Image dstim
/************/
/* polygons */
/************/
void
__evas_x11_poly_draw (Display *disp, Imlib_Image dstim, Window win,
int win_w, int win_h,
Evas_List points,
int r, int g, int b, int a)
{
}

@ -102,6 +102,11 @@ void __evas_x11_gradient_free(Evas_X11_Graident *gr);
void __evas_x11_gradient_color_add(Evas_X11_Graident *gr, int r, int g, int b, int a, int dist);
void __evas_x11_gradient_draw(Evas_X11_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);
/************/
/* polygons */
/************/
void __evas_x11_poly_draw (Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, Evas_List points, int r, int g, int b, int a);
/***********/
/* drawing */
/***********/

@ -76,7 +76,7 @@ main(int argc, char **argv)
int win_w, win_h;
int i, a, w, h, m;
Evas e;
Evas_Object o[128], o_rect, o_line, o_grad, o_fps, o_text;
Evas_Object o[128], o_rect, o_line, o_grad, o_fps, o_text, o_poly;
Evas_Gradient grad;
int down;
double t1, t2;
@ -234,6 +234,23 @@ main(int argc, char **argv)
evas_callback_add(e, o_rect, CALLBACK_MOUSE_MOVE, mouse_move, NULL);
evas_callback_add(e, o_rect, CALLBACK_MOUSE_IN, mouse_in, NULL);
evas_callback_add(e, o_rect, CALLBACK_MOUSE_OUT, mouse_out, NULL);
o_poly = evas_add_poly(e);
evas_show(e, o_poly);
evas_add_point(e, o_poly, 100, 100);
evas_add_point(e, o_poly, 200, 150);
evas_add_point(e, o_poly, 300, 80);
evas_add_point(e, o_poly, 500, 150);
evas_add_point(e, o_poly, 200, 120);
evas_add_point(e, o_poly, 55, 190);
evas_add_point(e, o_poly, 130, 110);
evas_set_color(e, o_poly, rand()&0xff, rand()&0xff, rand()&0xff, 180);
evas_set_layer(e, o_poly, 150);
evas_callback_add(e, o_poly, CALLBACK_MOUSE_DOWN, mouse_down, NULL);
evas_callback_add(e, o_poly, CALLBACK_MOUSE_UP, mouse_up, NULL);
evas_callback_add(e, o_poly, CALLBACK_MOUSE_MOVE, mouse_move, NULL);
evas_callback_add(e, o_poly, CALLBACK_MOUSE_IN, mouse_in, NULL);
evas_callback_add(e, o_poly, CALLBACK_MOUSE_OUT, mouse_out, NULL);
o_line = evas_add_line(e);
evas_show(e, o_line);

Loading…
Cancel
Save