ecore_evas supprot for buffers... and bingo... image objects in another
authorCarsten Haitzler <raster@rasterman.com>
Sat, 8 Jan 2005 18:40:32 +0000 (18:40 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Sat, 8 Jan 2005 18:40:32 +0000 (18:40 +0000)
evas.. so u can put an evas in an evas.. and get its pixel data or just
render to raw ARGB memory too :)

SVN revision: 12834

legacy/ecore/configure.in
legacy/ecore/src/bin/ecore_evas_test_app.c
legacy/ecore/src/bin/ecore_evas_test_calibrate.c
legacy/ecore/src/lib/ecore_evas/Ecore_Evas.h
legacy/ecore/src/lib/ecore_evas/Makefile.am
legacy/ecore/src/lib/ecore_evas/ecore_evas.c
legacy/ecore/src/lib/ecore_evas/ecore_evas_buffer.c [new file with mode: 0644]
legacy/ecore/src/lib/ecore_evas/ecore_evas_fb.c
legacy/ecore/src/lib/ecore_evas/ecore_evas_private.h
legacy/ecore/src/lib/ecore_evas/ecore_evas_x.c

index a10d81f..e4ec51d 100644 (file)
@@ -509,6 +509,48 @@ fi
 
 AC_SUBST(BUILD_ECORE_EVAS_FB)
 
+have_ecore_evas_buffer="no";
+
+AC_MSG_CHECKING(whether ecore_evas buffer support is to be built)
+
+AC_ARG_ENABLE(ecore-evas-buffer, 
+[  --disable-ecore-evas-buffer          disable buffer in the ecore_evas module], [
+  if [ test "$enableval" = "yes" ]; then  
+    AC_MSG_RESULT(yes)
+    have_ecore_evas_buffer="yes"
+  else
+    AC_MSG_RESULT(no)
+  fi
+], [
+  AC_MSG_RESULT(yes)
+  have_ecore_evas_buffer="yes"
+]
+)
+
+if test "x$have_ecore_evas_buffer" = "xyes"; then
+  AC_CHECK_HEADER(Evas_Engine_Buffer.h,
+    [
+      AM_CONDITIONAL(BUILD_ECORE_EVAS_BUFFER, true)
+      AC_DEFINE(BUILD_ECORE_EVAS_BUFFER, 1, [Support for Buffers in Ecore_Evas])
+    ], [
+      AM_CONDITIONAL(BUILD_ECORE_EVAS_BUFFER, false)
+      have_ecore_evas_buffer="no"
+    ], [
+      #include <Evas.h>
+    ]
+  )
+else
+  AM_CONDITIONAL(BUILD_ECORE_EVAS_BUFFER, false)
+fi
+
+if test "x$have_ecore_evas_buffer" = "xyes"; then
+       BUILD_ECORE_EVAS_BUFFER=1
+else
+       BUILD_ECORE_EVAS_BUFFER=0
+fi
+
+AC_SUBST(BUILD_ECORE_EVAS_BUFFER)
+
 AC_MSG_CHECKING(whether ecore_con module is to be built)
 
 have_ecore_con="no";
@@ -725,6 +767,7 @@ echo "  Ecore_FB................: $have_ecore_fb"
 echo "  Ecore_Evas..............: $have_ecore_evas"
 echo "  Ecore_Evas GL Support...: $have_ecore_evas_gl"
 echo "  Ecore_Evas FB Support...: $have_ecore_evas_fb"
+echo "  Ecore_Buffer............: $have_ecore_evas_buffer"
 echo "  Ecore_Ipc...............: $have_ecore_ipc (OpenSSL: $use_openssl)"
 echo "  Ecore_Config............: $have_ecore_config"
 echo
index d1113ab..e0fe19c 100644 (file)
@@ -6,10 +6,50 @@ double       start_time = 0.0;
 Ecore_Evas  *ee         = NULL;
 Evas        *evas       = NULL;
 
+Ecore_Idle_Enterer *getpix_handler = NULL;
+
 static void app_resize(Ecore_Evas *ee);
 static int app_signal_exit(void *data, int ev_type, void *ev);
 static void app_delete_request(Ecore_Evas *ee);
 
