forked from enlightenment/efl
first stage of simplifying evas configure/build options. much more
still to do. SVN revision: 77932
This commit is contained in:
parent
3dbe715a79
commit
2da956caa0
File diff suppressed because it is too large
Load Diff
|
@ -1,61 +1,3 @@
|
|||
dnl use: EVAS_CHECK_LOADER_DEP_EDB(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_EDB],
|
||||
[
|
||||
|
||||
requirement=""
|
||||
have_dep="no"
|
||||
evas_image_loader_[]$1[]_cflags=""
|
||||
evas_image_loader_[]$1[]_libs=""
|
||||
|
||||
PKG_CHECK_MODULES([EDB], [edb], [have_dep="yes" requirement="edb"], [have_dep="no"])
|
||||
evas_image_loader_[]$1[]_cflags="${EDB_CFLAGS}"
|
||||
evas_image_loader_[]$1[]_libs="${EDB_LIBS}"
|
||||
|
||||
AC_SUBST([evas_image_loader_$1_cflags])
|
||||
AC_SUBST([evas_image_loader_$1_libs])
|
||||
|
||||
if test "x$2" = "xstatic" ; then
|
||||
requirement_evas="${requirement} ${requirement_evas}"
|
||||
fi
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_EET(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_EET],
|
||||
[
|
||||
|
||||
requirement=""
|
||||
have_dep="no"
|
||||
evas_image_loader_[]$1[]_cflags=""
|
||||
evas_image_loader_[]$1[]_libs=""
|
||||
|
||||
PKG_CHECK_MODULES([EET], [eet >= 1.6.0], [have_dep="yes" requirement="eet >= 1.4.0"], [have_dep="no"])
|
||||
evas_image_loader_[]$1[]_cflags="${EET_CFLAGS}"
|
||||
evas_image_loader_[]$1[]_libs="${EET_LIBS}"
|
||||
|
||||
AC_SUBST([evas_image_loader_$1_cflags])
|
||||
AC_SUBST([evas_image_loader_$1_libs])
|
||||
|
||||
if test "x$2" = "xstatic" ; then
|
||||
requirement_evas="${requirement} ${requirement_evas}"
|
||||
fi
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_GIF(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_GIF],
|
||||
|
@ -98,130 +40,6 @@ fi
|
|||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_JPEG(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_JPEG],
|
||||
[
|
||||
|
||||
have_dep="no"
|
||||
evas_image_loader_[]$1[]_cflags=""
|
||||
evas_image_loader_[]$1[]_libs=""
|
||||
|
||||
AC_CHECK_HEADER([jpeglib.h], [have_dep="yes"])
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
AC_CHECK_LIB([jpeg],
|
||||
[jpeg_CreateDecompress],
|
||||
[
|
||||
evas_image_loader_[]$1[]_libs="-ljpeg"
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[
|
||||
#include <stdio.h>
|
||||
#include <jpeglib.h>
|
||||
#include <setjmp.h>
|
||||
]],
|
||||
[[
|
||||
struct jpeg_decompress_struct decomp;
|
||||
decomp.region_x = 0;
|
||||
]])],
|
||||
[have_jpeg_region="yes"],
|
||||
[have_jpeg_region="no"])
|
||||
],
|
||||
[have_dep="no"]
|
||||
)
|
||||
if test "x${have_jpeg_region}" = "xyes" ; then
|
||||
AC_DEFINE(BUILD_LOADER_JPEG_REGION, [1], [JPEG Region Decode Support])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST([evas_image_loader_$1_cflags])
|
||||
AC_SUBST([evas_image_loader_$1_libs])
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_PMAPS(loader, want_static[[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_PMAPS],
|
||||
[
|
||||
|
||||
have_dep="yes"
|
||||
evas_image_loader_[]$1[]_cflags=""
|
||||
evas_image_loader_[]$1[]_libs=""
|
||||
|
||||
AC_SUBST([evas_image_loader_$1_cflags])
|
||||
AC_SUBST([evas_image_loader_$1_libs])
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_PNG(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_PNG],
|
||||
[
|
||||
|
||||
requirement=""
|
||||
have_dep="no"
|
||||
evas_image_loader_[]$1[]_cflags=""
|
||||
evas_image_loader_[]$1[]_libs=""
|
||||
|
||||
dnl libpng.pc is the latest version of libpng that ahs been installed.
|
||||
dnl We check it first.
|
||||
PKG_CHECK_MODULES([PNG],
|
||||
[libpng >= 1.2.10],
|
||||
[have_dep="yes" requirement="libpng"],
|
||||
[have_dep="no"])
|
||||
|
||||
if test "x${have_dep}" = "xno" ; then
|
||||
PKG_CHECK_MODULES([PNG],
|
||||
[libpng15],
|
||||
[have_dep="yes" requirement="libpng15"],
|
||||
[have_dep="no"])
|
||||
fi
|
||||
|
||||
if test "x${have_dep}" = "xno" ; then
|
||||
PKG_CHECK_MODULES([PNG],
|
||||
[libpng14],
|
||||
[have_dep="yes" requirement="libpng14"],
|
||||
[have_dep="no"])
|
||||
fi
|
||||
|
||||
if test "x${have_dep}" = "xno" ; then
|
||||
PKG_CHECK_MODULES([PNG],
|
||||
[libpng12 >= 1.2.10],
|
||||
[have_dep="yes" requirement="libpng12"],
|
||||
[have_dep="no"])
|
||||
fi
|
||||
|
||||
evas_image_loader_[]$1[]_cflags="${PNG_CFLAGS}"
|
||||
evas_image_loader_[]$1[]_libs="${PNG_LIBS}"
|
||||
|
||||
AC_SUBST([evas_image_loader_$1_cflags])
|
||||
AC_SUBST([evas_image_loader_$1_libs])
|
||||
|
||||
if test "x$2" = "xstatic" ; then
|
||||
requirement_evas="${requirement} ${requirement_evas}"
|
||||
fi
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_SVG(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_SVG],
|
||||
|
@ -311,126 +129,6 @@ fi
|
|||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_XPM(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_XPM],
|
||||
[
|
||||
|
||||
have_dep="yes"
|
||||
evas_image_loader_[]$1[]_cflags=""
|
||||
evas_image_loader_[]$1[]_libs=""
|
||||
|
||||
AC_SUBST([evas_image_loader_$1_cflags])
|
||||
AC_SUBST([evas_image_loader_$1_libs])
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_BMP(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_BMP],
|
||||
[
|
||||
|
||||
have_dep="yes"
|
||||
evas_image_loader_[]$1[]_cflags=""
|
||||
evas_image_loader_[]$1[]_libs=""
|
||||
|
||||
AC_SUBST([evas_image_loader_$1_cflags])
|
||||
AC_SUBST([evas_image_loader_$1_libs])
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_ICO(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_ICO],
|
||||
[
|
||||
|
||||
have_dep="yes"
|
||||
evas_image_loader_[]$1[]_cflags=""
|
||||
evas_image_loader_[]$1[]_libs=""
|
||||
|
||||
AC_SUBST([evas_image_loader_$1_cflags])
|
||||
AC_SUBST([evas_image_loader_$1_libs])
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_TGA(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_TGA],
|
||||
[
|
||||
|
||||
have_dep="yes"
|
||||
evas_image_loader_[]$1[]_cflags=""
|
||||
evas_image_loader_[]$1[]_libs=""
|
||||
|
||||
AC_SUBST([evas_image_loader_$1_cflags])
|
||||
AC_SUBST([evas_image_loader_$1_libs])
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_WBMP(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_WBMP],
|
||||
[
|
||||
|
||||
have_dep="yes"
|
||||
evas_image_loader_[]$1[]_cflags=""
|
||||
evas_image_loader_[]$1[]_libs=""
|
||||
|
||||
AC_SUBST([evas_image_loader_$1_cflags])
|
||||
AC_SUBST([evas_image_loader_$1_libs])
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_PSD(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_PSD],
|
||||
[
|
||||
|
||||
have_dep="yes"
|
||||
evas_image_loader_[]$1[]_cflags=""
|
||||
evas_image_loader_[]$1[]_libs=""
|
||||
|
||||
AC_SUBST([evas_image_loader_$1_cflags])
|
||||
AC_SUBST([evas_image_loader_$1_libs])
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_WEBP(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_WEBP],
|
||||
|
@ -463,26 +161,6 @@ fi
|
|||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_LOADER_DEP_GENERIC(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_LOADER_DEP_GENERIC],
|
||||
[
|
||||
|
||||
have_dep="yes"
|
||||
evas_image_loader_[]$1[]_cflags=""
|
||||
evas_image_loader_[]$1[]_libs=""
|
||||
|
||||
AC_SUBST([evas_image_loader_$1_cflags])
|
||||
AC_SUBST([evas_image_loader_$1_libs])
|
||||
|
||||
if test "x${have_dep}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_IMAGE_LOADER(loader, want_loader, macro)
|
||||
|
||||
|
||||
|
@ -552,42 +230,3 @@ m4_popdef([UP])
|
|||
m4_popdef([DOWN])
|
||||
|
||||
])
|
||||
|
||||
dnl use: EVAS_CHECK_FONT_LOADER(want)
|
||||
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_FONT_LOADER],
|
||||
[
|
||||
|
||||
pushdef([UP], translit([$1], [a-z], [A-Z]))dnl
|
||||
pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
|
||||
|
||||
want_loader="$1"
|
||||
have_evas_font_loader_eet="no"
|
||||
|
||||
AC_ARG_ENABLE([font-loader-eet],
|
||||
[AC_HELP_STRING([--disable-font-loader-eet],
|
||||
[disable EET font loader. [[default=enabled]]])],
|
||||
[want_loader=${enableval}]
|
||||
)
|
||||
|
||||
AC_MSG_CHECKING([whether to enable Eet font loader])
|
||||
AC_MSG_RESULT([${want_loader}])
|
||||
|
||||
if test "x$want_loader" = "xyes" -o "x$want_loader" = "xauto"; then
|
||||
PKG_CHECK_MODULES([EET], [eet >= 1.6.0], [have_evas_font_loader_eet="yes"], [have_evas_font_loader_eet="no"])
|
||||
fi
|
||||
|
||||
if test "x${have_evas_font_loader_eet}" = "xno" -a "x$want_loader" = "xyes" -a "x$use_strict" = "xyes" ; then
|
||||
AC_MSG_ERROR([Eet dependencies not found (strict dependencies checking)])
|
||||
fi
|
||||
|
||||
if test "x$have_evas_font_loader_eet" = "xyes" ; then
|
||||
AC_DEFINE([BUILD_FONT_LOADER_EET], [1], [EET Font Loader Support])
|
||||
requirement_evas="eet >= 1.6.0 ${requirement_evas}"
|
||||
fi
|
||||
|
||||
popdef([UP])
|
||||
popdef([DOWN])
|
||||
|
||||
])
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
dnl use: EVAS_CONVERT_COLOR(bpp, colorspace, components[, default-enabled])
|
||||
AC_DEFUN([EVAS_CONVERT_COLOR],
|
||||
[
|
||||
pushdef([UP], translit([$1_$2_$3], [a-z], [A-Z]))dnl
|
||||
pushdef([DOWN_D], translit([$1-$2-$3], [A-Z], [a-z]))dnl
|
||||
pushdef([DOWN_U], translit([$1_$2_$3], [A-Z], [a-z]))dnl
|
||||
|
||||
conv_[]DOWN_U="no"
|
||||
|
||||
ifelse("x$4", "xno",
|
||||
[
|
||||
AC_ARG_ENABLE(convert-[]DOWN_D,
|
||||
AC_HELP_STRING(
|
||||
[--enable-convert-[]DOWN_D],
|
||||
[enable the $1bpp $2 $3 converter code]
|
||||
),
|
||||
[ conv_[]DOWN_U=$enableval ],
|
||||
[ conv_[]DOWN_U=no ]
|
||||
)
|
||||
], [
|
||||
AC_ARG_ENABLE(convert-[]DOWN_D,
|
||||
AC_HELP_STRING(
|
||||
[--disable-convert-[]DOWN_D],
|
||||
[disable the $1bpp $2 $3 converter code]
|
||||
),
|
||||
[ conv_[]DOWN_U=$enableval ],
|
||||
[ conv_[]DOWN_U=yes ]
|
||||
)
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING(whether to build $1bpp $2 $3 converter code)
|
||||
AC_MSG_RESULT($conv_[]DOWN_U)
|
||||
|
||||
if test "x$conv_[]DOWN_U" = "xyes" ; then
|
||||
AC_DEFINE(BUILD_CONVERT_[]UP, 1, [$1bpp $2 $3 Converter Support])
|
||||
fi
|
||||
|
||||
popdef([UP])
|
||||
popdef([DOWN_D])
|
||||
popdef([DOWN_U])
|
||||
])
|
||||
|
||||
dnl use: EVAS_CONVERT_ROT(bpp, colorspace, rot[, default-enabled])
|
||||
AC_DEFUN([EVAS_CONVERT_ROT],
|
||||
[
|
||||
pushdef([UP], translit([$1_$2_ROT$3], [a-z], [A-Z]))dnl
|
||||
pushdef([DOWN_D], translit([$1-$2-rot-$3], [A-Z], [a-z]))dnl
|
||||
pushdef([DOWN_U], translit([$1_$2_rot_$3], [A-Z], [a-z]))dnl
|
||||
|
||||
conv_[]DOWN_U="no"
|
||||
|
||||
ifelse("x$4", "xno",
|
||||
[
|
||||
AC_ARG_ENABLE(convert-[]DOWN_D,
|
||||
AC_HELP_STRING(
|
||||
[--enable-convert-[]DOWN_D],
|
||||
[enable the $1bpp $2 rotation $3 converter code]
|
||||
),
|
||||
[ conv_[]DOWN_U=$enableval ],
|
||||
[ conv_[]DOWN_U=no ]
|
||||
)
|
||||
], [
|
||||
AC_ARG_ENABLE(convert-[]DOWN_D,
|
||||
AC_HELP_STRING(
|
||||
[--disable-convert-[]DOWN_D],
|
||||
[disable the $1bpp $2 rotation $3 converter code]
|
||||
),
|
||||
[ conv_[]DOWN_U=$enableval ],
|
||||
[ conv_[]DOWN_U=yes ]
|
||||
)
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING(whether to build $1bpp $2 rotation $3 converter code)
|
||||
AC_MSG_RESULT($conv_[]DOWN_U)
|
||||
|
||||
if test "x$conv_[]DOWN_U" = "xyes" ; then
|
||||
AC_DEFINE(BUILD_CONVERT_[]UP, 1, [$1bpp $2 Rotation $3 Converter Support])
|
||||
fi
|
||||
|
||||
popdef([UP])
|
||||
popdef([DOWN_D])
|
||||
popdef([DOWN_U])
|
||||
])
|
|
@ -1,44 +0,0 @@
|
|||
dnl Copyright (C) 2009 Vincent Torri <vtorri at univ-evry dot fr>
|
||||
dnl That code is public domain and can be freely used or copied.
|
||||
|
||||
dnl Macro that enables scaler support is wanted.
|
||||
|
||||
dnl Usage: EVAS_CHECK_SCALER(scaler, description [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
||||
dnl The parameter 'scaler' is the type of scaler.
|
||||
dnl The parameter 'description' is the description of the scaler.
|
||||
dnl Defines BUILD_[TYPEOFSCALER]
|
||||
|
||||
AC_DEFUN([EVAS_CHECK_SCALER],
|
||||
[
|
||||
m4_pushdef([UP], m4_translit([$1], [-a-z], [_A-Z]))dnl
|
||||
m4_pushdef([DOWN], m4_translit([$1], [-A-Z], [_a-z]))dnl
|
||||
|
||||
AC_ARG_ENABLE([$1],
|
||||
AC_HELP_STRING([--disable-$1], [disable $2 code @<:@default=enabled@:>@]),
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
_efl_enable_scaler_option_[]DOWN="yes"
|
||||
else
|
||||
_efl_enable_scaler_option_[]DOWN="no"
|
||||
fi
|
||||
],
|
||||
[_efl_enable_scaler_option_[]DOWN="yes"])
|
||||
|
||||
AC_MSG_CHECKING(whether to build $2)
|
||||
AC_MSG_RESULT([${_efl_enable_scaler_option_[]DOWN}])
|
||||
|
||||
if test "x${_efl_enable_scaler_option_[]DOWN}" = "xyes" ; then
|
||||
AC_DEFINE([BUILD_]UP[], [1], [define to 1 if you have the $2 support])
|
||||
fi
|
||||
|
||||
if test "x${_efl_enable_scaler_option_[]DOWN}" = "xyes" ; then
|
||||
m4_default([$3], [:])
|
||||
else
|
||||
m4_default([$4], [:])
|
||||
fi
|
||||
|
||||
m4_popdef([UP])
|
||||
m4_popdef([DOWN])
|
||||
])
|
||||
|
||||
dnl End of evas_scaler.m4
|
|
@ -1,45 +1,5 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
if EVAS_CSERVE
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/lib/include \
|
||||
-I$(top_srcdir)/src/lib/cserve \
|
||||
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
||||
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
|
||||
@EVAS_GENERAL_CFLAGS@ \
|
||||
@FREETYPE_CFLAGS@ \
|
||||
@FRIBIDI_CFLAGS@ \
|
||||
@EET_CFLAGS@ \
|
||||
@FONTCONFIG_CFLAGS@ \
|
||||
@pthread_cflags@ \
|
||||
@PIXMAN_CFLAGS@
|
||||
|
||||
bin_PROGRAMS = evas_cserve evas_cserve_tool
|
||||
|
||||
evas_cserve_SOURCES = \
|
||||
evas_cserve_main.c
|
||||
|
||||
evas_cserve_LDADD = \
|
||||
$(top_builddir)/src/lib/libevas.la \
|
||||
@pthread_libs@ \
|
||||
@EVAS_GENERAL_LIBS@
|
||||
|
||||
evas_cserve_tool_LDFLAGS =
|
||||
|
||||
evas_cserve_tool_SOURCES = \
|
||||
evas_cserve_tool.c
|
||||
|
||||
evas_cserve_tool_LDADD = \
|
||||
$(top_builddir)/src/lib/libevas.la \
|
||||
@pthread_libs@ \
|
||||
@EVAS_GENERAL_LIBS@
|
||||
|
||||
endif
|
||||
|
||||
if EVAS_CSERVE2
|
||||
|
||||
SUBDIRS = loaders
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,160 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "evas_cs.h"
|
||||
|
||||
int _cserve_tool_log_dom = -1;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
evas_init();
|
||||
if (!evas_cserve_init())
|
||||
{
|
||||
printf("ERROR: Cannot connect to cserve. abort\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if ((!strcmp(argv[i], "-h")) ||
|
||||
(!strcmp(argv[i], "-help")) ||
|
||||
(!strcmp(argv[i], "--help")))
|
||||
{
|
||||
printf("Options:\n"
|
||||
"\t-h This help\n"
|
||||
"\tgetconfig Get configuration values\n"
|
||||
"\tsetconfig CSIZE CTIME CTIMECHECK Set the config values\n"
|
||||
"\tgetstats Get current cache statistics\n"
|
||||
"\tgetinfo Get current cache content info\n"
|
||||
);
|
||||
exit(0);
|
||||
}
|
||||
else if ((!strcmp(argv[i], "getconfig")))
|
||||
{
|
||||
Op_Getconfig_Reply config;
|
||||
|
||||
if (!evas_cserve_raw_config_get(&config))
|
||||
{
|
||||
printf("ERROR: cannot fetch config.\n");
|
||||
exit(-1);
|
||||
}
|
||||
printf("-REPLY-\n");
|
||||
printf("csize: %i\n", config.cache_max_usage);
|
||||
printf("ctime: %i\n", config.cache_item_timeout);
|
||||
printf("ctimecheck: %i\n", config.cache_item_timeout_check);
|
||||
printf("-OK-\n");
|
||||
}
|
||||
else if ((!strcmp(argv[i], "setconfig")) && (i < (argc - 3)))
|
||||
{
|
||||
Op_Setconfig config;
|
||||
|
||||
i++;
|
||||
config.cache_max_usage = atoi(argv[i]);
|
||||
i++;
|
||||
config.cache_item_timeout = atoi(argv[i]);
|
||||
i++;
|
||||
config.cache_item_timeout_check = atoi(argv[i]);
|
||||
if (!evas_cserve_raw_config_set(&config))
|
||||
{
|
||||
printf("ERROR: cannot set config.\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
else if ((!strcmp(argv[i], "getstats")))
|
||||
{
|
||||
Op_Getstats_Reply stats;
|
||||
|
||||
if (!evas_cserve_raw_stats_get(&stats))
|
||||
{
|
||||
printf("ERROR: cannot fetch stats.\n");
|
||||
exit(-1);
|
||||
}
|
||||
printf("-REPLY-\n");
|
||||
printf("saved_memory: %i Kb\n", stats.saved_memory / 1024);
|
||||
printf("wasted_memory: %i Kb\n", stats.wasted_memory / 1024);
|
||||
printf("saved_memory_peak: %i Kb\n", stats.saved_memory_peak / 1024);
|
||||
printf("wasted_memory_peak: %i Kb\n", stats.wasted_memory_peak / 1024);
|
||||
printf("saved_time_image_header_load: %1.3f sec\n", stats.saved_time_image_header_load);
|
||||
printf("saved_time_image_data_load: %1.3f sec\n", stats.saved_time_image_data_load);
|
||||
printf("-OK-\n");
|
||||
}
|
||||
else if ((!strcmp(argv[i], "getinfo")))
|
||||
{
|
||||
Op_Getinfo_Reply *info;
|
||||
unsigned char *p;
|
||||
int h, j;
|
||||
|
||||
info = evas_cserve_raw_info_get();
|
||||
if (!info)
|
||||
{
|
||||
printf("ERROR: cannot fetch info.\n");
|
||||
exit(-1);
|
||||
}
|
||||
j = info->active.count + info->cached.count;
|
||||
printf("-REPLY-\n");
|
||||
printf("active_count: %i\n", info->active.count);
|
||||
printf("active_memory: %i Kb\n", info->active.mem_total);
|
||||
printf("cache_count: %i\n", info->cached.count);
|
||||
printf("cache_memory: %i Kb\n", info->cached.mem_total);
|
||||
p = (unsigned char *)info;
|
||||
p += sizeof(Op_Getinfo_Reply);
|
||||
for (h = 0; h < j; h++)
|
||||
{
|
||||
Op_Getinfo_Item it;
|
||||
char *file, *key, buf[512];
|
||||
struct tm *ltm;
|
||||
|
||||
memcpy(&it, p, sizeof(Op_Getinfo_Item));
|
||||
file = (char*) (p + sizeof(Op_Getinfo_Item));
|
||||
key = file + strlen(file) + 1;
|
||||
printf("-IMAGE- [#%i]\n", h);
|
||||
printf(" file : %s\n", file);
|
||||
printf(" key : %s\n", key);
|
||||
printf(" size : %i x %i\n", it.w, it.h);
|
||||
printf(" active : %i\n", (int)it.active);
|
||||
printf(" memory used: %i bytes (%i Kb)\n", it.memory_footprint, (it.memory_footprint + 1023) / 1024);
|
||||
printf(" has alpha : %i\n", (int)it.alpha);
|
||||
printf(" data loaded: %i\n", (int)it.data_loaded);
|
||||
printf(" dead : %i\n", (int)it.dead);
|
||||
printf(" useless : %i\n", (int)it.useless);
|
||||
printf(" image refs : %i\n", it.refcount);
|
||||
printf(" data refs : %i\n", it.data_refcount);
|
||||
printf(" header load: %1.5f sec\n", it.head_load_time);
|
||||
printf(" data load : %1.5f sec\n", it.data_load_time);
|
||||
if (it.cached_time == 0)
|
||||
printf(" cached at : N/A\n");
|
||||
else
|
||||
{
|
||||
ltm = localtime(&(it.cached_time));
|
||||
if (ltm)
|
||||
{
|
||||
strftime(buf, sizeof(buf), "%Y.%m.%d %T", ltm);
|
||||
printf(" cached at : %s\n", buf);
|
||||
}
|
||||
}
|
||||
ltm = localtime(&(it.file_mod_time));
|
||||
if (ltm)
|
||||
{
|
||||
strftime(buf, sizeof(buf), "%Y.%m.%d %T", ltm);
|
||||
printf(" file mod at: %s\n", buf);
|
||||
}
|
||||
ltm = localtime(&(it.file_checked_time));
|
||||
if (ltm)
|
||||
{
|
||||
strftime(buf, sizeof(buf), "%Y.%m.%d %T", ltm);
|
||||
printf(" file check : %s\n", buf);
|
||||
}
|
||||
p += sizeof(Op_Getinfo_Item) + it.file_key_size;
|
||||
}
|
||||
free(info);
|
||||
printf("-OK-\n");
|
||||
}
|
||||
}
|
||||
evas_cserve_shutdown();
|
||||
evas_shutdown();
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
SUBDIRS = canvas cache cache2 cserve cserve2 file engines include
|
||||
SUBDIRS = canvas cache cache2 cserve2 file engines include
|
||||
EVAS_STATIC_MODULE =
|
||||
EVAS_STATIC_LIBADD =
|
||||
|
||||
|
@ -82,11 +82,6 @@ SUBDIRS += ../modules/loaders/bmp
|
|||
EVAS_STATIC_MODULE += ../modules/loaders/bmp/libevas_loader_bmp.la
|
||||
EVAS_STATIC_LIBADD += @evas_image_loader_bmp_libs@
|
||||
endif
|
||||
if EVAS_STATIC_BUILD_EDB
|
||||
SUBDIRS += ../modules/savers/edb ../modules/loaders/edb
|
||||
EVAS_STATIC_MODULE += ../modules/savers/edb/libevas_saver_edb.la ../modules/loaders/edb/libevas_loader_edb.la
|
||||
EVAS_STATIC_LIBADD += @evas_image_loader_edb_libs@
|
||||
endif
|
||||
if EVAS_STATIC_BUILD_EET
|
||||
SUBDIRS += ../modules/savers/eet ../modules/loaders/eet
|
||||
EVAS_STATIC_MODULE += ../modules/savers/eet/libevas_saver_eet.la ../modules/loaders/eet/libevas_loader_eet.la
|
||||
|
@ -181,23 +176,14 @@ includesdir = $(includedir)/evas-@VMAJ@
|
|||
|
||||
libevas_la_SOURCES = main.c
|
||||
|
||||
if EVAS_CSERVE
|
||||
|
||||
libevas_cserve_la = cserve/libevas_cserve.la
|
||||
|
||||
endif
|
||||
|
||||
if EVAS_CSERVE2
|
||||
|
||||
libevas_cserve2_la = cserve2/libevas_cserve2.la
|
||||
|
||||
endif
|
||||
|
||||
libevas_la_LIBADD = \
|
||||
canvas/libevas_canvas.la \
|
||||
file/libevas_file.la \
|
||||
cache/libevas_cache.la \
|
||||
$(libevas_cserve_la) \
|
||||
$(libevas_cserve2_la) \
|
||||
engines/common/libevas_engine_common.la \
|
||||
@FREETYPE_LIBS@ \
|
||||
|
@ -217,26 +203,20 @@ libevas_la_DEPENDENCIES = \
|
|||
canvas/libevas_canvas.la \
|
||||
file/libevas_file.la \
|
||||
cache/libevas_cache.la \
|
||||
$(libevas_cserve_la) \
|
||||
$(libevas_cserve2_la) \
|
||||
engines/common/libevas_engine_common.la \
|
||||
$(EVAS_STATIC_MODULE)
|
||||
|
||||
if EVAS_CSERVE2
|
||||
|
||||
libevas_la_LIBADD += \
|
||||
cache2/libevas_cache2.la
|
||||
|
||||
libevas_la_DEPENDENCIES += \
|
||||
cache2/libevas_cache2.la
|
||||
|
||||
endif
|
||||
|
||||
if BUILD_ENGINE_SOFTWARE_8
|
||||
|
||||
libevas_la_LIBADD += engines/common_8/libevas_engine_common_8.la
|
||||
libevas_la_DEPENDENCIES += engines/common_8/libevas_engine_common_8.la
|
||||
|
||||
endif
|
||||
|
||||
libevas_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
|
||||
|
@ -244,4 +224,4 @@ libevas_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @versio
|
|||
### Evas_GL we are still using it in our code, so just don't install it.
|
||||
EXTRA_DIST=Evas_GL.h
|
||||
|
||||
DIST_SUBDIRS = canvas cache cache2 cserve cserve2 file engines include
|
||||
DIST_SUBDIRS = canvas cache cache2 cserve2 file engines include
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "evas_common.h"
|
||||
#include "evas_private.h"
|
||||
#include "evas_cs.h"
|
||||
//#include "evas_cs.h"
|
||||
#ifdef EVAS_CSERVE2
|
||||
#include "evas_cs2_private.h"
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "evas_common.h"
|
||||
#include "evas_private.h"
|
||||
#include "evas_cs.h"
|
||||
//#include "evas_cs.h"
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_want_get(void)
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/lib/include \
|
||||
-I$(top_srcdir)/src/lib/cserve \
|
||||
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
||||
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
|
||||
@EVAS_GENERAL_CFLAGS@ \
|
||||
@FREETYPE_CFLAGS@ \
|
||||
@FRIBIDI_CFLAGS@ \
|
||||
@EET_CFLAGS@ \
|
||||
@FONTCONFIG_CFLAGS@ \
|
||||
@pthread_cflags@ \
|
||||
@PIXMAN_CFLAGS@
|
||||
|
||||
if EVAS_CSERVE
|
||||
|
||||
noinst_LTLIBRARIES = libevas_cserve.la
|
||||
|
||||
endif
|
||||
|
||||
libevas_cserve_la_SOURCES = \
|
||||
evas_cs.h \
|
||||
evas_cs_main.c \
|
||||
evas_cs_server.c \
|
||||
evas_cs_client.c \
|
||||
evas_cs_mem.c
|
||||
|
||||
libevas_cserve_la_LIBADD = @EVAS_GENERAL_LIBS@ @EFL_SHM_OPEN_LIBS@
|
|
@ -1,285 +0,0 @@
|
|||
#ifndef EVAS_CS_H
|
||||
#define EVAS_CS_H 1
|
||||
|
||||
#ifdef EVAS_CSERVE
|
||||
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/un.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "evas_common.h"
|
||||
#include "evas_private.h"
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef EFL_EVAS_BUILD
|
||||
# ifdef DLL_EXPORT
|
||||
# define EAPI __declspec(dllexport)
|
||||
# else
|
||||
# define EAPI
|
||||
# endif /* ! DLL_EXPORT */
|
||||
# else
|
||||
# define EAPI __declspec(dllimport)
|
||||
# endif /* ! EFL_EVAS_BUILD */
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
#endif /* ! _WIN32 */
|
||||
|
||||
#define LENGTH_OF_SOCKADDR_UN(s) (strlen((s)->sun_path) + (size_t)(((struct sockaddr_un *)NULL)->sun_path))
|
||||
|
||||
typedef struct _Server Server;
|
||||
typedef struct _Client Client;
|
||||
typedef struct _Mem Mem;
|
||||
|
||||
struct _Server
|
||||
{
|
||||
char *socket_path;
|
||||
Eina_List *clients;
|
||||
int (*func) (void *fdata, Server *s, Client *c, int opcode, int size, unsigned char *data);
|
||||
void *data;
|
||||
pid_t pid;
|
||||
int server_id;
|
||||
// for channel 2;
|
||||
struct {
|
||||
int fd;
|
||||
int req_from, req_to;
|
||||
} ch[2];
|
||||
void *main_handle;
|
||||
};
|
||||
|
||||
struct _Client
|
||||
{
|
||||
Server *server;
|
||||
unsigned char *buf;
|
||||
Client *client_main;
|
||||
int bufsize, bufalloc;
|
||||
int fd;
|
||||
unsigned char *inbuf;
|
||||
int inbufsize, inbufalloc;
|
||||
unsigned char dead : 1;
|
||||
void (*func) (void *fdata, Client *c);
|
||||
void *data;
|
||||
pid_t pid;
|
||||
int req_from, req_to;
|
||||
LK(lock);
|
||||
};
|
||||
|
||||
struct _Mem
|
||||
{
|
||||
unsigned char *data;
|
||||
char *name;
|
||||
int fd;
|
||||
int id;
|
||||
int offset;
|
||||
int size;
|
||||
int ref;
|
||||
Eina_Bool write : 1;
|
||||
};
|
||||
|
||||
//// for comms
|
||||
enum
|
||||
{
|
||||
OP_NOP, // 0
|
||||
|
||||
OP_INIT, // 1
|
||||
OP_LOAD, // 2
|
||||
OP_UNLOAD, // 3
|
||||
OP_LOADDATA, // 4
|
||||
OP_UNLOADDATA, // 5
|
||||
OP_USELESSDATA, // 6
|
||||
OP_PRELOAD, // 7
|
||||
OP_FORCEDUNLOAD, // 8
|
||||
|
||||
OP_GETCONFIG, // 9
|
||||
OP_SETCONFIG, // 10
|
||||
OP_GETSTATS, // 11
|
||||
OP_GETINFO, // 12
|
||||
|
||||
OP_INVALID // 13
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
pid_t pid;
|
||||
int server_id;
|
||||
void *handle;
|
||||
} Op_Init;
|
||||
typedef struct
|
||||
{
|
||||
struct {
|
||||
int scale_down_by;
|
||||
double dpi;
|
||||
int w, h;
|
||||
struct {
|
||||
int x, y, w, h;
|
||||
} region;
|
||||
Eina_Bool orientation;
|
||||
} lopt;
|
||||
} Op_Load; // +"file""key"
|
||||
typedef struct
|
||||
{
|
||||
void *handle;
|
||||
int server_id;
|
||||
struct {
|
||||
int id;
|
||||
int offset;
|
||||
int size;
|
||||
} mem;
|
||||
struct {
|
||||
int w, h;
|
||||
Eina_Bool alpha : 1;
|
||||
} image;
|
||||
} Op_Load_Reply;
|
||||
typedef struct
|
||||
{
|
||||
void *handle;
|
||||
int server_id;
|
||||
} Op_Unload;
|
||||
typedef struct
|
||||
{
|
||||
void *handle;
|
||||
int server_id;
|
||||
} Op_Unloaddata;
|
||||
typedef struct
|
||||
{
|
||||
void *handle;
|
||||
int server_id;
|
||||
} Op_Loaddata;
|
||||
typedef struct
|
||||
{
|
||||
struct {
|
||||
int id;
|
||||
int offset;
|
||||
int size;
|
||||
} mem;
|
||||
} Op_Loaddata_Reply;
|
||||
typedef struct
|
||||
{
|
||||
void *handle;
|
||||
int server_id;
|
||||
} Op_Preload;
|
||||
typedef struct
|
||||
{
|
||||
void *handle;
|
||||
struct {
|
||||
int id;
|
||||
int offset;
|
||||
int size;
|
||||
} mem;
|
||||
} Op_Preload_Reply;
|
||||
typedef struct
|
||||
{
|
||||
void *handle;
|
||||
int server_id;
|
||||
} Op_Forcedunload;
|
||||
typedef struct
|
||||
{
|
||||
int cache_max_usage;
|
||||
int cache_item_timeout;
|
||||
int cache_item_timeout_check;
|
||||
} Op_Getconfig_Reply;
|
||||
typedef struct
|
||||
{
|
||||
int cache_max_usage;
|
||||
int cache_item_timeout;
|
||||
int cache_item_timeout_check;
|
||||
} Op_Setconfig;
|
||||
typedef struct
|
||||
{
|
||||
int saved_memory;
|
||||
int wasted_memory;
|
||||
int saved_memory_peak;
|
||||
int wasted_memory_peak;
|
||||
double saved_time_image_header_load;
|
||||
double saved_time_image_data_load;
|
||||
} Op_Getstats_Reply;
|
||||
typedef struct
|
||||
{
|
||||
struct {
|
||||
int mem_total;
|
||||
int count;
|
||||
} active, cached;
|
||||
} Op_Getinfo_Reply; // + N active Info Items + N cached items
|
||||
typedef struct
|
||||
{
|
||||
int file_key_size;
|
||||
int w, h;
|
||||
time_t file_mod_time;
|
||||
time_t file_checked_time;
|
||||
time_t cached_time;
|
||||
int refcount;
|
||||
int data_refcount;
|
||||
int memory_footprint;
|
||||
double head_load_time;
|
||||
double data_load_time;
|
||||
Eina_Bool alpha : 1;
|
||||
Eina_Bool data_loaded : 1;
|
||||
Eina_Bool active : 1;
|
||||
Eina_Bool dead : 1;
|
||||
Eina_Bool useless : 1;
|
||||
} Op_Getinfo_Item; // + "file""key"
|
||||
|
||||
|
||||
// for clients to connect to cserve
|
||||
EAPI Eina_Bool evas_cserve_init(void);
|
||||
EAPI int evas_cserve_use_get(void);
|
||||
EAPI Eina_Bool evas_cserve_have_get(void);
|
||||
EAPI void evas_cserve_shutdown(void);
|
||||
EAPI void evas_cserve_discon(void);
|
||||
EAPI Eina_Bool evas_cserve_image_load(Image_Entry *ie, const char *file, const char *key, RGBA_Image_Loadopts *lopt);
|
||||
EAPI Eina_Bool evas_cserve_image_data_load(Image_Entry *ie);
|
||||
EAPI void evas_cserve_image_unload(Image_Entry *ie);
|
||||
EAPI void evas_cserve_image_useless(Image_Entry *ie);
|
||||
EAPI void evas_cserve_image_free(Image_Entry *ie);
|
||||
EAPI Eina_Bool evas_cserve_raw_config_get(Op_Getconfig_Reply *config);
|
||||
EAPI Eina_Bool evas_cserve_raw_config_set(Op_Setconfig *config);
|
||||
EAPI Eina_Bool evas_cserve_raw_stats_get(Op_Getstats_Reply *stats);
|
||||
EAPI Op_Getinfo_Reply *evas_cserve_raw_info_get(void);
|
||||
|
||||
// for the server
|
||||
EAPI Server *evas_cserve_server_add(void);
|
||||
EAPI void evas_cserve_server_del(Server *s);
|
||||
EAPI void evas_cserve_client_send(Client *c, int opcode, int size, unsigned char *data);
|
||||
EAPI void evas_cserve_server_message_handler_set(Server *s, int (*func) (void *fdata, Server *s, Client *c, int opcode, int size, unsigned char *data), void *data);
|
||||
EAPI void evas_cserve_server_wait(Server *s, int timeout);
|
||||
|
||||
//// for memory
|
||||
// for server
|
||||
EAPI Mem *evas_cserve_mem_new(int size, const char *name);
|
||||
EAPI void evas_cserve_mem_free(Mem *m);
|
||||
|
||||
// for client
|
||||
EAPI Mem *evas_cserve_mem_open(int pid, int id, const char *name, int size, int do_write);
|
||||
EAPI void evas_cserve_mem_close(Mem *m);
|
||||
|
||||
// for both
|
||||
EAPI Eina_Bool evas_cserve_mem_resize(Mem *m, int size);
|
||||
EAPI void evas_cserve_mem_del(int pid, int id);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,528 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "evas_cs.h"
|
||||
|
||||
#ifdef EVAS_CSERVE
|
||||
|
||||
static Server *cserve = NULL;
|
||||
static int csrve_init = 0;
|
||||
static int connect_num = 0;
|
||||
static int cserve_discon = 0;
|
||||
|
||||
static void
|
||||
pipe_handler(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
pipe_handle(int push)
|
||||
{
|
||||
static struct sigaction old_action;
|
||||
struct sigaction action;
|
||||
|
||||
if (push)
|
||||
{
|
||||
action.sa_handler = NULL;
|
||||
action.sa_sigaction = pipe_handler;
|
||||
action.sa_flags = SA_RESTART | SA_SIGINFO;
|
||||
sigemptyset(&action.sa_mask);
|
||||
sigaction(SIGPIPE, &action, &old_action);
|
||||
}
|
||||
else
|
||||
{
|
||||
sigaction(SIGPIPE, &old_action, &action);
|
||||
}
|
||||
}
|
||||
|
||||
static Server *
|
||||
server_connect(void)
|
||||
{
|
||||
Server *s;
|
||||
char buf[PATH_MAX];
|
||||
int curstate = 0;
|
||||
struct sockaddr_un socket_unix;
|
||||
int socket_unix_len;
|
||||
|
||||
s = calloc(1, sizeof(Server));
|
||||
if (!s) return NULL;
|
||||
s->ch[0].fd = -1;
|
||||
s->ch[1].fd = -1;
|
||||
snprintf(buf, sizeof(buf), "/tmp/.evas-cserve-%x", getuid());
|
||||
s->socket_path = strdup(buf);
|
||||
if (!s->socket_path)
|
||||
{
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
s->ch[0].fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (s->ch[0].fd < 0) goto error;
|
||||
if (fcntl(s->ch[0].fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
|
||||
if (setsockopt(s->ch[0].fd, SOL_SOCKET, SO_REUSEADDR, &curstate, sizeof(curstate)) < 0)
|
||||
goto error;
|
||||
socket_unix.sun_family = AF_UNIX;
|
||||
strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
|
||||
socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix);
|
||||
if (connect(s->ch[0].fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0) goto error;
|
||||
|
||||
s->ch[1].fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (s->ch[1].fd < 0) goto error;
|
||||
if (fcntl(s->ch[1].fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
|
||||
if (setsockopt(s->ch[1].fd, SOL_SOCKET, SO_REUSEADDR, &curstate, sizeof(curstate)) < 0)
|
||||
goto error;
|
||||
socket_unix.sun_family = AF_UNIX;
|
||||
strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
|
||||
socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix);
|
||||
if (connect(s->ch[1].fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0) goto error;
|
||||
|
||||
return s;
|
||||
error:
|
||||
if (s->ch[0].fd >= 0) close(s->ch[0].fd);
|
||||
if (s->ch[1].fd >= 0) close(s->ch[1].fd);
|
||||
free(s->socket_path);
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
server_disconnect(Server *s)
|
||||
{
|
||||
close(s->ch[0].fd);
|
||||
close(s->ch[1].fd);
|
||||
free(s->socket_path);
|
||||
free(s);
|
||||
}
|
||||
|
||||
static int
|
||||
server_send(Server *s, int channel, int opcode, int size, unsigned char *data)
|
||||
{
|
||||
int ints[3];
|
||||
int num;
|
||||
|
||||
pipe_handle(1);
|
||||
ints[0] = size;
|
||||
ints[1] = opcode;
|
||||
s->ch[channel].req_to++;
|
||||
ints[2] = s->ch[channel].req_to;
|
||||
num = write(s->ch[channel].fd, ints, (sizeof(int) * 3));
|
||||
if (num < 0)
|
||||
{
|
||||
pipe_handle(0);
|
||||
if (cserve) server_disconnect(cserve);
|
||||
cserve = NULL;
|
||||
return 0;
|
||||
}
|
||||
num = write(s->ch[channel].fd, data, size);
|
||||
if (num < 0)
|
||||
{
|
||||
pipe_handle(0);
|
||||
if (cserve) server_disconnect(cserve);
|
||||
cserve = NULL;
|
||||
return 0;
|
||||
}
|
||||
pipe_handle(0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static unsigned char *
|
||||
server_read(Server *s, int channel, int *opcode, int *size)
|
||||
{
|
||||
int ints[3], num, left;
|
||||
unsigned char *data;
|
||||
|
||||
num = read(s->ch[channel].fd, ints, sizeof(int) * 3);
|
||||
if (num != (sizeof(int) * 3))
|
||||
{
|
||||
if (cserve) server_disconnect(cserve);
|
||||
cserve = NULL;
|
||||
return NULL;
|
||||
}
|
||||
*size = ints[0];
|
||||
*opcode = ints[1];
|
||||
if ((*size < 0) || (*size > (1024 * 1024))) return NULL;
|
||||
if (ints[2] != (s->ch[channel].req_from + 1))
|
||||
{
|
||||
ERR("EEK! sequence number mismatch from serer with pid: %i. "
|
||||
"---- num %i is not 1 more than %i"
|
||||
,
|
||||
s->pid, ints[2], s->ch[channel].req_from);
|
||||
return NULL;
|
||||
}
|
||||
s->ch[channel].req_from++;
|
||||
data = malloc(*size);
|
||||
if (!data) return NULL;
|
||||
num = read(s->ch[channel].fd, data, *size);
|
||||
if (num < 0)
|
||||
{
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
left = *size - num;
|
||||
while (left > 0)
|
||||
{
|
||||
num = read(s->ch[channel].fd, data + (*size - left), left);
|
||||
if (num < 0)
|
||||
{
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
left -= num;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static int
|
||||
server_init(Server *s)
|
||||
{
|
||||
Op_Init msg, *rep;
|
||||
int opcode;
|
||||
int size;
|
||||
|
||||
msg.pid = getpid();
|
||||
msg.server_id = 0;
|
||||
msg.handle = NULL;
|
||||
if (!server_send(s, 0, OP_INIT, sizeof(msg), (unsigned char *)(&msg)))
|
||||
return 0;
|
||||
rep = (Op_Init *)server_read(s, 0, &opcode, &size);
|
||||
if ((rep) && (opcode == OP_INIT) && (size == sizeof(Op_Init)))
|
||||
{
|
||||
s->pid = rep->pid;
|
||||
s->server_id = rep->server_id;
|
||||
s->main_handle = rep->handle;
|
||||
connect_num++;
|
||||
msg.pid = getpid();
|
||||
msg.server_id = 1;
|
||||
msg.handle = rep->handle;
|
||||
free(rep);
|
||||
if (!server_send(s, 1, OP_INIT, sizeof(msg), (unsigned char *)(&msg)))
|
||||
return 0;
|
||||
rep = (Op_Init *)server_read(s, 1, &opcode, &size);
|
||||
if ((rep) && (opcode == OP_INIT) && (size == sizeof(Op_Init)))
|
||||
{
|
||||
free(rep);
|
||||
return 1;
|
||||
}
|
||||
if (rep) free(rep);
|
||||
return 0;
|
||||
}
|
||||
if (rep) free(rep);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_init(void)
|
||||
{
|
||||
csrve_init++;
|
||||
if (cserve) return 1;
|
||||
cserve = server_connect();
|
||||
if (!cserve) return 0;
|
||||
if (!server_init(cserve))
|
||||
{
|
||||
if (cserve) server_disconnect(cserve);
|
||||
cserve = NULL;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
evas_cserve_use_get(void)
|
||||
{
|
||||
return csrve_init;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_have_get(void)
|
||||
{
|
||||
if (cserve) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_shutdown(void)
|
||||
{
|
||||
csrve_init--;
|
||||
if (csrve_init > 0) return;
|
||||
if (!cserve) return;
|
||||
server_disconnect(cserve);
|
||||
cserve = NULL;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_discon(void)
|
||||
{
|
||||
if (cserve)
|
||||
{
|
||||
server_disconnect(cserve);
|
||||
cserve = NULL;
|
||||
cserve_discon = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
server_reinit(void)
|
||||
{
|
||||
if (cserve) return;
|
||||
if (cserve_discon) return;
|
||||
cserve = server_connect();
|
||||
if (cserve)
|
||||
{
|
||||
if (!server_init(cserve))
|
||||
{
|
||||
if (cserve) server_disconnect(cserve);
|
||||
cserve = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_image_load(Image_Entry *ie, const char *file, const char *key, RGBA_Image_Loadopts *lopt)
|
||||
{
|
||||
Op_Load msg;
|
||||
Op_Load_Reply *rep;
|
||||
unsigned char *buf;
|
||||
char fbuf[PATH_MAX], wdb[PATH_MAX];
|
||||
int flen, klen;
|
||||
int opcode;
|
||||
int size;
|
||||
|
||||
if (csrve_init > 0) server_reinit();
|
||||
else return 0;
|
||||
if (!cserve) return 0;
|
||||
if (!key) key = "";
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
msg.lopt.scale_down_by = lopt->scale_down_by;
|
||||
msg.lopt.dpi = lopt->dpi;
|
||||
msg.lopt.w = lopt->w;
|
||||
msg.lopt.h = lopt->h;
|
||||
msg.lopt.region.x = lopt->region.x;
|
||||
msg.lopt.region.y = lopt->region.y;
|
||||
msg.lopt.region.w = lopt->region.w;
|
||||
msg.lopt.region.h = lopt->region.h;
|
||||
msg.lopt.orientation = lopt->orientation;
|
||||
if (file[0] != '/')
|
||||
{
|
||||
if (getcwd(wdb, sizeof(wdb)))
|
||||
{
|
||||
snprintf(fbuf, sizeof(buf), "%s/%s", wdb, file);
|
||||
file = fbuf;
|
||||
}
|
||||
}
|
||||
if (!realpath(file, wdb)) file = wdb;
|
||||
flen = strlen(file) + 1;
|
||||
klen = strlen(key) + 1;
|
||||
buf = malloc(sizeof(msg) + flen + klen);
|
||||
if (!buf) return 0;
|
||||
memcpy(buf, &msg, sizeof(msg));
|
||||
memcpy(buf + sizeof(msg), file, flen);
|
||||
memcpy(buf + sizeof(msg) + flen, key, klen);
|
||||
if (!server_send(cserve, ie->channel, OP_LOAD,
|
||||
sizeof(msg) + flen + klen,
|
||||
buf))
|
||||
{
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
free(buf);
|
||||
if (!cserve) return 0;
|
||||
rep = (Op_Load_Reply *)server_read(cserve, ie->channel, &opcode, &size);
|
||||
if ((rep) && (opcode == OP_LOAD) && (size == sizeof(Op_Load_Reply)))
|
||||
{
|
||||
ie->w = rep->image.w;
|
||||
ie->h = rep->image.h;
|
||||
ie->flags.alpha = rep->image.alpha;
|
||||
ie->data1 = rep->handle;
|
||||
}
|
||||
if (rep) free(rep);
|
||||
if (!ie->data1) return 0;
|
||||
ie->connect_num = connect_num;
|
||||
if (cserve)
|
||||
ie->server_id = cserve->server_id;
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_image_data_load(Image_Entry *ie)
|
||||
{
|
||||
Op_Loaddata msg;
|
||||
Op_Loaddata_Reply *rep;
|
||||
int opcode;
|
||||
int size;
|
||||
if (csrve_init > 0) server_reinit();
|
||||
else return 0;
|
||||
if (!cserve) return 0;
|
||||
if (!ie->data1) return 0;
|
||||
if (cserve->server_id != ie->server_id)
|
||||
{
|
||||
ie->data1 = NULL;
|
||||
if (!evas_cserve_image_load(ie, ie->file, ie->key, &(ie->load_opts)))
|
||||
return 0;
|
||||
}
|
||||
if (ie->connect_num != connect_num) return 0;
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
msg.handle = ie->data1;
|
||||
msg.server_id = cserve->server_id;
|
||||
if (!server_send(cserve, ie->channel, OP_LOADDATA, sizeof(msg), (unsigned char *)(&msg)))
|
||||
return 0;
|
||||
if (!cserve) return 0;
|
||||
rep = (Op_Loaddata_Reply *)server_read(cserve, ie->channel, &opcode, &size);
|
||||
if ((rep) && (opcode == OP_LOADDATA) && (size == sizeof(Op_Loaddata_Reply)))
|
||||
{
|
||||
if (rep->mem.size <= 0)
|
||||
{
|
||||
free(rep);
|
||||
return 0;
|
||||
}
|
||||
ie->data2 = evas_cserve_mem_open(cserve->pid, rep->mem.id, NULL, rep->mem.size, 0);
|
||||
free(rep);
|
||||
return 1;
|
||||
}
|
||||
if (rep) free(rep);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_image_free(Image_Entry *ie)
|
||||
{
|
||||
Op_Unload msg;
|
||||
|
||||
if (csrve_init > 0) server_reinit();
|
||||
else return;
|
||||
if (!cserve) return;
|
||||
if (!ie->data1) return;
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
msg.handle = ie->data1;
|
||||
msg.server_id = cserve->server_id;
|
||||
if (ie->data2) evas_cserve_image_unload(ie);
|
||||
if (cserve)
|
||||
{
|
||||
if (ie->connect_num == connect_num)
|
||||
{
|
||||
if (ie->server_id == cserve->server_id)
|
||||
server_send(cserve, ie->channel, OP_UNLOAD, sizeof(msg), (unsigned char *)(&msg));
|
||||
}
|
||||
}
|
||||
ie->data1 = NULL;
|
||||
ie->data2 = NULL;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_image_unload(Image_Entry *ie)
|
||||
{
|
||||
Op_Unloaddata msg;
|
||||
|
||||
if (csrve_init > 0) server_reinit();
|
||||
else return;
|
||||
if (!cserve) return;
|
||||
if (!ie->data1) return;
|
||||
if (ie->connect_num != connect_num) return;
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
msg.handle = ie->data1;
|
||||
msg.server_id = cserve->server_id;
|
||||
if (ie->data2) evas_cserve_mem_close(ie->data2);
|
||||
ie->data2 = NULL;
|
||||
if (ie->connect_num == connect_num)
|
||||
{
|
||||
if (ie->server_id == cserve->server_id)
|
||||
server_send(cserve, ie->channel, OP_UNLOADDATA, sizeof(msg), (unsigned char *)(&msg));
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_image_useless(Image_Entry *ie)
|
||||
{
|
||||
Op_Unloaddata msg;
|
||||
|
||||
if (csrve_init > 0) server_reinit();
|
||||
else return;
|
||||
if (!cserve) return;
|
||||
if (!ie->data1) return;
|
||||
if (ie->connect_num != connect_num) return;
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
msg.handle = ie->data1;
|
||||
msg.server_id = cserve->server_id;
|
||||
if (ie->data2) evas_cserve_mem_close(ie->data2);
|
||||
ie->data2 = NULL;
|
||||
if (ie->connect_num == connect_num)
|
||||
{
|
||||
if (ie->server_id == cserve->server_id)
|
||||
server_send(cserve, ie->channel, OP_USELESSDATA, sizeof(msg), (unsigned char *)(&msg));
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_raw_config_get(Op_Getconfig_Reply *config)
|
||||
{
|
||||
Op_Getconfig_Reply *rep;
|
||||
int opcode;
|
||||
int size;
|
||||
if (csrve_init > 0) server_reinit();
|
||||
else return 0;
|
||||
if (!cserve) return 0;
|
||||
if (!server_send(cserve, 0, OP_GETCONFIG, 0, NULL)) return 0;
|
||||
rep = (Op_Getconfig_Reply *)server_read(cserve, 0, &opcode, &size);
|
||||
if ((rep) && (opcode == OP_GETCONFIG) && (size == sizeof(Op_Getconfig_Reply)))
|
||||
{
|
||||
memcpy(config, rep, sizeof(Op_Getconfig_Reply));
|
||||
free(rep);
|
||||
return 1;
|
||||
}
|
||||
if (rep) free(rep);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_raw_config_set(Op_Setconfig *config)
|
||||
{
|
||||
if (csrve_init > 0) server_reinit();
|
||||
else return 0;
|
||||
if (!cserve) return 0;
|
||||
if (!server_send(cserve, 0, OP_SETCONFIG, sizeof(Op_Setconfig), (unsigned char *)config)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_raw_stats_get(Op_Getstats_Reply *stats)
|
||||
{
|
||||
Op_Getstats_Reply *rep;
|
||||
int opcode;
|
||||
int size;
|
||||
if (csrve_init > 0) server_reinit();
|
||||
else return 0;
|
||||
if (!cserve) return 0;
|
||||
if (!server_send(cserve, 0, OP_GETSTATS, 0, NULL)) return 0;
|
||||
rep = (Op_Getstats_Reply *)server_read(cserve, 0, &opcode, &size);
|
||||
if ((rep) && (opcode == OP_GETSTATS) && (size == sizeof(Op_Getstats_Reply)))
|
||||
{
|
||||
memcpy(stats, rep, sizeof(Op_Getstats_Reply));
|
||||
free(rep);
|
||||
return 1;
|
||||
}
|
||||
if (rep) free(rep);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI Op_Getinfo_Reply *
|
||||
evas_cserve_raw_info_get(void)
|
||||
{
|
||||
Op_Getinfo_Reply *rep;
|
||||
int opcode;
|
||||
int size;
|
||||
if (csrve_init > 0) server_reinit();
|
||||
else return NULL;
|
||||
if (!cserve) return NULL;
|
||||
if (!server_send(cserve, 0, OP_GETINFO, 0, NULL)) return NULL;
|
||||
rep = (Op_Getinfo_Reply *)server_read(cserve, 0, &opcode, &size);
|
||||
if ((rep) && (opcode == OP_GETINFO) &&
|
||||
(size >= (int)sizeof(Op_Getinfo_Reply)))
|
||||
{
|
||||
return rep;
|
||||
}
|
||||
if (rep) free(rep);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,9 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "evas_cs.h"
|
||||
|
||||
#ifdef EVAS_CSERVE
|
||||
|
||||
#endif
|
|
@ -1,168 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "evas_cs.h"
|
||||
|
||||
#ifdef EVAS_CSERVE
|
||||
|
||||
EAPI Mem *
|
||||
evas_cserve_mem_new(int size, const char *name)
|
||||
{
|
||||
Mem *m;
|
||||
static int id = 0;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
m = calloc(1, sizeof(Mem));
|
||||
if (!m) return NULL;
|
||||
if (name)
|
||||
snprintf(buf, sizeof(buf), "/evas-shm-%x.%s", getuid(), name);
|
||||
else
|
||||
{
|
||||
id++;
|
||||
snprintf(buf, sizeof(buf), "/evas-shm-%x.%x.%x", getuid(), getpid(), id);
|
||||
}
|
||||
m->id = id;
|
||||
m->offset = 0;
|
||||
m->name = strdup(buf);
|
||||
if (!m->name)
|
||||
{
|
||||
free(m);
|
||||
return NULL;
|
||||
}
|
||||
m->size = size;
|
||||
m->fd = shm_open(m->name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
if (m->fd < 0)
|
||||
{
|
||||
free(m->name);
|
||||
free(m);
|
||||
return NULL;
|
||||
}
|
||||
if (ftruncate(m->fd, m->size) < 0)
|
||||
{
|
||||
shm_unlink(m->name);
|
||||
close(m->fd);
|
||||
free(m->name);
|
||||
free(m);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
eina_mmap_safety_enabled_set(EINA_TRUE);
|
||||
|
||||
m->data = mmap(NULL, m->size, PROT_READ | PROT_WRITE, MAP_SHARED, m->fd, 0);
|
||||
if (m->data == MAP_FAILED)
|
||||
{
|
||||
shm_unlink(m->name);
|
||||
close(m->fd);
|
||||
free(m->name);
|
||||
free(m);
|
||||
return NULL;
|
||||
}
|
||||
m->ref = 1;
|
||||
m->write = 1;
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_mem_free(Mem *m)
|
||||
{
|
||||
shm_unlink(m->name);
|
||||
munmap(m->data, m->size);
|
||||
close(m->fd);
|
||||
free(m->name);
|
||||
free(m);
|
||||
}
|
||||
|
||||
EAPI Mem *
|
||||
evas_cserve_mem_open(int pid, int id, const char *name, int size, int do_write)
|
||||
{
|
||||
Mem *m;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
m = calloc(1, sizeof(Mem));
|
||||
if (!m) return NULL;
|
||||
if (name)
|
||||
snprintf(buf, sizeof(buf), "/evas-shm-%x.%s", getuid(), name);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "/evas-shm-%x.%x.%x", getuid(), pid, id);
|
||||
m->name = strdup(buf);
|
||||
if (!m->name)
|
||||
{
|
||||
free(m);
|
||||
return NULL;
|
||||
}
|
||||
m->size = size;
|
||||
if (do_write)
|
||||
m->fd = shm_open(m->name, O_RDWR, S_IRUSR | S_IWUSR);
|
||||
else
|
||||
m->fd = shm_open(m->name, O_RDONLY, S_IRUSR);
|
||||
if (m->fd < 0)
|
||||
{
|
||||
free(m->name);
|
||||
free(m);
|
||||
return NULL;
|
||||
}
|
||||
m->write = do_write;
|
||||
|
||||
eina_mmap_safety_enabled_set(EINA_TRUE);
|
||||
|
||||
if (do_write)
|
||||
m->data = mmap(NULL, m->size, PROT_READ | PROT_WRITE, MAP_SHARED, m->fd, 0);
|
||||
else
|
||||
m->data = mmap(NULL, m->size, PROT_READ, MAP_SHARED, m->fd, 0);
|
||||
if (m->data == MAP_FAILED)
|
||||
{
|
||||
close(m->fd);
|
||||
free(m->name);
|
||||
free(m);
|
||||
return NULL;
|
||||
}
|
||||
m->ref = 1;
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_mem_close(Mem *m)
|
||||
{
|
||||
munmap(m->data, m->size);
|
||||
close(m->fd);
|
||||
free(m->name);
|
||||
free(m);
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_cserve_mem_resize(Mem *m, int size)
|
||||
{
|
||||
if (m->size == size) return 1;
|
||||
if (m->write)
|
||||
{
|
||||
if (ftruncate(m->fd, size) < 0) return 0;
|
||||
munmap(m->data, m->size);
|
||||
eina_mmap_safety_enabled_set(EINA_TRUE);
|
||||
m->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, m->fd, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
munmap(m->data, m->size);
|
||||
eina_mmap_safety_enabled_set(EINA_TRUE);
|
||||
m->data = mmap(NULL, size, PROT_READ, MAP_SHARED, m->fd, 0);
|
||||
}
|
||||
if (m->data == MAP_FAILED)
|
||||
{
|
||||
m->data = NULL;
|
||||
return 0;
|
||||
}
|
||||
m->size = size;
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_mem_del(int pid, int id)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
|
||||
snprintf(buf, sizeof(buf), "/evas-shm-%x.%x.%x", getuid(), pid, id);
|
||||
shm_unlink(buf);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,380 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "evas_cs.h"
|
||||
|
||||
#ifdef EVAS_CSERVE
|
||||
|
||||
EAPI Server *
|
||||
evas_cserve_server_add(void)
|
||||
{
|
||||
Server *s;
|
||||
char buf[PATH_MAX];
|
||||
struct sockaddr_un socket_unix;
|
||||
struct linger lin;
|
||||
mode_t pmode;
|
||||
int socket_unix_len;
|
||||
|
||||
s = calloc(1, sizeof(Server));
|
||||
if (!s) return NULL;
|
||||
s->ch[0].fd = -1;
|
||||
snprintf(buf, sizeof(buf), "/tmp/.evas-cserve-%x", getuid());
|
||||
s->socket_path = strdup(buf);
|
||||
if (!s->socket_path)
|
||||
{
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
pmode = umask(~(S_IRUSR | S_IWUSR));
|
||||
start:
|
||||
s->ch[0].fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (s->ch[0].fd < 0) goto error;
|
||||
if (fcntl(s->ch[0].fd, F_SETFL, O_NONBLOCK) < 0) goto error;
|
||||
if (fcntl(s->ch[0].fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
|
||||
lin.l_onoff = 1;
|
||||
lin.l_linger = 0;
|
||||
if (setsockopt(s->ch[0].fd, SOL_SOCKET, SO_LINGER, &lin, sizeof(struct linger)) < 0)
|
||||
goto error;
|
||||
socket_unix.sun_family = AF_UNIX;
|
||||
strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
|
||||
socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix);
|
||||
if (bind(s->ch[0].fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0)
|
||||
{
|
||||
if ((connect(s->ch[0].fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0) &&
|
||||
(unlink(s->socket_path) >= 0))
|
||||
{
|
||||
close(s->ch[0].fd);
|
||||
goto start;
|
||||
}
|
||||
else
|
||||
goto error;
|
||||
}
|
||||
if (listen(s->ch[0].fd, 4096) < 0) goto error;
|
||||
umask(pmode);
|
||||
return s;
|
||||
error:
|
||||
umask(pmode);
|
||||
if (s->ch[0].fd >= 0) close(s->ch[0].fd);
|
||||
free(s->socket_path);
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_server_del(Server *s)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
EINA_LIST_FREE(s->clients, c)
|
||||
{
|
||||
LKL(c->lock);
|
||||
close(c->fd);
|
||||
if (c->buf) free(c->buf);
|
||||
if (c->inbuf) free(c->inbuf);
|
||||
LKD(c->lock);
|
||||
free(c);
|
||||
}
|
||||
close(s->ch[0].fd);
|
||||
unlink(s->socket_path);
|
||||
free(s->socket_path);
|
||||
free(s);
|
||||
}
|
||||
|
||||
static void
|
||||
server_accept(Server *s)
|
||||
{
|
||||
Client *c;
|
||||
int new_fd;
|
||||
struct sockaddr_in incoming;
|
||||
size_t size_in;
|
||||
|
||||
size_in = sizeof(struct sockaddr_in);
|
||||
new_fd = accept(s->ch[0].fd, (struct sockaddr *)&incoming, (socklen_t *)&size_in);
|
||||
if (new_fd < 0) return;
|
||||
fcntl(new_fd, F_SETFL, O_NONBLOCK);
|
||||
fcntl(new_fd, F_SETFD, FD_CLOEXEC);
|
||||
c = calloc(1, sizeof(Client));
|
||||
if (!c)
|
||||
{
|
||||
close(new_fd);
|
||||
return;
|
||||
}
|
||||
c->server = s;
|
||||
c->fd = new_fd;
|
||||
LKI(c->lock);
|
||||
s->clients = eina_list_append(s->clients, c);
|
||||
}
|
||||
|
||||
static void
|
||||
client_flush(Client *c)
|
||||
{
|
||||
int num;
|
||||
|
||||
num = write(c->fd, c->buf, c->bufsize);
|
||||
if (num < 0)
|
||||
{
|
||||
c->dead = 1;
|
||||
return;
|
||||
}
|
||||
if (num < c->bufsize)
|
||||
{
|
||||
unsigned char *buf;
|
||||
|
||||
buf = malloc(c->bufsize - num);
|
||||
if (buf)
|
||||
{
|
||||
memcpy(buf, c->buf + num, c->bufsize - num);
|
||||
free(c->buf);
|
||||
c->bufsize = c->bufsize - num;
|
||||
c->bufalloc = c->bufsize;
|
||||
c->buf = buf;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free(c->buf);
|
||||
c->buf = NULL;
|
||||
c->bufsize = 0;
|
||||
c->bufalloc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
client_buf_add(Client *c, unsigned char *data, int size)
|
||||
{
|
||||
int newsize;
|
||||
unsigned char *buf;
|
||||
|
||||
newsize = c->bufsize + size;
|
||||
if (newsize > c->bufalloc)
|
||||
{
|
||||
c->bufalloc = newsize + 16384;
|
||||
buf = realloc(c->buf, c->bufalloc);
|
||||
if (buf) c->buf = buf;
|
||||
else return;
|
||||
}
|
||||
memcpy(c->buf + c->bufsize, data, size);
|
||||
c->bufsize += size;
|
||||
}
|
||||
|
||||
static void
|
||||
client_write(Client *c, unsigned char *data, int size)
|
||||
{
|
||||
int num;
|
||||
|
||||
if (!c->buf)
|
||||
{
|
||||
num = write(c->fd, data, size);
|
||||
if (num != size)
|
||||
client_buf_add(c, data + num, size - num);
|
||||
}
|
||||
else
|
||||
{
|
||||
client_buf_add(c, data, size);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_client_send(Client *c, int opcode, int size, unsigned char *data)
|
||||
{
|
||||
unsigned char *data2;
|
||||
int *ints;
|
||||
|
||||
data2 = malloc(size + (sizeof(int) * 3));
|
||||
if (!data2) return;
|
||||
ints = (int *)data2;
|
||||
ints[0] = size;
|
||||
ints[1] = opcode;
|
||||
// LKL(c->lock);
|
||||
c->req_to++;
|
||||
ints[2] = c->req_to;
|
||||
memcpy(data2 + (sizeof(int) * 3), data, size);
|
||||
client_write(c, data2, size + (sizeof(int) * 3));
|
||||
// LKU(c->lock);
|
||||
free(data2);
|
||||
}
|
||||
|
||||
static void
|
||||
server_message_handle(Server *s, Client *c, int opcode, int size, unsigned char *data)
|
||||
{
|
||||
if (s->func) s->func(s->data, s, c, opcode, size, data);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_server_message_handler_set(Server *s, int (*func) (void *fdata, Server *s, Client *c, int opcode, int size, unsigned char *data), void *data)
|
||||
{
|
||||
s->func = func;
|
||||
s->data = data;
|
||||
}
|
||||
|
||||
static int
|
||||
server_parse(Server *s, Client *c)
|
||||
{
|
||||
int *ints;
|
||||
unsigned char *data, *newbuf;
|
||||
|
||||
if (c->inbufsize < (int)sizeof(int)) return 0;
|
||||
ints = (int *)((c->inbuf));
|
||||
if ((ints[0] < 0) || (ints[0] > (1024 * 1024)))
|
||||
return 0;
|
||||
if (c->inbufsize < (ints[0] + ((int)sizeof(int) * 3)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
data = c->inbuf + (sizeof(int) * 3);
|
||||
if (ints[2] != (c->req_from + 1))
|
||||
{
|
||||
ERR("EEK! sequence number mismatch from client with pid: %i."
|
||||
"---- num %i is not 1 more than %i"
|
||||
,
|
||||
c->pid, ints[2], c->req_from);
|
||||
return 0;
|
||||
}
|
||||
c->req_from++;
|
||||
server_message_handle(s, c, ints[1], ints[0], data);
|
||||
c->inbufalloc -= ints[0] + (sizeof(int) * 3);
|
||||
if (c->inbufalloc == 0)
|
||||
{
|
||||
free(c->inbuf);
|
||||
c->inbuf = NULL;
|
||||
c->inbufsize = 0;
|
||||
return 0;
|
||||
}
|
||||
newbuf = malloc(c->inbufalloc);
|
||||
if (!newbuf)
|
||||
{
|
||||
c->inbufalloc += ints[0] + (sizeof(int) * 3);
|
||||
/* fixme - bad situation */
|
||||
return 0;
|
||||
}
|
||||
memcpy(newbuf, c->inbuf + ints[0] + (sizeof(int) * 3), c->inbufalloc);
|
||||
c->inbufsize -= ints[0] + (sizeof(int) * 3);
|
||||
free(c->inbuf);
|
||||
c->inbuf = newbuf;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
server_data(Server *s, Client *c, unsigned char *data, int size)
|
||||
{
|
||||
if (!c->inbuf)
|
||||
{
|
||||
c->inbuf = malloc(size);
|
||||
if (c->inbuf)
|
||||
{
|
||||
memcpy(c->inbuf, data, size);
|
||||
c->inbufalloc = size;
|
||||
c->inbufsize = size;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* fixme - bad situation */
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int size2;
|
||||
|
||||
size2 = c->inbufsize + size;
|
||||
if (size2 > c->inbufalloc)
|
||||
{
|
||||
unsigned char *newbuf;
|
||||
|
||||
c->inbufalloc = size2;
|
||||
newbuf = realloc(c->inbuf, c->inbufalloc);
|
||||
if (newbuf) c->inbuf = newbuf;
|
||||
else size2 = 0;
|
||||
}
|
||||
if (size2 > 0)
|
||||
{
|
||||
memcpy(c->inbuf + c->inbufsize, data, size);
|
||||
c->inbufsize = size2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* fixme - bad situation */
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (server_parse(s, c));
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_cserve_server_wait(Server *s, int timeout)
|
||||
{
|
||||
fd_set rset, wset, xset;
|
||||
int maxfd;
|
||||
int ret;
|
||||
struct timeval to;
|
||||
Eina_List *l, *dead = NULL;
|
||||
Client *c;
|
||||
|
||||
maxfd = 0;
|
||||
FD_ZERO(&rset);
|
||||
FD_ZERO(&wset);
|
||||
FD_ZERO(&xset);
|
||||
FD_SET(s->ch[0].fd, &rset);
|
||||
if (s->ch[0].fd > maxfd) maxfd = s->ch[0].fd;
|
||||
EINA_LIST_FOREACH(s->clients, l, c)
|
||||
{
|
||||
FD_SET(c->fd, &rset);
|
||||
if (c->buf)
|
||||
FD_SET(c->fd, &wset);
|
||||
if (c->fd > maxfd) maxfd = c->fd;
|
||||
}
|
||||
if (timeout > 0)
|
||||
{
|
||||
to.tv_sec = timeout / 1000000;
|
||||
to.tv_usec = timeout % 1000000;
|
||||
ret = select(maxfd + 1, &rset, &wset, &xset, &to);
|
||||
}
|
||||
else
|
||||
ret = select(maxfd + 1, &rset, &wset, &xset, NULL);
|
||||
if (ret < 1) return;
|
||||
|
||||
EINA_LIST_FOREACH(s->clients, l, c)
|
||||
{
|
||||
if (c->dead) continue;
|
||||
if (FD_ISSET(c->fd, &rset))
|
||||
{
|
||||
unsigned char buf[16384];
|
||||
int num;
|
||||
|
||||
errno = 0;
|
||||
num = read(c->fd, buf, sizeof(buf));
|
||||
if (num <= 0)
|
||||
{
|
||||
c->dead = 1;
|
||||
dead = eina_list_append(dead, c);
|
||||
}
|
||||
else if (num > 0)
|
||||
{
|
||||
server_data(s, c, buf, num);
|
||||
}
|
||||
}
|
||||
else if (FD_ISSET(c->fd, &wset))
|
||||
{
|
||||
client_flush(c);
|
||||
if (c->dead) dead = eina_list_append(dead, c);
|
||||
}
|
||||
}
|
||||
if (FD_ISSET(s->ch[0].fd, &rset))
|
||||
{
|
||||
server_accept(s);
|
||||
}
|
||||
EINA_LIST_FREE(dead, c)
|
||||
{
|
||||
LKL(c->lock);
|
||||
if (c->func) c->func(c->data, c);
|
||||
s->clients = eina_list_remove(s->clients, c);
|
||||
close(c->fd);
|
||||
if (c->buf) free(c->buf);
|
||||
if (c->inbuf) free(c->inbuf);
|
||||
LKD(c->lock);
|
||||
free(c);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "evas_common.h"
|
||||
#include "evas_private.h"
|
||||
#include "evas_cs.h"
|
||||
//#include "evas_cs.h"
|
||||
#ifdef EVAS_CSERVE2
|
||||
#include "evas_cs2_private.h"
|
||||
#endif
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "evas_private.h"
|
||||
#include "evas_image_private.h"
|
||||
#include "evas_convert_yuv.h"
|
||||
#include "evas_cs.h"
|
||||
//#include "evas_cs.h"
|
||||
|
||||
#ifdef HAVE_VALGRIND
|
||||
# include <memcheck.h>
|
||||
|
|
|
@ -8,12 +8,6 @@ SUBDIRS += bmp
|
|||
endif
|
||||
endif
|
||||
|
||||
if BUILD_LOADER_EDB
|
||||
if !EVAS_STATIC_BUILD_EDB
|
||||
SUBDIRS += edb
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_LOADER_EET
|
||||
if !EVAS_STATIC_BUILD_EET
|
||||
SUBDIRS += eet
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/lib/include \
|
||||
@FREETYPE_CFLAGS@ \
|
||||
@PIXMAN_CFLAGS@ \
|
||||
@FRIBIDI_CFLAGS@ \
|
||||
@evas_image_loader_edb_cflags@ \
|
||||
@EVAS_GENERAL_CFLAGS@
|
||||
|
||||
|
||||
if BUILD_LOADER_EDB
|
||||
if !EVAS_STATIC_BUILD_EDB
|
||||
|
||||
pkgdir = $(libdir)/evas/modules/loaders/edb/$(MODULE_ARCH)
|
||||
pkg_LTLIBRARIES = module.la
|
||||
|
||||
module_la_SOURCES = evas_image_load_edb.c
|
||||
|
||||
module_la_LIBADD = @evas_image_loader_edb_libs@ @EVAS_GENERAL_LIBS@ $(top_builddir)/src/lib/libevas.la
|
||||
module_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
module_la_LIBTOOLFLAGS = --tag=disable-static
|
||||
|
||||
else
|
||||
|
||||
noinst_LTLIBRARIES = libevas_loader_edb.la
|
||||
|
||||
libevas_loader_edb_la_SOURCES = evas_image_load_edb.c
|
||||
libevas_loader_edb_la_LIBADD = @evas_image_loader_edb_libs@
|
||||
|
||||
endif
|
||||
endif
|
|
@ -1,251 +0,0 @@
|
|||
#include "evas_common.h"
|
||||
#include "evas_private.h"
|
||||
|
||||
#include <Edb.h>
|
||||
#include <zlib.h>
|
||||
|
||||
|
||||
#define SWAP32(x) (x) = ((((x) & 0x000000ff ) << 24) | (((x) & 0x0000ff00 ) << 8) | (((x) & 0x00ff0000 ) >> 8) | (((x) & 0xff000000 ) >> 24))
|
||||
|
||||
|
||||
static Eina_Bool evas_image_load_file_head_edb(Image_Entry *ie, const char *file, const char *key, int *error) EINA_ARG_NONNULL(1, 2, 4);
|
||||
static Eina_Bool evas_image_load_file_data_edb(Image_Entry *ie, const char *file, const char *key, int *error) EINA_ARG_NONNULL(1, 2, 4);
|
||||
|
||||
static Evas_Image_Load_Func evas_image_load_edb_func =
|
||||
{
|
||||
EINA_TRUE,
|
||||
evas_image_load_file_head_edb,
|
||||
evas_image_load_file_data_edb,
|
||||
NULL,
|
||||
EINA_FALSE
|
||||
};
|
||||
|
||||
static Eina_Bool
|
||||
evas_image_load_file_head_edb(Image_Entry *ie, const char *file, const char *key, int *error)
|
||||
{
|
||||
int w, h, alpha, compression, size;
|
||||
E_DB_File *db;
|
||||
DATA32 *ret;
|
||||
DATA32 header[8];
|
||||
|
||||
if (!key)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
db = e_db_open_read((char *)file);
|
||||
if (!db)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
ret = e_db_data_get(db, (char *)key, &size);
|
||||
if (!ret)
|
||||
{
|
||||
e_db_close(db);
|
||||
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
if (size < 32)
|
||||
{
|
||||
free(ret);
|
||||
e_db_close(db);
|
||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
memcpy(header, ret, 32);
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++) SWAP32(header[i]);
|
||||
}
|
||||
#endif
|
||||
if (header[0] != 0xac1dfeed)
|
||||
{
|
||||
free(ret);
|
||||
e_db_close(db);
|
||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
w = header[1];
|
||||
h = header[2];
|
||||
if ((w < 1) || (h < 1) || (w > IMG_MAX_SIZE) || (h > IMG_MAX_SIZE) ||
|
||||
IMG_TOO_BIG(w, h))
|
||||
{
|
||||
free(ret);
|
||||
e_db_close(db);
|
||||
if (IMG_TOO_BIG(w, h))
|
||||
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
||||
else
|
||||
*error = EVAS_LOAD_ERROR_GENERIC;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
alpha = header[3];
|
||||
compression = header[4];
|
||||
|
||||
if ((compression == 0) && (size < ((w * h * 4) + 32)))
|
||||
{
|
||||
free(ret);
|
||||
e_db_close(db);
|
||||
*error = EVAS_LOAD_ERROR_GENERIC;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
if (alpha) ie->flags.alpha = 1;
|
||||
ie->w = w;
|
||||
ie->h = h;
|
||||
free(ret);
|
||||
e_db_close(db);
|
||||
*error = EVAS_LOAD_ERROR_NONE;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
evas_image_load_file_data_edb(Image_Entry *ie, const char *file, const char *key, int *error)
|
||||
{
|
||||
int w, h, alpha, compression, size;
|
||||
E_DB_File *db;
|
||||
DATA32 *ret;
|
||||
DATA32 *body;
|
||||
DATA32 *surface;
|
||||
DATA32 header[8];
|
||||
|
||||
if (!key)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
db = e_db_open_read((char *)file);
|
||||
if (!db)
|
||||
{
|
||||
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
ret = e_db_data_get(db, (char *)key, &size);
|
||||
if (!ret)
|
||||
{
|
||||
e_db_close(db);
|
||||
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
if (size < 32)
|
||||
{
|
||||
free(ret);
|
||||
e_db_close(db);
|
||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
memcpy(header, ret, 32);
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++) SWAP32(header[i]);
|
||||
}
|
||||
#endif
|
||||
if (header[0] != 0xac1dfeed)
|
||||
{
|
||||
free(ret);
|
||||
e_db_close(db);
|
||||
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
w = header[1];
|
||||
h = header[2];
|
||||
if ((w < 1) || (h < 1) || (w > IMG_MAX_SIZE) || (h > IMG_MAX_SIZE) ||
|
||||
IMG_TOO_BIG(w, h))
|
||||
{
|
||||
free(ret);
|
||||
e_db_close(db);
|
||||
if (IMG_TOO_BIG(w, h))
|
||||
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
||||
else
|
||||
*error = EVAS_LOAD_ERROR_GENERIC;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
alpha = header[3];
|
||||
compression = header[4];
|
||||
|
||||
if ((compression == 0) && (size < ((w * h * 4) + 32)))
|
||||
{
|
||||
free(ret);
|
||||
e_db_close(db);
|
||||
*error = EVAS_LOAD_ERROR_GENERIC;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
if (alpha) ie->flags.alpha = 1;
|
||||
body = &(ret[8]);
|
||||
evas_cache_image_surface_alloc(ie, w, h);
|
||||
surface = evas_cache_image_pixels(ie);
|
||||
if (!surface)
|
||||
{
|
||||
free(ret);
|
||||
e_db_close(db);
|
||||
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
if (!compression)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
{
|
||||
int x;
|
||||
|
||||
memcpy(surface, body, w * h * sizeof(DATA32));
|
||||
for (x = 0; x < (w * h); x++) SWAP32(surface[x]);
|
||||
}
|
||||
#else
|
||||
memcpy(surface, body, w * h * sizeof(DATA32));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
uLongf dlen;
|
||||
|
||||
dlen = w * h * sizeof(DATA32);
|
||||
uncompress((Bytef *)surface, &dlen, (Bytef *)body,
|
||||
(uLongf)(size - 32));
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
{
|
||||
int x;
|
||||
|
||||
for (x = 0; x < (w * h); x++) SWAP32(surface[x]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
evas_common_image_premul(ie);
|
||||
free(ret);
|
||||
e_db_close(db);
|
||||
*error = EVAS_LOAD_ERROR_NONE;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
module_open(Evas_Module *em)
|
||||
{
|
||||
if (!em) return 0;
|
||||
em->functions = (void *)(&evas_image_load_edb_func);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
module_close(Evas_Module *em)
|
||||
{
|
||||
}
|
||||
|
||||
static Evas_Module_Api evas_modapi =
|
||||
{
|
||||
EVAS_MODULE_API_VERSION,
|
||||
"edb",
|
||||
"none",
|
||||
{
|
||||
module_open,
|
||||
module_close
|
||||
}
|
||||
};
|
||||
|
||||
EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_IMAGE_LOADER, image_loader, edb);
|
||||
|
||||
#ifndef EVAS_STATIC_BUILD_EDB
|
||||
EVAS_EINA_MODULE_DEFINE(image_loader, edb);
|
||||
#endif
|
|
@ -2,12 +2,6 @@ MAINTAINERCLEANFILES = Makefile.in
|
|||
|
||||
SUBDIRS =
|
||||
|
||||
if BUILD_LOADER_EDB
|
||||
if !EVAS_STATIC_BUILD_EDB
|
||||
SUBDIRS += edb
|
||||
endif
|
||||
endif
|
||||
|
||||
if BUILD_LOADER_EET
|
||||
if !EVAS_STATIC_BUILD_EET
|
||||
SUBDIRS += eet
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
AM_CPPFLAGS = -I. -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/lib/include \
|
||||
@FREETYPE_CFLAGS@ \
|
||||
@PIXMAN_CFLAGS@ \
|
||||
@FRIBIDI_CFLAGS@ \
|
||||
@evas_image_loader_edb_cflags@ \
|
||||
@EVAS_GENERAL_CFLAGS@
|
||||
|
||||
if BUILD_LOADER_EDB
|
||||
if !EVAS_STATIC_BUILD_EDB
|
||||
|
||||
pkgdir = $(libdir)/evas/modules/savers/edb/$(MODULE_ARCH)
|
||||
pkg_LTLIBRARIES = module.la
|
||||
|
||||
module_la_SOURCES = evas_image_save_edb.c
|
||||
|
||||
module_la_LIBADD = @EVAS_GENERAL_LIBS@ @evas_image_loader_edb_libs@ $(top_builddir)/src/lib/libevas.la
|
||||
module_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
module_la_LIBTOOLFLAGS = --tag=disable-static
|
||||
|
||||
else
|
||||
|
||||
noinst_LTLIBRARIES = libevas_saver_edb.la
|
||||
|
||||
libevas_saver_edb_la_SOURCES = evas_image_save_edb.c
|
||||
libevas_saver_edb_la_LIBADD = @evas_image_loader_edb_libs@
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_DIST = evas_image_save_edb.c
|
|
@ -1,48 +0,0 @@
|
|||
#include "evas_common.h"
|
||||
#include "evas_private.h"
|
||||
|
||||
#include <Edb.h>
|
||||
#include <zlib.h>
|
||||
|
||||
static int evas_image_save_file_edb(RGBA_Image *im, const char *file, const char *key, int quality, int compress);
|
||||
|
||||
static Evas_Image_Save_Func evas_image_save_edb_func =
|
||||
{
|
||||
evas_image_save_file_edb
|
||||
};
|
||||
|
||||
static int
|
||||
evas_image_save_file_edb(RGBA_Image *im, const char *file, const char *key, int quality, int compress)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
module_open(Evas_Module *em)
|
||||
{
|
||||
if (!em) return 0;
|
||||
em->functions = (void *)(&evas_image_save_edb_func);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
module_close(Evas_Module *em)
|
||||
{
|
||||
}
|
||||
|
||||
static Evas_Module_Api evas_modapi =
|
||||
{
|
||||
EVAS_MODULE_API_VERSION,
|
||||
"edb",
|
||||
"none",
|
||||
{
|
||||
module_open,
|
||||
module_close
|
||||
}
|
||||
};
|
||||
|
||||
EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_IMAGE_SAVER, image_saver, edb);
|
||||
|
||||
#ifndef EVAS_STATIC_BUILD_EDB
|
||||
EVAS_EINA_MODULE_DEFINE(image_saver, edb);
|
||||
#endif
|
Loading…
Reference in New Issue