From 7ddb73b1777ca6284a0e8a3ab82b16849f27dfcd Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 8 Mar 2016 14:11:07 +0900 Subject: [PATCH] Evas: Move 3d to Efl.Canvas.Scene3d This still seems a bit redondant with the underlying Evas.Canvas3d.Scene class. --- src/Makefile_Evas.am | 5 +- src/examples/evas/evas-3d-aabb.c | 4 +- src/examples/evas/evas-3d-blending.c | 4 +- src/examples/evas/evas-3d-colorpick.c | 4 +- src/examples/evas/evas-3d-cube-rotate.c | 4 +- src/examples/evas/evas-3d-cube.c | 4 +- src/examples/evas/evas-3d-cube2.c | 4 +- src/examples/evas/evas-3d-eet.c | 4 +- src/examples/evas/evas-3d-fog.c | 4 +- src/examples/evas/evas-3d-frustum.c | 4 +- src/examples/evas/evas-3d-hull.c | 4 +- src/examples/evas/evas-3d-md2.c | 4 +- src/examples/evas/evas-3d-mmap-set.c | 4 +- src/examples/evas/evas-3d-obj.c | 4 +- .../evas/evas-3d-parallax-occlusion.c | 4 +- src/examples/evas/evas-3d-pick.c | 4 +- src/examples/evas/evas-3d-ply.c | 4 +- src/examples/evas/evas-3d-proxy.c | 15 +- src/examples/evas/evas-3d-shadows.c | 4 +- src/examples/evas/shooter/evas-3d-shooter.c | 4 +- src/lib/evas/Evas_Eo.h | 1 + src/lib/evas/canvas/efl_canvas_proxy.c | 6 +- src/lib/evas/canvas/efl_canvas_scene3d.c | 204 +++++++++++++ src/lib/evas/canvas/efl_canvas_scene3d.eo | 19 ++ src/lib/evas/canvas/evas_image.eo | 25 -- src/lib/evas/canvas/evas_image_private.h | 23 +- src/lib/evas/canvas/evas_object_image.c | 270 ++---------------- 27 files changed, 325 insertions(+), 315 deletions(-) create mode 100644 src/lib/evas/canvas/efl_canvas_scene3d.c create mode 100644 src/lib/evas/canvas/efl_canvas_scene3d.eo diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index e6aa6cf6e1..28c670de0d 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -43,6 +43,7 @@ evas_eolian_pub_files = \ lib/evas/canvas/efl_vg_gradient_linear.eo \ lib/evas/canvas/efl_canvas_snapshot.eo \ lib/evas/canvas/efl_canvas_proxy.eo \ + lib/evas/canvas/efl_canvas_scene3d.eo \ lib/evas/canvas/evas_filter.eo \ $(NULL) @@ -176,7 +177,9 @@ lib/evas/canvas/evas_map.c \ lib/evas/canvas/evas_gl.c \ lib/evas/canvas/evas_out.c \ lib/evas/canvas/efl_canvas_proxy.c \ -lib/evas/canvas/efl_canvas_snapshot.c +lib/evas/canvas/efl_canvas_snapshot.c \ +lib/evas/canvas/efl_canvas_scene3d.c \ +$(NULL) EXTRA_DIST += \ lib/evas/canvas/render2/evas_render2_th_main.c \ diff --git a/src/examples/evas/evas-3d-aabb.c b/src/examples/evas/evas-3d-aabb.c index d02668bed0..a5ef7b1e8d 100644 --- a/src/examples/evas/evas-3d-aabb.c +++ b/src/examples/evas/evas-3d-aabb.c @@ -220,11 +220,11 @@ main(void) efl_gfx_size_set(background, WIDTH, HEIGHT); efl_gfx_visible_set(background, EINA_TRUE); - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); evas_object_focus_set(image, EINA_TRUE); - evas_obj_image_scene_set(image, scene); + efl_canvas_scene3d_set(image, scene); evas_object_event_callback_add(image, EVAS_CALLBACK_KEY_DOWN, _on_key_down, mesh_node); diff --git a/src/examples/evas/evas-3d-blending.c b/src/examples/evas/evas-3d-blending.c index db7c7a1590..862d08de93 100644 --- a/src/examples/evas/evas-3d-blending.c +++ b/src/examples/evas/evas-3d-blending.c @@ -283,14 +283,14 @@ main(void) evas_object_show(background); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); evas_object_move(image, 0, 0); evas_object_resize(image, WIDTH, HEIGHT); evas_object_show(image); evas_object_focus_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, data.scene); + efl_canvas_scene3d_set(image, data.scene); /* Add animation timer callback. */ diff --git a/src/examples/evas/evas-3d-colorpick.c b/src/examples/evas/evas-3d-colorpick.c index 885a53bd81..d90e3f54b1 100644 --- a/src/examples/evas/evas-3d-colorpick.c +++ b/src/examples/evas/evas-3d-colorpick.c @@ -381,12 +381,12 @@ int main(int argc, char **argv) globalscene.precision = precision; globalscene.scene_init(texture); - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); evas_object_focus_set(image, EINA_TRUE); - evas_obj_image_scene_set(image, globalscene.scene); + efl_canvas_scene3d_set(image, globalscene.scene); r = evas_object_key_grab(image, "Down", 0, 0, EINA_TRUE); r = evas_object_key_grab(image, "Up", 0, 0, EINA_TRUE); diff --git a/src/examples/evas/evas-3d-cube-rotate.c b/src/examples/evas/evas-3d-cube-rotate.c index e393c14deb..29448d817e 100644 --- a/src/examples/evas/evas-3d-cube-rotate.c +++ b/src/examples/evas/evas-3d-cube-rotate.c @@ -255,14 +255,14 @@ main(void) evas_object_show(background); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); evas_object_image_size_set(image, WIDTH, HEIGHT); evas_object_move(image, 0, 0); evas_object_resize(image, WIDTH, HEIGHT); evas_object_show(image); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, scene); + efl_canvas_scene3d_set(image, scene); evas_object_focus_set(image, EINA_TRUE); diff --git a/src/examples/evas/evas-3d-cube.c b/src/examples/evas/evas-3d-cube.c index 6f6f4208c2..9f0707fbcb 100644 --- a/src/examples/evas/evas-3d-cube.c +++ b/src/examples/evas/evas-3d-cube.c @@ -239,12 +239,12 @@ main(void) efl_gfx_visible_set(background, EINA_TRUE); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, data.scene); + efl_canvas_scene3d_set(image, data.scene); /* Add animation timer callback. */ ecore_timer_add(0.016, _animate_scene, &data); diff --git a/src/examples/evas/evas-3d-cube2.c b/src/examples/evas/evas-3d-cube2.c index e46c2f7c64..baa77c0d60 100644 --- a/src/examples/evas/evas-3d-cube2.c +++ b/src/examples/evas/evas-3d-cube2.c @@ -240,12 +240,12 @@ main(void) efl_gfx_visible_set(background, EINA_TRUE); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, data.scene); + efl_canvas_scene3d_set(image, data.scene); /* Add animation timer callback. */ ecore_timer_add(0.01, _animate_scene, &data); diff --git a/src/examples/evas/evas-3d-eet.c b/src/examples/evas/evas-3d-eet.c index dc09191e05..5785a0b57b 100644 --- a/src/examples/evas/evas-3d-eet.c +++ b/src/examples/evas/evas-3d-eet.c @@ -192,12 +192,12 @@ main(void) efl_gfx_visible_set(background, EINA_TRUE); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, scene); + efl_canvas_scene3d_set(image, scene); ecore_timer_add(0.01, _animate_md2, mesh_node); ecore_timer_add(0.01, _animate_eet, mesh_node2); diff --git a/src/examples/evas/evas-3d-fog.c b/src/examples/evas/evas-3d-fog.c index 33bd05cc8c..4518dc6b89 100644 --- a/src/examples/evas/evas-3d-fog.c +++ b/src/examples/evas/evas-3d-fog.c @@ -215,13 +215,13 @@ main(void) efl_gfx_visible_set(background, EINA_TRUE); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, data.scene); + efl_canvas_scene3d_set(image, data.scene); /* Add animation timer callback. */ ecore_animator_frametime_set(0.008); diff --git a/src/examples/evas/evas-3d-frustum.c b/src/examples/evas/evas-3d-frustum.c index 4e1323f5b4..b0d1733bcc 100644 --- a/src/examples/evas/evas-3d-frustum.c +++ b/src/examples/evas/evas-3d-frustum.c @@ -425,13 +425,13 @@ main(void) evas_object_resize(background, WIDTH, HEIGHT); evas_object_show(background); - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); evas_object_move(image, 0, 0); evas_object_resize(image, WIDTH, HEIGHT); evas_object_show(image); evas_object_focus_set(image, EINA_TRUE); - evas_obj_image_scene_set(image, data.scene); + efl_canvas_scene3d_set(image, data.scene); _redraw_bounding_object(&data); _show_help(); diff --git a/src/examples/evas/evas-3d-hull.c b/src/examples/evas/evas-3d-hull.c index 57602b6988..f65ad13962 100644 --- a/src/examples/evas/evas-3d-hull.c +++ b/src/examples/evas/evas-3d-hull.c @@ -435,7 +435,7 @@ main(void) efl_gfx_visible_set(background, EINA_TRUE); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); @@ -443,7 +443,7 @@ main(void) evas_object_focus_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, data.scene); + efl_canvas_scene3d_set(image, data.scene); evas_object_event_callback_add(image, EVAS_CALLBACK_KEY_DOWN, _key_down, &data); diff --git a/src/examples/evas/evas-3d-md2.c b/src/examples/evas/evas-3d-md2.c index e19dfd6630..b3ea48e3e9 100644 --- a/src/examples/evas/evas-3d-md2.c +++ b/src/examples/evas/evas-3d-md2.c @@ -158,12 +158,12 @@ main(void) efl_gfx_visible_set(background, EINA_TRUE); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, scene); + efl_canvas_scene3d_set(image, scene); ecore_timer_add(0.01, _animate_scene, mesh_node); diff --git a/src/examples/evas/evas-3d-mmap-set.c b/src/examples/evas/evas-3d-mmap-set.c index 000204d2e8..ec48336492 100644 --- a/src/examples/evas/evas-3d-mmap-set.c +++ b/src/examples/evas/evas-3d-mmap-set.c @@ -239,12 +239,12 @@ main(void) efl_gfx_visible_set(background, EINA_TRUE); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, scene); + efl_canvas_scene3d_set(image, scene); /* Enter main loop. */ ecore_main_loop_begin(); diff --git a/src/examples/evas/evas-3d-obj.c b/src/examples/evas/evas-3d-obj.c index b9a6b69bd1..e3a94fc365 100644 --- a/src/examples/evas/evas-3d-obj.c +++ b/src/examples/evas/evas-3d-obj.c @@ -218,12 +218,12 @@ main(void) efl_gfx_visible_set(background, EINA_TRUE); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, scene); + efl_canvas_scene3d_set(image, scene); for (i = 0; i < NUMBER_OF_MESHES; i++) ecore_timer_add(ANIM_SPEED, _animate_scene, mesh_node[i]); diff --git a/src/examples/evas/evas-3d-parallax-occlusion.c b/src/examples/evas/evas-3d-parallax-occlusion.c index 67be66536d..0d770b7c31 100644 --- a/src/examples/evas/evas-3d-parallax-occlusion.c +++ b/src/examples/evas/evas-3d-parallax-occlusion.c @@ -243,13 +243,13 @@ main(void) efl_gfx_visible_set(background, EINA_TRUE); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); evas_object_focus_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, data.scene); + efl_canvas_scene3d_set(image, data.scene); /* Add animation timer callback. */ ecore_timer_add(0.01, _animate_scene, &data); diff --git a/src/examples/evas/evas-3d-pick.c b/src/examples/evas/evas-3d-pick.c index 1ae79a8cc9..a328b712ed 100644 --- a/src/examples/evas/evas-3d-pick.c +++ b/src/examples/evas/evas-3d-pick.c @@ -187,8 +187,8 @@ main(void) efl_gfx_size_set(background, WIDTH, HEIGHT); efl_gfx_visible_set(background, EINA_TRUE); - image = evas_object_image_filled_add(evas); - evas_obj_image_scene_set(image, scene); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); + efl_canvas_scene3d_set(image, scene); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); evas_object_event_callback_add(image, EVAS_CALLBACK_MOUSE_DOWN, diff --git a/src/examples/evas/evas-3d-ply.c b/src/examples/evas/evas-3d-ply.c index b34b2cc313..acde5654ef 100644 --- a/src/examples/evas/evas-3d-ply.c +++ b/src/examples/evas/evas-3d-ply.c @@ -214,12 +214,12 @@ main(void) efl_gfx_visible_set(background, EINA_TRUE); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, scene); + efl_canvas_scene3d_set(image, scene); ecore_animator_frametime_set(0.03); for (i = 0; i < NUMBER_OF_MESHES; i++) diff --git a/src/examples/evas/evas-3d-proxy.c b/src/examples/evas/evas-3d-proxy.c index 901c52bd54..246d8c3cf8 100644 --- a/src/examples/evas/evas-3d-proxy.c +++ b/src/examples/evas/evas-3d-proxy.c @@ -75,8 +75,9 @@ _animate_scene(void *data) /* Rotate */ if (angle > 360.0) angle -= 360.0f; - pixels = evas_obj_image_data_get(source, EINA_TRUE); - stride = evas_obj_image_stride_get(source); + //pixels = efl_gfx_buffer_get(source, EINA_TRUE, NULL, NULL, NULL, &stride, NULL, NULL, NULL, NULL, NULL, NULL); + pixels = evas_object_image_data_get(source, EINA_TRUE); + stride = evas_object_image_stride_get(source); for (i = 0; i < IMG_HEIGHT; i++) { @@ -88,8 +89,10 @@ _animate_scene(void *data) } } - evas_obj_image_data_set(source, pixels); - evas_obj_image_data_update_add(source, 0, 0, IMG_WIDTH, IMG_HEIGHT); + //efl_gfx_buffer_set(source, pixels, 0, 0, stride, 0, 0, 0, 0, 0, 0); + //evas_obj_image_data_update_add(source, 0, 0, IMG_WIDTH, IMG_HEIGHT); + evas_object_image_data_set(source, pixels); + evas_object_image_data_update_add(source, 0, 0, IMG_WIDTH, IMG_HEIGHT); return EINA_TRUE; } @@ -212,7 +215,7 @@ main(void) efl_gfx_visible_set(source, EINA_TRUE); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, (WIDTH / 2), (HEIGHT / 2)); efl_gfx_visible_set(image, EINA_TRUE); @@ -220,7 +223,7 @@ main(void) _scene_setup(&data); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, data.scene); + efl_canvas_scene3d_set(image, data.scene); /* Add animation timer callback. */ ecore_timer_add(0.016, _animate_scene, &data); diff --git a/src/examples/evas/evas-3d-shadows.c b/src/examples/evas/evas-3d-shadows.c index f70d7e41a8..c9aefbd133 100644 --- a/src/examples/evas/evas-3d-shadows.c +++ b/src/examples/evas/evas-3d-shadows.c @@ -616,13 +616,13 @@ main(void) efl_gfx_visible_set(background, EINA_TRUE); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); efl_gfx_size_set(image, WIDTH, HEIGHT); efl_gfx_visible_set(image, EINA_TRUE); evas_object_focus_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, data.scene); + efl_canvas_scene3d_set(image, data.scene); nodes1 = eina_list_append(nodes1, data.sphere.node); nodes2 = eina_list_append(nodes2, data.sphere.node); diff --git a/src/examples/evas/shooter/evas-3d-shooter.c b/src/examples/evas/shooter/evas-3d-shooter.c index 2e83fd8e6d..9fcb47a2fd 100644 --- a/src/examples/evas/shooter/evas-3d-shooter.c +++ b/src/examples/evas/shooter/evas-3d-shooter.c @@ -1145,13 +1145,13 @@ main(int argc, char *argv[]) _scene_setup(&data); /* Add an image object for 3D scene rendering. */ - image = evas_object_image_filled_add(evas); + image = eo_add(EFL_CANVAS_SCENE3D_CLASS, evas); evas_object_move(image, 0, 0); evas_object_resize(image, WIDTH, HEIGHT); evas_object_show(image); /* Set the image object as render target for 3D scene. */ - evas_obj_image_scene_set(image, global_scene); + efl_canvas_scene3d_set(image, global_scene); evas_object_focus_set(image, EINA_TRUE); diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index d23d65434f..718c984c85 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -344,6 +344,7 @@ typedef void (Evas_Canvas3D_Surface_Func)(Evas_Real *out_x, #include "canvas/efl_canvas_snapshot.eo.h" #include "canvas/efl_canvas_proxy.eo.h" +#include "canvas/efl_canvas_scene3d.eo.h" /** * @ingroup Evas_Object_VG diff --git a/src/lib/evas/canvas/efl_canvas_proxy.c b/src/lib/evas/canvas/efl_canvas_proxy.c index 5c8ac4bf0d..add2b6a597 100644 --- a/src/lib/evas/canvas/efl_canvas_proxy.c +++ b/src/lib/evas/canvas/efl_canvas_proxy.c @@ -46,13 +46,13 @@ _efl_canvas_proxy_source_set(Eo *eo_obj, void *pd EINA_UNUSED, Evas_Object *eo_s } if (o->cur->source == eo_src) return EINA_TRUE; evas_object_async_block(obj); - _evas_object_image_cleanup(eo_obj, obj, o); + _evas_image_cleanup(eo_obj, obj, o); /* Kill the image if any */ if (o->cur->u.file || o->cur->key) evas_object_image_file_set(eo_obj, NULL, NULL); - if (eo_src) _proxy_set(eo_obj, eo_src); - else _proxy_unset(eo_obj, obj, o); + if (eo_src) _evas_image_proxy_set(eo_obj, eo_src); + else _evas_image_proxy_unset(eo_obj, obj, o); return EINA_TRUE; } diff --git a/src/lib/evas/canvas/efl_canvas_scene3d.c b/src/lib/evas/canvas/efl_canvas_scene3d.c new file mode 100644 index 0000000000..0a86c4770f --- /dev/null +++ b/src/lib/evas/canvas/efl_canvas_scene3d.c @@ -0,0 +1,204 @@ +#include "evas_image_private.h" +#include "efl_canvas_scene3d.eo.h" + +#define MY_CLASS EFL_CANVAS_SCENE3D_CLASS + +EOLIAN static void +_efl_canvas_scene3d_scene3d_set(Eo *eo_obj, void *pd EINA_UNUSED, Evas_Canvas3D_Scene *scene) +{ + Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); + Evas_Image_Data *o = eo_data_scope_get(eo_obj, EVAS_IMAGE_CLASS); + Evas_Image_Load_Opts lo; + + if (o->cur->scene == scene) return; + + evas_object_async_block(obj); + _evas_image_init_set(NULL, NULL, NULL, eo_obj, obj, o, &lo); + o->engine_data = ENFN->image_load(ENDT, o->cur->u.file, o->cur->key, &o->load_error, &lo); + _evas_image_done_set(eo_obj, obj, o); + + if (scene) _evas_image_3d_set(eo_obj, scene); + else _evas_image_3d_unset(eo_obj, obj, o); +} + +EOLIAN static Evas_Canvas3D_Scene * +_efl_canvas_scene3d_scene3d_get(Eo *eo_obj, void *pd EINA_UNUSED) +{ + Evas_Image_Data *o = eo_data_scope_get(eo_obj, EVAS_IMAGE_CLASS); + return o->cur->scene; +} + +void +_evas_image_3d_render(Evas *eo_e, Evas_Object *eo_obj EINA_UNUSED, + Evas_Object_Protected_Data *obj, Evas_Image_Data *o EINA_UNUSED, + Evas_Canvas3D_Scene *scene) +{ + Evas_Public_Data *e; + Eina_Bool need_native_set = EINA_FALSE; + Evas_Canvas3D_Scene_Public_Data scene_data; + Evas_Canvas3D_Scene_Data *pd_scene = NULL; + + pd_scene = eo_data_scope_get(scene, EVAS_CANVAS3D_SCENE_CLASS); + + if ((pd_scene->w == 0) || (pd_scene->h == 0)) return; + if (!pd_scene->camera_node) + { + WRN("Camera has not been set to scene(%p)", scene); + return; + } + + e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS); + + if (pd_scene->surface) + { + int w = 0; + int h = 0; + + if (e->engine.func->drawable_size_get) + { + e->engine.func->drawable_size_get(e->engine.data.output, + pd_scene->surface, &w, &h); + } + if ((w != pd_scene->w) || (h != pd_scene->h)) + { + if (e->engine.func->drawable_free) + { + e->engine.func->drawable_free(e->engine.data.output, + pd_scene->surface); + } + pd_scene->surface = NULL; + need_native_set = EINA_TRUE; + } + } + else + { + /* TODO: Hard-coded alpha on. */ + if (e->engine.func->drawable_new) + { + pd_scene->surface = + e->engine.func->drawable_new(e->engine.data.output, + pd_scene->w, pd_scene->h, 1); + } + need_native_set = EINA_TRUE; + } + + EINA_COW_WRITE_BEGIN(evas_object_3d_cow, obj->data_3d, Evas_Object_3D_Data, + data) + { + if (need_native_set) + { + if (e->engine.func->image_drawable_set) + { + data->surface = + e->engine.func->image_drawable_set(e->engine.data.output, + data->surface, + pd_scene->surface); + } + } + data->w = pd_scene->w; + data->h = pd_scene->h; + } + EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data); + + evas_canvas3d_scene_data_init(&scene_data); + + scene_data.bg_color = pd_scene->bg_color; + scene_data.shadows_enabled = pd_scene->shadows_enabled; + scene_data.camera_node = pd_scene->camera_node; + scene_data.depth_offset = pd_scene->depth_offset; + scene_data.depth_constant = pd_scene->depth_constant; + + /* Phase 1 - Update scene graph tree. */ + evas_canvas3d_object_update(scene); + + /* Phase 2 - Do frustum culling and get visible model nodes. */ + evas_canvas3d_node_tree_traverse(pd_scene->root_node, + EVAS_CANVAS3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE, + evas_canvas3d_node_mesh_collect, &scene_data); + + /* Phase 3 - Collect active light nodes in the scene graph tree. */ + evas_canvas3d_node_tree_traverse(pd_scene->root_node, + EVAS_CANVAS3D_TREE_TRAVERSE_ANY_ORDER, EINA_FALSE, + evas_canvas3d_node_light_collect, &scene_data); + + /* Phase 5 - Draw the scene. */ + if (e->engine.func->drawable_scene_render) + { + e->engine.func->drawable_scene_render(e->engine.data.output, + pd_scene->surface, &scene_data); + } + /* Clean up temporary resources. */ + evas_canvas3d_scene_data_fini(&scene_data); +} + +void +_evas_image_3d_set(Evas_Object *eo_obj, Evas_Canvas3D_Scene *scene) +{ + Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); + Evas_Image_Data *o = eo_data_scope_get(eo_obj, EVAS_IMAGE_CLASS); + Evas_Canvas3D_Scene_Data *pd_scene = eo_data_scope_get(scene, + EVAS_CANVAS3D_SCENE_CLASS); + EINA_COW_WRITE_BEGIN(evas_object_3d_cow, obj->data_3d, Evas_Object_3D_Data, + data) + { + data->surface = NULL; + data->w = 0; + data->h = 0; + eo_ref(scene); + } + EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data); + + EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write) + { + state_write->scene = scene; + } + EINA_COW_IMAGE_STATE_WRITE_END(o, state_write); + + pd_scene->images = eina_list_append(pd_scene->images, eo_obj); +} + +void +_evas_image_3d_unset(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, + Evas_Image_Data *o) +{ + Evas_Public_Data *e; + + if (!o->cur->scene) return; + + Evas_Canvas3D_Scene_Data *pd_scene = + eo_data_scope_get(o->cur->scene, EVAS_CANVAS3D_SCENE_CLASS); + + EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write) + { + pd_scene->images = eina_list_remove(pd_scene->images, eo_obj); + eo_unref(state_write->scene); + state_write->scene = NULL; + } + EINA_COW_IMAGE_STATE_WRITE_END(o, state_write); + + if (o->cur->defmap) + { + EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write) + { + evas_map_free(state_write->defmap); + state_write->defmap = NULL; + } + EINA_COW_IMAGE_STATE_WRITE_END(o, state_write); + } + + EINA_COW_WRITE_BEGIN(evas_object_3d_cow, obj->data_3d, Evas_Object_3D_Data, + data) + { + e = obj->layer->evas; + + if (data->surface) + e->engine.func->image_free(e->engine.data.output, data->surface); + + data->surface = NULL; + data->w = 0; + data->h = 0; + } + EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data); +} + +#include "efl_canvas_scene3d.eo.c" diff --git a/src/lib/evas/canvas/efl_canvas_scene3d.eo b/src/lib/evas/canvas/efl_canvas_scene3d.eo new file mode 100644 index 0000000000..685e42296a --- /dev/null +++ b/src/lib/evas/canvas/efl_canvas_scene3d.eo @@ -0,0 +1,19 @@ +class Efl.Canvas.Scene3d (Evas.Image, Efl.Gfx.Base, Efl.Image, Efl.Gfx.Buffer, Efl.Gfx.Fill, Efl.Gfx.View, Efl.Gfx.Filter) +{ + [[A UI view for EFL Canvas 3D.]] + legacy_prefix: null; + data: null; + methods { + @property scene3d { + [[The 3d scene to display in this view. + + @since 1.10 + ]] + set {} + get {} + values { + scene: Evas.Canvas3D.Scene *; [[3D scene.]] + } + } + } +} diff --git a/src/lib/evas/canvas/evas_image.eo b/src/lib/evas/canvas/evas_image.eo index 9edb29e5fa..23de879cd8 100644 --- a/src/lib/evas/canvas/evas_image.eo +++ b/src/lib/evas/canvas/evas_image.eo @@ -141,31 +141,6 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image, Efl.Image_Load, Efl.Image_An surf: Evas.Native_Surface* @nonull; [[The native surface.]] } } - - /* 3d */ - @property scene { - set { - [[Set the 3D scene of a given image of the canvas. - - This function sets a 3d scene of a given canvas image. - - @since 1.10 - ]] - legacy: null; - } - get { - [[Get the 3D scene of a given image of the canvas. - - This function returns the 3d scene of a given canvas image. - - @since 1.10 - ]] - legacy: null; - } - values { - scene: Evas.Canvas3D.Scene *; [[3D scene on an image object.]] - } - } } implements { Eo.Base.constructor; diff --git a/src/lib/evas/canvas/evas_image_private.h b/src/lib/evas/canvas/evas_image_private.h index dfbfc09537..fd7e072d29 100644 --- a/src/lib/evas/canvas/evas_image_private.h +++ b/src/lib/evas/canvas/evas_image_private.h @@ -137,9 +137,24 @@ struct _Evas_Image_Data }; /* shared functions between legacy and new eo classes */ -void _evas_object_image_cleanup(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o); -void _proxy_unset(Evas_Object *proxy, Evas_Object_Protected_Data *obj, Evas_Image_Data *o); -void _proxy_set(Evas_Object *proxy, Evas_Object *src); -void _proxy_error(Evas_Object *proxy, void *context, void *output, void *surface, int x, int y, Eina_Bool do_async); +void _evas_image_init_set(const Eina_File *f, const char *file, const char *key, Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o, Evas_Image_Load_Opts *lo); +void _evas_image_done_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o); +void _evas_image_cleanup(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o); +void _evas_image_proxy_unset(Evas_Object *proxy, Evas_Object_Protected_Data *obj, Evas_Image_Data *o); +void _evas_image_proxy_set(Evas_Object *proxy, Evas_Object *src); +void _evas_image_proxy_error(Evas_Object *proxy, void *context, void *output, void *surface, int x, int y, Eina_Bool do_async); +void _evas_image_3d_render(Evas *eo_e, Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o, Evas_Canvas3D_Scene *scene); +void _evas_image_3d_set(Evas_Object *eo_obj, Evas_Canvas3D_Scene *scene); +void _evas_image_3d_unset(Evas_Object *eo_obj, Evas_Object_Protected_Data *image, Evas_Image_Data *o); + +/* save typing */ +#define ENFN obj->layer->evas->engine.func +#define ENDT obj->layer->evas->engine.data.output + +# define EINA_COW_IMAGE_STATE_WRITE_BEGIN(Obj, Write) \ + EINA_COW_WRITE_BEGIN(evas_object_image_state_cow, Obj->cur, Evas_Object_Image_State, Write) + +# define EINA_COW_IMAGE_STATE_WRITE_END(Obj, Write) \ + EINA_COW_WRITE_END(evas_object_image_state_cow, Obj->cur, Write) #endif // EVAS_IMAGE_PRIVATE_H diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c index ffb883a747..b2480311db 100644 --- a/src/lib/evas/canvas/evas_object_image.c +++ b/src/lib/evas/canvas/evas_object_image.c @@ -3,10 +3,6 @@ #define MY_CLASS EVAS_IMAGE_CLASS #define MY_CLASS_NAME "Evas_Image" -/* save typing */ -#define ENFN obj->layer->evas->engine.func -#define ENDT obj->layer->evas->engine.data.output - /* private magic number for image objects */ static const char o_type[] = "image"; @@ -61,10 +57,6 @@ static int evas_object_image_can_map(Evas_Object *eo_obj); static void *evas_object_image_data_convert_internal(Evas_Image_Data *o, void *data, Evas_Colorspace to_cspace); static void evas_object_image_filled_resize_listener(void *data, Evas *eo_e, Evas_Object *eo_obj, void *einfo); -static void _3d_render(Evas *eo_e, Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o, Evas_Canvas3D_Scene *scene); -static void _3d_set(Evas_Object *eo_obj, Evas_Canvas3D_Scene *scene); -static void _3d_unset(Evas_Object *eo_obj, Evas_Object_Protected_Data *image, Evas_Image_Data *o); - static const Evas_Object_Func object_func = { /* methods (compulsory) */ @@ -134,12 +126,6 @@ Eina_Cow *evas_object_image_state_cow = NULL; # define EINA_COW_LOAD_OPTS_WRITE_END(Obj, Write) \ EINA_COW_WRITE_END(evas_object_image_load_opts_cow, Obj->load_opts, Write) -# define EINA_COW_IMAGE_STATE_WRITE_BEGIN(Obj, Write) \ - EINA_COW_WRITE_BEGIN(evas_object_image_state_cow, Obj->cur, Evas_Object_Image_State, Write) - -# define EINA_COW_IMAGE_STATE_WRITE_END(Obj, Write) \ - EINA_COW_WRITE_END(evas_object_image_state_cow, Obj->cur, Write) - # define EVAS_OBJECT_WRITE_IMAGE_FREE_FILE_AND_KEY(Obj) \ if ((!Obj->cur->mmaped_source && Obj->cur->u.file) || Obj->cur->key) \ { \ @@ -153,7 +139,7 @@ Eina_Cow *evas_object_image_state_cow = NULL; } void -_evas_object_image_cleanup(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o) +_evas_image_cleanup(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o) { /* Eina_Cow doesn't know if the resulting memory has changed, better check before we change it */ @@ -171,8 +157,8 @@ _evas_object_image_cleanup(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, o->preloading = EINA_FALSE; ENFN->image_data_preload_cancel(ENDT, o->engine_data, eo_obj); } - if (o->cur->source) _proxy_unset(eo_obj, obj, o); - if (o->cur->scene) _3d_unset(eo_obj, obj, o); + if (o->cur->source) _evas_image_proxy_unset(eo_obj, obj, o); + if (o->cur->scene) _evas_image_3d_unset(eo_obj, obj, o); } static Eina_Bool @@ -262,13 +248,13 @@ evas_object_image_memfile_set(Evas_Object *eo_obj, void *data, int size, char *f eina_file_close(f); } -static void -_image_init_set(const Eina_File *f, const char *file, const char *key, +void +_evas_image_init_set(const Eina_File *f, const char *file, const char *key, Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o, Evas_Image_Load_Opts *lo) { - if (o->cur->source) _proxy_unset(eo_obj, obj, o); - if (o->cur->scene) _3d_unset(eo_obj, obj, o); + if (o->cur->source) _evas_image_proxy_unset(eo_obj, obj, o); + if (o->cur->scene) _evas_image_3d_unset(eo_obj, obj, o); EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write) { @@ -337,8 +323,8 @@ _image_init_set(const Eina_File *f, const char *file, const char *key, lo->degree = 0; } -static void -_image_done_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o) +void +_evas_image_done_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o) { Eina_Bool resize_call = EINA_FALSE; @@ -408,9 +394,9 @@ _evas_image_efl_file_mmap_set(Eo *eo_obj, return EINA_FALSE; } evas_object_async_block(obj); - _image_init_set(f, NULL, key, eo_obj, obj, o, &lo); + _evas_image_init_set(f, NULL, key, eo_obj, obj, o, &lo); o->engine_data = ENFN->image_mmap(ENDT, o->cur->u.f, o->cur->key, &o->load_error, &lo); - _image_done_set(eo_obj, obj, o); + _evas_image_done_set(eo_obj, obj, o); return EINA_TRUE; } @@ -445,9 +431,9 @@ _evas_image_efl_file_file_set(Eo *eo_obj, Evas_Image_Data *o, const char *file, ENFN->image_data_preload_cancel(ENDT, o->engine_data, eo_obj); */ evas_object_async_block(obj); - _image_init_set(NULL, file, key, eo_obj, obj, o, &lo); + _evas_image_init_set(NULL, file, key, eo_obj, obj, o, &lo); o->engine_data = ENFN->image_load(ENDT, o->cur->u.file, o->cur->key, &o->load_error, &lo); - _image_done_set(eo_obj, obj, o); + _evas_image_done_set(eo_obj, obj, o); return EINA_TRUE; } @@ -549,29 +535,6 @@ _evas_image_eo_base_dbg_info_get(Eo *eo_obj, Evas_Image_Data *o, Eo_Dbg_Info *ro } } -EOLIAN static void -_evas_image_scene_set(Eo *eo_obj, Evas_Image_Data *o, Evas_Canvas3D_Scene *scene) -{ - Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); - Evas_Image_Load_Opts lo; - - if (o->cur->scene == scene) return; - - evas_object_async_block(obj); - _image_init_set(NULL, NULL, NULL, eo_obj, obj, o, &lo); - o->engine_data = ENFN->image_load(ENDT, o->cur->u.file, o->cur->key, &o->load_error, &lo); - _image_done_set(eo_obj, obj, o); - - if (scene) _3d_set(eo_obj, scene); - else _3d_unset(eo_obj, obj, o); -} - -EOLIAN static Evas_Canvas3D_Scene * -_evas_image_scene_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o) -{ - return o->cur->scene; -} - EOLIAN static void _evas_image_efl_image_border_set(Eo *eo_obj, Evas_Image_Data *o, int l, int r, int t, int b) { @@ -736,7 +699,7 @@ evas_object_image_size_set(Eo *eo_obj, int w, int h) if (o->cur->scene) return; evas_object_async_block(obj); - _evas_object_image_cleanup(eo_obj, obj, o); + _evas_image_cleanup(eo_obj, obj, o); if (w < 1) w = 1; if (h < 1) h = 1; if (w >= 32768) return; @@ -1114,7 +1077,7 @@ _evas_image_efl_file_save(const Eo *eo_obj, Evas_Image_Data *o, const char *file if (o->cur->scene) { - _3d_render(obj->layer->evas->evas, (Eo *) eo_obj, obj, o, o->cur->scene); + _evas_image_3d_render(obj->layer->evas->evas, (Eo *) eo_obj, obj, o, o->cur->scene); pixels = obj->data_3d->surface; imagew = obj->data_3d->w; imageh = obj->data_3d->h; @@ -1293,7 +1256,7 @@ evas_object_image_pixels_import(Evas_Object *eo_obj, Evas_Pixel_Import_Source *p evas_object_async_block(obj); o = eo_data_scope_get(eo_obj, MY_CLASS); - _evas_object_image_cleanup(eo_obj, obj, o); + _evas_image_cleanup(eo_obj, obj, o); if ((pixels->w != o->cur->image.w) || (pixels->h != o->cur->image.h)) return EINA_FALSE; switch (pixels->format) @@ -1524,7 +1487,7 @@ evas_object_image_colorspace_set(Evas_Object *eo_obj, Evas_Colorspace cspace) Evas_Image_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); evas_object_async_block(obj); - _evas_object_image_cleanup(eo_obj, obj, o); + _evas_image_cleanup(eo_obj, obj, o); EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write) state_write->cspace = cspace; @@ -1546,7 +1509,7 @@ _evas_image_video_surface_set(Eo *eo_obj, Evas_Image_Data *o, Evas_Video_Surface Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); evas_object_async_block(obj); - _evas_object_image_cleanup(eo_obj, obj, o); + _evas_image_cleanup(eo_obj, obj, o); if (o->video_surface) { o->video_surface = EINA_FALSE; @@ -1610,7 +1573,7 @@ _evas_image_video_surface_caps_set(Eo *eo_obj, Evas_Image_Data *o, unsigned int Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); evas_object_async_block(obj); - _evas_object_image_cleanup(eo_obj, obj, o); + _evas_image_cleanup(eo_obj, obj, o); if (caps == o->pixels->video_caps) return; @@ -1655,7 +1618,7 @@ _evas_image_native_surface_set(Eo *eo_obj, Evas_Image_Data *o, Evas_Native_Surfa evas_object_async_block(obj); evas_render_rendering_wait(obj->layer->evas); - _evas_object_image_cleanup(eo_obj, obj, o); + _evas_image_cleanup(eo_obj, obj, o); if (!ENFN->image_native_set) return; if ((surf) && ((surf->version < 2) || @@ -1964,7 +1927,7 @@ _evas_canvas_image_max_size_get(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, int * } void -_proxy_unset(Evas_Object *proxy, Evas_Object_Protected_Data *cur_proxy, Evas_Image_Data *o) +_evas_image_proxy_unset(Evas_Object *proxy, Evas_Object_Protected_Data *cur_proxy, Evas_Image_Data *o) { Evas_Object_Protected_Data *cur_source; @@ -2020,7 +1983,7 @@ _proxy_unset(Evas_Object *proxy, Evas_Object_Protected_Data *cur_proxy, Evas_Ima } void -_proxy_set(Evas_Object *eo_proxy, Evas_Object *eo_src) +_evas_image_proxy_set(Evas_Object *eo_proxy, Evas_Object *eo_src) { Evas_Object_Protected_Data *src = eo_data_scope_get(eo_src, EVAS_OBJECT_CLASS); Evas_Object_Protected_Data *proxy = eo_data_scope_get(eo_proxy, EVAS_OBJECT_CLASS); @@ -2052,7 +2015,7 @@ _proxy_set(Evas_Object *eo_proxy, Evas_Object *eo_src) * Give them some pixels. A random color */ void -_proxy_error(Evas_Object *eo_proxy, void *context, void *output, void *surface, +_evas_image_proxy_error(Evas_Object *eo_proxy, void *context, void *output, void *surface, int x, int y, Eina_Bool do_async) { Evas_Image_Data *o = eo_data_scope_get(eo_proxy, MY_CLASS); @@ -2077,179 +2040,6 @@ _proxy_error(Evas_Object *eo_proxy, void *context, void *output, void *surface, do_async); } -static void -_3d_set(Evas_Object *eo_obj, Evas_Canvas3D_Scene *scene) -{ - Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); - Evas_Image_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); - Evas_Canvas3D_Scene_Data *pd_scene = eo_data_scope_get(scene, - EVAS_CANVAS3D_SCENE_CLASS); - EINA_COW_WRITE_BEGIN(evas_object_3d_cow, obj->data_3d, Evas_Object_3D_Data, - data) - { - data->surface = NULL; - data->w = 0; - data->h = 0; - eo_ref(scene); - } - EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data); - - EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write) - { - state_write->scene = scene; - } - EINA_COW_IMAGE_STATE_WRITE_END(o, state_write); - - pd_scene->images = eina_list_append(pd_scene->images, eo_obj); -} - -static void -_3d_unset(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, - Evas_Image_Data *o) -{ - Evas_Public_Data *e; - - if (!o->cur->scene) return; - - Evas_Canvas3D_Scene_Data *pd_scene = - eo_data_scope_get(o->cur->scene, EVAS_CANVAS3D_SCENE_CLASS); - - EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write) - { - pd_scene->images = eina_list_remove(pd_scene->images, eo_obj); - eo_unref(state_write->scene); - state_write->scene = NULL; - } - EINA_COW_IMAGE_STATE_WRITE_END(o, state_write); - - if (o->cur->defmap) - { - EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write) - { - evas_map_free(state_write->defmap); - state_write->defmap = NULL; - } - EINA_COW_IMAGE_STATE_WRITE_END(o, state_write); - } - - EINA_COW_WRITE_BEGIN(evas_object_3d_cow, obj->data_3d, Evas_Object_3D_Data, - data) - { - e = obj->layer->evas; - - if (data->surface) - e->engine.func->image_free(e->engine.data.output, data->surface); - - data->surface = NULL; - data->w = 0; - data->h = 0; - } - EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data); -} - -static void -_3d_render(Evas *eo_e, Evas_Object *eo_obj EINA_UNUSED, - Evas_Object_Protected_Data *obj, Evas_Image_Data *o EINA_UNUSED, - Evas_Canvas3D_Scene *scene) -{ - Evas_Public_Data *e; - Eina_Bool need_native_set = EINA_FALSE; - Evas_Canvas3D_Scene_Public_Data scene_data; - Evas_Canvas3D_Scene_Data *pd_scene = NULL; - - pd_scene = eo_data_scope_get(scene, EVAS_CANVAS3D_SCENE_CLASS); - - if ((pd_scene->w == 0) || (pd_scene->h == 0)) return; - if (!pd_scene->camera_node) - { - WRN("Camera has not been set to scene(%p)", scene); - return; - } - - e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS); - - if (pd_scene->surface) - { - int w = 0; - int h = 0; - - if (e->engine.func->drawable_size_get) - { - e->engine.func->drawable_size_get(e->engine.data.output, - pd_scene->surface, &w, &h); - } - if ((w != pd_scene->w) || (h != pd_scene->h)) - { - if (e->engine.func->drawable_free) - { - e->engine.func->drawable_free(e->engine.data.output, - pd_scene->surface); - } - pd_scene->surface = NULL; - need_native_set = EINA_TRUE; - } - } - else - { - /* TODO: Hard-coded alpha on. */ - if (e->engine.func->drawable_new) - { - pd_scene->surface = - e->engine.func->drawable_new(e->engine.data.output, - pd_scene->w, pd_scene->h, 1); - } - need_native_set = EINA_TRUE; - } - - EINA_COW_WRITE_BEGIN(evas_object_3d_cow, obj->data_3d, Evas_Object_3D_Data, - data) - { - if (need_native_set) - { - if (e->engine.func->image_drawable_set) - { - data->surface = - e->engine.func->image_drawable_set(e->engine.data.output, - data->surface, - pd_scene->surface); - } - } - data->w = pd_scene->w; - data->h = pd_scene->h; - } - EINA_COW_WRITE_END(evas_object_3d_cow, obj->data_3d, data); - - evas_canvas3d_scene_data_init(&scene_data); - - scene_data.bg_color = pd_scene->bg_color; - scene_data.shadows_enabled = pd_scene->shadows_enabled; - scene_data.camera_node = pd_scene->camera_node; - scene_data.depth_offset = pd_scene->depth_offset; - scene_data.depth_constant = pd_scene->depth_constant; - - /* Phase 1 - Update scene graph tree. */ - evas_canvas3d_object_update(scene); - - /* Phase 2 - Do frustum culling and get visible model nodes. */ - evas_canvas3d_node_tree_traverse(pd_scene->root_node, - EVAS_CANVAS3D_TREE_TRAVERSE_LEVEL_ORDER, EINA_TRUE, - evas_canvas3d_node_mesh_collect, &scene_data); - - /* Phase 3 - Collect active light nodes in the scene graph tree. */ - evas_canvas3d_node_tree_traverse(pd_scene->root_node, - EVAS_CANVAS3D_TREE_TRAVERSE_ANY_ORDER, EINA_FALSE, - evas_canvas3d_node_light_collect, &scene_data); - - /* Phase 5 - Draw the scene. */ - if (e->engine.func->drawable_scene_render) - { - e->engine.func->drawable_scene_render(e->engine.data.output, - pd_scene->surface, &scene_data); - } - /* Clean up temporary resources. */ - evas_canvas3d_scene_data_fini(&scene_data); -} - static void evas_object_image_unload(Evas_Object *eo_obj, Eina_Bool dirty) { @@ -2461,8 +2251,8 @@ evas_object_image_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj) if (o->cur->u.f) eina_file_close(o->cur->u.f); } if (o->cur->key) eina_stringshare_del(o->cur->key); - if (o->cur->source) _proxy_unset(eo_obj, obj, o); - if (o->cur->scene) _3d_unset(eo_obj, obj, o); + if (o->cur->source) _evas_image_proxy_unset(eo_obj, obj, o); + if (o->cur->scene) _evas_image_3d_unset(eo_obj, obj, o); if (obj->layer && obj->layer->evas) { if (o->engine_data) @@ -2765,7 +2555,7 @@ evas_object_image_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, v /* Proxy sanity */ if (o->proxyrendering) { - _proxy_error(eo_obj, context, output, surface, x, y, EINA_FALSE); + _evas_image_proxy_error(eo_obj, context, output, surface, x, y, EINA_FALSE); return; } @@ -2843,7 +2633,7 @@ _evas_image_render(Eo *eo_obj, Evas_Object_Protected_Data *obj, if (o->cur->scene) { - _3d_render(obj->layer->evas->evas, eo_obj, obj, o, o->cur->scene); + _evas_image_3d_render(obj->layer->evas->evas, eo_obj, obj, o, o->cur->scene); pixels = obj->data_3d->surface; imagew = obj->data_3d->w; imageh = obj->data_3d->h; @@ -3743,7 +3533,7 @@ evas_object_image_is_inside(Evas_Object *eo_obj, if (o->cur->scene) { - _3d_render(obj->layer->evas->evas, eo_obj, obj, o, o->cur->scene); + _evas_image_3d_render(obj->layer->evas->evas, eo_obj, obj, o, o->cur->scene); pixels = obj->data_3d->surface; imagew = obj->data_3d->w; imageh = obj->data_3d->h; @@ -4486,7 +4276,7 @@ evas_object_image_data_set(Eo *eo_obj, void *data) evas_object_async_block(obj); evas_render_rendering_wait(obj->layer->evas); - _evas_object_image_cleanup(eo_obj, obj, o); + _evas_image_cleanup(eo_obj, obj, o); p_data = o->engine_data; if (data) { @@ -4614,7 +4404,7 @@ evas_object_image_data_copy_set(Eo *eo_obj, void *data) if (!data) return; evas_object_async_block(obj); - _evas_object_image_cleanup(eo_obj, obj, o); + _evas_image_cleanup(eo_obj, obj, o); if ((o->cur->image.w <= 0) || (o->cur->image.h <= 0)) return; if (o->engine_data)