forked from enlightenment/efl
Evas: 3D: Refined proxy texture implementation
Added new APIs for controlling source object's visibility. Fixed bugs related to updating proxy textures.
This commit is contained in:
parent
26e43f938f
commit
6856e562ca
|
@ -245,7 +245,7 @@ main(void)
|
||||||
evas_object_show(image);
|
evas_object_show(image);
|
||||||
|
|
||||||
/* Set the image object as render target for 3D scene. */
|
/* Set the image object as render target for 3D scene. */
|
||||||
evas_object_image_3d_scene_set(image, data.scene);
|
evas_object_image_t3d_scene_set(image, data.scene);
|
||||||
|
|
||||||
/* Add animation timer callback. */
|
/* Add animation timer callback. */
|
||||||
ecore_timer_add(0.016, _animate_scene, &data);
|
ecore_timer_add(0.016, _animate_scene, &data);
|
||||||
|
|
|
@ -306,7 +306,7 @@ main(void)
|
||||||
evas_object_show(image);
|
evas_object_show(image);
|
||||||
|
|
||||||
/* Set the image object as render target for 3D scene. */
|
/* Set the image object as render target for 3D scene. */
|
||||||
evas_object_image_3d_scene_set(image, data.scene);
|
evas_object_image_t3d_scene_set(image, data.scene);
|
||||||
|
|
||||||
/* Add animation timer callback. */
|
/* Add animation timer callback. */
|
||||||
ecore_timer_add(0.01, _animate_scene, &data);
|
ecore_timer_add(0.01, _animate_scene, &data);
|
||||||
|
|
|
@ -148,7 +148,7 @@ main(void)
|
||||||
|
|
||||||
image = evas_object_image_filled_add(evas);
|
image = evas_object_image_filled_add(evas);
|
||||||
evas_object_image_size_set(image, WIDTH, HEIGHT);
|
evas_object_image_size_set(image, WIDTH, HEIGHT);
|
||||||
evas_object_image_3d_scene_set(image, scene);
|
evas_object_image_t3d_scene_set(image, scene);
|
||||||
evas_object_move(image, 0, 0);
|
evas_object_move(image, 0, 0);
|
||||||
evas_object_resize(image, WIDTH, HEIGHT);
|
evas_object_resize(image, WIDTH, HEIGHT);
|
||||||
evas_object_show(image);
|
evas_object_show(image);
|
||||||
|
|
|
@ -378,7 +378,7 @@ main(void)
|
||||||
|
|
||||||
image = evas_object_image_filled_add(evas);
|
image = evas_object_image_filled_add(evas);
|
||||||
evas_object_image_size_set(image, WIDTH, HEIGHT);
|
evas_object_image_size_set(image, WIDTH, HEIGHT);
|
||||||
evas_object_image_3d_scene_set(image, scene);
|
evas_object_image_t3d_scene_set(image, scene);
|
||||||
evas_object_move(image, 0, 0);
|
evas_object_move(image, 0, 0);
|
||||||
evas_object_resize(image, WIDTH, HEIGHT);
|
evas_object_resize(image, WIDTH, HEIGHT);
|
||||||
evas_object_show(image);
|
evas_object_show(image);
|
||||||
|
|
|
@ -260,7 +260,7 @@ main(void)
|
||||||
_scene_setup(&data);
|
_scene_setup(&data);
|
||||||
|
|
||||||
/* Set the image object as render target for 3D scene. */
|
/* Set the image object as render target for 3D scene. */
|
||||||
evas_object_image_3d_scene_set(image, data.scene);
|
evas_object_image_t3d_scene_set(image, data.scene);
|
||||||
|
|
||||||
/* Add animation timer callback. */
|
/* Add animation timer callback. */
|
||||||
ecore_timer_add(0.016, _animate_scene, &data);
|
ecore_timer_add(0.016, _animate_scene, &data);
|
||||||
|
|
|
@ -117,8 +117,8 @@ typedef enum _Evas_3D_Pick_Type
|
||||||
} Evas_3D_Pick_Type;
|
} Evas_3D_Pick_Type;
|
||||||
|
|
||||||
/* Image object render target */
|
/* Image object render target */
|
||||||
EAPI void evas_object_image_3d_scene_set(Evas_Object *obj, Evas_3D_Scene *scene) EINA_ARG_NONNULL(1);
|
EAPI void evas_object_image_t3d_scene_set(Evas_Object *obj, Evas_3D_Scene *scene) EINA_ARG_NONNULL(1);
|
||||||
EAPI Evas_3D_Scene *evas_object_image_3d_scene_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
EAPI Evas_3D_Scene *evas_object_image_t3d_scene_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||||
|
|
||||||
/* Scene */
|
/* Scene */
|
||||||
EAPI Evas_3D_Scene *evas_3d_scene_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
EAPI Evas_3D_Scene *evas_3d_scene_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||||
|
@ -259,6 +259,8 @@ EAPI Evas *evas_3d_texture_evas_get(const Evas_3D_Texture *texture)
|
||||||
EAPI void evas_3d_texture_data_set(Evas_3D_Texture *texture, Evas_3D_Color_Format color_format, Evas_3D_Pixel_Format pixel_format, int w, int h, const void *data);
|
EAPI void evas_3d_texture_data_set(Evas_3D_Texture *texture, Evas_3D_Color_Format color_format, Evas_3D_Pixel_Format pixel_format, int w, int h, const void *data);
|
||||||
EAPI void evas_3d_texture_file_set(Evas_3D_Texture *texture, const char *file, const char *key) EINA_ARG_NONNULL(1);
|
EAPI void evas_3d_texture_file_set(Evas_3D_Texture *texture, const char *file, const char *key) EINA_ARG_NONNULL(1);
|
||||||
EAPI void evas_3d_texture_source_set(Evas_3D_Texture *texture, Evas_Object *source) EINA_ARG_NONNULL(1);
|
EAPI void evas_3d_texture_source_set(Evas_3D_Texture *texture, Evas_Object *source) EINA_ARG_NONNULL(1);
|
||||||
|
EAPI void evas_3d_texture_source_visible_set(Evas_3D_Texture *texture, Eina_Bool visible) EINA_ARG_NONNULL(1);
|
||||||
|
EAPI Eina_Bool evas_3d_texture_source_visible_get(const Evas_3D_Texture *texture) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||||
EAPI Evas_3D_Color_Format evas_3d_texture_color_format_get(const Evas_3D_Texture *texture) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
EAPI Evas_3D_Color_Format evas_3d_texture_color_format_get(const Evas_3D_Texture *texture) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||||
EAPI void evas_3d_texture_size_get(const Evas_3D_Texture *texture, int *w, int *h) EINA_ARG_NONNULL(1);
|
EAPI void evas_3d_texture_size_get(const Evas_3D_Texture *texture, int *w, int *h) EINA_ARG_NONNULL(1);
|
||||||
EAPI void evas_3d_texture_wrap_set(Evas_3D_Texture *texture, Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mode t) EINA_ARG_NONNULL(1);
|
EAPI void evas_3d_texture_wrap_set(Evas_3D_Texture *texture, Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mode t) EINA_ARG_NONNULL(1);
|
||||||
|
|
|
@ -28,15 +28,14 @@ _texture_proxy_unset(Evas_3D_Texture *texture)
|
||||||
{
|
{
|
||||||
proxy_src->proxy_textures = eina_list_remove(proxy_src->proxy_textures, texture);
|
proxy_src->proxy_textures = eina_list_remove(proxy_src->proxy_textures, texture);
|
||||||
|
|
||||||
if (eina_list_count(proxy_src->proxy_textures) == 0)
|
if (eina_list_count(proxy_src->proxy_textures) == 0 &&
|
||||||
|
eina_list_count(proxy_src->proxies) == 0 &&
|
||||||
|
proxy_src->surface != NULL)
|
||||||
{
|
{
|
||||||
if (eina_list_count(proxy_src->proxies) == 0)
|
Evas_Public_Data *e = src->layer->evas;
|
||||||
{
|
e->engine.func->image_map_surface_free(e->engine.data.output,
|
||||||
Evas_Public_Data *e = src->layer->evas;
|
proxy_src->surface);
|
||||||
e->engine.func->image_map_surface_free(e->engine.data.output,
|
proxy_src->surface = NULL;
|
||||||
proxy_src->surface);
|
|
||||||
proxy_src->surface = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proxy_src->src_invisible)
|
if (proxy_src->src_invisible)
|
||||||
|
@ -134,11 +133,18 @@ _texture_proxy_subrender(Evas_3D_Texture *texture)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Evas_Proxy_Render_Data proxy_render_data = {
|
||||||
|
.eo_proxy = NULL,
|
||||||
|
.proxy_obj = NULL,
|
||||||
|
.eo_src = texture->source,
|
||||||
|
.source_clip = EINA_FALSE
|
||||||
|
};
|
||||||
|
|
||||||
evas_render_mapped(e, texture->source, source, ctx, proxy_write->surface,
|
evas_render_mapped(e, texture->source, source, ctx, proxy_write->surface,
|
||||||
-source->cur->geometry.x,
|
-source->cur->geometry.x,
|
||||||
-source->cur->geometry.y,
|
-source->cur->geometry.y,
|
||||||
1, 0, 0, e->output.w, e->output.h,
|
1, 0, 0, e->output.w, e->output.h,
|
||||||
NULL
|
&proxy_render_data
|
||||||
#ifdef REND_DBG
|
#ifdef REND_DBG
|
||||||
, 1
|
, 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -388,6 +394,40 @@ evas_3d_texture_source_set(Evas_3D_Texture *texture, Evas_Object *source)
|
||||||
evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_DATA, NULL);
|
evas_3d_object_change(&texture->base, EVAS_3D_STATE_TEXTURE_DATA, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
evas_3d_texture_source_visible_set(Evas_3D_Texture *texture, Eina_Bool visible)
|
||||||
|
{
|
||||||
|
Evas_Object_Protected_Data *src_obj;
|
||||||
|
|
||||||
|
if (texture->source == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
src_obj = eo_data_scope_get(texture->source, EVAS_OBJ_CLASS);
|
||||||
|
|
||||||
|
if (src_obj->proxy->src_invisible == !visible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, src_obj->proxy, Evas_Object_Proxy_Data, proxy_write)
|
||||||
|
proxy_write->src_invisible = !visible;
|
||||||
|
EINA_COW_WRITE_END(evas_object_proxy_cow, src_obj->proxy, proxy_write);
|
||||||
|
|
||||||
|
src_obj->changed_src_visible = EINA_TRUE;
|
||||||
|
evas_object_smart_member_cache_invalidate(texture->source, EINA_FALSE, EINA_FALSE, EINA_TRUE);
|
||||||
|
evas_object_change(texture->source, src_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
evas_3d_texture_source_visible_get(const Evas_3D_Texture *texture)
|
||||||
|
{
|
||||||
|
Evas_Object_Protected_Data *src_obj;
|
||||||
|
|
||||||
|
if (texture->source == NULL)
|
||||||
|
return EINA_FALSE;
|
||||||
|
|
||||||
|
src_obj = eo_data_scope_get(texture->source, EVAS_OBJ_CLASS);
|
||||||
|
return !src_obj->proxy->src_invisible;
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Evas_3D_Color_Format
|
EAPI Evas_3D_Color_Format
|
||||||
evas_3d_texture_color_format_get(const Evas_3D_Texture *texture)
|
evas_3d_texture_color_format_get(const Evas_3D_Texture *texture)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3875,7 +3875,20 @@ evas_object_image_is_inside(Evas_Object *eo_obj,
|
||||||
(o->cur->source ?
|
(o->cur->source ?
|
||||||
eo_data_scope_get(o->cur->source, EVAS_OBJ_CLASS):
|
eo_data_scope_get(o->cur->source, EVAS_OBJ_CLASS):
|
||||||
NULL);
|
NULL);
|
||||||
|
#ifdef EVAS_3D
|
||||||
|
if (o->cur->scene)
|
||||||
|
{
|
||||||
|
_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;
|
||||||
|
uvw = imagew;
|
||||||
|
uvh = imageh;
|
||||||
|
}
|
||||||
|
else if (!o->cur->source)
|
||||||
|
#else
|
||||||
if (!o->cur->source)
|
if (!o->cur->source)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
pixels = o->engine_data;
|
pixels = o->engine_data;
|
||||||
imagew = o->cur->image.w;
|
imagew = o->cur->image.w;
|
||||||
|
|
|
@ -677,6 +677,10 @@ _evas_object_eo_base_destructor(Eo *eo_obj, Evas_Object_Protected_Data *obj)
|
||||||
else if (eo_isa(proxy, EVAS_OBJ_TEXT_CLASS))
|
else if (eo_isa(proxy, EVAS_OBJ_TEXT_CLASS))
|
||||||
eo_do(proxy, evas_obj_text_filter_source_set(NULL, eo_obj));
|
eo_do(proxy, evas_obj_text_filter_source_set(NULL, eo_obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (obj->proxy->proxy_textures)
|
||||||
|
evas_3d_texture_source_set(obj->proxy->proxy_textures->data, NULL);
|
||||||
|
|
||||||
if (obj->cur->clipper) evas_object_clip_unset(eo_obj);
|
if (obj->cur->clipper) evas_object_clip_unset(eo_obj);
|
||||||
evas_object_map_set(eo_obj, NULL);
|
evas_object_map_set(eo_obj, NULL);
|
||||||
if (obj->is_smart) evas_object_smart_del(eo_obj);
|
if (obj->is_smart) evas_object_smart_del(eo_obj);
|
||||||
|
|
|
@ -278,6 +278,17 @@ _evas_proxy_redraw_set(Evas_Public_Data *e, Evas_Object_Protected_Data *obj,
|
||||||
//Update the proxies recursively.
|
//Update the proxies recursively.
|
||||||
_evas_proxy_redraw_set(e, proxy, render);
|
_evas_proxy_redraw_set(e, proxy, render);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef EVAS_3D
|
||||||
|
if (obj->proxy->proxy_textures)
|
||||||
|
{
|
||||||
|
/* Flag need redraw on proxy texture source */
|
||||||
|
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, obj->proxy,
|
||||||
|
Evas_Object_Proxy_Data, source)
|
||||||
|
source->redraw = EINA_TRUE;
|
||||||
|
EINA_COW_WRITE_END(evas_object_proxy_cow, obj->proxy, source);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -298,7 +309,11 @@ _evas_render_phase1_direct(Evas_Public_Data *e,
|
||||||
eina_array_data_get(active_objects, i);
|
eina_array_data_get(active_objects, i);
|
||||||
|
|
||||||
if (obj->changed) evas_object_clip_recalc(obj);
|
if (obj->changed) evas_object_clip_recalc(obj);
|
||||||
|
#ifdef EVAS_3D
|
||||||
|
if (!obj->proxy->proxies && !obj->proxy->proxy_textures) continue;
|
||||||
|
#else
|
||||||
if (!obj->proxy->proxies) continue;
|
if (!obj->proxy->proxies) continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (obj->smart.smart)
|
if (obj->smart.smart)
|
||||||
changed = evas_object_smart_changed_get(obj->object);
|
changed = evas_object_smart_changed_get(obj->object);
|
||||||
|
@ -325,7 +340,11 @@ _evas_render_phase1_direct(Evas_Public_Data *e,
|
||||||
obj->func->render_pre(eo_obj, obj, obj->private_data);
|
obj->func->render_pre(eo_obj, obj, obj->private_data);
|
||||||
if (obj->proxy->redraw)
|
if (obj->proxy->redraw)
|
||||||
_evas_render_prev_cur_clip_cache_add(e, obj);
|
_evas_render_prev_cur_clip_cache_add(e, obj);
|
||||||
|
#ifdef EVAS_3D
|
||||||
|
if (obj->proxy->proxies || obj->proxy->proxy_textures)
|
||||||
|
#else
|
||||||
if (obj->proxy->proxies)
|
if (obj->proxy->proxies)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (!obj->smart.smart || evas_object_smart_changed_get(eo_obj))
|
if (!obj->smart.smart || evas_object_smart_changed_get(eo_obj))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1528,13 +1528,12 @@ evas_box3_ray3_intersect(const Evas_Box3 *box EINA_UNUSED, const Evas_Ray3 *ray
|
||||||
static inline Evas_Real
|
static inline Evas_Real
|
||||||
evas_reciprocal_sqrt(Evas_Real x)
|
evas_reciprocal_sqrt(Evas_Real x)
|
||||||
{
|
{
|
||||||
long i;
|
union {
|
||||||
float y, r;
|
float f;
|
||||||
|
long i;
|
||||||
|
} u;
|
||||||
|
|
||||||
y = x * 0.5f;
|
u.f = x;
|
||||||
i = *(long *)(&x);
|
u.i = 0x5f3759df - (u.i >> 1);
|
||||||
i = 0x5f3759df - (i >> 1);
|
return u.f * (1.5f - u.f * u.f * x * 0.5f);
|
||||||
r = *(float *)(&i);
|
|
||||||
r = r * (1.5f - r * r * y);
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,11 @@ evas_object_is_source_invisible(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Pro
|
||||||
{
|
{
|
||||||
if (obj->parent_cache.src_invisible_valid)
|
if (obj->parent_cache.src_invisible_valid)
|
||||||
return obj->parent_cache.src_invisible;
|
return obj->parent_cache.src_invisible;
|
||||||
|
#ifdef EVAS_3D
|
||||||
|
if ((obj->proxy->proxies || obj->proxy->proxy_textures) && obj->proxy->src_invisible) return 1;
|
||||||
|
#else
|
||||||
if (obj->proxy->proxies && obj->proxy->src_invisible) return 1;
|
if (obj->proxy->proxies && obj->proxy->src_invisible) return 1;
|
||||||
|
#endif
|
||||||
if (!obj->smart.parent) return 0;
|
if (!obj->smart.parent) return 0;
|
||||||
Evas_Object_Protected_Data *smart_parent_pd =
|
Evas_Object_Protected_Data *smart_parent_pd =
|
||||||
eo_data_scope_get(obj->smart.parent, EVAS_OBJ_CLASS);
|
eo_data_scope_get(obj->smart.parent, EVAS_OBJ_CLASS);
|
||||||
|
|
Loading…
Reference in New Issue