app/paint-funcs/Makefile.am include files from app/composite/

app/paint-funcs/paint-funcs.c stubbed out code for using
gimp_composite.  To enable the use of gimp_composite, set the
value of gimp_composite_use_old to 0 (zero).

app/base/base.c calls gimp_composite_init() hook to initialse
all the gimp_composite "stuff."

app/composite/make-gimp-composite-dispatch.py now generates
gimp-composite-dispatch.h

app/composite/gimp-composite-dispatch.[ch] are in CVS although
they are generated files.  This is preparation for building the
table at run-time, instead of compile time.

app/composite/gimp-composite.c doesn't #include the main
dispatch table.  This is preparation for building the table at
run-time, instead of compile time.

app/composite/Makefile.am doesn't compile gimp-composite-mmx.c
(until the various remaining gcc problems and configuration issues
are worked out).
This commit is contained in:
Helvetix Victorinox
2003-07-13 15:48:41 +00:00
parent e4f083a956
commit 9d2b63962e
9 changed files with 179 additions and 101 deletions

View File

@ -1,3 +1,30 @@
2003-07-13 Helvetix Victorinox <helvetix@gimp.org>
* app/paint-funcs/Makefile.am include files from app/composite/
* app/paint-funcs/paint-funcs.c stubbed out code for using
gimp_composite. To enable the use of gimp_composite, set the
value of gimp_composite_use_old to 0 (zero).
* app/base/base.c calls gimp_composite_init() hook to initialse
all the gimp_composite "stuff."
* app/composite/make-gimp-composite-dispatch.py now generates
gimp-composite-dispatch.h
* app/composite/gimp-composite-dispatch.[ch] are in CVS although
they are generated files. This is preparation for building the
table at run-time, instead of compile time.
* app/composite/gimp-composite.c doesn't #include the main
dispatch table. This is preparation for building the table at
run-time, instead of compile time.
* app/composite/Makefile.am doesn't compile gimp-composite-mmx.c
(until the various remaining gcc problems and configuration issues
are worked out).
2003-07-11 Michael Natterer <mitch@gimp.org>
* app/config/gimpconfig.c (gimp_config_reset): don't return stuff

View File

@ -78,8 +78,8 @@ gimp_1_3_LDADD = \
file/libappfile.a \
plug-in/libappplug-in.a \
paint-funcs/libapppaint-funcs.a \
composite/libappcomposite.a \
base/libappbase.a \
composite/libappcomposite.a \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
$(top_builddir)/libgimpmath/libgimpmath-$(LT_RELEASE).la \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \

View File

@ -118,6 +118,7 @@ base_init (GimpBaseConfig *config,
g_free (path);
paint_funcs_setup (use_mmx);
gimp_composite_init();
}
void

View File

@ -18,13 +18,16 @@ INCLUDES = \
noinst_LIBRARIES = libappcomposite.a
libappcomposite_mmx_sources = \
gimp-composite-mmx.c \
gimp-composite-mmx.h \
libappcomposite_a_sources = \
gimp-composite.c \
gimp-composite-generic.c \
gimp-composite-generic.h \
gimp-composite.h \
gimp-composite-mmx.c \
gimp-composite-mmx.h \
gimp-composite-dispatch.c \
gimp-composite-util.h
libappcomposite_a_built_sources = gimp-composite-dispatch.c
@ -32,6 +35,7 @@ libappcomposite_a_built_sources = gimp-composite-dispatch.c
libappcomposite_a_SOURCES = $(libappcomposite_a_built_sources) $(libappcomposite_a_sources)
gimp-composite.c: gimp-composite-dispatch.c
gimp-composite-dispatch.c: gimp-composite-generic.o make-gimp-composite-dispatch.py
@ -46,7 +50,7 @@ EXTRA_PROGRAMS = test-composite
#
# unit tests for GimpComposite
# unit tests and meta tools for GimpComposite
#
TESTS = test-composite

View File

@ -151,7 +151,10 @@ struct {
char announce_function;
} gimp_composite_debug;
#include "gimp-composite-dispatch.c"
/*#include "gimp-composite-dispatch.c"*/
extern char *gimp_composite_function_name[GIMP_COMPOSITE_N][GIMP_PIXELFORMAT_N][GIMP_PIXELFORMAT_N][GIMP_PIXELFORMAT_N];
extern void (*gimp_composite_function[GIMP_COMPOSITE_N][GIMP_PIXELFORMAT_N][GIMP_PIXELFORMAT_N][GIMP_PIXELFORMAT_N]);
void
gimp_composite_dispatch(GimpCompositeContext *ctx)

