From d847d2c2208ab793e59b264a6c0fedbc0f71f6c1 Mon Sep 17 00:00:00 2001
From: Benedikt Meurer <benny@xfce.org>
Date: Thu, 2 Mar 2006 15:09:57 +0000
Subject: [PATCH] 2006-03-02	Benedikt Meurer <benny@xfce.org>

	* configure.in.in, thunar/thunar-gdk-pixbuf-extensions.{c,h},
	  thunar/thunar-icon-renderer.c: Some of the gdk-pixbuf extensions were
	  moved to libexo. Use the libexo ones.




(Old svn revision: 20174)
---
 ChangeLog                             |   6 +
 configure.in.in                       |   2 +-
 thunar/thunar-gdk-pixbuf-extensions.c | 338 --------------------------
 thunar/thunar-gdk-pixbuf-extensions.h |  10 +-
 thunar/thunar-icon-renderer.c         |   8 +-
 5 files changed, 12 insertions(+), 352 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b63933f0e..140075fee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-03-02	Benedikt Meurer <benny@xfce.org>
+
+	* configure.in.in, thunar/thunar-gdk-pixbuf-extensions.{c,h},
+	  thunar/thunar-icon-renderer.c: Some of the gdk-pixbuf extensions were
+	  moved to libexo. Use the libexo ones.
+
 2006-03-02	Benedikt Meurer <benny@xfce.org>
 
 	* thunar/thunar-stock.{c,h}, thunar/thunar-create-dialog.c,
diff --git a/configure.in.in b/configure.in.in
index 073c1f76e..25ac1b94c 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -102,7 +102,7 @@ dnl **********************************
 dnl *** Check for standard headers ***
 dnl **********************************
 AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h fnmatch.h fstab.h grp.h \
-                  locale.h math.h memory.h mmintrin.h mntent.h pwd.h regex.h sched.h setjmp.h \
+                  locale.h math.h memory.h mntent.h pwd.h regex.h sched.h setjmp.h \
                   stdarg.h stdlib.h string.h sys/xattr.h sys/extattr.h \
                   sys/cdio.h sys/mman.h sys/mount.h sys/param.h sys/stat.h \
                   sys/statfs.h sys/statvfs.h sys/time.h sys/uio.h \
diff --git a/thunar/thunar-gdk-pixbuf-extensions.c b/thunar/thunar-gdk-pixbuf-extensions.c
index 3acdaa43d..d173e0830 100644
--- a/thunar/thunar-gdk-pixbuf-extensions.c
+++ b/thunar/thunar-gdk-pixbuf-extensions.c
@@ -24,131 +24,10 @@
 #include <config.h>
 #endif
 
-#ifdef HAVE_MMINTRIN_H
-#include <mmintrin.h>
-#endif
-
 #include <thunar/thunar-gdk-pixbuf-extensions.h>
 
 
 
