diff --git a/legacy/evas/acconfig.h b/legacy/evas/acconfig.h index de2d5cf35d..cc407718fe 100644 --- a/legacy/evas/acconfig.h +++ b/legacy/evas/acconfig.h @@ -12,6 +12,7 @@ #undef BUILD_ENGINE_SOFTWARE_X11 #undef BUILD_ENGINE_DIRECTFB #undef BUILD_ENGINE_FB +#undef BUILD_ENGINE_BUFFER #undef BUILD_ENGINE_SOFTWARE_WIN32_GDI #undef BUILD_ENGINE_SOFTWARE_QTOPIA #undef BUILD_ENGINE_GL_COMMON diff --git a/legacy/evas/configure.in b/legacy/evas/configure.in index 2b4fa1b02f..2f94dcffa3 100644 --- a/legacy/evas/configure.in +++ b/legacy/evas/configure.in @@ -171,6 +171,20 @@ AC_ARG_ENABLE(fb, [ --enable-fb enable the FB rendering bac ] ) +AC_MSG_CHECKING(whether buffer backend is to be built) + +AC_ARG_ENABLE(fb, [ --enable-buffer enable the Buffer rendering backend], [ + AC_MSG_RESULT(yes) + AM_CONDITIONAL(BUILD_ENGINE_BUFFER, true) + AC_DEFINE(BUILD_ENGINE_BUFFER) + ENGINE_BUFFER_PRG="evas_buffer_test" + ], [ + AC_MSG_RESULT(no) + AM_CONDITIONAL(BUILD_ENGINE_BUFFER, false) + ENGINE_BUFFER_PRG="" + ] +) + AC_MSG_CHECKING(whether software qtopia backend is to be built) AC_ARG_ENABLE(software-qtopia, [ --enable-software-qtopia enable the Software Qtopia rendering backend], [ @@ -573,6 +587,7 @@ AC_SUBST(edb_libs) AC_SUBST(ENGINE_SOFTWARE_X11_PRG) AC_SUBST(ENGINE_DIRECTFB_PRG) AC_SUBST(ENGINE_FB_PRG) +AC_SUBST(ENGINE_BUFFER_PRG) AC_SUBST(ENGINE_SOFTWARE_QTOPIA_PRG) AC_SUBST(ENGINE_GL_X11_PRG) @@ -589,6 +604,7 @@ src/lib/engines/Makefile src/lib/engines/common/Makefile src/lib/engines/software_x11/Makefile src/lib/engines/fb/Makefile +src/lib/engines/buffer/Makefile src/lib/engines/software_win32_gdi/Makefile src/lib/engines/software_qtopia/Makefile src/lib/engines/directfb/Makefile diff --git a/legacy/evas/src/bin/Makefile.am b/legacy/evas/src/bin/Makefile.am index 29805c1558..5dcbc94021 100644 --- a/legacy/evas/src/bin/Makefile.am +++ b/legacy/evas/src/bin/Makefile.am @@ -8,6 +8,7 @@ bin_PROGRAMS = \ @ENGINE_SOFTWARE_X11_PRG@ \ @ENGINE_DIRECTFB_PRG@ \ @ENGINE_FB_PRG@ \ +@ENGINE_BUFFER_PRG@ \ @ENGINE_SOFTWARE_QTOPIA_PRG@ \ @ENGINE_GL_X11_PRG@ @@ -18,6 +19,7 @@ evas_software_x11_perf_load \ evas_directfb_test \ evas_directfb_window \ evas_fb_test \ +evas_buffer_test \ evas_software_qtopia_test \ evas_gl_x11_test @@ -59,6 +61,12 @@ evas_fb_test_LDFLAGS = $(LDFLAGS) evas_fb_test_CFLAGS = $(CFLAGS) evas_fb_test_DEPENDENCIES = $(top_builddir)/src/lib/libevas.la +evas_buffer_test_SOURCES = evas_test_main.h evas_test_main.c evas_buffer_main.c +evas_buffer_test_LDADD = $(top_builddir)/src/lib/libevas.la -lm +evas_buffer_test_LDFLAGS = $(LDFLAGS) +evas_buffer_test_CFLAGS = $(CFLAGS) +evas_buffer_test_DEPENDENCIES = $(top_builddir)/src/lib/libevas.la + if BUILD_ENGINE_SOFTWARE_QTOPIA moc_evas_software_qtopia_main.cpp: evas_software_qtopia_main.h @qt_moc@ evas_software_qtopia_main.h -o moc_evas_software_qtopia_main.cpp diff --git a/legacy/evas/src/bin/evas_buffer_main.c b/legacy/evas/src/bin/evas_buffer_main.c new file mode 100644 index 0000000000..e00578482b --- /dev/null +++ b/legacy/evas/src/bin/evas_buffer_main.c @@ -0,0 +1,46 @@ +#include "evas_test_main.h" + +#include "Evas.h" +#include "Evas_Engine_Buffer.h" + +#include +#include + +int +main(int argc, char **argv) +{ + int rot = 0; + unsigned char *img_buf = NULL; + + if ((argc >= 3) && (!strcmp(argv[1], "-rot"))) + rot = atoi(argv[2]); + evas = evas_new(); + evas_output_method_set(evas, evas_render_method_lookup("buffer")); + evas_output_size_set(evas, win_w, win_h); + evas_output_viewport_set(evas, 0, 0, win_w, win_h); + { + Evas_Engine_Info_Buffer *einfo; + + einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(evas); + + /* the following is specific to the engine */ + einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB24; + img_buf = malloc(win_w * win_h * 3); + einfo->info.dest_buffer = img_buf; + einfo->info.dest_buffer_row_bytes = win_w * 3; + einfo->info.use_color_key = 1; + einfo->info.alpha_threshold = 128; + einfo->info.color_key_r = 0xff; + einfo->info.color_key_g = 0x00; + einfo->info.color_key_b = 0xff; + evas_engine_info_set(evas, (Evas_Engine_Info *) einfo); + } + setup(); + orig_start_time = start_time = get_time(); + for (;;) + { + loop(); + evas_render(evas); + } + return 0; +} diff --git a/legacy/evas/src/lib/Evas_Engine_Buffer.h b/legacy/evas/src/lib/Evas_Engine_Buffer.h new file mode 100644 index 0000000000..2c5e573805 --- /dev/null +++ b/legacy/evas/src/lib/Evas_Engine_Buffer.h @@ -0,0 +1,30 @@ +#ifndef _EVAS_ENGINE_BUFFER_H +#define _EVAS_ENGINE_BUFFER_H + +#define EVAS_ENGINE_BUFFER_DEPTH_RGBA32 0 +#define EVAS_ENGINE_BUFFER_DEPTH_RGB24 1 + +typedef struct _Evas_Engine_Info_Buffer Evas_Engine_Info_Buffer; + +struct _Evas_Engine_Info_Buffer +{ + /* PRIVATE - don't mess with this baby or evas will poke its tongue out */ + /* at you and make nasty noises */ + Evas_Engine_Info magic; + + struct { + int depth_type; + + void *dest_buffer; + int dest_buffer_row_bytes; + + char use_color_key : 1; + int alpha_threshold; + int color_key_r; + int color_key_g; + int color_key_b; + } info; +}; +#endif + + diff --git a/legacy/evas/src/lib/Makefile.am b/legacy/evas/src/lib/Makefile.am index 826695f76d..629d47acca 100644 --- a/legacy/evas/src/lib/Makefile.am +++ b/legacy/evas/src/lib/Makefile.am @@ -20,6 +20,7 @@ EXTRA_DIST = \ Evas_Engine_Software_X11.h \ Evas_Engine_DirectFB.h \ Evas_Engine_FB.h \ +Evas_Engine_Buffer.h \ Evas_Engine_Software_Win32_GDI.h \ Evas_Engine_Software_Qtopia.h \ Evas_Engine_GL_X11.h @@ -48,6 +49,14 @@ ENGINE_FB = ENGINE_FB_INC = endif +if BUILD_ENGINE_BUFFER +ENGINE_BUFFER = engines/buffer/libevas_engine_buffer.la +ENGINE_BUFFER_INC = Evas_Engine_Buffer.h +else +ENGINE_BUFFER = +ENGINE_BUFFER_INC = +endif + if BUILD_ENGINE_SOFTWARE_QTOPIA ENGINE_SOFTWARE_QTOPIA = engines/software_qtopia/libevas_engine_software_qtopia.la ENGINE_SOFTWARE_QTOPIA_INC = Evas_Engine_Software_Qtopia.h @@ -69,6 +78,7 @@ Evas.h \ $(ENGINE_SOFTWARE_X11_INC) \ $(ENGINE_DIRECTFB_INC) \ $(ENGINE_FB_INC) \ +$(ENGINE_BUFFER_INC) \ $(ENGINE_SOFTWARE_QTOPIA_INC) \ $(ENGINE_GL_X11_INC) @@ -85,6 +95,7 @@ libevas_la_LIBADD = $(LDFLAGS) \ $(ENGINE_SOFTWARE_X11) \ $(ENGINE_DIRECTFB) \ $(ENGINE_FB) \ + $(ENGINE_BUFFER) \ $(ENGINE_SOFTWARE_QTOPIA) \ $(ENGINE_GL_X11) @@ -98,6 +109,7 @@ libevas_la_DEPENDENCIES = \ $(ENGINE_SOFTWARE_X11) \ $(ENGINE_DIRECTFB) \ $(ENGINE_FB) \ + $(ENGINE_BUFFER) \ $(ENGINE_SOFTWARE_QTOPIA) \ $(ENGINE_GL_X11) diff --git a/legacy/evas/src/lib/canvas/evas_main.c b/legacy/evas/src/lib/canvas/evas_main.c index 9a51fcc825..f9cc80a8e7 100644 --- a/legacy/evas/src/lib/canvas/evas_main.c +++ b/legacy/evas/src/lib/canvas/evas_main.c @@ -9,6 +9,9 @@ #ifdef BUILD_ENGINE_FB #include "evas_engine_api_fb.h" #endif +#ifdef BUILD_ENGINE_BUFFER +#include "evas_engine_api_buffer.h" +#endif #ifdef BUILD_ENGINE_SOFTWARE_WIN32_GDI #include "evas_engine_api_software_win32_gdi.h" #endif @@ -171,6 +174,11 @@ evas_output_method_set(Evas *e, int render_method) e->engine.func = &evas_engine_fb_func; else #endif +#ifdef BUILD_ENGINE_BUFFER + if (e->output.render_method == RENDER_METHOD_BUFFER) + e->engine.func = &evas_engine_buffer_func; + else +#endif #ifdef BUILD_ENGINE_SOFTWARE_WIN32_GDI if (e->output.render_method == RENDER_METHOD_SOFTWARE_WIN32_GDI) e->engine.func = &evas_engine_software_win32_gdi_func; @@ -647,10 +655,13 @@ evas_render_method_lookup(const char *name) if (!strcmp(name, "gl_x11")) return RENDER_METHOD_GL_X11; #endif #ifdef BUILD_ENGINE_DIRECTFB - if (!strcmp(name, "directfb")) return RENDER_METHOD_DIRECTFB; + if (!strcmp(name, "directfb")) return RENDER_METHOD_DIRECTFB; #endif #ifdef BUILD_ENGINE_FB - if (!strcmp(name, "fb")) return RENDER_METHOD_FB; + if (!strcmp(name, "fb")) return RENDER_METHOD_FB; +#endif +#ifdef BUILD_ENGINE_BUFFER + if (!strcmp(name, "buffer")) return RENDER_METHOD_BUFFER; #endif #ifdef BUILD_ENGINE_SOFTWARE_WIN32_GDI if (!strcmp(name, "software_win32_gdi")) return RENDER_METHOD_SOFTWARE_WIN32_GDI; @@ -700,18 +711,21 @@ evas_render_method_list(void) { Evas_List *methods = NULL; -#ifdef BUILD_ENGINE_SOFTWARE_X11 +#ifdef BUILD_ENGINE_SOFTWARE_X11 methods = evas_list_append(methods, strdup("software_x11")); #endif -#ifdef BUILD_ENGINE_GL_X11 +#ifdef BUILD_ENGINE_GL_X11 methods = evas_list_append(methods, strdup("gl_x11")); #endif -#ifdef BUILD_ENGINE_DIRECTFB +#ifdef BUILD_ENGINE_DIRECTFB methods = evas_list_append(methods, strdup("directfb")); #endif -#ifdef BUILD_ENGINE_FB +#ifdef BUILD_ENGINE_FB methods = evas_list_append(methods, strdup("fb")); #endif +#ifdef BUILD_ENGINE_BUFFER + methods = evas_list_append(methods, strdup("buffer")); +#endif #ifdef BBUILD_ENGINE_SOFTWARE_WIN32_GDI methods = evas_list_append(methods, strdup("software_win32_gdi")); #endif diff --git a/legacy/evas/src/lib/engines/Makefile.am b/legacy/evas/src/lib/engines/Makefile.am index 3d8ee4f70d..b915f7814e 100644 --- a/legacy/evas/src/lib/engines/Makefile.am +++ b/legacy/evas/src/lib/engines/Makefile.am @@ -4,6 +4,7 @@ SUBDIRS = \ common \ software_x11 \ fb \ +buffer \ software_win32_gdi \ software_qtopia \ directfb \ diff --git a/legacy/evas/src/lib/engines/buffer/Makefile.am b/legacy/evas/src/lib/engines/buffer/Makefile.am new file mode 100644 index 0000000000..6376fbdc03 --- /dev/null +++ b/legacy/evas/src/lib/engines/buffer/Makefile.am @@ -0,0 +1,36 @@ +## Process this file with automake to produce Makefile.in + +AUTOMAKE_OPTIONS = 1.4 foreign + +# A list of all the files in the current directory which can be regenerated +MAINTAINERCLEANFILES = Makefile.in + +LDFLAGS = -L/usr/local/lib +INCLUDES = @freetype_cflags@ \ + -I. \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/lib/include \ + -I$(includedir) \ + -I/usr/local/include + + +if BUILD_ENGINE_BUFFER + +noinst_LTLIBRARIES = libevas_engine_buffer.la +libevas_engine_buffer_la_SOURCES = \ +evas_engine.h \ +evas_engine.c \ +evas_outbuf.c + +libevas_engine_buffer_la_LIBADD = \ +$(LDFLAGS) + +libevas_engine_buffer_la_DEPENDENCIES = \ +$(top_builddir)/config.h + +endif + +EXTRA_DIST = \ +evas_engine.h \ +evas_engine.c \ +evas_outbuf.c diff --git a/legacy/evas/src/lib/engines/buffer/evas_engine.c b/legacy/evas/src/lib/engines/buffer/evas_engine.c new file mode 100644 index 0000000000..c9d9bfe523 --- /dev/null +++ b/legacy/evas/src/lib/engines/buffer/evas_engine.c @@ -0,0 +1,1082 @@ +#include "evas_common.h" +#include "evas_private.h" +#include "evas_engine.h" +#include "evas_engine_api_buffer.h" +#include "Evas.h" +#include "Evas_Engine_Buffer.h" + +static void *evas_engine_buffer_info(Evas *e); +static void evas_engine_buffer_info_free(Evas *e, void *info); +static void evas_engine_buffer_setup(Evas *e, void *info); +static void *evas_engine_buffer_output_setup(int w, + int h, + void *dest_buffer, + int dest_buffer_row_bytes, + int depth_type, + int use_color_key, + int alpha_threshold, + int color_key_r, + int color_key_g, + int color_key_b + ); +static void evas_engine_buffer_output_free(void *data); +static void evas_engine_buffer_output_resize(void *data, int w, int h); +static void evas_engine_buffer_output_tile_size_set(void *data, int w, int h); +static void evas_engine_buffer_output_redraws_rect_add(void *data, int x, int y, int w, int h); +static void evas_engine_buffer_output_redraws_rect_del(void *data, int x, int y, int w, int h); +static void evas_engine_buffer_output_redraws_clear(void *data); +static void *evas_engine_buffer_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch); +static void evas_engine_buffer_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h); +static void evas_engine_buffer_output_flush(void *data); +static void *evas_engine_buffer_context_new(void *data); +static void evas_engine_buffer_context_free(void *data, void *context); +static void evas_engine_buffer_context_clip_set(void *data, void *context, int x, int y, int w, int h); +static void evas_engine_buffer_context_clip_clip(void *data, void *context, int x, int y, int w, int h); +static void evas_engine_buffer_context_clip_unset(void *data, void *context); +static int evas_engine_buffer_context_clip_get(void *data, void *context, int *x, int *y, int *w, int *h); +static void evas_engine_buffer_context_color_set(void *data, void *context, int r, int g, int b, int a); +static int evas_engine_buffer_context_color_get(void *data, void *context, int *r, int *g, int *b, int *a); +static void evas_engine_buffer_context_multiplier_set(void *data, void *context, int r, int g, int b, int a); +static void evas_engine_buffer_context_multiplier_unset(void *data, void *context); +static int evas_engine_buffer_context_multiplier_get(void *data, void *context, int *r, int *g, int *b, int *a); +static void evas_engine_buffer_context_cutout_add(void *data, void *context, int x, int y, int w, int h); +static void evas_engine_buffer_context_cutout_clear(void *data, void *context); +static void evas_engine_buffer_draw_rectangle(void *data, void *context, void *surface, int x, int y, int w, int h); +static void evas_engine_buffer_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2); +static void *evas_engine_buffer_polygon_point_add(void *data, void *context, void *polygon, int x, int y); +static void *evas_engine_buffer_polygon_points_clear(void *data, void *context, void *polygon); +static void evas_engine_buffer_polygon_draw(void *data, void *context, void *surface, void *polygon); +static void *evas_engine_buffer_gradient_color_add(void *data, void *context, void *gradient, int r, int g, int b, int a, int distance); +static void *evas_engine_buffer_gradient_colors_clear(void *data, void *context, void *gradient); +static void evas_engine_buffer_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h, double angle); +static void *evas_engine_buffer_image_load(void *data, char *file, char *key, int *error); +static void *evas_engine_buffer_image_new_from_data(void *data, int w, int h, DATA32 *image_data); +static void *evas_engine_buffer_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data); +static void evas_engine_buffer_image_free(void *data, void *image); +static void evas_engine_buffer_image_size_get(void *data, void *image, int *w, int *h); +static void *evas_engine_buffer_image_size_set(void *data, void *image, int w, int h); +static void *evas_engine_buffer_image_dirty_region(void *data, void *image, int x, int y, int w, int h); +static void *evas_engine_buffer_image_data_get(void *data, void *image, int to_write, DATA32 **image_data); +static void *evas_engine_buffer_image_data_put(void *data, void *image, DATA32 *image_data); +static void *evas_engine_buffer_image_alpha_set(void *data, void *image, int has_alpha); +static int evas_engine_buffer_image_alpha_get(void *data, void *image); +static void evas_engine_buffer_image_draw(void *data, void *context, void *surface, void *image, 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 smooth); +static char *evas_engine_buffer_image_comment_get(void *data, void *image, char *key); +static char *evas_engine_buffer_image_format_get(void *data, void *image); +static void evas_engine_buffer_image_cache_flush(void *data); +static void evas_engine_buffer_image_cache_set(void *data, int bytes); +static int evas_engine_buffer_image_cache_get(void *data); +static void *evas_engine_buffer_font_load(void *data, char *name, int size); +static void evas_engine_buffer_font_free(void *data, void *font); +static int evas_engine_buffer_font_ascent_get(void *data, void *font); +static int evas_engine_buffer_font_descent_get(void *data, void *font); +static int evas_engine_buffer_font_max_ascent_get(void *data, void *font); +static int evas_engine_buffer_font_max_descent_get(void *data, void *font); +static void evas_engine_buffer_font_string_size_get(void *data, void *font, char *text, int *w, int *h); +static int evas_engine_buffer_font_inset_get(void *data, void *font, char *text); +static int evas_engine_buffer_font_h_advance_get(void *data, void *font, char *text); +static int evas_engine_buffer_font_v_advance_get(void *data, void *font, char *text); +static int evas_engine_buffer_font_char_coords_get(void *data, void *font, char *text, int pos, int *cx, int *cy, int *cw, int *ch); +static int evas_engine_buffer_font_char_at_coords_get(void *data, void *font, char *text, int x, int y, int *cx, int *cy, int *cw, int *ch); +static void evas_engine_buffer_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, char *text); +static void evas_engine_buffer_font_cache_flush(void *data); +static void evas_engine_buffer_font_cache_set(void *data, int bytes); +static int evas_engine_buffer_font_cache_get(void *data); + +typedef struct _Render_Engine Render_Engine; + +struct _Render_Engine +{ + Tilebuf *tb; + Outbuf *ob; + Tilebuf_Rect *rects; + Evas_Object_List *cur_rect; + int end : 1; +}; + +Evas_Func evas_engine_buffer_func = +{ + evas_engine_buffer_info, + evas_engine_buffer_info_free, + evas_engine_buffer_setup, + evas_engine_buffer_output_free, + evas_engine_buffer_output_resize, + evas_engine_buffer_output_tile_size_set, + evas_engine_buffer_output_redraws_rect_add, + evas_engine_buffer_output_redraws_rect_del, + evas_engine_buffer_output_redraws_clear, + evas_engine_buffer_output_redraws_next_update_get, + evas_engine_buffer_output_redraws_next_update_push, + evas_engine_buffer_output_flush, + /* draw context virtual methods */ + evas_engine_buffer_context_new, + evas_engine_buffer_context_free, + evas_engine_buffer_context_clip_set, + evas_engine_buffer_context_clip_clip, + evas_engine_buffer_context_clip_unset, + evas_engine_buffer_context_clip_get, + evas_engine_buffer_context_color_set, + evas_engine_buffer_context_color_get, + evas_engine_buffer_context_multiplier_set, + evas_engine_buffer_context_multiplier_unset, + evas_engine_buffer_context_multiplier_get, + evas_engine_buffer_context_cutout_add, + evas_engine_buffer_context_cutout_clear, + /* rectangle draw funcs */ + evas_engine_buffer_draw_rectangle, + evas_engine_buffer_line_draw, + evas_engine_buffer_polygon_point_add, + evas_engine_buffer_polygon_points_clear, + evas_engine_buffer_polygon_draw, + evas_engine_buffer_gradient_color_add, + evas_engine_buffer_gradient_colors_clear, + evas_engine_buffer_gradient_draw, + /* image draw funcs */ + evas_engine_buffer_image_load, + evas_engine_buffer_image_new_from_data, + evas_engine_buffer_image_new_from_copied_data, + evas_engine_buffer_image_free, + evas_engine_buffer_image_size_get, + evas_engine_buffer_image_size_set, + evas_engine_buffer_image_dirty_region, + evas_engine_buffer_image_data_get, + evas_engine_buffer_image_data_put, + evas_engine_buffer_image_alpha_set, + evas_engine_buffer_image_alpha_get, + evas_engine_buffer_image_draw, + evas_engine_buffer_image_comment_get, + evas_engine_buffer_image_format_get, + /* image cache funcs */ + evas_engine_buffer_image_cache_flush, + evas_engine_buffer_image_cache_set, + evas_engine_buffer_image_cache_get, + /* font draw functions */ + evas_engine_buffer_font_load, + evas_engine_buffer_font_free, + evas_engine_buffer_font_ascent_get, + evas_engine_buffer_font_descent_get, + evas_engine_buffer_font_max_ascent_get, + evas_engine_buffer_font_max_descent_get, + evas_engine_buffer_font_string_size_get, + evas_engine_buffer_font_inset_get, + evas_engine_buffer_font_h_advance_get, + evas_engine_buffer_font_v_advance_get, + evas_engine_buffer_font_char_coords_get, + evas_engine_buffer_font_char_at_coords_get, + evas_engine_buffer_font_draw, + /* font cache functions */ + evas_engine_buffer_font_cache_flush, + evas_engine_buffer_font_cache_set, + evas_engine_buffer_font_cache_get +}; + +static void * +evas_engine_buffer_info(Evas *e) +{ + Evas_Engine_Info_Buffer *info; + + info = calloc(1, sizeof(Evas_Engine_Info_Buffer)); + if (!info) return NULL; + info->magic.magic = rand(); + return info; + e = NULL; +} + +static void +evas_engine_buffer_info_free(Evas *e, void *info) +{ + Evas_Engine_Info_Buffer *in; + + in = (Evas_Engine_Info_Buffer *)info; + free(in); +} + +static void +evas_engine_buffer_setup(Evas *e, void *in) +{ + Render_Engine *re; + Evas_Engine_Info_Buffer *info; + + info = (Evas_Engine_Info_Buffer *)in; + re = evas_engine_buffer_output_setup(e->output.w, + e->output.h, + info->info.dest_buffer, + info->info.dest_buffer_row_bytes, + info->info.depth_type, + info->info.use_color_key, + info->info.alpha_threshold, + info->info.color_key_r, + info->info.color_key_g, + info->info.color_key_b); + e->engine.data.output = re; + if (!e->engine.data.output) return; + e->engine.data.context = e->engine.func->context_new(e->engine.data.output); +} + +static void * +evas_engine_buffer_output_setup(int w, + int h, + void *dest_buffer, + int dest_buffer_row_bytes, + int depth_type, + int use_color_key, + int alpha_threshold, + int color_key_r, + int color_key_g, + int color_key_b + ) +{ + Render_Engine *re; + + re = calloc(1, sizeof(Render_Engine)); + /* if we haven't initialized - init (automatic abort if already done) */ + evas_common_cpu_init(); + + evas_common_blend_init(); + evas_common_image_init(); + evas_common_convert_init(); + evas_common_scale_init(); + evas_common_rectangle_init(); + evas_common_gradient_init(); + evas_common_polygon_init(); + evas_common_line_init(); + evas_common_font_init(); + evas_common_draw_init(); + evas_common_tilebuf_init(); + + evas_buffer_outbuf_buf_init(); + + /* get any stored performance metrics from device (xserver) */ + { + Outbuf_Depth dep; + DATA32 color_key; + + dep = OUTBUF_DEPTH_RGB_24BPP_888_888; + if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_RGBA32) + dep = OUTBUF_DEPTH_RGB_32BPP_888_8888; + else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_RGB24) + dep = OUTBUF_DEPTH_RGB_24BPP_888_888; + R_VAL(&color_key) = color_key_r; + G_VAL(&color_key) = color_key_g; + B_VAL(&color_key) = color_key_b; + A_VAL(&color_key) = 0; + re->ob = evas_buffer_outbuf_buf_setup_fb(w, + h, + dep, + dest_buffer, + dest_buffer_row_bytes, + use_color_key, + color_key, + alpha_threshold); + } + re->tb = evas_common_tilebuf_new(w, h); + /* in preliminary tests 16x16 gave highest framerates */ + evas_common_tilebuf_set_tile_size(re->tb, 16, 16); + return re; +} + +static void +evas_engine_buffer_output_free(void *data) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_buffer_outbuf_buf_free(re->ob); + evas_common_tilebuf_free(re->tb); + if (re->rects) evas_common_tilebuf_free_render_rects(re->rects); + free(re); +} + +static void +evas_engine_buffer_output_resize(void *data, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + { + int depth; + void *dest; + int dest_row_bytes; + int alpha_level; + DATA32 color_key; + char use_color_key; + + depth = re->ob->depth; + dest = re->ob->dest; + dest_row_bytes = re->ob->dest_row_bytes; + alpha_level = re->ob->alpha_level; + color_key = re->ob->color_key; + use_color_key = re->ob->use_color_key; + + evas_buffer_outbuf_buf_free(re->ob); + re->ob = evas_buffer_outbuf_buf_setup_fb(w, + h, + depth, + dest, + dest_row_bytes, + use_color_key, + color_key, + alpha_level); + } + evas_common_tilebuf_free(re->tb); + re->tb = evas_common_tilebuf_new(w, h); + if (re->tb) + evas_common_tilebuf_set_tile_size(re->tb, 16, 16); +} + +static void +evas_engine_buffer_output_tile_size_set(void *data, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_tilebuf_set_tile_size(re->tb, w, h); +} + +static void +evas_engine_buffer_output_redraws_rect_add(void *data, int x, int y, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_tilebuf_add_redraw(re->tb, x, y, w, h); +} + +static void +evas_engine_buffer_output_redraws_rect_del(void *data, int x, int y, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_tilebuf_del_redraw(re->tb, x, y, w, h); +} + +static void +evas_engine_buffer_output_redraws_clear(void *data) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_tilebuf_clear(re->tb); +} + +static void * +evas_engine_buffer_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch) +{ + Render_Engine *re; + RGBA_Image *surface; + Tilebuf_Rect *rect; + int ux, uy, uw, uh; + + re = (Render_Engine *)data; + if (re->end) + { + re->end = 0; + return NULL; + } + if (!re->rects) + { + re->rects = evas_common_tilebuf_get_render_rects(re->tb); + re->cur_rect = (Evas_Object_List *)re->rects; + } + if (!re->cur_rect) return NULL; + rect = (Tilebuf_Rect *)re->cur_rect; + ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h; + re->cur_rect = re->cur_rect->next; + if (!re->cur_rect) + { + evas_common_tilebuf_free_render_rects(re->rects); + re->rects = NULL; + re->end = 1; + } + + surface = evas_buffer_outbuf_buf_new_region_for_update(re->ob, + ux, uy, uw, uh, + cx, cy, cw, ch); + *x = ux; *y = uy; *w = uw; *h = uh; + return surface; +} + +static void +evas_engine_buffer_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_buffer_outbuf_buf_push_updated_region(re->ob, surface, x, y, w, h); + evas_buffer_outbuf_buf_free_region_for_update(re->ob, surface); + evas_common_cpu_end_opt(); +} + +static void +evas_engine_buffer_output_flush(void *data) +{ + Render_Engine *re; + + re = (Render_Engine *)data; +} + +static void * +evas_engine_buffer_context_new(void *data) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_draw_context_new(); +} + +static void +evas_engine_buffer_context_free(void *data, void *context) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_draw_context_free(context); +} + +static void +evas_engine_buffer_context_clip_set(void *data, void *context, int x, int y, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_draw_context_set_clip(context, x, y, w, h); +} + +static void +evas_engine_buffer_context_clip_clip(void *data, void *context, int x, int y, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_draw_context_clip_clip(context, x, y, w, h); +} + +static void +evas_engine_buffer_context_clip_unset(void *data, void *context) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_draw_context_unset_clip(context); +} + +static int +evas_engine_buffer_context_clip_get(void *data, void *context, int *x, int *y, int *w, int *h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + *x = ((RGBA_Draw_Context *)context)->clip.x; + *y = ((RGBA_Draw_Context *)context)->clip.y; + *w = ((RGBA_Draw_Context *)context)->clip.w; + *h = ((RGBA_Draw_Context *)context)->clip.h; + return ((RGBA_Draw_Context *)context)->clip.use; +} + +static void +evas_engine_buffer_context_color_set(void *data, void *context, int r, int g, int b, int a) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_draw_context_set_color(context, r, g, b, a); +} + +static int +evas_engine_buffer_context_color_get(void *data, void *context, int *r, int *g, int *b, int *a) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + *r = (int)(R_VAL(((RGBA_Draw_Context *)context)->col.col)); + *g = (int)(G_VAL(((RGBA_Draw_Context *)context)->col.col)); + *b = (int)(B_VAL(((RGBA_Draw_Context *)context)->col.col)); + *a = (int)(A_VAL(((RGBA_Draw_Context *)context)->col.col)); + return 1; +} + +static void +evas_engine_buffer_context_multiplier_set(void *data, void *context, int r, int g, int b, int a) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_draw_context_set_multiplier(context, r, g, b, a); +} + +static void +evas_engine_buffer_context_multiplier_unset(void *data, void *context) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_draw_context_unset_multiplier(context); +} + +static int +evas_engine_buffer_context_multiplier_get(void *data, void *context, int *r, int *g, int *b, int *a) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + *r = (int)(R_VAL(((RGBA_Draw_Context *)context)->mul.col)); + *g = (int)(G_VAL(((RGBA_Draw_Context *)context)->mul.col)); + *b = (int)(B_VAL(((RGBA_Draw_Context *)context)->mul.col)); + *a = (int)(A_VAL(((RGBA_Draw_Context *)context)->mul.col)); + return ((RGBA_Draw_Context *)context)->mul.use; +} + +static void +evas_engine_buffer_context_cutout_add(void *data, void *context, int x, int y, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_draw_context_add_cutout(context, x, y, w, h); +} + +static void +evas_engine_buffer_context_cutout_clear(void *data, void *context) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_draw_context_clear_cutouts(context); +} + +static void +evas_engine_buffer_draw_rectangle(void *data, void *context, void *surface, int x, int y, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_rectangle_draw(surface, context, x, y, w, h); + evas_common_cpu_end_opt(); +} + +static void +evas_engine_buffer_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_line_draw(surface, context, x1, y1, x2, y2); + evas_common_cpu_end_opt(); +} + +static void * +evas_engine_buffer_polygon_point_add(void *data, void *context, void *polygon, int x, int y) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_polygon_point_add(polygon, x, y); + context = 0; +} + +static void * +evas_engine_buffer_polygon_points_clear(void *data, void *context, void *polygon) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_polygon_points_clear(polygon); + context = 0; +} + +static void +evas_engine_buffer_polygon_draw(void *data, void *context, void *surface, void *polygon) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_polygon_draw(surface, context, polygon); + evas_common_cpu_end_opt(); +} + +static void * +evas_engine_buffer_gradient_color_add(void *data, void *context, void *gradient, int r, int g, int b, int a, int distance) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + if (!gradient) + gradient = evas_common_gradient_new(); + evas_common_gradient_color_add(gradient, r, g, b, a, distance); + return gradient; + context = 0; +} + +static void * +evas_engine_buffer_gradient_colors_clear(void *data, void *context, void *gradient) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + if (gradient) evas_common_gradient_free(gradient); + return NULL; + context = 0; +} + +static void +evas_engine_buffer_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h, double angle) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_gradient_draw(surface, context, x, y, w, h, gradient, angle); + evas_common_cpu_end_opt(); +} + +static void * +evas_engine_buffer_image_load(void *data, char *file, char *key, int *error) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + *error = 0; + return evas_common_load_image_from_file(file, key); +} + +static void * +evas_engine_buffer_image_new_from_data(void *data, int w, int h, DATA32 *image_data) +{ + Render_Engine *re; + RGBA_Image *im; + + re = (Render_Engine *)data; + im = evas_common_image_new(); + im->image = evas_common_image_surface_new(); + if (!im->image) + { + evas_common_image_free(im); + return NULL; + } + im->image->w = w; + im->image->h = h; + im->image->data = image_data; + im->image->no_free = 1; + return im; +} + +static void * +evas_engine_buffer_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data) +{ + Render_Engine *re; + RGBA_Image *im; + + re = (Render_Engine *)data; + im = evas_common_image_create(w, h); + if (!im) return NULL; + if (image_data) + memcpy(im->image->data, image_data, w * h * sizeof(DATA32)); + return im; +} + +static void +evas_engine_buffer_image_free(void *data, void *image) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_image_unref(image); +} + +static void +evas_engine_buffer_image_size_get(void *data, void *image, int *w, int *h) +{ + Render_Engine *re; + RGBA_Image *im; + + re = (Render_Engine *)data; + im = image; + if (w) *w = im->image->w; + if (h) *h = im->image->h; +} + +static void * +evas_engine_buffer_image_size_set(void *data, void *image, int w, int h) +{ + Render_Engine *re; + RGBA_Image *im, *im_old; + + re = (Render_Engine *)data; + im_old = image; + im = evas_common_image_create(w, h); + if (!im) return im_old; + if (im_old) + { + evas_common_load_image_data_from_file(im_old); + if (im_old->image->data) + { + evas_common_blit_rectangle(im_old, im, 0, 0, w, h, 0, 0); + evas_common_cpu_end_opt(); + } + evas_common_image_unref(im_old); + } + return im; +} + +static void * +evas_engine_buffer_image_dirty_region(void *data, void *image, int x, int y, int w, int h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_image_dirty(image); + return image; + x = 0; + y = 0; + w = 0; + h = 0; +} + +static void * +evas_engine_buffer_image_data_get(void *data, void *image, int to_write, DATA32 **image_data) +{ + Render_Engine *re; + RGBA_Image *im; + + re = (Render_Engine *)data; + im = image; + evas_common_load_image_data_from_file(im); + if (to_write) + { + if (im->references > 1) + { + RGBA_Image *im_new; + + im_new = evas_common_image_create(im->image->w, im->image->h); + if (!im_new) return im; + evas_common_blit_rectangle(im, im_new, 0, 0, im->image->w, im->image->h, 0, 0); + evas_common_cpu_end_opt(); + evas_common_image_unref(im); + im = im_new; + } + else + evas_common_image_dirty(im); + } + *image_data = im->image->data; + return im; +} + +static void * +evas_engine_buffer_image_data_put(void *data, void *image, DATA32 *image_data) +{ + Render_Engine *re; + RGBA_Image *im; + + re = (Render_Engine *)data; + im = image; + if (image_data != im->image->data) + { + int w, h; + + w = im->image->w; + h = im->image->h; + evas_common_image_unref(im); + return evas_engine_buffer_image_new_from_data(data, w, h, image_data); + } + evas_common_image_dirty(im); + return im; +} + +static void * +evas_engine_buffer_image_alpha_set(void *data, void *image, int has_alpha) +{ + Render_Engine *re; + RGBA_Image *im; + + re = (Render_Engine *)data; + im = image; + if (im->references > 1) + { + RGBA_Image *im_new; + + im_new = evas_common_image_create(im->image->w, im->image->h); + if (!im_new) return im; + evas_common_load_image_data_from_file(im); + evas_common_blit_rectangle(im, im_new, 0, 0, im->image->w, im->image->h, 0, 0); + evas_common_cpu_end_opt(); + evas_common_image_unref(im); + im = im_new; + } + else + evas_common_image_dirty(im); + if (has_alpha) + im->flags |= RGBA_IMAGE_HAS_ALPHA; + else + im->flags &= ~RGBA_IMAGE_HAS_ALPHA; + return im; +} + + +static int +evas_engine_buffer_image_alpha_get(void *data, void *image) +{ + Render_Engine *re; + RGBA_Image *im; + + re = (Render_Engine *)data; + im = image; + if (im->flags & RGBA_IMAGE_HAS_ALPHA) return 1; + return 0; +} + +static void +evas_engine_buffer_image_draw(void *data, void *context, void *surface, void *image, 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 smooth) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_load_image_data_from_file(image); + if (smooth) + evas_common_scale_rgba_in_to_out_clip_smooth(image, surface, context, + src_x, src_y, src_w, src_h, + dst_x, dst_y, dst_w, dst_h); + else + evas_common_scale_rgba_in_to_out_clip_sample(image, surface, context, + src_x, src_y, src_w, src_h, + dst_x, dst_y, dst_w, dst_h); + evas_common_cpu_end_opt(); +} + +static char * +evas_engine_buffer_image_comment_get(void *data, void *image, char *key) +{ + Render_Engine *re; + RGBA_Image *im; + + re = (Render_Engine *)data; + im = image; + return im->info.comment; + key = 0; +} + +static char * +evas_engine_buffer_image_format_get(void *data, void *image) +{ + Render_Engine *re; + RGBA_Image *im; + + re = (Render_Engine *)data; + im = image; + if (im->info.format == 1) return "png"; + return NULL; +} + +static void +evas_engine_buffer_image_cache_flush(void *data) +{ + Render_Engine *re; + int tmp_size; + + re = (Render_Engine *)data; + tmp_size = evas_common_image_get_cache(); + evas_common_image_set_cache(0); + evas_common_image_set_cache(tmp_size); +} + +static void +evas_engine_buffer_image_cache_set(void *data, int bytes) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_image_set_cache(bytes); +} + +static int +evas_engine_buffer_image_cache_get(void *data) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_image_get_cache(); +} + +static void * +evas_engine_buffer_font_load(void *data, char *name, int size) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_font_load(name, size); +} + +static void +evas_engine_buffer_font_free(void *data, void *font) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_font_free(font); +} + +static int +evas_engine_buffer_font_ascent_get(void *data, void *font) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_font_ascent_get(font); +} + +static int +evas_engine_buffer_font_descent_get(void *data, void *font) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_font_descent_get(font); +} + +static int +evas_engine_buffer_font_max_ascent_get(void *data, void *font) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_font_max_ascent_get(font); +} + +static int +evas_engine_buffer_font_max_descent_get(void *data, void *font) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_font_max_descent_get(font); +} + +static void +evas_engine_buffer_font_string_size_get(void *data, void *font, char *text, int *w, int *h) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_font_query_size(font, text, w, h); +} + +static int +evas_engine_buffer_font_inset_get(void *data, void *font, char *text) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_font_query_inset(font, text); +} + +static int +evas_engine_buffer_font_h_advance_get(void *data, void *font, char *text) +{ + Render_Engine *re; + int h, v; + + re = (Render_Engine *)data; + evas_common_font_query_advance(font, text, &h, &v); + return h; +} + +static int +evas_engine_buffer_font_v_advance_get(void *data, void *font, char *text) +{ + Render_Engine *re; + int h, v; + + re = (Render_Engine *)data; + evas_common_font_query_advance(font, text, &h, &v); + return v; +} + +static int +evas_engine_buffer_font_char_coords_get(void *data, void *font, char *text, int pos, int *cx, int *cy, int *cw, int *ch) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_font_query_char_coords(font, text, pos, cx, cy, cw, ch); +} + +static int +evas_engine_buffer_font_char_at_coords_get(void *data, void *font, char *text, int x, int y, int *cx, int *cy, int *cw, int *ch) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_font_query_text_at_pos(font, text, x, y, cx, cy, cw, ch); +} + +static void +evas_engine_buffer_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, char *text) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + if ((w == ow) && (h == oh)) + evas_common_font_draw(surface, context, font, x, y, text); + else + { + /* create output surface size ow x oh and scale to w x h */ + RGBA_Draw_Context *dc, *dc_in; + + dc_in = context; + dc = evas_common_draw_context_new(); + if (dc) + { + RGBA_Image *im; + + dc->col.col = dc_in->col.col; + im = evas_common_image_create(ow, oh); + if (im) + { + int max_ascent; + int i, j; + + im->flags |= RGBA_IMAGE_HAS_ALPHA; + j = ow * oh; + for (i = 0; i < j; i++) im->image->data[i] = (dc->col.col & 0xffffff); + + max_ascent = evas_common_font_max_ascent_get(font); + + evas_common_font_draw(im, dc, font, 0, max_ascent, text); + evas_common_cpu_end_opt(); + evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context, + 0, 0, ow, oh, + x, y - ((max_ascent * h) / oh), + w, h); + evas_common_image_free(im); + } + evas_common_draw_context_free(dc); + } + } + evas_common_cpu_end_opt(); +} + +static void +evas_engine_buffer_font_cache_flush(void *data) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_font_flush(); +} + +static void +evas_engine_buffer_font_cache_set(void *data, int bytes) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + evas_common_font_cache_set(bytes); +} + +static int +evas_engine_buffer_font_cache_get(void *data) +{ + Render_Engine *re; + + re = (Render_Engine *)data; + return evas_common_font_cache_get(); +} diff --git a/legacy/evas/src/lib/engines/buffer/evas_engine.h b/legacy/evas/src/lib/engines/buffer/evas_engine.h new file mode 100644 index 0000000000..00ad236dbf --- /dev/null +++ b/legacy/evas/src/lib/engines/buffer/evas_engine.h @@ -0,0 +1,41 @@ +#ifndef EVAS_ENGINE_H +#define EVAS_ENGINE_H + +typedef struct _Outbuf Outbuf; + +typedef enum _Outbuf_Depth Outbuf_Depth; + +enum _Outbuf_Depth +{ + OUTBUF_DEPTH_NONE, + OUTBUF_DEPTH_RGB_24BPP_888_888, + OUTBUF_DEPTH_RGB_32BPP_888_8888, + OUTBUF_DEPTH_LAST +}; + +struct _Outbuf +{ + int w, h; + Outbuf_Depth depth; + + void *dest; + int dest_row_bytes; + + int alpha_level; + DATA32 color_key; + char use_color_key : 1; +}; + +/****/ + +void evas_buffer_outbuf_buf_init (void); +void evas_buffer_outbuf_buf_free (Outbuf *buf); + +Outbuf *evas_buffer_outbuf_buf_setup_fb (int w, int h, Outbuf_Depth depth, void *dest, int dest_row_bytes, int use_color_key, DATA32 color_key, int alpha_level); + +RGBA_Image *evas_buffer_outbuf_buf_new_region_for_update (Outbuf *buf, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch); +void evas_buffer_outbuf_buf_free_region_for_update (Outbuf *buf, RGBA_Image *update); +void evas_buffer_outbuf_buf_push_updated_region (Outbuf *buf, RGBA_Image *update, int x, int y, int w, int h); + +#endif + diff --git a/legacy/evas/src/lib/engines/buffer/evas_outbuf.c b/legacy/evas/src/lib/engines/buffer/evas_outbuf.c new file mode 100644 index 0000000000..dad804b537 --- /dev/null +++ b/legacy/evas/src/lib/engines/buffer/evas_outbuf.c @@ -0,0 +1,125 @@ +#include "evas_common.h" +#include "evas_engine.h" +#include +#include + +void +evas_buffer_outbuf_buf_init(void) +{ +} + +void +evas_buffer_outbuf_buf_free(Outbuf *buf) +{ + free(buf); +} + +Outbuf * +evas_buffer_outbuf_buf_setup_fb(int w, int h, Outbuf_Depth depth, void *dest, int dest_row_bytes, int use_color_key, DATA32 color_key, int alpha_level) +{ + Outbuf *buf; + + buf = calloc(1, sizeof(Outbuf)); + if (!buf) return NULL; + + buf->w = w; + buf->h = h; + buf->depth = depth; + + buf->dest = dest; + buf->dest_row_bytes = dest_row_bytes; + + buf->alpha_level = alpha_level; + buf->color_key = color_key; + buf->use_color_key = use_color_key; + + return buf; +} + +RGBA_Image * +evas_buffer_outbuf_buf_new_region_for_update(Outbuf *buf, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch) +{ + RGBA_Image *im; + + *cx = 0; *cy = 0; *cw = w; *ch = h; + im = evas_common_image_create(w, h); + if (im) + { + im->flags |= RGBA_IMAGE_HAS_ALPHA; + memset(im->image->data, 0, w * h * sizeof(DATA32)); + } + return im; +} + +void +evas_buffer_outbuf_buf_free_region_for_update(Outbuf *buf, RGBA_Image *update) +{ + evas_common_image_free(update); +} + +void +evas_buffer_outbuf_buf_push_updated_region(Outbuf *buf, RGBA_Image *update, int x, int y, int w, int h) +{ + /* copy update image to out buf & convert */ + switch (buf->depth) + { + case OUTBUF_DEPTH_RGB_24BPP_888_888: + /* copy & pack into 24bpp - if colorkey is enabled... etc. */ + { + DATA8 thresh; + int xx, yy; + DATA32 colorkey; + DATA32 *src; + DATA8 *dst; + + colorkey = buf->color_key; + thresh = buf->alpha_level; + if (buf->use_color_key) + { + for (yy = 0; yy < h; yy++) + { + dst = buf->dest + ((y + yy) * buf->dest_row_bytes); + src = update->image->data + (yy * update->image->w); + for (xx = 0; xx < w; xx++) + { + if (A_VAL(src) > thresh) + { + *dst++ = R_VAL(src); + *dst++ = G_VAL(src); + *dst++ = B_VAL(src); + } + else + { + *dst++ = R_VAL(&colorkey); + *dst++ = G_VAL(&colorkey); + *dst++ = B_VAL(&colorkey); + } + src++; + } + } + } + else + { + for (yy = 0; yy < h; yy++) + { + dst = buf->dest + ((y + yy) * buf->dest_row_bytes); + src = update->image->data + (yy * update->image->w); + for (xx = 0; xx < w; xx++) + { + *dst++ = R_VAL(src); + *dst++ = G_VAL(src); + *dst++ = B_VAL(src); + src++; + } + } + } + } + break; + case OUTBUF_DEPTH_RGB_32BPP_888_8888: + /* simple memcpy */ + /* FIXME: write this */ + break; + default: + break; + } +} diff --git a/legacy/evas/src/lib/include/Makefile.am b/legacy/evas/src/lib/include/Makefile.am index 31c2da79d1..953f9eb95d 100644 --- a/legacy/evas/src/lib/include/Makefile.am +++ b/legacy/evas/src/lib/include/Makefile.am @@ -5,6 +5,7 @@ evas_common.h \ evas_engine_api_software_x11.h \ evas_engine_api_directfb.h \ evas_engine_api_fb.h \ +evas_engine_api_buffer.h \ evas_engine_api_software_qtopia.h \ evas_engine_api_gl_x11.h \ evas_mmx.h \ diff --git a/legacy/evas/src/lib/include/evas_engine_api_buffer.h b/legacy/evas/src/lib/include/evas_engine_api_buffer.h new file mode 100644 index 0000000000..cf0fa793fb --- /dev/null +++ b/legacy/evas/src/lib/include/evas_engine_api_buffer.h @@ -0,0 +1,6 @@ +#ifndef EVAS_ENGINE_BUFFER_H +#define EVAS_ENGINE_BUFFER_H + +extern Evas_Func evas_engine_buffer_func; + +#endif diff --git a/legacy/evas/src/lib/include/evas_private.h b/legacy/evas/src/lib/include/evas_private.h index b965b44f52..3f7075e328 100644 --- a/legacy/evas/src/lib/include/evas_private.h +++ b/legacy/evas/src/lib/include/evas_private.h @@ -10,9 +10,10 @@ #define RENDER_METHOD_SOFTWARE_X11 0x00000001 #define RENDER_METHOD_DIRECTFB 0x00000002 #define RENDER_METHOD_FB 0x00000003 -#define RENDER_METHOD_SOFTWARE_WIN32_GDI 0x00000004 -#define RENDER_METHOD_SOFTWARE_QTOPIA 0x00000005 -#define RENDER_METHOD_GL_X11 0x00000006 +#define RENDER_METHOD_BUFFER 0x00000004 +#define RENDER_METHOD_SOFTWARE_WIN32_GDI 0x00000005 +#define RENDER_METHOD_SOFTWARE_QTOPIA 0x00000006 +#define RENDER_METHOD_GL_X11 0x00000007 #define RENDER_METHOD_INVALID 0x00000000