[gnome-flashback] common: remove gf_background_surface_create



commit 9b9f180b8b2f1123d7202b7cc3feb9f452a4a072
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Mar 20 17:39:34 2021 +0200

    common: remove gf_background_surface_create

 configure.ac                                    |   8 --
 gnome-flashback/libcommon/gf-background-utils.c | 161 ------------------------
 gnome-flashback/libcommon/gf-background-utils.h |   8 +-
 3 files changed, 1 insertion(+), 176 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c52ceae..a022721 100644
--- a/configure.ac
+++ b/configure.ac
@@ -289,14 +289,6 @@ PKG_CHECK_EXISTS([pango >= 1.44.0],
                  AC_DEFINE([HAVE_PANGO144], [1],
                            [Define if Pango is 1.44.0 or newer]))
 
-dnl **************************************************************************
-dnl Check if we have gnome-desktop 3.35.4 or newer
-dnl **************************************************************************
-
-PKG_CHECK_EXISTS([gnome-desktop-3.0 >= 3.35.4],
-                 AC_DEFINE([HAVE_GNOME_DESKTOP_3_35_4], [1],
-                           [Define if gnome-desktop is 3.35.4 or newer]))
-
 dnl **************************************************************************
 dnl Systemd session
 dnl **************************************************************************
diff --git a/gnome-flashback/libcommon/gf-background-utils.c b/gnome-flashback/libcommon/gf-background-utils.c
index 66ddaef..927871a 100644
--- a/gnome-flashback/libcommon/gf-background-utils.c
+++ b/gnome-flashback/libcommon/gf-background-utils.c
@@ -24,94 +24,6 @@
 
 static const cairo_user_data_key_t average_color_key;
 
-static cairo_surface_t *
-get_surface_as_image_surface (cairo_surface_t *surface)
-{
-  cairo_surface_t *image;
-  cairo_t *cr;
-
-  if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE)
-    return cairo_surface_reference (surface);
-
-  image = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
-                                      cairo_xlib_surface_get_width (surface),
-                                      cairo_xlib_surface_get_height (surface));
-
-  cr = cairo_create (image);
-
-  cairo_set_source_surface (cr, surface, 0, 0);
-  cairo_paint (cr);
-
-  cairo_destroy (cr);
-
-  return image;
-}
-
-static void
-get_average_color (cairo_surface_t *surface,
-                   GdkRGBA         *color)
-{
-  cairo_surface_t *image;
-  unsigned char *data;
-  int width;
-  int height;
-  int stride;
-  guint64 red_total;
-  guint64 green_total;
-  guint64 blue_total;
-  guint64 pixels_total;
-  int row;
-  int column;
-
-  image = get_surface_as_image_surface (surface);
-
-  data = cairo_image_surface_get_data (image);
-  width = cairo_image_surface_get_width (image);
-  height = cairo_image_surface_get_height (image);
-  stride = cairo_image_surface_get_stride (image);
-
-  red_total = 0;
-  green_total = 0;
-  blue_total = 0;
-  pixels_total = (guint64) width * height;
-
-  for (row = 0; row < height; row++)
-    {
-      unsigned char *p;
-
-      p = data + (row * stride);
-
-      for (column = 0; column < width; column++)
-        {
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-          blue_total += *p++;
-          green_total += *p++;
-          red_total += *p++;
-          p++;
-#else
-          p++;
-          red_total += *p++;
-          green_total += *p++;
-          blue_total += *p++;
-#endif
-        }
-    }
-
-  cairo_surface_destroy (image);
-
-  pixels_total *= 0xff;
-  color->red = (double) red_total / pixels_total;
-  color->green = (double) green_total / pixels_total;
-  color->blue = (double) blue_total / pixels_total;
-  color->alpha = 1.0;
-}
-
-static void
-destroy_color (void *data)
-{
-  gdk_rgba_free (data);
-}
-
 static gboolean
 is_valid_pixmap (GdkDisplay *display,
                  Pixmap      pixmap)
@@ -351,79 +263,6 @@ set_average_color (GdkDisplay *display,
     }
 }
 
-cairo_surface_t *
-gf_background_surface_create (GdkDisplay *display,
-                              GnomeBG    *bg,
-                              GdkWindow  *window,
-                              int         width,
-                              int         height)
-{
-  cairo_surface_t *surface;
-  cairo_t *cr;
-  GdkRGBA color;
-  int n_monitors;
-  int i;
-
-  surface = gdk_window_create_similar_surface (window,
-                                               CAIRO_CONTENT_COLOR,
-                                               width,
-                                               height);
-
-  cr = cairo_create (surface);
-
-  color = (GdkRGBA) {};
-
-  n_monitors = gdk_display_get_n_monitors (display);
-
-  for (i = 0; i < n_monitors; i++)
-    {
-      GdkMonitor *monitor;
-      GdkRectangle geometry;
-      cairo_surface_t *monitor_surface;
-      GdkRGBA monitor_color;
-
-      monitor = gdk_display_get_monitor (display, i);
-      gdk_monitor_get_geometry (monitor, &geometry);
-
-#ifdef HAVE_GNOME_DESKTOP_3_35_4
-      monitor_surface = gnome_bg_create_surface (bg,
-                                                 window,
-                                                 geometry.width,
-                                                 geometry.height);
-#else
-      monitor_surface = gnome_bg_create_surface (bg,
-                                                 window,
-                                                 geometry.width,
-                                                 geometry.height,
-                                                 FALSE);
-#endif
-
-      cairo_set_source_surface (cr, monitor_surface, geometry.x, geometry.y);
-      cairo_paint (cr);
-
-      get_average_color (monitor_surface, &monitor_color);
-      cairo_surface_destroy (monitor_surface);
-
-      color.red += monitor_color.red;
-      color.green += monitor_color.green;
-      color.blue += monitor_color.blue;
-    }
-
-  cairo_destroy (cr);
-
-  color.red /= n_monitors;
-  color.green /= n_monitors;
-  color.blue /= n_monitors;
-  color.alpha = 1.0;
-
-  cairo_surface_set_user_data (surface,
-                               &average_color_key,
-                               gdk_rgba_copy (&color),
-                               destroy_color);
-
-  return surface;
-}
-
 cairo_surface_t *
 gf_background_surface_get_from_root (GdkDisplay *display,
                                      int         width,
diff --git a/gnome-flashback/libcommon/gf-background-utils.h b/gnome-flashback/libcommon/gf-background-utils.h
index 229c5a6..cd91acc 100644
--- a/gnome-flashback/libcommon/gf-background-utils.h
+++ b/gnome-flashback/libcommon/gf-background-utils.h
@@ -18,16 +18,10 @@
 #ifndef GF_BACKGROUND_UTILS_H
 #define GF_BACKGROUND_UTILS_H
 
-#include <libgnome-desktop/gnome-bg.h>
+#include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
-cairo_surface_t *gf_background_surface_create            (GdkDisplay      *display,
-                                                          GnomeBG         *bg,
-                                                          GdkWindow       *window,
-                                                          int              width,
-                                                          int              height);
-
 cairo_surface_t *gf_background_surface_get_from_root     (GdkDisplay      *display,
                                                           int              width,
                                                           int              height);


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