-/**
- * thunar_gdk_pixbuf_colorize:
- * @src   : the source #GdkPixbuf.
- * @color : the new color.
- *
- * Creates a new #GdkPixbuf based on @src, which is
- * colorized to @color.
- *
- * Return value: the colorized #GdkPixbuf.
- **/
-GdkPixbuf*
-thunar_gdk_pixbuf_colorize (const GdkPixbuf *src,
-                            const GdkColor  *color)
-{
-  GdkPixbuf *dst;
-  gboolean   has_alpha;
-  gint       dst_row_stride;
-  gint       src_row_stride;
-  gint       width;
-  gint       height;
-  gint       i;
-
-  /* determine source parameters */
-  width = gdk_pixbuf_get_width (src);
-  height = gdk_pixbuf_get_height (src);
-  has_alpha = gdk_pixbuf_get_has_alpha (src);
-
-  /* allocate the destination pixbuf */
-  dst = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src), has_alpha, gdk_pixbuf_get_bits_per_sample (src), width, height);
-
-  /* determine row strides on src/dst */
-  dst_row_stride = gdk_pixbuf_get_rowstride (dst);
-  src_row_stride = gdk_pixbuf_get_rowstride (src);
-
-#if defined(__GNUC__) && defined(__MMX__)
-  /* check if there's a good reason to use MMX */
-  if (G_LIKELY (has_alpha && dst_row_stride == width * 4 && src_row_stride == width * 4 && (width * height) % 2 == 0))
-    {
-      __m64 *pixdst = (__m64 *) gdk_pixbuf_get_pixels (dst);
-      __m64 *pixsrc = (__m64 *) gdk_pixbuf_get_pixels (src);
-      __m64  alpha_mask = _mm_set_pi8 (0xff, 0, 0, 0, 0xff, 0, 0, 0);
-      __m64  color_factor = _mm_set_pi16 (0, color->blue, color->green, color->red);
-      __m64  zero = _mm_setzero_si64 ();
-      __m64  src, alpha, hi, lo;
-
-      /* divide color components by 256 */
-      color_factor = _mm_srli_pi16 (color_factor, 8);
-
-      for (i = (width * height) >> 1; i > 0; --i)
-        {
-          /* read the source pixel */
-          src = *pixsrc;
-
-          /* remember the two alpha values */
-          alpha = _mm_and_si64 (alpha_mask, src);
-
-          /* extract the hi pixel */
-          hi = _mm_unpackhi_pi8 (src, zero);
-          hi = _mm_mullo_pi16 (hi, color_factor);
-
-          /* extract the lo pixel */
-          lo = _mm_unpacklo_pi8 (src, zero);
-          lo = _mm_mullo_pi16 (lo, color_factor);
-
-          /* prefetch the next two pixels */
-          __builtin_prefetch (++pixsrc, 0, 1);
-
-          /* divide by 256 */
-          hi = _mm_srli_pi16 (hi, 8);
-          lo = _mm_srli_pi16 (lo, 8);
-
-          /* combine the 2 pixels again */
-          src = _mm_packs_pu16 (lo, hi);
-
-          /* write back the calculated color together with the alpha */
-          *pixdst = _mm_or_si64 (alpha, src);
-
-          /* advance the dest pointer */
-          ++pixdst;
-        }
-
-      _mm_empty ();
-    }
-  else
-#endif
-    {
-      guchar *dst_pixels = gdk_pixbuf_get_pixels (dst);
-      guchar *src_pixels = gdk_pixbuf_get_pixels (src);
-      guchar *pixdst;
-      guchar *pixsrc;
-      gint    red_value = color->red / 255.0;
-      gint    green_value = color->green / 255.0;
-      gint    blue_value = color->blue / 255.0;
-      gint    j;
-
-      for (i = height; --i >= 0; )
-        {
-          pixdst = dst_pixels + i * dst_row_stride;
-          pixsrc = src_pixels + i * src_row_stride;
-
-          for (j = width; j > 0; --j)
-            {
-              *pixdst++ = (*pixsrc++ * red_value) >> 8;
-              *pixdst++ = (*pixsrc++ * green_value) >> 8;
-              *pixdst++ = (*pixsrc++ * blue_value) >> 8;
-              
-              if (has_alpha)
-                *pixdst++ = *pixsrc++;
-            }
-        }
-    }
-
-  return dst;
-}
-
-
-
 static void
 draw_frame_row (GdkPixbuf *frame_image,
                 gint       target_width,
@@ -273,221 +152,4 @@ thunar_gdk_pixbuf_frame (GdkPixbuf *src,
 
 
 
-/**
- * thunar_gdk_pixbuf_lucent:
- * @src     : the source #GdkPixbuf.
- * @percent : the percentage of translucency.
- *
- * Returns a version of @src, whose pixels translucency is
- * @percent of the original @src pixels.
- *
- * The caller is responsible to free the returned object
- * using g_object_unref() when no longer needed.
- *
- * Return value: a translucent version of @src.
- **/
-GdkPixbuf*
-thunar_gdk_pixbuf_lucent (const GdkPixbuf *src,
-                          guint            percent)
-{
-  GdkPixbuf *dst;
-  guchar    *dst_pixels;
-  guchar    *src_pixels;
-  guchar    *pixdst;
-  guchar    *pixsrc;
-  gint       dst_row_stride;
-  gint       src_row_stride;
-  gint       width;
-  gint       height;
-  gint       i, j;
-
-  g_return_val_if_fail (GDK_IS_PIXBUF (src), NULL);
-  g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
-
-  /* determine source parameters */
-  width = gdk_pixbuf_get_width (src);
-  height = gdk_pixbuf_get_height (src);
-
-  /* allocate the destination pixbuf */
-  dst = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src), TRUE, gdk_pixbuf_get_bits_per_sample (src), width, height);
-
-  /* determine row strides on src/dst */
-  dst_row_stride = gdk_pixbuf_get_rowstride (dst);
-  src_row_stride = gdk_pixbuf_get_rowstride (src);
-
-  /* determine pixels on src/dst */
-  dst_pixels = gdk_pixbuf_get_pixels (dst);
-  src_pixels = gdk_pixbuf_get_pixels (src);
-
-  /* check if the source already contains an alpha channel */
-  if (G_LIKELY (gdk_pixbuf_get_has_alpha (src)))
-    {
-      for (i = height; --i >= 0; )
-        {
-          pixdst = dst_pixels + i * dst_row_stride;
-          pixsrc = src_pixels + i * src_row_stride;
-
-          for (j = width; --j >= 0; )
-            {
-              *pixdst++ = *pixsrc++;
-              *pixdst++ = *pixsrc++;
-              *pixdst++ = *pixsrc++;
-              *pixdst++ = ((guint) *pixsrc++ * percent) / 100u;
-            }
-        }
-    }
-  else
-    {
-      /* pre-calculate the alpha value */
-      percent = (255u * percent) / 100u;
-
-      for (i = height; --i >= 0; )
-        {
-          pixdst = dst_pixels + i * dst_row_stride;
-          pixsrc = src_pixels + i * src_row_stride;
-
-          for (j = width; --j >= 0; )
-            {
-              *pixdst++ = *pixsrc++;
-              *pixdst++ = *pixsrc++;
-              *pixdst++ = *pixsrc++;
-              *pixdst++ = percent;
-            }
-        }
-    }
-
-  return dst;
-}
-
-
-
-static guchar
-lighten_channel (guchar cur_value)
-{
-  gint new_value = cur_value;
-
-  new_value += 24 + (new_value >> 3);
-  if (G_UNLIKELY (new_value > 255))
-    new_value = 255;
-
-  return (guchar) new_value;
-}
-
-
-
-/**
- * thunar_gdk_pixbuf_spotlight:
- * @src : the source #GdkPixbuf.
- *
- * Creates a lightened version of @src, suitable for
- * prelit state display of icons.
- *
- * The caller is responsible to free the returned
- * pixbuf using #g_object_unref().
- *
- * Return value: the lightened version of @src.
- **/
-GdkPixbuf*
-thunar_gdk_pixbuf_spotlight (const GdkPixbuf *src)
-{
-  GdkPixbuf *dst;
-  gboolean   has_alpha;
-  gint       dst_row_stride;
-  gint       src_row_stride;
-  gint       width;
-  gint       height;
-  gint       i;
-
-  /* determine source parameters */
-  width = gdk_pixbuf_get_width (src);
-  height = gdk_pixbuf_get_height (src);
-  has_alpha = gdk_pixbuf_get_has_alpha (src);
-
-  /* allocate the destination pixbuf */
-  dst = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src), has_alpha, gdk_pixbuf_get_bits_per_sample (src), width, height);
-
-  /* determine src/dst row strides */
-  dst_row_stride = gdk_pixbuf_get_rowstride (dst);
-  src_row_stride = gdk_pixbuf_get_rowstride (src);
-  
-#if defined(__GNUC__) && defined(__MMX__)
-  /* check if there's a good reason to use MMX */
-  if (G_LIKELY (has_alpha && dst_row_stride == width * 4 && src_row_stride == width * 4 && (width * height) % 2 == 0))
-    {
-      __m64 *pixdst = (__m64 *) gdk_pixbuf_get_pixels (dst);
-      __m64 *pixsrc = (__m64 *) gdk_pixbuf_get_pixels (src);
-      __m64  alpha_mask = _mm_set_pi8 (0xff, 0, 0, 0, 0xff, 0, 0, 0);
-      __m64  twentyfour = _mm_set_pi8 (0, 24, 24, 24, 0, 24, 24, 24);
-      __m64  zero = _mm_setzero_si64 ();
-
-      for (i = (width * height) >> 1; i > 0; --i)
-        {
-          /* read the source pixel */
-          __m64 src = *pixsrc;
-
-          /* remember the two alpha values */
-          __m64 alpha = _mm_and_si64 (alpha_mask, src);
-
-          /* extract the hi pixel */
-          __m64 hi = _mm_unpackhi_pi8 (src, zero);
-
-          /* extract the lo pixel */
-          __m64 lo = _mm_unpacklo_pi8 (src, zero);
-
-          /* add (x >> 3) to x */
-          hi = _mm_adds_pu16 (hi, _mm_srli_pi16 (hi, 3));
-          lo = _mm_adds_pu16 (lo, _mm_srli_pi16 (lo, 3));
-
-          /* prefetch next value */
-          __builtin_prefetch (++pixsrc, 0, 1);
-
-          /* combine the two pixels again */
-          src = _mm_packs_pu16 (lo, hi);
-
-          /* add 24 (with saturation) */
-          src = _mm_adds_pu8 (src, twentyfour);
-
-          /* drop the alpha channel from the temp color */
-          src = _mm_andnot_si64 (alpha_mask, src);
-
-          /* write back the calculated color */
-          *pixdst = _mm_or_si64 (alpha, src);
-
-          /* advance the dest pointer */
-          ++pixdst;
-        }
-
-      _mm_empty ();
-    }
-  else
-#endif
-    {
-      guchar *dst_pixels = gdk_pixbuf_get_pixels (dst);
-      guchar *src_pixels = gdk_pixbuf_get_pixels (src);
-      guchar *pixdst;
-      guchar *pixsrc;
-      gint    j;
-
-      for (i = height; --i >= 0; )
-        {
-          pixdst = dst_pixels + i * dst_row_stride;
-          pixsrc = src_pixels + i * src_row_stride;
-      
-          for (j = width; j > 0; --j)
-            {
-              *pixdst++ = lighten_channel (*pixsrc++);
-              *pixdst++ = lighten_channel (*pixsrc++);
-              *pixdst++ = lighten_channel (*pixsrc++);
-
-              if (G_LIKELY (has_alpha))
-                *pixdst++ = *pixsrc++;
-            }
-        }
-    }
-
-  return dst;
-}
-
-
-
 