+static int
+getpix_cb(void *data)
+{
+   int *pix, p;
+   int w, h;
+   FILE *f;
+   int x, y;
+   static int count = 0;
+   char buf[256];
+   unsigned char *line;
+   
+   pix = ecore_evas_buffer_pixels_get(ee);
+   ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
+   snprintf(buf, sizeof(buf), "out%04i.ppm", count);
+   count++;
+   f = fopen(buf, "wb");
+   if (f)
+     {
+       line = malloc(w * 4);
+       fprintf(f, "P6\n%i %i\n255\n", w, h);
+       for (y = 0; y < h; y++)
+         {
+            for (x = 0; x < w; x++)
+              {
+                 p = pix[(y * w) + x];
+                 line[(x * 3) + 0] = ((p >> 16) & 0xff);
+                 line[(x * 3) + 1] = ((p >> 8 ) & 0xff);
+                 line[(x * 3) + 2] = ((p      ) & 0xff);
+/*               line[(x * 3) + 3] = ((p >> 24) & 0xff);*/
+              }
+            fwrite(line, w * 3, 1, f);
+         }
+       free(line);
+       fclose(f);
+     }
+   return 1;
+}
+
 int
 app_start(int argc, const char **argv)
 {
@@ -22,39 +62,80 @@ app_start(int argc, const char **argv)
    /* create an evas */
    if (!ecore_evas_init()) return -1;
    if ((argc > 1) && (!strcmp(argv[1], "-fb")))
-     ee = ecore_evas_fb_new(NULL, 0,  240, 320);
+     {
+       ee = ecore_evas_fb_new(NULL, 0,  240, 320);
+       evas = ecore_evas_get(ee);
+     }
    else if ((argc > 1) && (!strcmp(argv[1], "-x")))
-     ee = ecore_evas_software_x11_new(NULL, 0,  0, 0, 240, 320);
+     {
+       ee = ecore_evas_software_x11_new(NULL, 0,  0, 0, 240, 320);
+       evas = ecore_evas_get(ee);
+     }
 #if HAVE_ECORE_EVAS_GL
    else if ((argc > 1) && (!strcmp(argv[1], "-gl")))
-     ee = ecore_evas_gl_x11_new(NULL, 0,  0, 0, 240, 320);
+     {
+       ee = ecore_evas_gl_x11_new(NULL, 0,  0, 0, 240, 320);
+       evas = ecore_evas_get(ee);
+     }
 #endif
+   else if ((argc > 1) && (!strcmp(argv[1], "-buf")))
+     {
+       ee = ecore_evas_buffer_new(240, 320);
+       evas = ecore_evas_get(ee);
+       getpix_handler = ecore_idle_enterer_add(getpix_cb, NULL);
+     }
+   else if ((argc > 1) && (!strcmp(argv[1], "-buf2")))
+     {
+       Evas_Object *o;
+       
+       ee = ecore_evas_software_x11_new(NULL, 0,  0, 0, 240, 320);
+       
+       o = evas_object_rectangle_add(ecore_evas_get(ee));
+       evas_object_move(o, 0, 0);
+       evas_object_resize(o, 240, 320);
+       evas_object_color_set(o, 150, 200, 250, 255);
+       evas_object_show(o);
+       
+       o = ecore_evas_object_image_new(ee);
+       evas = ecore_evas_get(evas_object_data_get(o, "Ecore_Evas"));
+       evas_object_move(o, 50, 50);
+       evas_object_resize(o, 120, 160);
+       evas_object_image_fill_set(o, 0, 0, 120, 160);
+       evas_object_image_size_set(o, 240, 320);
+       ecore_evas_resize(evas_object_data_get(o, "Ecore_Evas"), 240, 320);
+       evas_object_color_set(o, 255, 255, 255, 200);
+       evas_object_show(o);
+     }
    else if ((argc > 1) && (!strcmp(argv[1], "-h")))
      {
        printf("%s -x         Test ecore_evas in X (default)\n"
               "%s -gl        Test ecore_evas in X GL\n"
               "%s -fb        Test ecore_evas in the Framebuffer\n"
+              "%s -buf       Test ecore_evas in the Buffer\n"
+              "%s -buf2      Test ecore_evas in the Image Buffer\n"
               "%s -h         Display this help\n",
-              argv[0], argv[0], argv[0], argv[0]);
+              argv[0], argv[0], argv[0], argv[0], argv[0], argv[0]);
        ecore_evas_shutdown();
        ecore_shutdown();
        return 0;
      }
    else
 #ifdef BUILD_ECORE_X
-     ee = ecore_evas_software_x11_new(NULL, 0,  0, 0, 240, 320);        
+     {
+       ee = ecore_evas_software_x11_new(NULL, 0,  0, 0, 240, 320);      
 #else
 #ifdef BUILD_ECORE_FB
-     ee = ecore_evas_fb_new(NULL, 270,  240, 320);
-#endif   
+       ee = ecore_evas_fb_new(NULL, 270,  240, 320);
+#endif
 #endif   
+       evas = ecore_evas_get(ee);
+     }
    if (!ee) return -1;
    ecore_evas_callback_delete_request_set(ee, app_delete_request);
    ecore_evas_callback_resize_set(ee, app_resize);
    ecore_evas_title_set(ee, "Ecore Evas Test");
    ecore_evas_name_class_set(ee, "ecore_test", "test_evas");   
    ecore_evas_show(ee);
-   evas = ecore_evas_get(ee);
    evas_image_cache_set(evas, 8192 * 1024);
    evas_font_cache_set(evas, 512 * 1024);
    evas_font_path_append(evas, FN);
