[gnome-photos] gegl: Add some infrastructure to preemptively profile Babl conversions



commit d19b64a9bcaa1e5e6fcd8bdc55bf78c369d0b531
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Feb 2 02:03:02 2017 +0100

    gegl: Add some infrastructure to preemptively profile Babl conversions
    
    Not all conversions occur in performance-critical code paths. Hence, we
    start with a very conservative list:
     - "R'G'B' u8" to "cairo-ARGB32" is used to render all JPEGs, and
       those PNGs which use 8-bits per channel and have no alpha.
     - "R'G'B' u8" to "YA float" is used to generate the preview of the
       Gotham filter for all such items.

 src/photos-gegl.c |   35 +++++++++++++++++++++++++++++++++++
 src/photos-gegl.h |    2 ++
 2 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-gegl.c b/src/photos-gegl.c
index b0584fe..9080490 100644
--- a/src/photos-gegl.c
+++ b/src/photos-gegl.c
@@ -34,6 +34,17 @@
 #include "photos-quarks.h"
 
 
+static const struct
+{
+  const gchar *input_format;
+  const gchar *output_format;
+} REQUIRED_BABL_FISHES[] =
+{
+  { "R'G'B' u8", "cairo-ARGB32" },
+  { "R'G'B' u8", "YA float" }
+};
+
+
 static GeglBuffer *
 photos_gegl_buffer_zoom (GeglBuffer *buffer, gdouble zoom, GCancellable *cancellable, GError **error)
 {
@@ -253,6 +264,30 @@ photos_gegl_get_buffer_from_node (GeglNode *node, const Babl *format)
 }
 
 
+void
+photos_gegl_init_fishes (void)
+{
+  gint64 end;
+  gint64 start;
+  guint i;
+
+  start = g_get_monotonic_time ();
+
+  for (i = 0; i < G_N_ELEMENTS (REQUIRED_BABL_FISHES); i++)
+    {
+      const Babl *input_format;
+      const Babl *output_format;
+
+      input_format = babl_format (REQUIRED_BABL_FISHES[i].input_format);
+      output_format = babl_format (REQUIRED_BABL_FISHES[i].output_format);
+      babl_fish (input_format, output_format);
+    }
+
+  end = g_get_monotonic_time ();
+  photos_debug (PHOTOS_DEBUG_GEGL, "GEGL: Init Fishes: %" G_GINT64_FORMAT, end - start);
+}
+
+
 static gboolean
 photos_gegl_processor_process_idle (gpointer user_data)
 {
diff --git a/src/photos-gegl.h b/src/photos-gegl.h
index 6889458..11d0176 100644
--- a/src/photos-gegl.h
+++ b/src/photos-gegl.h
@@ -47,6 +47,8 @@ void             photos_gegl_ensure_builtins              (void);
 
 GeglBuffer      *photos_gegl_get_buffer_from_node         (GeglNode *node, const Babl *format);
 
+void             photos_gegl_init_fishes                  (void);
+
 void             photos_gegl_processor_process_async      (GeglProcessor *processor,
                                                            GCancellable *cancellable,
                                                            GAsyncReadyCallback callback,


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