app: remove the entire legacy composition code

This commit is contained in:
Michael Natterer 2012-05-19 00:41:43 +02:00
parent 07cc3976ca
commit 06c59973d3
49 changed files with 6 additions and 16638 deletions

View File

@ -15,7 +15,6 @@ SUBDIRS = \
base \
paint-funcs \
config \
composite \
core \
operations \
gegl \
@ -162,7 +161,6 @@ gimpconsoleldadd = \
file/libappfile.a \
text/libapptext.a \
paint/libapppaint.a \
composite/libappcomposite.a \
operations/libappoperations.a \
gegl/libappgegl.a \
config/libappconfig.a \

View File

@ -34,8 +34,6 @@
#include "config/gimpgeglconfig.h"
#include "composite/gimp-composite.h"
#include "base.h"
#include "pixel-processor.h"
#include "tile-cache.h"
@ -104,8 +102,6 @@ base_init (GimpGeglConfig *config,
G_CALLBACK (base_num_processors_notify),
NULL);
gimp_composite_init (be_verbose, use_cpu_accel);
return swap_is_ok;
}

View File

@ -1,16 +0,0 @@
/Makefile
/Makefile.in
/.deps
/.libs
/*.lo
/*.a
/libappcomposite.la
/ns.pyc
/gimp-composite-test
/test-composite
/gimp-composite-3dnow-test
/gimp-composite-altivec-test
/gimp-composite-mmx-test
/gimp-composite-sse-test
/gimp-composite-sse2-test
/gimp-composite-vis-test

View File

@ -1,220 +0,0 @@
## Process this file with automake to produce Makefile.in
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Composite\"
INCLUDES = \
-I$(top_builddir) \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(GEGL_CFLAGS) \
$(CAIRO_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
-I$(includedir)
composite_libraries = \
libcomposite3dnow.a \
libcompositealtivec.a \
libcompositemmx.a \
libcompositesse.a \
libcompositesse2.a \
libcompositevis.a
noinst_LIBRARIES = $(composite_libraries) libcomposite.a
libcomposite3dnow_a_SOURCES = \
gimp-composite-3dnow.c \
gimp-composite-3dnow.h
libcompositealtivec_a_CFLAGS = $(ALTIVEC_EXTRA_CFLAGS)
libcompositealtivec_a_SOURCES = \
gimp-composite-altivec.c \
gimp-composite-altivec.h
libcompositemmx_a_CFLAGS = $(MMX_EXTRA_CFLAGS)
libcompositemmx_a_SOURCES = \
gimp-composite-mmx.c \
gimp-composite-mmx.h
libcompositesse_a_CFLAGS = $(SSE_EXTRA_CFLAGS)
libcompositesse_a_SOURCES = \
gimp-composite-sse.c \
gimp-composite-sse.h
libcompositesse2_a_CFLAGS = $(SSE_EXTRA_CFLAGS)
libcompositesse2_a_SOURCES = \
gimp-composite-sse2.c \
gimp-composite-sse2.h
libcompositevis_a_SOURCES = \
gimp-composite-vis.c \
gimp-composite-vis.h
libcomposite_a_sources = \
gimp-composite-generic.c \
gimp-composite-generic.h \
gimp-composite-util.h \
gimp-composite-x86.h \
gimp-composite.c \
gimp-composite.h
libcomposite_a_built_sources = \
gimp-composite-3dnow-installer.c \
gimp-composite-altivec-installer.c \
gimp-composite-generic-installer.c \
gimp-composite-mmx-installer.c \
gimp-composite-sse-installer.c \
gimp-composite-sse2-installer.c \
gimp-composite-vis-installer.c
libcomposite_a_SOURCES = \
$(libcomposite_a_built_sources) \
$(libcomposite_a_sources)
## This is a huge hack
libappcomposite.a: $(noinst_LIBRARIES)
-rm -f libappcomposite.a
$(AR) $(ARFLAGS) libappcomposite.a $(libcomposite_a_OBJECTS) \
$(libcomposite3dnow_a_OBJECTS) \
$(libcompositealtivec_a_OBJECTS) \
$(libcompositemmx_a_OBJECTS) \
$(libcompositesse_a_OBJECTS) \
$(libcompositesse2_a_OBJECTS) \
$(libcompositevis_a_OBJECTS)
$(RANLIB) libappcomposite.a
all-local: libappcomposite.a
clean_libs = libappcomposite.a
regenerate: gimp-composite-generic.o $(libcomposite3dnow_a_OBJECTS) $(libcompositealtivec_a_OBJECTS) $(libcompositemmx_a_OBJECTS) $(libcompositesse_a_OBJECTS) $(libcompositesse2_a_OBJECTS) $(libcompositevis_a_OBJECTS)
$(srcdir)/make-installer.py -f gimp-composite-generic.o
$(srcdir)/make-installer.py -f $(libcompositemmx_a_OBJECTS) -t -r 'defined(COMPILE_MMX_IS_OKAY)' -c 'X86_MMX'
$(srcdir)/make-installer.py -f $(libcompositesse_a_OBJECTS) -t -r 'defined(COMPILE_SSE_IS_OKAY)' -c 'X86_SSE' -c 'X86_MMXEXT'
$(srcdir)/make-installer.py -f $(libcompositesse2_a_OBJECTS) -t -r 'defined(COMPILE_SSE2_IS_OKAY)' -c 'X86_SSE2'
$(srcdir)/make-installer.py -f $(libcomposite3dnow_a_OBJECTS) -t -r 'defined(COMPILE_3DNOW_IS_OKAY)' -c 'X86_3DNOW'
$(srcdir)/make-installer.py -f $(libcompositealtivec_a_OBJECTS) -t -r 'defined(COMPILE_ALTIVEC_IS_OKAY)' -c 'PPC_ALTIVEC'
$(srcdir)/make-installer.py -f $(libcompositevis_a_OBJECTS) -t -r 'defined(COMPILE_VIS_IS_OKAY)'
EXTRA_DIST = \
make-installer.py \
ns.py
#
# unit tests and meta tools for GimpComposite
#
TESTS = \
gimp-composite-3dnow-test \
gimp-composite-altivec-test \
gimp-composite-mmx-test \
gimp-composite-sse-test \
gimp-composite-sse2-test \
gimp-composite-vis-test
EXTRA_PROGRAMS = gimp-composite-test $(TESTS)
CLEANFILES = $(EXTRA_PROGRAMS) $(clean_libs)
gimp_composite_test_SOURCES = \
gimp-composite-regression.c \
gimp-composite-regression.h \
gimp-composite-test.c
gimp_composite_test_DEPENDENCIES = $(gimpcomposite_dependencies)
gimp_composite_test_LDADD = \
libappcomposite.a \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS)
gimp_composite_mmx_test_SOURCES = \
gimp-composite-regression.c \
gimp-composite-regression.h \
gimp-composite-mmx-test.c
gimp_composite_mmx_test_DEPENDENCIES = $(gimpcomposite_dependencies)
gimp_composite_mmx_test_LDADD = \
libappcomposite.a \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS)
gimp_composite_sse_test_SOURCES = \
gimp-composite-regression.c \
gimp-composite-regression.h \
gimp-composite-sse-test.c
gimp_composite_sse_test_DEPENDENCIES = $(gimpcomposite_dependencies)
gimp_composite_sse_test_LDADD = \
libappcomposite.a \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS)
gimp_composite_sse2_test_SOURCES = \
gimp-composite-regression.c \
gimp-composite-regression.h \
gimp-composite-sse2-test.c
gimp_composite_sse2_test_DEPENDENCIES = $(gimpcomposite_dependencies)
gimp_composite_sse2_test_LDADD = \
libappcomposite.a \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS)
gimp_composite_3dnow_test_SOURCES = \
gimp-composite-regression.c \
gimp-composite-regression.h \
gimp-composite-3dnow-test.c
gimp_composite_3dnow_test_DEPENDENCIES = $(gimpcomposite_dependencies)
gimp_composite_3dnow_test_LDADD = \
libappcomposite.a \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS)
gimp_composite_altivec_test_SOURCES = \
gimp-composite-regression.c \
gimp-composite-regression.h \
gimp-composite-altivec-test.c
gimp_composite_altivec_test_DEPENDENCIES = $(gimpcomposite_dependencies)
gimp_composite_altivec_test_LDADD = \
libappcomposite.a \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS)
gimp_composite_vis_test_SOURCES = \
gimp-composite-regression.c \
gimp-composite-regression.h \
gimp-composite-vis-test.c
gimp_composite_vis_test_DEPENDENCIES = $(gimpcomposite_dependencies)
gimp_composite_vis_test_LDADD = \
libappcomposite.a \
$(libgimpcolor) \
$(libgimpbase) \
$(GLIB_LIBS)

View File

@ -1,33 +0,0 @@
/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */
/* REGENERATE BY USING make-installer.py */
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-3dnow.h"
gboolean
gimp_composite_3dnow_install (void)
{
/* nothing to do */
return (FALSE);
}
gboolean
gimp_composite_3dnow_init (void)
{
#if defined(COMPILE_3DNOW_IS_OKAY)
if (gimp_cpu_accel_get_support () & GIMP_CPU_ACCEL_X86_3DNOW)
{
return (TRUE);
}
#endif
return (FALSE);
}

View File

@ -1,101 +0,0 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-regression.h"
#include "gimp-composite-util.h"
#include "gimp-composite-generic.h"
#include "gimp-composite-3dnow.h"
static int
gimp_composite_3dnow_test (int iterations, int n_pixels)
{
#if defined(COMPILE_3DNOW_IS_OKAY)
gimp_rgba8_t *rgba8D1;
gimp_rgba8_t *rgba8D2;
gimp_rgba8_t *rgba8A;
gimp_rgba8_t *rgba8B;
gimp_rgba8_t *rgba8M;
gimp_va8_t *va8A;
gimp_va8_t *va8B;
gimp_va8_t *va8M;
gimp_va8_t *va8D1;
gimp_va8_t *va8D2;
int i;
if (gimp_composite_3dnow_init () == 0)
{
g_print ("\ngimp_composite_3dnow: Instruction set is not available.\n");
return EXIT_SUCCESS;
}
g_print ("\nRunning gimp_composite_3dnow tests...\n");
rgba8A = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8B = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8M = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8D1 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
rgba8D2 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
va8A = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8B = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8M = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D1 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D2 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
for (i = 0; i < n_pixels; i++)
{
va8A[i].v = i;
va8A[i].a = 255-i;
va8B[i].v = i;
va8B[i].a = i;
va8M[i].v = i;
va8M[i].a = i;
}
#endif
return EXIT_SUCCESS;
}
int
main (int argc, char *argv[])
{
int iterations;
int n_pixels;
srand (314159);
g_setenv ("GIMP_COMPOSITE", "0x1", TRUE);
iterations = 10;
n_pixels = 8388625;
argv++, argc--;
while (argc >= 2)
{
if (argc > 1 && (strcmp (argv[0], "--iterations") == 0 || strcmp (argv[0], "-i") == 0))
{
iterations = atoi(argv[1]);
argc -= 2, argv++; argv++;
}
else if (argc > 1 && (strcmp (argv[0], "--n-pixels") == 0 || strcmp (argv[0], "-n") == 0))
{
n_pixels = atoi (argv[1]);
argc -= 2, argv++; argv++;
}
else
{
g_print ("Usage: gimp-composites-*-test [-i|--iterations n] [-n|--n-pixels n]");
return EXIT_FAILURE;
}
}
gimp_composite_generic_install ();
return (gimp_composite_3dnow_test (iterations, n_pixels));
}

View File

@ -1,35 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Gimp image compositing
* Copyright (C) 2003 Helvetix Victorinox, a pseudonym, <helvetix@gimp.org>
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-3dnow.h"
#ifdef COMPILE_3DNOW_IS_OKAY
#endif

View File

@ -1,24 +0,0 @@
#ifndef gimp_composite_3dnow_h
#define gimp_composite_3dnow_h
extern gboolean gimp_composite_3dnow_init (void);
/*
* The function gimp_composite_*_install() is defined in the code generated by make-install.py
* I hate to create a .h file just for that declaration, so I do it here (for now).
*/
extern gboolean gimp_composite_3dnow_install (void);
#if !defined(__INTEL_COMPILER)
#if defined(USE_MMX)
#if defined(ARCH_X86)
#if __GNUC__ >= 3
#if defined(ARCH_X86_64) || (!defined(PIC) && !defined(__PIC__))
#define COMPILE_3DNOW_IS_OKAY (1)
#endif /* ARCH_X86_64 || (!defined(PIC) && !defined(__PIC__)) */
#endif /* __GNUC__ > 3 */
#endif /* ARCH_X86 */
#endif /* USE_MMX */
#endif /* !defined(__INTEL_COMPILER) */
#endif

View File

@ -1,33 +0,0 @@
/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */
/* REGENERATE BY USING make-installer.py */
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-altivec.h"
gboolean
gimp_composite_altivec_install (void)
{
/* nothing to do */
return (FALSE);
}
gboolean
gimp_composite_altivec_init (void)
{
#if defined(COMPILE_ALTIVEC_IS_OKAY)
if (gimp_cpu_accel_get_support () & GIMP_CPU_ACCEL_PPC_ALTIVEC)
{
return (TRUE);
}
#endif
return (FALSE);
}

View File

@ -1,105 +0,0 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-regression.h"
#include "gimp-composite-util.h"
#include "gimp-composite-generic.h"
#include "gimp-composite-altivec.h"
static int
gimp_composite_altivec_test (int iterations, int n_pixels)
{
#if defined(COMPILE_ALTIVEC_IS_OKAY)
GimpCompositeContext generic_ctx;
GimpCompositeContext special_ctx;
double ft0;
double ft1;
gimp_rgba8_t *rgba8D1;
gimp_rgba8_t *rgba8D2;
gimp_rgba8_t *rgba8A;
gimp_rgba8_t *rgba8B;
gimp_rgba8_t *rgba8M;
gimp_va8_t *va8A;
gimp_va8_t *va8B;
gimp_va8_t *va8M;
gimp_va8_t *va8D1;
gimp_va8_t *va8D2;
int i;
if (gimp_composite_altivec_init () == 0)
{
g_print ("\ngimp_composite_altivec: Instruction set is not available.\n");
return EXIT_SUCCESS;
}
g_print ("\nRunning gimp_composite_altivec tests...\n");
rgba8A = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8B = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8M = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8D1 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
rgba8D2 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
va8A = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8B = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8M = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D1 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D2 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
for (i = 0; i < n_pixels; i++)
{
va8A[i].v = i;
va8A[i].a = 255-i;
va8B[i].v = i;
va8B[i].a = i;
va8M[i].v = i;
va8M[i].a = i;
}
#endif
return EXIT_SUCCESS;
}
int
main (int argc, char *argv[])
{
int iterations;
int n_pixels;
srand (314159);
g_setenv ("GIMP_COMPOSITE", "0x1", TRUE);
iterations = 10;
n_pixels = 8388625;
argv++, argc--;
while (argc >= 2)
{
if (argc > 1 && (strcmp (argv[0], "--iterations") == 0 || strcmp (argv[0], "-i") == 0))
{
iterations = atoi(argv[1]);
argc -= 2, argv++; argv++;
}
else if (argc > 1 && (strcmp (argv[0], "--n-pixels") == 0 || strcmp (argv[0], "-n") == 0))
{
n_pixels = atoi (argv[1]);
argc -= 2, argv++; argv++;
}
else
{
g_print ("Usage: gimp-composites-*-test [-i|--iterations n] [-n|--n-pixels n]");
return EXIT_FAILURE;
}
}
gimp_composite_generic_install ();
return (gimp_composite_altivec_test (iterations, n_pixels));
}

View File