index 817df54..22b2424 100644 (file)
@@ -28,14 +28,14 @@ static void calibrate_cb_move(void *data, Evas *e, Evas_Object *obj, void *event
 void
 calibrate_pos_set(int pos)
 {
-   Evas_Coord w, h;
-   int x, y, ow, oh;
+   Evas_Coord w, h, ow, oh;
+   int x, y;
    
    cal_pos = pos;
    evas_object_geometry_get(o_crosshair, NULL, NULL, &w, &h);
    x = cal_coords[(cal_pos * 2) + 0];
    y = cal_coords[(cal_pos * 2) + 1];
-   evas_output_size_get(evas, &ow, &oh);
+   evas_output_viewport_get(evas, NULL, NULL, &ow, &oh);
    if (x < 0) x = ow + x - 1;
    if (y < 0) y = oh + y - 1;
    cal_coords[(cal_pos * 2) + 0] = x;
@@ -165,6 +165,7 @@ calibrate_cb_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
    
    ev = event_info;
    
+   evas_object_move(o_crosshair, ev->output.x - 15, ev->output.y - 15);
    tmp_input_count = 0;   
    tmp_input[((tmp_input_count & 0x7) * 2) + 0] = ev->output.x;
    tmp_input[((tmp_input_count & 0x7) * 2) + 1] = ev->output.y;
index 6f24d42..65dc99d 100644 (file)
@@ -52,7 +52,8 @@ typedef enum
 {
    ECORE_EVAS_ENGINE_SOFTWARE_X11,
    ECORE_EVAS_ENGINE_SOFTWARE_FB,
-   ECORE_EVAS_ENGINE_GL_X11
+   ECORE_EVAS_ENGINE_GL_X11,
+   ECORE_EVAS_ENGINE_SOFTWARE_BUFFER
 } Ecore_Evas_Engine_Type;
 
 #ifndef _ECORE_X_H
@@ -87,6 +88,11 @@ EAPI int             ecore_evas_gl_x11_direct_resize_get(Ecore_Evas *ee);
 
 EAPI Ecore_Evas     *ecore_evas_fb_new(char *disp_name, int rotation, int w, int h);
 
+EAPI Ecore_Evas     *ecore_evas_buffer_new(int w, int h);
+EAPI int            *ecore_evas_buffer_pixels_get(Ecore_Evas *ee);
+       
+EAPI Evas_Object    *ecore_evas_object_image_new(Ecore_Evas *ee_target);
+
 /* generic manipulation calls */
 EAPI void        ecore_evas_free(Ecore_Evas *ee);
 EAPI void       *ecore_evas_data_get(Ecore_Evas *ee, const char *key);
index e29f0a3..f7a8e05 100644 (file)
@@ -43,8 +43,9 @@ Ecore_Evas.h
 libecore_evas_la_SOURCES = \
 ecore_evas.c \
 ecore_evas_private.h \
+ecore_evas_x.c \
 ecore_evas_fb.c \
-ecore_evas_x.c
+ecore_evas_buffer.c
 
 libecore_evas_la_LIBADD = \
 $(ECORE_X_LIB) \
@@ -61,7 +62,8 @@ endif
 
 EXTRA_DIST = \
 ecore_evas.c \
+ecore_evas_private.h \
 ecore_evas_x.c \
 ecore_evas_fb.c \
-ecore_evas_private.h
+ecore_evas_buffer.c
 
index b543bf9..b6e57cd 100644 (file)
@@ -40,6 +40,13 @@ ecore_evas_engine_type_supported_get(Ecore_Evas_Engine_Type engine)
        return 0;
 #endif 
        break;
+      case ECORE_EVAS_ENGINE_SOFTWARE_BUFFER:
+#ifdef BUILD_ECORE_EVAS_BUFFER
+       return 1;
+#else
+       return 0;
+#endif 
+       break;
       default:
        return 0;
        break;
@@ -79,6 +86,9 @@ ecore_evas_shutdown(void)
 #ifdef BUILD_ECORE_EVAS_FB
        while (_ecore_evas_fb_shutdown());
 #endif
+#ifdef BUILD_ECORE_EVAS_BUFFER
+       while (_ecore_evas_buffer_shutdown());
+#endif
        evas_shutdown(); 
      }
    if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
@@ -101,6 +111,10 @@ ecore_evas_free(Ecore_Evas *ee)
        return;
      }
    ECORE_MAGIC_SET(ee, ECORE_MAGIC_NONE);
+   while (ee->sub_ecore_evas)
+     {
+       ecore_evas_free(ee->sub_ecore_evas->data);
+     }
    if (ee->data) evas_hash_free(ee->data);
    if (ee->driver) free(ee->driver);
    if (ee->name) free(ee->name);
