Commit 10d81c81 authored by Marek Dvoroznak's avatar Marek Dvoroznak Committed by Mikael Magnusson

make shared NPD library

parent e1f0dc4b
......@@ -1138,8 +1138,8 @@ fi
##################
have_libnpd="yes (internal)"
AC_SUBST(NPD_CFLAGS, "-I\$(top_srcdir)/libs/npd")
AC_SUBST(NPD_LIBS, "-L\$(top_builddir)/libs/npd -lnpd")
AC_SUBST(NPD_CFLAGS, "-I\$(top_srcdir)/libs")
AC_SUBST(NPD_LIBS, "-L\$(top_builddir)/libs/npd -lgegl-npd-\$(GEGL_API_VERSION)")
#######################
# Check for other items
......@@ -1296,5 +1296,4 @@ Optional dependencies:
umfpack: $have_umfpack
webp: $have_webp
poly2tri-c: $have_p2tc
libnpd: $have_libnpd
]);
......@@ -8,5 +8,5 @@ Name: GEGL
Description: Generic Graphics Library
Version: @GEGL_REAL_VERSION@
Requires: @GLIB_PACKAGES@ babl
Libs: -L${libdir} -l@PACKAGE_NAME@-@GEGL_API_VERSION@
Libs: -L${libdir} -l@PACKAGE_NAME@-@GEGL_API_VERSION@ -l@PACKAGE_NAME@-npd-@GEGL_API_VERSION@
Cflags: -I${includedir}/@PACKAGE_NAME@-@GEGL_API_VERSION@
noinst_LTLIBRARIES = libnpd.la
AM_CFLAGS = $(GLIB_CFLAGS) $(NPD_CFLAGS) -I$(top_builddir)/gegl -I$(top_srcdir)/gegl
AM_LDFLAGS = $(GLIB_LIBS) $(NPD_LIBS)
libnpd_la_SOURCES = \
npd_common.h \
npd_common.c \
deformation.h \
deformation.c \
npd_math.h \
npd_math.c \
graphics.h \
graphics.c \
npd_gegl.h \
npd_gegl.c \
npd.h
include $(top_srcdir)/operations/Makefile-common.am
######################################################
# A shared library for n-point image deformation API #
######################################################
GEGL_NPD_publicdir = $(includedir)/gegl-$(GEGL_API_VERSION)/npd
GEGL_NPD_public_HEADERS = \
npd_common.h \
deformation.h \
npd_math.h \
graphics.h \
refine.h \
npd_gegl.h \
npd.h
GEGL_NPD_SOURCES = \
$(GEGL_NPD_public_HEADERS) \
npd_common.c \
deformation.c \
npd_math.c \
graphics.c \
refine.c \
npd_gegl.c
libgegl_npd_@GEGL_API_VERSION@_la_SOURCES = \
$(GEGL_NPD_public_HEADERS) \
$(GEGL_NPD_SOURCES)
libgegl_npd_@GEGL_API_VERSION@_la_LDFLAGS = \
-avoid-version -export-dynamic $(no_undefined)
libgegl_npd_@GEGL_API_VERSION@_la_CFLAGS = \
$(AM_CFLAGS)
lib_LTLIBRARIES = libgegl-npd-@GEGL_API_VERSION@.la
libgegl_npd_@GEGL_API_VERSION@_la_LIBADD = \
$(libgegl)
......@@ -76,11 +76,11 @@ void npd_bilinear_color_interpolation (NPDColor *I0,
gfloat dx,
gfloat dy,
NPDColor *out);
void npd_get_pixel_color (NPDImage *image,
void (*npd_get_pixel_color) (NPDImage *image,
gint x,
gint y,
NPDColor *color);
void npd_set_pixel_color (NPDImage *image,
void (*npd_set_pixel_color) (NPDImage *image,
gint x,
gint y,
NPDColor *color);
......
......@@ -24,6 +24,7 @@
#include "graphics.h"
#include "deformation.h"
#include "npd_math.h"
/*#include "refine.h"*/
#endif /* __NPD_H__ */
......@@ -128,11 +128,11 @@ npd_remove_control_point (NPDModel *model,
for (i = 0; i < model->control_points->len; i++)
{
cp = &g_array_index(model->control_points, NPDControlPoint, i);
cp = &g_array_index (model->control_points, NPDControlPoint, i);
if (cp == control_point)
{
npd_set_control_point_weight(cp, 1.0);
npd_set_control_point_weight (cp, 1.0);
g_array_remove_index (model->control_points, i);
return;
}
......@@ -193,7 +193,7 @@ npd_get_control_point_at (NPDModel *model,
}
}
g_printf ("no control points\n");
// g_printf ("no control points\n");
return NULL;
}
......
......@@ -92,6 +92,10 @@ typedef struct
NPDDisplay *display;
} NPDModel;
#define npd_init(set_pixel, get_pixel)\
npd_set_pixel_color = set_pixel;\
npd_get_pixel_color = get_pixel
void npd_init_model (NPDModel *model);
void npd_destroy_hidden_model (NPDHiddenModel *model);
void npd_destroy_model (NPDModel *model);
......
......@@ -161,8 +161,8 @@ rgbe_save_la_LIBADD = $(op_libs) $(top_builddir)/libs/rgbe/librgbe.la
# Dependencies are in our source tree
ops += npd.la
npd_la_SOURCES = npd.c
npd_la_CFLAGS = $(AM_CFLAGS) -I $(top_srcdir)/libs
npd_la_LIBADD = $(op_libs) $(top_builddir)/libs/npd/libnpd.la
npd_la_CFLAGS = $(AM_CFLAGS) $(NPD_CFLAGS)
npd_la_LIBADD = $(op_libs) $(NPD_LIBS)
BUILT_SOURCES = $(subst .c,.c.h,$(wildcard $(srcdir)/*.c))
EXTRA_DIST += $(BUILT_SOURCES)
......
......@@ -20,6 +20,8 @@
#include <glib/gi18n-lib.h>
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_pointer (model, _("model"), _(""))
gegl_chant_int (rigidity, _("rigidity"), 100, 20000, 0, _(""))
#else
#define GEGL_CHANT_TYPE_FILTER
......@@ -53,12 +55,23 @@ typedef struct
void npd_create_image (NPDImage *image,
GeglBuffer *gegl_buffer,
const Babl *format);
void
npd_set_pixel_color_impl (NPDImage *image,
gint x,
gint y,
NPDColor *color);
void
npd_get_pixel_color_impl (NPDImage *image,
gint x,
gint y,
NPDColor *color);
void
npd_set_pixel_color (NPDImage *image,
gint x,
gint y,
NPDColor *color)
npd_set_pixel_color_impl (NPDImage *image,
gint x,
gint y,
NPDColor *color)
{
gint position = 4 * (y * image->width + x);
gint max = 4 * image->width * image->height;
......@@ -73,10 +86,10 @@ npd_set_pixel_color (NPDImage *image,
}
void
npd_get_pixel_color (NPDImage *image,
gint x,
gint y,
NPDColor *color)
npd_get_pixel_color_impl (NPDImage *image,
gint x,
gint y,
NPDColor *color)
{
gint position = 4 * (y * image->width + x);
gint max = 4 * image->width * image->height;
......@@ -177,47 +190,47 @@ process (GeglOperation *operation,
const Babl *format = babl_format ("RGBA u8");
NPDProperties *props = o->chant_data;
NPDModel *model = &props->model;
NPDControlPoint *cp;
NPDPoint coord, new_coord;
guchar *output_buffer;
if (props->first_run)
{
gint width, height;
NPDImage input_image;
NPDDisplay display;
NPDImage *input_image = g_new (NPDImage, 1);
NPDDisplay *display = g_new (NPDDisplay, 1);
npd_init (npd_set_pixel_color_impl, npd_get_pixel_color_impl);
npd_create_image (&input_image, input, format);
width = input_image.width;
height = input_image.height;
npd_create_image (input_image, input, format);
width = input_image->width;
height = input_image->height;
output_buffer = g_new0 (guchar, gegl_buffer_get_pixel_count (input) * 4);
display.image.width = width;
display.image.height = height;
display.image.buffer = output_buffer;
display->image.width = width;
display->image.height = height;
display->image.buffer = output_buffer;
npd_create_model_from_image(model, &input_image, 20);
npd_create_model_from_image (model, input_image, 20);
npd_create_list_of_overlapping_points (model->hidden_model);
model->display = &display;
model->display = display;
o->model = model;
NPDModel *m = o->model;
props->first_run = FALSE;
}
else
{
output_buffer = model->display->image.buffer;
}
coord.x = 20; coord.y = 200;
new_coord.x = 100; new_coord.y = 250;
cp = npd_add_control_point (model, &coord);
npd_set_point_coordinates (&cp->point, &new_coord);
npd_deform_model (model, 1000);
// npd_deform_model (model, o->rigidity);
npd_deform_model (model, 2000);
npd_draw_model (model, model->display);
gegl_buffer_set (output, NULL, 0, format, output_buffer, GEGL_AUTO_ROWSTRIDE);
return TRUE;
gegl_buffer_set (output, NULL, 0, format, output_buffer, GEGL_AUTO_ROWSTRIDE);
return TRUE;
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment