[maemo-commits] [maemo-commits] r18441 - in projects/haf/trunk/hildon-thumbnail: . daemon daemon/plugins
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue May 19 17:35:00 EEST 2009
- Previous message: [maemo-commits] r18440 - in projects/haf/trunk/libsdl1.2/debian: . patches
- Next message: [maemo-commits] r18442 - projects/haf/tags/libsdl1.2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: pvanhoof Date: 2009-05-19 17:34:54 +0300 (Tue, 19 May 2009) New Revision: 18441 Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog projects/haf/trunk/hildon-thumbnail/daemon/Makefile.am projects/haf/trunk/hildon-thumbnail/daemon/README.plugin-runner projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c projects/haf/trunk/hildon-thumbnail/daemon/plugins/Makefile.am projects/haf/trunk/hildon-thumbnail/daemon/plugins/epeg-plugin.c projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.c projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.h projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.h projects/haf/trunk/hildon-thumbnail/daemon/utils.c projects/haf/trunk/hildon-thumbnail/daemon/utils.h Log: 2009-05-19 Philip Van Hoof <pvanhoof at codeminded.be> * daemon/hildon-thumbnail-daemon.c * daemon/plugins/gdkpixbuf-plugin.c * daemon/plugins/Makefile.am * daemon/plugins/epeg-plugin.c * daemon/utils.c * daemon/utils.h * daemon/thumbnailer.c * daemon/thumbnailer.h * daemon/README.plugin-runner * daemon/thumb-hal.c * daemon/thumb-hal.h * daemon/Makefile.am: Bugfix for Bug #117799, properly scale wide images to cropped Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog =================================================================== --- projects/haf/trunk/hildon-thumbnail/ChangeLog 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/ChangeLog 2009-05-19 14:34:54 UTC (rev 18441) @@ -1,3 +1,19 @@ +2009-05-19 Philip Van Hoof <pvanhoof at codeminded.be> + + * daemon/hildon-thumbnail-daemon.c + * daemon/plugins/gdkpixbuf-plugin.c + * daemon/plugins/Makefile.am + * daemon/plugins/epeg-plugin.c + * daemon/utils.c + * daemon/utils.h + * daemon/thumbnailer.c + * daemon/thumbnailer.h + * daemon/README.plugin-runner + * daemon/thumb-hal.c + * daemon/thumb-hal.h + * daemon/Makefile.am: Bugfix for Bug #117799, properly scale wide + images to cropped + 2009-05-18 Philip Van Hoof <pvanhoof at codeminded.be> * daemon/plugins/gdkpixbuf-png-out-plugin.c Modified: projects/haf/trunk/hildon-thumbnail/daemon/Makefile.am =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/Makefile.am 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/daemon/Makefile.am 2009-05-19 14:34:54 UTC (rev 18441) @@ -2,7 +2,7 @@ INCLUDES = -I. \ $(DBUS_CFLAGS) \ - $(GLIB_CFLAGS) \ + $(GLIB_CFLAGS) $(GDK_PIXBUF_CFLAGS) \ $(GMODULE_CFLAGS) \ $(GIO_CFLAGS) $(HAL_CFLAGS) \ $(LIBOSSO_CFLAGS) \ @@ -76,7 +76,7 @@ $(top_builddir)/daemon/libshared.la \ $(DBUS_LIBS) $(LIBOSSO_LIBS) \ $(GLIB_LIBS) \ - $(GMODULE_LIBS) \ + $(GMODULE_LIBS) $(GDK_PIXBUF_LIBS) \ $(GIO_LIBS) $(HAL_LIBS) # Services Modified: projects/haf/trunk/hildon-thumbnail/daemon/README.plugin-runner =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/README.plugin-runner 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/daemon/README.plugin-runner 2009-05-19 14:34:54 UTC (rev 18441) @@ -22,4 +22,5 @@ dbus-send --print-reply --dest=org.freedesktop.thumbnailer \ --type=method_call /org/freedesktop/thumbnailer/Generic \ org.freedesktop.thumbnailer.Generic.Queue \ - array:string:"$IMAGE_TO_THUMB" uint32:0 + array:string:"file:///tmp/Image001.jpg","file:///tmp/Image002.jpg" array:string:"image/jpeg","image/jpeg" uint32:0 + Modified: projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c 2009-05-19 14:34:54 UTC (rev 18441) @@ -481,7 +481,7 @@ G_CALLBACK (on_outputplugin_changed), thumbnailer); - thumb_hal_init (); + thumb_hal_init (thumbnailer); main_loop = g_main_loop_new (NULL, FALSE); Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/Makefile.am =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/plugins/Makefile.am 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/Makefile.am 2009-05-19 14:34:54 UTC (rev 18441) @@ -1,3 +1,5 @@ +INCLUDES = $(GDK_PIXBUF_CFLAGS) + plugin_flags = -module -avoid-version -no-undefined pluginsdir = $(libdir)/hildon-thumbnailer/plugins Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/epeg-plugin.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/plugins/epeg-plugin.c 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/epeg-plugin.c 2009-05-19 14:34:54 UTC (rev 18441) @@ -316,123 +316,33 @@ static GdkPixbuf* crop_resize (GdkPixbuf *src, int width, int height) { - int x = width, y = height; - int a = gdk_pixbuf_get_width(src); - int b = gdk_pixbuf_get_height(src); - GdkPixbuf *dest; + return hildon_thumbnail_crop_resize (src, width, height); +} - // This is the automagic cropper algorithm - // It is an optimized version of a system of equations - // Basically it maximizes the final size while minimizing the scale - int nx, ny; - double na, nb; - double offx = 0, offy = 0; - double scax, scay; - na = a; - nb = b; - if(a < x && b < y) { - //nx = a; - //ny = b; - g_object_ref(src); - return src; - } else { - int u, v; - - nx = u = x; - ny = v = y; - - if(a < x) { - nx = a; - u = a; - } - - if(b < y) { - ny = b; - v = b; - } - - if(a * y < b * x) { - nb = (double)a * v / u; - // Center - offy = (double)(b - nb) / 2; - } else { - na = (double)b * u / v; - // Center - offx = (double)(a - na) / 2; - } - } - - // gdk_pixbuf_scale has crappy inputs - scax = scay = (double)nx / na; - - offx = -offx * scax; - offy = -offy * scay; - - dest = gdk_pixbuf_new (gdk_pixbuf_get_colorspace(src), - gdk_pixbuf_get_has_alpha(src), - gdk_pixbuf_get_bits_per_sample(src), - nx, ny); - - gdk_pixbuf_scale (src, dest, 0, 0, nx, ny, offx, offy, scax, scay, - GDK_INTERP_BILINEAR); - - return dest; -} - - static void wanted_size (int a, int b, int width, int height, int *w, int *h) { - int x = width, y = height; - int nx, ny; - double na, nb; - double offx = 0, offy = 0; - double scax, scay; - na = a; - nb = b; - - if(a < x && b < y) { - nx = a; - ny = b; + if(a < width && b < height) { + *w = width; + *h = height; } else { - int u, v; + int rw, rh; - nx = u = x; - ny = v = y; - - if(a < x) { - nx = a; - u = a; - } - - if(b < y) { - ny = b; - v = b; - } - - if(a * y < b * x) { - nb = (double)a * v / u; - // Center - offy = (double)(b - nb) / 2; + rw = a / width; + rh = b / height; + if (rw > rh) { + *h = b / rw; + *w = width; } else { - na = (double)b * u / v; - // Center - offx = (double)(a - na) / 2; + *w = a / rh; + *h = height; } } - scax = scay = (double)nx / na; - - offx = -offx * scax; - offy = -offy * scay; - - *w = nx; - *h = ny; - return; } @@ -509,8 +419,10 @@ epeg_size_get (im, &ow, &oh); - wanted_size (ow, oh, LARGE, LARGE, &ww, &wh); + wanted_size (ow, oh, LARGE , LARGE, &ww, &wh); + // printf ("%dx%d -> %dx%d\n", ow, oh, ww, wh); + if (ow < LARGE || oh < LARGE) { /* Epeg doesn't behave as expected when the destination is larger * than the source */ @@ -551,7 +463,7 @@ pixbuf_large1 = gdk_pixbuf_new_from_data ((const guchar*) data, GDK_COLORSPACE_RGB, FALSE, - 8, LARGE, LARGE, LARGE*3, + 8, ww, wh, ww*3, destroy_pixbuf, im); restore_orientation (path, pixbuf_large1); @@ -730,8 +642,6 @@ reload_config (const gchar *config) { GKeyFile *keyfile; - GStrv mimetypes; - guint i = 0, length; GError *error = NULL; keyfile = g_key_file_new (); @@ -753,7 +663,7 @@ } static void -on_file_changed (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type, gpointer user_data) +on_file_changed (GFileMonitor *monitor_, GFile *file, GFile *other_file, GFileMonitorEvent event_type, gpointer user_data) { if (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT || event_type == G_FILE_MONITOR_EVENT_CREATED) { gchar *config = g_file_get_path (file); @@ -768,7 +678,7 @@ gchar *config = g_build_filename (g_get_user_config_dir (), "hildon-thumbnailer", "epeg-plugin.conf", NULL); GFile *file = g_file_new_for_path (config); guint i = 0; - const gchar **supported; + const gchar **supported_; const gchar *uri_schemes[2] = { "file", NULL }; monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); @@ -783,10 +693,10 @@ *cropping = do_cropped; if (func) { - supported = hildon_thumbnail_plugin_supported (); - if (supported) { - while (supported[i] != NULL) { - func (thumbnailer, supported[i], module, (const GStrv) uri_schemes, 1); + supported_ = hildon_thumbnail_plugin_supported (); + if (supported_) { + while (supported_[i] != NULL) { + func (thumbnailer, supported_[i], module, (const GStrv) uri_schemes, 1); i++; } } Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c 2009-05-19 14:34:54 UTC (rev 18441) @@ -92,71 +92,8 @@ static GdkPixbuf* crop_resize (GdkPixbuf *src, int width, int height) { - int x = width, y = height; - int a = gdk_pixbuf_get_width(src); - int b = gdk_pixbuf_get_height(src); - GdkPixbuf *dest; - - // This is the automagic cropper algorithm - // It is an optimized version of a system of equations - // Basically it maximizes the final size while minimizing the scale - - int nx, ny; - double na, nb; - double offx = 0, offy = 0; - double scax, scay; - - na = a; - nb = b; - - if(a < x && b < y) { - //nx = a; - //ny = b; - g_object_ref(src); - return src; - } else { - int u, v; - - nx = u = x; - ny = v = y; - - if(a < x) { - nx = a; - u = a; - } - - if(b < y) { - ny = b; - v = b; - } - - if(a * y < b * x) { - nb = (double)a * v / u; - // Center - offy = (double)(b - nb) / 2; - } else { - na = (double)b * u / v; - // Center - offx = (double)(a - na) / 2; - } - } - - // gdk_pixbuf_scale has crappy inputs - scax = scay = (double)nx / na; - - offx = -offx * scax; - offy = -offy * scay; - - dest = gdk_pixbuf_new (gdk_pixbuf_get_colorspace(src), - gdk_pixbuf_get_has_alpha(src), - gdk_pixbuf_get_bits_per_sample(src), - nx, ny); - - gdk_pixbuf_scale (src, dest, 0, 0, nx, ny, offx, offy, scax, scay, - GDK_INTERP_BILINEAR); - - return dest; + return hildon_thumbnail_crop_resize (src, width, height); } void Modified: projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.c 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.c 2009-05-19 14:34:54 UTC (rev 18441) @@ -8,6 +8,7 @@ #define CHECK_FILE "/tmp/thumbnailer_please_wait" static GVolumeMonitor *monitor; +static Thumbnailer *thumbnailer; static void on_pre_unmount (GVolumeMonitor *volume_monitor, @@ -18,6 +19,8 @@ if (g_drive_is_media_removable (drive)) { FILE *filep; + thumbnailer_crash_out (thumbnailer); + g_object_unref (drive); /* The idea here is that if we had to force-shutdown because of an @@ -36,7 +39,7 @@ } void -thumb_hal_init (void) +thumb_hal_init (Thumbnailer *thumbnailer_) { FILE *filep; @@ -50,6 +53,8 @@ monitor = g_volume_monitor_get (); + thumbnailer = g_object_ref (thumbnailer_); + g_signal_connect (G_OBJECT (monitor), "mount-pre-unmount", G_CALLBACK (on_pre_unmount), NULL); } @@ -58,4 +63,5 @@ thumb_hal_shutdown (void) { g_object_unref (monitor); + g_object_unref (thumbnailer); } Modified: projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.h =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.h 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/daemon/thumb-hal.h 2009-05-19 14:34:54 UTC (rev 18441) @@ -4,9 +4,18 @@ #include <glib-object.h> #include <gio/gio.h> +#include <string.h> +#include <ctype.h> +#include <glib.h> +#include <glib/gstdio.h> +#include <gio/gio.h> +#include <dbus/dbus-glib-bindings.h> + +#include "thumbnailer.h" + G_BEGIN_DECLS -void thumb_hal_init (void); +void thumb_hal_init (Thumbnailer *thumbnailer); void thumb_hal_shutdown (void); G_END_DECLS Modified: projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c 2009-05-19 14:34:54 UTC (rev 18441) @@ -230,7 +230,7 @@ Thumbnailer *object; GStrv urls, mime_types; guint num; - gboolean unqueued; + gboolean unqueued, dead; } WorkTask; @@ -264,7 +264,26 @@ g_mutex_unlock (priv->mutex); } +static void +crash_queued (WorkTask *task, guint handle) +{ + task->unqueued = TRUE; + task->dead = TRUE; + g_signal_emit (task->object, signals[FINISHED_SIGNAL], 0, + task->num); +} + void +thumbnailer_crash_out (Thumbnailer *object) +{ + ThumbnailerPrivate *priv = THUMBNAILER_GET_PRIVATE (object); + + g_mutex_lock (priv->mutex); + g_list_foreach (priv->tasks, (GFunc) crash_queued, NULL); + g_mutex_unlock (priv->mutex); +} + +void thumbnailer_queue (Thumbnailer *object, GStrv urls, GStrv mime_hints, guint handle_to_unqueue, DBusGMethodInvocation *context) { ThumbnailerPrivate *priv = THUMBNAILER_GET_PRIVATE (object); @@ -281,6 +300,7 @@ task->num = ++num; task->object = g_object_ref (object); task->urls = g_strdupv (urls); + task->dead = FALSE; if (mime_hints) task->mime_types = g_strdupv (mime_hints); @@ -874,8 +894,10 @@ unqueued: - g_signal_emit (task->object, signals[FINISHED_SIGNAL], 0, - task->num); + if (!task->dead) { + g_signal_emit (task->object, signals[FINISHED_SIGNAL], 0, + task->num); + } g_object_unref (task->object); g_strfreev (task->urls); Modified: projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.h =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.h 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.h 2009-05-19 14:34:54 UTC (rev 18441) @@ -67,6 +67,8 @@ void thumbnailer_register_plugin (Thumbnailer *object, const gchar *mime_type, GModule *plugin, const GStrv uri_schemes, gint priority); void thumbnailer_unregister_plugin (Thumbnailer *object, GModule *plugin); +void thumbnailer_crash_out (Thumbnailer *object); + void thumbnailer_do_stop (void); void thumbnailer_do_init (DBusGConnection *connection, ThumbnailManager *manager, Thumbnailer **thumbnailer, GError **error); Modified: projects/haf/trunk/hildon-thumbnail/daemon/utils.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/utils.c 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/daemon/utils.c 2009-05-19 14:34:54 UTC (rev 18441) @@ -47,7 +47,76 @@ return retval; } +GdkPixbuf* +hildon_thumbnail_crop_resize (GdkPixbuf *src, int width, int height) { + int x = width, y = height; + int a = gdk_pixbuf_get_width(src); + int b = gdk_pixbuf_get_height(src); + + GdkPixbuf *dest; + + // This is the automagic cropper algorithm + // It is an optimized version of a system of equations + // Basically it maximizes the final size while minimizing the scale + + int nx, ny; + double na, nb; + double offx = 0, offy = 0; + double scax, scay; + + na = a; + nb = b; + + if(a < x && b < y) { + //nx = a; + //ny = b; + g_object_ref(src); + return src; + } else { + int u, v; + + nx = u = x; + ny = v = y; + + if(a < x) { + nx = a; + u = a; + } + + if(b < y) { + ny = b; + v = b; + } + + if(a * y < b * x) { + nb = (double)a * v / u; + // Center + offy = (double)(b - nb) / 2; + } else { + na = (double)b * u / v; + // Center + offx = (double)(a - na) / 2; + } + } + + // gdk_pixbuf_scale has crappy inputs + scax = scay = (double) nx / na; + + offx = -offx * scax; + offy = -offy * scay; + + dest = gdk_pixbuf_new (gdk_pixbuf_get_colorspace(src), + gdk_pixbuf_get_has_alpha(src), + gdk_pixbuf_get_bits_per_sample(src), + nx, ny); + + gdk_pixbuf_scale (src, dest, 0, 0, nx, ny, offx, offy, scax, scay, + GDK_INTERP_BILINEAR); + + return dest; +} + void hildon_thumbnail_util_get_thumb_paths (const gchar *uri, gchar **large, gchar **normal, gchar **cropped, gchar **local_large, gchar **local_normal, gchar **local_cropped, gboolean as_png) { Modified: projects/haf/trunk/hildon-thumbnail/daemon/utils.h =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/utils.h 2009-05-19 14:31:49 UTC (rev 18440) +++ projects/haf/trunk/hildon-thumbnail/daemon/utils.h 2009-05-19 14:34:54 UTC (rev 18441) @@ -29,9 +29,11 @@ #include <glib.h> #include <gio/gio.h> +#include <gdk-pixbuf/gdk-pixbuf.h> +#include <gdk-pixbuf/gdk-pixbuf-io.h> void hildon_thumbnail_util_get_thumb_paths (const gchar *uri, gchar **large, gchar **normal, gchar **cropped, gchar **local_large, gchar **local_normal, gchar **local_cropped, gboolean as_png); void hildon_thumbnail_util_get_albumart_path (const gchar *a, const gchar *b, const gchar *prefix, gchar **path); +GdkPixbuf* hildon_thumbnail_crop_resize (GdkPixbuf *src, int width, int height); - #endif
- Previous message: [maemo-commits] r18440 - in projects/haf/trunk/libsdl1.2/debian: . patches
- Next message: [maemo-commits] r18442 - projects/haf/tags/libsdl1.2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]