summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_eet.c75
-rw-r--r--src/lib/evas/include/evas_common_private.h3
-rw-r--r--src/lib/evas/include/evas_private.h8
-rw-r--r--src/modules/evas/model_loaders/eet/evas_model_load_eet.c13
-rw-r--r--src/modules/evas/model_savers/eet/evas_model_save_eet.c12
5 files changed, 68 insertions, 43 deletions
diff --git a/src/lib/evas/canvas/evas_canvas3d_eet.c b/src/lib/evas/canvas/evas_canvas3d_eet.c
index 281f69da82..aed6512cb2 100644
--- a/src/lib/evas/canvas/evas_canvas3d_eet.c
+++ b/src/lib/evas/canvas/evas_canvas3d_eet.c
@@ -2,18 +2,16 @@
2#include "evas_common_private.h" 2#include "evas_common_private.h"
3#include "evas_private.h" 3#include "evas_private.h"
4 4
5Evas_Canvas3D_File_Eet* eet_file; 5static Eet_Data_Descriptor *_vec2_descriptor = NULL;
6const char EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY[] = "evas_3d file"; 6static Eet_Data_Descriptor *_vec3_descriptor = NULL;
7Eet_Data_Descriptor *_vec2_descriptor; 7static Eet_Data_Descriptor *_vertex_descriptor = NULL;
8Eet_Data_Descriptor *_vec3_descriptor; 8static Eet_Data_Descriptor *_geometry_descriptor = NULL;
9Eet_Data_Descriptor *_vertex_descriptor; 9static Eet_Data_Descriptor *_color_descriptor = NULL;
10Eet_Data_Descriptor *_geometry_descriptor; 10static Eet_Data_Descriptor *_material_descriptor = NULL;
11Eet_Data_Descriptor *_color_descriptor; 11static Eet_Data_Descriptor *_frame_descriptor = NULL;
12Eet_Data_Descriptor *_material_descriptor; 12static Eet_Data_Descriptor *_mesh_descriptor = NULL;
13Eet_Data_Descriptor *_frame_descriptor; 13static Eet_Data_Descriptor *_header_descriptor = NULL;
14Eet_Data_Descriptor *_mesh_descriptor; 14static Eet_Data_Descriptor *_file_descriptor = NULL;
15Eet_Data_Descriptor *_header_descriptor;
16Eet_Data_Descriptor *_file_descriptor;
17 15
18Evas_Canvas3D_File_Eet * 16Evas_Canvas3D_File_Eet *
19_evas_canvas3d_eet_file_new(void) 17_evas_canvas3d_eet_file_new(void)
@@ -29,8 +27,16 @@ _evas_canvas3d_eet_file_new(void)
29 return creating_file; 27 return creating_file;
30} 28}
31 29
30Eet_Data_Descriptor*
31_evas_canvas3d_eet_file_get()
32{
33 if(_file_descriptor == NULL)
34 _evas_canvas3d_eet_file_init();
35
36 return _file_descriptor;
37}
32void 38void
33_evas_canvas3d_eet_file_init(void) 39_evas_canvas3d_eet_file_init()
34{ 40{
35 eina_init(); 41 eina_init();
36 eet_init(); 42 eet_init();
@@ -153,38 +159,55 @@ _evas_canvas3d_eet_file_init(void)
153 "mesh", mesh, _mesh_descriptor); 159 "mesh", mesh, _mesh_descriptor);
154 EET_DATA_DESCRIPTOR_ADD_SUB(_file_descriptor, Evas_Canvas3D_File_Eet, 160 EET_DATA_DESCRIPTOR_ADD_SUB(_file_descriptor, Evas_Canvas3D_File_Eet,
155 "header", header, _header_descriptor); 161 "header", header, _header_descriptor);
156
157} 162}
158 163
159void 164void
160_evas_canvas3d_eet_descriptor_shutdown(void) 165_evas_canvas3d_eet_descriptor_shutdown()
161{ 166{
162 eet_data_descriptor_free(_geometry_descriptor); 167 eet_data_descriptor_free(_geometry_descriptor);
168 _geometry_descriptor = NULL;
163 eet_data_descriptor_free(_vertex_descriptor); 169 eet_data_descriptor_free(_vertex_descriptor);
170 _vertex_descriptor = NULL;
164 eet_data_descriptor_free(_vec2_descriptor); 171 eet_data_descriptor_free(_vec2_descriptor);
172 _vec2_descriptor = NULL;
165 eet_data_descriptor_free(_vec3_descriptor); 173 eet_data_descriptor_free(_vec3_descriptor);
174 _vec3_descriptor = NULL;
166 eet_data_descriptor_free(_color_descriptor); 175 eet_data_descriptor_free(_color_descriptor);
176 _color_descriptor = NULL;
167 eet_data_descriptor_free(_material_descriptor); 177 eet_data_descriptor_free(_material_descriptor);
178 _material_descriptor = NULL;
168 eet_data_descriptor_free(_frame_descriptor); 179 eet_data_descriptor_free(_frame_descriptor);
180 _frame_descriptor = NULL;
169 eet_data_descriptor_free(_mesh_descriptor); 181 eet_data_descriptor_free(_mesh_descriptor);
182 _mesh_descriptor = NULL;
170 eet_data_descriptor_free(_header_descriptor); 183 eet_data_descriptor_free(_header_descriptor);
184 _header_descriptor = NULL;
171 eet_data_descriptor_free(_file_descriptor); 185 eet_data_descriptor_free(_file_descriptor);
186 _file_descriptor = NULL;
172} 187}
173 188
174void 189void
175_evas_canvas3d_eet_file_free(void) 190_evas_canvas3d_eet_file_free(Evas_Canvas3D_File_Eet* eet_file)
176{ 191{
177 free(eet_file->mesh->geometries[0].vertices); 192 if (eet_file->mesh)
178 free(eet_file->mesh->geometries); 193 {
179 free(eet_file->mesh->frames); 194 free(eet_file->mesh->geometries[0].vertices);
180 free(eet_file->mesh->materials[0].colors); 195 free(eet_file->mesh->geometries);
181 free(eet_file->mesh->materials); 196 free(eet_file->mesh->frames);
182 free(eet_file->mesh); 197 free(eet_file->mesh->materials[0].colors);
183 free(eet_file->header->materials); 198 free(eet_file->mesh->materials);
184 free(eet_file->header->geometries); 199 free(eet_file->mesh);
185 free(eet_file->header); 200 }
186 free(eet_file);
187 201
202 if (eet_file->header)
203 {
204 free(eet_file->header->materials);
205 free(eet_file->header->geometries);
206 free(eet_file->header);
207 }
208
209 free(eet_file);
210 eet_file = NULL;
188 _evas_canvas3d_eet_descriptor_shutdown(); 211 _evas_canvas3d_eet_descriptor_shutdown();
189 eet_shutdown(); 212 eet_shutdown();
190 eina_shutdown(); 213 eina_shutdown();
diff --git a/src/lib/evas/include/evas_common_private.h b/src/lib/evas/include/evas_common_private.h
index f7deaa7f42..cf29f2d345 100644
--- a/src/lib/evas/include/evas_common_private.h
+++ b/src/lib/evas/include/evas_common_private.h
@@ -90,6 +90,9 @@
90#define lround(x) (((x) < 0) ? (long int)ceil((x) - 0.5) : (long int)floor((x) + 0.5)) 90#define lround(x) (((x) < 0) ? (long int)ceil((x) - 0.5) : (long int)floor((x) + 0.5))
91#endif 91#endif
92 92
93/*macro to be used in eet loader/saver*/
94#define EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY "evas_3d file"
95
93/* macros needed to log message through eina_log */ 96/* macros needed to log message through eina_log */
94extern EAPI int _evas_log_dom_global; 97extern EAPI int _evas_log_dom_global;
95#ifdef _EVAS_DEFAULT_LOG_DOM 98#ifdef _EVAS_DEFAULT_LOG_DOM
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index 5ef176f3bc..b6f8c89d63 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1784,9 +1784,11 @@ void evas_canvas3d_scene_data_fini(Evas_Canvas3D_Scene_Public_Data *data);
1784 1784
1785/* Eet saver/loader functions */ 1785/* Eet saver/loader functions */
1786Evas_Canvas3D_File_Eet *_evas_canvas3d_eet_file_new(void); 1786Evas_Canvas3D_File_Eet *_evas_canvas3d_eet_file_new(void);
1787void _evas_canvas3d_eet_file_init(void); 1787Eet_Data_Descriptor* _evas_canvas3d_eet_file_get();
1788void _evas_canvas3d_eet_descriptor_shutdown(void); 1788void _evas_canvas3d_eet_file_init();
1789void _evas_canvas3d_eet_file_free(void); 1789void _evas_canvas3d_eet_descriptor_shutdown();
1790void _evas_canvas3d_eet_file_free(Evas_Canvas3D_File_Eet* eet_file);
1791
1790 1792
1791/* Filters */ 1793/* Filters */
1792void evas_filter_init(void); 1794void evas_filter_init(void);
diff --git a/src/modules/evas/model_loaders/eet/evas_model_load_eet.c b/src/modules/evas/model_loaders/eet/evas_model_load_eet.c
index a36dff4f34..f5b1b6b8ca 100644
--- a/src/modules/evas/model_loaders/eet/evas_model_load_eet.c
+++ b/src/modules/evas/model_loaders/eet/evas_model_load_eet.c
@@ -7,10 +7,6 @@
7#include "evas_common_private.h" 7#include "evas_common_private.h"
8#include "evas_private.h" 8#include "evas_private.h"
9 9
10extern Evas_Canvas3D_File_Eet* eet_file;
11extern const char EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY[];
12extern Eet_Data_Descriptor *_file_descriptor;
13
14void 10void
15_set_geometry_to_mesh_from_eet_file(Evas_Canvas3D_Mesh *mesh, 11_set_geometry_to_mesh_from_eet_file(Evas_Canvas3D_Mesh *mesh,
16 Evas_Canvas3D_Mesh_Eet *eet_mesh) 12 Evas_Canvas3D_Mesh_Eet *eet_mesh)
@@ -107,8 +103,11 @@ void
107evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file) 103evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file)
108{ 104{
109 Eet_File *ef; 105 Eet_File *ef;
106 Evas_Canvas3D_File_Eet* eet_file;
107 Eet_Data_Descriptor *_file_descriptor;
108
110 109
111 _evas_canvas3d_eet_file_init(); 110 _file_descriptor = _evas_canvas3d_eet_file_get();
112 ef = eet_mmap(file); 111 ef = eet_mmap(file);
113 eet_file = eet_data_read(ef, 112 eet_file = eet_data_read(ef,
114 _file_descriptor, 113 _file_descriptor,
@@ -119,14 +118,14 @@ evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file)
119 if ((eet_file->mesh == NULL) || (eet_file->header == NULL)) 118 if ((eet_file->mesh == NULL) || (eet_file->header == NULL))
120 { 119 {
121 ERR("Reading of file is failed."); 120 ERR("Reading of file is failed.");
122 _evas_canvas3d_eet_file_free(); 121 _evas_canvas3d_eet_file_free(eet_file);
123 return; 122 return;
124 } 123 }
125 124
126 _set_geometry_to_mesh_from_eet_file(mesh, eet_file->mesh); 125 _set_geometry_to_mesh_from_eet_file(mesh, eet_file->mesh);
127 _set_material_to_mesh_from_eet_file(mesh, eet_file->mesh); 126 _set_material_to_mesh_from_eet_file(mesh, eet_file->mesh);
128 127
129 _evas_canvas3d_eet_file_free(); 128 _evas_canvas3d_eet_file_free(eet_file);
130} 129}
131 130
132 131
diff --git a/src/modules/evas/model_savers/eet/evas_model_save_eet.c b/src/modules/evas/model_savers/eet/evas_model_save_eet.c
index ff43a3f851..0ac7e66e44 100644
--- a/src/modules/evas/model_savers/eet/evas_model_save_eet.c
+++ b/src/modules/evas/model_savers/eet/evas_model_save_eet.c
@@ -9,10 +9,6 @@
9#define COMPONENT_OF_DEFAULT_GREY_COLOR 0.3 9#define COMPONENT_OF_DEFAULT_GREY_COLOR 0.3
10#define TRANSPARENCY_OF_DEFAULT_GREY_COLOR 0.5 10#define TRANSPARENCY_OF_DEFAULT_GREY_COLOR 0.5
11 11
12extern Evas_Canvas3D_File_Eet* eet_file;
13extern const char EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY[];
14extern Eet_Data_Descriptor *_file_descriptor;
15
16void 12void
17_set_geometry_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Data *mesh, 13_set_geometry_to_eet_file_from_mesh(Evas_Canvas3D_Mesh_Data *mesh,
18 Evas_Canvas3D_Mesh_Eet *eet_mesh, 14 Evas_Canvas3D_Mesh_Eet *eet_mesh,
@@ -154,8 +150,10 @@ evas_model_save_file_eet(const Evas_Canvas3D_Mesh *mesh,
154 Eet_File *ef = eet_open(file, EET_FILE_MODE_WRITE); 150 Eet_File *ef = eet_open(file, EET_FILE_MODE_WRITE);
155 Evas_Canvas3D_Mesh_Eet* eet_mesh = malloc(sizeof(Evas_Canvas3D_Mesh_Eet)); 151 Evas_Canvas3D_Mesh_Eet* eet_mesh = malloc(sizeof(Evas_Canvas3D_Mesh_Eet));
156 Evas_Canvas3D_Header_Eet* eet_header = malloc(sizeof(Evas_Canvas3D_Header_Eet)); 152 Evas_Canvas3D_Header_Eet* eet_header = malloc(sizeof(Evas_Canvas3D_Header_Eet));
153 Eet_Data_Descriptor *_file_descriptor;
154 Evas_Canvas3D_File_Eet *eet_file;
157 155
158 _evas_canvas3d_eet_file_init(); 156 _file_descriptor = _evas_canvas3d_eet_file_get();
159 157
160 eet_file = _evas_canvas3d_eet_file_new(); 158 eet_file = _evas_canvas3d_eet_file_new();
161 159
@@ -176,7 +174,7 @@ evas_model_save_file_eet(const Evas_Canvas3D_Mesh *mesh,
176 ERR("Opening of file is failed."); 174 ERR("Opening of file is failed.");
177 free(eet_mesh); 175 free(eet_mesh);
178 free(eet_header); 176 free(eet_header);
179 _evas_canvas3d_eet_file_free(); 177 _evas_canvas3d_eet_file_free(eet_file);
180 return; 178 return;
181 } 179 }
182 180
@@ -190,6 +188,6 @@ evas_model_save_file_eet(const Evas_Canvas3D_Mesh *mesh,
190 EINA_TRUE); 188 EINA_TRUE);
191 eet_close(ef); 189 eet_close(ef);
192 190
193 _evas_canvas3d_eet_file_free(); 191 _evas_canvas3d_eet_file_free(eet_file);
194} 192}
195 193