diff --git a/legacy/ecore/src/lib/ecore_evas/ecore_evas_buffer.c b/legacy/ecore/src/lib/ecore_evas/ecore_evas_buffer.c
new file mode 100644 (file)
index 0000000..2ab0001
--- /dev/null
@@ -0,0 +1,630 @@
+#include "config.h"
+#include "Ecore.h"
+#include "ecore_private.h"
+#include "ecore_evas_private.h"
+#include "Ecore_Evas.h"
+
+#ifdef BUILD_ECORE_EVAS_BUFFER
+static int _ecore_evas_init_count = 0;
+
+static int _ecore_evas_fps_debug = 0;
+
+static Ecore_Evas *ecore_evases = NULL;
+
+static void
+_ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y)
+{
+   ee->mouse.x = x;
+   ee->mouse.y = y;
+   evas_event_feed_mouse_move(ee->evas, x, y, NULL);
+}
+
+static int
+_ecore_evas_buffer_init(void)
+{
+   _ecore_evas_init_count++;
+   if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
+   if (getenv("ECORE_EVAS_FPS_DEBUG")) _ecore_evas_fps_debug = 1;
+   if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_init();
+   return _ecore_evas_init_count;
+}
+
+static void
+_ecore_evas_buffer_free(Ecore_Evas *ee)
+{
+   ecore_evases = _ecore_list_remove(ecore_evases, ee);   
+   _ecore_evas_buffer_shutdown();
+   if (ee->engine.buffer.image)
+     {
+       Ecore_Evas *ee2;
+       
+       ee2 = evas_object_data_get(ee->engine.buffer.image, "Ecore_Evas_Parent");
+       evas_object_del(ee->engine.buffer.image);
+       ee2->sub_ecore_evas = evas_list_remove(ee2->sub_ecore_evas, ee);
+     }
+   else
+     free(ee->engine.buffer.pixels);
+}
+
+static void
+_ecore_evas_resize(Ecore_Evas *ee, int w, int h)
+{
+   Evas_Engine_Info_Buffer *einfo;
+   
+   if (w < 1) w = 1;
+   if (h < 1) h = 1;
+   if ((w == ee->w) && (h == ee->h)) return;
+   ee->w = w;
+   ee->h = h;
+   evas_output_size_set(ee->evas, ee->w, ee->h);
+   evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
+   evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
+
+   if (ee->engine.buffer.image)
+     {
+       ee->engine.buffer.pixels = evas_object_image_data_get(ee->engine.buffer.image, 1);
+     }
+   else
+     {
+       if (ee->engine.buffer.pixels) free(ee->engine.buffer.pixels);
+       ee->engine.buffer.pixels = malloc(ee->w * ee->h * sizeof(int));
+     }
+   
+   einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
+   if (einfo)
+     {
+       einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
+       einfo->info.dest_buffer = ee->engine.buffer.pixels;
+       einfo->info.dest_buffer_row_bytes = ee->w * sizeof(int);
+       einfo->info.use_color_key = 0;
+       einfo->info.alpha_threshold = 0;
+       einfo->info.func.new_update_region = NULL;
+       einfo->info.func.free_update_region = NULL;
+       evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
+     }
+   if (ee->func.fn_resize) ee->func.fn_resize(ee);     
+}
+    
+int
+_ecore_evas_buffer_shutdown(void)
+{
+   _ecore_evas_init_count--;
+   if (_ecore_evas_init_count == 0)
+     {
+       while (ecore_evases)
+         ecore_evas_free((Ecore_Evas *)(ecore_evases->data));
+       if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_shutdown();
+     }
+   if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
+   return _ecore_evas_init_count;
+}
+
+void
+_ecore_evas_buffer_render(Ecore_Evas *ee)
+{
+   Evas_List *updates, *l, *ll;
+
+   for (ll = ee->sub_ecore_evas; ll; ll = ll->next)
+     {
+       Ecore_Evas *ee2;
+       
+       ee2 = ll->data;
+       if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
+       _ecore_evas_buffer_render(ee2);
+       if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
+     }
+   if (ee->engine.buffer.image)
+     {
+       int w, h;
+       
+       evas_object_image_size_get(ee->engine.buffer.image, &w, &h);
+       if ((w != ee->w) || (h != ee->h))
+         _ecore_evas_resize(ee, w, h);
+     }
+   updates = evas_render_updates(ee->evas);
+   if (ee->engine.buffer.image)
+     {
+       for (l = updates; l; l = l->next)
+         {  
+            Evas_Rectangle *r;
+            
+            r = l->data;
+            if (ee->engine.buffer.image)
+              evas_object_image_data_update_add(ee->engine.buffer.image,
+                                                r->x, r->y, r->w, r->h);
+         }
+     }
+   if (updates) evas_render_updates_free(updates);
+}
+
+static void
+_ecore_evas_buffer_coord_translate(Ecore_Evas *ee, Evas_Coord *x, Evas_Coord *y)
+{
+   Evas_Coord xx, yy, fx, fy, fw, fh;
+   
+   evas_object_geometry_get(ee->engine.buffer.image, &xx, &yy, NULL, NULL);
+   evas_object_image_fill_get(ee->engine.buffer.image, &fx, &fy, &fw, &fh);
+   
+   if (fw < 1) fw = 1;
+   xx = (*x - xx) - fx;
+   while (xx < 0) xx += fw;
+   while (xx > fw) xx -= fw;
+   *x = (ee->w * xx) / fw;
+   
+   if (fh < 1) fh = 1;
+   yy = (*y - yy) - fy;
+   while (yy < 0) yy += fh;
+   while (yy > fh) yy -= fh;
+   *y = (ee->h * yy) / fh;
+}
+
+static void
+_ecore_evas_buffer_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee;
+   
+   ee = data;
+   evas_event_feed_mouse_in(ee->evas, NULL);
+}
+
+static void
+_ecore_evas_buffer_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee;
+   
+   ee = data;
+   evas_event_feed_mouse_out(ee->evas, NULL);
+}
+
+static void
+_ecore_evas_buffer_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee; 
+   Evas_Event_Mouse_Down *ev;
+  
+   ee = data;
+   ev = event_info;
+   evas_event_feed_mouse_down(ee->evas, ev->button, ev->flags, NULL);
+}
+
+static void
+_ecore_evas_buffer_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee;
+   Evas_Event_Mouse_Up *ev;
+   
+   ee = data;
+   ev = event_info;
+   evas_event_feed_mouse_up(ee->evas, ev->button, ev->flags, NULL);
+}
+
+static void
+_ecore_evas_buffer_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee;
+   Evas_Event_Mouse_Move *ev;
+   Evas_Coord x, y;
+   
+   ee = data;
+   ev = event_info;
+   x = ev->cur.canvas.x;
+   y = ev->cur.canvas.y;
+   _ecore_evas_buffer_coord_translate(ee, &x, &y);
+   _ecore_evas_mouse_move_process(ee, x, y);
+}
+
+static void
+_ecore_evas_buffer_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee;
+   Evas_Event_Mouse_Wheel *ev;
+   
+   ee = data;
+   ev = event_info;
+   evas_event_feed_mouse_wheel(ee->evas, ev->direction, ev->z, NULL);
+}
+
+static void
+_ecore_evas_buffer_cb_free(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee;
+   
+   ee = data;
+   if (ee->driver)
+     ecore_evas_free(ee);
+}
+
+static void
+_ecore_evas_buffer_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee;
+   Evas_Event_Key_Down *ev;
+   
+   ee = data;
+   ev = event_info;
+   if (evas_key_modifier_is_set_get(evas_key_modifier_get(e), "Shift"))
+     evas_key_modifier_on(e, "Shift");
+   else
+     evas_key_modifier_off(e, "Shift");
+   if (evas_key_modifier_is_set_get(evas_key_modifier_get(e), "Control"))
+     evas_key_modifier_on(e, "Control");
+   else
+     evas_key_modifier_off(e, "Control");
+   if (evas_key_modifier_is_set_get(evas_key_modifier_get(e), "Alt"))
+     evas_key_modifier_on(e, "Alt");
+   else
+     evas_key_modifier_off(e, "Alt");
+   if (evas_key_modifier_is_set_get(evas_key_modifier_get(e), "Meta"))
+     evas_key_modifier_on(e, "Meta");
+   else
+     evas_key_modifier_off(e, "Meta");
+   if (evas_key_modifier_is_set_get(evas_key_modifier_get(e), "Hyper"))
+     evas_key_modifier_on(e, "Hyper");
+   else
+     evas_key_modifier_off(e, "Hyper");
+   if (evas_key_modifier_is_set_get(evas_key_modifier_get(e), "Super"))
+     evas_key_modifier_on(e, "Super");
+   else
+     evas_key_modifier_off(e, "Super");
+   if (evas_key_lock_is_set_get(evas_key_lock_get(e), "Scroll_Lock"))
+     evas_key_lock_on(e, "Scroll_Lock");
+   else
+     evas_key_lock_off(e, "Scroll_Lock");
+   if (evas_key_lock_is_set_get(evas_key_lock_get(e), "Num_Lock"))
+     evas_key_lock_on(e, "Num_Lock");
+   else
+     evas_key_lock_off(e, "Num_Lock");
+   if (evas_key_lock_is_set_get(evas_key_lock_get(e), "Caps_Lock"))
+     evas_key_lock_on(e, "Caps_Lock");
+   else
+     evas_key_lock_off(e, "Caps_Lock");
+   evas_event_feed_key_down(ee->evas, ev->keyname, ev->key, ev->string, ev->compose, NULL);
+}
+
+static void
+_ecore_evas_buffer_cb_key_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee;
+   Evas_Event_Key_Up *ev;
+   
+   ee = data;
+   ev = event_info;
+   if (evas_key_modifier_is_set_get(evas_key_modifier_get(e), "Shift"))
+     evas_key_modifier_on(e, "Shift");
+   else
+     evas_key_modifier_off(e, "Shift");
+   if (evas_key_modifier_is_set_get(evas_key_modifier_get(e), "Control"))
+     evas_key_modifier_on(e, "Control");
+   else
+     evas_key_modifier_off(e, "Control");
+   if (evas_key_modifier_is_set_get(evas_key_modifier_get(e), "Alt"))
+     evas_key_modifier_on(e, "Alt");
+   else
+     evas_key_modifier_off(e, "Alt");
+   if (evas_key_modifier_is_set_get(evas_key_modifier_get(e), "Meta"))
+     evas_key_modifier_on(e, "Meta");
+   else
+     evas_key_modifier_off(e, "Meta");
+   if (evas_key_modifier_is_set_get(evas_key_modifier_get(e), "Hyper"))
+     evas_key_modifier_on(e, "Hyper");
+   else
+     evas_key_modifier_off(e, "Hyper");
+   if (evas_key_modifier_is_set_get(evas_key_modifier_get(e), "Super"))
+     evas_key_modifier_on(e, "Super");
+   else
+     evas_key_modifier_off(e, "Super");
+   if (evas_key_lock_is_set_get(evas_key_lock_get(e), "Scroll_Lock"))
+     evas_key_lock_on(e, "Scroll_Lock");
+   else
+     evas_key_lock_off(e, "Scroll_Lock");
+   if (evas_key_lock_is_set_get(evas_key_lock_get(e), "Num_Lock"))
+     evas_key_lock_on(e, "Num_Lock");
+   else
+     evas_key_lock_off(e, "Num_Lock");
+   if (evas_key_lock_is_set_get(evas_key_lock_get(e), "Caps_Lock"))
+     evas_key_lock_on(e, "Caps_Lock");
+   else
+     evas_key_lock_off(e, "Caps_Lock");
+   evas_event_feed_key_up(ee->evas, ev->keyname, ev->key, ev->string, ev->compose, NULL);
+}
+
+static void
+_ecore_evas_buffer_cb_focus_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee;
+   
+   ee = data;
+   ee->prop.focused = 1;
+   if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
+}
+
+static void
+_ecore_evas_buffer_cb_focus_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee;
+   
+   ee = data;
+   ee->prop.focused = 0;
+   if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee);
+}
+
+static void
+_ecore_evas_buffer_cb_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee;
+   
+   ee = data;
+   ee->visible = 1;
+   if (ee->func.fn_show) ee->func.fn_show(ee);
+}
+
+static void
+_ecore_evas_buffer_cb_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+   Ecore_Evas *ee;
+   
+   ee = data;
+   ee->visible = 0;
+   if (ee->func.fn_hide) ee->func.fn_hide(ee);
+}
+
+static const Ecore_Evas_Engine_Func _ecore_buffer_engine_func =
+{
+   _ecore_evas_buffer_free,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     _ecore_evas_resize,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL,
+     NULL
+};
+#endif
+
+/**
+ * To be documented.
+ *
+ * FIXME: To be fixed.
+ */
+Ecore_Evas *
+ecore_evas_buffer_new(int w, int h)
+{
+#ifdef BUILD_ECORE_EVAS_BUFFER
+   Evas_Engine_Info_Buffer *einfo;
+   Ecore_Evas *ee;
+   int rmethod;
+
+   rmethod = evas_render_method_lookup("buffer");
+   if (!rmethod) return NULL;
+   ee = calloc(1, sizeof(Ecore_Evas));
+   if (!ee) return NULL;
+
+   ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
+   
+   _ecore_evas_buffer_init();
+   
+   ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_buffer_engine_func;
+   
+   ee->driver = strdup("buffer");
+
+   if (w < 1) w = 1;
+   if (h < 1) h = 1;
+   ee->rotation = 0;
+   ee->visible = 1;
+   ee->w = w;
+   ee->h = h;
+
+   ee->prop.max.w = 0;
+   ee->prop.max.h = 0;
+   ee->prop.layer = 0;
+   ee->prop.focused = 1;
+   ee->prop.borderless = 1;
+   ee->prop.override = 1;
+   ee->prop.maximized = 1;
+   ee->prop.fullscreen = 0;
+   ee->prop.withdrawn = 0;
+   ee->prop.sticky = 0;
+   
+   /* init evas here */
+   ee->evas = evas_new();
+   evas_output_method_set(ee->evas, rmethod);
+   evas_output_size_set(ee->evas, w, h);
+   evas_output_viewport_set(ee->evas, 0, 0, w, h);
+   
+   ee->engine.buffer.pixels = malloc(w * h * sizeof(int));
+   
+   einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
+   if (einfo)
+     {
+       einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
+       einfo->info.dest_buffer = ee->engine.buffer.pixels;
+       einfo->info.dest_buffer_row_bytes = ee->w * sizeof(int);
+       einfo->info.use_color_key = 0;
+       einfo->info.alpha_threshold = 0;
+       einfo->info.func.new_update_region = NULL;
+       einfo->info.func.free_update_region = NULL;
+       evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
+     }
+   evas_key_modifier_add(ee->evas, "Shift");
+   evas_key_modifier_add(ee->evas, "Control");
+   evas_key_modifier_add(ee->evas, "Alt");
+   evas_key_modifier_add(ee->evas, "Meta");
+   evas_key_modifier_add(ee->evas, "Hyper");
+   evas_key_modifier_add(ee->evas, "Super");
+   evas_key_lock_add(ee->evas, "Caps_Lock");
+   evas_key_lock_add(ee->evas, "Num_Lock");
+   evas_key_lock_add(ee->evas, "Scroll_Lock");
+   
+   evas_event_feed_mouse_in(ee->evas, NULL);
+
+   ecore_evases = _ecore_list_prepend(ecore_evases, ee);
+   return ee;
+#else
+   return NULL;
+#endif   
+}
+
+int *
+ecore_evas_buffer_pixels_get(Ecore_Evas *ee)
+{
+#ifdef BUILD_ECORE_EVAS_BUFFER
+   _ecore_evas_buffer_render(ee);
+   return ee->engine.buffer.pixels;
+#else
+   return NULL;
+#endif   
+}
+
+Evas_Object *
+ecore_evas_object_image_new(Ecore_Evas *ee_target)
+{
+#ifdef BUILD_ECORE_EVAS_BUFFER
+   Evas_Object *o;
+   Evas_Engine_Info_Buffer *einfo;
+   Ecore_Evas *ee;
+   int rmethod;
+   int w, h;
+
+   rmethod = evas_render_method_lookup("buffer");
+   if (!rmethod) return NULL;
+   ee = calloc(1, sizeof(Ecore_Evas));
+   if (!ee) return NULL;
+
+   o = evas_object_image_add(ee_target->evas);
+   
+   ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
+   
+   _ecore_evas_buffer_init();
+   
+   ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_buffer_engine_func;
+   
+   ee->driver = strdup("buffer");
+
+   w = 1;
+   h = 1;
+   ee->rotation = 0;
+   ee->visible = 0;
+   ee->w = w;
+   ee->h = h;
+
+   ee->prop.max.w = 0;
+   ee->prop.max.h = 0;
+   ee->prop.layer = 0;
+   ee->prop.focused = 0;
+   ee->prop.borderless = 1;
+   ee->prop.override = 1;
+   ee->prop.maximized = 0;
+   ee->prop.fullscreen = 0;
+   ee->prop.withdrawn = 0;
+   ee->prop.sticky = 0;
+   
+   /* init evas here */
+   ee->evas = evas_new();
+   evas_output_method_set(ee->evas, rmethod);
+   evas_output_size_set(ee->evas, w, h);
+   evas_output_viewport_set(ee->evas, 0, 0, w, h);
+   
+   ee->engine.buffer.image = o;
+   evas_object_data_set(ee->engine.buffer.image, "Ecore_Evas", ee);
+   evas_object_data_set(ee->engine.buffer.image, "Ecore_Evas_Parent", ee_target);
+   evas_object_image_size_set(o, ee->w, ee->h);
+   evas_object_image_alpha_set(o, 1);
+   ee->engine.buffer.pixels = evas_object_image_data_get(o, 1);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_MOUSE_IN,
+                                 _ecore_evas_buffer_cb_mouse_in, ee);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_MOUSE_OUT,
+                                 _ecore_evas_buffer_cb_mouse_out, ee);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_MOUSE_DOWN,
+                                 _ecore_evas_buffer_cb_mouse_down, ee);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_MOUSE_UP,
+                                 _ecore_evas_buffer_cb_mouse_up, ee);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_MOUSE_MOVE,
+                                 _ecore_evas_buffer_cb_mouse_move, ee);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_MOUSE_WHEEL,
+                                 _ecore_evas_buffer_cb_mouse_wheel, ee);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_FREE,
+                                 _ecore_evas_buffer_cb_free, ee);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_KEY_DOWN,
+                                 _ecore_evas_buffer_cb_key_down, ee);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_KEY_UP,
+                                 _ecore_evas_buffer_cb_key_up, ee);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_FOCUS_IN,
+                                 _ecore_evas_buffer_cb_focus_in, ee);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_FOCUS_OUT,
+                                 _ecore_evas_buffer_cb_focus_out, ee);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_SHOW,
+                                 _ecore_evas_buffer_cb_show, ee);
+   evas_object_event_callback_add(ee->engine.buffer.image,
+                                 EVAS_CALLBACK_HIDE,
+                                 _ecore_evas_buffer_cb_hide, ee);
+   einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
+   if (einfo)
+     {
+       einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
+       einfo->info.dest_buffer = ee->engine.buffer.pixels;
+       einfo->info.dest_buffer_row_bytes = ee->w * sizeof(int);
+       einfo->info.use_color_key = 0;
+       einfo->info.alpha_threshold = 0;
+       einfo->info.func.new_update_region = NULL;
+       einfo->info.func.free_update_region = NULL;
+       evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
+     }
+   evas_key_modifier_add(ee->evas, "Shift");
+   evas_key_modifier_add(ee->evas, "Control");
+   evas_key_modifier_add(ee->evas, "Alt");
+   evas_key_modifier_add(ee->evas, "Meta");
+   evas_key_modifier_add(ee->evas, "Hyper");
+   evas_key_modifier_add(ee->evas, "Super");
+   evas_key_lock_add(ee->evas, "Caps_Lock");
+   evas_key_lock_add(ee->evas, "Num_Lock");
+   evas_key_lock_add(ee->evas, "Scroll_Lock");
+   
+   ee_target->sub_ecore_evas = evas_list_append(ee_target->sub_ecore_evas, ee);
+   return o;
+#else
+   return NULL;
+#endif   
+}
index d641441..d2c6e88 100644 (file)
@@ -186,7 +186,22 @@ _ecore_evas_idle_enter(void *data)
        ee = (Ecore_Evas *)l;
        if (ee->visible)
          {
+#ifdef BUILD_ECORE_EVAS_BUFFER
+            Evas_List *ll;
+#endif
+            
             if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
+#ifdef BUILD_ECORE_EVAS_BUFFER
+            for (ll = ee->sub_ecore_evas; ll; ll = ll->next)
+              {
+                 Ecore_Evas *ee2;
+                 
+                 ee2 = ll->data;
+                 if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
+                 _ecore_evas_buffer_render(ee2);
+                 if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
+              }
+#endif      
             evas_render(ee->evas);
             if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
          }
