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