diff options
Diffstat (limited to 'libraries/evas/src/lib/cache')
-rw-r--r-- | libraries/evas/src/lib/cache/Makefile.am | 27 | ||||
-rw-r--r-- | libraries/evas/src/lib/cache/Makefile.in | 683 | ||||
-rw-r--r-- | libraries/evas/src/lib/cache/evas_cache.h | 175 | ||||
-rw-r--r-- | libraries/evas/src/lib/cache/evas_cache_engine_image.c | 699 | ||||
-rw-r--r-- | libraries/evas/src/lib/cache/evas_cache_image.c | 1433 | ||||
-rw-r--r-- | libraries/evas/src/lib/cache/evas_preload.c | 264 |
6 files changed, 3281 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/cache/Makefile.am b/libraries/evas/src/lib/cache/Makefile.am new file mode 100644 index 0000000..d417262 --- /dev/null +++ b/libraries/evas/src/lib/cache/Makefile.am | |||
@@ -0,0 +1,27 @@ | |||
1 | |||
2 | MAINTAINERCLEANFILES = Makefile.in | ||
3 | |||
4 | AM_CPPFLAGS = -I. \ | ||
5 | -I$(top_srcdir)/src/lib \ | ||
6 | -I$(top_srcdir)/src/lib/include \ | ||
7 | -DPACKAGE_BIN_DIR=\"$(bindir)\" \ | ||
8 | -DPACKAGE_LIB_DIR=\"$(libdir)\" \ | ||
9 | -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ | ||
10 | @WIN32_CPPFLAGS@ \ | ||
11 | @EVIL_CFLAGS@ \ | ||
12 | @FREETYPE_CFLAGS@ \ | ||
13 | @PIXMAN_CFLAGS@ \ | ||
14 | @EINA_CFLAGS@ \ | ||
15 | @PIXMAN_CFLAGS@ | ||
16 | |||
17 | noinst_LTLIBRARIES = libevas_cache.la | ||
18 | libevas_cache_la_SOURCES = \ | ||
19 | evas_cache_image.c \ | ||
20 | evas_cache_engine_image.c \ | ||
21 | evas_preload.c | ||
22 | |||
23 | libevas_cache_la_LIBAD = @EVIL_LIBS@ | ||
24 | |||
25 | libevas_cache_la_DEPENDENCIES = $(top_builddir)/config.h | ||
26 | |||
27 | EXTRA_DIST = evas_cache.h | ||
diff --git a/libraries/evas/src/lib/cache/Makefile.in b/libraries/evas/src/lib/cache/Makefile.in new file mode 100644 index 0000000..b024731 --- /dev/null +++ b/libraries/evas/src/lib/cache/Makefile.in | |||
@@ -0,0 +1,683 @@ | |||
1 | # Makefile.in generated by automake 1.11.1 from Makefile.am. | ||
2 | # @configure_input@ | ||
3 | |||
4 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, | ||
5 | # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, | ||
6 | # Inc. | ||
7 | # This Makefile.in is free software; the Free Software Foundation | ||
8 | # gives unlimited permission to copy and/or distribute it, | ||
9 | # with or without modifications, as long as this notice is preserved. | ||
10 | |||
11 | # This program is distributed in the hope that it will be useful, | ||
12 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without | ||
13 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
14 | # PARTICULAR PURPOSE. | ||
15 | |||
16 | @SET_MAKE@ | ||
17 | |||
18 | VPATH = @srcdir@ | ||
19 | pkgdatadir = $(datadir)/@PACKAGE@ | ||
20 | pkgincludedir = $(includedir)/@PACKAGE@ | ||
21 | pkglibdir = $(libdir)/@PACKAGE@ | ||
22 | pkglibexecdir = $(libexecdir)/@PACKAGE@ | ||
23 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd | ||
24 | install_sh_DATA = $(install_sh) -c -m 644 | ||
25 | install_sh_PROGRAM = $(install_sh) -c | ||
26 | install_sh_SCRIPT = $(install_sh) -c | ||
27 | INSTALL_HEADER = $(INSTALL_DATA) | ||
28 | transform = $(program_transform_name) | ||
29 | NORMAL_INSTALL = : | ||
30 | PRE_INSTALL = : | ||
31 | POST_INSTALL = : | ||
32 | NORMAL_UNINSTALL = : | ||
33 | PRE_UNINSTALL = : | ||
34 | POST_UNINSTALL = : | ||
35 | build_triplet = @build@ | ||
36 | host_triplet = @host@ | ||
37 | subdir = src/lib/cache | ||
38 | DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in | ||
39 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 | ||
40 | am__aclocal_m4_deps = $(top_srcdir)/m4/efl_attribute.m4 \ | ||
41 | $(top_srcdir)/m4/efl_coverage.m4 \ | ||
42 | $(top_srcdir)/m4/efl_doxygen.m4 \ | ||
43 | $(top_srcdir)/m4/efl_fnmatch.m4 \ | ||
44 | $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \ | ||
45 | $(top_srcdir)/m4/evas_check_engine.m4 \ | ||
46 | $(top_srcdir)/m4/evas_check_loader.m4 \ | ||
47 | $(top_srcdir)/m4/evas_converter.m4 \ | ||
48 | $(top_srcdir)/m4/evas_dither.m4 \ | ||
49 | $(top_srcdir)/m4/evas_scaler.m4 $(top_srcdir)/m4/libtool.m4 \ | ||
50 | $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ | ||
51 | $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ | ||
52 | $(top_srcdir)/configure.ac | ||
53 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ | ||
54 | $(ACLOCAL_M4) | ||
55 | mkinstalldirs = $(install_sh) -d | ||
56 | CONFIG_HEADER = $(top_builddir)/config.h | ||
57 | CONFIG_CLEAN_FILES = | ||
58 | CONFIG_CLEAN_VPATH_FILES = | ||
59 | LTLIBRARIES = $(noinst_LTLIBRARIES) | ||
60 | libevas_cache_la_LIBADD = | ||
61 | am_libevas_cache_la_OBJECTS = evas_cache_image.lo \ | ||
62 | evas_cache_engine_image.lo evas_preload.lo | ||
63 | libevas_cache_la_OBJECTS = $(am_libevas_cache_la_OBJECTS) | ||
64 | AM_V_lt = $(am__v_lt_$(V)) | ||
65 | am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) | ||
66 | am__v_lt_0 = --silent | ||
67 | DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) | ||
68 | depcomp = $(SHELL) $(top_srcdir)/depcomp | ||
69 | am__depfiles_maybe = depfiles | ||
70 | am__mv = mv -f | ||
71 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ | ||
72 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) | ||
73 | LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ | ||
74 | $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ | ||
75 | $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ | ||
76 | $(AM_CFLAGS) $(CFLAGS) | ||
77 | AM_V_CC = $(am__v_CC_$(V)) | ||
78 | am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) | ||
79 | am__v_CC_0 = @echo " CC " $@; | ||
80 | AM_V_at = $(am__v_at_$(V)) | ||
81 | am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) | ||
82 | am__v_at_0 = @ | ||
83 | CCLD = $(CC) | ||
84 | LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ | ||
85 | $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ | ||
86 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ | ||
87 | AM_V_CCLD = $(am__v_CCLD_$(V)) | ||
88 | am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) | ||
89 | am__v_CCLD_0 = @echo " CCLD " $@; | ||
90 | AM_V_GEN = $(am__v_GEN_$(V)) | ||
91 | am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) | ||
92 | am__v_GEN_0 = @echo " GEN " $@; | ||
93 | SOURCES = $(libevas_cache_la_SOURCES) | ||
94 | DIST_SOURCES = $(libevas_cache_la_SOURCES) | ||
95 | ETAGS = etags | ||
96 | CTAGS = ctags | ||
97 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) | ||
98 | ACLOCAL = @ACLOCAL@ | ||
99 | ALLOCA = @ALLOCA@ | ||
100 | AMTAR = @AMTAR@ | ||
101 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ | ||
102 | AR = @AR@ | ||
103 | AS = @AS@ | ||
104 | AUTOCONF = @AUTOCONF@ | ||
105 | AUTOHEADER = @AUTOHEADER@ | ||
106 | AUTOMAKE = @AUTOMAKE@ | ||
107 | AWK = @AWK@ | ||
108 | CC = @CC@ | ||
109 | CCDEPMODE = @CCDEPMODE@ | ||
110 | CFLAGS = @CFLAGS@ | ||
111 | CHECK_CFLAGS = @CHECK_CFLAGS@ | ||
112 | CHECK_LIBS = @CHECK_LIBS@ | ||
113 | CPP = @CPP@ | ||
114 | CPPFLAGS = @CPPFLAGS@ | ||
115 | CXX = @CXX@ | ||
116 | CXXCPP = @CXXCPP@ | ||
117 | CXXDEPMODE = @CXXDEPMODE@ | ||
118 | CXXFLAGS = @CXXFLAGS@ | ||
119 | CYGPATH_W = @CYGPATH_W@ | ||
120 | DEFS = @DEFS@ | ||
121 | DEPDIR = @DEPDIR@ | ||
122 | DIRECTFB_CFLAGS = @DIRECTFB_CFLAGS@ | ||
123 | DIRECTFB_LIBS = @DIRECTFB_LIBS@ | ||
124 | DLLTOOL = @DLLTOOL@ | ||
125 | DSYMUTIL = @DSYMUTIL@ | ||
126 | DUMPBIN = @DUMPBIN@ | ||
127 | ECHO_C = @ECHO_C@ | ||
128 | ECHO_N = @ECHO_N@ | ||
129 | ECHO_T = @ECHO_T@ | ||
130 | ECORE_EVAS_CFLAGS = @ECORE_EVAS_CFLAGS@ | ||
131 | ECORE_EVAS_LIBS = @ECORE_EVAS_LIBS@ | ||
132 | EDB_CFLAGS = @EDB_CFLAGS@ | ||
133 | EDB_LIBS = @EDB_LIBS@ | ||
134 | EDJE_CFLAGS = @EDJE_CFLAGS@ | ||
135 | EDJE_LIBS = @EDJE_LIBS@ | ||
136 | EET_CFLAGS = @EET_CFLAGS@ | ||
137 | EET_LIBS = @EET_LIBS@ | ||
138 | EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@ | ||
139 | EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@ | ||
140 | EFL_FNMATCH_LIBS = @EFL_FNMATCH_LIBS@ | ||
141 | EGREP = @EGREP@ | ||
142 | EINA_CFLAGS = @EINA_CFLAGS@ | ||
143 | EINA_LIBS = @EINA_LIBS@ | ||
144 | EVAS_CFLAGS = @EVAS_CFLAGS@ | ||
145 | EVAS_LIBS = @EVAS_LIBS@ | ||
146 | EVAS_SSE3_CFLAGS = @EVAS_SSE3_CFLAGS@ | ||
147 | EVIL_CFLAGS = @EVIL_CFLAGS@ | ||
148 | EVIL_LIBS = @EVIL_LIBS@ | ||
149 | EXEEXT = @EXEEXT@ | ||
150 | FGREP = @FGREP@ | ||
151 | FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ | ||
152 | FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ | ||
153 | FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ | ||
154 | FREETYPE_LIBS = @FREETYPE_LIBS@ | ||
155 | FRIBIDI_CFLAGS = @FRIBIDI_CFLAGS@ | ||
156 | FRIBIDI_LIBS = @FRIBIDI_LIBS@ | ||
157 | GL_EET_CFLAGS = @GL_EET_CFLAGS@ | ||
158 | GL_EET_LIBS = @GL_EET_LIBS@ | ||
159 | GREP = @GREP@ | ||
160 | HARFBUZZ_CFLAGS = @HARFBUZZ_CFLAGS@ | ||
161 | HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ | ||
162 | INSTALL = @INSTALL@ | ||
163 | INSTALL_DATA = @INSTALL_DATA@ | ||
164 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ | ||
165 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ | ||
166 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ | ||
167 | LD = @LD@ | ||
168 | LDFLAGS = @LDFLAGS@ | ||
169 | LIBOBJS = @LIBOBJS@ | ||
170 | LIBS = @LIBS@ | ||
171 | LIBTOOL = @LIBTOOL@ | ||
172 | LINEBREAK_CFLAGS = @LINEBREAK_CFLAGS@ | ||
173 | LINEBREAK_LIBS = @LINEBREAK_LIBS@ | ||
174 | LIPO = @LIPO@ | ||
175 | LN_S = @LN_S@ | ||
176 | LTLIBOBJS = @LTLIBOBJS@ | ||
177 | MAKEINFO = @MAKEINFO@ | ||
178 | MKDIR_P = @MKDIR_P@ | ||
179 | MODULE_ARCH = @MODULE_ARCH@ | ||
180 | NM = @NM@ | ||
181 | NMEDIT = @NMEDIT@ | ||
182 | OBJC = @OBJC@ | ||
183 | OBJCDEPMODE = @OBJCDEPMODE@ | ||
184 | OBJCFLAGS = @OBJCFLAGS@ | ||
185 | OBJDUMP = @OBJDUMP@ | ||
186 | OBJEXT = @OBJEXT@ | ||
187 | OTOOL = @OTOOL@ | ||
188 | OTOOL64 = @OTOOL64@ | ||
189 | PACKAGE = @PACKAGE@ | ||
190 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ | ||
191 | PACKAGE_NAME = @PACKAGE_NAME@ | ||
192 | PACKAGE_STRING = @PACKAGE_STRING@ | ||
193 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ | ||
194 | PACKAGE_URL = @PACKAGE_URL@ | ||
195 | PACKAGE_VERSION = @PACKAGE_VERSION@ | ||
196 | PATH_SEPARATOR = @PATH_SEPARATOR@ | ||
197 | PIXMAN_CFLAGS = @PIXMAN_CFLAGS@ | ||
198 | PIXMAN_LIBS = @PIXMAN_LIBS@ | ||
199 | PKG_CONFIG = @PKG_CONFIG@ | ||
200 | PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ | ||
201 | PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ | ||
202 | PNG_CFLAGS = @PNG_CFLAGS@ | ||
203 | PNG_LIBS = @PNG_LIBS@ | ||
204 | RANLIB = @RANLIB@ | ||
205 | SDL_CFLAGS = @SDL_CFLAGS@ | ||
206 | SDL_LIBS = @SDL_LIBS@ | ||
207 | SED = @SED@ | ||
208 | SET_MAKE = @SET_MAKE@ | ||
209 | SHELL = @SHELL@ | ||
210 | SHM_OPEN_LINK = @SHM_OPEN_LINK@ | ||
211 | STRIP = @STRIP@ | ||
212 | SVG_CFLAGS = @SVG_CFLAGS@ | ||
213 | SVG_LIBS = @SVG_LIBS@ | ||
214 | VALGRIND_CFLAGS = @VALGRIND_CFLAGS@ | ||
215 | VALGRIND_LIBS = @VALGRIND_LIBS@ | ||
216 | VERSION = @VERSION@ | ||
217 | VMAJ = @VMAJ@ | ||
218 | WIN32_CFLAGS = @WIN32_CFLAGS@ | ||
219 | WIN32_CPPFLAGS = @WIN32_CPPFLAGS@ | ||
220 | XCB_CFLAGS = @XCB_CFLAGS@ | ||
221 | XCB_GL_CFLAGS = @XCB_GL_CFLAGS@ | ||
222 | XCB_GL_LIBS = @XCB_GL_LIBS@ | ||
223 | XCB_LIBS = @XCB_LIBS@ | ||
224 | XEXT_CFLAGS = @XEXT_CFLAGS@ | ||
225 | XEXT_LIBS = @XEXT_LIBS@ | ||
226 | XMKMF = @XMKMF@ | ||
227 | X_CFLAGS = @X_CFLAGS@ | ||
228 | X_EXTRA_LIBS = @X_EXTRA_LIBS@ | ||
229 | X_LIBS = @X_LIBS@ | ||
230 | X_PRE_LIBS = @X_PRE_LIBS@ | ||
231 | abs_builddir = @abs_builddir@ | ||
232 | abs_srcdir = @abs_srcdir@ | ||
233 | abs_top_builddir = @abs_top_builddir@ | ||
234 | abs_top_srcdir = @abs_top_srcdir@ | ||
235 | ac_ct_CC = @ac_ct_CC@ | ||
236 | ac_ct_CXX = @ac_ct_CXX@ | ||
237 | ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ | ||
238 | ac_ct_OBJC = @ac_ct_OBJC@ | ||
239 | altivec_cflags = @altivec_cflags@ | ||
240 | am__include = @am__include@ | ||
241 | am__leading_dot = @am__leading_dot@ | ||
242 | am__quote = @am__quote@ | ||
243 | am__tar = @am__tar@ | ||
244 | am__untar = @am__untar@ | ||
245 | bindir = @bindir@ | ||
246 | build = @build@ | ||
247 | build_alias = @build_alias@ | ||
248 | build_cpu = @build_cpu@ | ||
249 | build_os = @build_os@ | ||
250 | build_vendor = @build_vendor@ | ||
251 | builddir = @builddir@ | ||
252 | datadir = @datadir@ | ||
253 | datarootdir = @datarootdir@ | ||
254 | dlopen_libs = @dlopen_libs@ | ||
255 | docdir = @docdir@ | ||
256 | dvidir = @dvidir@ | ||
257 | edje_cc = @edje_cc@ | ||
258 | efl_doxygen = @efl_doxygen@ | ||
259 | efl_have_doxygen = @efl_have_doxygen@ | ||
260 | evas_engine_buffer_cflags = @evas_engine_buffer_cflags@ | ||
261 | evas_engine_buffer_libs = @evas_engine_buffer_libs@ | ||
262 | evas_engine_direct3d_cflags = @evas_engine_direct3d_cflags@ | ||
263 | evas_engine_direct3d_libs = @evas_engine_direct3d_libs@ | ||
264 | evas_engine_directfb_cflags = @evas_engine_directfb_cflags@ | ||
265 | evas_engine_directfb_libs = @evas_engine_directfb_libs@ | ||
266 | evas_engine_fb_cflags = @evas_engine_fb_cflags@ | ||
267 | evas_engine_fb_libs = @evas_engine_fb_libs@ | ||
268 | evas_engine_gl_cocoa_cflags = @evas_engine_gl_cocoa_cflags@ | ||
269 | evas_engine_gl_cocoa_libs = @evas_engine_gl_cocoa_libs@ | ||
270 | evas_engine_gl_common_libs = @evas_engine_gl_common_libs@ | ||
271 | evas_engine_gl_sdl_cflags = @evas_engine_gl_sdl_cflags@ | ||
272 | evas_engine_gl_sdl_libs = @evas_engine_gl_sdl_libs@ | ||
273 | evas_engine_gl_xcb_cflags = @evas_engine_gl_xcb_cflags@ | ||
274 | evas_engine_gl_xcb_libs = @evas_engine_gl_xcb_libs@ | ||
275 | evas_engine_gl_xlib_cflags = @evas_engine_gl_xlib_cflags@ | ||
276 | evas_engine_gl_xlib_libs = @evas_engine_gl_xlib_libs@ | ||
277 | evas_engine_psl1ght_cflags = @evas_engine_psl1ght_cflags@ | ||
278 | evas_engine_psl1ght_libs = @evas_engine_psl1ght_libs@ | ||
279 | evas_engine_software_16_ddraw_cflags = @evas_engine_software_16_ddraw_cflags@ | ||
280 | evas_engine_software_16_ddraw_libs = @evas_engine_software_16_ddraw_libs@ | ||
281 | evas_engine_software_16_sdl_cflags = @evas_engine_software_16_sdl_cflags@ | ||
282 | evas_engine_software_16_sdl_libs = @evas_engine_software_16_sdl_libs@ | ||
283 | evas_engine_software_16_wince_cflags = @evas_engine_software_16_wince_cflags@ | ||
284 | evas_engine_software_16_wince_libs = @evas_engine_software_16_wince_libs@ | ||
285 | evas_engine_software_16_x11_cflags = @evas_engine_software_16_x11_cflags@ | ||
286 | evas_engine_software_16_x11_libs = @evas_engine_software_16_x11_libs@ | ||
287 | evas_engine_software_8_x11_cflags = @evas_engine_software_8_x11_cflags@ | ||
288 | evas_engine_software_8_x11_libs = @evas_engine_software_8_x11_libs@ | ||
289 | evas_engine_software_ddraw_cflags = @evas_engine_software_ddraw_cflags@ | ||
290 | evas_engine_software_ddraw_libs = @evas_engine_software_ddraw_libs@ | ||
291 | evas_engine_software_gdi_cflags = @evas_engine_software_gdi_cflags@ | ||
292 | evas_engine_software_gdi_libs = @evas_engine_software_gdi_libs@ | ||
293 | evas_engine_software_sdl_cflags = @evas_engine_software_sdl_cflags@ | ||
294 | evas_engine_software_sdl_libs = @evas_engine_software_sdl_libs@ | ||
295 | evas_engine_software_xcb_cflags = @evas_engine_software_xcb_cflags@ | ||
296 | evas_engine_software_xcb_libs = @evas_engine_software_xcb_libs@ | ||
297 | evas_engine_software_xlib_cflags = @evas_engine_software_xlib_cflags@ | ||
298 | evas_engine_software_xlib_libs = @evas_engine_software_xlib_libs@ | ||
299 | evas_image_loader_bmp_cflags = @evas_image_loader_bmp_cflags@ | ||
300 | evas_image_loader_bmp_libs = @evas_image_loader_bmp_libs@ | ||
301 | evas_image_loader_edb_cflags = @evas_image_loader_edb_cflags@ | ||
302 | evas_image_loader_edb_libs = @evas_image_loader_edb_libs@ | ||
303 | evas_image_loader_eet_cflags = @evas_image_loader_eet_cflags@ | ||
304 | evas_image_loader_eet_libs = @evas_image_loader_eet_libs@ | ||
305 | evas_image_loader_generic_cflags = @evas_image_loader_generic_cflags@ | ||
306 | evas_image_loader_generic_libs = @evas_image_loader_generic_libs@ | ||
307 | evas_image_loader_gif_cflags = @evas_image_loader_gif_cflags@ | ||
308 | evas_image_loader_gif_libs = @evas_image_loader_gif_libs@ | ||
309 | evas_image_loader_ico_cflags = @evas_image_loader_ico_cflags@ | ||
310 | evas_image_loader_ico_libs = @evas_image_loader_ico_libs@ | ||
311 | evas_image_loader_jpeg_cflags = @evas_image_loader_jpeg_cflags@ | ||
312 | evas_image_loader_jpeg_libs = @evas_image_loader_jpeg_libs@ | ||
313 | evas_image_loader_pmaps_cflags = @evas_image_loader_pmaps_cflags@ | ||
314 | evas_image_loader_pmaps_libs = @evas_image_loader_pmaps_libs@ | ||
315 | evas_image_loader_png_cflags = @evas_image_loader_png_cflags@ | ||
316 | evas_image_loader_png_libs = @evas_image_loader_png_libs@ | ||
317 | evas_image_loader_psd_cflags = @evas_image_loader_psd_cflags@ | ||
318 | evas_image_loader_psd_libs = @evas_image_loader_psd_libs@ | ||
319 | evas_image_loader_svg_cflags = @evas_image_loader_svg_cflags@ | ||
320 | evas_image_loader_svg_libs = @evas_image_loader_svg_libs@ | ||
321 | evas_image_loader_tga_cflags = @evas_image_loader_tga_cflags@ | ||
322 | evas_image_loader_tga_libs = @evas_image_loader_tga_libs@ | ||
323 | evas_image_loader_tiff_cflags = @evas_image_loader_tiff_cflags@ | ||
324 | evas_image_loader_tiff_libs = @evas_image_loader_tiff_libs@ | ||
325 | evas_image_loader_wbmp_cflags = @evas_image_loader_wbmp_cflags@ | ||
326 | evas_image_loader_wbmp_libs = @evas_image_loader_wbmp_libs@ | ||
327 | evas_image_loader_xpm_cflags = @evas_image_loader_xpm_cflags@ | ||
328 | evas_image_loader_xpm_libs = @evas_image_loader_xpm_libs@ | ||
329 | exec_prefix = @exec_prefix@ | ||
330 | have_evas_engine_gl_x11 = @have_evas_engine_gl_x11@ | ||
331 | have_evas_engine_gl_xcb = @have_evas_engine_gl_xcb@ | ||
332 | have_evas_engine_gl_xlib = @have_evas_engine_gl_xlib@ | ||
333 | have_evas_engine_software_x11 = @have_evas_engine_software_x11@ | ||
334 | have_evas_engine_software_xcb = @have_evas_engine_software_xcb@ | ||
335 | have_evas_engine_software_xlib = @have_evas_engine_software_xlib@ | ||
336 | have_lcov = @have_lcov@ | ||
337 | host = @host@ | ||
338 | host_alias = @host_alias@ | ||
339 | host_cpu = @host_cpu@ | ||
340 | host_os = @host_os@ | ||
341 | host_vendor = @host_vendor@ | ||
342 | htmldir = @htmldir@ | ||
343 | includedir = @includedir@ | ||
344 | infodir = @infodir@ | ||
345 | install_sh = @install_sh@ | ||
346 | libdir = @libdir@ | ||
347 | libexecdir = @libexecdir@ | ||
348 | localedir = @localedir@ | ||
349 | localstatedir = @localstatedir@ | ||
350 | lt_ECHO = @lt_ECHO@ | ||
351 | lt_enable_auto_import = @lt_enable_auto_import@ | ||
352 | mandir = @mandir@ | ||
353 | mkdir_p = @mkdir_p@ | ||
354 | oldincludedir = @oldincludedir@ | ||
355 | pdfdir = @pdfdir@ | ||
356 | pkgconfig_requires_private = @pkgconfig_requires_private@ | ||
357 | prefix = @prefix@ | ||
358 | program_transform_name = @program_transform_name@ | ||
359 | psdir = @psdir@ | ||
360 | pthread_cflags = @pthread_cflags@ | ||
361 | pthread_libs = @pthread_libs@ | ||
362 | release_info = @release_info@ | ||
363 | requirement_evas = @requirement_evas@ | ||
364 | sbindir = @sbindir@ | ||
365 | sharedstatedir = @sharedstatedir@ | ||
366 | srcdir = @srcdir@ | ||
367 | sysconfdir = @sysconfdir@ | ||
368 | target_alias = @target_alias@ | ||
369 | top_build_prefix = @top_build_prefix@ | ||
370 | top_builddir = @top_builddir@ | ||
371 | top_srcdir = @top_srcdir@ | ||
372 | version_info = @version_info@ | ||
373 | MAINTAINERCLEANFILES = Makefile.in | ||
374 | AM_CPPFLAGS = -I. \ | ||
375 | -I$(top_srcdir)/src/lib \ | ||
376 | -I$(top_srcdir)/src/lib/include \ | ||
377 | -DPACKAGE_BIN_DIR=\"$(bindir)\" \ | ||
378 | -DPACKAGE_LIB_DIR=\"$(libdir)\" \ | ||
379 | -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ | ||
380 | @WIN32_CPPFLAGS@ \ | ||
381 | @EVIL_CFLAGS@ \ | ||
382 | @FREETYPE_CFLAGS@ \ | ||
383 | @PIXMAN_CFLAGS@ \ | ||
384 | @EINA_CFLAGS@ \ | ||
385 | @PIXMAN_CFLAGS@ | ||
386 | |||
387 | noinst_LTLIBRARIES = libevas_cache.la | ||
388 | libevas_cache_la_SOURCES = \ | ||
389 | evas_cache_image.c \ | ||
390 | evas_cache_engine_image.c \ | ||
391 | evas_preload.c | ||
392 | |||
393 | libevas_cache_la_LIBAD = @EVIL_LIBS@ | ||
394 | libevas_cache_la_DEPENDENCIES = $(top_builddir)/config.h | ||
395 | EXTRA_DIST = evas_cache.h | ||
396 | all: all-am | ||
397 | |||
398 | .SUFFIXES: | ||
399 | .SUFFIXES: .c .lo .o .obj | ||
400 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) | ||
401 | @for dep in $?; do \ | ||
402 | case '$(am__configure_deps)' in \ | ||
403 | *$$dep*) \ | ||
404 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ | ||
405 | && { if test -f $@; then exit 0; else break; fi; }; \ | ||
406 | exit 1;; \ | ||
407 | esac; \ | ||
408 | done; \ | ||
409 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/lib/cache/Makefile'; \ | ||
410 | $(am__cd) $(top_srcdir) && \ | ||
411 | $(AUTOMAKE) --gnu src/lib/cache/Makefile | ||
412 | .PRECIOUS: Makefile | ||
413 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status | ||
414 | @case '$?' in \ | ||
415 | *config.status*) \ | ||
416 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ | ||
417 | *) \ | ||
418 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ | ||
419 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ | ||
420 | esac; | ||
421 | |||
422 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) | ||
423 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh | ||
424 | |||
425 | $(top_srcdir)/configure: $(am__configure_deps) | ||
426 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh | ||
427 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) | ||
428 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh | ||
429 | $(am__aclocal_m4_deps): | ||
430 | |||
431 | clean-noinstLTLIBRARIES: | ||
432 | -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) | ||
433 | @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ | ||
434 | dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ | ||
435 | test "$$dir" != "$$p" || dir=.; \ | ||
436 | echo "rm -f \"$${dir}/so_locations\""; \ | ||
437 | rm -f "$${dir}/so_locations"; \ | ||
438 | done | ||
439 | libevas_cache.la: $(libevas_cache_la_OBJECTS) $(libevas_cache_la_DEPENDENCIES) | ||
440 | $(AM_V_CCLD)$(LINK) $(libevas_cache_la_OBJECTS) $(libevas_cache_la_LIBADD) $(LIBS) | ||
441 | |||
442 | mostlyclean-compile: | ||
443 | -rm -f *.$(OBJEXT) | ||
444 | |||
445 | distclean-compile: | ||
446 | -rm -f *.tab.c | ||
447 | |||
448 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_cache_engine_image.Plo@am__quote@ | ||
449 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_cache_image.Plo@am__quote@ | ||
450 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_preload.Plo@am__quote@ | ||
451 | |||
452 | .c.o: | ||
453 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< | ||
454 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po | ||
455 | @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ | ||
456 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ | ||
457 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
458 | @am__fastdepCC_FALSE@ $(COMPILE) -c $< | ||
459 | |||
460 | .c.obj: | ||
461 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` | ||
462 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po | ||
463 | @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ | ||
464 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ | ||
465 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
466 | @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` | ||
467 | |||
468 | .c.lo: | ||
469 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< | ||
470 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo | ||
471 | @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ | ||
472 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ | ||
473 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
474 | @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< | ||
475 | |||
476 | mostlyclean-libtool: | ||
477 | -rm -f *.lo | ||
478 | |||
479 | clean-libtool: | ||
480 | -rm -rf .libs _libs | ||
481 | |||
482 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) | ||
483 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ | ||
484 | unique=`for i in $$list; do \ | ||
485 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ | ||
486 | done | \ | ||
487 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ | ||
488 | END { if (nonempty) { for (i in files) print i; }; }'`; \ | ||
489 | mkid -fID $$unique | ||
490 | tags: TAGS | ||
491 | |||
492 | TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ | ||
493 | $(TAGS_FILES) $(LISP) | ||
494 | set x; \ | ||
495 | here=`pwd`; \ | ||
496 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ | ||
497 | unique=`for i in $$list; do \ | ||
498 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ | ||
499 | done | \ | ||
500 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ | ||
501 | END { if (nonempty) { for (i in files) print i; }; }'`; \ | ||
502 | shift; \ | ||
503 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ | ||
504 | test -n "$$unique" || unique=$$empty_fix; \ | ||
505 | if test $$# -gt 0; then \ | ||
506 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ | ||
507 | "$$@" $$unique; \ | ||
508 | else \ | ||
509 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ | ||
510 | $$unique; \ | ||
511 | fi; \ | ||
512 | fi | ||
513 | ctags: CTAGS | ||
514 | CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ | ||
515 | $(TAGS_FILES) $(LISP) | ||
516 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ | ||
517 | unique=`for i in $$list; do \ | ||
518 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ | ||
519 | done | \ | ||
520 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ | ||
521 | END { if (nonempty) { for (i in files) print i; }; }'`; \ | ||
522 | test -z "$(CTAGS_ARGS)$$unique" \ | ||
523 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ | ||
524 | $$unique | ||
525 | |||
526 | GTAGS: | ||
527 | here=`$(am__cd) $(top_builddir) && pwd` \ | ||
528 | && $(am__cd) $(top_srcdir) \ | ||
529 | && gtags -i $(GTAGS_ARGS) "$$here" | ||
530 | |||
531 | distclean-tags: | ||
532 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags | ||
533 | |||
534 | distdir: $(DISTFILES) | ||
535 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ | ||
536 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ | ||
537 | list='$(DISTFILES)'; \ | ||
538 | dist_files=`for file in $$list; do echo $$file; done | \ | ||
539 | sed -e "s|^$$srcdirstrip/||;t" \ | ||
540 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ | ||
541 | case $$dist_files in \ | ||
542 | */*) $(MKDIR_P) `echo "$$dist_files" | \ | ||
543 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ | ||
544 | sort -u` ;; \ | ||
545 | esac; \ | ||
546 | for file in $$dist_files; do \ | ||
547 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ | ||
548 | if test -d $$d/$$file; then \ | ||
549 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ | ||
550 | if test -d "$(distdir)/$$file"; then \ | ||
551 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ | ||
552 | fi; \ | ||
553 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ | ||
554 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ | ||
555 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ | ||
556 | fi; \ | ||
557 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ | ||
558 | else \ | ||
559 | test -f "$(distdir)/$$file" \ | ||
560 | || cp -p $$d/$$file "$(distdir)/$$file" \ | ||
561 | || exit 1; \ | ||
562 | fi; \ | ||
563 | done | ||
564 | check-am: all-am | ||
565 | check: check-am | ||
566 | all-am: Makefile $(LTLIBRARIES) | ||
567 | installdirs: | ||
568 | install: install-am | ||
569 | install-exec: install-exec-am | ||
570 | install-data: install-data-am | ||
571 | uninstall: uninstall-am | ||
572 | |||
573 | install-am: all-am | ||
574 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am | ||
575 | |||
576 | installcheck: installcheck-am | ||
577 | install-strip: | ||
578 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ | ||
579 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ | ||
580 | `test -z '$(STRIP)' || \ | ||
581 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install | ||
582 | mostlyclean-generic: | ||
583 | |||
584 | clean-generic: | ||
585 | |||
586 | distclean-generic: | ||
587 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) | ||
588 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) | ||
589 | |||
590 | maintainer-clean-generic: | ||
591 | @echo "This command is intended for maintainers to use" | ||
592 | @echo "it deletes files that may require special tools to rebuild." | ||
593 | -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) | ||
594 | clean: clean-am | ||
595 | |||
596 | clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ | ||
597 | mostlyclean-am | ||
598 | |||
599 | distclean: distclean-am | ||
600 | -rm -rf ./$(DEPDIR) | ||
601 | -rm -f Makefile | ||
602 | distclean-am: clean-am distclean-compile distclean-generic \ | ||
603 | distclean-tags | ||
604 | |||
605 | dvi: dvi-am | ||
606 | |||
607 | dvi-am: | ||
608 | |||
609 | html: html-am | ||
610 | |||
611 | html-am: | ||
612 | |||
613 | info: info-am | ||
614 | |||
615 | info-am: | ||
616 | |||
617 | install-data-am: | ||
618 | |||
619 | install-dvi: install-dvi-am | ||
620 | |||
621 | install-dvi-am: | ||
622 | |||
623 | install-exec-am: | ||
624 | |||
625 | install-html: install-html-am | ||
626 | |||
627 | install-html-am: | ||
628 | |||
629 | install-info: install-info-am | ||
630 | |||
631 | install-info-am: | ||
632 | |||
633 | install-man: | ||
634 | |||
635 | install-pdf: install-pdf-am | ||
636 | |||
637 | install-pdf-am: | ||
638 | |||
639 | install-ps: install-ps-am | ||
640 | |||
641 | install-ps-am: | ||
642 | |||
643 | installcheck-am: | ||
644 | |||
645 | maintainer-clean: maintainer-clean-am | ||
646 | -rm -rf ./$(DEPDIR) | ||
647 | -rm -f Makefile | ||
648 | maintainer-clean-am: distclean-am maintainer-clean-generic | ||
649 | |||
650 | mostlyclean: mostlyclean-am | ||
651 | |||
652 | mostlyclean-am: mostlyclean-compile mostlyclean-generic \ | ||
653 | mostlyclean-libtool | ||
654 | |||
655 | pdf: pdf-am | ||
656 | |||
657 | pdf-am: | ||
658 | |||
659 | ps: ps-am | ||
660 | |||
661 | ps-am: | ||
662 | |||
663 | uninstall-am: | ||
664 | |||
665 | .MAKE: install-am install-strip | ||
666 | |||
667 | .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ | ||
668 | clean-libtool clean-noinstLTLIBRARIES ctags distclean \ | ||
669 | distclean-compile distclean-generic distclean-libtool \ | ||
670 | distclean-tags distdir dvi dvi-am html html-am info info-am \ | ||
671 | install install-am install-data install-data-am install-dvi \ | ||
672 | install-dvi-am install-exec install-exec-am install-html \ | ||
673 | install-html-am install-info install-info-am install-man \ | ||
674 | install-pdf install-pdf-am install-ps install-ps-am \ | ||
675 | install-strip installcheck installcheck-am installdirs \ | ||
676 | maintainer-clean maintainer-clean-generic mostlyclean \ | ||
677 | mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ | ||
678 | pdf pdf-am ps ps-am tags uninstall uninstall-am | ||
679 | |||
680 | |||
681 | # Tell versions [3.59,3.63) of GNU make to not export all variables. | ||
682 | # Otherwise a system limit (for SysV at least) may be exceeded. | ||
683 | .NOEXPORT: | ||
diff --git a/libraries/evas/src/lib/cache/evas_cache.h b/libraries/evas/src/lib/cache/evas_cache.h new file mode 100644 index 0000000..0947a6d --- /dev/null +++ b/libraries/evas/src/lib/cache/evas_cache.h | |||
@@ -0,0 +1,175 @@ | |||
1 | #ifndef _EVAS_CACHE_H | ||
2 | #define _EVAS_CACHE_H | ||
3 | |||
4 | |||
5 | typedef struct _Evas_Cache_Image Evas_Cache_Image; | ||
6 | typedef struct _Evas_Cache_Image_Func Evas_Cache_Image_Func; | ||
7 | typedef struct _Evas_Cache_Engine_Image Evas_Cache_Engine_Image; | ||
8 | typedef struct _Evas_Cache_Engine_Image_Func Evas_Cache_Engine_Image_Func; | ||
9 | |||
10 | |||
11 | struct _Evas_Cache_Image_Func | ||
12 | { | ||
13 | Image_Entry *(*alloc)(void); | ||
14 | void (*dealloc)(Image_Entry *im); | ||
15 | |||
16 | /* The cache provide some helpers for surface manipulation. */ | ||
17 | int (*surface_alloc)(Image_Entry *im, unsigned int w, unsigned int h); | ||
18 | void (*surface_delete)(Image_Entry *im); | ||
19 | DATA32 *(*surface_pixels)(Image_Entry *im); | ||
20 | |||
21 | /* The cache is doing the allocation and deallocation, you must just do the rest. */ | ||
22 | int (*constructor)(Image_Entry *im); /**< return is EVAS_LOAD_ERROR_* or EVAS_LOAD_ERROR_NONE! */ | ||
23 | void (*destructor)(Image_Entry *im); | ||
24 | |||
25 | void (*dirty_region)(Image_Entry *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h); | ||
26 | /* Only called when references > 0. Need to provide a fresh copie of im. */ | ||
27 | /* The destination surface does have a surface, but no allocated pixel data. */ | ||
28 | int (*dirty)(Image_Entry *dst, const Image_Entry *src); | ||
29 | /* Only called when references == 1. We will call drop on `im'. */ | ||
30 | /* The destination surface does not have any surface. */ | ||
31 | int (*size_set)(Image_Entry *dst, const Image_Entry *src, unsigned int w, unsigned int h); | ||
32 | |||
33 | /* The destination surface does not have any surface. */ | ||
34 | int (*copied_data)(Image_Entry *dst, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, int cspace); | ||
35 | /* The destination surface does not have any surface. */ | ||
36 | int (*data)(Image_Entry *dst, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, int cspace); | ||
37 | int (*color_space)(Image_Entry *dst, int cspace); | ||
38 | |||
39 | /* This function need to update im->w and im->h. */ | ||
40 | int (*load)(Image_Entry *im); /**< return is EVAS_LOAD_ERROR_* or EVAS_LOAD_ERROR_NONE! */ | ||
41 | int (*mem_size_get)(Image_Entry *im); | ||
42 | void (*debug)(const char *context, Image_Entry *im); | ||
43 | }; | ||
44 | |||
45 | struct _Evas_Cache_Image | ||
46 | { | ||
47 | Evas_Cache_Image_Func func; | ||
48 | |||
49 | Eina_List *preload; | ||
50 | Eina_List *pending; | ||
51 | |||
52 | Eina_Inlist *dirty; | ||
53 | |||
54 | Eina_Inlist *lru; | ||
55 | Eina_Inlist *lru_nodata; | ||
56 | Eina_Hash *inactiv; | ||
57 | Eina_Hash *activ; | ||
58 | void *data; | ||
59 | |||
60 | int usage; | ||
61 | unsigned int limit; | ||
62 | int references; | ||
63 | #ifdef EVAS_FRAME_QUEUING | ||
64 | LK(lock); | ||
65 | #endif | ||
66 | }; | ||
67 | |||
68 | struct _Evas_Cache_Engine_Image_Func | ||
69 | { | ||
70 | /* Must return a char* allocated with eina_stringshare_add. */ | ||
71 | char* (*key)(Image_Entry *im, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error); | ||
72 | |||
73 | Engine_Image_Entry* (*alloc)(void); | ||
74 | void (*dealloc)(Engine_Image_Entry *eim); | ||
75 | |||
76 | int (*constructor)(Engine_Image_Entry *eim, void* data); | ||
77 | void (*destructor)(Engine_Image_Entry *eim); | ||
78 | |||
79 | void (*dirty_region)(Engine_Image_Entry *eim, unsigned int x, unsigned int y, unsigned int w, unsigned int h); | ||
80 | /* Only called when references > 0. Need to provide a fresh copie of im. */ | ||
81 | int (*dirty)(Engine_Image_Entry *dst, const Engine_Image_Entry *src); | ||
82 | /* Only called when references == 1. We will call drop on `im'. */ | ||
83 | int (*size_set)(Engine_Image_Entry *dst, const Engine_Image_Entry *src); | ||
84 | |||
85 | int (*update_data)(Engine_Image_Entry* dst, void* data); | ||
86 | |||
87 | void (*load)(Engine_Image_Entry *eim, const Image_Entry* im); | ||
88 | int (*mem_size_get)(Engine_Image_Entry *eim); | ||
89 | void (*debug)(const char* context, Engine_Image_Entry *eim); | ||
90 | }; | ||
91 | |||
92 | struct _Evas_Cache_Engine_Image | ||
93 | { | ||
94 | Evas_Cache_Engine_Image_Func func; | ||
95 | |||
96 | Eina_Inlist* dirty; | ||
97 | |||
98 | Eina_Hash* activ; | ||
99 | Eina_Hash* inactiv; | ||
100 | Eina_Inlist* lru; | ||
101 | |||
102 | Evas_Cache_Image* parent; | ||
103 | Evas_Cache_Engine_Image* brother; | ||
104 | |||
105 | int usage; | ||
106 | int limit; | ||
107 | |||
108 | int references; | ||
109 | }; | ||
110 | |||
111 | |||
112 | #ifdef __cplusplus | ||
113 | extern "C" { | ||
114 | #endif | ||
115 | |||
116 | |||
117 | EAPI Evas_Cache_Image* evas_cache_image_init(const Evas_Cache_Image_Func *cb); | ||
118 | EAPI void evas_cache_image_shutdown(Evas_Cache_Image *cache); | ||
119 | EAPI Image_Entry* evas_cache_image_request(Evas_Cache_Image *cache, const char *file, const char *key, RGBA_Image_Loadopts *lo, int *error); | ||
120 | EAPI void evas_cache_image_drop(Image_Entry *im); | ||
121 | EAPI void evas_cache_image_data_not_needed(Image_Entry *im); | ||
122 | EAPI int evas_cache_image_flush(Evas_Cache_Image *cache); | ||
123 | EAPI void evas_cache_private_set(Evas_Cache_Image *cache, const void *data); | ||
124 | EAPI void* evas_cache_private_get(Evas_Cache_Image *cache); | ||
125 | EAPI void* evas_cache_private_from_image_entry_get(Image_Entry *im); | ||
126 | |||
127 | EAPI int evas_cache_image_usage_get(Evas_Cache_Image *cache); | ||
128 | EAPI int evas_cache_image_get(Evas_Cache_Image *cache); | ||
129 | EAPI void evas_cache_image_set(Evas_Cache_Image *cache, unsigned int size); | ||
130 | |||
131 | EAPI Image_Entry* evas_cache_image_alone(Image_Entry *im); | ||
132 | EAPI Image_Entry* evas_cache_image_dirty(Image_Entry *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h); | ||
133 | EAPI int evas_cache_image_load_data(Image_Entry *im); | ||
134 | EAPI void evas_cache_image_unload_data(Image_Entry *im); | ||
135 | EAPI Eina_Bool evas_cache_image_is_loaded(Image_Entry *im); | ||
136 | EAPI void evas_cache_image_unload_all(Evas_Cache_Image *cache); | ||
137 | EAPI void evas_cache_image_surface_alloc(Image_Entry *im, unsigned int w, unsigned int h); | ||
138 | EAPI DATA32* evas_cache_image_pixels(Image_Entry *im); | ||
139 | EAPI Image_Entry* evas_cache_image_copied_data(Evas_Cache_Image *cache, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, int cspace); | ||
140 | EAPI Image_Entry* evas_cache_image_data(Evas_Cache_Image *cache, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, int cspace); | ||
141 | EAPI void evas_cache_image_colorspace(Image_Entry *im, int cspace); | ||
142 | EAPI Image_Entry* evas_cache_image_empty(Evas_Cache_Image *cache); | ||
143 | EAPI Image_Entry* evas_cache_image_size_set(Image_Entry *im, unsigned int w, unsigned int h); | ||
144 | |||
145 | EAPI Evas_Cache_Engine_Image* evas_cache_engine_image_init(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_Image *parent); | ||
146 | EAPI void evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache); | ||
147 | |||
148 | EAPI int evas_cache_engine_image_usage_get(Evas_Cache_Engine_Image *cache); | ||
149 | EAPI int evas_cache_engine_image_get(Evas_Cache_Engine_Image *cache); | ||
150 | EAPI void evas_cache_engine_image_set(Evas_Cache_Engine_Image *cache, int limit); | ||
151 | |||
152 | EAPI Engine_Image_Entry* evas_cache_engine_image_request(Evas_Cache_Engine_Image *cache, const char *file, const char *key, RGBA_Image_Loadopts *lo, void *engine_data, int *error); | ||
153 | EAPI void evas_cache_engine_parent_not_needed(Engine_Image_Entry *eim); | ||
154 | EAPI Engine_Image_Entry* evas_cache_engine_image_engine(Evas_Cache_Engine_Image *cache, void *engine_data); | ||
155 | EAPI void evas_cache_engine_image_drop(Engine_Image_Entry *eim); | ||
156 | EAPI Engine_Image_Entry* evas_cache_engine_image_alone(Engine_Image_Entry *eim, void *data); | ||
157 | EAPI Engine_Image_Entry* evas_cache_engine_image_dirty(Engine_Image_Entry *eim, unsigned int x, unsigned int y, unsigned int w, unsigned int h); | ||
158 | EAPI Engine_Image_Entry* evas_cache_engine_image_copied_data(Evas_Cache_Engine_Image *cache, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, int cspace, void *engine_data); | ||
159 | EAPI Engine_Image_Entry* evas_cache_engine_image_data(Evas_Cache_Engine_Image *cache, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, int cspace, void *engine_data); | ||
160 | EAPI void evas_cache_engine_image_colorspace(Engine_Image_Entry *eim, int cspace, void *engine_data); | ||
161 | EAPI Engine_Image_Entry* evas_cache_engine_image_size_set(Engine_Image_Entry *eim, unsigned int w, unsigned int h); | ||
162 | |||
163 | EAPI void evas_cache_engine_image_load_data(Engine_Image_Entry *eim); | ||
164 | |||
165 | EAPI void evas_cache_image_preload_data(Image_Entry *im, const void *target); | ||
166 | EAPI void evas_cache_image_preload_cancel(Image_Entry *im, const void *target); | ||
167 | |||
168 | EAPI void evas_cache_image_wakeup(void); | ||
169 | |||
170 | #ifdef __cplusplus | ||
171 | } | ||
172 | #endif | ||
173 | |||
174 | |||
175 | #endif /* _EVAS_CACHE_H */ | ||
diff --git a/libraries/evas/src/lib/cache/evas_cache_engine_image.c b/libraries/evas/src/lib/cache/evas_cache_engine_image.c new file mode 100644 index 0000000..8ae4392 --- /dev/null +++ b/libraries/evas/src/lib/cache/evas_cache_engine_image.c | |||
@@ -0,0 +1,699 @@ | |||
1 | #include <assert.h> | ||
2 | |||
3 | #include "evas_common.h" | ||
4 | #include "evas_private.h" | ||
5 | |||
6 | static void | ||
7 | _evas_cache_engine_image_make_dirty(Evas_Cache_Engine_Image *cache, | ||
8 | Engine_Image_Entry *eim) | ||
9 | { | ||
10 | eim->flags.cached = 1; | ||
11 | eim->flags.dirty = 1; | ||
12 | eim->flags.loaded = 1; | ||
13 | eim->flags.activ = 0; | ||
14 | cache->dirty = eina_inlist_prepend(cache->dirty, EINA_INLIST_GET(eim)); | ||
15 | } | ||
16 | |||
17 | static void | ||
18 | _evas_cache_engine_image_make_active(Evas_Cache_Engine_Image *cache, | ||
19 | Engine_Image_Entry *eim, | ||
20 | const char *key) | ||
21 | { | ||
22 | eim->flags.cached = 1; | ||
23 | eim->flags.activ = 1; | ||
24 | eim->flags.dirty = 0; | ||
25 | eina_hash_add(cache->activ, key, eim); | ||
26 | } | ||
27 | |||
28 | static void | ||
29 | _evas_cache_engine_image_make_inactive(Evas_Cache_Engine_Image *cache, | ||
30 | Engine_Image_Entry *eim, | ||
31 | const char *key) | ||
32 | { | ||
33 | eim->flags.cached = 1; | ||
34 | eim->flags.dirty = 0; | ||
35 | eim->flags.activ = 0; | ||
36 | eina_hash_add(cache->inactiv, key, eim); | ||
37 | cache->lru = eina_inlist_prepend(cache->lru, EINA_INLIST_GET(eim)); | ||
38 | cache->usage += cache->func.mem_size_get(eim); | ||
39 | } | ||
40 | |||
41 | static void | ||
42 | _evas_cache_engine_image_remove_activ(Evas_Cache_Engine_Image *cache, | ||
43 | Engine_Image_Entry *eim) | ||
44 | { | ||
45 | if (eim->flags.cached) | ||
46 | { | ||
47 | if (eim->flags.dirty) | ||
48 | { | ||
49 | cache->dirty = eina_inlist_remove(cache->dirty, EINA_INLIST_GET(eim)); | ||
50 | } | ||
51 | else | ||
52 | if (eim->flags.activ) | ||
53 | { | ||
54 | eina_hash_del(cache->activ, eim->cache_key, eim); | ||
55 | } | ||
56 | else | ||
57 | { | ||
58 | cache->usage -= cache->func.mem_size_get(eim); | ||
59 | eina_hash_del(cache->inactiv, eim->cache_key, eim); | ||
60 | cache->lru = eina_inlist_remove(cache->lru, EINA_INLIST_GET(eim)); | ||
61 | } | ||
62 | eim->flags.cached = 0; | ||
63 | eim->flags.dirty = 0; | ||
64 | eim->flags.activ = 0; | ||
65 | } | ||
66 | } | ||
67 | |||
68 | static Engine_Image_Entry * | ||
69 | _evas_cache_engine_image_alloc(Evas_Cache_Engine_Image *cache, | ||
70 | Image_Entry *ie, | ||
71 | const char *hkey) | ||
72 | { | ||
73 | Engine_Image_Entry *eim; | ||
74 | |||
75 | assert(cache); | ||
76 | |||
77 | if (cache->func.alloc) | ||
78 | eim = cache->func.alloc(); | ||
79 | else | ||
80 | eim = malloc(sizeof (Engine_Image_Entry)); | ||
81 | |||
82 | if (!eim) goto on_error; | ||
83 | memset(eim, 0, sizeof (Engine_Image_Entry)); | ||
84 | |||
85 | eim->cache = cache; | ||
86 | if (ie) | ||
87 | { | ||
88 | eim->w = ie->w; | ||
89 | eim->h = ie->h; | ||
90 | eim->src = ie; | ||
91 | eim->flags.need_parent = 1; | ||
92 | } | ||
93 | else | ||
94 | { | ||
95 | eim->w = -1; | ||
96 | eim->h = -1; | ||
97 | eim->flags.need_parent = 0; | ||
98 | eim->src = NULL; | ||
99 | } | ||
100 | |||
101 | eim->flags.cached = 0; | ||
102 | eim->references = 0; | ||
103 | eim->cache_key = hkey; | ||
104 | |||
105 | if (hkey) | ||
106 | _evas_cache_engine_image_make_active(cache, eim, hkey); | ||
107 | else | ||
108 | _evas_cache_engine_image_make_dirty(cache, eim); | ||
109 | |||
110 | return eim; | ||
111 | |||
112 | on_error: | ||
113 | if (eim) | ||
114 | evas_cache_engine_image_drop(eim); | ||
115 | eina_stringshare_del(hkey); | ||
116 | evas_cache_image_drop(ie); | ||
117 | return NULL; | ||
118 | } | ||
119 | |||
120 | static void | ||
121 | _evas_cache_engine_image_dealloc(Evas_Cache_Engine_Image *cache, Engine_Image_Entry *eim) | ||
122 | { | ||
123 | Image_Entry *im; | ||
124 | |||
125 | if (cache->func.debug) cache->func.debug("delete", eim); | ||
126 | |||
127 | _evas_cache_engine_image_remove_activ(cache, eim); | ||
128 | |||
129 | im = eim->src; | ||
130 | cache->func.destructor(eim); | ||
131 | if (im) evas_cache_image_drop(im); | ||
132 | |||
133 | if (cache->func.dealloc) | ||
134 | { | ||
135 | cache->func.dealloc(eim); | ||
136 | } | ||
137 | else | ||
138 | { | ||
139 | memset(eim, 0, sizeof (Engine_Image_Entry)); | ||
140 | free(eim); | ||
141 | } | ||
142 | } | ||
143 | |||
144 | EAPI int | ||
145 | evas_cache_engine_image_usage_get(Evas_Cache_Engine_Image *cache) | ||
146 | { | ||
147 | assert(cache != NULL); | ||
148 | |||
149 | return cache->usage; | ||
150 | } | ||
151 | |||
152 | EAPI int | ||
153 | evas_cache_engine_image_get(Evas_Cache_Engine_Image *cache) | ||
154 | { | ||
155 | assert(cache != NULL); | ||
156 | |||
157 | return cache->limit; | ||
158 | } | ||
159 | |||
160 | EAPI void | ||
161 | evas_cache_engine_image_set(Evas_Cache_Engine_Image *cache, int limit) | ||
162 | { | ||
163 | assert(cache != NULL); | ||
164 | |||
165 | cache->limit = limit; | ||
166 | } | ||
167 | |||
168 | EAPI Evas_Cache_Engine_Image * | ||
169 | evas_cache_engine_image_init(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_Image *parent) | ||
170 | { | ||
171 | Evas_Cache_Engine_Image *new; | ||
172 | |||
173 | new = malloc(sizeof (Evas_Cache_Engine_Image)); | ||
174 | if (!new) | ||
175 | return NULL; | ||
176 | |||
177 | new->func = *cb; | ||
178 | |||
179 | new->limit = 0; | ||
180 | new->usage = 0; | ||
181 | |||
182 | new->dirty = NULL; | ||
183 | new->lru = NULL; | ||
184 | new->activ = eina_hash_string_superfast_new(NULL); | ||
185 | new->inactiv = eina_hash_string_superfast_new(NULL); | ||
186 | |||
187 | new->parent = parent; | ||
188 | parent->references++; | ||
189 | |||
190 | new->brother = NULL; | ||
191 | |||
192 | return new; | ||
193 | } | ||
194 | |||
195 | EAPI Evas_Cache_Engine_Image * | ||
196 | evas_cache_engine_image_dup(const Evas_Cache_Engine_Image_Func *cb, Evas_Cache_Engine_Image *brother) | ||
197 | { | ||
198 | Evas_Cache_Engine_Image *new; | ||
199 | |||
200 | new = calloc(1, sizeof (Evas_Cache_Engine_Image)); | ||
201 | if (!new) | ||
202 | return NULL; | ||
203 | |||
204 | new->func = brother->func; | ||
205 | |||
206 | #define ORD(Func) if (cb->Func) new->func.Func = cb->Func; | ||
207 | |||
208 | ORD(key); | ||
209 | ORD(constructor); | ||
210 | ORD(destructor); | ||
211 | ORD(dirty_region); | ||
212 | ORD(dirty); | ||
213 | ORD(size_set); | ||
214 | ORD(update_data); | ||
215 | ORD(load); | ||
216 | ORD(mem_size_get); | ||
217 | ORD(debug); | ||
218 | |||
219 | #undef ORD | ||
220 | |||
221 | new->limit = -1; | ||
222 | new->usage = 0; | ||
223 | new->references = 1; | ||
224 | |||
225 | new->dirty = NULL; | ||
226 | new->activ = NULL; | ||
227 | |||
228 | new->parent = brother->parent; | ||
229 | new->parent->references++; | ||
230 | |||
231 | new->brother = brother; | ||
232 | brother->references++; | ||
233 | |||
234 | return new; | ||
235 | } | ||
236 | |||
237 | static Eina_Bool | ||
238 | _evas_cache_engine_image_free_cb(__UNUSED__ const Eina_Hash *hash, __UNUSED__ const void *key, void *data, void *fdata) | ||
239 | { | ||
240 | Eina_List **delete_list = fdata; | ||
241 | |||
242 | *delete_list = eina_list_prepend(*delete_list, data); | ||
243 | |||
244 | return EINA_TRUE; | ||
245 | } | ||
246 | |||
247 | EAPI void | ||
248 | evas_cache_engine_image_flush(Evas_Cache_Engine_Image *cache) | ||
249 | { | ||
250 | assert(cache != NULL); | ||
251 | |||
252 | while ((cache->lru) && (cache->limit < cache->usage)) | ||
253 | { | ||
254 | Engine_Image_Entry *eim; | ||
255 | |||
256 | eim = (Engine_Image_Entry *) cache->lru->last; | ||
257 | _evas_cache_engine_image_dealloc(cache, eim); | ||
258 | } | ||
259 | } | ||
260 | |||
261 | EAPI void | ||
262 | evas_cache_engine_image_shutdown(Evas_Cache_Engine_Image *cache) | ||
263 | { | ||
264 | Engine_Image_Entry *eim; | ||
265 | Eina_List *delete_list = NULL; | ||
266 | |||
267 | assert(cache != NULL); | ||
268 | |||
269 | if (cache->func.debug) cache->func.debug("shutdown-engine", NULL); | ||
270 | |||
271 | eina_hash_foreach(cache->inactiv, _evas_cache_engine_image_free_cb, &delete_list); | ||
272 | eina_hash_foreach(cache->activ, _evas_cache_engine_image_free_cb, &delete_list); | ||
273 | |||
274 | while (delete_list) | ||
275 | { | ||
276 | _evas_cache_engine_image_dealloc(cache, eina_list_data_get(delete_list)); | ||
277 | delete_list = eina_list_remove_list(delete_list, delete_list); | ||
278 | } | ||
279 | |||
280 | eina_hash_free(cache->inactiv); | ||
281 | eina_hash_free(cache->activ); | ||
282 | |||
283 | /* This is mad, I am about to destroy image still alive, but we need to prevent leak. */ | ||
284 | while (cache->dirty) | ||
285 | { | ||
286 | eim = (Engine_Image_Entry *) cache->dirty; | ||
287 | _evas_cache_engine_image_dealloc(cache, eim); | ||
288 | } | ||
289 | |||
290 | |||
291 | evas_cache_image_shutdown(cache->parent); | ||
292 | if (cache->brother) | ||
293 | evas_cache_engine_image_shutdown(cache->brother); | ||
294 | free(cache); | ||
295 | } | ||
296 | |||
297 | EAPI Engine_Image_Entry * | ||
298 | evas_cache_engine_image_request(Evas_Cache_Engine_Image *cache, | ||
299 | const char *file, const char *key, | ||
300 | RGBA_Image_Loadopts *lo, void *data, int *error) | ||
301 | { | ||
302 | Engine_Image_Entry *eim; | ||
303 | Image_Entry *im; | ||
304 | const char *ekey; | ||
305 | |||
306 | assert(cache != NULL); | ||
307 | |||
308 | *error = EVAS_LOAD_ERROR_NONE; | ||
309 | |||
310 | ekey = NULL; | ||
311 | eim = NULL; | ||
312 | |||
313 | im = evas_cache_image_request(cache->parent, file, key, lo, error); | ||
314 | if (!im) | ||
315 | goto on_error; | ||
316 | |||
317 | if (cache->func.key) | ||
318 | ekey = cache->func.key(im, file, key, lo, data); | ||
319 | else | ||
320 | ekey = eina_stringshare_add(im->cache_key); | ||
321 | if (!ekey) | ||
322 | { | ||
323 | *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; | ||
324 | goto on_error; | ||
325 | } | ||
326 | |||
327 | eim = eina_hash_find(cache->activ, ekey); | ||
328 | if (eim) | ||
329 | { | ||
330 | evas_cache_image_drop(im); | ||
331 | goto on_ok; | ||
332 | } | ||
333 | |||
334 | eim = eina_hash_find(cache->inactiv, ekey); | ||
335 | if (eim) | ||
336 | { | ||
337 | _evas_cache_engine_image_remove_activ(cache, eim); | ||
338 | _evas_cache_engine_image_make_active(cache, eim, ekey); | ||
339 | evas_cache_image_drop(im); | ||
340 | goto on_ok; | ||
341 | } | ||
342 | |||
343 | eim = _evas_cache_engine_image_alloc(cache, im, ekey); | ||
344 | if (!eim) | ||
345 | { | ||
346 | *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; | ||
347 | return NULL; | ||
348 | } | ||
349 | |||
350 | *error = cache->func.constructor(eim, data); | ||
351 | if (*error != EVAS_LOAD_ERROR_NONE) goto on_error; | ||
352 | if (cache->func.debug) | ||
353 | cache->func.debug("constructor-engine", eim); | ||
354 | |||
355 | on_ok: | ||
356 | eim->references++; | ||
357 | return eim; | ||
358 | |||
359 | on_error: | ||
360 | if (!eim) | ||
361 | { | ||
362 | if (im) evas_cache_image_drop(im); | ||
363 | if (ekey) eina_stringshare_del(ekey); | ||
364 | } | ||
365 | else | ||
366 | { | ||
367 | _evas_cache_engine_image_dealloc(cache, eim); | ||
368 | } | ||
369 | |||
370 | return NULL; | ||
371 | } | ||
372 | |||
373 | EAPI void | ||
374 | evas_cache_engine_image_drop(Engine_Image_Entry *eim) | ||
375 | { | ||
376 | Evas_Cache_Engine_Image *cache; | ||
377 | |||
378 | assert(eim); | ||
379 | assert(eim->cache); | ||
380 | |||
381 | eim->references--; | ||
382 | cache = eim->cache; | ||
383 | |||
384 | if (eim->flags.dirty) | ||
385 | { | ||
386 | _evas_cache_engine_image_dealloc(cache, eim); | ||
387 | return ; | ||
388 | } | ||
389 | |||
390 | if (eim->references == 0) | ||
391 | { | ||
392 | _evas_cache_engine_image_remove_activ(cache, eim); | ||
393 | _evas_cache_engine_image_make_inactive(cache, eim, eim->cache_key); | ||
394 | evas_cache_engine_image_flush(cache); | ||
395 | return ; | ||
396 | } | ||
397 | } | ||
398 | |||
399 | EAPI Engine_Image_Entry * | ||
400 | evas_cache_engine_image_dirty(Engine_Image_Entry *eim, unsigned int x, unsigned int y, unsigned int w, unsigned int h) | ||
401 | { | ||
402 | Engine_Image_Entry *eim_dirty = eim; | ||
403 | Image_Entry *im_dirty = NULL; | ||
404 | Image_Entry *im; | ||
405 | Evas_Cache_Engine_Image *cache; | ||
406 | unsigned char alloc_eim; | ||
407 | |||
408 | assert(eim); | ||
409 | assert(eim->cache); | ||
410 | |||
411 | cache = eim->cache; | ||
412 | if (!(eim->flags.dirty)) | ||
413 | { | ||
414 | alloc_eim = 0; | ||
415 | |||
416 | if (eim->flags.need_parent == 1) | ||
417 | { | ||
418 | im = eim->src; | ||
419 | im_dirty = evas_cache_image_dirty(im, x, y, w, h); | ||
420 | |||
421 | /* If im == im_dirty, this meens that we have only one reference to the eim. */ | ||
422 | if (im != im_dirty) | ||
423 | { | ||
424 | if (eim->references == 1) | ||
425 | { | ||
426 | _evas_cache_engine_image_remove_activ(cache, eim); | ||
427 | _evas_cache_engine_image_make_dirty(cache, eim); | ||
428 | |||
429 | eim->src = im_dirty; | ||
430 | } | ||
431 | else | ||
432 | alloc_eim = 1; | ||
433 | } | ||
434 | } | ||
435 | else | ||
436 | if (eim->references > 1) | ||
437 | { | ||
438 | alloc_eim = 1; | ||
439 | } | ||
440 | else | ||
441 | { | ||
442 | _evas_cache_engine_image_remove_activ(cache, eim_dirty); | ||
443 | _evas_cache_engine_image_make_dirty(cache, eim_dirty); | ||
444 | } | ||
445 | |||
446 | if (alloc_eim == 1) | ||
447 | { | ||
448 | int error; | ||
449 | |||
450 | eim_dirty = _evas_cache_engine_image_alloc(cache, im_dirty, NULL); | ||
451 | if (!eim_dirty) goto on_error; | ||
452 | |||
453 | eim_dirty->w = eim->w; | ||
454 | eim_dirty->h = eim->h; | ||
455 | eim_dirty->references = 1; | ||
456 | |||
457 | error = cache->func.dirty(eim_dirty, eim); | ||
458 | if (cache->func.debug) | ||
459 | cache->func.debug("dirty-engine", eim_dirty); | ||
460 | |||
461 | if (error != 0) goto on_error; | ||
462 | |||
463 | evas_cache_engine_image_drop(eim); | ||
464 | } | ||
465 | } | ||
466 | |||
467 | if (cache->func.dirty_region) | ||
468 | cache->func.dirty_region(eim_dirty, x, y, w, h); | ||
469 | if (cache->func.debug) | ||
470 | cache->func.debug("dirty-region-engine", eim_dirty); | ||
471 | |||
472 | return eim_dirty; | ||
473 | |||
474 | on_error: | ||
475 | if (eim) evas_cache_engine_image_drop(eim); | ||
476 | if (eim_dirty && eim_dirty != eim) | ||
477 | evas_cache_engine_image_drop(eim_dirty); | ||
478 | else | ||
479 | if (im_dirty) evas_cache_image_drop(im_dirty); | ||
480 | |||
481 | return NULL; | ||
482 | } | ||
483 | |||
484 | EAPI Engine_Image_Entry * | ||
485 | evas_cache_engine_image_alone(Engine_Image_Entry *eim, void *data) | ||
486 | { | ||
487 | Evas_Cache_Engine_Image *cache; | ||
488 | Image_Entry *im; | ||
489 | |||
490 | |||
491 | assert(eim); | ||
492 | assert(eim->cache); | ||
493 | |||
494 | cache = eim->cache; | ||
495 | im = evas_cache_image_alone(eim->src); | ||
496 | if (im != eim->src) | ||
497 | { | ||
498 | eim = _evas_cache_engine_image_alloc(cache, im, NULL); | ||
499 | if (!eim) goto on_error; | ||
500 | |||
501 | eim->references = 1; | ||
502 | |||
503 | if (cache->func.constructor(eim, data) != EVAS_LOAD_ERROR_NONE) | ||
504 | goto on_error; | ||
505 | } | ||
506 | /* FIXME */ | ||
507 | return eim; | ||
508 | |||
509 | on_error: | ||
510 | evas_cache_image_drop(im); | ||
511 | return NULL; | ||
512 | } | ||
513 | |||
514 | static Engine_Image_Entry * | ||
515 | _evas_cache_engine_image_push_dirty(Evas_Cache_Engine_Image *cache, Image_Entry *im, void *engine_data) | ||
516 | { | ||
517 | Engine_Image_Entry *eim; | ||
518 | int error; | ||
519 | |||
520 | eim = _evas_cache_engine_image_alloc(cache, im, NULL); | ||
521 | if (!eim) goto on_error; | ||
522 | eim->references = 1; | ||
523 | |||
524 | error = cache->func.update_data(eim, engine_data); | ||
525 | if (cache->func.debug) | ||
526 | cache->func.debug("dirty-update_data-engine", eim); | ||
527 | if (error != 0) goto on_error; | ||
528 | |||
529 | return eim; | ||
530 | |||
531 | on_error: | ||
532 | if (eim) | ||
533 | evas_cache_engine_image_drop(eim); | ||
534 | return NULL; | ||
535 | } | ||
536 | |||
537 | EAPI Engine_Image_Entry * | ||
538 | evas_cache_engine_image_copied_data(Evas_Cache_Engine_Image *cache, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, int cspace, void *engine_data) | ||
539 | { | ||
540 | Image_Entry *im; | ||
541 | |||
542 | assert(cache); | ||
543 | |||
544 | im = evas_cache_image_copied_data(cache->parent, w, h, image_data, alpha, cspace); | ||
545 | |||
546 | return _evas_cache_engine_image_push_dirty(cache, im, engine_data); | ||
547 | } | ||
548 | |||
549 | EAPI Engine_Image_Entry * | ||
550 | evas_cache_engine_image_data(Evas_Cache_Engine_Image *cache, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, int cspace, void *engine_data) | ||
551 | { | ||
552 | Image_Entry *im; | ||
553 | |||
554 | assert(cache); | ||
555 | |||
556 | im = evas_cache_image_data(cache->parent, w, h, image_data, alpha, cspace); | ||
557 | |||
558 | return _evas_cache_engine_image_push_dirty(cache, im, engine_data); | ||
559 | } | ||
560 | |||
561 | EAPI Engine_Image_Entry * | ||
562 | evas_cache_engine_image_size_set(Engine_Image_Entry *eim, unsigned int w, unsigned int h) | ||
563 | { | ||
564 | Evas_Cache_Engine_Image *cache; | ||
565 | Engine_Image_Entry *new; | ||
566 | Image_Entry *im; | ||
567 | const char *hkey; | ||
568 | int error; | ||
569 | |||
570 | assert(eim); | ||
571 | assert(eim->cache); | ||
572 | assert(eim->references > 0); | ||
573 | |||
574 | im = NULL; | ||
575 | cache = eim->cache; | ||
576 | |||
577 | if (eim->flags.need_parent == 1) | ||
578 | { | ||
579 | assert(eim->src); | ||
580 | |||
581 | if (eim->src->w == w | ||
582 | && eim->src->h == h) | ||
583 | return eim; | ||
584 | |||
585 | im = evas_cache_image_size_set(eim->src, w, h); | ||
586 | /* FIXME: Good idea to call update_data ? */ | ||
587 | if (im == eim->src) return eim; | ||
588 | eim->src = NULL; | ||
589 | } | ||
590 | |||
591 | hkey = (eim->references > 1 ) ? eina_stringshare_add(eim->cache_key) : NULL; | ||
592 | |||
593 | new = _evas_cache_engine_image_alloc(cache, im, hkey); | ||
594 | if (!new) goto on_error; | ||
595 | |||
596 | new->w = w; | ||
597 | new->h = h; | ||
598 | new->references = 1; | ||
599 | |||
600 | error = cache->func.size_set(new, eim); | ||
601 | if (error) goto on_error; | ||
602 | |||
603 | evas_cache_engine_image_drop(eim); | ||
604 | return new; | ||
605 | |||
606 | on_error: | ||
607 | if (new) | ||
608 | evas_cache_engine_image_drop(new); | ||
609 | else | ||
610 | if (im) | ||
611 | evas_cache_image_drop(im); | ||
612 | evas_cache_engine_image_drop(eim); | ||
613 | |||
614 | return NULL; | ||
615 | } | ||
616 | |||
617 | EAPI void | ||
618 | evas_cache_engine_image_load_data(Engine_Image_Entry *eim) | ||
619 | { | ||
620 | Evas_Cache_Engine_Image *cache; | ||
621 | int size = 0; | ||
622 | |||
623 | assert(eim); | ||
624 | assert(eim->src); | ||
625 | assert(eim->cache); | ||
626 | |||
627 | if (eim->flags.loaded) return; | ||
628 | |||
629 | if (eim->src) | ||
630 | evas_cache_image_load_data(eim->src); | ||
631 | |||
632 | cache = eim->cache; | ||
633 | if (cache->func.debug) | ||
634 | cache->func.debug("load-engine", eim); | ||
635 | |||
636 | if (eim->flags.dirty) | ||
637 | size = cache->func.mem_size_get(eim); | ||
638 | cache = eim->cache; | ||
639 | cache->func.load(eim, eim->src); | ||
640 | if (eim->flags.dirty) | ||
641 | cache->usage += cache->func.mem_size_get(eim) - size; | ||
642 | |||
643 | eim->flags.loaded = 1; | ||
644 | } | ||
645 | |||
646 | EAPI Engine_Image_Entry * | ||
647 | evas_cache_engine_image_engine(Evas_Cache_Engine_Image *cache, void *engine_data) | ||
648 | { | ||
649 | Engine_Image_Entry *eim; | ||
650 | Image_Entry *ie; | ||
651 | int error; | ||
652 | |||
653 | ie = evas_cache_image_empty(cache->parent); | ||
654 | if (!ie) return NULL; | ||
655 | |||
656 | eim = _evas_cache_engine_image_alloc(cache, ie, NULL); | ||
657 | if (!eim) goto on_error; | ||
658 | eim->references = 1; | ||
659 | |||
660 | error = cache->func.update_data(eim, engine_data); | ||
661 | if (cache->func.debug) | ||
662 | cache->func.debug("update_data-engine", eim); | ||
663 | |||
664 | if (error != 0) goto on_error; | ||
665 | |||
666 | return eim; | ||
667 | |||
668 | on_error: | ||
669 | if (!eim) | ||
670 | evas_cache_image_drop(ie); | ||
671 | else | ||
672 | evas_cache_engine_image_drop(eim); | ||
673 | |||
674 | return NULL; | ||
675 | } | ||
676 | |||
677 | EAPI void | ||
678 | evas_cache_engine_image_colorspace(Engine_Image_Entry *eim, int cspace, void *engine_data) | ||
679 | { | ||
680 | Evas_Cache_Engine_Image *cache = eim->cache; | ||
681 | |||
682 | assert(cache); | ||
683 | |||
684 | cache->func.destructor(eim); | ||
685 | evas_cache_image_colorspace(eim->src, cspace); | ||
686 | cache->func.constructor(eim, engine_data); | ||
687 | if (cache->func.debug) | ||
688 | cache->func.debug("cosntructor-colorspace-engine", eim); | ||
689 | } | ||
690 | |||
691 | EAPI void | ||
692 | evas_cache_engine_parent_not_needed(Engine_Image_Entry *eim) | ||
693 | { | ||
694 | assert(eim); | ||
695 | assert(eim->cache); | ||
696 | |||
697 | eim->flags.need_parent = 0; | ||
698 | evas_cache_image_data_not_needed(eim->src); | ||
699 | } | ||
diff --git a/libraries/evas/src/lib/cache/evas_cache_image.c b/libraries/evas/src/lib/cache/evas_cache_image.c new file mode 100644 index 0000000..d52c64e --- /dev/null +++ b/libraries/evas/src/lib/cache/evas_cache_image.c | |||
@@ -0,0 +1,1433 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <stdlib.h> | ||
6 | #include <assert.h> | ||
7 | #include <sys/types.h> | ||
8 | #include <sys/stat.h> | ||
9 | #include <errno.h> | ||
10 | |||
11 | #ifdef HAVE_EVIL | ||
12 | # include <Evil.h> | ||
13 | #endif | ||
14 | |||
15 | #include "evas_common.h" | ||
16 | #include "evas_private.h" | ||
17 | |||
18 | //#define CACHEDUMP 1 | ||
19 | |||
20 | #ifdef EVAS_CSERVE | ||
21 | // FIXME: cache server and threaded preload clash badly atm - disable | ||
22 | //#undef BUILD_ASYNC_PRELOAD | ||
23 | #endif | ||
24 | |||
25 | #ifdef BUILD_ASYNC_PRELOAD | ||
26 | typedef struct _Evas_Cache_Preload Evas_Cache_Preload; | ||
27 | |||
28 | struct _Evas_Cache_Preload | ||
29 | { | ||
30 | EINA_INLIST; | ||
31 | Image_Entry *ie; | ||
32 | }; | ||
33 | |||
34 | static LK(engine_lock); | ||
35 | static LK(wakeup); | ||
36 | static int _evas_cache_mutex_init = 0; | ||
37 | |||
38 | static Eina_Condition cond_wakeup; | ||
39 | |||
40 | static void _evas_cache_image_entry_preload_remove(Image_Entry *ie, const void *target); | ||
41 | #endif | ||
42 | |||
43 | #define FREESTRC(Var) \ | ||
44 | if (Var) \ | ||
45 | { \ | ||
46 | eina_stringshare_del(Var); \ | ||
47 | Var = NULL; \ | ||
48 | } | ||
49 | |||
50 | static void _evas_cache_image_dirty_add(Image_Entry *im); | ||
51 | static void _evas_cache_image_dirty_del(Image_Entry *im); | ||
52 | static void _evas_cache_image_activ_add(Image_Entry *im); | ||
53 | static void _evas_cache_image_activ_del(Image_Entry *im); | ||
54 | static void _evas_cache_image_lru_add(Image_Entry *im); | ||
55 | static void _evas_cache_image_lru_del(Image_Entry *im); | ||
56 | static void _evas_cache_image_lru_nodata_add(Image_Entry *im); | ||
57 | static void _evas_cache_image_lru_nodata_del(Image_Entry *im); | ||
58 | |||
59 | static void | ||
60 | _evas_cache_image_dirty_add(Image_Entry *im) | ||
61 | { | ||
62 | if (im->flags.dirty) return; | ||
63 | _evas_cache_image_activ_del(im); | ||
64 | _evas_cache_image_lru_del(im); | ||
65 | _evas_cache_image_lru_nodata_del(im); | ||
66 | im->flags.dirty = 1; | ||
67 | im->flags.cached = 1; | ||
68 | #ifdef EVAS_FRAME_QUEUING | ||
69 | LKL(im->cache->lock); | ||
70 | #endif | ||
71 | im->cache->dirty = eina_inlist_prepend(im->cache->dirty, EINA_INLIST_GET(im)); | ||
72 | #ifdef EVAS_FRAME_QUEUING | ||
73 | LKU(im->cache->lock); | ||
74 | #endif | ||
75 | if (im->cache_key) | ||
76 | { | ||
77 | eina_stringshare_del(im->cache_key); | ||
78 | im->cache_key = NULL; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | static void | ||
83 | _evas_cache_image_dirty_del(Image_Entry *im) | ||
84 | { | ||
85 | if (!im->flags.dirty) return; | ||
86 | im->flags.dirty = 0; | ||
87 | im->flags.cached = 0; | ||
88 | #ifdef EVAS_FRAME_QUEUING | ||
89 | LKL(im->cache->lock); | ||
90 | #endif | ||
91 | im->cache->dirty = eina_inlist_remove(im->cache->dirty, EINA_INLIST_GET(im)); | ||
92 | #ifdef EVAS_FRAME_QUEUING | ||
93 | LKU(im->cache->lock); | ||
94 | #endif | ||
95 | } | ||
96 | |||
97 | static void | ||
98 | _evas_cache_image_activ_add(Image_Entry *im) | ||
99 | { | ||
100 | if (im->flags.activ) return; | ||
101 | _evas_cache_image_dirty_del(im); | ||
102 | _evas_cache_image_lru_del(im); | ||
103 | _evas_cache_image_lru_nodata_del(im); | ||
104 | if (!im->cache_key) return; | ||
105 | im->flags.activ = 1; | ||
106 | im->flags.cached = 1; | ||
107 | #ifdef EVAS_FRAME_QUEUING | ||
108 | LKL(im->cache->lock); | ||
109 | #endif | ||
110 | eina_hash_direct_add(im->cache->activ, im->cache_key, im); | ||
111 | #ifdef EVAS_FRAME_QUEUING | ||
112 | LKU(im->cache->lock); | ||
113 | #endif | ||
114 | } | ||
115 | |||
116 | static void | ||
117 | _evas_cache_image_activ_del(Image_Entry *im) | ||
118 | { | ||
119 | if (!im->flags.activ) return; | ||
120 | if (!im->cache_key) return; | ||
121 | im->flags.activ = 0; | ||
122 | im->flags.cached = 0; | ||
123 | #ifdef EVAS_FRAME_QUEUING | ||
124 | LKL(im->cache->lock); | ||
125 | #endif | ||
126 | eina_hash_del(im->cache->activ, im->cache_key, im); | ||
127 | #ifdef EVAS_FRAME_QUEUING | ||
128 | LKU(im->cache->lock); | ||
129 | #endif | ||
130 | } | ||
131 | |||
132 | static void | ||
133 | _evas_cache_image_lru_add(Image_Entry *im) | ||
134 | { | ||
135 | if (im->flags.lru) return; | ||
136 | _evas_cache_image_dirty_del(im); | ||
137 | _evas_cache_image_activ_del(im); | ||
138 | _evas_cache_image_lru_nodata_del(im); | ||
139 | if (!im->cache_key) return; | ||
140 | im->flags.lru = 1; | ||
141 | im->flags.cached = 1; | ||
142 | #ifdef EVAS_FRAME_QUEUING | ||
143 | LKL(im->cache->lock); | ||
144 | #endif | ||
145 | eina_hash_direct_add(im->cache->inactiv, im->cache_key, im); | ||
146 | im->cache->lru = eina_inlist_prepend(im->cache->lru, EINA_INLIST_GET(im)); | ||
147 | im->cache->usage += im->cache->func.mem_size_get(im); | ||
148 | #ifdef EVAS_FRAME_QUEUING | ||
149 | LKU(im->cache->lock); | ||
150 | #endif | ||
151 | } | ||
152 | |||
153 | static void | ||
154 | _evas_cache_image_lru_del(Image_Entry *im) | ||
155 | { | ||
156 | if (!im->flags.lru) return; | ||
157 | if (!im->cache_key) return; | ||
158 | im->flags.lru = 0; | ||
159 | im->flags.cached = 0; | ||
160 | #ifdef EVAS_FRAME_QUEUING | ||
161 | LKL(im->cache->lock); | ||
162 | #endif | ||
163 | eina_hash_del(im->cache->inactiv, im->cache_key, im); | ||
164 | im->cache->lru = eina_inlist_remove(im->cache->lru, EINA_INLIST_GET(im)); | ||
165 | im->cache->usage -= im->cache->func.mem_size_get(im); | ||
166 | #ifdef EVAS_FRAME_QUEUING | ||
167 | LKU(im->cache->lock); | ||
168 | #endif | ||
169 | } | ||
170 | |||
171 | static void | ||
172 | _evas_cache_image_lru_nodata_add(Image_Entry *im) | ||
173 | { | ||
174 | if (im->flags.lru_nodata) return; | ||
175 | _evas_cache_image_dirty_del(im); | ||
176 | _evas_cache_image_activ_del(im); | ||
177 | _evas_cache_image_lru_del(im); | ||
178 | im->flags.lru = 1; | ||
179 | im->flags.cached = 1; | ||
180 | #ifdef EVAS_FRAME_QUEUING | ||
181 | LKL(im->cache->lock); | ||
182 | #endif | ||
183 | im->cache->lru_nodata = eina_inlist_prepend(im->cache->lru_nodata, EINA_INLIST_GET(im)); | ||
184 | #ifdef EVAS_FRAME_QUEUING | ||
185 | LKU(im->cache->lock); | ||
186 | #endif | ||
187 | } | ||
188 | |||
189 | static void | ||
190 | _evas_cache_image_lru_nodata_del(Image_Entry *im) | ||
191 | { | ||
192 | if (!im->flags.lru_nodata) return; | ||
193 | im->flags.lru = 0; | ||
194 | im->flags.cached = 0; | ||
195 | #ifdef EVAS_FRAME_QUEUING | ||
196 | LKL(im->cache->lock); | ||
197 | #endif | ||
198 | im->cache->lru_nodata = eina_inlist_remove(im->cache->lru_nodata, EINA_INLIST_GET(im)); | ||
199 | #ifdef EVAS_FRAME_QUEUING | ||
200 | LKU(im->cache->lock); | ||
201 | #endif | ||
202 | } | ||
203 | |||
204 | static void | ||
205 | _evas_cache_image_entry_delete(Evas_Cache_Image *cache, Image_Entry *ie) | ||
206 | { | ||
207 | if (!ie) return; | ||
208 | if (cache->func.debug) cache->func.debug("deleting", ie); | ||
209 | #ifdef BUILD_ASYNC_PRELOAD | ||
210 | if (ie->flags.delete_me == 1) return; | ||
211 | if (ie->preload) | ||
212 | { | ||
213 | ie->flags.delete_me = 1; | ||
214 | _evas_cache_image_entry_preload_remove(ie, NULL); | ||
215 | return; | ||
216 | } | ||
217 | #endif | ||
218 | |||
219 | _evas_cache_image_dirty_del(ie); | ||
220 | _evas_cache_image_activ_del(ie); | ||
221 | _evas_cache_image_lru_del(ie); | ||
222 | _evas_cache_image_lru_nodata_del(ie); | ||
223 | |||
224 | cache->func.destructor(ie); | ||
225 | FREESTRC(ie->cache_key); | ||
226 | FREESTRC(ie->file); | ||
227 | FREESTRC(ie->key); | ||
228 | ie->cache = NULL; | ||
229 | cache->func.surface_delete(ie); | ||
230 | |||
231 | #ifdef BUILD_ASYNC_PRELOAD | ||
232 | LKD(ie->lock); | ||
233 | LKD(ie->lock_cancel); | ||
234 | #endif | ||
235 | #ifdef EVAS_FRAME_QUEUING | ||
236 | LKD(ie->lock_references); | ||
237 | #endif | ||
238 | cache->func.dealloc(ie); | ||
239 | } | ||
240 | |||
241 | static Eina_Bool | ||
242 | _timestamp_compare(Image_Timestamp *tstamp, struct stat *st) | ||
243 | { | ||
244 | if (tstamp->mtime != st->st_mtime) return EINA_FALSE; | ||
245 | if (tstamp->size != st->st_size) return EINA_FALSE; | ||
246 | if (tstamp->ino != st->st_ino) return EINA_FALSE; | ||
247 | #ifdef _STAT_VER_LINUX | ||
248 | #if (defined __USE_MISC && defined st_mtime) | ||
249 | if (tstamp->mtime_nsec != (unsigned long int)st->st_mtim.tv_nsec) | ||
250 | return EINA_FALSE; | ||
251 | #else | ||
252 | if (tstamp->mtime_nsec != (unsigned long int)st->st_mtimensec) | ||
253 | return EINA_FALSE; | ||
254 | #endif | ||
255 | #endif | ||
256 | return EINA_TRUE; | ||
257 | } | ||
258 | |||
259 | static void | ||
260 | _timestamp_build(Image_Timestamp *tstamp, struct stat *st) | ||
261 | { | ||
262 | tstamp->mtime = st->st_mtime; | ||
263 | tstamp->size = st->st_size; | ||
264 | tstamp->ino = st->st_ino; | ||
265 | #ifdef _STAT_VER_LINUX | ||
266 | #if (defined __USE_MISC && defined st_mtime) | ||
267 | tstamp->mtime_nsec = (unsigned long int)st->st_mtim.tv_nsec; | ||
268 | #else | ||
269 | tstamp->mtime_nsec = (unsigned long int)st->st_mtimensec; | ||
270 | #endif | ||
271 | #endif | ||
272 | } | ||
273 | |||
274 | static Image_Entry * | ||
275 | _evas_cache_image_entry_new(Evas_Cache_Image *cache, | ||
276 | const char *hkey, | ||
277 | Image_Timestamp *tstamp, | ||
278 | const char *file, | ||
279 | const char *key, | ||
280 | RGBA_Image_Loadopts *lo, | ||
281 | int *error) | ||
282 | { | ||
283 | Image_Entry *ie; | ||
284 | |||
285 | ie = cache->func.alloc(); | ||
286 | if (!ie) | ||
287 | { | ||
288 | *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; | ||
289 | return NULL; | ||
290 | } | ||
291 | ie->cache = cache; | ||
292 | if (hkey) ie->cache_key = eina_stringshare_add(hkey); | ||
293 | ie->flags.need_data = 1; | ||
294 | ie->space = EVAS_COLORSPACE_ARGB8888; | ||
295 | ie->w = -1; | ||
296 | ie->h = -1; | ||
297 | ie->scale = 1; | ||
298 | if (file) ie->file = eina_stringshare_add(file); | ||
299 | if (key) ie->key = eina_stringshare_add(key); | ||
300 | if (tstamp) ie->tstamp = *tstamp; | ||
301 | else memset(&ie->tstamp, 0, sizeof(Image_Timestamp)); | ||
302 | |||
303 | #ifdef EVAS_FRAME_QUEUING | ||
304 | LKI(ie->lock_references); | ||
305 | #endif | ||
306 | #ifdef BUILD_ASYNC_PRELOAD | ||
307 | LKI(ie->lock); | ||
308 | LKI(ie->lock_cancel); | ||
309 | #endif | ||
310 | |||
311 | if (lo) ie->load_opts = *lo; | ||
312 | if (ie->file) | ||
313 | { | ||
314 | *error = cache->func.constructor(ie); | ||
315 | if (*error != EVAS_LOAD_ERROR_NONE) | ||
316 | { | ||
317 | _evas_cache_image_entry_delete(cache, ie); | ||
318 | return NULL; | ||
319 | } | ||
320 | } | ||
321 | if (cache->func.debug) cache->func.debug("build", ie); | ||
322 | if (ie->cache_key) _evas_cache_image_activ_add(ie); | ||
323 | else _evas_cache_image_dirty_add(ie); | ||
324 | return ie; | ||
325 | } | ||
326 | |||
327 | static void | ||
328 | _evas_cache_image_entry_surface_alloc__locked(Evas_Cache_Image *cache, | ||
329 | Image_Entry *ie, | ||
330 | unsigned int wmin, | ||
331 | unsigned int hmin) | ||
332 | { | ||
333 | if ((ie->allocated.w == wmin) && (ie->allocated.h == hmin)) return; | ||
334 | if (cache->func.surface_alloc(ie, wmin, hmin)) | ||
335 | { | ||
336 | wmin = 0; | ||
337 | hmin = 0; | ||
338 | } | ||
339 | ie->w = wmin; | ||
340 | ie->h = hmin; | ||
341 | ie->allocated.w = wmin; | ||
342 | ie->allocated.h = hmin; | ||
343 | } | ||
344 | |||
345 | static void | ||
346 | _evas_cache_image_entry_surface_alloc(Evas_Cache_Image *cache, | ||
347 | Image_Entry *ie, int w, int h) | ||
348 | { | ||
349 | int wmin = w > 0 ? w : 1; | ||
350 | int hmin = h > 0 ? h : 1; | ||
351 | #ifdef BUILD_ASYNC_PRELOAD | ||
352 | LKL(engine_lock); | ||
353 | #endif | ||
354 | _evas_cache_image_entry_surface_alloc__locked(cache, ie, wmin, hmin); | ||
355 | #ifdef BUILD_ASYNC_PRELOAD | ||
356 | LKU(engine_lock); | ||
357 | #endif | ||
358 | } | ||
359 | |||
360 | #ifdef BUILD_ASYNC_PRELOAD | ||
361 | static void | ||
362 | _evas_cache_image_async_heavy(void *data) | ||
363 | { | ||
364 | Evas_Cache_Image *cache; | ||
365 | Image_Entry *current; | ||
366 | int error; | ||
367 | int pchannel; | ||
368 | |||
369 | current = data; | ||
370 | |||
371 | LKL(current->lock); | ||
372 | pchannel = current->channel; | ||
373 | current->channel++; | ||
374 | cache = current->cache; | ||
375 | |||
376 | if ((!current->flags.loaded) && | ||
377 | ((Evas_Image_Load_Func*) current->info.module)->threadable) | ||
378 | { | ||
379 | error = cache->func.load(current); | ||
380 | if (cache->func.debug) cache->func.debug("load", current); | ||
381 | current->load_error = error; | ||
382 | if (error != EVAS_LOAD_ERROR_NONE) | ||
383 | { | ||
384 | current->flags.loaded = 0; | ||
385 | _evas_cache_image_entry_surface_alloc(cache, current, | ||
386 | current->w, current->h); | ||
387 | } | ||
388 | else | ||
389 | { | ||
390 | current->flags.loaded = 1; | ||
391 | } | ||
392 | } | ||
393 | current->channel = pchannel; | ||
394 | // check the unload cancel flag | ||
395 | LKL(current->lock_cancel); | ||
396 | if (current->unload_cancel) | ||
397 | { | ||
398 | current->unload_cancel = EINA_FALSE; | ||
399 | cache->func.surface_delete(current); | ||
400 | current->flags.loaded = 0; | ||
401 | current->flags.preload_done = 0; | ||
402 | } | ||
403 | LKU(current->lock_cancel); | ||
404 | LKU(current->lock); | ||
405 | } | ||
406 | |||
407 | static void | ||
408 | _evas_cache_image_async_end(void *data) | ||
409 | { | ||
410 | Image_Entry *ie = (Image_Entry *)data; | ||
411 | Evas_Cache_Target *tmp; | ||
412 | |||
413 | ie->cache->preload = eina_list_remove(ie->cache->preload, ie); | ||
414 | ie->cache->pending = eina_list_remove(ie->cache->pending, ie); | ||
415 | ie->preload = NULL; | ||
416 | ie->flags.preload_done = ie->flags.loaded; | ||
417 | while ((tmp = ie->targets)) | ||
418 | { | ||
419 | evas_object_inform_call_image_preloaded((Evas_Object*) tmp->target); | ||
420 | ie->targets = (Evas_Cache_Target *) | ||
421 | eina_inlist_remove(EINA_INLIST_GET(ie->targets), | ||
422 | EINA_INLIST_GET(ie->targets)); | ||
423 | free(tmp); | ||
424 | } | ||
425 | } | ||
426 | |||
427 | static void | ||
428 | _evas_cache_image_async_cancel(void *data) | ||
429 | { | ||
430 | Evas_Cache_Image *cache = NULL; | ||
431 | Image_Entry *ie = (Image_Entry *)data; | ||
432 | |||
433 | ie->preload = NULL; | ||
434 | ie->cache->pending = eina_list_remove(ie->cache->pending, ie); | ||
435 | if ((ie->flags.delete_me) || (ie->flags.dirty)) | ||
436 | { | ||
437 | ie->flags.delete_me = 0; | ||
438 | _evas_cache_image_entry_delete(ie->cache, ie); | ||
439 | return; | ||
440 | } | ||
441 | if (ie->flags.loaded) _evas_cache_image_async_end(ie); | ||
442 | #ifdef EVAS_FRAME_QUEUING | ||
443 | LKL(ie->lock_references); | ||
444 | #endif | ||
445 | if (ie->references == 0) | ||
446 | { | ||
447 | _evas_cache_image_lru_add(ie); | ||
448 | cache = ie->cache; | ||
449 | } | ||
450 | #ifdef EVAS_FRAME_QUEUING | ||
451 | LKU(ie->lock_references); | ||
452 | #endif | ||
453 | if (cache) evas_cache_image_flush(cache); | ||
454 | } | ||
455 | |||
456 | // note - preload_add assumes a target is ONLY added ONCE to the image | ||
457 | // entry. make sure you only add once, or remove first, then add | ||
458 | static int | ||
459 | _evas_cache_image_entry_preload_add(Image_Entry *ie, const void *target) | ||
460 | { | ||
461 | Evas_Cache_Target *tg; | ||
462 | |||
463 | if (ie->flags.preload_done) return 0; | ||
464 | |||
465 | tg = malloc(sizeof (Evas_Cache_Target)); | ||
466 | if (!tg) return 0; | ||
467 | |||
468 | tg->target = target; | ||
469 | ie->targets = (Evas_Cache_Target *) | ||
470 | eina_inlist_append(EINA_INLIST_GET(ie->targets), EINA_INLIST_GET(tg)); | ||
471 | if (!ie->preload) | ||
472 | { | ||
473 | ie->cache->preload = eina_list_append(ie->cache->preload, ie); | ||
474 | ie->flags.pending = 0; | ||
475 | ie->preload = evas_preload_thread_run(_evas_cache_image_async_heavy, | ||
476 | _evas_cache_image_async_end, | ||
477 | _evas_cache_image_async_cancel, | ||
478 | ie); | ||
479 | } | ||
480 | return 1; | ||
481 | } | ||
482 | |||
483 | static void | ||
484 | _evas_cache_image_entry_preload_remove(Image_Entry *ie, const void *target) | ||
485 | { | ||
486 | if (target) | ||
487 | { | ||
488 | Evas_Cache_Target *tg; | ||
489 | |||
490 | EINA_INLIST_FOREACH(ie->targets, tg) | ||
491 | { | ||
492 | if (tg->target == target) | ||
493 | { | ||
494 | // FIXME: No callback when we cancel only for one target ? | ||
495 | ie->targets = (Evas_Cache_Target *) | ||
496 | eina_inlist_remove(EINA_INLIST_GET(ie->targets), | ||
497 | EINA_INLIST_GET(tg)); | ||
498 | free(tg); | ||
499 | break; | ||
500 | } | ||
501 | } | ||
502 | } | ||
503 | else | ||
504 | { | ||
505 | Evas_Cache_Target *tg; | ||
506 | |||
507 | while (ie->targets) | ||
508 | { | ||
509 | tg = ie->targets; | ||
510 | ie->targets = (Evas_Cache_Target *) | ||
511 | eina_inlist_remove(EINA_INLIST_GET(ie->targets), | ||
512 | EINA_INLIST_GET(tg)); | ||
513 | free(tg); | ||
514 | } | ||
515 | } | ||
516 | |||
517 | if ((!ie->targets) && (ie->preload) && (!ie->flags.pending)) | ||
518 | { | ||
519 | ie->cache->preload = eina_list_remove(ie->cache->preload, ie); | ||
520 | ie->cache->pending = eina_list_append(ie->cache->pending, ie); | ||
521 | ie->flags.pending = 1; | ||
522 | evas_preload_thread_cancel(ie->preload); | ||
523 | } | ||
524 | } | ||
525 | #endif | ||
526 | |||
527 | EAPI int | ||
528 | evas_cache_image_usage_get(Evas_Cache_Image *cache) | ||
529 | { | ||
530 | return cache->usage; | ||
531 | } | ||
532 | |||
533 | EAPI int | ||
534 | evas_cache_image_get(Evas_Cache_Image *cache) | ||
535 | { | ||
536 | return cache->limit; | ||
537 | } | ||
538 | |||
539 | EAPI void | ||
540 | evas_cache_image_set(Evas_Cache_Image *cache, unsigned int limit) | ||
541 | { | ||
542 | #ifdef EVAS_FRAME_QUEUING | ||
543 | LKL(cache->lock); | ||
544 | #endif | ||
545 | if (cache->limit == limit) | ||
546 | { | ||
547 | #ifdef EVAS_FRAME_QUEUING | ||
548 | LKU(cache->lock); | ||
549 | #endif | ||
550 | return; | ||
551 | } | ||
552 | cache->limit = limit; | ||
553 | #ifdef EVAS_FRAME_QUEUING | ||
554 | LKU(cache->lock); | ||
555 | #endif | ||
556 | evas_cache_image_flush(cache); | ||
557 | } | ||
558 | |||
559 | EAPI Evas_Cache_Image * | ||
560 | evas_cache_image_init(const Evas_Cache_Image_Func *cb) | ||
561 | { | ||
562 | Evas_Cache_Image *cache; | ||
563 | |||
564 | #ifdef BUILD_ASYNC_PRELOAD | ||
565 | if (_evas_cache_mutex_init++ == 0) | ||
566 | { | ||
567 | LKI(engine_lock); | ||
568 | LKI(wakeup); | ||
569 | eina_condition_new(&cond_wakeup, &wakeup); | ||
570 | } | ||
571 | #endif | ||
572 | |||
573 | cache = calloc(1, sizeof(Evas_Cache_Image)); | ||
574 | if (!cache) return NULL; | ||
575 | cache->func = *cb; | ||
576 | cache->inactiv = eina_hash_string_superfast_new(NULL); | ||
577 | cache->activ = eina_hash_string_superfast_new(NULL); | ||
578 | cache->references = 1; | ||
579 | #ifdef EVAS_FRAME_QUEUING | ||
580 | LKI(cache->lock); | ||
581 | #endif | ||
582 | return cache; | ||
583 | } | ||
584 | |||
585 | static Eina_Bool | ||
586 | _evas_cache_image_free_cb(__UNUSED__ const Eina_Hash *hash, __UNUSED__ const void *key, void *data, void *fdata) | ||
587 | { | ||
588 | Eina_List **delete_list = fdata; | ||
589 | *delete_list = eina_list_prepend(*delete_list, data); | ||
590 | return EINA_TRUE; | ||
591 | } | ||
592 | |||
593 | EAPI void | ||
594 | evas_cache_image_shutdown(Evas_Cache_Image *cache) | ||
595 | { | ||
596 | Eina_List *delete_list; | ||
597 | Image_Entry *im; | ||
598 | |||
599 | #ifdef EVAS_FRAME_QUEUING | ||
600 | LKL(cache->lock); | ||
601 | #endif | ||
602 | cache->references--; | ||
603 | if (cache->references != 0) | ||
604 | { | ||
605 | #ifdef EVAS_FRAME_QUEUING | ||
606 | LKU(cache->lock); | ||
607 | #endif | ||
608 | return; | ||
609 | } | ||
610 | #ifdef EVAS_FRAME_QUEUING | ||
611 | /* Release and destroy lock early ! */ | ||
612 | LKU(cache->lock); | ||
613 | LKD(cache->lock); | ||
614 | #endif | ||
615 | |||
616 | #ifdef BUILD_ASYNC_PRELOAD | ||
617 | EINA_LIST_FREE(cache->preload, im) | ||
618 | { | ||
619 | /* By doing that we are protecting us from destroying image when the cache is no longer available. */ | ||
620 | im->flags.delete_me = 1; | ||
621 | _evas_cache_image_entry_preload_remove(im, NULL); | ||
622 | } | ||
623 | evas_async_events_process(); | ||
624 | #endif | ||
625 | while (cache->lru) | ||
626 | { | ||
627 | im = (Image_Entry *)cache->lru; | ||
628 | _evas_cache_image_entry_delete(cache, im); | ||
629 | } | ||
630 | while (cache->lru_nodata) | ||
631 | { | ||
632 | im = (Image_Entry *)cache->lru_nodata; | ||
633 | _evas_cache_image_entry_delete(cache, im); | ||
634 | } | ||
635 | /* This is mad, I am about to destroy image still alive, but we need to prevent leak. */ | ||
636 | while (cache->dirty) | ||
637 | { | ||
638 | im = (Image_Entry *)cache->dirty; | ||
639 | _evas_cache_image_entry_delete(cache, im); | ||
640 | } | ||
641 | delete_list = NULL; | ||
642 | eina_hash_foreach(cache->activ, _evas_cache_image_free_cb, &delete_list); | ||
643 | while (delete_list) | ||
644 | { | ||
645 | _evas_cache_image_entry_delete(cache, eina_list_data_get(delete_list)); | ||
646 | delete_list = eina_list_remove_list(delete_list, delete_list); | ||
647 | } | ||
648 | |||
649 | #ifdef BUILD_ASYNC_PRELOAD | ||
650 | /* Now wait for all pending image to die */ | ||
651 | while (cache->pending) | ||
652 | { | ||
653 | evas_async_events_process(); | ||
654 | LKL(wakeup); | ||
655 | // the lazy bum who did eain threads and converted this code | ||
656 | // didn't bother to worry about Eina_Lock being a different type | ||
657 | // to a pthread mutex. | ||
658 | if (cache->pending) eina_condition_wait(&cond_wakeup); | ||
659 | LKU(wakeup); | ||
660 | } | ||
661 | #endif | ||
662 | eina_hash_free(cache->activ); | ||
663 | eina_hash_free(cache->inactiv); | ||
664 | free(cache); | ||
665 | |||
666 | #ifdef BUILD_ASYNC_PRELOAD | ||
667 | if (--_evas_cache_mutex_init == 0) | ||
668 | { | ||
669 | eina_condition_free(&cond_wakeup); | ||
670 | LKD(engine_lock); | ||
671 | LKD(wakeup); | ||
672 | } | ||
673 | #endif | ||
674 | } | ||
675 | |||
676 | EAPI Image_Entry * | ||
677 | evas_cache_image_request(Evas_Cache_Image *cache, const char *file, | ||
678 | const char *key, RGBA_Image_Loadopts *lo, int *error) | ||
679 | { | ||
680 | const char *ckey = "(null)"; | ||
681 | char *hkey; | ||
682 | Image_Entry *im; | ||
683 | Evas_Image_Load_Opts prevent = { 0, 0.0, 0, 0, 0, { 0, 0, 0, 0 }, EINA_FALSE }; | ||
684 | size_t size; | ||
685 | int stat_done = 0, stat_failed = 0; | ||
686 | size_t file_length; | ||
687 | size_t key_length; | ||
688 | struct stat st; | ||
689 | Image_Timestamp tstamp; | ||
690 | |||
691 | if ((!file) || ((!file) && (!key))) | ||
692 | { | ||
693 | *error = EVAS_LOAD_ERROR_GENERIC; | ||
694 | return NULL; | ||
695 | } | ||
696 | |||
697 | /* generate hkey from file+key+load opts */ | ||
698 | file_length = strlen(file); | ||
699 | key_length = key ? strlen(key) : 6; | ||
700 | size = file_length + key_length + 132; | ||
701 | hkey = alloca(sizeof (char) * size); | ||
702 | memcpy(hkey, file, file_length); | ||
703 | size = file_length; | ||
704 | memcpy(hkey + size, "//://", 5); | ||
705 | size += 5; | ||
706 | if (key) ckey = key; | ||
707 | memcpy(hkey + size, ckey, key_length); | ||
708 | size += key_length; | ||
709 | if ((!lo) || | ||
710 | (lo && | ||
711 | (lo->scale_down_by == 0) && | ||
712 | (lo->dpi == 0.0) && | ||
713 | ((lo->w == 0) || (lo->h == 0)) && | ||
714 | ((lo->region.w == 0) || (lo->region.h == 0)) && | ||
715 | (lo->orientation == 0) | ||
716 | )) | ||
717 | { | ||
718 | lo = &prevent; | ||
719 | } | ||
720 | else | ||
721 | { | ||
722 | memcpy(hkey + size, "//@/", 4); | ||
723 | size += 4; | ||
724 | size += eina_convert_xtoa(lo->scale_down_by, hkey + size); | ||
725 | hkey[size] = '/'; | ||
726 | size += 1; | ||
727 | size += eina_convert_dtoa(lo->dpi, hkey + size); | ||
728 | hkey[size] = '/'; | ||
729 | size += 1; | ||
730 | size += eina_convert_xtoa(lo->w, hkey + size); | ||
731 | hkey[size] = 'x'; | ||
732 | size += 1; | ||
733 | size += eina_convert_xtoa(lo->h, hkey + size); | ||
734 | hkey[size] = '/'; | ||
735 | size += 1; | ||
736 | size += eina_convert_xtoa(lo->region.x, hkey + size); | ||
737 | hkey[size] = '+'; | ||
738 | size += 1; | ||
739 | size += eina_convert_xtoa(lo->region.y, hkey + size); | ||
740 | hkey[size] = '.'; | ||
741 | size += 1; | ||
742 | size += eina_convert_xtoa(lo->region.w, hkey + size); | ||
743 | hkey[size] = 'x'; | ||
744 | size += 1; | ||
745 | size += eina_convert_xtoa(lo->region.h, hkey + size); | ||
746 | |||
747 | if (lo->orientation) | ||
748 | { | ||
749 | hkey[size] = '/'; | ||
750 | size += 1; | ||
751 | hkey[size] = 'o'; | ||
752 | size += 1; | ||
753 | } | ||
754 | } | ||
755 | hkey[size] = '\0'; | ||
756 | |||
757 | /* find image by key in active hash */ | ||
758 | #ifdef EVAS_FRAME_QUEUING | ||
759 | LKL(cache->lock); | ||
760 | #endif | ||
761 | im = eina_hash_find(cache->activ, hkey); | ||
762 | #ifdef EVAS_FRAME_QUEUING | ||
763 | LKU(cache->lock); | ||
764 | #endif | ||
765 | if (im) | ||
766 | { | ||
767 | int ok = 1; | ||
768 | |||
769 | stat_done = 1; | ||
770 | if (stat(file, &st) < 0) | ||
771 | { | ||
772 | stat_failed = 1; | ||
773 | ok = 0; | ||
774 | } | ||
775 | else if (!_timestamp_compare(&(im->tstamp), &st)) ok = 0; | ||
776 | if (ok) goto on_ok; | ||
777 | /* image we found doesn't match what's on disk (stat info wise) | ||
778 | * so dirty the active cache entry so we never find it again. this | ||
779 | * also implicitly guarantees that we only have 1 active copy | ||
780 | * of an image at a given key. we wither find it and keep re-reffing | ||
781 | * it or we dirty it and get it out */ | ||
782 | _evas_cache_image_dirty_add(im); | ||
783 | im = NULL; | ||
784 | } | ||
785 | |||
786 | /* find image by key in inactive/lru hash */ | ||
787 | #ifdef EVAS_FRAME_QUEUING | ||
788 | LKL(cache->lock); | ||
789 | #endif | ||
790 | im = eina_hash_find(cache->inactiv, hkey); | ||
791 | #ifdef EVAS_FRAME_QUEUING | ||
792 | LKU(cache->lock); | ||
793 | #endif | ||
794 | if (im) | ||
795 | { | ||
796 | int ok = 1; | ||
797 | |||
798 | if (!stat_done) | ||
799 | { | ||
800 | stat_done = 1; | ||
801 | if (stat(file, &st) < 0) | ||
802 | { | ||
803 | stat_failed = 1; | ||
804 | ok = 0; | ||
805 | } | ||
806 | else if (!_timestamp_compare(&(im->tstamp), &st)) ok = 0; | ||
807 | } | ||
808 | else if (!_timestamp_compare(&(im->tstamp), &st)) ok = 0; | ||
809 | |||
810 | if (ok) | ||
811 | { | ||
812 | /* remove from lru and make it active again */ | ||
813 | _evas_cache_image_lru_del(im); | ||
814 | _evas_cache_image_activ_add(im); | ||
815 | goto on_ok; | ||
816 | } | ||
817 | /* as avtive cache find - if we match in lru and its invalid, dirty */ | ||
818 | _evas_cache_image_dirty_add(im); | ||
819 | im = NULL; | ||
820 | } | ||
821 | if (stat_failed) goto on_stat_error; | ||
822 | |||
823 | if (!stat_done) | ||
824 | { | ||
825 | if (stat(file, &st) < 0) goto on_stat_error; | ||
826 | } | ||
827 | _timestamp_build(&tstamp, &st); | ||
828 | im = _evas_cache_image_entry_new(cache, hkey, &tstamp, file, key, | ||
829 | lo, error); | ||
830 | if (!im) goto on_stat_error; | ||
831 | if (cache->func.debug) cache->func.debug("request", im); | ||
832 | |||
833 | on_ok: | ||
834 | *error = EVAS_LOAD_ERROR_NONE; | ||
835 | #ifdef EVAS_FRAME_QUEUING | ||
836 | LKL(im->lock_references); | ||
837 | #endif | ||
838 | im->references++; | ||
839 | #ifdef EVAS_FRAME_QUEUING | ||
840 | LKU(im->lock_references); | ||
841 | #endif | ||
842 | return im; | ||
843 | |||
844 | on_stat_error: | ||
845 | #ifndef _WIN32 | ||
846 | if ((errno == ENOENT) || (errno == ENOTDIR) || | ||
847 | (errno == ENAMETOOLONG) || (errno == ELOOP)) | ||
848 | #else | ||
849 | if (errno == ENOENT) | ||
850 | #endif | ||
851 | *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST; | ||
852 | #ifndef _WIN32 | ||
853 | else if ((errno == ENOMEM) || (errno == EOVERFLOW)) | ||
854 | #else | ||
855 | else if (errno == ENOMEM) | ||
856 | #endif | ||
857 | *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; | ||
858 | else if (errno == EACCES) | ||
859 | *error = EVAS_LOAD_ERROR_PERMISSION_DENIED; | ||
860 | else | ||
861 | *error = EVAS_LOAD_ERROR_GENERIC; | ||
862 | |||
863 | if (im) _evas_cache_image_entry_delete(cache, im); | ||
864 | return NULL; | ||
865 | } | ||
866 | |||
867 | EAPI void | ||
868 | evas_cache_image_drop(Image_Entry *im) | ||
869 | { | ||
870 | Evas_Cache_Image *cache; | ||
871 | int references; | ||
872 | |||
873 | #ifdef EVAS_FRAME_QUEUING | ||
874 | LKL(im->lock_references); | ||
875 | #endif | ||
876 | im->references--; | ||
877 | if (im->references < 0) im->references = 0; | ||
878 | references = im->references; | ||
879 | #ifdef EVAS_FRAME_QUEUING | ||
880 | LKU(im->lock_references); | ||
881 | #endif | ||
882 | |||
883 | cache = im->cache; | ||
884 | |||
885 | if (references == 0) | ||
886 | { | ||
887 | #ifdef EVAS_FRAME_QUEUING | ||
888 | LKL(im->ref_fq_add); | ||
889 | LKL(im->ref_fq_del); | ||
890 | if (im->ref_fq[0] != im->ref_fq[1]) | ||
891 | { | ||
892 | LKU(im->ref_fq_add); | ||
893 | LKU(im->ref_fq_del); | ||
894 | return; | ||
895 | } | ||
896 | LKU(im->ref_fq_add); | ||
897 | LKU(im->ref_fq_del); | ||
898 | #endif | ||
899 | |||
900 | #ifdef BUILD_ASYNC_PRELOAD | ||
901 | if (im->preload) | ||
902 | { | ||
903 | _evas_cache_image_entry_preload_remove(im, NULL); | ||
904 | return; | ||
905 | } | ||
906 | #endif | ||
907 | |||
908 | if (im->flags.dirty) | ||
909 | { | ||
910 | _evas_cache_image_entry_delete(cache, im); | ||
911 | return; | ||
912 | } | ||
913 | _evas_cache_image_lru_add(im); | ||
914 | if (cache) evas_cache_image_flush(cache); | ||
915 | } | ||
916 | } | ||
917 | |||
918 | EAPI void | ||
919 | evas_cache_image_data_not_needed(Image_Entry *im) | ||
920 | { | ||
921 | Evas_Cache_Image *cache; | ||
922 | int references; | ||
923 | |||
924 | /* FIXME: no one uses this api... well evas_cache_engine_parent_not_needed() | ||
925 | * does, but nothing uses that! */ | ||
926 | cache = im->cache; | ||
927 | #ifdef EVAS_FRAME_QUEUING | ||
928 | LKL(im->lock_references); | ||
929 | #endif | ||
930 | references = im->references; | ||
931 | #ifdef EVAS_FRAME_QUEUING | ||
932 | LKU(im->lock_references); | ||
933 | #endif | ||
934 | if (references > 1) return; | ||
935 | if ((im->flags.dirty) || (!im->flags.need_data)) return; | ||
936 | _evas_cache_image_lru_nodata_add(im); | ||
937 | } | ||
938 | |||
939 | EAPI Image_Entry * | ||
940 | evas_cache_image_dirty(Image_Entry *im, unsigned int x, unsigned int y, unsigned int w, unsigned int h) | ||
941 | { | ||
942 | Image_Entry *im_dirty = im; | ||
943 | Evas_Cache_Image *cache; | ||
944 | int references; | ||
945 | |||
946 | cache = im->cache; | ||
947 | if (!(im->flags.dirty)) | ||
948 | { | ||
949 | #ifdef EVAS_FRAME_QUEUING | ||
950 | LKL(im->lock_references); | ||
951 | #endif | ||
952 | references = im->references; | ||
953 | #ifdef EVAS_FRAME_QUEUING | ||
954 | LKU(im->lock_references); | ||
955 | #endif | ||
956 | #ifndef EVAS_CSERVE | ||
957 | // if ref 1 also copy if using shared cache as its read-only | ||
958 | if (references == 1) im_dirty = im; | ||
959 | else | ||
960 | #endif | ||
961 | { | ||
962 | int error; | ||
963 | |||
964 | im_dirty = | ||
965 | evas_cache_image_copied_data(cache, im->w, im->h, | ||
966 | evas_cache_image_pixels(im), | ||
967 | im->flags.alpha, im->space); | ||
968 | if (!im_dirty) goto on_error; | ||
969 | if (cache->func.debug) cache->func.debug("dirty-src", im); | ||
970 | error = cache->func.dirty(im_dirty, im); | ||
971 | if (cache->func.debug) cache->func.debug("dirty-out", im_dirty); | ||
972 | #ifdef EVAS_FRAME_QUEUING | ||
973 | LKL(im_dirty->lock_references); | ||
974 | #endif | ||
975 | im_dirty->references = 1; | ||
976 | #ifdef EVAS_FRAME_QUEUING | ||
977 | LKU(im_dirty->lock_references); | ||
978 | #endif | ||
979 | evas_cache_image_drop(im); | ||
980 | } | ||
981 | _evas_cache_image_dirty_add(im_dirty); | ||
982 | } | ||
983 | |||
984 | if (cache->func.debug) cache->func.debug("dirty-region", im_dirty); | ||
985 | if (cache->func.dirty_region) | ||
986 | cache->func.dirty_region(im_dirty, x, y, w, h); | ||
987 | return im_dirty; | ||
988 | |||
989 | on_error: | ||
990 | if (im_dirty) _evas_cache_image_entry_delete(cache, im_dirty); | ||
991 | evas_cache_image_drop(im); | ||
992 | return NULL; | ||
993 | } | ||
994 | |||
995 | EAPI Image_Entry * | ||
996 | evas_cache_image_alone(Image_Entry *im) | ||
997 | { | ||
998 | Evas_Cache_Image *cache; | ||
999 | Image_Entry *im_dirty = im; | ||
1000 | int references; | ||
1001 | |||
1002 | cache = im->cache; | ||
1003 | #ifdef EVAS_FRAME_QUEUING | ||
1004 | LKL(im->lock_references); | ||
1005 | #endif | ||
1006 | references = im->references; | ||
1007 | #ifdef EVAS_FRAME_QUEUING | ||
1008 | LKU(im->lock_references); | ||
1009 | #endif | ||
1010 | |||
1011 | if (references <= 1) | ||
1012 | { | ||
1013 | if (!im->flags.dirty) _evas_cache_image_dirty_add(im); | ||
1014 | } | ||
1015 | else | ||
1016 | { | ||
1017 | int error; | ||
1018 | |||
1019 | im_dirty = evas_cache_image_copied_data(cache, im->w, im->h, | ||
1020 | evas_cache_image_pixels(im), | ||
1021 | im->flags.alpha, | ||
1022 | im->space); | ||
1023 | if (!im_dirty) goto on_error; | ||
1024 | if (cache->func.debug) cache->func.debug("dirty-src", im); | ||
1025 | error = cache->func.dirty(im_dirty, im); | ||
1026 | if (cache->func.debug) cache->func.debug("dirty-out", im_dirty); | ||
1027 | #ifdef EVAS_FRAME_QUEUING | ||
1028 | LKL(im_dirty->lock_references); | ||
1029 | #endif | ||
1030 | im_dirty->references = 1; | ||
1031 | #ifdef EVAS_FRAME_QUEUING | ||
1032 | LKU(im_dirty->lock_references); | ||
1033 | #endif | ||
1034 | evas_cache_image_drop(im); | ||
1035 | } | ||
1036 | return im_dirty; | ||
1037 | |||
1038 | on_error: | ||
1039 | if (im_dirty) _evas_cache_image_entry_delete(cache, im_dirty); | ||
1040 | evas_cache_image_drop(im); | ||
1041 | return NULL; | ||
1042 | } | ||
1043 | |||
1044 | EAPI Image_Entry * | ||
1045 | evas_cache_image_copied_data(Evas_Cache_Image *cache, | ||
1046 | unsigned int w, unsigned int h, | ||
1047 | DATA32 *image_data, int alpha, int cspace) | ||
1048 | { | ||
1049 | Image_Entry *im; | ||
1050 | |||
1051 | if ((cspace == EVAS_COLORSPACE_YCBCR422P601_PL) || | ||
1052 | (cspace == EVAS_COLORSPACE_YCBCR422P709_PL) || | ||
1053 | (cspace == EVAS_COLORSPACE_YCBCR422601_PL)) | ||
1054 | w &= ~0x1; | ||
1055 | |||
1056 | im = _evas_cache_image_entry_new(cache, NULL, NULL, NULL, NULL, NULL, NULL); | ||
1057 | if (!im) return NULL; | ||
1058 | im->space = cspace; | ||
1059 | im->flags.alpha = alpha; | ||
1060 | _evas_cache_image_entry_surface_alloc(cache, im, w, h); | ||
1061 | if (cache->func.copied_data(im, w, h, image_data, alpha, cspace) != 0) | ||
1062 | { | ||
1063 | _evas_cache_image_entry_delete(cache, im); | ||
1064 | return NULL; | ||
1065 | } | ||
1066 | #ifdef EVAS_FRAME_QUEUING | ||
1067 | LKL(im->lock_references); | ||
1068 | #endif | ||
1069 | im->references = 1; | ||
1070 | #ifdef EVAS_FRAME_QUEUING | ||
1071 | LKU(im->lock_references); | ||
1072 | #endif | ||
1073 | if (cache->func.debug) cache->func.debug("copied-data", im); | ||
1074 | return im; | ||
1075 | } | ||
1076 | |||
1077 | EAPI Image_Entry * | ||
1078 | evas_cache_image_data(Evas_Cache_Image *cache, unsigned int w, unsigned int h, DATA32 *image_data, int alpha, int cspace) | ||
1079 | { | ||
1080 | Image_Entry *im; | ||
1081 | |||
1082 | if ((cspace == EVAS_COLORSPACE_YCBCR422P601_PL) || | ||
1083 | (cspace == EVAS_COLORSPACE_YCBCR422P709_PL) || | ||
1084 | (cspace == EVAS_COLORSPACE_YCBCR422601_PL)) | ||
1085 | w &= ~0x1; | ||
1086 | |||
1087 | im = _evas_cache_image_entry_new(cache, NULL, NULL, NULL, NULL, NULL, NULL); | ||
1088 | if (!im) return NULL; | ||
1089 | im->w = w; | ||
1090 | im->h = h; | ||
1091 | im->flags.alpha = alpha; | ||
1092 | if (cache->func.data(im, w, h, image_data, alpha, cspace) != 0) | ||
1093 | { | ||
1094 | _evas_cache_image_entry_delete(cache, im); | ||
1095 | return NULL; | ||
1096 | } | ||
1097 | #ifdef EVAS_FRAME_QUEUING | ||
1098 | LKL(im->lock_references); | ||
1099 | #endif | ||
1100 | im->references = 1; | ||
1101 | #ifdef EVAS_FRAME_QUEUING | ||
1102 | LKU(im->lock_references); | ||
1103 | #endif | ||
1104 | if (cache->func.debug) cache->func.debug("data", im); | ||
1105 | return im; | ||
1106 | } | ||
1107 | |||
1108 | EAPI void | ||
1109 | evas_cache_image_surface_alloc(Image_Entry *im, unsigned int w, unsigned int h) | ||
1110 | { | ||
1111 | Evas_Cache_Image *cache = im->cache; | ||
1112 | |||
1113 | if ((im->space == EVAS_COLORSPACE_YCBCR422P601_PL) || | ||
1114 | (im->space == EVAS_COLORSPACE_YCBCR422P709_PL) || | ||
1115 | (im->space == EVAS_COLORSPACE_YCBCR422601_PL)) | ||
1116 | w &= ~0x1; | ||
1117 | |||
1118 | _evas_cache_image_entry_surface_alloc(cache, im, w, h); | ||
1119 | if (cache->func.debug) cache->func.debug("surface-alloc", im); | ||
1120 | } | ||
1121 | |||
1122 | EAPI Image_Entry * | ||
1123 | evas_cache_image_size_set(Image_Entry *im, unsigned int w, unsigned int h) | ||
1124 | { | ||
1125 | Evas_Cache_Image *cache; | ||
1126 | Image_Entry *im2 = NULL; | ||
1127 | int error; | ||
1128 | |||
1129 | if ((im->space == EVAS_COLORSPACE_YCBCR422P601_PL) || | ||
1130 | (im->space == EVAS_COLORSPACE_YCBCR422P709_PL) || | ||
1131 | (im->space == EVAS_COLORSPACE_YCBCR422601_PL)) | ||
1132 | w &= ~0x1; | ||
1133 | if ((im->w == w) && (im->h == h)) return im; | ||
1134 | |||
1135 | cache = im->cache; | ||
1136 | im2 = _evas_cache_image_entry_new(cache, NULL, NULL, NULL, NULL, NULL, &error); | ||
1137 | if (!im2) goto on_error; | ||
1138 | |||
1139 | im2->flags.alpha = im->flags.alpha; | ||
1140 | im2->space = im->space; | ||
1141 | im2->load_opts = im->load_opts; | ||
1142 | _evas_cache_image_entry_surface_alloc(cache, im2, w, h); | ||
1143 | error = cache->func.size_set(im2, im, w, h); | ||
1144 | if (error != 0) goto on_error; | ||
1145 | #ifdef EVAS_FRAME_QUEUING | ||
1146 | LKL(im2->lock_references); | ||
1147 | #endif | ||
1148 | im2->references = 1; | ||
1149 | #ifdef EVAS_FRAME_QUEUING | ||
1150 | LKU(im2->lock_references); | ||
1151 | #endif | ||
1152 | evas_cache_image_drop(im); | ||
1153 | if (cache->func.debug) cache->func.debug("size_set", im2); | ||
1154 | return im2; | ||
1155 | |||
1156 | on_error: | ||
1157 | if (im2) _evas_cache_image_entry_delete(cache, im2); | ||
1158 | evas_cache_image_drop(im); | ||
1159 | return NULL; | ||
1160 | } | ||
1161 | |||
1162 | EAPI int | ||
1163 | evas_cache_image_load_data(Image_Entry *im) | ||
1164 | { | ||
1165 | #ifdef BUILD_ASYNC_PRELOAD | ||
1166 | Eina_Bool preload = EINA_FALSE; | ||
1167 | #endif | ||
1168 | int error = EVAS_LOAD_ERROR_NONE; | ||
1169 | |||
1170 | if ((im->flags.loaded) && (!im->flags.animated)) return error; | ||
1171 | #ifdef BUILD_ASYNC_PRELOAD | ||
1172 | if (im->preload) | ||
1173 | { | ||
1174 | preload = EINA_TRUE; | ||
1175 | if (!im->flags.pending) | ||
1176 | { | ||
1177 | im->cache->preload = eina_list_remove(im->cache->preload, im); | ||
1178 | im->cache->pending = eina_list_append(im->cache->pending, im); | ||
1179 | im->flags.pending = 1; | ||
1180 | evas_preload_thread_cancel(im->preload); | ||
1181 | } | ||
1182 | evas_async_events_process(); | ||
1183 | LKL(wakeup); | ||
1184 | while (im->preload) | ||
1185 | { | ||
1186 | eina_condition_wait(&cond_wakeup); | ||
1187 | LKU(wakeup); | ||
1188 | evas_async_events_process(); | ||
1189 | LKL(wakeup); | ||
1190 | } | ||
1191 | LKU(wakeup); | ||
1192 | } | ||
1193 | |||
1194 | if ((im->flags.loaded) && (!im->flags.animated)) return error; | ||
1195 | LKL(im->lock); | ||
1196 | #endif | ||
1197 | im->flags.in_progress = EINA_TRUE; | ||
1198 | error = im->cache->func.load(im); | ||
1199 | im->flags.in_progress = EINA_FALSE; | ||
1200 | #ifdef BUILD_ASYNC_PRELOAD | ||
1201 | LKU(im->lock); | ||
1202 | #endif | ||
1203 | im->flags.loaded = 1; | ||
1204 | if (im->cache->func.debug) im->cache->func.debug("load", im); | ||
1205 | if (error != EVAS_LOAD_ERROR_NONE) | ||
1206 | { | ||
1207 | _evas_cache_image_entry_surface_alloc(im->cache, im, im->w, im->h); | ||
1208 | im->flags.loaded = 0; | ||
1209 | } | ||
1210 | #ifdef BUILD_ASYNC_PRELOAD | ||
1211 | if (preload) _evas_cache_image_async_end(im); | ||
1212 | #endif | ||
1213 | return error; | ||
1214 | } | ||
1215 | |||
1216 | EAPI void | ||
1217 | evas_cache_image_unload_data(Image_Entry *im) | ||
1218 | { | ||
1219 | if (im->flags.in_progress) return; | ||
1220 | evas_cache_image_preload_cancel(im, NULL); | ||
1221 | #ifdef BUILD_ASYNC_PRELOAD | ||
1222 | LKL(im->lock_cancel); | ||
1223 | if (LKT(im->lock) == EINA_FALSE) /* can't get image lock - busy async load */ | ||
1224 | { | ||
1225 | im->unload_cancel = EINA_TRUE; | ||
1226 | LKU(im->lock_cancel); | ||
1227 | return; | ||
1228 | } | ||
1229 | LKU(im->lock_cancel); | ||
1230 | #endif | ||
1231 | if ((!im->flags.loaded) || (!im->file) || (!im->info.module) || | ||
1232 | (im->flags.dirty)) | ||
1233 | { | ||
1234 | #ifdef BUILD_ASYNC_PRELOAD | ||
1235 | LKU(im->lock); | ||
1236 | #endif | ||
1237 | return; | ||
1238 | } | ||
1239 | im->cache->func.destructor(im); | ||
1240 | #ifdef BUILD_ASYNC_PRELOAD | ||
1241 | LKU(im->lock); | ||
1242 | #endif | ||
1243 | //FIXME: imagedataunload - inform owners | ||
1244 | } | ||
1245 | |||
1246 | static Eina_Bool | ||
1247 | _evas_cache_image_unload_cb(__UNUSED__ const Eina_Hash *hash, __UNUSED__ const void *key, void *data, __UNUSED__ void *fdata) | ||
1248 | { | ||
1249 | evas_cache_image_unload_data(data); | ||
1250 | return EINA_TRUE; | ||
1251 | } | ||
1252 | |||
1253 | EAPI void | ||
1254 | evas_cache_image_unload_all(Evas_Cache_Image *cache) | ||
1255 | { | ||
1256 | Image_Entry *im; | ||
1257 | |||
1258 | EINA_INLIST_FOREACH(cache->lru, im) evas_cache_image_unload_data(im); | ||
1259 | EINA_INLIST_FOREACH(cache->lru_nodata, im) evas_cache_image_unload_data(im); | ||
1260 | eina_hash_foreach(cache->activ, _evas_cache_image_unload_cb, NULL); | ||
1261 | eina_hash_foreach(cache->inactiv, _evas_cache_image_unload_cb, NULL); | ||
1262 | } | ||
1263 | |||
1264 | EAPI Eina_Bool | ||
1265 | evas_cache_image_is_loaded(Image_Entry *im) | ||
1266 | { | ||
1267 | if (im->flags.loaded) return EINA_TRUE; | ||
1268 | return EINA_FALSE; | ||
1269 | } | ||
1270 | |||
1271 | EAPI void | ||
1272 | evas_cache_image_preload_data(Image_Entry *im, const void *target) | ||
1273 | { | ||
1274 | #ifdef BUILD_ASYNC_PRELOAD | ||
1275 | RGBA_Image *img = (RGBA_Image *)im; | ||
1276 | |||
1277 | if ((im->flags.loaded) && (img->image.data)) | ||
1278 | { | ||
1279 | evas_object_inform_call_image_preloaded((Evas_Object *)target); | ||
1280 | return; | ||
1281 | } | ||
1282 | im->flags.loaded = 0; | ||
1283 | if (!_evas_cache_image_entry_preload_add(im, target)) | ||
1284 | evas_object_inform_call_image_preloaded((Evas_Object *)target); | ||
1285 | #else | ||
1286 | evas_cache_image_load_data(im); | ||
1287 | evas_object_inform_call_image_preloaded((Evas_Object *)target); | ||
1288 | #endif | ||
1289 | } | ||
1290 | |||
1291 | EAPI void | ||
1292 | evas_cache_image_preload_cancel(Image_Entry *im, const void *target) | ||
1293 | { | ||
1294 | #ifdef BUILD_ASYNC_PRELOAD | ||
1295 | if (!target) return; | ||
1296 | _evas_cache_image_entry_preload_remove(im, target); | ||
1297 | #else | ||
1298 | (void)im; | ||
1299 | #endif | ||
1300 | } | ||
1301 | |||
1302 | #ifdef CACHEDUMP | ||
1303 | static int total = 0; | ||
1304 | |||
1305 | static void | ||
1306 | _dump_img(Image_Entry *im, const char *type) | ||
1307 | { | ||
1308 | total += im->cache->func.mem_size_get(im); | ||
1309 | printf("%s: %4i: %4ib, %4ix%4i alloc[%4ix%4i] [%s] [%s]\n", | ||
1310 | type, | ||
1311 | im->references, | ||
1312 | im->cache->func.mem_size_get(im), | ||
1313 | im->w, im->h, im->allocated.w, im->allocated.h, | ||
1314 | im->file, im->key); | ||
1315 | } | ||
1316 | |||
1317 | static Eina_Bool | ||
1318 | _dump_cache_active(__UNUSED__ const Eina_Hash *hash, __UNUSED__ const void *key, void *data, void *fdata __UNUSED__) | ||
1319 | { | ||
1320 | Image_Entry *im = data; | ||
1321 | _dump_img(im, "ACTIVE"); | ||
1322 | return EINA_TRUE; | ||
1323 | } | ||
1324 | |||
1325 | static void | ||
1326 | _dump_cache(Evas_Cache_Image *cache) | ||
1327 | { | ||
1328 | Image_Entry *im; | ||
1329 | |||
1330 | printf("--CACHE DUMP----------------------------------------------------\n"); | ||
1331 | printf("cache: %ikb / %ikb\n", | ||
1332 | cache->usage / 1024, | ||
1333 | cache->limit / 1024); | ||
1334 | printf("................................................................\n"); | ||
1335 | total = 0; | ||
1336 | EINA_INLIST_FOREACH(cache->lru_nodata, im) | ||
1337 | _dump_img(im, "NODATA"); | ||
1338 | EINA_INLIST_FOREACH(cache->lru, im) | ||
1339 | _dump_img(im, "DATA "); | ||
1340 | printf("tot: %i\n" | ||
1341 | "usg: %i\n", | ||
1342 | total, | ||
1343 | cache->usage); | ||
1344 | eina_hash_foreach(cache->activ, _dump_cache_active, NULL); | ||
1345 | } | ||
1346 | #endif | ||
1347 | |||
1348 | EAPI int | ||
1349 | evas_cache_image_flush(Evas_Cache_Image *cache) | ||
1350 | { | ||
1351 | #ifdef CACHEDUMP | ||
1352 | _dump_cache(cache); | ||
1353 | #endif | ||
1354 | if (cache->limit == (unsigned int)-1) return -1; | ||
1355 | |||
1356 | while ((cache->lru) && (cache->limit < (unsigned int)cache->usage)) | ||
1357 | { | ||
1358 | Image_Entry *im; | ||
1359 | |||
1360 | im = (Image_Entry *)cache->lru->last; | ||
1361 | _evas_cache_image_entry_delete(cache, im); | ||
1362 | } | ||
1363 | |||
1364 | while ((cache->lru_nodata) && (cache->limit < (unsigned int)cache->usage)) | ||
1365 | { | ||
1366 | Image_Entry *im; | ||
1367 | |||
1368 | im = (Image_Entry *) cache->lru_nodata->last; | ||
1369 | _evas_cache_image_lru_nodata_del(im); | ||
1370 | cache->func.surface_delete(im); | ||
1371 | im->flags.loaded = 0; | ||
1372 | } | ||
1373 | |||
1374 | return cache->usage; | ||
1375 | } | ||
1376 | |||
1377 | EAPI Image_Entry * | ||
1378 | evas_cache_image_empty(Evas_Cache_Image *cache) | ||
1379 | { | ||
1380 | Image_Entry *im; | ||
1381 | |||
1382 | im = _evas_cache_image_entry_new(cache, NULL, NULL, NULL, NULL, NULL, NULL); | ||
1383 | if (!im) return NULL; | ||
1384 | #ifdef EVAS_FRAME_QUEUING | ||
1385 | LKL(im->lock_references); | ||
1386 | #endif | ||
1387 | im->references = 1; | ||
1388 | #ifdef EVAS_FRAME_QUEUING | ||
1389 | LKU(im->lock_references); | ||
1390 | #endif | ||
1391 | return im; | ||
1392 | } | ||
1393 | |||
1394 | EAPI void | ||
1395 | evas_cache_image_colorspace(Image_Entry *im, int cspace) | ||
1396 | { | ||
1397 | if (im->space == cspace) return; | ||
1398 | im->space = cspace; | ||
1399 | im->cache->func.color_space(im, cspace); | ||
1400 | } | ||
1401 | |||
1402 | EAPI void * | ||
1403 | evas_cache_private_from_image_entry_get(Image_Entry *im) | ||
1404 | { | ||
1405 | return (void *)im->cache->data; | ||
1406 | } | ||
1407 | |||
1408 | EAPI void * | ||
1409 | evas_cache_private_get(Evas_Cache_Image *cache) | ||
1410 | { | ||
1411 | return cache->data; | ||
1412 | } | ||
1413 | |||
1414 | EAPI void | ||
1415 | evas_cache_private_set(Evas_Cache_Image *cache, const void *data) | ||
1416 | { | ||
1417 | cache->data = (void *)data; | ||
1418 | } | ||
1419 | |||
1420 | EAPI DATA32 * | ||
1421 | evas_cache_image_pixels(Image_Entry *im) | ||
1422 | { | ||
1423 | return im->cache->func.surface_pixels(im); | ||
1424 | } | ||
1425 | |||
1426 | EAPI void | ||
1427 | evas_cache_image_wakeup(void) | ||
1428 | { | ||
1429 | #ifdef BUILD_ASYNC_PRELOAD | ||
1430 | if (_evas_cache_mutex_init > 0) | ||
1431 | eina_condition_broadcast(&cond_wakeup); | ||
1432 | #endif | ||
1433 | } | ||
diff --git a/libraries/evas/src/lib/cache/evas_preload.c b/libraries/evas/src/lib/cache/evas_preload.c new file mode 100644 index 0000000..6e0412a --- /dev/null +++ b/libraries/evas/src/lib/cache/evas_preload.c | |||
@@ -0,0 +1,264 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #ifdef HAVE_EVIL | ||
6 | # include <Evil.h> | ||
7 | #endif | ||
8 | |||
9 | #ifdef BUILD_ASYNC_PRELOAD | ||
10 | # include <pthread.h> | ||
11 | # ifdef __linux__ | ||
12 | # include <sys/syscall.h> | ||
13 | # endif | ||
14 | #endif | ||
15 | |||
16 | #include "evas_common.h" | ||
17 | #include "evas_private.h" | ||
18 | #include "Evas.h" | ||
19 | |||
20 | #ifdef BUILD_ASYNC_PRELOAD | ||
21 | |||
22 | static int _threads_max = 0; | ||
23 | |||
24 | typedef struct _Evas_Preload_Pthread_Worker Evas_Preload_Pthread_Worker; | ||
25 | typedef struct _Evas_Preload_Pthread_Data Evas_Preload_Pthread_Data; | ||
26 | |||
27 | typedef void (*_evas_preload_pthread_func)(void *data); | ||
28 | |||
29 | struct _Evas_Preload_Pthread_Worker | ||
30 | { | ||
31 | EINA_INLIST; | ||
32 | |||
33 | _evas_preload_pthread_func func_heavy; | ||
34 | _evas_preload_pthread_func func_end; | ||
35 | _evas_preload_pthread_func func_cancel; | ||
36 | void *data; | ||
37 | Eina_Bool cancel : 1; | ||
38 | }; | ||
39 | |||
40 | struct _Evas_Preload_Pthread_Data | ||
41 | { | ||
42 | pthread_t thread; | ||
43 | }; | ||
44 | |||
45 | static int _threads_count = 0; | ||
46 | static Evas_Preload_Pthread_Worker *_workers = NULL; | ||
47 | |||
48 | static LK(_mutex); | ||
49 | |||
50 | static void | ||
51 | _evas_preload_thread_end(void *data) | ||
52 | { | ||
53 | Evas_Preload_Pthread_Data *pth = data; | ||
54 | Evas_Preload_Pthread_Data *p = NULL; | ||
55 | |||
56 | if (pthread_join(pth->thread, (void **)&p) == 0) free(p); | ||
57 | else return; | ||
58 | eina_threads_shutdown(); | ||
59 | } | ||
60 | |||
61 | static void | ||
62 | _evas_preload_thread_done(void *target __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info) | ||
63 | { | ||
64 | Evas_Preload_Pthread_Worker *work = event_info; | ||
65 | if (work->cancel) | ||
66 | { | ||
67 | if (work->func_cancel) work->func_cancel(work->data); | ||
68 | } | ||
69 | else | ||
70 | work->func_end(work->data); | ||
71 | |||
72 | free(work); | ||
73 | } | ||
74 | |||
75 | static void * | ||
76 | _evas_preload_thread_worker(void *data) | ||
77 | { | ||
78 | Evas_Preload_Pthread_Data *pth = data; | ||
79 | Evas_Preload_Pthread_Worker *work; | ||
80 | |||
81 | eina_sched_prio_drop(); | ||
82 | pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); | ||
83 | pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); | ||
84 | on_error: | ||
85 | for (;;) | ||
86 | { | ||
87 | LKL(_mutex); | ||
88 | if (!_workers) | ||
89 | { | ||
90 | LKU(_mutex); | ||
91 | break; | ||
92 | } | ||
93 | |||
94 | work = _workers; | ||
95 | _workers = EINA_INLIST_CONTAINER_GET(eina_inlist_remove(EINA_INLIST_GET(_workers), | ||
96 | EINA_INLIST_GET(_workers)), | ||
97 | Evas_Preload_Pthread_Worker); | ||
98 | LKU(_mutex); | ||
99 | |||
100 | if (work->func_heavy) work->func_heavy(work->data); | ||
101 | evas_async_events_put(pth, 0, work, _evas_preload_thread_done); | ||
102 | } | ||
103 | |||
104 | LKL(_mutex); | ||
105 | if (_workers) | ||
106 | { | ||
107 | LKU(_mutex); | ||
108 | goto on_error; | ||
109 | } | ||
110 | _threads_count--; | ||
111 | LKU(_mutex); | ||
112 | |||
113 | // dummy worker to wake things up | ||
114 | work = malloc(sizeof(Evas_Preload_Pthread_Worker)); | ||
115 | if (!work) return NULL; | ||
116 | |||
117 | work->data = pth; | ||
118 | work->func_heavy = NULL; | ||
119 | work->func_end = (_evas_preload_pthread_func) _evas_preload_thread_end; | ||
120 | work->func_cancel = NULL; | ||
121 | work->cancel = EINA_FALSE; | ||
122 | |||
123 | evas_async_events_put(pth, 0, work, _evas_preload_thread_done); | ||
124 | return pth; | ||
125 | } | ||
126 | #endif | ||
127 | |||
128 | void | ||
129 | _evas_preload_thread_init(void) | ||
130 | { | ||
131 | #ifdef BUILD_ASYNC_PRELOAD | ||
132 | _threads_max = eina_cpu_count(); | ||
133 | if (_threads_max < 1) _threads_max = 1; | ||
134 | |||
135 | LKI(_mutex); | ||
136 | #endif | ||
137 | } | ||
138 | |||
139 | void | ||
140 | _evas_preload_thread_shutdown(void) | ||
141 | { | ||
142 | /* FIXME: If function are still running in the background, should we kill them ? */ | ||
143 | #ifdef BUILD_ASYNC_PRELOAD | ||
144 | Evas_Preload_Pthread_Worker *work; | ||
145 | |||
146 | /* Force processing of async events. */ | ||
147 | evas_async_events_process(); | ||
148 | LKL(_mutex); | ||
149 | while (_workers) | ||
150 | { | ||
151 | work = _workers; | ||
152 | _workers = EINA_INLIST_CONTAINER_GET(eina_inlist_remove(EINA_INLIST_GET(_workers), | ||
153 | EINA_INLIST_GET(_workers)), | ||
154 | Evas_Preload_Pthread_Worker); | ||
155 | if (work->func_cancel) work->func_cancel(work->data); | ||
156 | free(work); | ||
157 | } | ||
158 | LKU(_mutex); | ||
159 | |||
160 | LKD(_mutex); | ||
161 | #endif | ||
162 | } | ||
163 | |||
164 | Evas_Preload_Pthread * | ||
165 | evas_preload_thread_run(void (*func_heavy) (void *data), | ||
166 | void (*func_end) (void *data), | ||
167 | void (*func_cancel) (void *data), | ||
168 | const void *data) | ||
169 | { | ||
170 | #ifdef BUILD_ASYNC_PRELOAD | ||
171 | Evas_Preload_Pthread_Worker *work; | ||
172 | Evas_Preload_Pthread_Data *pth; | ||
173 | |||
174 | work = malloc(sizeof(Evas_Preload_Pthread_Worker)); | ||
175 | if (!work) | ||
176 | { | ||
177 | func_cancel((void *)data); | ||
178 | return NULL; | ||
179 | } | ||
180 | |||
181 | work->func_heavy = func_heavy; | ||
182 | work->func_end = func_end; | ||
183 | work->func_cancel = func_cancel; | ||
184 | work->cancel = EINA_FALSE; | ||
185 | work->data = (void *)data; | ||
186 | |||
187 | LKL(_mutex); | ||
188 | _workers = (Evas_Preload_Pthread_Worker *)eina_inlist_append(EINA_INLIST_GET(_workers), EINA_INLIST_GET(work)); | ||
189 | if (_threads_count == _threads_max) | ||
190 | { | ||
191 | LKU(_mutex); | ||
192 | return (Evas_Preload_Pthread *)work; | ||
193 | } | ||
194 | LKU(_mutex); | ||
195 | |||
196 | /* One more thread could be created. */ | ||
197 | pth = malloc(sizeof(Evas_Preload_Pthread_Data)); | ||
198 | if (!pth) goto on_error; | ||
199 | |||
200 | eina_threads_init(); | ||
201 | |||
202 | if (pthread_create(&pth->thread, NULL, _evas_preload_thread_worker, pth) == 0) | ||
203 | { | ||
204 | LKL(_mutex); | ||
205 | _threads_count++; | ||
206 | LKU(_mutex); | ||
207 | return (Evas_Preload_Pthread*)work; | ||
208 | } | ||
209 | |||
210 | eina_threads_shutdown(); | ||
211 | |||
212 | on_error: | ||
213 | LKL(_mutex); | ||
214 | if (_threads_count == 0) | ||
215 | { | ||
216 | LKU(_mutex); | ||
217 | if (work->func_cancel) work->func_cancel(work->data); | ||
218 | free(work); | ||
219 | return NULL; | ||
220 | } | ||
221 | LKU(_mutex); | ||
222 | return NULL; | ||
223 | #else | ||
224 | /* | ||
225 | If no thread and as we don't want to break app that rely on this | ||
226 | facility, we will lock the interface until we are done. | ||
227 | */ | ||
228 | func_heavy((void *)data); | ||
229 | func_end((void *)data); | ||
230 | return (void *)1; | ||
231 | #endif | ||
232 | } | ||
233 | |||
234 | Eina_Bool | ||
235 | evas_preload_thread_cancel(Evas_Preload_Pthread *thread) | ||
236 | { | ||
237 | #ifdef BUILD_ASYNC_PRELOAD | ||
238 | Evas_Preload_Pthread_Worker *work; | ||
239 | |||
240 | if (!thread) return EINA_TRUE; | ||
241 | LKL(_mutex); | ||
242 | EINA_INLIST_FOREACH(_workers, work) | ||
243 | { | ||
244 | if (work == (Evas_Preload_Pthread_Worker *)thread) | ||
245 | { | ||
246 | _workers = EINA_INLIST_CONTAINER_GET(eina_inlist_remove(EINA_INLIST_GET(_workers), | ||
247 | EINA_INLIST_GET(work)), | ||
248 | Evas_Preload_Pthread_Worker); | ||
249 | LKU(_mutex); | ||
250 | if (work->func_cancel) work->func_cancel(work->data); | ||
251 | free(work); | ||
252 | return EINA_TRUE; | ||
253 | } | ||
254 | } | ||
255 | LKU(_mutex); | ||
256 | |||
257 | /* Delay the destruction */ | ||
258 | work = (Evas_Preload_Pthread_Worker *)thread; | ||
259 | work->cancel = EINA_TRUE; | ||
260 | return EINA_FALSE; | ||
261 | #else | ||
262 | return EINA_TRUE; | ||
263 | #endif | ||
264 | } | ||