[gnome-photos/wip/rishi/buffer-decoder: 4/11] gegl: Add a function to calculate the inverse Jacobian for zooming
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/buffer-decoder: 4/11] gegl: Add a function to calculate the inverse Jacobian for zooming
- Date: Fri, 22 Feb 2019 14:31:20 +0000 (UTC)
commit 0b1f717fbc86ba742d3f82e68d348eebbc17df44
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Sep 24 11:36:21 2018 +0200
gegl: Add a function to calculate the inverse Jacobian for zooming
This will be necessary to support arbitrary downscales, without keeping
the aspect ratio, in the new codec API for GeglBuffer. It is something
that every codec will need and is, therefore, useful to have as a
separate utility function.
Bump minimum GEGL version to 0.4.10.
https://gitlab.gnome.org/GNOME/gnome-photos/issues/63
configure.ac | 2 +-
meson.build | 2 +-
src/photos-gegl.c | 20 +++++++++++
src/photos-gegl.h | 4 +++
tests/unit/photos-test-gegl.c | 84 +++++++++++++++++++++++++++++++++++++++++++
5 files changed, 110 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c16702ed..1747f9ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,7 +42,7 @@ CAIRO_MIN_VERSION=1.14.0
DAZZLE_MIN_VERSION=3.26.0
GDATA_MIN_VERSION=0.15.2
GDK_PIXBUF_MIN_VERSION=2.36.8
-GEGL_MIN_VERSION=0.4.0
+GEGL_MIN_VERSION=0.4.10
GEXIV2_MIN_VERSION=0.10.8
GFBGRAPH_MIN_VERSION=0.2.1
GLIB_MIN_VERSION=2.57.2
diff --git a/meson.build b/meson.build
index 905758d8..bcfb965a 100644
--- a/meson.build
+++ b/meson.build
@@ -151,7 +151,7 @@ libgd_dep = libgd.get_variable('libgd_dep')
babl_dep = dependency('babl')
cairo_dep = dependency('cairo', version: '>= 1.14.0')
gdk_pixbuf_dep = dependency('gdk-pixbuf-2.0', version: '>= 2.36.8')
-gegl_dep = dependency('gegl-0.4', version: '>= 0.4.0')
+gegl_dep = dependency('gegl-0.4', version: '>= 0.4.10')
geocode_glib_dep = dependency('geocode-glib-1.0')
gexiv_dep = dependency('gexiv2', version: '>= 0.10.8')
gio_dep = dependency('gio-2.0')
diff --git a/src/photos-gegl.c b/src/photos-gegl.c
index b793360b..30e36927 100644
--- a/src/photos-gegl.c
+++ b/src/photos-gegl.c
@@ -725,6 +725,26 @@ photos_gegl_init_fishes (void)
}
+void
+photos_gegl_inverse_jacobian_zoom (GeglBufferMatrix2 *inverse_jacobian, gdouble zoom_x, gdouble zoom_y)
+{
+ GeglMatrix3 tmp;
+
+ g_return_if_fail (inverse_jacobian != NULL);
+
+ gegl_matrix3_identity (&tmp);
+ tmp.coeff[0][0] = zoom_x;
+ tmp.coeff[1][1] = zoom_y;
+
+ gegl_matrix3_invert (&tmp);
+
+ inverse_jacobian->coeff[0][0] = tmp.coeff[0][0];
+ inverse_jacobian->coeff[0][1] = tmp.coeff[0][1];
+ inverse_jacobian->coeff[1][0] = tmp.coeff[1][0];
+ inverse_jacobian->coeff[1][1] = tmp.coeff[1][1];
+}
+
+
GdkPixbuf *
photos_gegl_pixbuf_new_from_buffer (GeglBuffer *buffer)
{
diff --git a/src/photos-gegl.h b/src/photos-gegl.h
index cd533a97..a2b05215 100644
--- a/src/photos-gegl.h
+++ b/src/photos-gegl.h
@@ -55,6 +55,10 @@ void photos_gegl_init (void);
void photos_gegl_init_fishes (void);
+void photos_gegl_inverse_jacobian_zoom (GeglBufferMatrix2 *out_inverse_jacobian,
+ gdouble zoom_x,
+ gdouble zoom_y);
+
GdkPixbuf *photos_gegl_pixbuf_new_from_buffer (GeglBuffer *buffer);
void photos_gegl_processor_process_async (GeglProcessor *processor,
diff --git a/tests/unit/photos-test-gegl.c b/tests/unit/photos-test-gegl.c
index 5cda0d59..f050fc30 100644
--- a/tests/unit/photos-test-gegl.c
+++ b/tests/unit/photos-test-gegl.c
@@ -441,6 +441,19 @@ photos_test_gegl_buffer_check_zoom (PhotosTestGeglFixture *fixture,
}
+static void
+photos_test_gegl_check_inverse_jacobian (gdouble zoom_x, gdouble zoom_y, GeglBufferMatrix2 *reference)
+{
+ GeglBufferMatrix2 inverse_jacobian;
+
+ photos_gegl_inverse_jacobian_zoom (&inverse_jacobian, zoom_x, zoom_y);
+ g_assert_cmpfloat_with_epsilon (inverse_jacobian.coeff[0][0], reference->coeff[0][0], PHOTOS_EPSILON);
+ g_assert_cmpfloat_with_epsilon (inverse_jacobian.coeff[0][1], reference->coeff[0][1], PHOTOS_EPSILON);
+ g_assert_cmpfloat_with_epsilon (inverse_jacobian.coeff[1][0], reference->coeff[1][0], PHOTOS_EPSILON);
+ g_assert_cmpfloat_with_epsilon (inverse_jacobian.coeff[1][1], reference->coeff[1][1], PHOTOS_EPSILON);
+}
+
+
static void
photos_test_gegl_buffer_apply_orientation_bottom_0 (PhotosTestGeglFixture *fixture, gconstpointer user_data)
{
@@ -794,6 +807,71 @@ photos_test_gegl_buffer_zoom_out_1 (PhotosTestGeglFixture *fixture, gconstpointe
}
+static void
+photos_test_gegl_inverse_jacobian_zoom_0 (void)
+{
+ GeglBufferMatrix2 inverse_jacobian;
+
+ inverse_jacobian.coeff[0][0] = 0.714285714;
+ inverse_jacobian.coeff[0][1] = 0.0;
+ inverse_jacobian.coeff[1][0] = 0.0;
+ inverse_jacobian.coeff[1][1] = 0.25;
+ photos_test_gegl_check_inverse_jacobian (1.4, 4.0, &inverse_jacobian);
+}
+
+
+static void
+photos_test_gegl_inverse_jacobian_zoom_1 (void)
+{
+ GeglBufferMatrix2 inverse_jacobian;
+
+ inverse_jacobian.coeff[0][0] = 0.25;
+ inverse_jacobian.coeff[0][1] = 0.0;
+ inverse_jacobian.coeff[1][0] = 0.0;
+ inverse_jacobian.coeff[1][1] = 0.714285714;
+ photos_test_gegl_check_inverse_jacobian (4.0, 1.4, &inverse_jacobian);
+}
+
+
+static void
+photos_test_gegl_inverse_jacobian_zoom_2 (void)
+{
+ GeglBufferMatrix2 inverse_jacobian;
+
+ inverse_jacobian.coeff[0][0] = 1.0;
+ inverse_jacobian.coeff[0][1] = 0.0;
+ inverse_jacobian.coeff[1][0] = 0.0;
+ inverse_jacobian.coeff[1][1] = 1.0;
+ photos_test_gegl_check_inverse_jacobian (1.0, 1.0, &inverse_jacobian);
+}
+
+
+static void
+photos_test_gegl_inverse_jacobian_zoom_3 (void)
+{
+ GeglBufferMatrix2 inverse_jacobian;
+
+ inverse_jacobian.coeff[0][0] = 1.66666667;
+ inverse_jacobian.coeff[0][1] = 0.0;
+ inverse_jacobian.coeff[1][0] = 0.0;
+ inverse_jacobian.coeff[1][1] = 4.0;
+ photos_test_gegl_check_inverse_jacobian (0.6, 0.25, &inverse_jacobian);
+}
+
+
+static void
+photos_test_gegl_inverse_jacobian_zoom_4 (void)
+{
+ GeglBufferMatrix2 inverse_jacobian;
+
+ inverse_jacobian.coeff[0][0] = 4.0;
+ inverse_jacobian.coeff[0][1] = 0.0;
+ inverse_jacobian.coeff[1][0] = 0.0;
+ inverse_jacobian.coeff[1][1] = 1.66666667;
+ photos_test_gegl_check_inverse_jacobian (0.25, 0.6, &inverse_jacobian);
+}
+
+
static void
photos_test_gegl_legacy_convert_between_buffer_pixbuf_0 (PhotosTestGeglFixture *fixture, gconstpointer
user_data)
{
@@ -1123,6 +1201,12 @@ main (gint argc, gchar *argv[])
photos_test_gegl_buffer_zoom_out_1,
photos_test_gegl_teardown);
+ g_test_add_func ("/gegl/inverse-jacobian-zoom-0", photos_test_gegl_inverse_jacobian_zoom_0);
+ g_test_add_func ("/gegl/inverse-jacobian-zoom-1", photos_test_gegl_inverse_jacobian_zoom_1);
+ g_test_add_func ("/gegl/inverse-jacobian-zoom-2", photos_test_gegl_inverse_jacobian_zoom_2);
+ g_test_add_func ("/gegl/inverse-jacobian-zoom-3", photos_test_gegl_inverse_jacobian_zoom_3);
+ g_test_add_func ("/gegl/inverse-jacobian-zoom-4", photos_test_gegl_inverse_jacobian_zoom_4);
+
g_test_add ("/gegl/legacy/convert-between-buffer-pixbuf-0",
PhotosTestGeglFixture,
NULL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]