Enable disabling filter functions

To optionally reduce footprint.
This commit is contained in:
Kim Woelders 2022-07-22 14:47:21 +02:00
parent 2ba6ec494f
commit 96e95920dc
7 changed files with 42 additions and 8 deletions

View File

@ -223,6 +223,16 @@ EC_LOADER_CHECK(ID3, auto, id3tag)
AM_CONDITIONAL(BUILD_TEST, false)
AC_ARG_ENABLE([filters],
[AS_HELP_STRING([--enable-filters], [Enable filters @<:@default=yes@:>@])],
enable_filters="$enableval",
enable_filters="yes"
)
if test "$enable_filters" = "yes"; then
AC_DEFINE(ENABLE_FILTERS, 1, [Enable filters])
fi
AM_CONDITIONAL(ENABLE_FILTERS, test "$enable_filters" = "yes")
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug], [Enable debug features @<:@default=no@:>@])],
[
@ -306,6 +316,7 @@ echo
echo "Use X86 MMX for speed.....: $mmx"
echo "Use AMD64 for speed.......: $amd64"
echo
echo "Include filters...........: $enable_filters"
echo "Use visibility hiding.....: $enable_visibility_hiding"
echo
echo "Installation path.........: $prefix"

View File

@ -5,7 +5,10 @@ AM_CPPFLAGS = \
$(X_CFLAGS)
if BUILD_X11
X_BASED_PROGS = imlib2_show imlib2_test imlib2_bumpmap imlib2_poly imlib2_colorspace imlib2_view imlib2_grab
X_BASED_PROGS = imlib2_show imlib2_test imlib2_poly imlib2_colorspace imlib2_view imlib2_grab
if ENABLE_FILTERS
X_BASED_PROGS += imlib2_bumpmap
endif
endif
bin_PROGRAMS = \

View File

@ -56,7 +56,10 @@ main(int argc, char **argv)
int blend = 1;
int interactive = 1;
int blendtest = 0;
#if ENABLE_FILTERS
int filter = 0;
#endif
int pol = 0;
int rotate = 0;
int rottest = 0;
@ -121,9 +124,13 @@ main(int argc, char **argv)
printf("-loop\t\tScales down the image.\n");
printf("-blendtest\tPerforms a blending test on the file.\n");
printf("-rotatetest\tPerforms a rotate test on the file.\n");
#if ENABLE_FILTERS
printf
("-filter\t\tPerforms filtering. Possible filters are,\n\t\t\t1:Blur filter, 2:Sharpen filter, 3:Color blur filter, \n\t\t\t4:Emboss filter, 5:Grayscale filter, 6:Saturation filter,\n\t\t\t7:Edge detection filter.\n");
#endif
#if 0
printf("-bmp2pt\t\tPerformas Bump Mapping to a point\n");
#endif
return 0;
}
@ -227,11 +234,13 @@ main(int argc, char **argv)
}
else if (!strcmp(argv[i], "-rotate"))
rotate = 1;
#if ENABLE_FILTERS
else if (!strcmp(argv[i], "-filter"))
{
filter = atoi(argv[++i]);
interactive = 0;
}
#endif
else if (!strcmp(argv[i], "-rotatetest"))
{
rottest = 1;
@ -682,6 +691,7 @@ main(int argc, char **argv)
}
imlib_free_image();
}
#if ENABLE_FILTERS
else if (filter)
{
imlib_context_set_filter(imlib_create_filter(0));
@ -766,6 +776,7 @@ main(int argc, char **argv)
}
imlib_free_filter();
}
#endif /* ENABLE_FILTERS */
else if (interactive)
{
int px, py, first = 1;

View File

@ -15,7 +15,6 @@ libImlib2_la_LIBADD =
libImlib2_la_SOURCES = \
api.c api.h \
api_filter.c \
api_obsolete.c \
asm.h \
asm_c.c asm_c.h \
@ -28,9 +27,7 @@ draw_ellipse.c \
draw_line.c \
draw_polygon.c \
draw_rectangle.c \
dynamic_filters.c dynamic_filters.h \
file.c file.h \
filter.c filter.h \
font.h \
font_draw.c \
font_load.c \
@ -45,11 +42,17 @@ object.c object.h \
rgbadraw.c rgbadraw.h \
rotate.c rotate.h \
scale.c scale.h \
script.c script.h \
span.c span.h \
strutils.c strutils.h \
types.h \
updates.c updates.h
if ENABLE_FILTERS
libImlib2_la_SOURCES += \
api_filter.c \
dynamic_filters.c dynamic_filters.h \
filter.c filter.h \
script.c script.h
endif
libImlib2_la_LIBADD += $(FREETYPE_LIBS)

View File

@ -143,11 +143,13 @@ __imlib_free_context(ImlibContext * context)
imlib_free_color_modifier();
ctx->color_modifier = NULL;
}
#if ENABLE_FILTERS
if (ctx->filter)
{
imlib_free_filter();
ctx->filter = NULL;
}
#endif
free(ctx);
ctx = next->context;

View File

@ -58,11 +58,12 @@ typedef struct {
char progress_granularity;
char dither_mask;
int mask_alpha_threshold;
Imlib_Filter filter;
Imlib_Rectangle cliprect;
int references;
char dirty;
#if ENABLE_FILTERS
Imlib_Filter filter;
#endif
} ImlibContext;
extern ImlibContext *ctx;

View File

@ -1 +1,4 @@
SUBDIRS = loaders filters
SUBDIRS = loaders
if ENABLE_FILTERS
SUBDIRS += filters
endif