View File

@ -39,6 +39,9 @@ typedef enum
GIMP_PIXELFORMAT_N
} GimpPixelFormat;
/*
* The following typedefs are temporary and only used in regression testing.
*/
typedef struct
{
guint8 v;

View File

@ -118,56 +118,56 @@ def print_function_table(filename, function_table):
for key in function_table_keys:
if not function_table_declarations.has_key(function_table[key][0]):
print "void %s(GimpCompositeContext *);" % (function_table[key][0])
print 'void %s(GimpCompositeContext *);' % (function_table[key][0])
function_table_declarations[function_table[key][0]] = function_table[key][0]
pass
pass
print ""
print "void (*%s[%d][%d][%d][%d])() = {" % (functionnameify(filename),
len(composite_modes),
len(pixel_format)-1,
len(pixel_format)-1,
len(pixel_format)-1)
print ''
print 'GimpCompositeFunction (*%s[%s][%s][%s][%s])() = {' % (functionnameify(filename),
"GIMP_COMPOSITE_N",
"GIMP_PIXELFORMAT_N",
"GIMP_PIXELFORMAT_N",
"GIMP_PIXELFORMAT_N")
for mode in composite_modes:
print " { /* %s */" % (mode)
print ' { /* %s */' % (mode)
for A in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
print " { /* A = %s */" % (pixel_depth_name(A))
print ' { /* A = %s */' % (pixel_depth_name(A))
for B in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
print " /* %-6s */ {" % (pixel_depth_name(B)),
print ' /* %-6s */ {' % (pixel_depth_name(B)),
for D in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
key = "%s_%s_%s_%s" % (string.lower(mode), pixel_depth_name(A), pixel_depth_name(B), pixel_depth_name(D))
if function_table.has_key(key):
print "%s, " % (function_table[key][0]),
print '%s, ' % (function_table[key][0]),
else:
print "%s, " % ("NULL"),
print '%s, ' % ("NULL"),
pass
pass
print "},"
print '},'
pass
print " },"
print ' },'
pass
print " },"
print ' },'
pass
print "};\n"
print '};\n'
return
def print_function_table_name(filename, function_table):
print ""
print "char *%s_name[%d][%d][%d][%d] = {" % (functionnameify(filename),
len(composite_modes),
len(pixel_format)-1,
len(pixel_format)-1,
len(pixel_format)-1)
print ''
print 'char *%s_name[%s][%s][%s][%s] = {' % (functionnameify(filename),
"GIMP_COMPOSITE_N",
"GIMP_PIXELFORMAT_N",
"GIMP_PIXELFORMAT_N",
"GIMP_PIXELFORMAT_N")
for mode in composite_modes:
print " { /* %s */" % (mode)
print ' { /* %s */' % (mode)
for A in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
print " { /* A = %s */" % (pixel_depth_name(A))
print ' { /* A = %s */' % (pixel_depth_name(A))
for B in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
print " /* %-6s */ {" % (pixel_depth_name(B)),
print ' /* %-6s */ {' % (pixel_depth_name(B)),
for D in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
key = "%s_%s_%s_%s" % (string.lower(mode), pixel_depth_name(A), pixel_depth_name(B), pixel_depth_name(D))
if function_table.has_key(key):
@ -176,14 +176,14 @@ def print_function_table_name(filename, function_table):
print '"%s", ' % (""),
pass
pass
print "},"
print '},'
pass
print " },"
print ' },'
pass
print " },"
print ' },'
pass
print "};\n"
print '};\n'
return
@ -286,27 +286,27 @@ def main(argv):
pass
print "/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */"
print "$Id$"
print '/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */'
print '$Id$'
print '#include "gimp-composite.h"'
print "extern void %s(GimpCompositeContext *);" % ("gimp_composite_unsupported")
print 'extern void %s(GimpCompositeContext *);' % ("gimp_composite_unsupported")
done = dict()
for k in gimp_composite_function.keys():
f = gimp_composite_function[k]
if not done.has_key(f[0]):
print "extern void %s(GimpCompositeContext *);" % (f[0])
print 'extern void %s(GimpCompositeContext *);' % (f[0])
done.update({f[0] : None})
pass
pass
if 1:
print "char *gimp_composite_function_name[%d][%d][%d][%d] = {" % (len(composite_modes), len(pixel_format)-1, len(pixel_format)-1, len(pixel_format)-1)
print 'char *gimp_composite_function_name[%d][%d][%d][%d] = {' % (len(composite_modes), len(pixel_format)-1, len(pixel_format)-1, len(pixel_format)-1)
for mode in composite_modes:
print " {"
print ' {'
for A in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
print " {"
print ' {'
for B in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
print " {",
print ' {',
for D in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
key = "%s_%s_%s_%s" % (string.lower(mode), pixel_depth_name(A), pixel_depth_name(B), pixel_depth_name(D))
if gimp_composite_function.has_key(key):
@ -315,71 +315,67 @@ def main(argv):
print '"%s", ' % ("gimp_composite_unsupported"),
pass
pass
print "},"
print '},'
pass
print " },"
print ' },'
pass
print " },"
print ' },'
pass
print "};"
print '};'
pass
print ""
print "void (*gimp_composite_function[%d][%d][%d][%d])() = {" % (len(composite_modes), len(pixel_format)-1, len(pixel_format)-1, len(pixel_format)-1)
print ''
print 'void (*gimp_composite_function[%d][%d][%d][%d])() = {' % (len(composite_modes), len(pixel_format)-1, len(pixel_format)-1, len(pixel_format)-1)
for mode in composite_modes:
print " { /* %s */" % (mode)
print ' { /* %s */' % (mode)
for A in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
print " { /* A = %s */" % (pixel_depth_name(A))
print ' { /* A = %s */' % (pixel_depth_name(A))
for B in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
print " /* %s */ {" % (pixel_depth_name(B)),
print ' /* %s */ {' % (pixel_depth_name(B)),
for D in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
key = "%s_%s_%s_%s" % (string.lower(mode), pixel_depth_name(A), pixel_depth_name(B), pixel_depth_name(D))
if gimp_composite_function.has_key(key):
print "%s, " % (gimp_composite_function[key][0]),
print '%s, ' % (gimp_composite_function[key][0]),
else:
print "%s, " % ("gimp_composite_unsupported"),
print '%s, ' % ("gimp_composite_unsupported"),
pass
pass
print "},"
print '},'
pass
print " },"
print ' },'
pass
print " },"
print ' },'
pass
print "};"
print '};'
print """
static int gimp_composite_initialised = 0;
print 'static int gimp_composite_initialised = 0;'
print 'void'
print 'gimp_composite_init()'
print '{'
print 'if (!gimp_composite_initialised) {'
void
gimp_composite_init()
{
if (!gimp_composite_initialised) {
"""
for o in objects:
print " %s_init();" % (functionnameify(o.filename))
print ' %s_init();' % (functionnameify(o.filename))
pass
print " gimp_composite_initialised = 1;"
print " }"
print "}"
print ' gimp_composite_initialised = 1;'
print ' }'
print '}'
pass
def gimp_composite_regression(function_tables):
print """
void
gimp_composite_regression()
{
GimpCompositeContext generic_ctx;
GimpCompositeContext special_ctx;
"""
print 'void'
print 'gimp_composite_regression()'
print '{'
print ' GimpCompositeContext generic_ctx;'
print ' GimpCompositeContext special_ctx;'
generic_table = function_tables[0][1]
@ -390,11 +386,11 @@ gimp_composite_regression()
for f in function_tables[1:]:
key = "%s_%s_%s_%s" % (string.lower(mode), pixel_depth_name(A), pixel_depth_name(B), pixel_depth_name(D))
if f[1].has_key(key):
print ""
print " special_ctx.op = %s;" % (mode)
print " generic_ctx.op = %s;" % (mode)
print " %s(&special_ctx);" % (f[1][key][0])
print " %s(&generic_ctx);" % (generic_table[key][0])
print ''
print ' special_ctx.op = %s;' % (mode)
print ' generic_ctx.op = %s;' % (mode)
print ' %s(&special_ctx);' % (f[1][key][0])
print ' %s(&generic_ctx);' % (generic_table[key][0])
print ' if (gimp_composite_regression_compare(&generic_ctx, &special_ctx)) {'
print ' printf("%s disagrees with %s\\n");' % (f[1][key][0], generic_table[key][0])
print ' }'
@ -405,43 +401,53 @@ gimp_composite_regression()
pass
pass
print """
}
"""
print '}'
def gimp_composite_init(function_tables):
for o in function_tables:
print "extern void %s_init();" % (functionnameify(o[0]))
print 'extern void %s_init();' % (functionnameify(o[0]))
pass
print ""
print """
static int gimp_composite_initialised = 0;
print ''
print 'static int gimp_composite_initialised = 0;'
print ''
print 'void'
print 'gimp_composite_init()'
print '{'
print ' if (!gimp_composite_initialised) {'
void
gimp_composite_init()
{
if (!gimp_composite_initialised) {
"""
for o in function_tables:
print " %s_init();" % (functionnameify(o[0]))
print ' %s_init();' % (functionnameify(o[0]))
pass
print " gimp_composite_initialised = 1;"
print " }"
print "}"
print ' gimp_composite_initialised = 1;'
print ' }'
print '}'
pass
def gimp_composite_hfile(fpout):
print >>fpout, '/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */'
print >>fpout, ''
print >>fpout, 'typedef void (*GimpCompositeFunction)(GimpCompositeContext *);'
print >>fpout, 'typedef GimpCompositeFunction (*GimpCompositeFunctionTable[%s][%s][%s][%s]);' % ("GIMP_COMPOSITE_N",
"GIMP_PIXELFORMAT_N",
"GIMP_PIXELFORMAT_N",
"GIMP_PIXELFORMAT_N")
pass
print "/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */"
gimp_composite_hfile(open("gimp-composite-dispatch.h", "w"))
print '/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */'
print '#include "config.h"'
print '#include <glib-object.h>'
print '#include "base/base-types.h"'
print '#include "gimp-composite.h"'
print "extern void %s(GimpCompositeContext *);" % ("gimp_composite_unsupported")
print ""
print '#include "gimp-composite-dispatch.h"'
print 'extern GimpCompositeFunction %s;' % ("gimp_composite_unsupported")
print ''
d = list()
for f in sys.argv[1:]:

View File

@ -11,6 +11,7 @@ libapppaint_funcs_a_SOURCES = \
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/app \
-I$(top_srcdir)/app/composite \
$(GLIB_CFLAGS) \
-I$(includedir)

View File

@ -36,6 +36,8 @@
#include "paint-funcs.h"
#include "paint-funcs-generic.h"
#include "gimp-composite.h"
int gimp_composite_use_old = 1;
#define RANDOM_SEED 314159265
#define EPSILON 0.0001
@ -4544,6 +4546,7 @@ combine_sub_region (struct combine_regions_struct *st,
alms.bytes1 = src1->bytes;
alms.bytes2 = src2->bytes;
if (gimp_composite_use_old) {
/* Determine whether the alpha channel of the destination can be
* affected by the specified mode--This keeps consistency with
* varying opacities
@ -4553,6 +4556,36 @@ combine_sub_region (struct combine_regions_struct *st,
layer_mode_funcs[mode] (&alms);
combine = (alms.combine == NO_COMBINATION) ? type : alms.combine;
} else {
GimpCompositeContext ctx;
ctx.A = s1;
ctx.pixelformat_A = (src1->bytes == 1 ? GIMP_PIXELFORMAT_V8
: src1->bytes == 2 ? GIMP_PIXELFORMAT_VA8
: src1->bytes == 3 ? GIMP_PIXELFORMAT_RGB8
: src1->bytes == 4 ? GIMP_PIXELFORMAT_RGBA8
: GIMP_PIXELFORMAT_ANY);
ctx.B = s2;
ctx.pixelformat_B = (src2->bytes == 1 ? GIMP_PIXELFORMAT_V8
: src2->bytes == 2 ? GIMP_PIXELFORMAT_VA8
: src2->bytes == 3 ? GIMP_PIXELFORMAT_RGB8
: src2->bytes == 4 ? GIMP_PIXELFORMAT_RGBA8
: GIMP_PIXELFORMAT_ANY);
ctx.D = s;
ctx.pixelformat_D = gimp_composite_pixel_alpha[ctx.pixelformat_B];
ctx.n_pixels = src1->w;
ctx.combine = combine;
ctx.op = mode;
ctx.dissolve.x = src1->x;
ctx.dissolve.y = src1->y + h;
ctx.dissolve.opacity = opacity;
mode_affect = gimp_composite_operation_effects[mode].affect_opacity;
gimp_composite_dispatch(&ctx);
s = ctx.D;
combine = (ctx.combine == NO_COMBINATION) ? type : ctx.combine;
}
break;
}