summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-06-18 17:55:44 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-07-03 11:37:48 +0900
commitc42415386734b71cef0efcbc6575b6e8c7ba8dbf (patch)
treeec238753add1d2f2e065fb89f1bf91077dc17c3e /src
parente239f8f4deb183103f7cabeb00a83f44b4f92393 (diff)
Evas: Add DDS image file loader
@feature: Add a Micrsoft DirectDraw Surface file loader
Diffstat (limited to '')
-rw-r--r--src/Makefile_Evas.am27
-rw-r--r--src/lib/evas/file/evas_module.c4
-rw-r--r--src/modules/evas/loaders/dds/evas_image_load_dds.c153
3 files changed, 184 insertions, 0 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 764cfca5ad..bc1a65f679 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -1372,6 +1372,33 @@ modules_evas_loaders_bmp_module_la_LIBTOOLFLAGS = --tag=disable-static
1372endif 1372endif
1373endif 1373endif
1374 1374
1375if BUILD_LOADER_DDS
1376if EVAS_STATIC_BUILD_DDS
1377lib_evas_libevas_la_SOURCES += modules/evas/loaders/dds/evas_image_load_dds.c
1378lib_evas_libevas_la_CPPFLAGS += @evas_image_loader_dds_cflags@
1379lib_evas_libevas_la_LIBADD += @evas_image_loader_dds_libs@
1380if EVAS_CSERVE2
1381bin_evas_evas_cserve2_slave_SOURCES += modules/evas/loaders/dds/evas_image_load_dds.c
1382bin_evas_evas_cserve2_slave_CPPFLAGS += @evas_image_loader_dds_cflags@
1383bin_evas_evas_cserve2_slave_LDADD += @evas_image_loader_dds_libs@
1384endif
1385else
1386loaderddspkgdir = $(libdir)/evas/modules/loaders/dds/$(MODULE_ARCH)
1387loaderddspkg_LTLIBRARIES = modules/evas/loaders/dds/module.la
1388modules_evas_loaders_dds_module_la_SOURCES = modules/evas/loaders/dds/evas_image_load_dds.c
1389modules_evas_loaders_dds_module_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
1390-I$(top_srcdir)/src/lib/evas/include \
1391@EVAS_CFLAGS@ \
1392@evas_image_loader_dds_cflags@
1393modules_evas_loaders_dds_module_la_LIBADD = \
1394@USE_EVAS_LIBS@ \
1395@evas_image_loader_dds_libs@
1396modules_evas_loaders_dds_module_la_DEPENDENCIES = @USE_EVAS_INTERNAL_LIBS@
1397modules_evas_loaders_dds_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@
1398modules_evas_loaders_dds_module_la_LIBTOOLFLAGS = --tag=disable-static
1399endif
1400endif
1401
1375if BUILD_LOADER_EET 1402if BUILD_LOADER_EET
1376if EVAS_STATIC_BUILD_EET 1403if EVAS_STATIC_BUILD_EET
1377lib_evas_libevas_la_SOURCES += modules/evas/loaders/eet/evas_image_load_eet.c modules/evas/savers/eet/evas_image_save_eet.c 1404lib_evas_libevas_la_SOURCES += modules/evas/loaders/eet/evas_image_load_eet.c modules/evas/savers/eet/evas_image_save_eet.c
diff --git a/src/lib/evas/file/evas_module.c b/src/lib/evas/file/evas_module.c
index 7d23d45963..5d1a8acdee 100644
--- a/src/lib/evas/file/evas_module.c
+++ b/src/lib/evas/file/evas_module.c
@@ -125,6 +125,7 @@ EVAS_EINA_STATIC_MODULE_DEFINE(engine, software_x11);
125 125
126#if !EVAS_MODULE_NO_IMAGE_LOADERS 126#if !EVAS_MODULE_NO_IMAGE_LOADERS
127EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, bmp); 127EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, bmp);
128EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, dds);
128EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, eet); 129EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, eet);
129EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, generic); 130EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, generic);
130EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, gif); 131EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, gif);
@@ -189,6 +190,9 @@ static const struct {
189#ifdef EVAS_STATIC_BUILD_BMP 190#ifdef EVAS_STATIC_BUILD_BMP
190 EVAS_EINA_STATIC_MODULE_USE(image_loader, bmp), 191 EVAS_EINA_STATIC_MODULE_USE(image_loader, bmp),
191#endif 192#endif
193#ifdef EVAS_STATIC_BUILD_DDS
194 EVAS_EINA_STATIC_MODULE_USE(image_loader, dds),
195#endif
192#ifdef EVAS_STATIC_BUILD_EET 196#ifdef EVAS_STATIC_BUILD_EET
193 EVAS_EINA_STATIC_MODULE_USE(image_loader, eet), 197 EVAS_EINA_STATIC_MODULE_USE(image_loader, eet),
194#endif 198#endif
diff --git a/src/modules/evas/loaders/dds/evas_image_load_dds.c b/src/modules/evas/loaders/dds/evas_image_load_dds.c
new file mode 100644
index 0000000000..356fc68443
--- /dev/null
+++ b/src/modules/evas/loaders/dds/evas_image_load_dds.c
@@ -0,0 +1,153 @@
1/* @file evas_image_load_dds.c
2 * @author Jean-Philippe ANDRE <jpeg@videolan.org>
3 *
4 * Load Microsoft DirectDraw Surface files.
5 * Decode S3TC image format.
6 */
7
8#ifdef HAVE_CONFIG_H
9# include "config.h"
10#endif
11
12#include "Evas_Loader.h"
13
14typedef struct _Evas_Loader_Internal Evas_Loader_Internal;
15struct _Evas_Loader_Internal
16{
17 Eina_File *f;
18};
19
20static void *
21evas_image_load_file_open_dds(Eina_File *f, Eina_Stringshare *key EINA_UNUSED,
22 Evas_Image_Load_Opts *opts,
23 Evas_Image_Animated *animated EINA_UNUSED,
24 int *error)
25{
26 Evas_Loader_Internal *loader;
27
28 // TODO: Check file size
29 if (eina_file_size_get(f) <= 16)
30 {
31 *error = EVAS_LOAD_ERROR_CORRUPT_FILE;
32 return NULL;
33 }
34
35 loader = calloc(1, sizeof (Evas_Loader_Internal));
36 if (!loader)
37 {
38 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
39 return NULL;
40 }
41
42
43 loader->f = eina_file_dup(f);
44 if (!loader->f)
45 {
46 free(loader);
47 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
48 return NULL;
49 }
50
51 return loader;
52}
53
54static void
55evas_image_load_file_close_dds(void *loader_data)
56{
57 Evas_Loader_Internal *loader = loader_data;
58
59 eina_file_close(loader->f);
60 free(loader);
61}
62
63static Eina_Bool
64evas_image_load_file_head_dds(void *loader_data,
65 Evas_Image_Property *prop,
66 int *error)
67{
68 Evas_Loader_Internal *loader = loader_data;
69 const char *m;
70
71 m = eina_file_map_all(loader->f, EINA_FILE_SEQUENTIAL);
72 if (!m)
73 {
74 *error = EVAS_LOAD_ERROR_CORRUPT_FILE;
75 return EINA_FALSE;
76 }
77
78 if (strncmp(m, "DDS ", 4) != 0)
79 {
80 *error = EVAS_LOAD_ERROR_CORRUPT_FILE;
81 return EINA_FALSE;
82 }
83
84 // TODO
85
86 return EINA_TRUE;
87}
88
89Eina_Bool
90evas_image_load_file_data_dds(void *loader_data,
91 Evas_Image_Property *prop,
92 void *pixels,
93 int *error)
94{
95 Evas_Loader_Internal *loader = loader_data;
96 const char *m;
97
98 Eina_Bool r = EINA_FALSE;
99
100 *error = EVAS_LOAD_ERROR_CORRUPT_FILE;
101
102 m = eina_file_map_all(loader->f, EINA_FILE_WILLNEED);
103 if (!m) return EINA_FALSE;
104
105 // TODO
106
107 r = EINA_TRUE;
108
109on_error:
110 eina_file_map_free(loader->f, m);
111 return r;
112}
113
114Evas_Image_Load_Func evas_image_load_dds_func =
115{
116 evas_image_load_file_open_dds,
117 evas_image_load_file_close_dds,
118 evas_image_load_file_head_dds,
119 evas_image_load_file_data_dds,
120 NULL,
121 EINA_TRUE,
122 EINA_FALSE
123};
124
125static int
126module_open(Evas_Module *em)
127{
128 if (!em) return 0;
129 em->functions = (void *)(&evas_image_load_dds_func);
130 return 1;
131}
132
133static void
134module_close(Evas_Module *em EINA_UNUSED)
135{
136}
137
138static Evas_Module_Api evas_modapi =
139{
140 EVAS_MODULE_API_VERSION,
141 "dds",
142 "none",
143 {
144 module_open,
145 module_close
146 }
147};
148
149EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_IMAGE_LOADER, image_loader, dds);
150
151#ifndef EVAS_STATIC_BUILD_DDS
152EVAS_EINA_MODULE_DEFINE(image_loader, dds);
153#endif