@@ -481,8 +496,8 @@ ecore_evas_fb_new(char *disp_name, int rotation, int w, int h)
    ee->w = w;
    ee->h = h;
 
-   ee->prop.max.w = 240;
-   ee->prop.max.h = 320;
+   ee->prop.max.w = 0;
+   ee->prop.max.h = 0;
    ee->prop.layer = 0;
    ee->prop.focused = 1;
    ee->prop.borderless = 1;
index 1eae253..ae49bb4 100644 (file)
@@ -25,6 +25,9 @@
 #ifdef BUILD_ECORE_EVAS_FB
 #include <Evas_Engine_FB.h>
 #endif
+#ifdef BUILD_ECORE_EVAS_BUFFER
+#include <Evas_Engine_Buffer.h>
+#endif
 
 typedef struct _Ecore_Evas             Ecore_Evas;
 typedef struct _Ecore_Evas_Engine      Ecore_Evas_Engine;
@@ -94,6 +97,12 @@ struct _Ecore_Evas_Engine
       int real_h;
    } fb;
 #endif
+#ifdef BUILD_ECORE_EVAS_BUFFER
+   struct {
+      void *pixels;
+      Evas_Object *image;
+   } buffer;
+#endif
 };
   
 struct _Ecore_Evas
@@ -165,6 +174,7 @@ struct _Ecore_Evas
    } func;
    
    Ecore_Evas_Engine engine;
