{
Efl_Canvas_Vg_Object_Data *pd = data;
- if (eina_rectangle_is_empty(&pd->viewbox.rect))
- return;
+ if (eina_rectangle_is_empty(&pd->viewbox.rect)) return;
_update_vgtree_viewport(ev->object, pd);
}
evas_cache_vg_entry_del(pd->vg_entry);
evas_object_change(eo_obj, obj);
pd->vg_entry = NULL;
+ if (pd->image)
+ {
+ ENFN->image_free(ENC, pd->image);
+ pd->image = NULL;
+ }
evas_object_change(eo_obj, obj);
pd->changed = EINA_TRUE;
}
evas_cache_vg_entry_del(pd->vg_entry);
evas_object_change(eo_obj, obj);
pd->vg_entry = NULL;
+ if (pd->image)
+ {
+ ENFN->image_free(ENC, pd->image);
+ pd->image = NULL;
+ }
}
EOLIAN static Eina_Bool
}
EOLIAN static void
+_efl_canvas_vg_object_efl_gfx_entity_visible_set(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd, Eina_Bool vis)
+{
+ if (_evas_object_intercept_call(eo_obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, vis)) return;
+
+ efl_gfx_entity_visible_set(efl_super(eo_obj, MY_CLASS), vis);
+
+ Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
+
+ if (!vis && pd->image)
+ {
+ ENFN->image_free(ENC, pd->image);
+ pd->image = NULL;
+ }
+}
+
+EOLIAN static void
_efl_canvas_vg_object_efl_object_invalidate(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd)
{
+ Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
+
efl_unref(pd->root);
pd->root = NULL;
evas_cache_vg_entry_del(pd->vg_entry);
- if (pd->tvg_buffer)
- {
- free(pd->tvg_buffer);
- pd->tvg_buffer = NULL;
- }
if (pd->tvg_canvas)
{
tvg_canvas_clear(pd->tvg_canvas, false);
tvg_canvas_destroy(pd->tvg_canvas);
}
+ if (pd->image)
+ {
+ ENFN->image_free(ENC, pd->image);
+ pd->image = NULL;
+ }
+
efl_invalidate(efl_super(eo_obj, MY_CLASS));
}
pd->obj = obj;
pd->root = efl_add_ref(EFL_CANVAS_VG_CONTAINER_CLASS, NULL);
pd->tvg_canvas = tvg_swcanvas_create();
- pd->tvg_canvas_size.w = 0;
- pd->tvg_canvas_size.h = 0;
+ pd->size.w = 0;
+ pd->size.h = 0;
return eo_obj;
}
static void
-_render_tvg_buffer_to_screen(Evas_Object_Protected_Data *obj, Efl_Canvas_Vg_Object_Data *pd,
- void *engine, void *output, void *context, void *surface,
- int x, int y, int w, int h, Eina_Bool do_async)
+_render_image_to_screen(Evas_Object_Protected_Data *obj, Efl_Canvas_Vg_Object_Data *pd,
+ void *engine, void *output, void *context, void *surface,
+ int x, int y, Eina_Bool async)
{
- Eina_Bool async_unref = EINA_FALSE;
- Image_Entry *image = NULL;
-
- if (!pd || !pd->tvg_buffer)
- return;
-
- image = ENFN->image_new_from_copied_data(engine,
- pd->tvg_canvas_size.w,
- pd->tvg_canvas_size.h,
- pd->tvg_buffer, 255,
- EVAS_COLORSPACE_ARGB8888);
+ if (!pd || !pd->image) return;
- async_unref = ENFN->image_draw(engine, output, context, surface, image,
- 0, 0, w, h, x, y, w, h,
- EINA_TRUE, do_async);
+ ENFN->image_dirty_region(engine, pd->image, 0, 0, pd->size.w, pd->size.h);
- if (do_async && async_unref)
+ Eina_Bool async_unref = ENFN->image_draw(engine, output, context, surface, pd->image, 0, 0,
+ pd->size.w, pd->size.h, x, y, pd->size.w, pd->size.h,
+ EINA_TRUE, async);
+ if (async && async_unref)
{
- evas_cache_image_ref(image);
- evas_unref_queue_image_put(obj->layer->evas, image);
+ evas_cache_image_ref(pd->image);
+ evas_unref_queue_image_put(obj->layer->evas, pd->image);
}
+}
+
+static void
+_prepare_render_image(Evas_Object_Protected_Data* obj, Efl_Canvas_Vg_Object_Data *pd, void *engine)
+{
+ if (pd->image) ENFN->image_free(engine, pd->image);
- ENFN->image_free(engine, image);
+ pd->image = ENFN->tvg_image_new(engine, pd->size.w, pd->size.h);
+ if (!pd->image) return;
+
+ int stride = 0;
+ DATA32* pixels = ENFN->tvg_image_acquire(engine, pd->image, &stride);
+
+ tvg_swcanvas_set_target(pd->tvg_canvas, (uint32_t*) pixels, stride, pd->size.w, pd->size.h, TVG_COLORSPACE_ARGB8888);
+
+ ENFN->tvg_image_release(engine, pd->image, pixels);
}
static void
_efl_canvas_vg_object_render(Evas_Object *eo_obj EINA_UNUSED,
Evas_Object_Protected_Data *obj,
void *type_private_data,
- void *engine, void *output, void *context, void *surface,
+ void *engine, void *output EINA_UNUSED, void *context, void *surface EINA_UNUSED,
int x, int y, Eina_Bool do_async)
{
Efl_Canvas_Vg_Object_Data *pd = type_private_data;
Eina_Position2D offset = {0, 0}; //Offset after keeping aspect ratio.
- Eina_Bool updated = pd->changed;
-
ENFN->context_color_set(engine, context, 255, 255, 255, 255);
ENFN->context_multiplier_set(engine, context,
obj->cur->cache.clip.r,
vg_entry = evas_cache_vg_entry_resize(vg_entry, size.w, size.h);
evas_cache_vg_entry_del(pd->vg_entry);
pd->vg_entry = vg_entry;
- updated = EINA_TRUE;
}
//update for adjusted pos and size.
}
}
+ Eina_Bool resized = EINA_FALSE;
+ Eina_Bool prepared = EINA_FALSE;
+
//Reset canvas size
- if (pd->tvg_canvas_size.w != w || pd->tvg_canvas_size.h != h)
+ if (pd->size.w != w || pd->size.h != h)
{
- pd->tvg_buffer = realloc(pd->tvg_buffer, w * h * sizeof(uint32_t));
- pd->tvg_canvas_size.w = w;
- pd->tvg_canvas_size.h = h;
-
- tvg_swcanvas_set_target(pd->tvg_canvas, pd->tvg_buffer,
- w, w, h, TVG_COLORSPACE_ARGB8888);
- updated = EINA_TRUE;
+ pd->size.w = w;
+ pd->size.h = h;
+ resized = EINA_TRUE;
}
- if (pd->vg_entry && updated)
+ if (pd->vg_entry && (resized || pd->changed))
{
Efl_VG *root = evas_cache_vg_tree_get(pd->vg_entry, pd->frame_idx);
- if (root) _update_scene(obj, pd, root);
+ if (root)
+ {
+ if (resized && !prepared)
+ {
+ _prepare_render_image(obj, pd, engine);
+ prepared = EINA_TRUE;
+ }
+ _update_scene(obj, pd, root);
+ }
}
- if (pd->user_entry && updated) _update_scene(obj, pd, pd->user_entry->root);
+ if (pd->user_entry && (resized || pd->changed))
+ {
+ if (resized && !prepared)
+ {
+ _prepare_render_image(obj, pd, engine);
+ prepared = EINA_TRUE;
+ }
+ _update_scene(obj, pd, pd->user_entry->root);
+ }
//Render the vector canvas
- if (updated)
+ if ((resized || pd->changed) && pd->image)
{
+ DATA32 *pixels = ENFN->tvg_image_acquire(engine, pd->image, NULL);
+
if (tvg_canvas_draw(pd->tvg_canvas) == TVG_RESULT_SUCCESS)
tvg_canvas_sync(pd->tvg_canvas);
+
+ ENFN->tvg_image_release(engine, pd->image, pixels);
+
tvg_canvas_clear(pd->tvg_canvas, EINA_FALSE);
}
- _render_tvg_buffer_to_screen(obj, pd, engine, output, context, surface,
- obj->cur->geometry.x + x + offset.x,
- obj->cur->geometry.y + y + offset.y,
- w, h, do_async);
+ _render_image_to_screen(obj, pd, engine, output, context, surface,
+ obj->cur->geometry.x + x + offset.x,
+ obj->cur->geometry.y + y + offset.y, do_async);
+
pd->changed = EINA_FALSE;
}