[gegl/npd-squashed] npd: Use GeglMatrix3 directly.



commit 72d00b354cedccd5f315de4ae1f1c4ca1ab290e2
Author: Michael Henning <drawoc darkrefraction com>
Date:   Mon Nov 18 22:18:15 2013 -0500

    npd: Use GeglMatrix3 directly.

 libs/npd/Makefile.am  |    1 -
 libs/npd/graphics.c   |   32 +++++++++++++-------------------
 libs/npd/graphics.h   |    6 ++++--
 libs/npd/npd_common.h |    1 -
 libs/npd/npd_gegl.c   |   27 ++++++++-------------------
 libs/npd/npd_gegl.h   |   33 ---------------------------------
 libs/npd/npd_math.h   |    9 ++++-----
 7 files changed, 29 insertions(+), 80 deletions(-)
---
diff --git a/libs/npd/Makefile.am b/libs/npd/Makefile.am
index 080bb9d..be99db0 100644
--- a/libs/npd/Makefile.am
+++ b/libs/npd/Makefile.am
@@ -12,7 +12,6 @@ GEGL_NPD_public_HEADERS = \
        npd_math.h       \
        graphics.h       \
        lattice_cut.h    \
-       npd_gegl.h       \
        npd.h
 
 GEGL_NPD_SOURCES = \
diff --git a/libs/npd/graphics.c b/libs/npd/graphics.c
index e5c5e5f..5e45f33 100644
--- a/libs/npd/graphics.c
+++ b/libs/npd/graphics.c
@@ -303,16 +303,13 @@ npd_blend_colors (NPDColor *src,
 }
 
 void
-npd_texture_fill_triangle (gint       x1,
-                           gint       y1,
-                           gint       x2,
-                           gint       y2,
-                           gint       x3,
-                           gint       y3,
-                           NPDMatrix *A,
-                           NPDImage  *input_image,
-                           NPDImage  *output_image,
-                           NPDSettings settings)
+npd_texture_fill_triangle (gint x1, gint y1,
+                           gint x2, gint y2,
+                           gint x3, gint y3,
+                           GeglMatrix3  *A,
+                           NPDImage     *input_image,
+                           NPDImage     *output_image,
+                           NPDSettings   settings)
 {
   gint yA, yB, yC, xA, xB, xC;
   gint tmp, y;
@@ -458,33 +455,30 @@ npd_texture_quadrilateral (NPDBone    *reference_bone,
   NPDPoint *p1 = current_bone->points;
   NPDPoint *p2 = reference_bone->points;
 
-  NPDMatrix *A = NULL;
-  npd_new_matrix (&A);
+  GeglMatrix3 A;
 
   npd_compute_affinity (&p1[0], &p1[1], &p1[2],
-                        &p2[0], &p2[1], &p2[2], A);
+                        &p2[0], &p2[1], &p2[2], &A);
   npd_texture_fill_triangle ((gint) p1[0].x, (gint) p1[0].y,
                              (gint) p1[1].x, (gint) p1[1].y,
                              (gint) p1[2].x, (gint) p1[2].y,
-                             A, input_image, output_image,
+                             &A, input_image, output_image,
                              settings);
 
   npd_compute_affinity (&p1[0], &p1[2], &p1[3],
-                        &p2[0], &p2[2], &p2[3], A);
+                        &p2[0], &p2[2], &p2[3], &A);
   npd_texture_fill_triangle ((gint) p1[0].x, (gint) p1[0].y,
                              (gint) p1[2].x, (gint) p1[2].y,
                              (gint) p1[3].x, (gint) p1[3].y,
-                             A, input_image, output_image,
+                             &A, input_image, output_image,
                              settings);
-
-  npd_destroy_matrix (&A);
 }
 
 void
 npd_draw_texture_line (gint        x1,
                        gint        x2,
                        gint        y,
-                       NPDMatrix  *A,
+                       GeglMatrix3*A,
                        NPDImage   *input_image,
                        NPDImage   *output_image,
                        NPDSettings settings)
diff --git a/libs/npd/graphics.h b/libs/npd/graphics.h
index 457ac80..b2d635c 100644
--- a/libs/npd/graphics.h
+++ b/libs/npd/graphics.h
@@ -24,6 +24,8 @@
 
 #include "npd_common.h"
 
