diff options
author | Mike Blumenkrantz <zmike@samsung.com> | 2019-02-27 13:17:09 -0500 |
---|---|---|
committer | Mike Blumenkrantz <zmike@samsung.com> | 2019-02-27 13:17:10 -0500 |
commit | 6326e18b3fb2a4757f8ffa22be5d55a75da23049 (patch) | |
tree | 31d586b52638aa0d0b1c759869a8e3368c9daf5d /src/lib/emotion/emotion_smart.c | |
parent | 7924660d54500285d3844bfa384394c683825cd9 (diff) |
efl.file: improve api a bit
Summary:
the previous implementation/api had a number of issues:
* "file" property contained both "file" and "key" values
- also performed file loading operation
* "load_error" property which was specific to image objects
* no methods for controlling file loading/unloading
this patch attempts the following changes:
* split "file" property into "file" and "key" properties
- also remove "key" from existing "mmap" property
* remove "load_error"
* directly return error codes from operations
* add "load" and "unload" methods for directly controlling load state
* add implicit file loading if file/mmap is set during construction
* rewrite all efl.file implementations to move file loading into load() method
* rewrite all usage of efl.file api based on these changes
* add C extension functions to mimic previous behavior
ref T7577
Reviewers: segfaultxavi, bu5hm4n, cedric
Reviewed By: segfaultxavi
Subscribers: vitor.sousa, #reviewers, #committers
Tags: #efl_api
Maniphest Tasks: T7577
Differential Revision: https://phab.enlightenment.org/D8018
Diffstat (limited to '')
-rw-r--r-- | src/lib/emotion/emotion_smart.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/lib/emotion/emotion_smart.c b/src/lib/emotion/emotion_smart.c index ed5eb36f34..06c95bf15b 100644 --- a/src/lib/emotion/emotion_smart.c +++ b/src/lib/emotion/emotion_smart.c | |||
@@ -119,6 +119,7 @@ struct _Efl_Canvas_Video_Data | |||
119 | Eina_Bool remember_play : 1; | 119 | Eina_Bool remember_play : 1; |
120 | Eina_Bool seek : 1; | 120 | Eina_Bool seek : 1; |
121 | Eina_Bool seeking : 1; | 121 | Eina_Bool seeking : 1; |
122 | Eina_Bool loaded : 1; | ||
122 | }; | 123 | }; |
123 | 124 | ||
124 | struct _Emotion_Xattr_Data | 125 | struct _Emotion_Xattr_Data |
@@ -344,21 +345,34 @@ _efl_canvas_video_engine_set(Eo *obj, Efl_Canvas_Video_Data *pd, const char *eng | |||
344 | EAPI Eina_Bool | 345 | EAPI Eina_Bool |
345 | emotion_object_file_set(Evas_Object *obj, const char *file) | 346 | emotion_object_file_set(Evas_Object *obj, const char *file) |
346 | { | 347 | { |
347 | return efl_file_set(obj, file, NULL); | 348 | return efl_file_simple_load(obj, file, NULL); |
348 | } | 349 | } |
349 | 350 | ||
350 | EOLIAN static Eina_Bool | 351 | EOLIAN static Eina_Error |
351 | _efl_canvas_video_efl_file_file_set(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd, const char *file, const char *key EINA_UNUSED) | 352 | _efl_canvas_video_efl_file_file_set(Eo *obj, Efl_Canvas_Video_Data *sd, const char *file) |
352 | { | 353 | { |
353 | DBG("file=%s", file); | 354 | DBG("file=%s", file); |
354 | 355 | ||
355 | if (!eina_stringshare_replace(&sd->file, file)) return EINA_TRUE; | 356 | eina_stringshare_replace(&sd->file, file); |
357 | sd->loaded = 0; | ||
358 | return efl_file_set(efl_super(obj, MY_CLASS), file); | ||
359 | } | ||
356 | 360 | ||
361 | EOLIAN static Eina_Bool | ||
362 | _efl_canvas_video_efl_file_loaded_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd) | ||
363 | { | ||
364 | return sd->open && sd->loaded; | ||
365 | } | ||
366 | |||
367 | EOLIAN static Eina_Error | ||
368 | _efl_canvas_video_efl_file_load(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd) | ||
369 | { | ||
370 | const char *file = sd->file; | ||
357 | if (!sd->engine_instance) _engine_init(obj, sd); | 371 | if (!sd->engine_instance) _engine_init(obj, sd); |
358 | if (!sd->engine_instance) | 372 | if (!sd->engine_instance) |
359 | { | 373 | { |
360 | WRN("No engine chosen. Please set an engine."); | 374 | WRN("No engine chosen. Please set an engine."); |
361 | return EINA_FALSE; | 375 | return EFL_GFX_IMAGE_LOAD_ERROR_GENERIC; |
362 | } | 376 | } |
363 | 377 | ||
364 | sd->video.w = 0; | 378 | sd->video.w = 0; |
@@ -367,7 +381,6 @@ _efl_canvas_video_efl_file_file_set(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data * | |||
367 | { | 381 | { |
368 | char *file2 = NULL; | 382 | char *file2 = NULL; |
369 | 383 | ||
370 | eina_stringshare_replace(&sd->file, file); | ||
371 | emotion_engine_instance_file_close(sd->engine_instance); | 384 | emotion_engine_instance_file_close(sd->engine_instance); |
372 | evas_object_image_data_set(sd->obj, NULL); | 385 | evas_object_image_data_set(sd->obj, NULL); |
373 | evas_object_image_size_set(sd->obj, 1, 1); | 386 | evas_object_image_size_set(sd->obj, 1, 1); |
@@ -382,7 +395,7 @@ _efl_canvas_video_efl_file_file_set(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data * | |||
382 | if (!emotion_engine_instance_file_open(sd->engine_instance, file2)) | 395 | if (!emotion_engine_instance_file_open(sd->engine_instance, file2)) |
383 | { | 396 | { |
384 | WRN("Couldn't open file=%s", sd->file); | 397 | WRN("Couldn't open file=%s", sd->file); |
385 | return EINA_FALSE; | 398 | return EFL_GFX_IMAGE_LOAD_ERROR_GENERIC; |
386 | } | 399 | } |
387 | free(file2); | 400 | free(file2); |
388 | DBG("successfully opened file=%s", sd->file); | 401 | DBG("successfully opened file=%s", sd->file); |
@@ -402,23 +415,15 @@ _efl_canvas_video_efl_file_file_set(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data * | |||
402 | sd->anim = NULL; | 415 | sd->anim = NULL; |
403 | 416 | ||
404 | _xattr_data_cancel(sd->xattr); | 417 | _xattr_data_cancel(sd->xattr); |
418 | sd->loaded = 1; | ||
405 | 419 | ||
406 | return EINA_TRUE; | 420 | return 0; |
407 | } | 421 | } |
408 | 422 | ||
409 | EAPI const char * | 423 | EAPI const char * |
410 | emotion_object_file_get(const Evas_Object *obj) | 424 | emotion_object_file_get(const Evas_Object *obj) |
411 | { | 425 | { |
412 | const char *file = NULL; | 426 | return efl_file_get(obj); |
413 | efl_file_get(obj, &file, NULL); | ||
414 | return file; | ||
415 | } | ||
416 | |||
417 | EOLIAN static void | ||
418 | _efl_canvas_video_efl_file_file_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd, const char **file, const char **key) | ||
419 | { | ||
420 | if (file) *file = sd->file; | ||
421 | if (key) *key = NULL; | ||
422 | } | 427 | } |
423 | 428 | ||
424 | static void | 429 | static void |