@ -1,960 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 2005 Frederic Leroy <fredo@starox.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-altivec.h"
#ifdef COMPILE_ALTIVEC_IS_OKAY
#ifdef HAVE_ALTIVEC_H
#include <altivec.h>
#endif
/* Paper over differences between official gcc and Apple's weird gcc */
#ifdef HAVE_ALTIVEC_H
#define INIT_VECTOR(v...) {v}
#define CONST_BUFFER(b) (b)
#else
#define INIT_VECTOR(v...) (v)
#define CONST_BUFFER(b) ((guchar *)(b))
#endif
static const vector unsigned char alphamask = (const vector unsigned char)
INIT_VECTOR(0,0,0,0xff,0,0,0,0xff,0,0,0,0xff,0,0,0,0xff);
static const vector unsigned char combine_high_bytes = (const vector unsigned char)
INIT_VECTOR(0,16,2,18,4,20,6,22,8,24,10,26,12,28,14,30);
static const vector unsigned short ox0080 = (const vector unsigned short)
INIT_VECTOR(0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80);
static const vector unsigned short ox0008 = (const vector unsigned short)
INIT_VECTOR(0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8);
static const vector signed short ox00ff = (const vector signed short)
INIT_VECTOR(0x00ff,0x00ff,0x00ff,0x00ff,0x00ff,0x00ff,0x00ff,0x00ff);
static const vector signed short oxff80 = (const vector signed short)
INIT_VECTOR(0xff80,0xff80,0xff80,0xff80,0xff80,0xff80,0xff80,0xff80);
/* Load a vector from an unaligned location in memory */
static inline vector unsigned char
LoadUnaligned(const guchar *v)
{
if ((long)v & 0x0f)
{
vector unsigned char permuteVector = vec_lvsl(0, v);
vector unsigned char low = vec_ld(0, v);
vector unsigned char high = vec_ld(16, v);
return vec_perm(low, high, permuteVector);
}
else
return vec_ld(0, v); /* don't want overflow */
}
/* Load less than a vector from an unaligned location in memory */
static inline vector unsigned char
LoadUnalignedLess(const guchar *v,
int n)
{
vector unsigned char permuteVector = vec_lvsl(0, v);
if (((long)v&0x0f)+n > 15)
{
vector unsigned char low = vec_ld(0, v);
vector unsigned char high = vec_ld(16, v);
return vec_perm(low, high, permuteVector);
}
else
{
vector unsigned char tmp = vec_ld(0, v);
return vec_perm(tmp, tmp, permuteVector); /* don't want overflow */
}
}
/* Store a vector to an unaligned location in memory */
static inline void
StoreUnaligned (vector unsigned char v,
const guchar *where)
{
if ((unsigned long)where & 0x0f)
{
/* Load the surrounding area */
vector unsigned char low = vec_ld(0, where);
vector unsigned char high = vec_ld(16, where);
/* Prepare the constants that we need */
vector unsigned char permuteVector = vec_lvsr(0, where);
vector signed char oxFF = vec_splat_s8(-1);
vector signed char ox00 = vec_splat_s8(0);
/* Make a mask for which parts of the vectors to swap out */
vector unsigned char mask = (vector unsigned char)vec_perm(ox00, oxFF, permuteVector);
v = vec_perm(v, v, permuteVector);
/* Insert our data into the low and high vectors */
low = vec_sel(low, v, mask);
high = vec_sel(v, high, mask);
/* Store the two aligned result vectors */
vec_st(low, 0, CONST_BUFFER(where));
vec_st(high, 16, CONST_BUFFER(where));
}
else
{ /* prevent overflow */
vec_st(v, 0, CONST_BUFFER(where));
}
}
/* Store less than a vector to an unaligned location in memory */
static inline void
StoreUnalignedLess (vector unsigned char v,
const guchar *where,
int n)
{
int i;
vector unsigned char permuteVector = vec_lvsr(0, where);
v = vec_perm(v, v, permuteVector);
for (i=0; i<n; i++)
vec_ste(v, i, CONST_BUFFER(where));
}
void
gimp_composite_addition_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guchar *D = ctx->D;
guint length = ctx->n_pixels;
vector unsigned char a,b,d,alpha_a,alpha_b;
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
d=vec_min(alpha_a, alpha_b);
a=vec_andc(a, alphamask);
a=vec_adds(a, d);
b=vec_andc(b, alphamask);
d=vec_adds(a, b);
StoreUnaligned(d, D);
A+=16;
B+=16;
D+=16;
length-=4;
}
/* process last pixels */
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
alpha_a=vec_and(a,alphamask);
alpha_b=vec_and(b,alphamask);
d=vec_min(alpha_a,alpha_b);
a=vec_andc(a,alphamask);
a=vec_adds(a,d);
b=vec_andc(b,alphamask);
d=vec_adds(a,b);
StoreUnalignedLess(d, D, length);
}
void
gimp_composite_subtract_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guchar *D = ctx->D;
guint length = ctx->n_pixels;
vector unsigned char a,b,d,alpha_a,alpha_b;
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
d=vec_min(alpha_a, alpha_b);
a=vec_andc(a, alphamask);
a=vec_adds(a, d);
b=vec_andc(b, alphamask);
d=vec_subs(a, b);
StoreUnaligned(d, D);
A+=16;
B+=16;
D+=16;
length-=4;
}
/* process last pixels */
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
alpha_a=vec_and(a,alphamask);
alpha_b=vec_and(b,alphamask);
d=vec_min(alpha_a,alpha_b);
a=vec_andc(a,alphamask);
a=vec_adds(a,d);
b=vec_andc(b,alphamask);
d=vec_subs(a,b);
StoreUnalignedLess(d, D, length);
}
void
gimp_composite_swap_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guint length = ctx->n_pixels;
vector unsigned char a,b;
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
StoreUnaligned(b, A);
StoreUnaligned(a, B);
A+=16;
B+=16;
length-=4;
}
/* process last pixels */
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
StoreUnalignedLess(a, B, length);
StoreUnalignedLess(b, A, length);
}
void
gimp_composite_difference_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guchar *D = ctx->D;
guint length = ctx->n_pixels;
vector unsigned char a,b,d,e,alpha_a,alpha_b;
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
d=vec_min(alpha_a, alpha_b);
a=vec_andc(a, alphamask);
a=vec_adds(a, d);
b=vec_andc(b, alphamask);
d=vec_subs(a, b);
e=vec_subs(b, a);
d=vec_add(d,e);
StoreUnaligned(d, D);
A+=16;
B+=16;
D+=16;
length-=4;
}
/* process last pixels */
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
alpha_a=vec_and(a,alphamask);
alpha_b=vec_and(b,alphamask);
d=vec_min(alpha_a,alpha_b);
a=vec_andc(a,alphamask);
a=vec_adds(a,d);
b=vec_andc(b,alphamask);
d=vec_subs(a,b);
e=vec_subs(b, a);
d=vec_add(d,e);
StoreUnalignedLess(d, D, length);
}
void
gimp_composite_darken_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guchar *D = ctx->D;
guint length = ctx->n_pixels;
vector unsigned char a,b,d;
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
d=vec_min(a, b);
StoreUnaligned(d, D);
A+=16;
B+=16;
D+=16;
length-=4;
}
/* process last pixels */
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
d=vec_min(a, b);
StoreUnalignedLess(d, D, length);
}
void
gimp_composite_lighten_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guchar *D = ctx->D;
guint length = ctx->n_pixels;
vector unsigned char a,b,d,alpha_a,alpha_b;
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
d=vec_min(alpha_a, alpha_b);
a=vec_andc(a, alphamask);
a=vec_adds(a, d);
b=vec_andc(b, alphamask);
d=vec_max(a, b);
StoreUnaligned(d, D);
A+=16;
B+=16;
D+=16;
length-=4;
}
/* process last pixels */
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
alpha_a=vec_and(a,alphamask);
alpha_b=vec_and(b,alphamask);
d=vec_min(alpha_a,alpha_b);
a=vec_andc(a,alphamask);
a=vec_adds(a,d);
b=vec_andc(b,alphamask);
d=vec_max(a, b);
StoreUnalignedLess(d, D, length);
}
void
gimp_composite_multiply_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guchar *D = ctx->D;
guint length = ctx->n_pixels;
vector unsigned char a,b,d,alpha_a,alpha_b,alpha;
vector unsigned short al,ah;
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
al=vec_mule(a,b);
al=vec_add(al,ox0080);
ah=vec_mulo(a,b);
ah=vec_add(ah,ox0080);
al=vec_add(al,vec_sr(al,ox0008));
ah=vec_add(ah,vec_sr(ah,ox0008));
d=vec_perm((vector unsigned char)al,(vector unsigned char)ah,combine_high_bytes);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
alpha=vec_min(alpha_a, alpha_b);
d=vec_andc(d, alphamask);
d=vec_or(d, alpha);
StoreUnaligned(d, D);
A+=16;
B+=16;
D+=16;
length-=4;
}
/* process last pixels */
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
al=vec_mule(a,b);
al=vec_add(al,ox0080);
ah=vec_mulo(a,b);
ah=vec_add(ah,ox0080);
al=vec_add(al,vec_sr(al,ox0008));
ah=vec_add(ah,vec_sr(ah,ox0008));
d=vec_perm((vector unsigned char)al,(vector unsigned char)ah,combine_high_bytes);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
alpha=vec_min(alpha_a, alpha_b);
d=vec_andc(d, alphamask);
d=vec_or(d, alpha);
StoreUnalignedLess(d, D, length);
}
void
gimp_composite_blend_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guchar *D = ctx->D;
guint length = ctx->n_pixels;
guchar blend = ctx->blend.blend;
union
{
vector unsigned char v;
unsigned char u8[16];
} vblend;
vector unsigned char vblendc;
vector unsigned char a,b,d;
vector unsigned short al,ah,bl,bh,one=vec_splat_u16(1);
guchar tmp;
for (tmp=0; tmp<16; tmp++ )
vblend.u8[tmp]=blend;
vblendc=vec_nor(vblend.v,vblend.v);
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
/* dest[b] = (src1[b] * blend2 + src2[b] * blend) / 255;
* to divide by 255 we use ((n+1)+(n+1)>>8)>>8
* It works for all value but 0xffff
* happily blending formula can't give this value */
al=vec_mule(a,vblendc);
ah=vec_mulo(a,vblendc);
bl=vec_mule(b,vblend.v);
bh=vec_mulo(b,vblend.v);
al=vec_add(al,bl);
al=vec_add(al,one);
al=vec_add(al,vec_sr(al,ox0008));
ah=vec_add(ah,bh);
ah=vec_add(ah,one);
ah=vec_add(ah,vec_sr(ah,ox0008));
d=vec_perm((vector unsigned char)al,(vector unsigned char)ah,combine_high_bytes);
StoreUnaligned(d, D);
A+=16;
B+=16;
D+=16;
length-=4;
}
/* process last pixels */
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
al=vec_mule(a,vblendc);
ah=vec_mulo(a,vblendc);
bl=vec_mule(b,vblend.v);
bh=vec_mulo(b,vblend.v);
al=vec_add(al,bl);
al=vec_add(al,one);
al=vec_add(al,vec_sr(al,ox0008));
ah=vec_add(ah,bh);
ah=vec_add(ah,one);
ah=vec_add(ah,vec_sr(ah,ox0008));
d=vec_perm((vector unsigned char)al,(vector unsigned char)ah,combine_high_bytes);
StoreUnalignedLess(d, D, length);
}
void
gimp_composite_screen_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guchar *D = ctx->D;
guint length = ctx->n_pixels;
vector unsigned char a,b,d,alpha_a,alpha_b,alpha;
vector unsigned short ah,al;
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
alpha=vec_min(alpha_a, alpha_b);
a=vec_nor(a,a);
b=vec_nor(b,b);
al=vec_mule(a,b);
al=vec_add(al,ox0080);
ah=vec_mulo(a,b);
ah=vec_add(ah,ox0080);
al=vec_add(al,vec_sr(al,ox0008));
ah=vec_add(ah,vec_sr(ah,ox0008));
d=vec_perm((vector unsigned char)al,(vector unsigned char)ah,combine_high_bytes);
d=vec_nor(d,d);
d=vec_andc(d, alphamask);
d=vec_or(d, alpha);
StoreUnaligned(d, D);
A+=16;
B+=16;
D+=16;
length-=4;
}
/* process last pixels */
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
alpha=vec_min(alpha_a, alpha_b);
a=vec_nor(a,a);
b=vec_nor(b,b);
al=vec_mule(a,b);
al=vec_add(al,ox0080);
ah=vec_mulo(a,b);
ah=vec_add(ah,ox0080);
al=vec_add(al,vec_sr(al,ox0008));
ah=vec_add(ah,vec_sr(ah,ox0008));
d=vec_perm((vector unsigned char)al,(vector unsigned char)ah,combine_high_bytes);
d=vec_nor(d,d);
d=vec_andc(d, alphamask);
d=vec_or(d, alpha);
StoreUnalignedLess(d, D, length);
}
void
gimp_composite_grain_merge_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guchar *D = ctx->D;
guint length = ctx->n_pixels;
vector unsigned char a,b,d,alpha_a,alpha_b,alpha;
vector signed short ah,al,bh,bl;
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
alpha=vec_min(alpha_a, alpha_b);
ah=vec_unpackh((vector signed char)a);
ah=vec_and(ah,ox00ff);
al=vec_unpackl((vector signed char)a);
al=vec_and(al,ox00ff);
bh=vec_unpackh((vector signed char)b);
bh=vec_and(bh,ox00ff);
bl=vec_unpackl((vector signed char)b);
bl=vec_and(bl,ox00ff);
ah=vec_add(ah,bh);
al=vec_add(al,bl);
ah=vec_add(ah,oxff80);
al=vec_add(al,oxff80);
d=vec_packsu(ah,al);
d=vec_andc(d, alphamask);
d=vec_or(d, alpha);
StoreUnaligned(d, D);
A+=16;
B+=16;
D+=16;
length-=4;
}
/* process last pixels */
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
alpha=vec_min(alpha_a, alpha_b);
ah=vec_unpackh((vector signed char)a);
ah=vec_and(ah,ox00ff);
al=vec_unpackl((vector signed char)a);
al=vec_and(al,ox00ff);
bh=vec_unpackh((vector signed char)b);
bh=vec_and(bh,ox00ff);
bl=vec_unpackl((vector signed char)b);
bl=vec_and(bl,ox00ff);
ah=vec_add(ah,bh);
al=vec_add(al,bl);
ah=vec_add(ah,oxff80);
al=vec_add(al,oxff80);
d=vec_packsu(ah,al);
d=vec_andc(d, alphamask);
d=vec_or(d, alpha);
StoreUnalignedLess(d, D, length);
}
void
gimp_composite_grain_extract_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guchar *D = ctx->D;
guint length = ctx->n_pixels;
vector unsigned char a,b,d,alpha_a,alpha_b,alpha;
vector signed short ah,al,bh,bl;
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
alpha=vec_min(alpha_a, alpha_b);
ah=vec_unpackh((vector signed char)a);
ah=vec_and(ah,ox00ff);
al=vec_unpackl((vector signed char)a);
al=vec_and(al,ox00ff);
bh=vec_unpackh((vector signed char)b);
bh=vec_and(bh,ox00ff);
bl=vec_unpackl((vector signed char)b);
bl=vec_and(bl,ox00ff);
ah=vec_sub(ah,bh);
al=vec_sub(al,bl);
ah=vec_sub(ah,oxff80);
al=vec_sub(al,oxff80);
d=vec_packsu(ah,al);
d=vec_andc(d, alphamask);
d=vec_or(d, alpha);
StoreUnaligned(d, D);
A+=16;
B+=16;
D+=16;
length-=4;
}
/* process last pixels */
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
alpha=vec_min(alpha_a, alpha_b);
ah=vec_unpackh((vector signed char)a);
ah=vec_and(ah,ox00ff);
al=vec_unpackl((vector signed char)a);
al=vec_and(al,ox00ff);
bh=vec_unpackh((vector signed char)b);
bh=vec_and(bh,ox00ff);
bl=vec_unpackl((vector signed char)b);
bl=vec_and(bl,ox00ff);
ah=vec_sub(ah,bh);
al=vec_sub(al,bl);
ah=vec_sub(ah,oxff80);
al=vec_sub(al,oxff80);
d=vec_packsu(ah,al);
d=vec_andc(d, alphamask);
d=vec_or(d, alpha);
StoreUnalignedLess(d, D, length);
}
void
gimp_composite_divide_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guchar *D = ctx->D;
guint length = ctx->n_pixels;
vector unsigned char a,b,d;
vector unsigned char alpha_a,alpha_b,alpha;
vector signed short ox0001=vec_splat_s16(1);
union
{
vector signed short v;
vector unsigned short vu;
gushort u16[8];
} ah,al,bh,bl;
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
alpha=vec_min(alpha_a, alpha_b);
ah.v=vec_unpackh((vector signed char)a);
ah.v=vec_sl(ah.v,ox0008);
al.v=vec_unpackl((vector signed char)a);
al.v=vec_sl(al.v,ox0008);
bh.v=vec_unpackh((vector signed char)b);
bh.v=vec_and(bh.v,ox00ff);
bh.v=vec_add(bh.v,ox0001);
bl.v=vec_unpackl((vector signed char)b);
bl.v=vec_and(bl.v,ox00ff);
bl.v=vec_add(bl.v,ox0001);
ah.u16[0]=ah.u16[0]/bh.u16[0];
ah.u16[1]=ah.u16[1]/bh.u16[1];
ah.u16[2]=ah.u16[2]/bh.u16[2];
ah.u16[4]=ah.u16[4]/bh.u16[4];
ah.u16[5]=ah.u16[5]/bh.u16[5];
ah.u16[6]=ah.u16[6]/bh.u16[6];
al.u16[0]=al.u16[0]/bl.u16[0];
al.u16[1]=al.u16[1]/bl.u16[1];
al.u16[2]=al.u16[2]/bl.u16[2];
al.u16[4]=al.u16[4]/bl.u16[4];
al.u16[5]=al.u16[5]/bl.u16[5];
al.u16[6]=al.u16[6]/bl.u16[6];
d=vec_packs(ah.vu,al.vu);
d=vec_andc(d, alphamask);
d=vec_or(d, alpha);
StoreUnaligned(d, D);
A+=16;
B+=16;
D+=16;
length-=4;
}
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
alpha=vec_min(alpha_a, alpha_b);
ah.v=vec_unpackh((vector signed char)a);
ah.v=vec_sl(ah.v,ox0008);
al.v=vec_unpackl((vector signed char)a);
al.v=vec_sl(al.v,ox0008);
bh.v=vec_unpackh((vector signed char)b);
bh.v=vec_and(bh.v,ox00ff);
bh.v=vec_add(bh.v,ox0001);
bl.v=vec_unpackl((vector signed char)b);
bl.v=vec_and(bl.v,ox00ff);
bl.v=vec_add(bl.v,ox0001);
ah.u16[0]=ah.u16[0]/bh.u16[0];
ah.u16[1]=ah.u16[1]/bh.u16[1];
ah.u16[2]=ah.u16[2]/bh.u16[2];
ah.u16[4]=ah.u16[4]/bh.u16[4];
ah.u16[5]=ah.u16[5]/bh.u16[5];
ah.u16[6]=ah.u16[6]/bh.u16[6];
al.u16[0]=al.u16[0]/bl.u16[0];
al.u16[1]=al.u16[1]/bl.u16[1];
al.u16[2]=al.u16[2]/bl.u16[2];
al.u16[4]=al.u16[4]/bl.u16[4];
al.u16[5]=al.u16[5]/bl.u16[5];
al.u16[6]=al.u16[6]/bl.u16[6];
d=vec_packs(ah.vu,al.vu);
d=vec_andc(d, alphamask);
d=vec_or(d, alpha);
StoreUnalignedLess(d, D, length);
}
void
gimp_composite_dodge_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx)
{
const guchar *A = ctx->A;
const guchar *B = ctx->B;
guchar *D = ctx->D;
guint length = ctx->n_pixels;
vector unsigned char a,b,d;
vector unsigned char alpha_a,alpha_b,alpha;
vector signed short ox0001=vec_splat_s16(1);
union
{
vector signed short v;
vector unsigned short vu;
gushort u16[8];
} ah,al,bh,bl;
while (length >= 4)
{
a=LoadUnaligned(A);
b=LoadUnaligned(B);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
alpha=vec_min(alpha_a, alpha_b);
ah.v=vec_unpackh((vector signed char)a);
ah.v=vec_sl(ah.v,ox0008);
al.v=vec_unpackl((vector signed char)a);
al.v=vec_sl(al.v,ox0008);
b=vec_nor(b,b);
bh.v=vec_unpackh((vector signed char)b);
bh.v=vec_and(bh.v,ox00ff);
bh.v=vec_add(bh.v,ox0001);
bl.v=vec_unpackl((vector signed char)b);
bl.v=vec_and(bl.v,ox00ff);
bl.v=vec_add(bl.v,ox0001);
ah.u16[0]=ah.u16[0]/bh.u16[0];
ah.u16[1]=ah.u16[1]/bh.u16[1];
ah.u16[2]=ah.u16[2]/bh.u16[2];
ah.u16[4]=ah.u16[4]/bh.u16[4];
ah.u16[5]=ah.u16[5]/bh.u16[5];
ah.u16[6]=ah.u16[6]/bh.u16[6];
al.u16[0]=al.u16[0]/bl.u16[0];
al.u16[1]=al.u16[1]/bl.u16[1];
al.u16[2]=al.u16[2]/bl.u16[2];
al.u16[4]=al.u16[4]/bl.u16[4];
al.u16[5]=al.u16[5]/bl.u16[5];
al.u16[6]=al.u16[6]/bl.u16[6];
d=vec_packs(ah.vu,al.vu);
d=vec_andc(d, alphamask);
d=vec_or(d, alpha);
StoreUnaligned(d, D);
A+=16;
B+=16;
D+=16;
length-=4;
}
length = length*4;
a=LoadUnalignedLess(A, length);
b=LoadUnalignedLess(B, length);
alpha_a=vec_and(a, alphamask);
alpha_b=vec_and(b, alphamask);
alpha=vec_min(alpha_a, alpha_b);
ah.v=vec_unpackh((vector signed char)a);
ah.v=vec_sl(ah.v,ox0008);
al.v=vec_unpackl((vector signed char)a);
al.v=vec_sl(al.v,ox0008);
b=vec_nor(b,b);
bh.v=vec_unpackh((vector signed char)b);
bh.v=vec_and(bh.v,ox00ff);
bh.v=vec_add(bh.v,ox0001);
bl.v=vec_unpackl((vector signed char)b);
bl.v=vec_and(bl.v,ox00ff);
bl.v=vec_add(bl.v,ox0001);
ah.u16[0]=ah.u16[0]/bh.u16[0];
ah.u16[1]=ah.u16[1]/bh.u16[1];
ah.u16[2]=ah.u16[2]/bh.u16[2];
ah.u16[4]=ah.u16[4]/bh.u16[4];
ah.u16[5]=ah.u16[5]/bh.u16[5];
ah.u16[6]=ah.u16[6]/bh.u16[6];
al.u16[0]=al.u16[0]/bl.u16[0];
al.u16[1]=al.u16[1]/bl.u16[1];
al.u16[2]=al.u16[2]/bl.u16[2];
al.u16[4]=al.u16[4]/bl.u16[4];
al.u16[5]=al.u16[5]/bl.u16[5];
al.u16[6]=al.u16[6]/bl.u16[6];
d=vec_packs(ah.vu,al.vu);
d=vec_andc(d, alphamask);
d=vec_or(d, alpha);
StoreUnalignedLess(d, D, length);
}
#endif /* COMPILE_IS_OKAY */

View File

@ -1,37 +0,0 @@
#ifndef gimp_composite_altivec_h
#define gimp_composite_altivec_h
extern gboolean gimp_composite_altivec_init (void);
/*
* The function gimp_composite_*_install() is defined in the code generated by make-install.py
* I hate to create a .h file just for that declaration, so I do it here (for now).
*/
extern gboolean gimp_composite_altivec_install (void);
#if defined(USE_ALTIVEC)
#if defined(ARCH_PPC)
#if __GNUC__ >= 3
#define COMPILE_ALTIVEC_IS_OKAY (1)
#endif /* __GNUC__ >= 3 */
#endif /* defined(ARCH_PPC) */
#endif /* defined(USE_ALTIVEC) */
#ifdef COMPILE_ALTIVEC_IS_OKAY
extern void gimp_composite_addition_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
extern void gimp_composite_subtract_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
extern void gimp_composite_swap_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
extern void gimp_composite_difference_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
extern void gimp_composite_darken_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
extern void gimp_composite_lighten_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
extern void gimp_composite_multiply_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
extern void gimp_composite_blend_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
extern void gimp_composite_screen_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
extern void gimp_composite_grain_merge_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
extern void gimp_composite_grain_extract_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
extern void gimp_composite_divide_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
extern void gimp_composite_dodge_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx);
#endif /* COMPILE_IS_OKAY */
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,46 +0,0 @@
#ifndef gimp_composite_generic_h
#define gimp_composite_generic_h
extern gboolean gimp_composite_generic_init (void);
/*
* The function gimp_composite_*_install() is defined in the code
* generated by make-install.py I hate to create a .h file just for
* that declaration, so I do it here (for now).
*/
extern gboolean gimp_composite_generic_install (void);
void gimp_composite_addition_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_anti_erase_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_blend_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_burn_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_color_any_any_any_generic (guchar *dest,
const guchar *color,
guint w,
guint bytes);
void gimp_composite_color_erase_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_color_only_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_convert_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_darken_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_difference_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_dissolve_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_divide_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_dodge_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_erase_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_grain_extract_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_grain_merge_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_hardlight_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_hue_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_lighten_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_multiply_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_normal_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_overlay_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_replace_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_saturation_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_scale_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_screen_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_softlight_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_subtract_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_swap_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_value_any_any_any_generic (GimpCompositeContext *ctx);
void gimp_composite_behind_any_any_any_generic (GimpCompositeContext *ctx);
#endif

View File

@ -1,66 +0,0 @@
/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */
/* REGENERATE BY USING make-installer.py */
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-mmx.h"
static const struct install_table {
GimpCompositeOperation mode;
GimpPixelFormat A;
GimpPixelFormat B;
GimpPixelFormat D;
void (*function)(GimpCompositeContext *);
} _gimp_composite_mmx[] = {
#if defined(COMPILE_MMX_IS_OKAY)
{ GIMP_COMPOSITE_MULTIPLY, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_multiply_rgba8_rgba8_rgba8_mmx },
{ GIMP_COMPOSITE_SCREEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_screen_rgba8_rgba8_rgba8_mmx },
{ GIMP_COMPOSITE_DIFFERENCE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_difference_rgba8_rgba8_rgba8_mmx },
{ GIMP_COMPOSITE_ADDITION, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, gimp_composite_addition_va8_va8_va8_mmx },
{ GIMP_COMPOSITE_ADDITION, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_addition_rgba8_rgba8_rgba8_mmx },
{ GIMP_COMPOSITE_SUBTRACT, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, gimp_composite_subtract_va8_va8_va8_mmx },
{ GIMP_COMPOSITE_SUBTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_subtract_rgba8_rgba8_rgba8_mmx },
{ GIMP_COMPOSITE_DARKEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_darken_rgba8_rgba8_rgba8_mmx },
{ GIMP_COMPOSITE_LIGHTEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_lighten_rgba8_rgba8_rgba8_mmx },
{ GIMP_COMPOSITE_GRAIN_EXTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_grain_extract_rgba8_rgba8_rgba8_mmx },
{ GIMP_COMPOSITE_GRAIN_MERGE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_grain_merge_rgba8_rgba8_rgba8_mmx },
{ GIMP_COMPOSITE_SWAP, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_swap_rgba8_rgba8_rgba8_mmx },
{ GIMP_COMPOSITE_SCALE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_scale_rgba8_rgba8_rgba8_mmx },
#endif
{ 0, 0, 0, 0, NULL }
};
gboolean
gimp_composite_mmx_install (void)
{
static const struct install_table *t = _gimp_composite_mmx;
if (gimp_composite_mmx_init ())
{
for (t = &_gimp_composite_mmx[0]; t->function != NULL; t++)
{
gimp_composite_function[t->mode][t->A][t->B][t->D] = t->function;
}
return (TRUE);
}
return (FALSE);
}
gboolean
gimp_composite_mmx_init (void)
{
#if defined(COMPILE_MMX_IS_OKAY)
if (gimp_cpu_accel_get_support () & GIMP_CPU_ACCEL_X86_MMX)
{
return (TRUE);
}
#endif
return (FALSE);
}

View File

