summaryrefslogtreecommitdiff
path: root/src/lib/evas
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2017-10-27 09:15:28 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-10-27 14:58:38 +0900
commitad4e133e08cc9e9ab327efed58b5ca36b17156b5 (patch)
tree4e7584150d0d3c0ac686572a0682e595dd3cdf9e /src/lib/evas
parent64231ae699858b34d65f6e27d665a1411ff1bcf0 (diff)
evas/vg: Added file handling support in vg canvas.
Diffstat (limited to 'src/lib/evas')
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg.c83
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg.eo4
2 files changed, 85 insertions, 2 deletions
diff --git a/src/lib/evas/canvas/efl_canvas_vg.c b/src/lib/evas/canvas/efl_canvas_vg.c
index e54875642d..15d0eb21b9 100644
--- a/src/lib/evas/canvas/efl_canvas_vg.c
+++ b/src/lib/evas/canvas/efl_canvas_vg.c
@@ -1,3 +1,5 @@
1#define EVAS_VG_BETA
2
1#include "evas_common_private.h" 3#include "evas_common_private.h"
2#include "evas_private.h" 4#include "evas_private.h"
3 5
@@ -133,6 +135,10 @@ evas_object_vg_add(Evas *e)
133EOLIAN static Efl_VG * 135EOLIAN static Efl_VG *
134_efl_canvas_vg_root_node_get(Eo *obj EINA_UNUSED, Efl_Canvas_Vg_Data *pd) 136_efl_canvas_vg_root_node_get(Eo *obj EINA_UNUSED, Efl_Canvas_Vg_Data *pd)
135{ 137{
138 if (pd->vg_entry)
139 {
140 return evas_cache_vg_tree_get(pd->vg_entry);
141 }
136 return pd->vg_tree; 142 return pd->vg_tree;
137} 143}
138 144
@@ -143,6 +149,13 @@ _efl_canvas_vg_root_node_set(Eo *obj EINA_UNUSED, Efl_Canvas_Vg_Data *pd, Efl_VG
143 if (pd->vg_tree == root_node) 149 if (pd->vg_tree == root_node)
144 return; 150 return;
145 151
152 // check if a file has been already set
153 if (pd->vg_entry)
154 {
155 evas_cache_vg_entry_del(pd->vg_entry);
156 pd->vg_entry = NULL;
157 }
158
146 // detach/free the old root_node 159 // detach/free the old root_node
147 if (pd->vg_tree) 160 if (pd->vg_tree)
148 efl_parent_set(pd->vg_tree, NULL); 161 efl_parent_set(pd->vg_tree, NULL);
@@ -226,6 +239,62 @@ _efl_canvas_vg_viewbox_align_get(Eo *obj EINA_UNUSED, Efl_Canvas_Vg_Data *pd, do
226 if (align_y) *align_y = pd->align_y; 239 if (align_y) *align_y = pd->align_y;
227} 240}
228 241
242// file set and save api implementation
243
244EOLIAN static Eina_Bool
245_efl_canvas_vg_efl_file_file_set(Eo *obj, Efl_Canvas_Vg_Data *pd, const char *file, const char *key)
246{
247 int w, h;
248 Evas_Cache_Vg_Entry *entry;
249
250 if (!file) return EINA_FALSE;
251
252 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
253 entry = evas_cache_vg_entry_find(file, key, w, h);
254 if (entry != pd->vg_entry)
255 {
256 if (pd->vg_entry)
257 {
258 evas_cache_vg_entry_del(pd->vg_entry);
259 }
260 pd->vg_entry = entry;
261 }
262 evas_object_change(obj, efl_data_scope_get(obj, EFL_CANVAS_OBJECT_CLASS));
263 return EINA_TRUE;
264}
265
266EOLIAN static void
267_efl_canvas_vg_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_Canvas_Vg_Data *pd, const char **file, const char **key)
268{
269 if (pd->vg_entry)
270 {
271 if (file) *file = pd->vg_entry->file;
272 if (key) *key = pd->vg_entry->key;
273 }
274}
275
276EOLIAN static Eina_Bool
277_efl_canvas_vg_efl_file_save(const Eo *obj, Efl_Canvas_Vg_Data *pd, const char *file, const char *key, const char *flags)
278{
279 Vg_File_Data tmp;
280 Vg_File_Data *info = &tmp;
281
282 if (pd->vg_entry && pd->vg_entry->file)
283 {
284 info = evas_cache_vg_file_info(pd->vg_entry->file, pd->vg_entry->key);
285 }
286 else
287 {
288 info->view_box.x = 0;
289 info->view_box.y = 0;
290 evas_object_geometry_get(obj, NULL, NULL, &info->view_box.w, &info->view_box.h);
291 info->root = pd->root;
292 info->preserve_aspect = EINA_FALSE;
293 }
294 evas_vg_save_to_file(info, file, key, flags);
295 return EINA_TRUE;
296}
297
229static void 298static void
230_cleanup_reference(void *data, const Efl_Event *event EINA_UNUSED) 299_cleanup_reference(void *data, const Efl_Event *event EINA_UNUSED)
231{ 300{
@@ -327,6 +396,7 @@ _efl_canvas_vg_render(Evas_Object *eo_obj EINA_UNUSED,
327 int x, int y, Eina_Bool do_async) 396 int x, int y, Eina_Bool do_async)
328{ 397{
329 Efl_Canvas_Vg_Data *vd = type_private_data; 398 Efl_Canvas_Vg_Data *vd = type_private_data;
399 Efl_VG *root = NULL;
330 Ector_Surface *ector = evas_ector_get(obj->layer->evas); 400 Ector_Surface *ector = evas_ector_get(obj->layer->evas);
331 401
332 obj->layer->evas->engine.func->ector_output_set(engine, surface, output); 402 obj->layer->evas->engine.func->ector_output_set(engine, surface, output);
@@ -351,6 +421,17 @@ _efl_canvas_vg_render(Evas_Object *eo_obj EINA_UNUSED,
351 obj->cur->anti_alias); 421 obj->cur->anti_alias);
352 obj->layer->evas->engine.func->context_render_op_set(engine, context, 422 obj->layer->evas->engine.func->context_render_op_set(engine, context,
353 obj->cur->render_op); 423 obj->cur->render_op);
424 if (vd->vg_entry)
425 {
426 root = evas_cache_vg_tree_get(vd->vg_entry);
427 if (!root) return;
428 _evas_vg_render_pre(root, ector, NULL);
429 }
430 else
431 {
432 root = vd->root;
433 }
434 //obj->layer->evas->engine.func->ector_begin(output, context,
354 obj->layer->evas->engine.func->ector_begin(engine, context, 435 obj->layer->evas->engine.func->ector_begin(engine, context,
355 ector, surface, 436 ector, surface,
356 vd->engine_data, 437 vd->engine_data,
@@ -358,7 +439,7 @@ _efl_canvas_vg_render(Evas_Object *eo_obj EINA_UNUSED,
358 do_async); 439 do_async);
359 _evas_vg_render(obj, vd, 440 _evas_vg_render(obj, vd,
360 engine, output, context, surface, 441 engine, output, context, surface,
361 vd->root, NULL, 442 root, NULL,
362 do_async); 443 do_async);
363 obj->layer->evas->engine.func->ector_end(engine, context, ector, surface, vd->engine_data, do_async); 444 obj->layer->evas->engine.func->ector_end(engine, context, ector, surface, vd->engine_data, do_async);
364 445
diff --git a/src/lib/evas/canvas/efl_canvas_vg.eo b/src/lib/evas/canvas/efl_canvas_vg.eo
index 27826af620..c9fee6dd10 100644
--- a/src/lib/evas/canvas/efl_canvas_vg.eo
+++ b/src/lib/evas/canvas/efl_canvas_vg.eo
@@ -21,7 +21,7 @@ enum Efl.Canvas.Vg.Fill_Mode
21 dimension of the viewport.]] 21 dimension of the viewport.]]
22} 22}
23 23
24class Efl.Canvas.Vg (Efl.Canvas.Object) 24class Efl.Canvas.Vg (Efl.Canvas.Object, Efl.File)
25{ 25{
26 [[Efl vector graphics class]] 26 [[Efl vector graphics class]]
27 legacy_prefix: evas_object_vg; 27 legacy_prefix: evas_object_vg;
@@ -73,5 +73,7 @@ class Efl.Canvas.Vg (Efl.Canvas.Object)
73 Efl.Object.constructor; 73 Efl.Object.constructor;
74 Efl.Object.finalize; 74 Efl.Object.finalize;
75 Efl.Object.destructor; 75 Efl.Object.destructor;
76 Efl.File.file { get; set; }
77 Efl.File.save;
76 } 78 }
77} 79}