From 240dc97f4c9b179adabc734d42ec7c73eae517b0 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sun, 17 Sep 2000 06:30:44 +0000 Subject: [PATCH] x11 engine code added - only partially works SVN revision: 3503 --- legacy/evas/src/Makefile.am | 2 + legacy/evas/src/evas_gradient.c | 20 + legacy/evas/src/evas_image_routines.c | 5 +- legacy/evas/src/evas_image_routines.h | 2 + legacy/evas/src/evas_imlib_routines.c | 5 +- legacy/evas/src/evas_imlib_routines.h | 4 +- legacy/evas/src/evas_misc.c | 9 + legacy/evas/src/evas_render.c | 33 +- legacy/evas/src/evas_text.c | 121 ++++ legacy/evas/src/evas_x11_routines.c | 758 ++++++++++++++++++++++++++ legacy/evas/src/evas_x11_routines.h | 115 ++++ legacy/evas/test/evas_test.c | 2 + 12 files changed, 1070 insertions(+), 6 deletions(-) create mode 100644 legacy/evas/src/evas_x11_routines.c create mode 100644 legacy/evas/src/evas_x11_routines.h diff --git a/legacy/evas/src/Makefile.am b/legacy/evas/src/Makefile.am index 2aac5dc0f8..f2b766b323 100644 --- a/legacy/evas/src/Makefile.am +++ b/legacy/evas/src/Makefile.am @@ -45,8 +45,10 @@ evas_rectangle.c \ evas_render.c \ evas_text.c \ evas_gl_routines.h \ +evas_x11_routines.c \ evas_image_routines.h \ evas_imlib_routines.h \ +evas_x11_routines.h \ Evas.h libevas_la_LIBADD = $(LIBS_ALL) diff --git a/legacy/evas/src/evas_gradient.c b/legacy/evas/src/evas_gradient.c index 6061ac71a6..ace45e8dc0 100644 --- a/legacy/evas/src/evas_gradient.c +++ b/legacy/evas/src/evas_gradient.c @@ -6,6 +6,7 @@ #include "evas_gl_routines.h" #include "evas_imlib_routines.h" #include "evas_image_routines.h" +#include "evas_x11_routines.h" static void _evas_free_gradient_box(Evas_Object o) @@ -30,6 +31,8 @@ _evas_free_gradient_box_renderer_data(Evas e, Evas_Object o) __evas_imlib_gradient_free(o->renderer_data.method[e->current.render_method]); break; case RENDER_METHOD_BASIC_HARDWARE: + if (o->renderer_data.method[e->current.render_method]) + __evas_x11_gradient_free(o->renderer_data.method[e->current.render_method]); break; case RENDER_METHOD_3D_HARDWARE: if (o->renderer_data.method[e->current.render_method]) @@ -116,6 +119,23 @@ evas_set_gradient(Evas e, Evas_Object o, Evas_Gradient grad) } break; case RENDER_METHOD_BASIC_HARDWARE: + if (o->renderer_data.method[e->current.render_method]) + __evas_x11_gradient_free(o->renderer_data.method[e->current.render_method]); + { + Evas_X11_Graident *g; + Evas_List l; + + g = __evas_x11_gradient_new(e->current.display); + o->renderer_data.method[e->current.render_method] = g; + for (l = grad->color_points; l; l = l->next) + { + Evas_Color_Point col; + + col= l->data; + __evas_x11_gradient_color_add(g, col->r, col->g, col->b, + col->a, col->distance); + } + } break; case RENDER_METHOD_3D_HARDWARE: if (o->renderer_data.method[e->current.render_method]) diff --git a/legacy/evas/src/evas_image_routines.c b/legacy/evas/src/evas_image_routines.c index 5d666c5801..81e6b64026 100644 --- a/legacy/evas/src/evas_image_routines.c +++ b/legacy/evas/src/evas_image_routines.c @@ -138,7 +138,10 @@ __evas_image_image_draw(Evas_Image_Image *im, } } if (cm) - imlib_context_set_color_modifier(NULL); + { + imlib_free_color_modifier(); + imlib_context_set_color_modifier(NULL); + } } int diff --git a/legacy/evas/src/evas_image_routines.h b/legacy/evas/src/evas_image_routines.h index 2218f529c9..2961974243 100644 --- a/legacy/evas/src/evas_image_routines.h +++ b/legacy/evas/src/evas_image_routines.h @@ -16,10 +16,12 @@ #include +#ifndef SPANS_COMMON #define SPANS_COMMON(x1, w1, x2, w2) \ (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1))))) #define RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) \ ((SPANS_COMMON((x), (w), (xx), (ww))) && (SPANS_COMMON((y), (h), (yy), (hh)))) +#endif typedef void Evas_Image_Image; typedef void Evas_Image_Font; diff --git a/legacy/evas/src/evas_imlib_routines.c b/legacy/evas/src/evas_imlib_routines.c index 1701412168..042baca307 100644 --- a/legacy/evas/src/evas_imlib_routines.c +++ b/legacy/evas/src/evas_imlib_routines.c @@ -123,7 +123,10 @@ __evas_imlib_image_draw(Evas_Imlib_Image *im, } } if (cm) - imlib_context_set_color_modifier(NULL); + { + imlib_free_color_modifier(); + imlib_context_set_color_modifier(NULL); + } } int diff --git a/legacy/evas/src/evas_imlib_routines.h b/legacy/evas/src/evas_imlib_routines.h index b0c0f8cf5d..9461376ff0 100644 --- a/legacy/evas/src/evas_imlib_routines.h +++ b/legacy/evas/src/evas_imlib_routines.h @@ -16,10 +16,12 @@ #include -#define SPANS_COMMON(x1, w1, x2, w2) \ +#ifndef SPANS_COMMON +# define SPANS_COMMON(x1, w1, x2, w2) \ (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1))))) #define RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) \ ((SPANS_COMMON((x), (w), (xx), (ww))) && (SPANS_COMMON((y), (h), (yy), (hh)))) +#endif typedef void Evas_Imlib_Image; typedef void Evas_Imlib_Font; diff --git a/legacy/evas/src/evas_misc.c b/legacy/evas/src/evas_misc.c index 8e588fd0c4..cec3c5d260 100644 --- a/legacy/evas/src/evas_misc.c +++ b/legacy/evas/src/evas_misc.c @@ -6,6 +6,7 @@ #include "evas_gl_routines.h" #include "evas_imlib_routines.h" #include "evas_image_routines.h" +#include "evas_x11_routines.h" void _evas_layer_free(Evas e, Evas_Layer layer); @@ -170,6 +171,7 @@ evas_set_font_cache(Evas e, int size) __evas_imlib_text_cache_set_size(e->current.display, size); break; case RENDER_METHOD_BASIC_HARDWARE: + __evas_x11_text_cache_set_size(e->current.display, size); break; case RENDER_METHOD_3D_HARDWARE: __evas_gl_text_cache_set_size(e->current.display, size); @@ -194,6 +196,7 @@ evas_get_font_cache(Evas e) return __evas_imlib_text_cache_get_size(e->current.display); break; case RENDER_METHOD_BASIC_HARDWARE: + return __evas_x11_text_cache_get_size(e->current.display); break; case RENDER_METHOD_3D_HARDWARE: return __evas_gl_text_cache_get_size(e->current.display); @@ -219,6 +222,7 @@ evas_flush_font_cache(Evas e) __evas_imlib_text_cache_empty(e->current.display); break; case RENDER_METHOD_BASIC_HARDWARE: + __evas_x11_text_cache_empty(e->current.display); break; case RENDER_METHOD_3D_HARDWARE: __evas_gl_text_cache_empty(e->current.display); @@ -243,6 +247,7 @@ evas_set_image_cache(Evas e, int size) __evas_imlib_image_cache_set_size(e->current.display, size); break; case RENDER_METHOD_BASIC_HARDWARE: + __evas_x11_image_cache_set_size(e->current.display, size); break; case RENDER_METHOD_3D_HARDWARE: __evas_gl_image_cache_set_size(e->current.display, size); @@ -267,6 +272,7 @@ evas_get_image_cache(Evas e) return __evas_imlib_image_cache_get_size(e->current.display); break; case RENDER_METHOD_BASIC_HARDWARE: + return __evas_x11_image_cache_get_size(e->current.display); break; case RENDER_METHOD_3D_HARDWARE: return __evas_gl_image_cache_get_size(e->current.display); @@ -292,6 +298,7 @@ evas_flush_image_cache(Evas e) __evas_imlib_image_cache_empty(e->current.display); break; case RENDER_METHOD_BASIC_HARDWARE: + __evas_x11_image_cache_empty(e->current.display); break; case RENDER_METHOD_3D_HARDWARE: __evas_gl_image_cache_empty(e->current.display); @@ -317,6 +324,7 @@ evas_font_add_path(Evas e, char *path) __evas_imlib_text_font_add_path(path); break; case RENDER_METHOD_BASIC_HARDWARE: + __evas_x11_text_font_add_path(path); break; case RENDER_METHOD_3D_HARDWARE: __evas_gl_text_font_add_path(path); @@ -341,6 +349,7 @@ evas_font_del_path(Evas e, char *path) __evas_imlib_text_font_del_path(path); break; case RENDER_METHOD_BASIC_HARDWARE: + __evas_x11_text_font_del_path(path); break; case RENDER_METHOD_3D_HARDWARE: __evas_gl_text_font_del_path(path); diff --git a/legacy/evas/src/evas_render.c b/legacy/evas/src/evas_render.c index b865661970..a4b7ebd3e6 100644 --- a/legacy/evas/src/evas_render.c +++ b/legacy/evas/src/evas_render.c @@ -1,11 +1,12 @@ #include "Evas.h" -#include "evas_gl_routines.h" -#include "evas_imlib_routines.h" -#include "evas_image_routines.h" #include #include #include #include +#include "evas_gl_routines.h" +#include "evas_imlib_routines.h" +#include "evas_image_routines.h" +#include "evas_x11_routines.h" void _evas_object_get_current_translated_coords(Evas e, Evas_Object o, @@ -125,6 +126,21 @@ evas_render(Evas e) func_gradient_draw = __evas_imlib_gradient_draw; break; case RENDER_METHOD_BASIC_HARDWARE: + func_draw_add_rect = __evas_x11_draw_add_rect; + func_image_new_from_file = __evas_x11_image_new_from_file; + func_image_set_borders = __evas_x11_image_set_borders; + func_image_draw = __evas_x11_image_draw; + func_image_free = __evas_x11_image_free; + func_flush_draw = __evas_x11_flush_draw; + func_init = __evas_x11_init; + func_image_get_width = __evas_x11_image_get_width; + func_image_get_height = __evas_x11_image_get_height; + func_text_font_new = __evas_x11_text_font_new; + func_text_font_free = __evas_x11_text_font_free; + func_text_draw = __evas_x11_text_draw; + func_rectangle_draw = __evas_x11_rectangle_draw; + func_line_draw = __evas_x11_line_draw; + func_gradient_draw = __evas_x11_gradient_draw; break; case RENDER_METHOD_3D_HARDWARE: func_draw_add_rect = __evas_gl_draw_add_rect; @@ -645,6 +661,11 @@ evas_get_optimal_visual(Evas e, Display *disp) } break; case RENDER_METHOD_BASIC_HARDWARE: + if (__evas_x11_capable(disp)) + return __evas_x11_get_visual(disp, e->current.screen); + else + { + } break; case RENDER_METHOD_3D_HARDWARE: if (__evas_gl_capable(disp)) @@ -684,6 +705,11 @@ evas_get_optimal_colormap(Evas e, Display *disp) } break; case RENDER_METHOD_BASIC_HARDWARE: + if (__evas_x11_capable(disp)) + return __evas_x11_get_colormap(disp, e->current.screen); + else + { + } break; case RENDER_METHOD_3D_HARDWARE: if (__evas_gl_capable(disp)) @@ -788,6 +814,7 @@ evas_set_scale_smoothness(Evas e, int smooth) __evas_imlib_image_set_smooth_scaling(smooth); break; case RENDER_METHOD_BASIC_HARDWARE: + __evas_x11_image_set_smooth_scaling(smooth); break; case RENDER_METHOD_3D_HARDWARE: __evas_gl_image_set_smooth_scaling(smooth); diff --git a/legacy/evas/src/evas_text.c b/legacy/evas/src/evas_text.c index 8490965c5b..c5e5d8a3f7 100644 --- a/legacy/evas/src/evas_text.c +++ b/legacy/evas/src/evas_text.c @@ -6,6 +6,7 @@ #include "evas_gl_routines.h" #include "evas_imlib_routines.h" #include "evas_image_routines.h" +#include "evas_x11_routines.h" static void _evas_free_text(Evas_Object o) @@ -75,6 +76,20 @@ evas_add_text(Evas e, char *font, int size, char *text) } break; case RENDER_METHOD_BASIC_HARDWARE: + { + Evas_X11_Font *fn; + + fn = __evas_x11_text_font_new (e->current.display, + oo->current.font, + oo->current.size); + if (fn) + { + __evas_x11_text_get_size(fn, oo->current.text, + &oo->current.string.w, + &oo->current.string.h); + __evas_x11_text_font_free(fn); + } + } break; case RENDER_METHOD_3D_HARDWARE: { @@ -193,6 +208,22 @@ evas_text_at_position(Evas e, Evas_Object o, double x, double y, } break; case RENDER_METHOD_BASIC_HARDWARE: + { + int ret; + Evas_X11_Font *fn; + + fn = __evas_x11_text_font_new(e->current.display, oo->current.font, oo->current.size); + if (fn) + { + ret = __evas_x11_text_get_character_at_pos(fn, oo->current.text, + (int)(x - o->current.x), + (int)(y - o->current.y), + char_x, char_y, + char_w, char_h); + __evas_x11_text_font_free(fn); + return ret; + } + } break; case RENDER_METHOD_3D_HARDWARE: { @@ -263,6 +294,19 @@ evas_text_at(Evas e, Evas_Object o, int index, } break; case RENDER_METHOD_BASIC_HARDWARE: + { + Evas_X11_Font *fn; + + fn = __evas_x11_text_font_new(e->current.display, oo->current.font, oo->current.size); + if (fn) + { + __evas_x11_text_get_character_number(fn, oo->current.text, + index, + char_x, char_y, + char_w, char_h); + __evas_x11_text_font_free(fn); + } + } break; case RENDER_METHOD_3D_HARDWARE: { @@ -326,6 +370,17 @@ evas_text_get_ascent_descent(Evas e, Evas_Object o, } break; case RENDER_METHOD_BASIC_HARDWARE: + { + Evas_X11_Font *fn; + + fn = __evas_x11_text_font_new(e->current.display, oo->current.font, oo->current.size); + if (fn) + { + a = __evas_x11_text_font_get_ascent(fn); + d = __evas_x11_text_font_get_descent(fn); + __evas_x11_text_font_free(fn); + } + } break; case RENDER_METHOD_3D_HARDWARE: { @@ -387,6 +442,17 @@ evas_text_get_max_ascent_descent(Evas e, Evas_Object o, } break; case RENDER_METHOD_BASIC_HARDWARE: + { + Evas_X11_Font *fn; + + fn = __evas_x11_text_font_new(e->current.display, oo->current.font, oo->current.size); + if (fn) + { + a = __evas_x11_text_font_get_max_ascent(fn); + d = __evas_x11_text_font_get_max_descent(fn); + __evas_x11_text_font_free(fn); + } + } break; case RENDER_METHOD_3D_HARDWARE: { @@ -447,6 +513,16 @@ evas_text_get_advance(Evas e, Evas_Object o, } break; case RENDER_METHOD_BASIC_HARDWARE: + { + Evas_X11_Font *fn; + + fn = __evas_x11_text_font_new(e->current.display, oo->current.font, oo->current.size); + if (fn) + { + __evas_x11_text_font_get_advances(fn, oo->current.text, &a, &d); + __evas_x11_text_font_free(fn); + } + } break; case RENDER_METHOD_3D_HARDWARE: { @@ -504,6 +580,17 @@ evas_text_get_inset(Evas e, Evas_Object o) } break; case RENDER_METHOD_BASIC_HARDWARE: + { + Evas_X11_Font *fn; + + fn = __evas_x11_text_font_new(e->current.display, oo->current.font, oo->current.size); + if (fn) + { + inset = __evas_x11_text_font_get_first_inset(fn, oo->current.text); + __evas_x11_text_font_free(fn); + return (double)inset; + } + } break; case RENDER_METHOD_3D_HARDWARE: { @@ -575,6 +662,23 @@ evas_set_text(Evas e, Evas_Object o, char *text) } break; case RENDER_METHOD_BASIC_HARDWARE: + { + Evas_X11_Font *fn; + + fn = __evas_x11_text_font_new (e->current.display, + oo->current.font, + oo->current.size); + if (fn) + { + __evas_x11_text_get_size(fn, oo->current.text, + &oo->current.string.w, + &oo->current.string.h); + evas_resize(e, o, + (double)oo->current.string.w, + (double)oo->current.string.h); + __evas_x11_text_font_free(fn); + } + } break; case RENDER_METHOD_3D_HARDWARE: { @@ -668,6 +772,23 @@ evas_set_font(Evas e, Evas_Object o, char *font, int size) } break; case RENDER_METHOD_BASIC_HARDWARE: + { + Evas_X11_Font *fn; + + fn = __evas_x11_text_font_new (e->current.display, + oo->current.font, + oo->current.size); + if (fn) + { + __evas_x11_text_get_size(fn, oo->current.text, + &oo->current.string.w, + &oo->current.string.h); + evas_resize(e, o, + (double)oo->current.string.w, + (double)oo->current.string.h); + __evas_x11_text_font_free(fn); + } + } break; case RENDER_METHOD_3D_HARDWARE: { diff --git a/legacy/evas/src/evas_x11_routines.c b/legacy/evas/src/evas_x11_routines.c new file mode 100644 index 0000000000..a6fe726b2d --- /dev/null +++ b/legacy/evas/src/evas_x11_routines.c @@ -0,0 +1,758 @@ +#include "evas_x11_routines.h" + +static void __evas_imlib_image_cache_flush(Display *disp); +static int __evas_anti_alias = 1; +static Evas_List drawable_list = NULL; + +static Visual *__evas_visual = NULL; +static Colormap __evas_cmap = 0; + +/*****************************************************************************/ +/* image internals ***********************************************************/ +/*****************************************************************************/ + +static void +__evas_x11_image_cache_flush(Display *disp) +{ + int size; + + size = imlib_get_cache_size(); + imlib_set_cache_size(0); + imlib_set_cache_size(size); +} + +/*****************************************************************************/ +/* image externals ***********************************************************/ +/*****************************************************************************/ + +Evas_X11_Image * +__evas_x11_image_new_from_file(Display *disp, char *file) +{ + return (Evas_X11_Image *)imlib_load_image(file); +} + +void +__evas_x11_image_free(Evas_X11_Image *im) +{ + imlib_context_set_image((Imlib_Image)im); + imlib_free_image(); +} + +void +__evas_x11_image_cache_empty(Display *disp) +{ + int size; + + size = imlib_get_cache_size(); + imlib_set_cache_size(0); + imlib_set_cache_size(size); +} + +void +__evas_x11_image_cache_set_size(Display *disp, int size) +{ + imlib_set_cache_size(size); +} + +int +__evas_x11_image_cache_get_size(Display *disp) +{ + return imlib_get_cache_size(); +} + +void +__evas_x11_image_draw(Evas_X11_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_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_display(disp); + imlib_context_set_visual(__evas_visual); + imlib_context_set_colormap(__evas_cmap); + imlib_context_set_drawable(w); + imlib_context_set_dither(1); + imlib_context_set_blend(0); + imlib_context_set_angle(0.0); + imlib_context_set_operation(IMLIB_OP_COPY); + imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT); + imlib_context_set_anti_alias(__evas_anti_alias); + for(l = drawable_list; l; l = l->next) + { + Evas_X11_Drawable *dr; + + dr = l->data; + + if ((dr->win == w) && (dr->disp == disp)) + { + Evas_List ll; + + for (ll = dr->tmp_images; ll; ll = ll->next) + { + Evas_X11_Update *up; + + up = ll->data; + + /* if image intersects image update - render */ + if (RECTS_INTERSECT(up->x, up->y, up->w, up->h, + dst_x, dst_y, dst_w, dst_h)) + { + Pixmap pmap = 0, mask = 0, s_pmap = 0, s_mask = 0; + + if (!up->p) + up->p = XCreatePixmap(disp, w, up->w, up->h, dr->depth); + imlib_context_set_image(im); + imlib_render_pixmaps_for_whole_image(&pmap, &mask); + /* if we need to scale...... */ +/* + if ((src_w != dst_w) || (src_h) != (dst_h)) + { + if (mask) + { + } + + if (s_pmap) XFreePixmap(disp, s_pmap); + if (s_mask) XFreePixmap(disp, s_mask); + } + else +*/ + { + if (mask) + { +/* + XSetStipple(disp, dr->gc, mask); + XSetTSOrigin(disp, dr->gc, dst_x - up->x, dst_y - up->y); +*/ + XSetClipMask(disp, dr->gc, mask); + XSetClipOrigin(disp, dr->gc, dst_x - up->x, dst_y - up->y); + } + else + { + XSetClipMask(disp, dr->gc, None); + } + if (pmap) + XCopyArea(disp, pmap, up->p, dr->gc, + src_x, src_y, src_w, src_h, dst_x - up->x, dst_y - up->y); + } + if (pmap) imlib_free_pixmap_and_mask(pmap); + } + } + } + } + if (cm) + { + imlib_free_color_modifier(); + imlib_context_set_color_modifier(NULL); + } +} + +int +__evas_x11_image_get_width(Evas_X11_Image *im) +{ + imlib_context_set_image((Imlib_Image)im); + return imlib_image_get_width(); +} + +int +__evas_x11_image_get_height(Evas_X11_Image *im) +{ + imlib_context_set_image((Imlib_Image)im); + return imlib_image_get_height(); +} + +void +__evas_x11_image_set_borders(Evas_X11_Image *im, int left, int right, + int top, int bottom) +{ + Imlib_Border bd; + + imlib_context_set_image((Imlib_Image)im); + bd.left = left; + bd.right = right; + bd.top = top; + bd.bottom = bottom; + imlib_image_set_border(&bd); +} + +void +__evas_x11_image_set_smooth_scaling(int on) +{ + __evas_anti_alias = on; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + +/*****************************************************************************/ +/* font internals ************************************************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/* font externals ************************************************************/ +/*****************************************************************************/ + +Evas_X11_Font * +__evas_x11_text_font_new(Display *disp, char *font, int size) +{ + return NULL; +} + +void +__evas_x11_text_font_free(Evas_X11_Font *fn) +{ +} + +int +__evas_x11_text_font_get_ascent(Evas_X11_Font *fn) +{ + return 1; +} + +int +__evas_x11_text_font_get_descent(Evas_X11_Font *fn) +{ + return 1; +} + +int +__evas_x11_text_font_get_max_ascent(Evas_X11_Font *fn) +{ + return 1; +} + +int +__evas_x11_text_font_get_max_descent(Evas_X11_Font *fn) +{ + return 1; +} + +void +__evas_x11_text_font_get_advances(Evas_X11_Font *fn, char *text, + int *advance_horiz, + int *advance_vert) +{ +} + +int +__evas_x11_text_font_get_first_inset(Evas_X11_Font *fn, char *text) +{ + return 1; +} + +void +__evas_x11_text_font_add_path(char *path) +{ +} + +void +__evas_x11_text_font_del_path(char *path) +{ +} + +char ** +__evas_x11_text_font_list_paths(int *count) +{ + return NULL; +} + +void +__evas_x11_text_cache_empty(Display *disp) +{ +} + +void +__evas_x11_text_cache_set_size(Display *disp, int size) +{ +} + +int +__evas_x11_text_cache_get_size(Display *disp) +{ + return 0; +} + +void +__evas_x11_text_draw(Evas_X11_Font *fn, Display *disp, Imlib_Image dstim, Window win, + int win_w, int win_h, int x, int y, char *text, + int r, int g, int b, int a) +{ +} + +void +__evas_x11_text_get_size(Evas_X11_Font *fn, char *text, int *w, int *h) +{ +} + +int +__evas_x11_text_get_character_at_pos(Evas_X11_Font *fn, char *text, + int x, int y, + int *cx, int *cy, int *cw, int *ch) +{ + return -1; +} + +void +__evas_x11_text_get_character_number(Evas_X11_Font *fn, char *text, + int num, + int *cx, int *cy, int *cw, int *ch) +{ +} + + + + + + + + + + + + + + + + + + + + + + + + + +/*****************************************************************************/ +/* rectangle externals *******************************************************/ +/*****************************************************************************/ + +void __evas_x11_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) +{ + Evas_List l; + + 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(__evas_anti_alias); + imlib_context_set_blend(1); + for(l = drawable_list; l; l = l->next) + { + Evas_X11_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_X11_Update *up; + + up = ll->data; + + /* if image intersects image update - render */ + if (RECTS_INTERSECT(up->x, up->y, up->w, up->h, + x, y, w, h)) + { +/* + if (!up->image) + up->image = imlib_create_image(up->w, up->h); + imlib_context_set_image(up->image); + imlib_image_fill_rectangle(x - up->x, y - up->y, w, h); +*/ + } + } + } + } +} + + + + + + + + + + + + + + + + + +/*****************************************************************************/ +/* rectangle externals *******************************************************/ +/*****************************************************************************/ + +void __evas_x11_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) +{ + Evas_List l; + 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); + w = x2 - x1; + if (w < 0) w = -w; + h = y2 - y1; + if (h < 0) h = -h; + if (x1 < x2) x = x1; + else x = x2; + if (y1 < y2) y = y1; + else y = y2; + w++; h++; + for(l = drawable_list; l; l = l->next) + { + Evas_X11_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_X11_Update *up; + + up = ll->data; + + /* if image intersects image update - render */ + if (RECTS_INTERSECT(up->x, up->y, up->w, up->h, + x, y, w, h)) + { +/* + if (!up->image) + up->image = imlib_create_image(up->w, up->h); + imlib_context_set_image(up->image); + imlib_image_draw_line(x1 - up->x, y1 - up->y, x2 - up->x, y2 - up->y, 0); +*/ + } + } + } + } +} + + + + + + + + + + + + + + + + + +/*****************************************************************************/ +/* gradient externals ********************************************************/ +/*****************************************************************************/ + + +Evas_X11_Graident * +__evas_x11_gradient_new(Display *disp) +{ + return (Evas_X11_Graident *)imlib_create_color_range(); +} + +void +__evas_x11_gradient_free(Evas_X11_Graident *gr) +{ + imlib_context_set_color_range((Imlib_Color_Range)gr); + imlib_free_color_range(); +} + +void +__evas_x11_gradient_color_add(Evas_X11_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_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) +{ + Evas_List l; + + imlib_context_set_angle(angle); + imlib_context_set_operation(IMLIB_OP_COPY); + imlib_context_set_color_modifier(NULL); + imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT); + imlib_context_set_color_range((Imlib_Color_Range)gr); + imlib_context_set_anti_alias(1); + imlib_context_set_blend(1); + for(l = drawable_list; l; l = l->next) + { + Evas_X11_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_X11_Update *up; + + up = ll->data; + + /* if image intersects image update - render */ + if (RECTS_INTERSECT(up->x, up->y, up->w, up->h, + x, y, w, h)) + { +/* + if (!up->image) + up->image = imlib_create_image(up->w, up->h); + imlib_context_set_image(up->image); + imlib_image_fill_color_range_rectangle(x - up->x, y - up->y, w, h, angle); +*/ + } + } + } + } +} + + + + + + + + + + + + + + + + + +/*****************************************************************************/ +/* general externals *********************************************************/ +/*****************************************************************************/ + +void +__evas_x11_sync(Display *disp) +{ + XSync(disp, False); +} + +void +__evas_x11_flush_draw(Display *disp, Imlib_Image dstim, Window win) +{ + Evas_List l; + +/* +*/ + for(l = drawable_list; l; l = l->next) + { + Evas_X11_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_X11_Update *up; + + up = ll->data; + + if (up->p) + { + XCopyArea(disp, up->p, win, dr->gc, + 0, 0, up->w, up->h, up->x, up->y); + XFreePixmap(disp, up->p); + } + + free(up); + } + if (dr->tmp_images) + dr->tmp_images = evas_list_free(dr->tmp_images); + } + XFreeGC(disp, dr->gc); + free(dr); + } + if (drawable_list) + drawable_list = evas_list_free(drawable_list); + drawable_list = NULL; +} + + +int +__evas_x11_capable(Display *disp) +{ + return 1; +} + +Visual * +__evas_x11_get_visual(Display *disp, int screen) +{ + int depth; + + __evas_visual = imlib_get_best_visual(disp, screen, &depth); + return __evas_visual; +} + +XVisualInfo * +__evas_x11_get_visual_info(Display *disp, int screen) +{ + static XVisualInfo *vi = NULL; + XVisualInfo vi_template; + int n; + + if (vi) return vi; + vi_template.visualid = (__evas_x11_get_visual(disp, screen))->visualid; + vi_template.screen = screen; + vi = XGetVisualInfo(disp, VisualIDMask | VisualScreenMask, &vi_template ,&n); + return vi; +} + +Colormap +__evas_x11_get_colormap(Display *disp, int screen) +{ + Visual *v; + + if (__evas_cmap) return __evas_cmap; + v = __evas_x11_get_visual(disp, screen); + __evas_cmap = XCreateColormap(disp, RootWindow(disp, screen), v, AllocNone); + return __evas_cmap; +} + +void +__evas_x11_init(Display *disp, int screen, int colors) +{ + static int initted = 0; + + if (!initted) + { + imlib_set_font_cache_size(1024 * 1024); + imlib_set_cache_size(8 * 1024 * 1024); + initted = 1; + } + imlib_set_color_usage(colors); +} + +void +__evas_x11_draw_add_rect(Display *disp, Imlib_Image dstim, Window win, + int x, int y, int w, int h) +{ + Evas_List l; + + for(l = drawable_list; l; l = l->next) + { + Evas_X11_Drawable *dr; + + dr = l->data; + + if ((dr->win == win) && (dr->disp == disp)) + { + Evas_X11_Update *up; + + up = malloc(sizeof(Evas_X11_Update)); + up->x = x; + up->y = y; + up->w = w; + up->h = h; + up->p = 0; + dr->tmp_images = evas_list_append(dr->tmp_images, up); + } + return; + } + { + Evas_X11_Drawable *dr; + Evas_X11_Update *up; + GC gc; + XGCValues gcv; + XWindowAttributes att; + + gc = XCreateGC(disp, win, 0, &gcv); + XGetWindowAttributes(disp, win, &att); + dr = malloc(sizeof(Evas_X11_Drawable)); + dr->win = win; + dr->disp = disp; + dr->tmp_images = NULL; + dr->gc = gc; + dr->depth = att.depth; + up = malloc(sizeof(Evas_X11_Update)); + up->x = x; + up->y = y; + up->w = w; + up->h = h; + up->p = 0; + drawable_list = evas_list_append(drawable_list, dr); + dr->tmp_images = evas_list_append(dr->tmp_images, up); + } +} diff --git a/legacy/evas/src/evas_x11_routines.h b/legacy/evas/src/evas_x11_routines.h new file mode 100644 index 0000000000..da916cad04 --- /dev/null +++ b/legacy/evas/src/evas_x11_routines.h @@ -0,0 +1,115 @@ +#include "config.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "Evas.h" + +#include + +#ifndef SPANS_COMMON +#define SPANS_COMMON(x1, w1, x2, w2) \ +(!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1))))) +#define RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) \ +((SPANS_COMMON((x), (w), (xx), (ww))) && (SPANS_COMMON((y), (h), (yy), (hh)))) +#endif + +typedef void Evas_X11_Image; +typedef void Evas_X11_Font; +typedef void Evas_X11_Graident; + +typedef struct _evas_x11_drawable Evas_X11_Drawable; +typedef struct _evas_x11_update Evas_X11_Update; + +struct _evas_x11_drawable +{ + Display *disp; + Window win; + GC gc; + int depth; + Evas_List tmp_images; +}; + +struct _evas_x11_update +{ + Pixmap p; + int x, y, w, h; +}; + +/***************/ +/* image stuff */ +/***************/ +Evas_X11_Image *__evas_x11_image_new_from_file(Display *disp, char *file); +void __evas_x11_image_free(Evas_X11_Image *im); +void __evas_x11_image_cache_empty(Display *disp); +void __evas_x11_image_cache_set_size(Display *disp, int size); +int __evas_x11_image_cache_get_size(Display *disp); +int __evas_x11_image_get_width(Evas_X11_Image *im); +int __evas_x11_image_get_height(Evas_X11_Image *im); +void __evas_x11_image_set_borders(Evas_X11_Image *im, int left, int right, int top, int bottom); +void __evas_x11_image_set_smooth_scaling(int on); +void __evas_x11_image_draw(Evas_X11_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 */ +/********/ +Evas_X11_Font *__evas_x11_text_font_new(Display *disp, char *font, int size); +void __evas_x11_text_font_free(Evas_X11_Font *fn); +int __evas_x11_text_font_get_ascent(Evas_X11_Font *fn); +int __evas_x11_text_font_get_descent(Evas_X11_Font *fn); +int __evas_x11_text_font_get_max_ascent(Evas_X11_Font *fn); +int __evas_x11_text_font_get_max_descent(Evas_X11_Font *fn); +void __evas_x11_text_font_get_advances(Evas_X11_Font *fn, char *text, int *advance_horiz, int *advance_vert); +int __evas_x11_text_font_get_first_inset(Evas_X11_Font *fn, char *text); +void __evas_x11_text_font_add_path(char *path); +void __evas_x11_text_font_del_path(char *path); +char **__evas_x11_text_font_list_paths(int *count); +void __evas_x11_text_cache_empty(Display *disp); +void __evas_x11_text_cache_set_size(Display *disp, int size); +int __evas_x11_text_cache_get_size(Display *disp); +void __evas_x11_text_get_size(Evas_X11_Font *fn, char *text, int *w, int *h); +int __evas_x11_text_get_character_at_pos(Evas_X11_Font *fn, char *text, int x, int y, int *cx, int *cy, int *cw, int *ch); +void __evas_x11_text_get_character_number(Evas_X11_Font *fn, char *text, int num, int *cx, int *cy, int *cw, int *ch); +void __evas_x11_text_draw(Evas_X11_Font *fn, Display *disp, Imlib_Image dstim, Window win, int win_w, int win_h, int x, int y, char *text, int r, int g, int b, int a); + +/**************/ +/* rectangles */ +/**************/ + +void __evas_x11_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); + +/*********/ +/* lines */ +/*********/ + +void __evas_x11_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); + +/*************/ +/* gradients */ +/*************/ +Evas_X11_Graident *__evas_x11_gradient_new(Display *disp); +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); + +/***********/ +/* drawing */ +/***********/ +void __evas_x11_init(Display *disp, int screen, int colors); +int __evas_x11_capable(Display *disp); +void __evas_x11_flush_draw(Display *disp, Imlib_Image dstim, Window win); +void __evas_x11_sync(Display *disp); +Visual *__evas_x11_get_visual(Display *disp, int screen); +XVisualInfo *__evas_x11_get_visual_info(Display *disp, int screen); +Colormap __evas_x11_get_colormap(Display *disp, int screen); +void __evas_x11_draw_add_rect(Display *disp, Imlib_Image dstim, Window win, int x, int y, int w, int h); + diff --git a/legacy/evas/test/evas_test.c b/legacy/evas/test/evas_test.c index 9ccd3f4f22..7f14c74f24 100644 --- a/legacy/evas/test/evas_test.c +++ b/legacy/evas/test/evas_test.c @@ -102,6 +102,8 @@ main(int argc, char **argv) e = evas_new(); if ((argc >= 4) && (!strcmp(argv[3], "software"))) evas_set_output_method(e, RENDER_METHOD_ALPHA_SOFTWARE); + else if ((argc >= 4) && (!strcmp(argv[3], "x11"))) + evas_set_output_method(e, RENDER_METHOD_BASIC_HARDWARE); else if ((argc >= 4) && (!strcmp(argv[3], "image"))) { DATA32 *data;