#include "evas_common_private.h"
#include "evas_private.h"
-Evas_Canvas3D_File_Eet* eet_file;
-const char EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY[] = "evas_3d file";
-Eet_Data_Descriptor *_vec2_descriptor;
-Eet_Data_Descriptor *_vec3_descriptor;
-Eet_Data_Descriptor *_vertex_descriptor;
-Eet_Data_Descriptor *_geometry_descriptor;
-Eet_Data_Descriptor *_color_descriptor;
-Eet_Data_Descriptor *_material_descriptor;
-Eet_Data_Descriptor *_frame_descriptor;
-Eet_Data_Descriptor *_mesh_descriptor;
-Eet_Data_Descriptor *_header_descriptor;
-Eet_Data_Descriptor *_file_descriptor;
+static Eet_Data_Descriptor *_vec2_descriptor = NULL;
+static Eet_Data_Descriptor *_vec3_descriptor = NULL;
+static Eet_Data_Descriptor *_vertex_descriptor = NULL;
+static Eet_Data_Descriptor *_geometry_descriptor = NULL;
+static Eet_Data_Descriptor *_color_descriptor = NULL;
+static Eet_Data_Descriptor *_material_descriptor = NULL;
+static Eet_Data_Descriptor *_frame_descriptor = NULL;
+static Eet_Data_Descriptor *_mesh_descriptor = NULL;
+static Eet_Data_Descriptor *_header_descriptor = NULL;
+static Eet_Data_Descriptor *_file_descriptor = NULL;
Evas_Canvas3D_File_Eet *
_evas_canvas3d_eet_file_new(void)
return creating_file;
}
+Eet_Data_Descriptor*
+_evas_canvas3d_eet_file_get()
+{
+ if(_file_descriptor == NULL)
+ _evas_canvas3d_eet_file_init();
+
+ return _file_descriptor;
+}
void
-_evas_canvas3d_eet_file_init(void)
+_evas_canvas3d_eet_file_init()
{
eina_init();
eet_init();
"mesh", mesh, _mesh_descriptor);
EET_DATA_DESCRIPTOR_ADD_SUB(_file_descriptor, Evas_Canvas3D_File_Eet,
"header", header, _header_descriptor);
-
}
void
-_evas_canvas3d_eet_descriptor_shutdown(void)
+_evas_canvas3d_eet_descriptor_shutdown()
{
eet_data_descriptor_free(_geometry_descriptor);
+ _geometry_descriptor = NULL;
eet_data_descriptor_free(_vertex_descriptor);
+ _vertex_descriptor = NULL;
eet_data_descriptor_free(_vec2_descriptor);
+ _vec2_descriptor = NULL;
eet_data_descriptor_free(_vec3_descriptor);
+ _vec3_descriptor = NULL;
eet_data_descriptor_free(_color_descriptor);
+ _color_descriptor = NULL;
eet_data_descriptor_free(_material_descriptor);
+ _material_descriptor = NULL;
eet_data_descriptor_free(_frame_descriptor);
+ _frame_descriptor = NULL;
eet_data_descriptor_free(_mesh_descriptor);
+ _mesh_descriptor = NULL;
eet_data_descriptor_free(_header_descriptor);
+ _header_descriptor = NULL;
eet_data_descriptor_free(_file_descriptor);
+ _file_descriptor = NULL;
}
void
-_evas_canvas3d_eet_file_free(void)
+_evas_canvas3d_eet_file_free(Evas_Canvas3D_File_Eet* eet_file)
{
- free(eet_file->mesh->geometries[0].vertices);
- free(eet_file->mesh->geometries);
- free(eet_file->mesh->frames);
- free(eet_file->mesh->materials[0].colors);
- free(eet_file->mesh->materials);
- free(eet_file->mesh);
- free(eet_file->header->materials);
- free(eet_file->header->geometries);
- free(eet_file->header);
- free(eet_file);
+ if (eet_file->mesh)
+ {
+ free(eet_file->mesh->geometries[0].vertices);
+ free(eet_file->mesh->geometries);
+ free(eet_file->mesh->frames);
+ free(eet_file->mesh->materials[0].colors);
+ free(eet_file->mesh->materials);
+ free(eet_file->mesh);
+ }
+ if (eet_file->header)
+ {
+ free(eet_file->header->materials);
+ free(eet_file->header->geometries);
+ free(eet_file->header);
+ }
+
+ free(eet_file);
+ eet_file = NULL;
_evas_canvas3d_eet_descriptor_shutdown();
eet_shutdown();
eina_shutdown();
#include "evas_common_private.h"
#include "evas_private.h"
-extern Evas_Canvas3D_File_Eet* eet_file;
-extern const char EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY[];
-extern Eet_Data_Descriptor *_file_descriptor;
-
void
_set_geometry_to_mesh_from_eet_file(Evas_Canvas3D_Mesh *mesh,
Evas_Canvas3D_Mesh_Eet *eet_mesh)
evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file)
{
Eet_File *ef;
+ Evas_Canvas3D_File_Eet* eet_file;
+ Eet_Data_Descriptor *_file_descriptor;
+
- _evas_canvas3d_eet_file_init();
+ _file_descriptor = _evas_canvas3d_eet_file_get();
ef = eet_mmap(file);
eet_file = eet_data_read(ef,
_file_descriptor,
if ((eet_file->mesh == NULL) || (eet_file->header == NULL))
{
ERR("Reading of file is failed.");
- _evas_canvas3d_eet_file_free();
+ _evas_canvas3d_eet_file_free(eet_file);
return;
}
_set_geometry_to_mesh_from_eet_file(mesh, eet_file->mesh);
_set_material_to_mesh_from_eet_file(mesh, eet_file->mesh);
- _evas_canvas3d_eet_file_free();
+ _evas_canvas3d_eet_file_free(eet_file);
}
#define COMPONENT_OF_DEFAULT_GREY_COLOR 0.3
#define TRANSPARENCY_OF_DEFAULT_GREY_COLOR 0.5
-extern Evas_Canvas3D_File_Eet* eet_file;
-extern const char EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY[];
-extern Eet_Data_Descriptor *_file_descriptor;
-
void
_set_geometry_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Data *mesh,
Evas_Canvas3D_Mesh_Eet *eet_mesh,
Eet_File *ef = eet_open(file, EET_FILE_MODE_WRITE);
Evas_Canvas3D_Mesh_Eet* eet_mesh = malloc(sizeof(Evas_Canvas3D_Mesh_Eet));
Evas_Canvas3D_Header_Eet* eet_header = malloc(sizeof(Evas_Canvas3D_Header_Eet));
+ Eet_Data_Descriptor *_file_descriptor;
+ Evas_Canvas3D_File_Eet *eet_file;
- _evas_canvas3d_eet_file_init();
+ _file_descriptor = _evas_canvas3d_eet_file_get();
eet_file = _evas_canvas3d_eet_file_new();
ERR("Opening of file is failed.");
free(eet_mesh);
free(eet_header);
- _evas_canvas3d_eet_file_free();
+ _evas_canvas3d_eet_file_free(eet_file);
return;
}
EINA_TRUE);
eet_close(ef);
- _evas_canvas3d_eet_file_free();
+ _evas_canvas3d_eet_file_free(eet_file);
}