diff --git a/thunar/thunar-gdk-pixbuf-extensions.h b/thunar/thunar-gdk-pixbuf-extensions.h
index b89b3b5ab..8d87430c1 100644
--- a/thunar/thunar-gdk-pixbuf-extensions.h
+++ b/thunar/thunar-gdk-pixbuf-extensions.h
@@ -20,13 +20,10 @@
 #ifndef __THUNAR_GDK_PIXBUF_EXTENSIONS_H__
 #define __THUNAR_GDK_PIXBUF_EXTENSIONS_H__
 
-#include <gdk/gdk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
 
 G_BEGIN_DECLS;
 
-GdkPixbuf *thunar_gdk_pixbuf_colorize  (const GdkPixbuf *src,
-                                        const GdkColor  *color);
-
 GdkPixbuf *thunar_gdk_pixbuf_frame     (GdkPixbuf       *src,
                                         GdkPixbuf       *frame,
                                         gint             left_offset,
@@ -34,11 +31,6 @@ GdkPixbuf *thunar_gdk_pixbuf_frame     (GdkPixbuf       *src,
                                         gint             right_offset,
                                         gint             bottom_offset);
 
-GdkPixbuf *thunar_gdk_pixbuf_lucent    (const GdkPixbuf *src,
-                                        guint            percent);
-
-GdkPixbuf *thunar_gdk_pixbuf_spotlight (const GdkPixbuf *src);
-
 G_END_DECLS;
 
 #endif /* !__THUNAR_GDK_PIXBUF_EXTENSIONS_H__ */
diff --git a/thunar/thunar-icon-renderer.c b/thunar/thunar-icon-renderer.c
index cea075e61..27acb1949 100644
--- a/thunar/thunar-icon-renderer.c
+++ b/thunar/thunar-icon-renderer.c
@@ -417,14 +417,14 @@ thunar_icon_renderer_render (GtkCellRenderer     *renderer,
       if (thunar_clipboard_manager_has_cutted_file (clipboard, icon_renderer->file))
         {
           /* 50% translucent for cutted files */
-          temp = thunar_gdk_pixbuf_lucent (icon, 50);
+          temp = exo_gdk_pixbuf_lucent (icon, 50);
           g_object_unref (G_OBJECT (icon));
           icon = temp;
         }
       else if (thunar_file_is_hidden (icon_renderer->file))
         {
           /* 75% translucent for hidden files */
-          temp = thunar_gdk_pixbuf_lucent (icon, 75);
+          temp = exo_gdk_pixbuf_lucent (icon, 75);
           g_object_unref (G_OBJECT (icon));
           icon = temp;
         }
@@ -436,14 +436,14 @@ thunar_icon_renderer_render (GtkCellRenderer     *renderer,
           if ((flags & GTK_CELL_RENDERER_SELECTED) != 0)
             {
               state = GTK_WIDGET_HAS_FOCUS (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE;
-              temp = thunar_gdk_pixbuf_colorize (icon, &widget->style->base[state]);
+              temp = exo_gdk_pixbuf_colorize (icon, &widget->style->base[state]);
               g_object_unref (G_OBJECT (icon));
               icon = temp;
             }
 
           if ((flags & GTK_CELL_RENDERER_PRELIT) != 0)
             {
-              temp = thunar_gdk_pixbuf_spotlight (icon);
+              temp = exo_gdk_pixbuf_spotlight (icon);
               g_object_unref (G_OBJECT (icon));
               icon = temp;
             }
-- 
GitLab