@ -1,249 +0,0 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-regression.h"
#include "gimp-composite-util.h"
#include "gimp-composite-generic.h"
#include "gimp-composite-mmx.h"
static int
gimp_composite_mmx_test (int iterations, int n_pixels)
{
#if defined(COMPILE_MMX_IS_OKAY)
GimpCompositeContext generic_ctx;
GimpCompositeContext special_ctx;
double ft0;
double ft1;
gimp_rgba8_t *rgba8D1;
gimp_rgba8_t *rgba8D2;
gimp_rgba8_t *rgba8A;
gimp_rgba8_t *rgba8B;
gimp_rgba8_t *rgba8M;
gimp_va8_t *va8A;
gimp_va8_t *va8B;
gimp_va8_t *va8M;
gimp_va8_t *va8D1;
gimp_va8_t *va8D2;
int i;
if (gimp_composite_mmx_init () == 0)
{
g_print ("\ngimp_composite_mmx: Instruction set is not available.\n");
return EXIT_SUCCESS;
}
g_print ("\nRunning gimp_composite_mmx tests...\n");
rgba8A = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8B = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8M = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8D1 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
rgba8D2 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
va8A = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8B = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8M = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D1 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D2 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
for (i = 0; i < n_pixels; i++)
{
va8A[i].v = i;
va8A[i].a = 255-i;
va8B[i].v = i;
va8B[i].a = i;
va8M[i].v = i;
va8M[i].a = i;
}
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_ADDITION, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, n_pixels, (unsigned char *) va8A, (unsigned char *) va8B, (unsigned char *) va8B, (unsigned char *) va8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_ADDITION, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, n_pixels, (unsigned char *) va8A, (unsigned char *) va8B, (unsigned char *) va8B, (unsigned char *) va8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_addition_va8_va8_va8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("addition", &generic_ctx, &special_ctx))
{
g_print ("addition_va8_va8_va8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("addition_va8_va8_va8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_ADDITION, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_ADDITION, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_addition_rgba8_rgba8_rgba8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("addition", &generic_ctx, &special_ctx))
{
g_print ("addition_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("addition_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_DARKEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_DARKEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_darken_rgba8_rgba8_rgba8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("darken", &generic_ctx, &special_ctx))
{
g_print ("darken_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("darken_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_DIFFERENCE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_DIFFERENCE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_difference_rgba8_rgba8_rgba8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("difference", &generic_ctx, &special_ctx))
{
g_print ("difference_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("difference_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_GRAIN_EXTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_GRAIN_EXTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_grain_extract_rgba8_rgba8_rgba8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("grain_extract", &generic_ctx, &special_ctx))
{
g_print ("grain_extract_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("grain_extract_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_GRAIN_MERGE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_GRAIN_MERGE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_grain_merge_rgba8_rgba8_rgba8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("grain_merge", &generic_ctx, &special_ctx))
{
g_print ("grain_merge_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("grain_merge_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_LIGHTEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_LIGHTEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_lighten_rgba8_rgba8_rgba8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("lighten", &generic_ctx, &special_ctx))
{
g_print ("lighten_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("lighten_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_MULTIPLY, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_MULTIPLY, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_multiply_rgba8_rgba8_rgba8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("multiply", &generic_ctx, &special_ctx))
{
g_print ("multiply_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("multiply_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_SCALE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_SCALE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_scale_rgba8_rgba8_rgba8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("scale", &generic_ctx, &special_ctx))
{
g_print ("scale_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("scale_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_SCREEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_SCREEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_screen_rgba8_rgba8_rgba8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("screen", &generic_ctx, &special_ctx))
{
g_print ("screen_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("screen_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_SUBTRACT, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, n_pixels, (unsigned char *) va8A, (unsigned char *) va8B, (unsigned char *) va8B, (unsigned char *) va8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_SUBTRACT, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, GIMP_PIXELFORMAT_VA8, n_pixels, (unsigned char *) va8A, (unsigned char *) va8B, (unsigned char *) va8B, (unsigned char *) va8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_subtract_va8_va8_va8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("subtract", &generic_ctx, &special_ctx))
{
g_print ("subtract_va8_va8_va8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("subtract_va8_va8_va8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_SUBTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_SUBTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_subtract_rgba8_rgba8_rgba8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("subtract", &generic_ctx, &special_ctx))
{
g_print ("subtract_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("subtract_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_SWAP, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_SWAP, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_swap_rgba8_rgba8_rgba8_mmx, &special_ctx);
if (gimp_composite_regression_compare_contexts ("swap", &generic_ctx, &special_ctx))
{
g_print ("swap_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("swap_rgba8_rgba8_rgba8", ft0, ft1);
#endif
return EXIT_SUCCESS;
}
int
main (int argc, char *argv[])
{
int iterations;
int n_pixels;
srand (314159);
g_setenv ("GIMP_COMPOSITE", "0x1", TRUE);
iterations = 10;
n_pixels = 8388625;
argv++, argc--;
while (argc >= 2)
{
if (argc > 1 && (strcmp (argv[0], "--iterations") == 0 || strcmp (argv[0], "-i") == 0))
{
iterations = atoi(argv[1]);
argc -= 2, argv++; argv++;
}
else if (argc > 1 && (strcmp (argv[0], "--n-pixels") == 0 || strcmp (argv[0], "-n") == 0))
{
n_pixels = atoi (argv[1]);
argc -= 2, argv++; argv++;
}
else
{
g_print ("Usage: gimp-composites-*-test [-i|--iterations n] [-n|--n-pixels n]");
return EXIT_FAILURE;
}
}
gimp_composite_generic_install ();
return (gimp_composite_mmx_test (iterations, n_pixels));
}

File diff suppressed because it is too large Load Diff

View File

@ -1,63 +0,0 @@
#ifndef gimp_composite_mmx_h
#define gimp_composite_mmx_h
extern gboolean gimp_composite_mmx_init (void);
/*
* The function gimp_composite_*_install() is defined in the code
* generated by make-install.py I hate to have make-install.py create
* a .h file just for that declaration, so I do it here.
*/
extern gboolean gimp_composite_mmx_install (void);
/*
* Rummage through the compile-time environment to ensure this file
* can actually be compiled like we expect it to. If all is okay,
* define the manifest constant COMPILE_MMX_IS_OKAY.
*/
#if !defined(__INTEL_COMPILER) || defined(USE_INTEL_COMPILER_ANYWAY)
#if defined(USE_MMX)
#if defined(ARCH_X86)
#if __GNUC__ >= 3
#if defined(ARCH_X86_64) || (!defined(PIC) && !defined(__PIC__))
#define COMPILE_MMX_IS_OKAY (1)
#endif /* defined(ARCH_X86_64) || (!defined(PIC) && !defined(__PIC__)) */
#endif /* __GNUC__ >= 3 */
#endif /* defined(ARCH_X86) */
#endif /* defined(USE_MMX) */
#endif /* !defined(__INTEL_COMPILER) */
#ifdef COMPILE_MMX_IS_OKAY
/*
*
*/
extern void gimp_composite_addition_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_burn_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_coloronly_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_darken_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_difference_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_dissolve_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_divide_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_dodge_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_grain_extract_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_grain_merge_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_hardlight_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_hueonly_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_lighten_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_multiply_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_overlay_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_replace_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_saturationonly_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_scale_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_screen_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_softlight_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_subtract_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_swap_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_valueonly_rgba8_rgba8_rgba8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_addition_va8_va8_va8_mmx (GimpCompositeContext *ctx);
extern void gimp_composite_subtract_va8_va8_va8_mmx (GimpCompositeContext *ctx);
/*extern void gimp_composite_multiply_va8_va8_va8_mmx (GimpCompositeContext *ctx);*/
#endif /* COMPILE_IS_OKAY */
#endif

View File

@ -1,559 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Gimp image compositing
* Copyright (C) 2003 Helvetix Victorinox, a pseudonym, <helvetix@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#ifndef timersub
/*
* Linux <sys/time.h> has a handy macro for finding the difference between
* two timers. This is lifted directly from <sys/time.h> on a GLIBC 2.2.x
* system.
*/
#define timersub(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
if ((result)->tv_usec < 0) \
{ \
--(result)->tv_sec; \
(result)->tv_usec += 1000000; \
} \
} while (0)
#endif
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-regression.h"
#include "gimp-composite-util.h"
#include "gimp-composite-generic.h"
/**
* gimp_composite_regression_print_vector:
* @vector:
* @format:
* @n_pixels:
*
*
**/
void
gimp_composite_regression_print_vector (guchar vector[], GimpPixelFormat format, gulong n_pixels)
{
switch (format)
{
case GIMP_PIXELFORMAT_V8:
gimp_composite_regression_print_vector_v8 ((gimp_v8_t *) vector, n_pixels);
break;
case GIMP_PIXELFORMAT_VA8:
gimp_composite_regression_print_vector_va8 ((gimp_va8_t *) vector, n_pixels);
break;
case GIMP_PIXELFORMAT_RGB8:
gimp_composite_regression_print_vector_rgb8 ((gimp_rgb8_t *) vector, n_pixels);
break;
case GIMP_PIXELFORMAT_RGBA8:
gimp_composite_regression_print_vector_rgba8 ((gimp_rgba8_t *) vector, n_pixels);
break;
case GIMP_PIXELFORMAT_ANY:
case GIMP_PIXELFORMAT_N:
default:
break;
}
}
/**
* gimp_composite_regression_print_vector_v8:
* @v:
* @n_pixels:
*
*
**/
void
gimp_composite_regression_print_vector_v8 (gimp_v8_t v[], unsigned int n_pixels)
{
unsigned int i;
for (i = 0; i < n_pixels; i++)
{
g_print ("#%02x\n", v[i].v);
}
}
/**
* gimp_composite_regression_print_vector_va8:
* @v:
* @n_pixels:
*
*
**/
void
gimp_composite_regression_print_vector_va8 (gimp_va8_t v[], unsigned int n_pixels)
{
unsigned int i;
for (i = 0; i < n_pixels; i++)
{
g_print ("#%02x,%02X\n", v[i].v, v[i].a);
}
}
/**
* gimp_composite_regression_print_vector_rgb8:
* @rgb8:
* @n_pixels:
*
*
**/
void
gimp_composite_regression_print_vector_rgb8 (gimp_rgb8_t v[], unsigned int n_pixels)
{
unsigned int i;
for (i = 0; i < n_pixels; i++)
{
g_print ("#%02x%02x%02x\n", v[i].r, v[i].g, v[i].b);
}
}
/**
* gimp_composite_regression_print_vector_rgba8:
* @v:
* @n_pixels:
*
*
**/
void
gimp_composite_regression_print_vector_rgba8 (gimp_rgba8_t v[], unsigned int n_pixels)
{
unsigned int i;
for (i = 0; i < n_pixels; i++)
{
g_print ("#%02x%02x%02x,%02X\n", v[i].r, v[i].g, v[i].b, v[i].a);
}
}
/**
* gimp_composite_regression_print_rgba8:
* @rgba8:
*
*
**/
void
gimp_composite_regression_print_rgba8 (gimp_rgba8_t *rgba8)
{
g_print ("#%02x%02x%02x,%02X", rgba8->r, rgba8->g, rgba8->b, rgba8->a);
}
/**
* gimp_composite_regression_print_va8:
* @va8:
*
*
**/
void
gimp_composite_regression_print_va8 (gimp_va8_t *va8)
{
g_print ("#%02x,%02X", va8->v, va8->a);
}
/**
* gimp_composite_regression_compare_contexts:
* @operation:
* @ctx1:
* @ctx2:
*
*
*
* Return value:
**/
int
gimp_composite_regression_compare_contexts (char *operation, GimpCompositeContext *ctx1, GimpCompositeContext *ctx2)
{
switch (ctx1->pixelformat_D) {
case GIMP_PIXELFORMAT_ANY:
case GIMP_PIXELFORMAT_N:
default:
g_print("Bad pixelformat! %d\n", ctx1->pixelformat_A);
exit(1);
break;
case GIMP_PIXELFORMAT_V8:
if (memcmp(ctx1->D, ctx2->D, ctx1->n_pixels * gimp_composite_pixel_bpp[ctx1->pixelformat_D])) {
g_print("%s: failed to agree\n", operation);
return (1);
}
break;
case GIMP_PIXELFORMAT_VA8:
if (memcmp(ctx1->D, ctx2->D, ctx1->n_pixels * gimp_composite_pixel_bpp[ctx1->pixelformat_D])) {
g_print("%s: failed to agree\n", operation);
return (1);
}
break;
case GIMP_PIXELFORMAT_RGB8:
if (memcmp(ctx1->D, ctx2->D, ctx1->n_pixels * gimp_composite_pixel_bpp[ctx1->pixelformat_D])) {
g_print("%s: failed to agree\n", operation);
return (1);
}
break;
case GIMP_PIXELFORMAT_RGBA8:
gimp_composite_regression_comp_rgba8(operation, (gimp_rgba8_t *) ctx1->A, (gimp_rgba8_t *) ctx1->B, (gimp_rgba8_t *) ctx1->D, (gimp_rgba8_t *) ctx2->D, ctx1->n_pixels);
break;
#if GIMP_COMPOSITE_16BIT
case GIMP_PIXELFORMAT_V16:
if (memcmp(ctx1->D, ctx2->D, ctx1->n_pixels * gimp_composite_pixel_bpp[ctx1->pixelformat_D])) {
g_print("%s: failed to agree\n", operation);
return (1);
}
break;
case GIMP_PIXELFORMAT_VA16:
if (memcmp(ctx1->D, ctx2->D, ctx1->n_pixels * gimp_composite_pixel_bpp[ctx1->pixelformat_D])) {
g_print("%s: failed to agree\n", operation);
return (1);
}
break;
case GIMP_PIXELFORMAT_RGB16:
if (memcmp(ctx1->D, ctx2->D, ctx1->n_pixels * gimp_composite_pixel_bpp[ctx1->pixelformat_D])) {
g_print("%s: failed to agree\n", operation);
return (1);
}
break;
case GIMP_PIXELFORMAT_RGBA16:
if (memcmp(ctx1->D, ctx2->D, ctx1->n_pixels * gimp_composite_pixel_bpp[ctx1->pixelformat_D])) {
g_print("%s: failed to agree\n", operation);
return (1);
}
break;
#endif
#if GIMP_COMPOSITE_32BIT
case GIMP_PIXELFORMAT_V32:
if (memcmp(ctx1->D, ctx2->D, ctx1->n_pixels * gimp_composite_pixel_bpp[ctx1->pixelformat_D])) {
g_print("%s: failed to agree\n", operation);
return (1);
}
break;
case GIMP_PIXELFORMAT_VA32:
if (memcmp(ctx1->D, ctx2->D, ctx1->n_pixels * gimp_composite_pixel_bpp[ctx1->pixelformat_D])) {
g_print("%s: failed to agree\n", operation);
return (1);
}
break;
case GIMP_PIXELFORMAT_RGB32:
if (memcmp(ctx1->D, ctx2->D, ctx1->n_pixels * gimp_composite_pixel_bpp[ctx1->pixelformat_D])) {
g_print("%s: failed to agree\n", operation);
return (1);
}
break;
case GIMP_PIXELFORMAT_RGBA32:
if (memcmp(ctx1->D, ctx2->D, ctx1->n_pixels * gimp_composite_pixel_bpp[ctx1->pixelformat_D])) {
g_print("%s: failed to agree\n", operation);
return (1);
}
break;
#endif
}
return (0);
}
/**
* gimp_composite_regression_comp_rgba8:
* @str:
* @rgba8A:
* @rgba8B:
* @expected:
* @actual:
* @length:
*
*
*
* Return value:
**/
int
gimp_composite_regression_comp_rgba8 (char *str, gimp_rgba8_t *rgba8A, gimp_rgba8_t *rgba8B, gimp_rgba8_t *expected, gimp_rgba8_t *actual, gulong length)
{
gulong i;
int failed;
int fail_count;
fail_count = 0;
for (i = 0; i < length; i++) {
failed = 0;
if (expected[i].r != actual[i].r) { failed = 1; }
if (expected[i].g != actual[i].g) { failed = 1; }
if (expected[i].b != actual[i].b) { failed = 1; }
if (expected[i].a != actual[i].a) { failed = 1; }
if (failed) {
fail_count++;
g_print("%s %8lu A=", str, i); gimp_composite_regression_print_rgba8(&rgba8A[i]);
if (rgba8B != (gimp_rgba8_t *) 0) {
g_print(" B="); gimp_composite_regression_print_rgba8(&rgba8B[i]);
}
g_print(" expected=");
gimp_composite_regression_print_rgba8(&expected[i]);
g_print(" actual=");
gimp_composite_regression_print_rgba8(&actual[i]);
g_print("\n");
}
if (fail_count > 5)
break;
}
return (fail_count);
}
/**
* gimp_composite_regression_comp_va8:
* @str:
* @va8A:
* @va8B:
* @expected:
* @actual:
* @length:
*
*
*
* Return value:
**/
int
gimp_composite_regression_comp_va8 (char *str, gimp_va8_t *va8A, gimp_va8_t *va8B, gimp_va8_t *expected, gimp_va8_t *actual, gulong length)
{
int i;
int failed;
int fail_count;
fail_count = 0;
for (i = 0; i < length; i++) {
failed = 0;
if (expected[i].v != actual[i].v) { failed = 1; }
if (expected[i].a != actual[i].a) { failed = 1; }
if (failed) {
fail_count++;
g_print("%s %8d A=", str, i); gimp_composite_regression_print_va8(&va8A[i]);
if (va8B != (gimp_va8_t *) 0) { g_print(" B="); gimp_composite_regression_print_va8(&va8B[i]); }
g_print(" ");
g_print("expected=");
gimp_composite_regression_print_va8(&expected[i]);
g_print(" actual=");
gimp_composite_regression_print_va8(&actual[i]);
g_print("\n");
}
if (fail_count > 5)
break;
}
return (fail_count);
}
/**
* gimp_composite_regression_dump_rgba8:
* @str:
* @rgba:
* @n_pixels:
*
*
**/
void
gimp_composite_regression_dump_rgba8 (char *str, gimp_rgba8_t *rgba, gulong n_pixels)
{
int i;
g_print("%s\n", str);
for (i = 0; i < n_pixels; i++) {
g_print("%5d: ", i);
gimp_composite_regression_print_rgba8(&rgba[i]);
g_print("\n");
}
}
#define tv_to_secs(tv) ((double) ((tv).tv_sec) + (double) ((tv).tv_usec / 1000000.0))
#define timer_report(name,t1,t2) g_print("%-32s %10.4f %10.4f %10.4f%c\n", name, tv_to_secs(t1), tv_to_secs(t2), tv_to_secs(t1)/tv_to_secs(t2), tv_to_secs(t1)/tv_to_secs(t2) > 1.0 ? ' ' : '*');
/**
* gimp_composite_regression_timer_report:
* @name:
* @t1:
* @t2:
*
*
**/
void
gimp_composite_regression_timer_report (char *name, double t1, double t2)
{
g_print ("%-32s %10.4f %10.4f %10.4f%c\n", name, t1, t2, t1/t2, t1/t2 > 1.0 ? ' ' : '*');
}
/**
* gimp_composite_regression_time_function:
* @iterations:
* @func:
*
*
*
* Return value:
**/
double
gimp_composite_regression_time_function (gulong iterations, GimpCompositeRegressionFunc func, GimpCompositeContext *ctx)
{
struct timeval t0;
struct timeval t1;
struct timeval tv_elapsed;
gulong i;
gettimeofday (&t0, NULL);
for (i = 0; i < iterations; i++) { (*func)(ctx); }
gettimeofday (&t1, NULL);
timersub (&t1, &t0, &tv_elapsed);
return (tv_to_secs (tv_elapsed));
}
/**
* gimp_composite_regression_random_rgba8:
* @n_pixels:
*
*
*
* Return value:
**/
gimp_rgba8_t *
gimp_composite_regression_random_rgba8 (gulong n_pixels)
{
gimp_rgba8_t *rgba8;
gulong i;
if ((rgba8 = (gimp_rgba8_t *) calloc (sizeof(gimp_rgba8_t), n_pixels))) {
for (i = 0; i < n_pixels; i++) {
rgba8[i].r = rand() % 256;
rgba8[i].g = rand() % 256;
rgba8[i].b = rand() % 256;
rgba8[i].a = rand() % 256;
}
}
return (rgba8);
}
/**
* gimp_composite_regression_fixed_rgba8:
* @n_pixels:
*
*
*
* Return value:
**/
gimp_rgba8_t *
gimp_composite_regression_fixed_rgba8 (gulong n_pixels)
{
gimp_rgba8_t *rgba8;
gulong i;
gulong v;
if ((rgba8 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels))) {
for (i = 0; i < n_pixels; i++) {
v = i % 256;
rgba8[i].r = v;
rgba8[i].g = v;
rgba8[i].b = v;
rgba8[i].a = v;
}
}
return (rgba8);
}
/**
* gimp_composite_context_init:
* @ctx:
* @op:
* @a_format:
* @b_format:
* @d_format:
* @m_format:
* @n_pixels:
* @A:
* @B:
* @M:
* @D:
*
*
*
* Return value:
**/
GimpCompositeContext *
gimp_composite_context_init (GimpCompositeContext *ctx,
GimpCompositeOperation op,
GimpPixelFormat a_format,
GimpPixelFormat b_format,
GimpPixelFormat d_format,
GimpPixelFormat m_format,
unsigned long n_pixels,
unsigned char *A,
unsigned char *B,
unsigned char *M,
unsigned char *D)
{
memset ((void *) ctx, 0, sizeof(*ctx));
ctx->op = op;
ctx->n_pixels = n_pixels;
ctx->scale.scale = 2;
ctx->pixelformat_A = a_format;
ctx->pixelformat_B = b_format;
ctx->pixelformat_D = d_format;
ctx->pixelformat_M = m_format;
ctx->A = (unsigned char *) A;
ctx->B = (unsigned char *) B;
ctx->M = (unsigned char *) B;
ctx->D = (unsigned char *) D;
memset (ctx->D, 0, ctx->n_pixels * gimp_composite_pixel_bpp[ctx->pixelformat_D]);
return (ctx);
}

View File

@ -1,141 +0,0 @@
#ifndef gimp_composite_regression_h
#define gimp_composite_regression_h
/*
* The following typedefs are temporary and only used in regression testing.
*/
typedef struct
{
guint8 v;
} gimp_v8_t;
typedef struct
{
guint8 v;
guint8 a;
} gimp_va8_t;
typedef struct
{
guint8 r;
guint8 g;
guint8 b;
} gimp_rgb8_t;
typedef struct
{
guint8 r;
guint8 g;
guint8 b;
guint8 a;
} gimp_rgba8_t;
#ifdef GIMP_COMPOSIE_16BIT
typedef struct
{
guint16 v;
} gimp_v16_t;
typedef struct
{
guint16 v;
guint16 a;
} gimp_va16_t;
typedef struct
{
guint16 r;
guint16 g;
guint16 b;
} gimp_rgb16_t;
typedef struct
{
guint16 r;
guint16 g;
guint16 b;
guint16 a;
} gimp_rgba16_t;
#endif
#ifdef GIMP_COMPOSIE_32BIT
typedef struct
{
guint32 v;
} gimp_v32_t;
typedef struct
{
guint32 v;
guint32 a;
} gimp_va32_t;
typedef struct
{
guint32 r;
guint32 g;
guint32 b;
} gimp_rgb32_t;
typedef struct
{
guint32 r;
guint32 g;
guint32 b;
guint32 a;
} gimp_rgba32_t;
#endif
typedef void (*GimpCompositeRegressionFunc) (GimpCompositeContext *ctx);
extern void gimp_composite_regression_print_vector (guchar vector[],
GimpPixelFormat format,
gulong n_pixels);
extern void gimp_composite_regression_print_vector_v8 (gimp_v8_t v[],
unsigned int n_pixels);
extern void gimp_composite_regression_print_vector_va8 (gimp_va8_t v[],
unsigned int n_pixels);
extern void gimp_composite_regression_print_vector_rgb8 (gimp_rgb8_t v[],
unsigned int n_pixels);
extern void gimp_composite_regression_print_vector_rgba8 (gimp_rgba8_t v[],
unsigned int n_pixels);
extern double gimp_composite_regression_time_function (gulong iterations,
GimpCompositeRegressionFunc func,
GimpCompositeContext *ctx);
extern int gimp_composite_regression_comp_rgba8 (char *str,
gimp_rgba8_t *rgba8A,
gimp_rgba8_t *rgba8B,
gimp_rgba8_t *expected,
gimp_rgba8_t *actual,
gulong length);
extern int gimp_composite_regression_comp_va8 (char *str,
gimp_va8_t *va8A,
gimp_va8_t *va8B,
gimp_va8_t *expected,
gimp_va8_t *actual,
gulong length);
extern int gimp_composite_regression_compare_contexts (char *,
GimpCompositeContext *ctx1,
GimpCompositeContext *ctx2);
extern void gimp_composite_regression_dump_rgba8 (char *str,
gimp_rgba8_t *rgba,
gulong n_pixels);
extern void gimp_composite_regression_print_rgba8 (gimp_rgba8_t *rgba8);
extern void gimp_composite_regression_print_va8 (gimp_va8_t *va8);
extern void gimp_composite_regression_timer_report (char *name,
double t1,
double t2);
extern gimp_rgba8_t * gimp_composite_regression_random_rgba8 (gulong n_pixels);
extern gimp_rgba8_t * gimp_composite_regression_fixed_rgba8 (gulong n_pixels);
extern GimpCompositeContext *gimp_composite_context_init (GimpCompositeContext *ctx,
GimpCompositeOperation op,
GimpPixelFormat a_format,
GimpPixelFormat b_format,
GimpPixelFormat d_format,
GimpPixelFormat m_format,
unsigned long n_pixels,
unsigned char *A,
unsigned char *B,
unsigned char *M,
unsigned char *D);
#endif

View File

@ -1,66 +0,0 @@
/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */
/* REGENERATE BY USING make-installer.py */
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-sse.h"
static const struct install_table {
GimpCompositeOperation mode;
GimpPixelFormat A;
GimpPixelFormat B;
GimpPixelFormat D;
void (*function)(GimpCompositeContext *);
} _gimp_composite_sse[] = {
#if defined(COMPILE_SSE_IS_OKAY)
{ GIMP_COMPOSITE_MULTIPLY, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_multiply_rgba8_rgba8_rgba8_sse },
{ GIMP_COMPOSITE_SCREEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_screen_rgba8_rgba8_rgba8_sse },
{ GIMP_COMPOSITE_DIFFERENCE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_difference_rgba8_rgba8_rgba8_sse },
{ GIMP_COMPOSITE_ADDITION, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_addition_rgba8_rgba8_rgba8_sse },
{ GIMP_COMPOSITE_SUBTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_subtract_rgba8_rgba8_rgba8_sse },
{ GIMP_COMPOSITE_DARKEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_darken_rgba8_rgba8_rgba8_sse },
{ GIMP_COMPOSITE_LIGHTEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_lighten_rgba8_rgba8_rgba8_sse },
{ GIMP_COMPOSITE_GRAIN_EXTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_grain_extract_rgba8_rgba8_rgba8_sse },
{ GIMP_COMPOSITE_GRAIN_MERGE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_grain_merge_rgba8_rgba8_rgba8_sse },
{ GIMP_COMPOSITE_SWAP, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_swap_rgba8_rgba8_rgba8_sse },
{ GIMP_COMPOSITE_SCALE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_scale_rgba8_rgba8_rgba8_sse },
#endif
{ 0, 0, 0, 0, NULL }
};
gboolean
gimp_composite_sse_install (void)
{
static const struct install_table *t = _gimp_composite_sse;
if (gimp_composite_sse_init ())
{
for (t = &_gimp_composite_sse[0]; t->function != NULL; t++)
{
gimp_composite_function[t->mode][t->A][t->B][t->D] = t->function;
}
return (TRUE);
}
return (FALSE);
}
gboolean
gimp_composite_sse_init (void)
{
#if defined(COMPILE_SSE_IS_OKAY)
GimpCpuAccelFlags cpu = gimp_cpu_accel_get_support ();
if (cpu & GIMP_CPU_ACCEL_X86_SSE || cpu & GIMP_CPU_ACCEL_X86_MMXEXT)
{
return (TRUE);
}
#endif
return (FALSE);
}

View File

@ -1,226 +0,0 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-regression.h"
#include "gimp-composite-util.h"
#include "gimp-composite-generic.h"
#include "gimp-composite-sse.h"
static int
gimp_composite_sse_test (int iterations, int n_pixels)
{
#if defined(COMPILE_SSE_IS_OKAY)
GimpCompositeContext generic_ctx;
GimpCompositeContext special_ctx;
double ft0;
double ft1;
gimp_rgba8_t *rgba8D1;
gimp_rgba8_t *rgba8D2;
gimp_rgba8_t *rgba8A;
gimp_rgba8_t *rgba8B;
gimp_rgba8_t *rgba8M;
gimp_va8_t *va8A;
gimp_va8_t *va8B;
gimp_va8_t *va8M;
gimp_va8_t *va8D1;
gimp_va8_t *va8D2;
int i;
if (gimp_composite_sse_init () == 0)
{
g_print ("\ngimp_composite_sse: Instruction set is not available.\n");
return EXIT_SUCCESS;
}
g_print ("\nRunning gimp_composite_sse tests...\n");
rgba8A = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8B = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8M = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8D1 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
rgba8D2 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
va8A = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8B = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8M = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D1 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D2 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
for (i = 0; i < n_pixels; i++)
{
va8A[i].v = i;
va8A[i].a = 255-i;
va8B[i].v = i;
va8B[i].a = i;
va8M[i].v = i;
va8M[i].a = i;
}
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_ADDITION, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_ADDITION, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_addition_rgba8_rgba8_rgba8_sse, &special_ctx);
if (gimp_composite_regression_compare_contexts ("addition", &generic_ctx, &special_ctx))
{
g_print ("addition_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("addition_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_DARKEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_DARKEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_darken_rgba8_rgba8_rgba8_sse, &special_ctx);
if (gimp_composite_regression_compare_contexts ("darken", &generic_ctx, &special_ctx))
{
g_print ("darken_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("darken_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_DIFFERENCE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_DIFFERENCE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_difference_rgba8_rgba8_rgba8_sse, &special_ctx);
if (gimp_composite_regression_compare_contexts ("difference", &generic_ctx, &special_ctx))
{
g_print ("difference_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("difference_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_GRAIN_EXTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_GRAIN_EXTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_grain_extract_rgba8_rgba8_rgba8_sse, &special_ctx);
if (gimp_composite_regression_compare_contexts ("grain_extract", &generic_ctx, &special_ctx))
{
g_print ("grain_extract_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("grain_extract_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_GRAIN_MERGE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_GRAIN_MERGE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_grain_merge_rgba8_rgba8_rgba8_sse, &special_ctx);
if (gimp_composite_regression_compare_contexts ("grain_merge", &generic_ctx, &special_ctx))
{
g_print ("grain_merge_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("grain_merge_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_LIGHTEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_LIGHTEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_lighten_rgba8_rgba8_rgba8_sse, &special_ctx);
if (gimp_composite_regression_compare_contexts ("lighten", &generic_ctx, &special_ctx))
{
g_print ("lighten_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("lighten_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_MULTIPLY, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_MULTIPLY, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_multiply_rgba8_rgba8_rgba8_sse, &special_ctx);
if (gimp_composite_regression_compare_contexts ("multiply", &generic_ctx, &special_ctx))
{
g_print ("multiply_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("multiply_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_SCALE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_SCALE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_scale_rgba8_rgba8_rgba8_sse, &special_ctx);
if (gimp_composite_regression_compare_contexts ("scale", &generic_ctx, &special_ctx))
{
g_print ("scale_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("scale_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_SCREEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_SCREEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_screen_rgba8_rgba8_rgba8_sse, &special_ctx);
if (gimp_composite_regression_compare_contexts ("screen", &generic_ctx, &special_ctx))
{
g_print ("screen_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("screen_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_SUBTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_SUBTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_subtract_rgba8_rgba8_rgba8_sse, &special_ctx);
if (gimp_composite_regression_compare_contexts ("subtract", &generic_ctx, &special_ctx))
{
g_print ("subtract_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("subtract_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_SWAP, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_SWAP, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_swap_rgba8_rgba8_rgba8_sse, &special_ctx);
if (gimp_composite_regression_compare_contexts ("swap", &generic_ctx, &special_ctx))
{
g_print ("swap_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("swap_rgba8_rgba8_rgba8", ft0, ft1);
#endif
return EXIT_SUCCESS;
}
int
main (int argc, char *argv[])
{
int iterations;
int n_pixels;
srand (314159);
g_setenv ("GIMP_COMPOSITE", "0x1", TRUE);
iterations = 10;
n_pixels = 8388625;
argv++, argc--;
while (argc >= 2)
{
if (argc > 1 && (strcmp (argv[0], "--iterations") == 0 || strcmp (argv[0], "-i") == 0))
{
iterations = atoi(argv[1]);
argc -= 2, argv++; argv++;
}
else if (argc > 1 && (strcmp (argv[0], "--n-pixels") == 0 || strcmp (argv[0], "-n") == 0))
{
n_pixels = atoi (argv[1]);
argc -= 2, argv++; argv++;
}
else
{
g_print ("Usage: gimp-composites-*-test [-i|--iterations n] [-n|--n-pixels n]");
return EXIT_FAILURE;
}
}
gimp_composite_generic_install ();
return (gimp_composite_sse_test (iterations, n_pixels));
}

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +0,0 @@
#ifndef gimp_composite_sse_h
#define gimp_composite_sse_h
extern gboolean gimp_composite_sse_init (void);
/*
* The function gimp_composite_*_install() is defined in the code generated by make-install.py
* I hate to create a .h file just for that declaration, so I do it here (for now).
*/
extern gboolean gimp_composite_sse_install (void);
#if !defined(__INTEL_COMPILER) || defined(USE_INTEL_COMPILER_ANYWAY)
#if defined(USE_SSE)
#if defined(ARCH_X86)
#if __GNUC__ >= 3
#if defined(ARCH_X86_64) || (!defined(PIC) && !defined(__PIC__))
#define COMPILE_SSE_IS_OKAY
#endif /* defined(ARCH_X86_64) || !defined(PIC) */
#endif /* __GNUC__ >= 3 */
#endif /* defined(ARCH_X86) */
#endif /* defined(USE_SSE) */
#endif /* */
#ifdef COMPILE_SSE_IS_OKAY
/*
*
*/
extern void gimp_composite_addition_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_burn_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_coloronly_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_darken_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_difference_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_dissolve_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_divide_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_dodge_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_grain_extract_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_grain_merge_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_hardlight_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_hueonly_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_lighten_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_multiply_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_overlay_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_replace_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_saturationonly_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_screen_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_softlight_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_subtract_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_swap_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_valueonly_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
extern void gimp_composite_scale_rgba8_rgba8_rgba8_sse (GimpCompositeContext *ctx);
#endif /* COMPILE_SSE_IS_OKAY */
#endif

View File

@ -1,60 +0,0 @@
/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */
/* REGENERATE BY USING make-installer.py */
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-sse2.h"
static const struct install_table {
GimpCompositeOperation mode;
GimpPixelFormat A;
GimpPixelFormat B;
GimpPixelFormat D;
void (*function)(GimpCompositeContext *);
} _gimp_composite_sse2[] = {
#if defined(COMPILE_SSE2_IS_OKAY)
{ GIMP_COMPOSITE_DIFFERENCE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_difference_rgba8_rgba8_rgba8_sse2 },
{ GIMP_COMPOSITE_ADDITION, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_addition_rgba8_rgba8_rgba8_sse2 },
{ GIMP_COMPOSITE_SUBTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_subtract_rgba8_rgba8_rgba8_sse2 },
{ GIMP_COMPOSITE_DARKEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_darken_rgba8_rgba8_rgba8_sse2 },
{ GIMP_COMPOSITE_LIGHTEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_lighten_rgba8_rgba8_rgba8_sse2 },
{ GIMP_COMPOSITE_GRAIN_EXTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_grain_extract_rgba8_rgba8_rgba8_sse2 },
{ GIMP_COMPOSITE_SWAP, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, gimp_composite_swap_rgba8_rgba8_rgba8_sse2 },
#endif
{ 0, 0, 0, 0, NULL }
};
gboolean
gimp_composite_sse2_install (void)
{
static const struct install_table *t = _gimp_composite_sse2;
if (gimp_composite_sse2_init ())
{
for (t = &_gimp_composite_sse2[0]; t->function != NULL; t++)
{
gimp_composite_function[t->mode][t->A][t->B][t->D] = t->function;
}
return (TRUE);
}
return (FALSE);
}
gboolean
gimp_composite_sse2_init (void)
{
#if defined(COMPILE_SSE2_IS_OKAY)
if (gimp_cpu_accel_get_support () & GIMP_CPU_ACCEL_X86_SSE2)
{
return (TRUE);
}
#endif
return (FALSE);
}

View File

@ -1,182 +0,0 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-regression.h"
#include "gimp-composite-util.h"
#include "gimp-composite-generic.h"
#include "gimp-composite-sse2.h"
static int
gimp_composite_sse2_test (int iterations, int n_pixels)
{
#if defined(COMPILE_SSE2_IS_OKAY)
GimpCompositeContext generic_ctx;
GimpCompositeContext special_ctx;
double ft0;
double ft1;
gimp_rgba8_t *rgba8D1;
gimp_rgba8_t *rgba8D2;
gimp_rgba8_t *rgba8A;
gimp_rgba8_t *rgba8B;
gimp_rgba8_t *rgba8M;
gimp_va8_t *va8A;
gimp_va8_t *va8B;
gimp_va8_t *va8M;
gimp_va8_t *va8D1;
gimp_va8_t *va8D2;
int i;
if (gimp_composite_sse2_init () == 0)
{
g_print ("\ngimp_composite_sse2: Instruction set is not available.\n");
return EXIT_SUCCESS;
}
g_print ("\nRunning gimp_composite_sse2 tests...\n");
rgba8A = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8B = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8M = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8D1 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
rgba8D2 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
va8A = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8B = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8M = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D1 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D2 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
for (i = 0; i < n_pixels; i++)
{
va8A[i].v = i;
va8A[i].a = 255-i;
va8B[i].v = i;
va8B[i].a = i;
va8M[i].v = i;
va8M[i].a = i;
}
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_ADDITION, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_ADDITION, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_addition_rgba8_rgba8_rgba8_sse2, &special_ctx);
if (gimp_composite_regression_compare_contexts ("addition", &generic_ctx, &special_ctx))
{
g_print ("addition_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("addition_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_DARKEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_DARKEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_darken_rgba8_rgba8_rgba8_sse2, &special_ctx);
if (gimp_composite_regression_compare_contexts ("darken", &generic_ctx, &special_ctx))
{
g_print ("darken_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("darken_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_DIFFERENCE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_DIFFERENCE, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_difference_rgba8_rgba8_rgba8_sse2, &special_ctx);
if (gimp_composite_regression_compare_contexts ("difference", &generic_ctx, &special_ctx))
{
g_print ("difference_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("difference_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_GRAIN_EXTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_GRAIN_EXTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_grain_extract_rgba8_rgba8_rgba8_sse2, &special_ctx);
if (gimp_composite_regression_compare_contexts ("grain_extract", &generic_ctx, &special_ctx))
{
g_print ("grain_extract_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("grain_extract_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_LIGHTEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_LIGHTEN, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_lighten_rgba8_rgba8_rgba8_sse2, &special_ctx);
if (gimp_composite_regression_compare_contexts ("lighten", &generic_ctx, &special_ctx))
{
g_print ("lighten_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("lighten_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_SUBTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_SUBTRACT, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_subtract_rgba8_rgba8_rgba8_sse2, &special_ctx);
if (gimp_composite_regression_compare_contexts ("subtract", &generic_ctx, &special_ctx))
{
g_print ("subtract_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("subtract_rgba8_rgba8_rgba8", ft0, ft1);
gimp_composite_context_init (&special_ctx, GIMP_COMPOSITE_SWAP, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D2);
gimp_composite_context_init (&generic_ctx, GIMP_COMPOSITE_SWAP, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, GIMP_PIXELFORMAT_RGBA8, n_pixels, (unsigned char *) rgba8A, (unsigned char *) rgba8B, (unsigned char *) rgba8B, (unsigned char *) rgba8D1);
ft0 = gimp_composite_regression_time_function (iterations, gimp_composite_dispatch, &generic_ctx);
ft1 = gimp_composite_regression_time_function (iterations, gimp_composite_swap_rgba8_rgba8_rgba8_sse2, &special_ctx);
if (gimp_composite_regression_compare_contexts ("swap", &generic_ctx, &special_ctx))
{
g_print ("swap_rgba8_rgba8_rgba8 failed\n");
return EXIT_FAILURE;
}
gimp_composite_regression_timer_report ("swap_rgba8_rgba8_rgba8", ft0, ft1);
#endif
return EXIT_SUCCESS;
}
int
main (int argc, char *argv[])
{
int iterations;
int n_pixels;
srand (314159);
g_setenv ("GIMP_COMPOSITE", "0x1", TRUE);
iterations = 10;
n_pixels = 8388625;
argv++, argc--;
while (argc >= 2)
{
if (argc > 1 && (strcmp (argv[0], "--iterations") == 0 || strcmp (argv[0], "-i") == 0))
{
iterations = atoi(argv[1]);
argc -= 2, argv++; argv++;
}
else if (argc > 1 && (strcmp (argv[0], "--n-pixels") == 0 || strcmp (argv[0], "-n") == 0))
{
n_pixels = atoi (argv[1]);
argc -= 2, argv++; argv++;
}
else
{
g_print ("Usage: gimp-composites-*-test [-i|--iterations n] [-n|--n-pixels n]");
return EXIT_FAILURE;
}
}
gimp_composite_generic_install ();
return (gimp_composite_sse2_test (iterations, n_pixels));
}

View File

@ -1,668 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Gimp image compositing
* Copyright (C) 2003 Helvetix Victorinox, a pseudonym, <helvetix@gimp.org>
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-sse2.h"
#ifdef COMPILE_SSE2_IS_OKAY
#include "gimp-composite-x86.h"
static const guint32 rgba8_alpha_mask_128[4] = { 0xFF000000, 0xFF000000, 0xFF000000, 0xFF000000 };
static const guint32 rgba8_b1_128[4] = { 0x01010101, 0x01010101, 0x01010101, 0x01010101 };
static const guint32 rgba8_b255_128[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
static const guint32 rgba8_w1_128[4] = { 0x00010001, 0x00010001, 0x00010001, 0x00010001 };
static const guint32 rgba8_w2_128[4] = { 0x00020002, 0x00020002, 0x00020002, 0x00020002 };
static const guint32 rgba8_w128_128[4] = { 0x00800080, 0x00800080, 0x00800080, 0x00800080 };
static const guint32 rgba8_w256_128[4] = { 0x01000100, 0x01000100, 0x01000100, 0x01000100 };
static const guint32 rgba8_w255_128[4] = { 0X00FF00FF, 0X00FF00FF, 0X00FF00FF, 0X00FF00FF };
static const guint32 va8_alpha_mask_128[4] = { 0xFF00FF00, 0xFF00FF00, 0xFF00FF00, 0xFF00FF00 };
static const guint32 va8_b255_128[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
static const guint32 va8_w1_128[4] = { 0x00010001, 0x00010001, 0x00010001, 0x00010001 };
static const guint32 va8_w255_128[4] = { 0x00FF00FF, 0x00FF00FF, 0x00FF00FF, 0x00FF00FF };
static const guint32 rgba8_alpha_mask_64[2] = { 0xFF000000, 0xFF000000 };
static const guint32 rgba8_b1_64[2] = { 0x01010101, 0x01010101 };
static const guint32 rgba8_b255_64[2] = { 0xFFFFFFFF, 0xFFFFFFFF };
static const guint32 rgba8_w1_64[2] = { 0x00010001, 0x00010001 };
static const guint32 rgba8_w2_64[2] = { 0x00020002, 0x00020002 };
static const guint32 rgba8_w128_64[2] = { 0x00800080, 0x00800080 };
static const guint32 rgba8_w256_64[2] = { 0x01000100, 0x01000100 };
static const guint32 rgba8_w255_64[2] = { 0X00FF00FF, 0X00FF00FF };
static const guint32 va8_alpha_mask_64[2] = { 0xFF00FF00, 0xFF00FF00 };
static const guint32 va8_b255_64[2] = { 0xFFFFFFFF, 0xFFFFFFFF };
static const guint32 va8_w1_64[2] = { 0x00010001, 0x00010001 };
static const guint32 va8_w255_64[2] = { 0x00FF00FF, 0x00FF00FF };
#if 0
void
debug_display_sse (void)
{
#define mask32(x) ((x)& (unsigned long long) 0xFFFFFFFF)
#define print128(reg) { \
unsigned long long reg[2]; \
asm("movdqu %%" #reg ",%0" : "=m" (reg)); \
g_print(#reg"=%08llx %08llx", mask32(reg[0]>>32), mask32(reg[0])); \
g_print(" %08llx %08llx", mask32(reg[1]>>32), mask32(reg[1])); \
}
g_print("--------------------------------------------\n");
print128(xmm0); g_print(" "); print128(xmm1); g_print("\n");
print128(xmm2); g_print(" "); print128(xmm3); g_print("\n");
print128(xmm4); g_print(" "); print128(xmm5); g_print("\n");
print128(xmm6); g_print(" "); print128(xmm7); g_print("\n");
g_print("--------------------------------------------\n");
}
#endif
void
gimp_composite_addition_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *_op)
{
uint64 *d;
uint64 *a;
uint64 *b;
uint128 *D = (uint128 *) _op->D;
uint128 *A = (uint128 *) _op->A;
uint128 *B = (uint128 *) _op->B;
gulong n_pixels = _op->n_pixels;
asm volatile (" movdqu %0,%%xmm0\n"
"\tmovq %1,%%mm0"
: /* empty */
: "m" (*rgba8_alpha_mask_128), "m" (*rgba8_alpha_mask_64)
: "%xmm0", "%mm0");
for (; n_pixels >= 4; n_pixels -= 4)
{
asm volatile (" movdqu %1,%%xmm2\n"
"\tmovdqu %2,%%xmm3\n"
"\tmovdqu %%xmm2,%%xmm4\n"
"\tpaddusb %%xmm3,%%xmm4\n"
"\tmovdqu %%xmm0,%%xmm1\n"
"\tpandn %%xmm4,%%xmm1\n"
"\tpminub %%xmm3,%%xmm2\n"
"\tpand %%xmm0,%%xmm2\n"
"\tpor %%xmm2,%%xmm1\n"
"\tmovdqu %%xmm1,%0\n"
: "=m" (*D)
: "m" (*A), "m" (*B)
: "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7");
A++;
B++;
D++;
}
a = (uint64 *) A;
b = (uint64 *) B;
d = (uint64 *) D;
for (; n_pixels >= 2; n_pixels -= 2)
{
asm volatile (" movq %1,%%mm2\n"
"\tmovq %2,%%mm3\n"
"\tmovq %%mm2,%%mm4\n"
"\tpaddusb %%mm3,%%mm4\n"
"\tmovq %%mm0,%%mm1\n"
"\tpandn %%mm4,%%mm1\n"
"\tpminub %%mm3,%%mm2\n"
"\tpand %%mm0,%%mm2\n"
"\tpor %%mm2,%%mm1\n"
"\tmovntq %%mm1,%0\n"
: "=m" (*d)
: "m" (*a), "m" (*b)
: "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7");
a++;
b++;
d++;
}
if (n_pixels > 0)
{
asm volatile (" movd %1,%%mm2\n"
"\tmovd %2,%%mm3\n"
"\tmovq %%mm2,%%mm4\n"
"\tpaddusb %%mm3,%%mm4\n"
"\tmovq %%mm0,%%mm1\n"
"\tpandn %%mm4,%%mm1\n"
"\tpminub %%mm3,%%mm2\n"
"\tpand %%mm0,%%mm2\n"
"\tpor %%mm2,%%mm1\n"
"\tmovd %%mm1,%0\n"
: "=m" (*d)
: "m" (*a), "m" (*b)
: "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7");
}
asm("emms");
}
void
gimp_composite_darken_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *_op)
{
uint64 *d;
uint64 *a;
uint64 *b;
uint128 *D = (uint128 *) _op->D;
uint128 *A = (uint128 *) _op->A;
uint128 *B = (uint128 *) _op->B;
gulong n_pixels = _op->n_pixels;
for (; n_pixels >= 4; n_pixels -= 4)
{
asm volatile (" movdqu %1,%%xmm2\n"
"\tmovdqu %2,%%xmm3\n"
"\tpminub %%xmm3,%%xmm2\n"
"\tmovdqu %%xmm2,%0\n"
: "=m" (*D)
: "m" (*A), "m" (*B)
: "%xmm2", "%xmm3");
A++;
B++;
D++;
}
a = (uint64 *) A;
b = (uint64 *) B;
d = (uint64 *) D;
for (; n_pixels >= 2; n_pixels -= 2)
{
asm volatile (" movq %1,%%mm2\n"
"\tmovq %2,%%mm3\n"
"\tpminub %%mm3,%%mm2\n"
"\tmovntq %%mm2,%0\n"
: "=m" (*d)
: "m" (*a), "m" (*b)
: "%mm2", "%mm3");
a++;
b++;
d++;
}
if (n_pixels > 0)
{
asm volatile (" movd %1, %%mm2\n"
"\tmovd %2, %%mm3\n"
"\tpminub %%mm3, %%mm2\n"
"\tmovd %%mm2, %0\n"
: "=m" (*d)
: "m" (*a), "m" (*b)
: "%mm2", "%mm3", "%mm4");
}
asm("emms");
}
void
gimp_composite_difference_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *_op)
{
uint64 *d;
uint64 *a;
uint64 *b;
uint128 *D = (uint128 *) _op->D;
uint128 *A = (uint128 *) _op->A;
uint128 *B = (uint128 *) _op->B;
gulong n_pixels = _op->n_pixels;
asm volatile (" movq %0,%%mm0\n"
"\tmovdqu %1,%%xmm0"
: /* */
: "m" (*rgba8_alpha_mask_64), "m" (*rgba8_alpha_mask_128)
: "%mm0", "%xmm0");
for (; n_pixels >= 4; n_pixels -= 4)
{
asm volatile (" movdqu %1,%%xmm2\n"
"\tmovdqu %2,%%xmm3\n"
"\tmovdqu %%xmm2,%%xmm4\n"
"\tmovdqu %%xmm3,%%xmm5\n"
"\tpsubusb %%xmm3,%%xmm4\n"
"\tpsubusb %%xmm2,%%xmm5\n"
"\tpaddb %%xmm5,%%xmm4\n"
"\tmovdqu %%xmm0,%%xmm1\n"
"\tpandn %%xmm4,%%xmm1\n"
"\tpminub %%xmm3,%%xmm2\n"
"\tpand %%xmm0,%%xmm2\n"
"\tpor %%xmm2,%%xmm1\n"
"\tmovdqu %%xmm1,%0\n"
: "=m" (*D)
: "m" (*A), "m" (*B)
: "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5");
A++;
B++;
D++;
}
a = (uint64 *) A;
b = (uint64 *) B;
d = (uint64 *) D;
for (; n_pixels >= 2; n_pixels -= 2)
{
asm volatile (" movq %1, %%mm2\n"
"\tmovq %2, %%mm3\n"
"\tmovq %%mm2, %%mm4\n"
"\tmovq %%mm3, %%mm5\n"
"\tpsubusb %%mm3, %%mm4\n"
"\tpsubusb %%mm2, %%mm5\n"
"\tpaddb %%mm5, %%mm4\n"
"\tmovq %%mm0, %%mm1\n"
"\tpandn %%mm4, %%mm1\n"
"\tpminub %%mm3, %%mm2\n"
"\tpand %%mm0, %%mm2\n"
"\tpor %%mm2, %%mm1\n"
"\tmovntq %%mm1, %0\n"
: "=m" (*d)
: "m" (*a), "m" (*b)
: "%mm1", "%mm2", "%mm3", "%mm4", "%mm5");
a++;
b++;
d++;
}
if (n_pixels > 0)
{
asm volatile (" movd %1, %%mm2\n"
"\tmovd %2, %%mm3\n"
"\tmovq %%mm2, %%mm4\n"
"\tmovq %%mm3, %%mm5\n"
"\tpsubusb %%mm3, %%mm4\n"
"\tpsubusb %%mm2, %%mm5\n"
"\tpaddb %%mm5, %%mm4\n"
"\tmovq %%mm0, %%mm1\n"
"\tpandn %%mm4, %%mm1\n"
"\tpminub %%mm3, %%mm2\n"
"\tpand %%mm0, %%mm2\n"
"\tpor %%mm2, %%mm1\n"
"\tmovd %%mm1, %0\n"
: "=m" (*d)
: "m" (*a), "m" (*b)
: "%mm1", "%mm2", "%mm3", "%mm4", "%mm5");
}
asm("emms");
}
void
gimp_composite_grain_extract_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *_op)
{
uint64 *d;
uint64 *a;
uint64 *b;
uint128 *D = (uint128 *) _op->D;
uint128 *A = (uint128 *) _op->A;
uint128 *B = (uint128 *) _op->B;
gulong n_pixels = _op->n_pixels;
asm volatile (" movq %0,%%mm0\n"
"\tpxor %%mm6,%%mm6\n"
"\tmovq %1,%%mm7\n"
"\tmovdqu %2,%%xmm0\n"
"\tpxor %%xmm6,%%xmm6\n"
"\tmovdqu %3,%%xmm7\n"
: /* empty */
: "m" (*rgba8_alpha_mask_64), "m" (*rgba8_w128_64), "m" (*rgba8_alpha_mask_128), "m" (*rgba8_w128_128)
: "%mm0", "%mm6", "%mm7", "%xmm0", "%xmm6", "%xmm7");
for (; n_pixels >= 4; n_pixels -= 4)
{
asm volatile (" movdqu %1,%%xmm2\n"
"\tmovdqu %2,%%xmm3\n"
xmm_low_bytes_to_words(xmm2,xmm4,xmm6)
xmm_low_bytes_to_words(xmm3,xmm5,xmm6)
"\tpsubw %%xmm5,%%xmm4\n"
"\tpaddw %%xmm7,%%xmm4\n"
"\tmovdqu %%xmm4,%%xmm1\n"
xmm_high_bytes_to_words(xmm2,xmm4,xmm6)
xmm_high_bytes_to_words(xmm3,xmm5,xmm6)
"\tpsubw %%xmm5,%%xmm4\n"
"\tpaddw %%xmm7,%%xmm4\n"
"\tpackuswb %%xmm4,%%xmm1\n"
"\tmovdqu %%xmm1,%%xmm4\n"
"\tmovdqu %%xmm0,%%xmm1\n"
"\tpandn %%xmm4,%%xmm1\n"
"\tpminub %%xmm3,%%xmm2\n"
"\tpand %%xmm0,%%xmm2\n"
"\tpor %%xmm2,%%xmm1\n"
"\tmovdqu %%xmm1,%0\n"
: "=m" (*D)
: "m" (*A), "m" (*B)
: "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5");
A++;
B++;
D++;
}
a = (uint64 *) A;
b = (uint64 *) B;
d = (uint64 *) D;
for (; n_pixels >= 2; n_pixels -= 2)
{
asm volatile (" movq %1,%%mm2\n"
"\tmovq %2,%%mm3\n"
mmx_low_bytes_to_words(mm2,mm4,mm6)
mmx_low_bytes_to_words(mm3,mm5,mm6)
"\tpsubw %%mm5,%%mm4\n"
"\tpaddw %%mm7,%%mm4\n"
"\tmovq %%mm4,%%mm1\n"
mmx_high_bytes_to_words(mm2,mm4,mm6)
mmx_high_bytes_to_words(mm3,mm5,mm6)
"\tpsubw %%mm5,%%mm4\n"
"\tpaddw %%mm7,%%mm4\n"
"\tpackuswb %%mm4,%%mm1\n"
"\tmovq %%mm1,%%mm4\n"
"\tmovq %%mm0,%%mm1\n"
"\tpandn %%mm4,%%mm1\n"
"\tpminub %%mm3,%%mm2\n"
"\tpand %%mm0,%%mm2\n"
"\tpor %%mm2,%%mm1\n"
"\tmovntq %%mm1,%0\n"
: "=m" (*d)
: "m" (*a), "m" (*b)
: "%mm1", "%mm2", "%mm3", "%mm4", "%mm5");
a++;
b++;
d++;
}
if (n_pixels > 0)
{
asm volatile (" movd %1, %%mm2\n"
"\tmovd %2, %%mm3\n"
mmx_low_bytes_to_words(mm2,mm4,mm6)
mmx_low_bytes_to_words(mm3,mm5,mm6)
"\tpsubw %%mm5, %%mm4\n"
"\tpaddw %%mm7, %%mm4\n"
"\tmovq %%mm4, %%mm1\n"
"\tpackuswb %%mm6, %%mm1\n"
"\tmovq %%mm1, %%mm4\n"
"\tmovq %%mm0, %%mm1\n"
"\tpandn %%mm4, %%mm1\n"
"\tpminub %%mm3, %%mm2\n"
"\tpand %%mm0, %%mm2\n"
"\tpor %%mm2, %%mm1\n"
"\tmovd %%mm1, %0\n"
: "=m" (*d)
: "m" (*a), "m" (*b)
: "%mm1", "%mm2", "%mm3", "%mm4", "%mm5");
}
asm("emms");
}
void
gimp_composite_lighten_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *_op)
{
uint64 *d;
uint64 *a;
uint64 *b;
uint128 *D = (uint128 *) _op->D;
uint128 *A = (uint128 *) _op->A;
uint128 *B = (uint128 *) _op->B;
gulong n_pixels = _op->n_pixels;
asm volatile (" movdqu %0,%%xmm0\n"
"\tmovq %1,%%mm0"
: /* empty */
: "m" (*rgba8_alpha_mask_128), "m" (*rgba8_alpha_mask_64)
: "%xmm0", "%mm0");
for (; n_pixels >= 4; n_pixels -= 4)
{
asm volatile (" movdqu %1, %%xmm2\n"
"\tmovdqu %2, %%xmm3\n"
"\tmovdqu %%xmm2, %%xmm4\n"
"\tpmaxub %%xmm3, %%xmm4\n"
"\tmovdqu %%xmm0, %%xmm1\n"
"\tpandn %%xmm4, %%xmm1\n"
"\tpminub %%xmm2, %%xmm3\n"
"\tpand %%xmm0, %%xmm3\n"
"\tpor %%xmm3, %%xmm1\n"
"\tmovdqu %%xmm1, %0\n"
: "=m" (*D)
: "m" (*A), "m" (*B)
: "%xmm1", "%xmm2", "%xmm3", "%xmm4");
A++;
B++;
D++;
}
a = (uint64 *) A;
b = (uint64 *) B;
d = (uint64 *) D;
for (; n_pixels >= 2; n_pixels -= 2)
{
asm volatile (" movq %1, %%mm2\n"
"\tmovq %2, %%mm3\n"
"\tmovq %%mm2, %%mm4\n"
"\tpmaxub %%mm3, %%mm4\n"
"\tmovq %%mm0, %%mm1\n"
"\tpandn %%mm4, %%mm1\n"
"\tpminub %%mm2, %%mm3\n"
"\tpand %%mm0, %%mm3\n"
"\tpor %%mm3, %%mm1\n"
"\tmovntq %%mm1, %0\n"
: "=m" (*d)
: "m" (*a), "m" (*b)
: "%mm1", "%mm2", "%mm3", "%mm4");
a++;
b++;
d++;
}
if (n_pixels > 0)
{
asm volatile (" movd %1, %%mm2\n"
"\tmovd %2, %%mm3\n"
"\tmovq %%mm2, %%mm4\n"
"\tpmaxub %%mm3, %%mm4\n"
"\tmovq %%mm0, %%mm1\n"
"\tpandn %%mm4, %%mm1\n"
"\tpminub %%mm2, %%mm3\n"
"\tpand %%mm0, %%mm3\n"
"\tpor %%mm3, %%mm1\n"
"\tmovd %%mm1, %0\n"
: "=m" (*d)
: "m" (*a), "m" (*b)
: "%mm1", "%mm2", "%mm3", "%mm4");
}
asm("emms");
}
void
gimp_composite_subtract_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *_op)
{
uint64 *d;
uint64 *a;
uint64 *b;
uint128 *D = (uint128 *) _op->D;
uint128 *A = (uint128 *) _op->A;
uint128 *B = (uint128 *) _op->B;
gulong n_pixels = _op->n_pixels;
asm volatile (" movq %0,%%mm0\n"
"\tmovdqu %1,%%xmm0\n"
: /* empty */
: "m" (*rgba8_alpha_mask_64), "m" (*rgba8_alpha_mask_128)
: "%mm0", "%xmm0");
for (; n_pixels >= 4; n_pixels -= 4)
{
asm volatile (" movdqu %1,%%xmm2\n"
"\tmovdqu %2,%%xmm3\n"
"\tmovdqu %%xmm2,%%xmm4\n"
"\tpsubusb %%xmm3,%%xmm4\n"
"\tmovdqu %%xmm0,%%xmm1\n"
"\tpandn %%xmm4,%%xmm1\n"
"\tpminub %%xmm3,%%xmm2\n"
"\tpand %%xmm0,%%xmm2\n"
"\tpor %%xmm2,%%xmm1\n"
"\tmovdqu %%xmm1,%0\n"
: "=m" (*D)
: "m" (*A), "m" (*B)
: "%xmm1", "%xmm2", "%xmm3", "%xmm4");
A++;
B++;
D++;
}
a = (uint64 *) A;
b = (uint64 *) B;
d = (uint64 *) D;
for (; n_pixels >= 2; n_pixels -= 2)
{
asm volatile (" movq %1,%%mm2\n"
"\tmovq %2,%%mm3\n"
"\tmovq %%mm2,%%mm4\n"
"\tpsubusb %%mm3,%%mm4\n"
"\tmovq %%mm0,%%mm1\n"
"\tpandn %%mm4,%%mm1\n"
"\tpminub %%mm3,%%mm2\n"
"\tpand %%mm0,%%mm2\n"
"\tpor %%mm2,%%mm1\n"
"\tmovntq %%mm1,%0\n"
: "=m" (*d)
: "m" (*a), "m" (*b)
: "%mm1", "%mm2", "%mm3", "%mm4");
a++;
b++;
d++;
}
if (n_pixels > 0)
{
asm volatile (" movd %1,%%mm2\n"
"\tmovd %2,%%mm3\n"
"\tmovq %%mm2,%%mm4\n"
"\tpsubusb %%mm3,%%mm4\n"
"\tmovq %%mm0,%%mm1\n"
"\tpandn %%mm4,%%mm1\n"
"\tpminub %%mm3,%%mm2\n"
"\tpand %%mm0,%%mm2\n"
"\tpor %%mm2,%%mm1\n"
"\tmovd %%mm1,%0\n"
: "=m" (*d)
: "m" (*a), "m" (*b)
: "%mm1", "%mm2", "%mm3", "%mm4");
}
asm("emms");
}
void
gimp_composite_swap_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *_op)
{
GimpCompositeContext op = *_op;
/*
* Inhale one whole i686 cache line at once. 128 bytes == 32 rgba8
* pixels == 8 128 bit xmm registers.
*/
for (; op.n_pixels >= 16; op.n_pixels -= 16)
{
asm volatile (" movdqu %0,%%xmm0\n" : :"m" (op.A[0]) : "%xmm0");
asm volatile (" movdqu %0,%%xmm1\n" : :"m" (op.B[0]) : "%xmm1");
asm volatile (" movdqu %0,%%xmm2\n" : :"m" (op.A[1]) : "%xmm2");
asm volatile (" movdqu %0,%%xmm3\n" : :"m" (op.B[1]) : "%xmm3");
asm volatile (" movdqu %0,%%xmm4\n" : :"m" (op.A[2]) : "%xmm4");
asm volatile (" movdqu %0,%%xmm5\n" : :"m" (op.B[2]) : "%xmm5");
asm volatile (" movdqu %0,%%xmm6\n" : :"m" (op.A[3]) : "%xmm6");
asm volatile (" movdqu %0,%%xmm7\n" : :"m" (op.B[3]) : "%xmm7");
asm volatile ("\tmovdqu %%xmm0,%0\n" : "=m" (op.A[0]));
asm volatile ("\tmovdqu %%xmm1,%0\n" : "=m" (op.B[0]));
asm volatile ("\tmovdqu %%xmm2,%0\n" : "=m" (op.A[1]));
asm volatile ("\tmovdqu %%xmm3,%0\n" : "=m" (op.B[1]));
asm volatile ("\tmovdqu %%xmm4,%0\n" : "=m" (op.A[2]));
asm volatile ("\tmovdqu %%xmm5,%0\n" : "=m" (op.B[2]));
asm volatile ("\tmovdqu %%xmm6,%0\n" : "=m" (op.A[3]));
asm volatile ("\tmovdqu %%xmm7,%0\n" : "=m" (op.B[3]));
op.A += 64;
op.B += 64;
}
for (; op.n_pixels >= 4; op.n_pixels -= 4)
{
asm volatile (" movdqu %0,%%xmm2\n"
"\tmovdqu %1,%%xmm3\n"
"\tmovdqu %%xmm3,%0\n"
"\tmovdqu %%xmm2,%1\n"
: "+m" (*op.A), "+m" (*op.B)
: /* empty */
: "%xmm2", "%xmm3");
op.A += 16;
op.B += 16;
}
for (; op.n_pixels >= 2; op.n_pixels -= 2)
{
asm volatile (" movq %0,%%mm2\n"
"\tmovq %1,%%mm3\n"
"\tmovq %%mm3,%0\n"
"\tmovntq %%mm2,%1\n"
: "+m" (*op.A), "+m" (*op.B)
: /* empty */
: "%mm2", "%mm3");
op.A += 8;
op.B += 8;
}
if (op.n_pixels)
{
asm volatile (" movd %0,%%mm2\n"
"\tmovd %1,%%mm3\n"
"\tmovd %%mm3,%0\n"
"\tmovd %%mm2,%1\n"
: "+m" (*op.A), "+m" (*op.B)
: /* empty */
: "%mm3", "%mm4");
}
asm("emms");
}
#endif /* COMPILE_SSE2_IS_OKAY */

View File

@ -1,34 +0,0 @@
#ifndef gimp_composite_sse2_h
#define gimp_composite_sse2_h
extern gboolean gimp_composite_sse2_init (void);
/*
* The function gimp_composite_*_install() is defined in the code generated by make-install.py
* I hate to create a .h file just for that declaration, so I do it here (for now).
*/
extern gboolean gimp_composite_sse2_install (void);
#if !defined(__INTEL_COMPILER) || defined(USE_INTEL_COMPILER_ANYWAY)
#if defined(USE_SSE)
#if defined(ARCH_X86)
#if __GNUC__ >= 3
#if defined(ARCH_X86_64) || (!defined(PIC) && !defined(__PIC__))
#define COMPILE_SSE2_IS_OKAY (1)
#endif /* defined(ARCH_X86_64) || (!defined(PIC) && !defined(__PIC__)) */
#endif /* __GNUC__ >= 3*/
#endif /* defined(ARCH_X86) */
#endif /* defined(USE_SSE) */
#endif /* !defined(__INTEL_COMPILER) */
#ifdef COMPILE_SSE2_IS_OKAY
extern void gimp_composite_addition_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *ctx);
extern void gimp_composite_darken_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *ctx);
extern void gimp_composite_difference_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *ctx);
extern void gimp_composite_grain_extract_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *ctx);
extern void gimp_composite_lighten_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *ctx);
extern void gimp_composite_subtract_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *ctx);
extern void gimp_composite_swap_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *ctx);
extern void gimp_composite_dodge_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *ctx);
#endif
#endif

View File

@ -1,84 +0,0 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-regression.h"
#include "gimp-composite-util.h"
#include "gimp-composite-generic.h"
static int
gimp_composite_regression(int iterations, int n_pixels)
{
GimpCompositeContext generic_ctx;
GimpCompositeContext special_ctx;
double ft0;
double ft1;
gimp_rgba8_t *rgba8D1;
gimp_rgba8_t *rgba8D2;
gimp_rgba8_t *rgba8A;
gimp_rgba8_t *rgba8B;
gimp_rgba8_t *rgba8M;
gimp_va8_t *va8A;
gimp_va8_t *va8B;
gimp_va8_t *va8M;
gimp_va8_t *va8D1;
gimp_va8_t *va8D2;
int i;
rgba8A = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
rgba8B = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
rgba8M = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
rgba8D1 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
rgba8D2 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
va8A = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8B = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8M = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D1 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D2 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
for (i = 0; i < n_pixels; i++) {
rgba8A[i].r = 255-i;
rgba8A[i].g = 255-i;
rgba8A[i].b = 255-i;
rgba8A[i].a = 255-i;
rgba8B[i].r = i;
rgba8B[i].g = i;
rgba8B[i].b = i;
rgba8B[i].a = i;
rgba8M[i].r = i;
rgba8M[i].g = i;
rgba8M[i].b = i;
rgba8M[i].a = i;
va8A[i].v = i;
va8A[i].a = 255-i;
va8B[i].v = i;
va8B[i].a = i;
va8M[i].v = i;
va8M[i].a = i;
}
return EXIT_SUCCESS;
}
int
main(int argc, char *argv[])
{
int iterations;
int n_pixels;
srand(314159);
iterations = 1;
n_pixels = 256*256;
return gimp_composite_regression (iterations, n_pixels);
}

View File

@ -1,33 +0,0 @@
#ifndef __GIMP_COMPOSITE_UTIL_H__
#define __GIMP_COMPOSITE_UTIL_H__
typedef struct
{
guchar r;
guchar g;
guchar b;
guchar a;
} rgba8_t;
typedef struct
{
guchar r;
guchar g;
guchar b;
} rgb8_t;
typedef struct
{
guchar v;
} v8_t;
typedef struct
{
guchar v;
guchar a;
} va8_t;
extern int gimp_composite_bpp[];
#endif /* __GIMP_COMPOSITE_UTIL_H__ */

View File

@ -1,29 +0,0 @@
/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */
/* REGENERATE BY USING make-installer.py */
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-vis.h"
gboolean
gimp_composite_vis_install (void)
{
/* nothing to do */
return (FALSE);
}
gboolean
gimp_composite_vis_init (void)
{
#if defined(COMPILE_VIS_IS_OKAY)
return (TRUE);
#else
return (FALSE);
#endif
}

View File

@ -1,105 +0,0 @@
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-regression.h"
#include "gimp-composite-util.h"
#include "gimp-composite-generic.h"
#include "gimp-composite-vis.h"
static int
gimp_composite_vis_test (int iterations, int n_pixels)
{
#if defined(COMPILE_VIS_IS_OKAY)
GimpCompositeContext generic_ctx;
GimpCompositeContext special_ctx;
double ft0;
double ft1;
gimp_rgba8_t *rgba8D1;
gimp_rgba8_t *rgba8D2;
gimp_rgba8_t *rgba8A;
gimp_rgba8_t *rgba8B;
gimp_rgba8_t *rgba8M;
gimp_va8_t *va8A;
gimp_va8_t *va8B;
gimp_va8_t *va8M;
gimp_va8_t *va8D1;
gimp_va8_t *va8D2;
int i;
if (gimp_composite_vis_init () == 0)
{
g_print ("\ngimp_composite_vis: Instruction set is not available.\n");
return EXIT_SUCCESS;
}
g_print ("\nRunning gimp_composite_vis tests...\n");
rgba8A = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8B = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8M = gimp_composite_regression_random_rgba8(n_pixels+1);
rgba8D1 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
rgba8D2 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);
va8A = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8B = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8M = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D1 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
va8D2 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);
for (i = 0; i < n_pixels; i++)
{
va8A[i].v = i;
va8A[i].a = 255-i;
va8B[i].v = i;
va8B[i].a = i;
va8M[i].v = i;
va8M[i].a = i;
}
#endif
return EXIT_SUCCESS;
}
int
main (int argc, char *argv[])
{
int iterations;
int n_pixels;
srand (314159);
g_setenv ("GIMP_COMPOSITE", "0x1", TRUE);
iterations = 10;
n_pixels = 8388625;
argv++, argc--;
while (argc >= 2)
{
if (argc > 1 && (strcmp (argv[0], "--iterations") == 0 || strcmp (argv[0], "-i") == 0))
{
iterations = atoi(argv[1]);
argc -= 2, argv++; argv++;
}
else if (argc > 1 && (strcmp (argv[0], "--n-pixels") == 0 || strcmp (argv[0], "-n") == 0))
{
n_pixels = atoi (argv[1]);
argc -= 2, argv++; argv++;
}
else
{
g_print ("Usage: gimp-composites-*-test [-i|--iterations n] [-n|--n-pixels n]");
return EXIT_FAILURE;
}
}
gimp_composite_generic_install ();
return (gimp_composite_vis_test (iterations, n_pixels));
}

View File

@ -1,34 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Gimp image compositing
* Copyright (C) 2003 Helvetix Victorinox, a pseudonym, <helvetix@gimp.org>
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-vis.h"
#ifdef COMPILE_VIS_IS_OKAY
#endif

View File

@ -1,20 +0,0 @@
#ifndef gimp_composite_vis_h
#define gimp_composite_vis_h
extern gboolean gimp_composite_vis_init (void);
/*
* The function gimp_composite_*_install() is defined in the code generated by make-install.py
* I hate to create a .h file just for that declaration, so I do it here (for now).
*/
extern gboolean gimp_composite_vis_install (void);
#if defined(USE_VIS)
#if defined(ARCH_SPARC)
#if __GNUC__ >= 3
#define COMPILE_VIS_IS_OKAY (1)
#endif /* __GNUC__ > 3 */
#endif /* defined(ARCH_SPARC) */
#endif /* defined(USE_VIS) */
#endif

View File

@ -1,244 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if __GNUC__ >= 3
/*
* Convert the low 8bit byte of the src to 16bit words in dst.
*/
#define mmx_low_bytes_to_words(src,dst,zero) \
"\tmovq %%"#src", %%"#dst"\n" \
"\tpunpcklbw %%"#zero", %%"#dst"\n"
/*
* Convert the high 8bit byte of the src to 16bit words in dst.
*/
#define mmx_high_bytes_to_words(src,dst,zero) \
"\tmovq %%"#src", %%"#dst"\n" \
"\tpunpckhbw %%"#zero", %%"#dst"\n"
#define xmm_low_bytes_to_words(src,dst,zero) \
"\tmovdqu %%"#src", %%"#dst"; " \
"\tpunpcklbw %%"#zero", %%"#dst"\n"
#define xmm_high_bytes_to_words(src,dst,zero) \
"\tmovdqu %%"#src", %%"#dst"; " \
"\tpunpckhbw %%"#zero", %%"#dst"\n"
/* a = INT_MULT(a,b) */
#define mmx_int_mult(a,b,w128) \
"\tpmullw %%"#b", %%"#a"; " \
"\tpaddw %%"#w128", %%"#a"; " \
"\tmovq %%"#a", %%"#b"; " \
"\tpsrlw $8, %%"#b"; " \
"\tpaddw %%"#a", %%"#b"; " \
"\tpsrlw $8, %%"#b"\n"
#define sse2_int_mult(a,b,w128) \
"\tpmullw %%"#b", %%"#a"; " \
"\tpaddw %%"#w128", %%"#a"; " \
"\tmovdqu %%"#a", %%"#b"; " \
"\tpsrlw $8, %%"#b"; " \
"\tpaddw %%"#a", %%"#b"; " \
"\tpsrlw $8, %%"#b"\n"
/*
* Double-word divide. Adjusted for subsequent unsigned packing
* (high-order bit of each word is cleared)
* Clobbers eax, ecx edx
*/
#define pdivwX(dividend,divisor,quotient) "movd %%" #dividend ",%%eax\n" \
"movd %%" #divisor ",%%ecx\n" \
"xorl %%edx,%%edx\n" \
"divw %%cx\n" \
"roll $16, %%eax\n" \
"roll $16, %%ecx\n" \
"xorl %%edx,%%edx\n" \
"divw %%cx\n" \
"btr $15, %%eax\n" \
"roll $16, %%eax\n" \
"btr $15, %%eax\n" \
"movd %%eax,%%" #quotient "\n"
/*
* Quadword divide. No adjustment for subsequent unsigned packing
* (high-order bit of each word is left alone)
* clobber list must include: "%eax", "%ecx", "%edx", divisor quotient
*/
#define pdivwqX(dividend,divisor,quotient) "movd %%" #dividend ",%%eax; " \
"movd %%" #divisor ",%%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"roll $16, %%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"movd %%eax,%%" #quotient "; " \
"psrlq $32,%%" #dividend ";" \
"psrlq $32,%%" #divisor ";" \
"movd %%" #dividend ",%%eax; " \
"movd %%" #divisor ",%%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"roll $16, %%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"movd %%eax,%%" #divisor ";" \
"psllq $32,%%" #divisor ";" \
"por %%" #divisor ",%%" #quotient ";"
#define pdivwqX_clobber "%eax", "%ecx", "%edx", "%cc"
/*
* Quadword divide. Adjusted for subsequent unsigned packing
* (high-order bit of each word is cleared)
*/
#define pdivwuqX(dividend,divisor,quotient) \
pdivwX(dividend,divisor,quotient) \
"psrlq $32,%%" #dividend ";" \
"psrlq $32,%%" #divisor ";" \
pdivwX(dividend,divisor,quotient) \
"movd %%eax,%%" #divisor ";" \
"psllq $32,%%" #divisor ";" \
"por %%" #divisor ",%%" #quotient ";"
#define pdivwuqX_clobber pdivwqX_clobber
#define xmm_pdivwqX(dividend,divisor,quotient,scratch) "movd %%" #dividend ",%%eax; " \
"movd %%" #divisor ",%%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"roll $16, %%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"movd %%eax,%%" #quotient "; " \
"psrlq $32,%%" #divisor ";" \
"psrlq $32,%%" #dividend ";" \
"movd %%" #dividend ",%%eax; " \
"movd %%" #divisor ",%%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"roll $16, %%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"movd %%eax,%%" #scratch ";" \
"psllq $32,%%" #scratch ";" \
"psrlq $32,%%" #divisor ";" \
"psrlq $32,%%" #dividend ";" \
"movd %%" #dividend ",%%eax; " \
"movd %%" #divisor ",%%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"roll $16, %%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"movd %%eax,%%" #scratch ";" \
"psllq $64,%%" #scratch ";" \
"psrlq $32,%%" #divisor ";" \
"psrlq $32,%%" #dividend ";" \
"movd %%" #dividend ",%%eax; " \
"movd %%" #divisor ",%%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"roll $16, %%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"movd %%eax,%%" #scratch ";" \
"psllq $96,%%" #scratch ";" \
"por %%" #scratch ",%%" #quotient ";"
#define xmm_pdivwX(dividend,divisor,quotient) "movd %%" #dividend ",%%eax; " \
"movd %%" #divisor ",%%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"roll $16, %%eax; " \
"roll $16, %%ecx; " \
"xorl %%edx,%%edx; " \
"divw %%cx; " \
"btr $15, %%eax; " \
"roll $16, %%eax; " \
"btr $15, %%eax; " \
"movd %%eax,%%" #quotient ";"
#define xmm_pdivwuqX(dividend,divisor,quotient,scratch) \
xmm_pdivwX(dividend,divisor,scratch) \
"movd %%"#scratch ",%%"#quotient ";" \
"psrlq $32,%%"#dividend ";" \
"psrlq $32,%%"#divisor ";" \
xmm_pdivwX(dividend,divisor,scratch) \
"psllq $32,%%"#scratch ";" \
"por %%"#scratch ",%%"#quotient ";" \
"psrlq $32,%%"#dividend ";" \
"psrlq $32,%%"#divisor ";" \
xmm_pdivwX(dividend,divisor,scratch) \
"psllq $64,%%"#scratch ";" \
"por %%"#scratch ",%%"#quotient ";" \
"psrlq $32,%%"#dividend ";" \
"psrlq $32,%%"#divisor ";" \
xmm_pdivwX(dividend,divisor,scratch) \
"psllq $96,%%"#scratch ";" \
"por %%"#scratch ",%%"#quotient
/* equivalent to the INT_MULT() macro in gimp-composite-generic.c */
/*
* opr2 = INT_MULT(opr1, opr2, t)
*
* Operates across quad-words using x86 word (16bit) value.
* Result is left in opr2
*
* opr1 = opr1 * opr2 + w128
* opr2 = opr1
* opr2 = ((opr2 >> 8) + opr1) >> 8
*/
#define pmulwX(opr1,opr2,w128) \
"\tpmullw %%"#opr2", %%"#opr1"; " \
"\tpaddw %%"#w128", %%"#opr1"; " \
"\tmovq %%"#opr1", %%"#opr2"; " \
"\tpsrlw $8, %%"#opr2"; " \
"\tpaddw %%"#opr1", %%"#opr2"; " \
"\tpsrlw $8, %%"#opr2"\n"
#define xmm_pmulwX(opr1,opr2,w128) \
"\tpmullw %%"#opr2", %%"#opr1"; " \
"\tpaddw %%"#w128", %%"#opr1"; " \
"\tmovdqu %%"#opr1", %%"#opr2"; " \
"\tpsrlw $8, %%"#opr2"; " \
"\tpaddw %%"#opr1", %%"#opr2"; " \
"\tpsrlw $8, %%"#opr2"\n"
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned long uint32;
typedef unsigned long long uint64;
typedef struct { uint64 __uint64[2]; } uint128;
extern const guint32 va8_alpha_mask[2];
extern const guint32 va8_b255[2];
extern const guint32 va8_w1[2];
extern const guint32 va8_w255[2];
#endif /* __GNUC__ >= 3 */

View File

@ -1,389 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Gimp image compositing
* Copyright (C) 2003 Helvetix Victorinox, a pseudonym, <helvetix@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <glib-object.h>
#include "base/base-types.h"
#include "gimp-composite.h"
#include "gimp-composite-generic.h"
#ifdef ARCH_X86
#include "gimp-composite-mmx.h"
#include "gimp-composite-sse.h"
#endif
/*
* Details about pixel formats, bits-per-pixel alpha and non alpha
* versions of pixel formats.
*/
/*
* Report on the number of bytes a particular pixel format consumes per pixel.
*/
const guchar gimp_composite_pixel_bpp[] =
{
1, /* GIMP_PIXELFORMAT_V8 */
2, /* GIMP_PIXELFORMAT_VA8 */
3, /* GIMP_PIXELFORMAT_RGB8 */
4, /* GIMP_PIXELFORMAT_RGBA8 */
#if GIMP_COMPOSITE_16BIT
2, /* GIMP_PIXELFORMAT_V16 */
4, /* GIMP_PIXELFORMAT_VA16 */
6, /* GIMP_PIXELFORMAT_RGB16 */
8, /* GIMP_PIXELFORMAT_RGBA16 */
#endif
#if GIMP_COMPOSITE_32BIT
2, /* GIMP_PIXELFORMAT_V32 */
4, /* GIMP_PIXELFORMAT_VA32 */
6, /* GIMP_PIXELFORMAT_RGB32 */
8, /* GIMP_PIXELFORMAT_RGBA32 */
#endif
0, /* GIMP_PIXELFORMAT_ANY */
};
/*
* Report true (non-zero) if a pixel format has alpha.
*/
const guchar gimp_composite_pixel_alphap[] =
{
0, /* GIMP_PIXELFORMAT_V8 */
1, /* GIMP_PIXELFORMAT_VA8 */
0, /* GIMP_PIXELFORMAT_RGB8 */
1, /* GIMP_PIXELFORMAT_RGBA8 */
#if GIMP_COMPOSITE_16BIT
0, /* GIMP_PIXELFORMAT_V16 */
1, /* GIMP_PIXELFORMAT_VA16 */
0, /* GIMP_PIXELFORMAT_RGB16 */
1, /* GIMP_PIXELFORMAT_RGBA16 */
#endif
#if GIMP_COMPOSITE_32BIT
0, /* GIMP_PIXELFORMAT_V32 */
1, /* GIMP_PIXELFORMAT_VA32 */
0, /* GIMP_PIXELFORMAT_RGB32 */
1, /* GIMP_PIXELFORMAT_RGBA32 */
#endif
0, /* GIMP_PIXELFORMAT_UNKNOWN */
};
/*
* Convert to/from pixel formats with/without alpha.
*/
const GimpPixelFormat gimp_composite_pixel_alpha[] =
{
GIMP_PIXELFORMAT_VA8, /* GIMP_PIXELFORMAT_V8 */
GIMP_PIXELFORMAT_V8, /* GIMP_PIXELFORMAT_VA8 */
GIMP_PIXELFORMAT_RGBA8, /* GIMP_PIXELFORMAT_RGB8 */
GIMP_PIXELFORMAT_RGB8, /* GIMP_PIXELFORMAT_RGBA8 */
#if GIMP_COMPOSITE_16BIT
GIMP_PIXELFORMAT_VA16,
GIMP_PIXELFORMAT_V16,
GIMP_PIXELFORMAT_RGBA16,
GIMP_PIXELFORMAT_RGB16
#endif
#if GIMP_COMPOSITE_32BIT
GIMP_PIXELFORMAT_VA32,
GIMP_PIXELFORMAT_V32,
GIMP_PIXELFORMAT_RGBA32,
GIMP_PIXELFORMAT_RGB32
#endif
GIMP_PIXELFORMAT_ANY, /* GIMP_PIXELFORMAT_ANY */
};
/*
* XXX I don't like to put this here. I think this information,
* specific to the functions, ought to be with the function.
*/
struct GimpCompositeOperationEffects gimp_composite_operation_effects[] =
{
{ TRUE, TRUE, FALSE, }, /* GIMP_NORMAL_MODE */
{ TRUE, TRUE, FALSE, }, /* GIMP_DISSOLVE_MODE */
{ TRUE, TRUE, FALSE, }, /* GIMP_BEHIND_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_MULTIPLY_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_SCREEN_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_OVERLAY_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_DIFFERENCE_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_ADDITION_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_SUBTRACT_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_DARKEN_ONLY_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_LIGHTEN_ONLY_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_HUE_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_SATURATION_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_COLOR_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_VALUE_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_DIVIDE_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_DODGE_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_BURN_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_HARDLIGHT_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_SOFTLIGHT_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_GRAIN_EXTRACT_MODE */
{ FALSE, FALSE, FALSE, }, /* GIMP_GRAIN_MERGE_MODE */
{ TRUE, FALSE, TRUE, }, /* GIMP_COLOR_ERASE_MODE */
{ TRUE, FALSE, TRUE, }, /* GIMP_ERASE_MODE */
{ TRUE, TRUE, TRUE, }, /* GIMP_REPLACE_MODE */
{ TRUE, TRUE, FALSE, }, /* GIMP_ANTI_ERASE_MODE */
{ FALSE, FALSE, FALSE }, /* GIMP_SWAP */
{ FALSE, FALSE, FALSE }, /* GIMP_SCALE */
{ FALSE, FALSE, FALSE }, /* GIMP_CONVERT */
};
struct GimpCompositeOptions gimp_composite_options =
{
0
};
const gchar * gimp_composite_function_name[GIMP_COMPOSITE_N][GIMP_PIXELFORMAT_N][GIMP_PIXELFORMAT_N][GIMP_PIXELFORMAT_N];
void (* gimp_composite_function[GIMP_COMPOSITE_N][GIMP_PIXELFORMAT_N][GIMP_PIXELFORMAT_N][GIMP_PIXELFORMAT_N])(GimpCompositeContext *);
/**
* gimp_composite_dispatch:
* @ctx: The compositing context
*
* Given a compositing context, perform the compositing function
* dictated by the compositing context operation. There is no return
* value, all results are in the compositing context.
**/
void
gimp_composite_dispatch (GimpCompositeContext *ctx)
{
void (* function) (GimpCompositeContext *);
function = gimp_composite_function[ctx->op][ctx->pixelformat_A][ctx->pixelformat_B][ctx->pixelformat_D];
if (function)
{
if (gimp_composite_options.bits & GIMP_COMPOSITE_OPTION_VERBOSE)
{
g_print ("%s %s %s %s = %p\n",
gimp_composite_mode_astext (ctx->op),
gimp_composite_pixelformat_astext (ctx->pixelformat_A),
gimp_composite_pixelformat_astext (ctx->pixelformat_B),
gimp_composite_pixelformat_astext (ctx->pixelformat_D),
function);
}
function (ctx);
}
else
{
g_print ("gimp_composite: unsupported operation: %s %s %s %s\n",
gimp_composite_mode_astext (ctx->op),
gimp_composite_pixelformat_astext (ctx->pixelformat_A),
gimp_composite_pixelformat_astext (ctx->pixelformat_B),
gimp_composite_pixelformat_astext (ctx->pixelformat_D));
}
}
/**
* gimp_composite_context_print:
* @ctx: The context to print
*
* Print a human readable form of a GimpCompositeContext on stdout.
**/
void
gimp_composite_context_print (GimpCompositeContext *ctx)
{
g_print ("%p: op=%s\n A=%s(%d):%p\n B=%s(%d):%p\n D=%s(%d):%p\n M=%s(%d):%p\n n_pixels=%lu\n",
ctx,
gimp_composite_mode_astext (ctx->op),
gimp_composite_pixelformat_astext (ctx->pixelformat_A),
ctx->pixelformat_A, ctx->A,
gimp_composite_pixelformat_astext (ctx->pixelformat_B),
ctx->pixelformat_B, ctx->B,
gimp_composite_pixelformat_astext (ctx->pixelformat_D),
ctx->pixelformat_D, ctx->D,
gimp_composite_pixelformat_astext (ctx->pixelformat_M),
ctx->pixelformat_M, ctx->M,
ctx->n_pixels);
}
/**
* gimp_composite_mode_astext:
* @op:
*
* Given a GimpCompositeOperatin, return a string representation of the name
* of that operation.
*
* Returns: gchar *, the name
**/
const gchar *
gimp_composite_mode_astext (GimpCompositeOperation op)
{
switch (op)
{
case GIMP_COMPOSITE_NORMAL: return ("GIMP_COMPOSITE_NORMAL");
case GIMP_COMPOSITE_DISSOLVE: return ("GIMP_COMPOSITE_DISSOLVE");
case GIMP_COMPOSITE_BEHIND: return ("GIMP_COMPOSITE_BEHIND");
case GIMP_COMPOSITE_MULTIPLY: return ("GIMP_COMPOSITE_MULTIPLY");
case GIMP_COMPOSITE_SCREEN: return ("GIMP_COMPOSITE_SCREEN");
case GIMP_COMPOSITE_OVERLAY: return ("GIMP_COMPOSITE_OVERLAY");
case GIMP_COMPOSITE_DIFFERENCE: return ("GIMP_COMPOSITE_DIFFERENCE");
case GIMP_COMPOSITE_ADDITION: return ("GIMP_COMPOSITE_ADDITION");
case GIMP_COMPOSITE_SUBTRACT: return ("GIMP_COMPOSITE_SUBTRACT");
case GIMP_COMPOSITE_DARKEN: return ("GIMP_COMPOSITE_DARKEN");
case GIMP_COMPOSITE_LIGHTEN: return ("GIMP_COMPOSITE_LIGHTEN");
case GIMP_COMPOSITE_HUE: return ("GIMP_COMPOSITE_HUE");
case GIMP_COMPOSITE_SATURATION: return ("GIMP_COMPOSITE_SATURATION");
case GIMP_COMPOSITE_COLOR_ONLY: return ("GIMP_COMPOSITE_COLOR_ONLY");
case GIMP_COMPOSITE_VALUE: return ("GIMP_COMPOSITE_VALUE");
case GIMP_COMPOSITE_DIVIDE: return ("GIMP_COMPOSITE_DIVIDE");
case GIMP_COMPOSITE_DODGE: return ("GIMP_COMPOSITE_DODGE");
case GIMP_COMPOSITE_BURN: return ("GIMP_COMPOSITE_BURN");
case GIMP_COMPOSITE_HARDLIGHT: return ("GIMP_COMPOSITE_HARDLIGHT");
case GIMP_COMPOSITE_SOFTLIGHT: return ("GIMP_COMPOSITE_SOFTLIGHT");
case GIMP_COMPOSITE_GRAIN_EXTRACT: return ("GIMP_COMPOSITE_GRAIN_EXTRACT");
case GIMP_COMPOSITE_GRAIN_MERGE: return ("GIMP_COMPOSITE_GRAIN_MERGE");
case GIMP_COMPOSITE_COLOR_ERASE: return ("GIMP_COMPOSITE_COLOR_ERASE");
case GIMP_COMPOSITE_ERASE: return ("GIMP_COMPOSITE_ERASE");
case GIMP_COMPOSITE_REPLACE: return ("GIMP_COMPOSITE_REPLACE");
case GIMP_COMPOSITE_ANTI_ERASE: return ("GIMP_COMPOSITE_ANTI_ERASE");
case GIMP_COMPOSITE_BLEND: return ("GIMP_COMPOSITE_BLEND");
case GIMP_COMPOSITE_SHADE: return ("GIMP_COMPOSITE_SHADE");
case GIMP_COMPOSITE_SWAP: return ("GIMP_COMPOSITE_SWAP");
case GIMP_COMPOSITE_SCALE: return ("GIMP_COMPOSITE_SCALE");
case GIMP_COMPOSITE_CONVERT: return ("GIMP_COMPOSITE_CONVERT");
case GIMP_COMPOSITE_XOR: return ("GIMP_COMPOSITE_XOR");
default:
break;
}
return ("bad mode");
}
/**
* gimp_composite_pixelformat_astext:
* @format: The format.
*
* Given a GimpPixelFormat, return a string representation of the name
* of that format.
*
* Returns: gchar *, the name
**/
const gchar *
gimp_composite_pixelformat_astext (GimpPixelFormat format)
{
switch (format) {
case GIMP_PIXELFORMAT_V8: return ("V8");
case GIMP_PIXELFORMAT_VA8: return ("VA8");
case GIMP_PIXELFORMAT_RGB8: return ("RGB8");
case GIMP_PIXELFORMAT_RGBA8: return ("RGBA8");
#if GIMP_COMPOSITE_16BIT
case GIMP_PIXELFORMAT_V16: return ("V16");
case GIMP_PIXELFORMAT_VA16: return ("VA16");
case GIMP_PIXELFORMAT_RGB16: return ("RGB16");
case GIMP_PIXELFORMAT_RGBA16: return ("RGBA16");
#endif
#if GIMP_COMPOSITE_32BIT
case GIMP_PIXELFORMAT_V32: return ("V32");
case GIMP_PIXELFORMAT_VA32: return ("VA32");
case GIMP_PIXELFORMAT_RGB32: return ("RGB32");
case GIMP_PIXELFORMAT_RGBA32: return ("RGBA32");
#endif
case GIMP_PIXELFORMAT_ANY: return ("ANY");
default:
break;
}
return ("bad format");
}
/**
* gimp_composite_init:
* @be_verbose: whether to be verbose on stdout
* @use_cpu_accel: whether to use accelerated routines like MMX
*
* Initialise the Gimp Compositing subsystem. This includes checking
* for user options and environment, installing the generic set of
* compositing operation handlers, followed by overloading those which
* are supported by the current cpu/hardware.
**/
void
gimp_composite_init (gboolean be_verbose,
gboolean use_cpu_accel)
{
const gchar *p;
if ((p = g_getenv ("GIMP_COMPOSITE")))
{
gimp_composite_options.bits = strtoul(p, NULL, 16);
}
if (! use_cpu_accel)
gimp_composite_options.bits |= GIMP_COMPOSITE_OPTION_NOEXTENSIONS;
if (be_verbose)
g_printerr ("gimp_composite: verbose=%s\n",
(gimp_composite_options.bits & GIMP_COMPOSITE_OPTION_VERBOSE) ?
"yes" : "no");
gimp_composite_generic_install ();
/*
* Here is where you "glue" in the initialisation of your
* optimisations.
*
* Declare the install() function external, and then call it. A
* return value of TRUE from the install function means the
* installer was successful in instantiating itself. For example,
* it succeeded in hooking in the functions with the special
* optimisation instructions, or hardware, or whatever.
*/
if (! (gimp_composite_options.bits & GIMP_COMPOSITE_OPTION_NOEXTENSIONS))
{
extern gboolean gimp_composite_mmx_install (void);
extern gboolean gimp_composite_sse_install (void);
extern gboolean gimp_composite_sse2_install (void);
extern gboolean gimp_composite_3dnow_install (void);
extern gboolean gimp_composite_altivec_install (void);
extern gboolean gimp_composite_vis_install (void);
gboolean can_use_mmx = gimp_composite_mmx_install ();
gboolean can_use_sse = gimp_composite_sse_install ();
gboolean can_use_sse2 = gimp_composite_sse2_install ();
gboolean can_use_3dnow = gimp_composite_3dnow_install ();
gboolean can_use_altivec = gimp_composite_altivec_install ();
gboolean can_use_vis = gimp_composite_vis_install ();
if (be_verbose)
g_printerr ("Processor instruction sets: "
"%cmmx %csse %csse2 %c3dnow %caltivec %cvis\n",
can_use_mmx ? '+' : '-',
can_use_sse ? '+' : '-',
can_use_sse2 ? '+' : '-',
can_use_3dnow ? '+' : '-',
can_use_altivec ? '+' : '-',
can_use_vis ? '+' : '-');
}
}
gboolean
gimp_composite_use_cpu_accel (void)
{
return ! (gimp_composite_options.bits & GIMP_COMPOSITE_OPTION_NOEXTENSIONS);
}

View File

@ -1,170 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Gimp Image Compositing
* Copyright (C) 2003 Helvetix Victorinox, a pseudonym, <helvetix@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_COMPOSITE_H__
#define __GIMP_COMPOSITE_H__
typedef enum
{
GIMP_PIXELFORMAT_V8,
GIMP_PIXELFORMAT_VA8,
GIMP_PIXELFORMAT_RGB8,
GIMP_PIXELFORMAT_RGBA8,
GIMP_PIXELFORMAT_ANY,
GIMP_PIXELFORMAT_N
} GimpPixelFormat;
/*
* gtk-doc is unhappy with these #ifdef's inside the enumeration.
*
#ifdef GIMP_COMPOSITE_16BIT
GIMP_PIXELFORMAT_V16,
GIMP_PIXELFORMAT_VA16,
GIMP_PIXELFORMAT_RGB16,
GIMP_PIXELFORMAT_RGBA16,
#endif
#ifdef GIMP_COMPOSITE_32BIT
GIMP_PIXELFORMAT_V32,
GIMP_PIXELFORMAT_VA32,
GIMP_PIXELFORMAT_RGB32,
GIMP_PIXELFORMAT_RGBA32,
#endif
*
*/
/* bytes per-pixel for each of the pixel formats */
extern const guchar gimp_composite_pixel_bpp[];
/* does pixel format have alpha? */
extern const guchar gimp_composite_pixel_alphap[];
/* converter between alpha and non-alpha pixel formats */
extern const GimpPixelFormat gimp_composite_pixel_alpha[];
#define GIMP_COMPOSITE_ALPHA_OPAQUE (-1)
#define GIMP_COMPOSITE_ALPHA_TRANSPARENT (0)
/*
* This is the enumeration of all the supported compositing
* operations. Many of them are taken from the GimpLayerModeEffect
* enumeration, but there are (possibly more) implemented. Here is
* where they are all enumerated.
*
* Nota Bene: Unfortunately, the order here is important!
*/
typedef enum
{
GIMP_COMPOSITE_NORMAL = GIMP_NORMAL_MODE,
GIMP_COMPOSITE_DISSOLVE = GIMP_DISSOLVE_MODE,
GIMP_COMPOSITE_BEHIND = GIMP_BEHIND_MODE,
GIMP_COMPOSITE_MULTIPLY = GIMP_MULTIPLY_MODE,
GIMP_COMPOSITE_SCREEN = GIMP_SCREEN_MODE,
GIMP_COMPOSITE_OVERLAY = GIMP_OVERLAY_MODE,
GIMP_COMPOSITE_DIFFERENCE = GIMP_DIFFERENCE_MODE,
GIMP_COMPOSITE_ADDITION = GIMP_ADDITION_MODE,
GIMP_COMPOSITE_SUBTRACT = GIMP_SUBTRACT_MODE,
GIMP_COMPOSITE_DARKEN = GIMP_DARKEN_ONLY_MODE,
GIMP_COMPOSITE_LIGHTEN = GIMP_LIGHTEN_ONLY_MODE,
GIMP_COMPOSITE_HUE = GIMP_HUE_MODE,
GIMP_COMPOSITE_SATURATION = GIMP_SATURATION_MODE,
GIMP_COMPOSITE_COLOR_ONLY = GIMP_COLOR_MODE,
GIMP_COMPOSITE_VALUE = GIMP_VALUE_MODE,
GIMP_COMPOSITE_DIVIDE = GIMP_DIVIDE_MODE,
GIMP_COMPOSITE_DODGE = GIMP_DODGE_MODE,
GIMP_COMPOSITE_BURN = GIMP_BURN_MODE,
GIMP_COMPOSITE_HARDLIGHT = GIMP_HARDLIGHT_MODE,
GIMP_COMPOSITE_SOFTLIGHT = GIMP_SOFTLIGHT_MODE,
GIMP_COMPOSITE_GRAIN_EXTRACT = GIMP_GRAIN_EXTRACT_MODE,
GIMP_COMPOSITE_GRAIN_MERGE = GIMP_GRAIN_MERGE_MODE,
GIMP_COMPOSITE_COLOR_ERASE = GIMP_COLOR_ERASE_MODE,
GIMP_COMPOSITE_ERASE = GIMP_ERASE_MODE,
GIMP_COMPOSITE_REPLACE = GIMP_REPLACE_MODE,
GIMP_COMPOSITE_ANTI_ERASE = GIMP_ANTI_ERASE_MODE,
GIMP_COMPOSITE_BLEND,
GIMP_COMPOSITE_SHADE,
GIMP_COMPOSITE_SWAP,
GIMP_COMPOSITE_SCALE,
GIMP_COMPOSITE_CONVERT,
GIMP_COMPOSITE_XOR,
GIMP_COMPOSITE_N
} GimpCompositeOperation;
struct GimpCompositeOperationEffects
{
guchar affect_opacity;
guchar increase_opacity;
guchar decrease_opacity;
};
extern struct GimpCompositeOperationEffects gimp_composite_operation_effects[];
/*
* This is structure for communicating all that is necessary to a
* compositing operation.
*/
typedef struct
{
guchar *A; /* Source A */
guchar *B; /* Source B */
guchar *D; /* Destination */
const guchar *M; /* Mask */
gulong n_pixels;
GimpPixelFormat pixelformat_A;
GimpPixelFormat pixelformat_B;
GimpPixelFormat pixelformat_D;
GimpPixelFormat pixelformat_M;
struct { gint opacity; gchar affect; } replace;
struct { gint scale; } scale;
struct { gint blend; } blend;
struct { gint x; gint y; gint opacity; } dissolve;
CombinationMode combine;
GimpCompositeOperation op;
} GimpCompositeContext;
struct GimpCompositeOptions
{
gulong bits;
};
#define GIMP_COMPOSITE_OPTION_NOEXTENSIONS 0x2
#define GIMP_COMPOSITE_OPTION_VERBOSE 0x4
extern struct GimpCompositeOptions gimp_composite_options;
void gimp_composite_init (gboolean be_verbose,
gboolean use_cpu_accel);
gboolean gimp_composite_use_cpu_accel (void);
void gimp_composite_dispatch (GimpCompositeContext *ctx);
void gimp_composite_context_print (GimpCompositeContext *ctx);
const gchar * gimp_composite_mode_astext (GimpCompositeOperation op);
const gchar * gimp_composite_pixelformat_astext (GimpPixelFormat format);
extern const gchar *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])(GimpCompositeContext *);
#endif /* __GIMP_COMPOSITE_H__ */

View File

@ -1,553 +0,0 @@
#!/usr/bin/env python
#
# Gimp image compositing
# Copyright (C) 2003 Helvetix Victorinox, <helvetix@gimp.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import string
import os
import ns
import pprint
import optparse
import copy
import re
#
# This programme creates C code for gluing a collection of compositing
# functions into an array indexed by compositing function, and the
# pixel formats of its arguments.
#
# I make some assuptions about the names of the compositing functions.
#
# I look into the namespace of a set of object files and figure out
# from them what compositing functions are implemented. This let's me
# build a table with the right cells populated with either the special
# compositing functions, or to use a generically implemented
# compositing function.
# These are in the same order as they appear in the
# ./app/base/base-enums.h GimpLayerModeEffects enumeration, because we
# (probably unwisely) use the value of the enumeration as an index
# into the Big Table.
#
# XXX I'd like some python functions that let me rummage around in C code....
#
composite_modes=[
"GIMP_COMPOSITE_NORMAL",
"GIMP_COMPOSITE_DISSOLVE",
"GIMP_COMPOSITE_BEHIND",
"GIMP_COMPOSITE_MULTIPLY",
"GIMP_COMPOSITE_SCREEN",
"GIMP_COMPOSITE_OVERLAY",
"GIMP_COMPOSITE_DIFFERENCE",
"GIMP_COMPOSITE_ADDITION",
"GIMP_COMPOSITE_SUBTRACT",
"GIMP_COMPOSITE_DARKEN",
"GIMP_COMPOSITE_LIGHTEN",
"GIMP_COMPOSITE_HUE",
"GIMP_COMPOSITE_SATURATION",
"GIMP_COMPOSITE_COLOR_ONLY",
"GIMP_COMPOSITE_VALUE",
"GIMP_COMPOSITE_DIVIDE",
"GIMP_COMPOSITE_DODGE",
"GIMP_COMPOSITE_BURN",
"GIMP_COMPOSITE_HARDLIGHT",
"GIMP_COMPOSITE_SOFTLIGHT",
"GIMP_COMPOSITE_GRAIN_EXTRACT",
"GIMP_COMPOSITE_GRAIN_MERGE",
"GIMP_COMPOSITE_COLOR_ERASE",
"GIMP_COMPOSITE_ERASE" ,
"GIMP_COMPOSITE_REPLACE" ,
"GIMP_COMPOSITE_ANTI_ERASE",
"GIMP_COMPOSITE_BLEND",
"GIMP_COMPOSITE_SHADE",
"GIMP_COMPOSITE_SWAP",
"GIMP_COMPOSITE_SCALE",
"GIMP_COMPOSITE_CONVERT",
"GIMP_COMPOSITE_XOR",
]
pixel_format=[
"GIMP_PIXELFORMAT_V8",
"GIMP_PIXELFORMAT_VA8",
"GIMP_PIXELFORMAT_RGB8",
"GIMP_PIXELFORMAT_RGBA8",
# "GIMP_PIXELFORMAT_V16",
# "GIMP_PIXELFORMAT_VA16",
# "GIMP_PIXELFORMAT_RGB16",
# "GIMP_PIXELFORMAT_RGBA16"
# "GIMP_PIXELFORMAT_V32",
# "GIMP_PIXELFORMAT_VA32",
# "GIMP_PIXELFORMAT_RGB32",
# "GIMP_PIXELFORMAT_RGBA32"
"GIMP_PIXELFORMAT_ANY",
]
def mode_name(mode):
s = string.replace(mode.lower(), "gimp_composite_", "")
return (s)
def pixel_depth_name(pixel_format):
s = string.replace(pixel_format.lower(), "gimp_pixelformat_", "")
return (s)
pp = pprint.PrettyPrinter(indent=4)
def sanitize_filename(filename):
return re.sub('^lib[^-]+-', '', filename)
def functionnameify(filename):
f = os.path.basename(filename)
f = sanitize_filename(f)
f = string.replace(f, ".o", "")
f = string.replace(f, ".c", "")
f = string.replace(f, ".h", "")
f = string.replace(f, "-", "_")
return (f)
def filenameify(filename):
f = os.path.basename(filename)
f = sanitize_filename(f)
f = string.replace(f, ".o", "")
f = string.replace(f, ".c", "")
f = string.replace(f, ".h", "")
return (f)
def print_function_table(fpout, name, function_table, requirements=[]):
if len(function_table) < 1:
return;
print >>fpout, 'static const struct install_table {'
print >>fpout, ' GimpCompositeOperation mode;'
print >>fpout, ' GimpPixelFormat A;'
print >>fpout, ' GimpPixelFormat B;'
print >>fpout, ' GimpPixelFormat D;'
print >>fpout, ' void (*function)(GimpCompositeContext *);'
#print >>fpout, ' char *name;'
print >>fpout, '} _%s[] = {' % (functionnameify(name))
for r in requirements:
print >>fpout, '#if %s' % (r)
pass
for mode in composite_modes:
for A in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
for B in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
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 >>fpout, ' { %s, %s, %s, %s, %s },' % (mode, A, B, D, function_table[key][0])
pass
pass
pass
pass
pass
for r in requirements:
print >>fpout, '#endif'
pass
print >>fpout, ' { 0, 0, 0, 0, NULL }'
print >>fpout, '};'
return
def print_function_table_name(fpout, name, function_table):
print >>fpout, ''
print >>fpout, 'char *%s_name[%s][%s][%s][%s] = {' % (functionnameify(name), "GIMP_COMPOSITE_N", "GIMP_PIXELFORMAT_N", "GIMP_PIXELFORMAT_N", "GIMP_PIXELFORMAT_N")
for mode in composite_modes:
print >>fpout, ' { /* %s */' % (mode)
for A in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
print >>fpout, ' { /* A = %s */' % (pixel_depth_name(A))
for B in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
print >>fpout, ' /* %-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 >>fpout, '"%s", ' % (function_table[key][0]),
else:
print >>fpout, '"%s", ' % (""),
pass
pass
print >>fpout, '},'
pass
print >>fpout, ' },'
pass
print >>fpout, ' },'
pass
print >>fpout, '};\n'
return
def load_function_table(filename):
nmx = ns.nmx(filename)
gimp_composite_function = dict()
for mode in composite_modes:
for A in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
for B in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
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))
for a in ["GIMP_PIXELFORMAT_ANY", A]:
for b in ["GIMP_PIXELFORMAT_ANY", B]:
for d in ["GIMP_PIXELFORMAT_ANY", D]:
key = "%s_%s_%s_%s" % (string.lower(mode), pixel_depth_name(a), pixel_depth_name(b), pixel_depth_name(d))
f = nmx.exports_re(key + ".*")
if f != None: gimp_composite_function["%s_%s_%s_%s" % (string.lower(mode), pixel_depth_name(A), pixel_depth_name(B), pixel_depth_name(D))] = [f]
pass
pass
pass
pass
pass
pass
pass
return (gimp_composite_function)
def merge_function_tables(tables):
main_table = copy.deepcopy(tables[0][1])
for t in tables[1:]:
#print >>sys.stderr, t[0]
for mode in composite_modes:
for A in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
for B in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
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 t[1].has_key(key):
#print >>sys.stderr, "%s = %s::%s" % (key, t[0], t[1][key])
main_table[key] = t[1][key]
pass
pass
pass
pass
pass
pass
return (main_table)
def gimp_composite_regression(fpout, function_tables, options):
# XXX move all this out to C code, instead of here.
print >>fpout, '#include "config.h"'
print >>fpout, ''
print >>fpout, '#include <stdio.h>'
print >>fpout, '#include <stdlib.h>'
print >>fpout, '#include <string.h>'
print >>fpout, ''
print >>fpout, '#include <sys/time.h>'
print >>fpout, ''
print >>fpout, '#include <glib-object.h>'
print >>fpout, ''
print >>fpout, '#include "base/base-types.h"'
print >>fpout, ''
print >>fpout, '#include "gimp-composite.h"'
print >>fpout, '#include "gimp-composite-regression.h"'
print >>fpout, '#include "gimp-composite-util.h"'
print >>fpout, '#include "gimp-composite-generic.h"'
print >>fpout, '#include "%s.h"' % (filenameify(options.file))
print >>fpout, ''
print >>fpout, 'int'
print >>fpout, '%s_test (int iterations, int n_pixels)' % (functionnameify(options.file))
print >>fpout, '{'
for r in options.requires:
print >>fpout, '#if %s' % (r)
pass
print >>fpout, ' GimpCompositeContext generic_ctx;'
print >>fpout, ' GimpCompositeContext special_ctx;'
print >>fpout, ' double ft0;'
print >>fpout, ' double ft1;'
print >>fpout, ' gimp_rgba8_t *rgba8D1;'
print >>fpout, ' gimp_rgba8_t *rgba8D2;'
print >>fpout, ' gimp_rgba8_t *rgba8A;'
print >>fpout, ' gimp_rgba8_t *rgba8B;'
print >>fpout, ' gimp_rgba8_t *rgba8M;'
print >>fpout, ' gimp_va8_t *va8A;'
print >>fpout, ' gimp_va8_t *va8B;'
print >>fpout, ' gimp_va8_t *va8M;'
print >>fpout, ' gimp_va8_t *va8D1;'
print >>fpout, ' gimp_va8_t *va8D2;'
print >>fpout, ' int i;'
print >>fpout, ''
print >>fpout, ' printf("\\nRunning %s tests...\\n");' % (functionnameify(options.file))
print >>fpout, ' if (%s_init () == 0)' % (functionnameify(options.file))
print >>fpout, ' {'
print >>fpout, ' printf("%s: Instruction set is not available.\\n");' % (functionnameify(options.file))
print >>fpout, ' return (0);'
print >>fpout, ' }'
print >>fpout, ''
print >>fpout, ' rgba8A = gimp_composite_regression_random_rgba8(n_pixels+1);'
print >>fpout, ' rgba8B = gimp_composite_regression_random_rgba8(n_pixels+1);'
print >>fpout, ' rgba8M = gimp_composite_regression_random_rgba8(n_pixels+1);'
print >>fpout, ' rgba8D1 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);'
print >>fpout, ' rgba8D2 = (gimp_rgba8_t *) calloc(sizeof(gimp_rgba8_t), n_pixels+1);'
print >>fpout, ' va8A = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);'
print >>fpout, ' va8B = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);'
print >>fpout, ' va8M = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);'
print >>fpout, ' va8D1 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);'
print >>fpout, ' va8D2 = (gimp_va8_t *) calloc(sizeof(gimp_va8_t), n_pixels+1);'
print >>fpout, ''
print >>fpout, ' for (i = 0; i < n_pixels; i++)'
print >>fpout, ' {'
print >>fpout, ' va8A[i].v = i;'
print >>fpout, ' va8A[i].a = 255-i;'
print >>fpout, ' va8B[i].v = i;'
print >>fpout, ' va8B[i].a = i;'
print >>fpout, ' va8M[i].v = i;'
print >>fpout, ' va8M[i].a = i;'
print >>fpout, ' }'
print >>fpout, ''
#pp.pprint(function_tables)
generic_table = function_tables
composite_modes.sort();
for mode in composite_modes:
for A in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
for B in filter(lambda pf: pf != "GIMP_PIXELFORMAT_ANY", pixel_format):
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_tables.has_key(key):
#print key
print >>fpout, ''
print >>fpout, ' gimp_composite_context_init (&special_ctx, %s, %s, %s, %s, %s, n_pixels, (unsigned char *) %sA, (unsigned char *) %sB, (unsigned char *) %sB, (unsigned char *) %sD2);' % (
mode, A, B, D, D, pixel_depth_name(A), pixel_depth_name(B), pixel_depth_name(D), pixel_depth_name(D))
print >>fpout, ' gimp_composite_context_init (&generic_ctx, %s, %s, %s, %s, %s, n_pixels, (unsigned char *) %sA, (unsigned char *) %sB, (unsigned char *) %sB, (unsigned char *) %sD1);' % (
mode, A, B, D, D, pixel_depth_name(A), pixel_depth_name(B), pixel_depth_name(D), pixel_depth_name(D))
print >>fpout, ' ft0 = gimp_composite_regression_time_function (iterations, %s, &generic_ctx);' % ("gimp_composite_dispatch")
print >>fpout, ' ft1 = gimp_composite_regression_time_function (iterations, %s, &special_ctx);' % (generic_table[key][0])
print >>fpout, ' if (gimp_composite_regression_compare_contexts ("%s", &generic_ctx, &special_ctx))' % (mode_name(mode))
print >>fpout, ' {'
print >>fpout, ' printf("%s_%s_%s_%s failed\\n");' % (mode_name(mode), pixel_depth_name(A), pixel_depth_name(B), pixel_depth_name(D))
print >>fpout, ' return (1);'
print >>fpout, ' }'
print >>fpout, ' gimp_composite_regression_timer_report ("%s_%s_%s_%s", ft0, ft1);' % (mode_name(mode), pixel_depth_name(A), pixel_depth_name(B), pixel_depth_name(D))
pass
pass
pass
pass
pass
for r in options.requires:
print >>fpout, '#endif'
pass
print >>fpout, ' return (0);'
print >>fpout, '}'
print >>fpout, ''
print >>fpout, 'int'
print >>fpout, 'main (int argc, char *argv[])'
print >>fpout, '{'
print >>fpout, ' int iterations;'
print >>fpout, ' int n_pixels;'
print >>fpout, ''
print >>fpout, ' srand (314159);'
print >>fpout, ''
print >>fpout, ' putenv ("GIMP_COMPOSITE=0x1");'
print >>fpout, ''
print >>fpout, ' iterations = %d;' % options.iterations
print >>fpout, ' n_pixels = %d;' % options.n_pixels
print >>fpout, ''
print >>fpout, ' argv++, argc--;'
print >>fpout, ' while (argc >= 2)'
print >>fpout, ' {'
print >>fpout, ' if (argc > 1 && (strcmp (argv[0], "--iterations") == 0 || strcmp (argv[0], "-i") == 0))'
print >>fpout, ' {'
print >>fpout, ' iterations = atoi(argv[1]);'
print >>fpout, ' argc -= 2, argv++; argv++;'
print >>fpout, ' }'
print >>fpout, ' else if (argc > 1 && (strcmp (argv[0], "--n-pixels") == 0 || strcmp (argv[0], "-n") == 0))'
print >>fpout, ' {'
print >>fpout, ' n_pixels = atoi (argv[1]);'
print >>fpout, ' argc -= 2, argv++; argv++;'
print >>fpout, ' }'
print >>fpout, ' else'
print >>fpout, ' {'
print >>fpout, ' printf("Usage: gimp-composites-*-test [-i|--iterations n] [-n|--n-pixels n]");'
print >>fpout, ' exit(1);'
print >>fpout, ' }'
print >>fpout, ' }'
print >>fpout, ''
print >>fpout, ' gimp_composite_generic_install ();'
print >>fpout, ''
print >>fpout, ' return (%s_test (iterations, n_pixels));' % (functionnameify(options.file))
print >>fpout, '}'
return
def gimp_composite_installer_install2(fpout, name, function_table, requirements=[]):
print >>fpout, ''
print >>fpout, 'gboolean'
print >>fpout, '%s_install (void)' % (functionnameify(name))
print >>fpout, '{'
if len(function_table) >= 1:
print >>fpout, ' static const struct install_table *t = _%s;' % (functionnameify(name))
print >>fpout, ''
print >>fpout, ' if (%s_init ())' % functionnameify(name)
print >>fpout, ' {'
print >>fpout, ' for (t = &_%s[0]; t->function != NULL; t++)' % (functionnameify(name))
print >>fpout, ' {'
print >>fpout, ' gimp_composite_function[t->mode][t->A][t->B][t->D] = t->function;'
print >>fpout, ' }'
print >>fpout, ' return (TRUE);'
print >>fpout, ' }'
else:
print >>fpout, ' /* nothing to do */'
pass
print >>fpout, ''
print >>fpout, ' return (FALSE);'
print >>fpout, '}'
pass
def gimp_composite_installer_install3(fpout, name, requirements=[], cpu_feature=[]):
if not requirements and not cpu_feature:
return
print >>fpout, ''
print >>fpout, 'gboolean'
print >>fpout, '%s_init (void)' % (functionnameify(name))
print >>fpout, '{'
need_endif = False
for r in requirements:
print >>fpout, '#if %s' % (r)
pass
if cpu_feature:
if len(cpu_feature) >= 2:
features = []
for f in cpu_feature:
features.append('cpu & GIMP_CPU_ACCEL_%s' % f)
feature_test = ' || '.join(features)
print >>fpout, ' GimpCpuAccelFlags cpu = gimp_cpu_accel_get_support ();'
print >>fpout, ''
else:
feature_test = 'gimp_cpu_accel_get_support () & GIMP_CPU_ACCEL_%s' % cpu_feature[0]
print >>fpout, ' if (%s)' % feature_test
print >>fpout, ' {'
print >>fpout, ' return (TRUE);'
print >>fpout, ' }'
if requirements:
print >>fpout, '#endif'
print >>fpout, ''
else:
print >>fpout, ' return (TRUE);'
if requirements:
print >>fpout, '#else'
need_endif = True
if requirements or cpu_feature:
print >>fpout, ' return (FALSE);'
if need_endif:
print >>fpout, '#endif'
print >>fpout, '}'
pass
def gimp_composite_hfile(fpout, name, function_table):
print >>fpout, '/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */'
print >>fpout, '/* REGENERATE BY USING make-installer.py */'
print >>fpout, ''
print >>fpout, 'void %s_install (void);' % (functionnameify(name))
print >>fpout, ''
print >>fpout, 'typedef void (*%s_table[%s][%s][%s][%s]);' % (functionnameify(name), "GIMP_COMPOSITE_N", "GIMP_PIXELFORMAT_N", "GIMP_PIXELFORMAT_N", "GIMP_PIXELFORMAT_N")
return
def gimp_composite_cfile(fpout, name, function_table, requirements=[], cpu_feature=[]):
print >>fpout, '/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */'
print >>fpout, '/* REGENERATE BY USING make-installer.py */'
print >>fpout, '#include "config.h"'
print >>fpout, '#include <stdlib.h>'
print >>fpout, '#include <stdio.h>'
print >>fpout, '#include <glib-object.h>'
if cpu_feature:
print >>fpout, '#include "libgimpbase/gimpbase.h"'
print >>fpout, '#include "base/base-types.h"'
print >>fpout, '#include "gimp-composite.h"'
print >>fpout, ''
print >>fpout, '#include "%s.h"' % (filenameify(name))
print >>fpout, ''
print_function_table(fpout, name, function_table, requirements)
gimp_composite_installer_install2(fpout, name, function_table, requirements)
gimp_composite_installer_install3(fpout, name, requirements, cpu_feature)
return
###########################################
op = optparse.OptionParser(version="$Revision$")
op.add_option('-f', '--file', action='store', type='string', dest='file', default=None,
help='the input object file')
op.add_option('-t', '--test', action='store_true', dest='test', default=False,
help='generate regression testing code')
op.add_option('-i', '--iterations', action='store', type='int', dest='iterations', default=10,
help='number of iterations in regression tests')
op.add_option('-n', '--n-pixels', action='store', type="int", dest='n_pixels', default=1024*8192+16+1,
help='number of pixels in each regression test iteration')
op.add_option('-r', '--requires', action='append', type='string', dest='requires', default=[],
help='cpp #if conditionals')
op.add_option('-c', '--cpu-feature', action='append', type='string', dest='cpu_feature', default=[],
help='cpu_accel feature tests')
options, args = op.parse_args()
table = load_function_table(options.file)
gimp_composite_cfile(open(filenameify(options.file) + "-installer.c", "w"), options.file, table, options.requires, options.cpu_feature)
if options.test == True:
gimp_composite_regression(open(filenameify(options.file) + "-test.c", "w"), table, options)
pass
sys.exit(0)

View File

@ -1,199 +0,0 @@
#!/usr/bin/env python
# Copyright (C) 2003 Helvetix Victorinox, a pseudonym, <helvetix@gimp.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -*- mode: python py-indent-offset: 2; -*-
#
# Look at object files and figure things about the namespaces they
# require and provide.
#
# It is very useful when working on libraries where you really should
# be hygenic about the namespace you occupy and not clutter it with
# conflicting and extraneous names.
#
import os
import re
import sys
import string
import pprint
pp = pprint.PrettyPrinter(indent=2)
#
# for each object file, we keep two lists: exported names and imported names.
#
# nm -A [files...]
#
class nmx:
def __init__(self, objfile=None):
self.objects = dict()
self.filename = None
if objfile != None:
self.update(objfile)
pass
return (None)
def split_(self, line):
tmp=string.split(line)[0:2]
tmp.reverse()
return tmp
def update(self, objfile):
self.filename = objfile
(sysname, nodename, release, version, machine) = os.uname()
if sysname == "Linux":
fp = os.popen("nm -P " + objfile, "r")
symbols = map(self.split_, fp.readlines())
elif sysname == "SunOS":
fp = os.popen("nm -p " + objfile, "r")
symbols = map(lambda l: string.split(l[12:]), fp.readlines())
pass
elif sysname == "IRIX":
fp = os.popen("nm -B " + objfile, "r")
symbols = map(lambda l: string.split(l[8:]), fp.readlines())
pass
object = objfile
for (type, symbol) in symbols:
if not self.objects.has_key(object):
self.objects.update({ object : dict({ "exports" : dict(), "imports" : dict() }) })
pass
if type == "U":
self.objects[object]["imports"].update({ symbol : dict() })
elif type in ["C", "D", "T"]:
self.objects[object]["exports"].update({ symbol : dict() })
pass
pass
fp.close()
return (None)
def exports(self, name):
for o in self.objects.keys():
if self.objects[o]["exports"].has_key(name):
return (1)
pass
return (0)
def exports_re(self, name):
regex = re.compile(name)
for o in self.objects.keys():
for p in self.objects[o]["exports"].keys():
if regex.match(p):
return (p)
pass
pass
return (None)
pass
def nm(nmfile):
objects = dict()
fp = open(nmfile, "r")
for line in fp.readlines():
(object, type, symbol) = string.split(line)
object = object[:string.rfind(object, ':')]
if not objects.has_key(object):
objects.update({ object : dict({"exports" : dict(), "imports" : dict()})})
pass
if type == "U":
objects[object]["imports"].update({symbol : dict()})
elif type in ["C", "D", "T"]:
objects[object]["exports"].update({symbol : dict()})
pass
fp.close()
return (objects)
def resolve_(objects, obj):
for object in objects.keys():
if object != obj:
for imported in objects[obj]["imports"].keys():
if objects[object]["exports"].has_key(imported):
objects[obj]["imports"][imported] = object
pass
pass
for exported in objects[obj]["exports"].keys():
if objects[object]["imports"].has_key(exported):
objects[obj]["exports"][exported] = object
pass
pass
pass
pass
return
def resolve(objects):
for object in objects.keys():
resolve_(objects, object)
return (objects)
def report_unreferenced(objects):
for object in objects.keys():
for symbol in objects[object]["exports"].keys():
if len(objects[object]["exports"][symbol]) == 0:
print object + ":" + symbol, "unreferenced"
pass
pass
pass
return
def report_referenced(objects):
for object in objects.keys():
for symbol in objects[object]["imports"].keys():
if len(objects[object]["imports"][symbol]) > 0:
print objects[object]["imports"][symbol] + ":" + symbol, object, "referenced"
pass
pass
pass
return
def make_depend(objects):
for object in objects.keys():
for symbol in objects[object]["imports"].keys():
if len(objects[object]["imports"][symbol]) > 0:
print object + ":" + symbol, "referenced", objects[object]["imports"][symbol]
pass
pass
pass
return
def main(argv):
ns = nm(argv[0])
resolve(ns)
report_referenced(ns)
report_unreferenced(ns)
pass
if __name__ == "__main__":
main(sys.argv[1:])

View File

@ -211,23 +211,6 @@ static void gimp_image_active_vectors_notify (GimpItemTree *tree,
GimpImage *image);
static const gint valid_combinations[][MAX_CHANNELS + 1] =
{
/* GIMP_RGB_IMAGE */
{ -1, -1, -1, COMBINE_INTEN_INTEN, COMBINE_INTEN_INTEN_A },
/* GIMP_RGBA_IMAGE */
{ -1, -1, -1, COMBINE_INTEN_A_INTEN, COMBINE_INTEN_A_INTEN_A },
/* GIMP_GRAY_IMAGE */
{ -1, COMBINE_INTEN_INTEN, COMBINE_INTEN_INTEN_A, -1, -1 },
/* GIMP_GRAYA_IMAGE */
{ -1, COMBINE_INTEN_A_INTEN, COMBINE_INTEN_A_INTEN_A, -1, -1 },
/* GIMP_INDEXED_IMAGE */
{ -1, COMBINE_INDEXED_INDEXED, COMBINE_INDEXED_INDEXED_A, -1, -1 },
/* GIMP_INDEXEDA_IMAGE */
{ -1, -1, COMBINE_INDEXED_A_INDEXED_A, -1, -1 },
};
G_DEFINE_TYPE_WITH_CODE (GimpImage, gimp_image, GIMP_TYPE_VIEWABLE,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_COLOR_MANAGED,
gimp_color_managed_iface_init)
@ -1522,13 +1505,6 @@ gimp_image_get_precision (const GimpImage *image)
return GIMP_IMAGE_GET_PRIVATE (image)->precision;
}
CombinationMode
gimp_image_get_combination_mode (GimpImageType dest_type,
gint src_bytes)
{
return valid_combinations[dest_type][src_bytes];
}
const Babl *
gimp_image_get_format (const GimpImage *image,
GimpImageBaseType base_type,

View File

@ -110,10 +110,8 @@ GimpImage * gimp_image_new (Gimp *gimp,
GimpImageBaseType base_type,
GimpPrecision precision);
GimpImageBaseType gimp_image_get_base_type (const GimpImage *image);
GimpPrecision gimp_image_get_precision (const GimpImage *image);
CombinationMode gimp_image_get_combination_mode (GimpImageType dest_type,
gint src_bytes);
GimpImageBaseType gimp_image_get_base_type (const GimpImage *image);
GimpPrecision gimp_image_get_precision (const GimpImage *image);
const Babl * gimp_image_get_format (const GimpImage *image,
GimpImageBaseType base_type,

View File

@ -23,8 +23,6 @@ noinst_LIBRARIES = libapppaint-funcs.a
libapppaint_funcs_a_SOURCES = \
paint-funcs.c \
paint-funcs.h \
paint-funcs-generic.h \
paint-funcs-types.h \
paint-funcs-utils.h \
subsample-region.c \
subsample-region.h

View File

@ -1,339 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This file is supposed to contain the generic (read: C) implementation
* of the pixel fiddling paint-functions.
*/
#ifndef __PAINT_FUNCS_GENERIC_H__
#define __PAINT_FUNCS_GENERIC_H__
inline void
copy_gray_to_inten_a_pixels (const guchar *src,
guchar *dest,
guint length,
guint bytes)
{
const guint alpha = bytes - 1;
while (length --)
{
guint b;
for (b = 0; b < alpha; b++)
dest[b] = *src;
dest[b] = OPAQUE_OPACITY;
src ++;
dest += bytes;
}
}
inline void
initial_channel_pixels (const guchar *src,
guchar *dest,
guint length,
guint bytes)
{
const guint alpha = bytes - 1;
while (length --)
{
guint b;
for (b = 0; b < alpha; b++)
dest[b] = src[0];
dest[alpha] = OPAQUE_OPACITY;
dest += bytes;
src ++;
}
}
inline void
initial_indexed_pixels (const guchar *src,
guchar *dest,
const guchar *cmap,
guint length)
{
/* This function assumes always that we're mapping from
* an RGB colormap to an RGBA image...
*/
while (length--)
{
gint col_index = *src++ * 3;
*dest++ = cmap[col_index++];
*dest++ = cmap[col_index++];
*dest++ = cmap[col_index++];
*dest++ = OPAQUE_OPACITY;
}
}
inline void
initial_indexed_a_pixels (const guchar *src,
guchar *dest,
const guchar *mask,
const guchar *no_mask,
const guchar *cmap,
guint opacity,
guint length)
{
const guchar *m = mask ? mask : no_mask;
while (length --)
{
gint col_index = *src++ * 3;
glong tmp;
guchar new_alpha = INT_MULT3(*src, *m, opacity, tmp);
src++;
*dest++ = cmap[col_index++];
*dest++ = cmap[col_index++];
*dest++ = cmap[col_index++];
/* Set the alpha channel */
*dest++ = (new_alpha > 127) ? OPAQUE_OPACITY : TRANSPARENT_OPACITY;
if (mask)
m++;
}
}
inline void
initial_inten_pixels (const guchar *src,
guchar *dest,
const guchar *mask,
const guchar *no_mask,
guint opacity,
const gboolean *affect,
guint length,
guint bytes)
{
const guchar *srcp;
const gint dest_bytes = bytes + 1;
guchar *destp;
gint b, l;
if (mask)
{
const guchar *m = mask;
/* This function assumes the source has no alpha channel and
* the destination has an alpha channel. So dest_bytes = bytes + 1
*/
if (bytes == 3 && affect[0] && affect[1] && affect[2])
{
if (!affect[bytes])
opacity = 0;
destp = dest + bytes;
if (opacity != 0)
while(length--)
{
gint tmp;
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
dest[3] = INT_MULT (opacity, *m, tmp);
src += bytes;
dest += dest_bytes;
m++;
}
else
while(length--)
{
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
dest[3] = opacity;
src += bytes;
dest += dest_bytes;
}
return;
}
for (b = 0; b < bytes; b++)
{
destp = dest + b;
srcp = src + b;
l = length;
if (affect[b])
while(l--)
{
*destp = *srcp;
srcp += bytes;
destp += dest_bytes;
}
else
while(l--)
{
*destp = 0;
destp += dest_bytes;
}
}
/* fill the alpha channel */
if (!affect[bytes])
opacity = 0;
destp = dest + bytes;
if (opacity != 0)
while (length--)
{
gint tmp;
*destp = INT_MULT(opacity , *m, tmp);
destp += dest_bytes;
m++;
}
else
while (length--)
{
*destp = opacity;
destp += dest_bytes;
}
}
else /* no mask */
{
/* This function assumes the source has no alpha channel and
* the destination has an alpha channel. So dest_bytes = bytes + 1
*/
if (bytes == 3 && affect[0] && affect[1] && affect[2])
{
if (!affect[bytes])
opacity = 0;
destp = dest + bytes;
while(length--)
{
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
dest[3] = opacity;
src += bytes;
dest += dest_bytes;
}
return;
}
for (b = 0; b < bytes; b++)
{
destp = dest + b;
srcp = src + b;
l = length;
if (affect[b])
while(l--)
{
*destp = *srcp;
srcp += bytes;
destp += dest_bytes;
}
else
while(l--)
{
*destp = 0;
destp += dest_bytes;
}
}
/* fill the alpha channel */
if (!affect[bytes])
opacity = 0;
destp = dest + bytes;
while (length--)
{
*destp = opacity;
destp += dest_bytes;
}
}
}
inline void
initial_inten_a_pixels (const guchar *src,
guchar *dest,
const guchar *mask,
guint opacity,
const gboolean *affect,
guint length,
guint bytes)
{
const guint alpha = bytes - 1;
if (mask)
{
const guchar *m = mask;
while (length--)
{
guint b;
glong tmp;
for (b = 0; b < alpha; b++)
dest[b] = src[b] * affect[b];
/* Set the alpha channel */
dest[alpha] = (affect [alpha] ?
INT_MULT3(opacity, src[alpha], *m, tmp) : 0);
m++;
dest += bytes;
src += bytes;
}
}
else
{
while (length--)
{
guint b;
glong tmp;
for (b = 0; b < alpha; b++)
dest[b] = src[b] * affect[b];
/* Set the alpha channel */
dest[alpha] = (affect [alpha] ?
INT_MULT(opacity , src[alpha], tmp) : 0);
dest += bytes;
src += bytes;
}
}
}
#endif /* __PAINT_FUNCS_GENERIC_H__ */

View File

@ -27,51 +27,4 @@
#define OPAQUE_OPACITY 255
/* Lay down the groundwork for layer construction...
* This includes background images for indexed or non-alpha
* images, floating selections, selective display of intensity
* channels, and display of arbitrary mask channels
*/
typedef enum
{
INITIAL_CHANNEL_MASK = 0,
INITIAL_CHANNEL_SELECTION,
INITIAL_INDEXED,
INITIAL_INDEXED_ALPHA,
INITIAL_INTENSITY,
INITIAL_INTENSITY_ALPHA
} InitialMode;
/* Combine two source regions with the help of an optional mask
* region into a destination region. This is used for constructing
* layer projections, and for applying image patches to an image
*/
typedef enum
{
NO_COMBINATION = 0,
COMBINE_INDEXED_INDEXED,
COMBINE_INDEXED_INDEXED_A,
COMBINE_INDEXED_A_INDEXED_A,
COMBINE_INTEN_A_INDEXED,
COMBINE_INTEN_A_INDEXED_A,
COMBINE_INTEN_A_CHANNEL_MASK,
COMBINE_INTEN_A_CHANNEL_SELECTION,
COMBINE_INTEN_INTEN,
COMBINE_INTEN_INTEN_A,
COMBINE_INTEN_A_INTEN,
COMBINE_INTEN_A_INTEN_A,
/* Non-conventional combination modes */
BEHIND_INTEN,
BEHIND_INDEXED,
REPLACE_INTEN,
REPLACE_INDEXED,
ERASE_INTEN,
ERASE_INDEXED,
ANTI_ERASE_INTEN,
ANTI_ERASE_INDEXED,
COLOR_ERASE_INTEN
} CombinationMode;
#endif /* __PAINT_FUNCS_TYPES_H__ */

View File

@ -1,45 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __PAINT_FUNCS_UTILS_H__
#define __PAINT_FUNCS_UTILS_H__
#define INT_MULT(a,b,t) ((t) = (a) * (b) + 0x80, ((((t) >> 8) + (t)) >> 8))
/* This version of INT_MULT3 is very fast, but suffers from some
slight roundoff errors. It returns the correct result 99.987
percent of the time */
#define INT_MULT3(a,b,c,t) ((t) = (a) * (b) * (c) + 0x7F5B, \
((((t) >> 7) + (t)) >> 16))
/*
This version of INT_MULT3 always gives the correct result, but runs at
approximatly one third the speed. */
/* #define INT_MULT3(a,b,c,t) (((a) * (b) * (c) + 32512) / 65025.0)
*/
#define INT_BLEND(a,b,alpha,tmp) (INT_MULT((a) - (b), alpha, tmp) + (b))
/* A drawable has an alphachannel if contains either 4 or 2 bytes data
* aka GRAYA and RGBA and thus the macro below works. This will have
* to change if we support bigger formats. We'll do it so for now because
* masking is always cheaper than passing parameters over the stack. */
/* FIXME: Move to a global place */
#define HAS_ALPHA(bytes) (~bytes & 1)
#endif /* __PAINT_FUNCS_UTILS_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -19,199 +19,6 @@
#define __PAINT_FUNCS_H__
/* copy gray pixels to intensity-alpha pixels. This function
* essentially takes a source that is only a grayscale image and
* copies it to the destination, expanding to RGB if necessary and
* adding an alpha channel. (OPAQUE)
*/
void copy_gray_to_inten_a_pixels (const guchar *src,
guchar *dest,
guint length,
guint bytes);
/* lay down the initial pixels in the case of only one
* channel being visible and no layers...In this singular
* case, we want to display a grayscale image w/o transparency
*/
void initial_channel_pixels (const guchar *src,
guchar *dest,
guint length,
guint bytes);
/* lay down the initial pixels in the case of an indexed image.
* This process obviously requires no composition
*/
void initial_indexed_pixels (const guchar *src,
guchar *dest,
const guchar *cmap,
guint length);
/* lay down the initial pixels in the case of an indexed image.
* This process obviously requires no composition
*/
void initial_indexed_a_pixels (const guchar *src,
guchar *dest,
const guchar *mask,
const guchar *no_mask,
const guchar *cmap,
guint opacity,
guint length);
/* lay down the initial pixels for the base layer.
* This process obviously requires no composition.
*/
void initial_inten_pixels (const guchar *src,
guchar *dest,
const guchar *mask,
const guchar *no_mask,
guint opacity,
const gboolean *affect,
guint length,
guint bytes);
/* lay down the initial pixels for the base layer.
* This process obviously requires no composition.
*/
void initial_inten_a_pixels (const guchar *src,
guchar *dest,
const guchar *mask,
guint opacity,
const gboolean *affect,
guint length,
guint bytes);
/* combine indexed images with an optional mask which
* is interpreted as binary...destination is indexed...
*/
void combine_indexed_and_indexed_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
const guchar *mask,
guint opacity,
const gboolean *affect,
guint length,
guint bytes);
/* combine indexed images with indexed-alpha images
* result is an indexed image
*/
void combine_indexed_and_indexed_a_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
const guchar *mask,
guint opacity,
const gint *affect,
guint length,
guint bytes);
/* combine indexed-alpha images with indexed-alpha images
* result is an indexed-alpha image. use this for painting
* to an indexed floating sel
*/
void combine_indexed_a_and_indexed_a_pixels(const guchar *src1,
const guchar *src2,
guchar *dest,
const guchar *mask,
guint opacity,
const gboolean *affect,
guint length,
guint bytes);
void combine_inten_a_and_indexed_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
const guchar *mask,
const guchar *cmap,
guint opacity,
guint length,
guint bytes);
/* combine intensity with indexed, destination is
* intensity-alpha...use this for an indexed floating sel
*/
void combine_inten_a_and_indexed_a_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
const guchar *mask,
const guchar *cmap,
guint opacity,
guint length,
guint bytes);
/* combine RGB image with RGB or GRAY with GRAY
* destination is intensity-only...
*/
void combine_inten_and_inten_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
const guchar *mask,
guint opacity,
const gboolean *affect,
guint length,
guint bytes);
/* combine an RGBA or GRAYA image with an RGB or GRAY image
* destination is intensity-only...
*/
void combine_inten_and_inten_a_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
const guchar *mask,
guint opacity,
const gboolean *affect,
guint length,
guint bytes);
/* combine an RGB or GRAY image with an RGBA or GRAYA image
* destination is intensity-alpha...
*/
void combine_inten_a_and_inten_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
const guchar *mask,
guint opacity,
const gboolean *affect,
gboolean mode_affect,
guint length,
guint bytes);
/* combine an RGBA or GRAYA image with an RGBA or GRAYA image
* destination is of course intensity-alpha...
*/
void combine_inten_a_and_inten_a_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
const guchar *mask,
guint opacity,
const gboolean *affect,
gboolean mode_affect,
guint length,
guint bytes);
/* combine a channel with intensity-alpha pixels based
* on some opacity, and a channel color...
* destination is intensity-alpha
*/
void combine_inten_a_and_channel_mask_pixels(const guchar *src,
const guchar *channel,
guchar *dest,
const guchar *col,
guint opacity,
guint length,
guint bytes);
void combine_inten_a_and_channel_selection_pixels(const guchar *src,
const guchar *channel,
guchar *dest,
const guchar *col,
guint opacity,
guint length,
guint bytes);
void paint_funcs_color_erase_helper (GimpRGB *src,
const GimpRGB *color);
/* Region functions */
void convolve_region (PixelRegion *srcR,
@ -227,28 +34,4 @@ void erode_region (PixelRegion *region);
void dilate_region (PixelRegion *region);
/* Copy a gray image to an intensity-alpha region */
void copy_gray_to_region (PixelRegion *src,
PixelRegion *dest);
void initial_region (PixelRegion *src,
PixelRegion *dest,
PixelRegion *mask,
const guchar *data,
guint opacity,
GimpLayerModeEffects mode,
const gboolean *affect,
InitialMode type);
void combine_regions (PixelRegion *src1,
PixelRegion *src2,
PixelRegion *dest,
PixelRegion *mask,
const guchar *data,
guint opacity,
GimpLayerModeEffects mode,
const gboolean *affect,
CombinationMode type);
#endif /* __PAINT_FUNCS_H__ */

View File

@ -29,8 +29,6 @@
#include "config/gimpguiconfig.h"
#include "composite/gimp-composite.h"
#include "core/gimp.h"
#include "core/gimpprogress.h"
@ -191,7 +189,10 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
config.check_type = display_config->transparency_type;
config.show_help_button = (gui_config->use_help &&
gui_config->show_help_button);
config.use_cpu_accel = gimp_composite_use_cpu_accel ();
#ifdef __GNUC__
#warning FIXME what to do with config.use_cpu_accel
#endif
config.use_cpu_accel = FALSE;
config.gimp_reserved_5 = 0;
config.gimp_reserved_6 = 0;
config.gimp_reserved_7 = 0;