+   Evas_List *sub_ecore_evas;
 };
 
 #ifdef BUILD_ECORE_X
@@ -173,6 +183,10 @@ int _ecore_evas_x_shutdown(void);
 #ifdef BUILD_ECORE_EVAS_FB
 int _ecore_evas_fb_shutdown(void);
 #endif
+#ifdef BUILD_ECORE_EVAS_BUFFER
+int _ecore_evas_buffer_shutdown(void);
+void _ecore_evas_buffer_render(Ecore_Evas *ee);
+#endif
 
 void _ecore_evas_fps_debug_init(void);
 void _ecore_evas_fps_debug_shutdown(void);
index 173a30f..1bf3243 100644 (file)
@@ -451,9 +451,23 @@ _ecore_evas_idle_enter(void *data)
    for (l = (Ecore_Oldlist *)ecore_evases; l; l = l->next)
      {
        Ecore_Evas *ee;
+#ifdef BUILD_ECORE_EVAS_BUFFER
+       Evas_List *ll;
+#endif
        
        ee = (Ecore_Evas *)l;
        if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
+#ifdef BUILD_ECORE_EVAS_BUFFER
+       for (ll = ee->sub_ecore_evas; ll; ll = ll->next)
+         {
+            Ecore_Evas *ee2;
+            
+            ee2 = ll->data;
+            if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
+            _ecore_evas_buffer_render(ee2);
+            if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
+         }
+#endif 
        if (ee->prop.avoid_damage)
          {
             Evas_List *updates, *l;