+#include <gegl-matrix.h>
+
 //#define NPD_RGBA_FLOAT
 
 struct _NPDColor {
@@ -67,7 +69,7 @@ void        npd_texture_fill_triangle         (gint        x1,
                                                gint        y2,
                                                gint        x3,
                                                gint        y3,
-                                               NPDMatrix  *A,
+                                               GeglMatrix3 *A,
                                                NPDImage   *input_image,
                                                NPDImage   *output_image,
                                                NPDSettings settings);
@@ -79,7 +81,7 @@ void        npd_texture_quadrilateral         (NPDBone    *reference_bone,
 void        npd_draw_texture_line             (gint        x1,
                                                gint        x2,
                                                gint        y,
-                                               NPDMatrix  *A,
+                                               GeglMatrix3 *A,
                                                NPDImage   *input_image,
                                                NPDImage   *output_image,
                                                NPDSettings settings);
diff --git a/libs/npd/npd_common.h b/libs/npd/npd_common.h
index 5714df5..7ffb537 100644
--- a/libs/npd/npd_common.h
+++ b/libs/npd/npd_common.h
@@ -28,7 +28,6 @@
 typedef struct _NPDImage    NPDImage;
 typedef struct _NPDColor    NPDColor;
 typedef struct _NPDDisplay  NPDDisplay;
-typedef struct _NPDMatrix   NPDMatrix;
 
 typedef struct _NPDPoint    NPDPoint;
 typedef struct _NPDBone     NPDBone;
diff --git a/libs/npd/npd_gegl.c b/libs/npd/npd_gegl.c
index 1a8abaf..b89926c 100644
--- a/libs/npd/npd_gegl.c
+++ b/libs/npd/npd_gegl.c
@@ -19,20 +19,9 @@
  * Copyright (C) 2013 Marek Dvoroznak <dvoromar gmail com>
  */
 
-#include "npd_gegl.h"
+#include "npd.h"
 #include <glib.h>
-
-void
-npd_new_matrix (NPDMatrix **matrix)
-{
-  *matrix = g_new (NPDMatrix, 1);
-}
-
-void
-npd_destroy_matrix (NPDMatrix **matrix)
-{
-  g_free (*matrix);
-}
+#include <gegl-matrix.h>
 
 void
 npd_compute_affinity (NPDPoint  *p11,
@@ -41,7 +30,7 @@ npd_compute_affinity (NPDPoint  *p11,
                       NPDPoint  *p12,
                       NPDPoint  *p22,
                       NPDPoint  *p32,
-                      NPDMatrix *T)
+                      GeglMatrix3 *T)
 {
   GeglMatrix3 Y, X;
   
@@ -54,15 +43,15 @@ npd_compute_affinity (NPDPoint  *p11,
   X.coeff[0][2] = p31->x; X.coeff[1][2] = p31->y; X.coeff[2][2] = 1;
   
   gegl_matrix3_invert (&X);
-  gegl_matrix3_multiply (&Y, &X, &T->matrix);
+  gegl_matrix3_multiply (&Y, &X, T);
 }
 
 void
-npd_apply_transformation (NPDMatrix *T,
-                          NPDPoint  *src,
-                          NPDPoint  *dest)
+npd_apply_transformation (GeglMatrix3 *T,
+                          NPDPoint    *src,
+                          NPDPoint    *dest)
 {
   gdouble x = src->x, y = src->y;
-  gegl_matrix3_transform_point (&T->matrix, &x, &y);
+  gegl_matrix3_transform_point (T, &x, &y);
   dest->x = x; dest->y = y;
 }
diff --git a/libs/npd/npd_math.h b/libs/npd/npd_math.h
index 411f4e9..e3c6d83 100644
--- a/libs/npd/npd_math.h
+++ b/libs/npd/npd_math.h
@@ -23,6 +23,7 @@
 #define        __NPD_MATH_H__
 
 #include "npd_common.h"
+#include <gegl-matrix.h>
 
 #define NPD_EPSILON 0.00001
 
@@ -34,15 +35,15 @@ void        npd_compute_homography   (NPDPoint  *p11,
                                       NPDPoint  *p22,
                                       NPDPoint  *p32,
                                       NPDPoint  *p42,
-                                      NPDMatrix *T);
+                                      GeglMatrix3 *T);
 void        npd_compute_affinity     (NPDPoint  *p11,
                                       NPDPoint  *p21,
                                       NPDPoint  *p31,
                                       NPDPoint  *p12,
                                       NPDPoint  *p22,
                                       NPDPoint  *p32,
-                                      NPDMatrix *T);
-void        npd_apply_transformation (NPDMatrix *T,
+                                      GeglMatrix3 *T);
+void        npd_apply_transformation (GeglMatrix3 *T,
                                       NPDPoint  *src,
                                       NPDPoint  *dest);
 gboolean    npd_equal_floats_epsilon (gfloat a,
@@ -52,7 +53,5 @@ gboolean    npd_equal_floats         (gfloat a,
                                       gfloat b);
 gfloat      npd_SED                  (NPDPoint *p1,
                                       NPDPoint *p2);
-void        npd_new_matrix           (NPDMatrix **matrix);
-void        npd_destroy_matrix       (NPDMatrix **matrix);
 
 #endif /* __NPD_MATH_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]