From 895b0e520cbdb497450fc4af5060198e29ad8047 Mon Sep 17 00:00:00 2001 From: Manish Singh Date: Sat, 28 Aug 1999 22:40:37 +0000 Subject: [PATCH] added framework for having multiple simultaneous displays -Yosh --- ChangeLog | 6 ++ app/core/gimpprojection.c | 2 +- app/core/gimpprojection.h | 7 +- app/display/gimpdisplay.c | 2 +- app/display/gimpdisplay.h | 7 +- app/display/gimpdisplayshell-filter.c | 116 ++++++++++++++++++++------ app/display/gimpdisplayshell-filter.h | 25 ++++-- app/gdisplay.c | 2 +- app/gdisplay.h | 7 +- app/gdisplay_color.c | 116 ++++++++++++++++++++------ app/gdisplay_color.h | 25 ++++-- 11 files changed, 236 insertions(+), 79 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba615a743d..f2ae8209f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Aug 28 15:36:36 PDT 1999 Manish Singh + + * app/gdisplay.[ch] + * app/gdisplay_color.[ch]: added framework for having multiple + simultaneous displays + Sat Aug 28 12:15:15 PDT 1999 Manish Singh * plug-ins/borderaverage/borderaverage.c diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index 35c26f7166..c38d7471d9 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -123,7 +123,7 @@ gdisplay_new (GimpImage *gimage, gdisp->idle_render.update_areas = NULL; gdisp->idle_render.active = FALSE; - gdisp->cd_name = NULL; + gdisp->cd_list = NULL; /* format the title */ gdisplay_format_title (gdisp, title, MAX_TITLE_BUF); diff --git a/app/core/gimpprojection.h b/app/core/gimpprojection.h index eb63b65d2d..4c7322df5d 100644 --- a/app/core/gimpprojection.h +++ b/app/core/gimpprojection.h @@ -22,8 +22,6 @@ #include "info_dialog.h" #include "selection.h" -#include "libgimp/color_display.h" - #include "gdisplayF.h" /* @@ -154,9 +152,7 @@ struct _GDisplay IdleRenderStruct idle_render; /* state of this gdisplay's render thread */ - char *cd_name; /* color display conversion stuff */ - gpointer cd_ID; - GimpColorDisplayConvert cd_convert; + GList *cd_list; /* color display conversion stuff */ }; @@ -220,4 +216,3 @@ void gdisplay_flush_displays_only (GDisplay *gdisp); /* no rerender! */ #endif /* __GDISPLAY_H__ */ - diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index 35c26f7166..c38d7471d9 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -123,7 +123,7 @@ gdisplay_new (GimpImage *gimage, gdisp->idle_render.update_areas = NULL; gdisp->idle_render.active = FALSE; - gdisp->cd_name = NULL; + gdisp->cd_list = NULL; /* format the title */ gdisplay_format_title (gdisp, title, MAX_TITLE_BUF); diff --git a/app/display/gimpdisplay.h b/app/display/gimpdisplay.h index eb63b65d2d..4c7322df5d 100644 --- a/app/display/gimpdisplay.h +++ b/app/display/gimpdisplay.h @@ -22,8 +22,6 @@ #include "info_dialog.h" #include "selection.h" -#include "libgimp/color_display.h" - #include "gdisplayF.h" /* @@ -154,9 +152,7 @@ struct _GDisplay IdleRenderStruct idle_render; /* state of this gdisplay's render thread */ - char *cd_name; /* color display conversion stuff */ - gpointer cd_ID; - GimpColorDisplayConvert cd_convert; + GList *cd_list; /* color display conversion stuff */ }; @@ -220,4 +216,3 @@ void gdisplay_flush_displays_only (GDisplay *gdisp); /* no rerender! */ #endif /* __GDISPLAY_H__ */ - diff --git a/app/display/gimpdisplayshell-filter.c b/app/display/gimpdisplayshell-filter.c index 8e7589b156..1f2f229915 100644 --- a/app/display/gimpdisplayshell-filter.c +++ b/app/display/gimpdisplayshell-filter.c @@ -16,10 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #include "gdisplay_color.h" +#include "gdisplay.h" #include "gimpimageP.h" + #include "libgimp/parasite.h" #include "libgimp/gimpintl.h" + #include typedef struct _ColorDisplayInfo ColorDisplayInfo; @@ -43,6 +48,12 @@ struct _GammaContext GtkWidget *spinner; }; +static void gdisplay_color_detach_real (GDisplay *gdisp, + ColorDisplayNode *node, + gboolean unref); +static gint node_name_compare (ColorDisplayNode *node, + const char *name); + static gpointer gamma_new (int type); static void gamma_create_lookup_table (GammaContext *context); static void gamma_destroy (gpointer cd_ID); @@ -110,12 +121,30 @@ gboolean gimp_color_display_unregister (const char *name) { ColorDisplayInfo *info; + GDisplay *gdisp; + GList *node; if ((info = g_hash_table_lookup (color_display_table, name))) { + GSList *refs = info->refs; + + while (refs) + { + gdisp = (GDisplay *) refs->data; + + node = g_list_find_custom (gdisp->cd_list, name, node_name_compare); + gdisp->cd_list = g_slist_remove_link (gdisp->cd_list, node); + + gdisplay_color_detach_real (gdisp, node->data, FALSE); + + g_list_free_1 (node); + + refs = refs->next; + } + + g_slist_free (info->refs); + g_hash_table_remove (color_display_table, name); - - /* FIXME: Check refs here */ g_free (info->name); g_free (info); @@ -129,48 +158,87 @@ gdisplay_color_attach (GDisplay *gdisp, const char *name) { ColorDisplayInfo *info; - - gdisplay_color_detach (gdisp); - - gdisp->cd_name = g_strdup (name); - gdisp->cd_ID = NULL; - gdisp->cd_convert = NULL; + ColorDisplayNode *node; if ((info = g_hash_table_lookup (color_display_table, name))) { + node = g_new (ColorDisplayNode, 1); + + node->cd_name = g_strdup (name); + node->cd_ID = NULL; + if (!info->refs && info->methods.init) info->methods.init (); info->refs = g_slist_append (info->refs, gdisp); if (info->methods.new) - gdisp->cd_ID = info->methods.new (gdisp->gimage->base_type); + node->cd_ID = info->methods.new (gdisp->gimage->base_type); - gdisp->cd_convert = info->methods.convert; + node->cd_convert = info->methods.convert; + + gdisp->cd_list = g_list_append (gdisp->cd_list, name); } + else + g_warning ("Tried to attach a nonexistant color display"); } void -gdisplay_color_detach (GDisplay *gdisp) +gdisplay_color_detach (GDisplay *gdisp, + const char *name) +{ + GList *node; + + node = g_list_find_custom (gdisp->cd_list, name, node_name_compare); + gdisplay_color_detach_real (gdisp, node->data, TRUE); + + gdisp->cd_list = g_list_remove_link (gdisp->cd_list, node); + g_list_free_1 (node); +} + +void +gdisplay_color_detach_all (GDisplay *gdisp) +{ + GList *list = gdisp->cd_list; + + while (list) + { + gdisplay_color_detach_real (gdisp, list->data, TRUE); + list = list->next; + } + + g_list_free (gdisp->cd_list); + gdisp->cd_list = NULL; +} + +static void +gdisplay_color_detach_real (GDisplay *gdisp, + ColorDisplayNode *node, + gboolean unref) { ColorDisplayInfo *info; - - if (gdisp->cd_name) + + if ((info = g_hash_table_lookup (color_display_table, node->cd_name))) { - if ((info = g_hash_table_lookup (color_display_table, gdisp->cd_name))) - { - if (info->methods.destroy) - info->methods.destroy (gdisp->cd_ID); + if (info->methods.destroy) + info->methods.destroy (node->cd_ID); - info->refs = g_slist_remove (info->refs, gdisp); + if (unref) + info->refs = g_slist_remove (info->refs, gdisp); - if (!info->refs && info->methods.finalize) - info->methods.finalize (); - } + if (!info->refs && info->methods.finalize) + info->methods.finalize (); + } - g_free (gdisp->cd_name); - gdisp->cd_name = NULL; - } + g_free (node->cd_name); + g_free (node); +} + +static gint +node_name_compare (ColorDisplayNode *node, + const char *name) +{ + return strcmp (node->cd_name, name); } /* The Gamma Color Display */ diff --git a/app/display/gimpdisplayshell-filter.h b/app/display/gimpdisplayshell-filter.h index 867a403bfe..44cb9d9e0a 100644 --- a/app/display/gimpdisplayshell-filter.h +++ b/app/display/gimpdisplayshell-filter.h @@ -15,10 +15,25 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef __GDISPLAY_COLOR_H__ +#define __GDISPLAY_COLOR_H__ -#include "gdisplay.h" +#include "libgimp/color_display.h" +#include "gdisplayF.h" -void gdisplay_color_init (void); -void gdisplay_color_attach (GDisplay *gdisp, - const char *name); -void gdisplay_color_detach (GDisplay *gdisp); +typedef struct _ColorDisplayNode ColorDisplayNode; + +struct _ColorDisplayNode { + char *cd_name; + gpointer cd_ID; + GimpColorDisplayConvert cd_convert; +}; + +void gdisplay_color_init (void); +void gdisplay_color_attach (GDisplay *gdisp, + const char *name); +void gdisplay_color_detach (GDisplay *gdisp, + const char *name); +void gdisplay_color_detach_all (GDisplay *gdisp); + +#endif /* __GDISPLAY_COLOR_H__ */ diff --git a/app/gdisplay.c b/app/gdisplay.c index 35c26f7166..c38d7471d9 100644 --- a/app/gdisplay.c +++ b/app/gdisplay.c @@ -123,7 +123,7 @@ gdisplay_new (GimpImage *gimage, gdisp->idle_render.update_areas = NULL; gdisp->idle_render.active = FALSE; - gdisp->cd_name = NULL; + gdisp->cd_list = NULL; /* format the title */ gdisplay_format_title (gdisp, title, MAX_TITLE_BUF); diff --git a/app/gdisplay.h b/app/gdisplay.h index eb63b65d2d..4c7322df5d 100644 --- a/app/gdisplay.h +++ b/app/gdisplay.h @@ -22,8 +22,6 @@ #include "info_dialog.h" #include "selection.h" -#include "libgimp/color_display.h" - #include "gdisplayF.h" /* @@ -154,9 +152,7 @@ struct _GDisplay IdleRenderStruct idle_render; /* state of this gdisplay's render thread */ - char *cd_name; /* color display conversion stuff */ - gpointer cd_ID; - GimpColorDisplayConvert cd_convert; + GList *cd_list; /* color display conversion stuff */ }; @@ -220,4 +216,3 @@ void gdisplay_flush_displays_only (GDisplay *gdisp); /* no rerender! */ #endif /* __GDISPLAY_H__ */ - diff --git a/app/gdisplay_color.c b/app/gdisplay_color.c index 8e7589b156..1f2f229915 100644 --- a/app/gdisplay_color.c +++ b/app/gdisplay_color.c @@ -16,10 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #include "gdisplay_color.h" +#include "gdisplay.h" #include "gimpimageP.h" + #include "libgimp/parasite.h" #include "libgimp/gimpintl.h" + #include typedef struct _ColorDisplayInfo ColorDisplayInfo; @@ -43,6 +48,12 @@ struct _GammaContext GtkWidget *spinner; }; +static void gdisplay_color_detach_real (GDisplay *gdisp, + ColorDisplayNode *node, + gboolean unref); +static gint node_name_compare (ColorDisplayNode *node, + const char *name); + static gpointer gamma_new (int type); static void gamma_create_lookup_table (GammaContext *context); static void gamma_destroy (gpointer cd_ID); @@ -110,12 +121,30 @@ gboolean gimp_color_display_unregister (const char *name) { ColorDisplayInfo *info; + GDisplay *gdisp; + GList *node; if ((info = g_hash_table_lookup (color_display_table, name))) { + GSList *refs = info->refs; + + while (refs) + { + gdisp = (GDisplay *) refs->data; + + node = g_list_find_custom (gdisp->cd_list, name, node_name_compare); + gdisp->cd_list = g_slist_remove_link (gdisp->cd_list, node); + + gdisplay_color_detach_real (gdisp, node->data, FALSE); + + g_list_free_1 (node); + + refs = refs->next; + } + + g_slist_free (info->refs); + g_hash_table_remove (color_display_table, name); - - /* FIXME: Check refs here */ g_free (info->name); g_free (info); @@ -129,48 +158,87 @@ gdisplay_color_attach (GDisplay *gdisp, const char *name) { ColorDisplayInfo *info; - - gdisplay_color_detach (gdisp); - - gdisp->cd_name = g_strdup (name); - gdisp->cd_ID = NULL; - gdisp->cd_convert = NULL; + ColorDisplayNode *node; if ((info = g_hash_table_lookup (color_display_table, name))) { + node = g_new (ColorDisplayNode, 1); + + node->cd_name = g_strdup (name); + node->cd_ID = NULL; + if (!info->refs && info->methods.init) info->methods.init (); info->refs = g_slist_append (info->refs, gdisp); if (info->methods.new) - gdisp->cd_ID = info->methods.new (gdisp->gimage->base_type); + node->cd_ID = info->methods.new (gdisp->gimage->base_type); - gdisp->cd_convert = info->methods.convert; + node->cd_convert = info->methods.convert; + + gdisp->cd_list = g_list_append (gdisp->cd_list, name); } + else + g_warning ("Tried to attach a nonexistant color display"); } void -gdisplay_color_detach (GDisplay *gdisp) +gdisplay_color_detach (GDisplay *gdisp, + const char *name) +{ + GList *node; + + node = g_list_find_custom (gdisp->cd_list, name, node_name_compare); + gdisplay_color_detach_real (gdisp, node->data, TRUE); + + gdisp->cd_list = g_list_remove_link (gdisp->cd_list, node); + g_list_free_1 (node); +} + +void +gdisplay_color_detach_all (GDisplay *gdisp) +{ + GList *list = gdisp->cd_list; + + while (list) + { + gdisplay_color_detach_real (gdisp, list->data, TRUE); + list = list->next; + } + + g_list_free (gdisp->cd_list); + gdisp->cd_list = NULL; +} + +static void +gdisplay_color_detach_real (GDisplay *gdisp, + ColorDisplayNode *node, + gboolean unref) { ColorDisplayInfo *info; - - if (gdisp->cd_name) + + if ((info = g_hash_table_lookup (color_display_table, node->cd_name))) { - if ((info = g_hash_table_lookup (color_display_table, gdisp->cd_name))) - { - if (info->methods.destroy) - info->methods.destroy (gdisp->cd_ID); + if (info->methods.destroy) + info->methods.destroy (node->cd_ID); - info->refs = g_slist_remove (info->refs, gdisp); + if (unref) + info->refs = g_slist_remove (info->refs, gdisp); - if (!info->refs && info->methods.finalize) - info->methods.finalize (); - } + if (!info->refs && info->methods.finalize) + info->methods.finalize (); + } - g_free (gdisp->cd_name); - gdisp->cd_name = NULL; - } + g_free (node->cd_name); + g_free (node); +} + +static gint +node_name_compare (ColorDisplayNode *node, + const char *name) +{ + return strcmp (node->cd_name, name); } /* The Gamma Color Display */ diff --git a/app/gdisplay_color.h b/app/gdisplay_color.h index 867a403bfe..44cb9d9e0a 100644 --- a/app/gdisplay_color.h +++ b/app/gdisplay_color.h @@ -15,10 +15,25 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef __GDISPLAY_COLOR_H__ +#define __GDISPLAY_COLOR_H__ -#include "gdisplay.h" +#include "libgimp/color_display.h" +#include "gdisplayF.h" -void gdisplay_color_init (void); -void gdisplay_color_attach (GDisplay *gdisp, - const char *name); -void gdisplay_color_detach (GDisplay *gdisp); +typedef struct _ColorDisplayNode ColorDisplayNode; + +struct _ColorDisplayNode { + char *cd_name; + gpointer cd_ID; + GimpColorDisplayConvert cd_convert; +}; + +void gdisplay_color_init (void); +void gdisplay_color_attach (GDisplay *gdisp, + const char *name); +void gdisplay_color_detach (GDisplay *gdisp, + const char *name); +void gdisplay_color_detach_all (GDisplay *gdisp); + +#endif /* __GDISPLAY_COLOR_H__ */