*/
#include "default_backend.h"
+#include <limits.h>
pui_backend_ani_func *ani_func = NULL;
Eina_Hash *_animations_hash = NULL;
pui_ani_t *ani = (pui_ani_t *)data;
pui_backend_ani_data *ani_data = NULL;
pui_ani_control_buffer *buffer = NULL;
- double now;
ani_data = pui_backend_ani_get_ani_data(ani);
default_ani_info *ani_info = (default_ani_info *)ani_data->ani_info;
- now = ecore_time_unix_get();
-
- pui_info("[time:%.3f] serial=%d\n", now, serial);
-
/* TODO : make use of ani_info */
(void) ani_info;
_read_json_file(const char *path, int *data_size)
{
FILE *fp = fopen(path, "rb");
- int size;
- char *buffer;
+ int size, ret;
+ char *buffer = NULL;
ERROR_CHECK(fp, return NULL, "Failed to open file: %s\n", path);
- fseek(fp, 0, SEEK_END);
- size = ftell(fp);
- fseek(fp, 0, SEEK_SET);
+ ret = fseek(fp, 0, SEEK_END);
+ ERROR_CHECK(ret == 0, goto error, "Failed to seek file. ret: %d\n", ret);
+ size = (long int)ftell(fp);
+ ERROR_CHECK(0 < size && size < INT_MAX, goto error, "Invalid file: %d size\n", size);
+ ret = fseek(fp, 0, SEEK_SET);
+ ERROR_CHECK(ret == 0, goto error, "Failed to seek file. ret: %d\n", ret);
buffer = (char *)calloc(sizeof(char), size + 1);
+ ERROR_CHECK(buffer, goto error, "Failed to allocate memory for buffer\n");
if (fread(buffer, size, 1, fp) < 1) {
- *data_size = 0;
- free(buffer);
- fclose(fp);
- return NULL;
+ goto error;
}
*data_size = size;
fclose(fp);
return buffer;
+
+error:
+ *data_size = 0;
+ if (buffer) free(buffer);
+ fclose(fp);
+ return NULL;
}
static default_ani_info *
int data_size = 0, i, j;
buffer = _read_json_file(path, &data_size);
- ERROR_CHECK(buffer && data_size > 0, return EINA_FALSE, "File %s has no data\n", path);
+ ERROR_CHECK(buffer && data_size > 0, goto error, "File %s has no data\n", path);
root_obj = json_tokener_parse(buffer);
ERROR_CHECK(root_obj, goto error, "Failed to tokenize json object\n");
//printf("\tframe id: %d\n", json_object_get_int(frame_data_obj));
frame_id = json_object_get_int(frame_data_obj);
+ frame_data_obj = json_object_object_get(frame_obj, "frame_duration");
+ if (frame_data_obj)
+ ani_info->frames[frame_id - 1].frame_duration = json_object_get_int(frame_data_obj);
+ else
+ ani_info->frames[frame_id - 1].frame_duration = ani_info->interval;
+
frame_data_obj = json_object_object_get(frame_obj, "led");
led_len = json_object_array_length(frame_data_obj);
return ani_info;
error:
- free(buffer);
+ if (buffer) free(buffer);
if (ani_info) {
if (ani_info->frames) {
for (i = 0; i < ani_info->num_key_frames; i++) {
return e;
}
+pui_bool
+_geometry_get(int *width, int *height)
+{
+ if (!width || !height)
+ return 0;
+
+ if (width)
+ *width = DEFAULT_BACKEND_GEOM_WIDTH;
+ if (height)
+ *height = DEFAULT_BACKEND_GEOM_HEIGHT;
+
+ return 1;
+}
+
pui_int_error
_is_ani_supported(pui_id id)
{
}
backend_data->create_ani_collection = _create_ani_collection;
+ backend_data->geometry_get = _geometry_get;
backend_data->ani_create = _ani_create;
backend_data->ani_destroy = _ani_destroy;
}
backend_data->create_ani_collection = NULL;
+ backend_data->geometry_get = NULL;
backend_data->ani_create = NULL;
backend_data->ani_destroy = NULL;