2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-01-11 01:55:53 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-01-11 01:55:53 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-01-11 01:55:53 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2003-01-11 01:55:53 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-19 15:59:08 +08:00
|
|
|
#include <gegl.h>
|
2003-01-11 01:55:53 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2006-09-06 05:36:20 +08:00
|
|
|
#include "core/gimp.h"
|
2010-06-07 02:24:27 +08:00
|
|
|
#include "core/gimp-utils.h"
|
2006-09-06 05:36:20 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2008-10-19 15:59:08 +08:00
|
|
|
#include "core/gimpimage.h"
|
2009-02-24 04:43:30 +08:00
|
|
|
#include "core/gimpprojectable.h"
|
2014-06-03 03:32:00 +08:00
|
|
|
#include "core/gimpprojection.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2009-02-24 04:43:30 +08:00
|
|
|
#include "gegl/gimp-gegl-utils.h"
|
|
|
|
|
2009-05-08 23:40:13 +08:00
|
|
|
#include "widgets/gimpaction.h"
|
2019-07-02 09:54:38 +08:00
|
|
|
#include "widgets/gimpactiongroup.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "widgets/gimpmenufactory.h"
|
2004-05-05 23:54:42 +08:00
|
|
|
#include "widgets/gimpuimanager.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2014-05-03 02:20:46 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
#include "display/gimpdisplayshell.h"
|
|
|
|
#include "display/gimpimagewindow.h"
|
|
|
|
|
2004-05-06 15:41:53 +08:00
|
|
|
#include "menus/menus.h"
|
|
|
|
|
2005-06-27 17:56:25 +08:00
|
|
|
#include "actions.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "debug-commands.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
2014-06-03 03:32:00 +08:00
|
|
|
static gboolean debug_benchmark_projection (GimpDisplay *display);
|
2009-05-08 23:40:13 +08:00
|
|
|
static gboolean debug_show_image_graph (GimpImage *source_image);
|
|
|
|
|
|
|
|
static void debug_print_qdata (GimpObject *object);
|
|
|
|
static void debug_print_qdata_foreach (GQuark key_id,
|
|
|
|
gpointer data,
|
|
|
|
gpointer user_data);
|
2008-11-15 20:43:18 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2018-06-21 02:43:41 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
debug_gtk_inspector_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2018-06-21 02:43:41 +08:00
|
|
|
{
|
|
|
|
gtk_window_set_interactive_debugging (TRUE);
|
|
|
|
}
|
|
|
|
|
2004-05-05 23:54:42 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
debug_mem_profile_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2004-05-05 23:54:42 +08:00
|
|
|
{
|
2005-06-27 17:56:25 +08:00
|
|
|
extern gboolean gimp_debug_memsize;
|
|
|
|
Gimp *gimp;
|
|
|
|
return_if_no_gimp (gimp, data);
|
2004-05-05 23:54:42 +08:00
|
|
|
|
|
|
|
gimp_debug_memsize = TRUE;
|
|
|
|
|
2005-06-27 17:56:25 +08:00
|
|
|
gimp_object_get_memsize (GIMP_OBJECT (gimp), NULL);
|
2004-05-05 23:54:42 +08:00
|
|
|
|
|
|
|
gimp_debug_memsize = FALSE;
|
|
|
|
}
|
|
|
|
|
2014-06-03 03:32:00 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
debug_benchmark_projection_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2014-06-03 03:32:00 +08:00
|
|
|
{
|
|
|
|
GimpDisplay *display;
|
|
|
|
return_if_no_display (display, data);
|
|
|
|
|
|
|
|
g_idle_add ((GSourceFunc) debug_benchmark_projection, g_object_ref (display));
|
|
|
|
}
|
|
|
|
|
2009-02-24 04:43:30 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
debug_show_image_graph_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2009-02-24 04:43:30 +08:00
|
|
|
{
|
|
|
|
GimpImage *source_image = NULL;
|
|
|
|
return_if_no_image (source_image, data);
|
|
|
|
|
|
|
|
g_idle_add ((GSourceFunc) debug_show_image_graph, g_object_ref (source_image));
|
|
|
|
}
|
|
|
|
|
2009-05-08 23:40:13 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
debug_dump_keyboard_shortcuts_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2009-05-08 23:40:13 +08:00
|
|
|
{
|
2023-03-08 01:23:38 +08:00
|
|
|
GimpDisplay *display;
|
|
|
|
GimpUIManager *manager;
|
|
|
|
GList *group_it;
|
|
|
|
GList *strings = NULL;
|
|
|
|
|
2009-05-08 23:40:13 +08:00
|
|
|
return_if_no_display (display, data);
|
|
|
|
|
2023-03-08 01:23:38 +08:00
|
|
|
manager = menus_get_image_manager_singleton (display->gimp);
|
2009-09-23 22:58:03 +08:00
|
|
|
|
2018-03-25 04:49:01 +08:00
|
|
|
/* Gather formatted strings of keyboard shortcuts */
|
2019-07-02 09:54:38 +08:00
|
|
|
for (group_it = gimp_ui_manager_get_action_groups (manager);
|
2009-05-08 23:40:13 +08:00
|
|
|
group_it;
|
|
|
|
group_it = g_list_next (group_it))
|
|
|
|
{
|
|
|
|
GimpActionGroup *group = group_it->data;
|
|
|
|
GList *actions = NULL;
|
|
|
|
GList *action_it = NULL;
|
|
|
|
|
2019-07-02 09:54:38 +08:00
|
|
|
actions = gimp_action_group_list_actions (group);
|
2009-05-08 23:40:13 +08:00
|
|
|
actions = g_list_sort (actions, (GCompareFunc) gimp_action_name_compare);
|
|
|
|
|
|
|
|
for (action_it = actions; action_it; action_it = g_list_next (action_it))
|
|
|
|
{
|
2023-02-06 05:55:37 +08:00
|
|
|
gchar **accels;
|
|
|
|
GimpAction *action = action_it->data;
|
|
|
|
const gchar *name = gimp_action_get_name (action);
|
2009-05-08 23:40:13 +08:00
|
|
|
|
2023-04-20 21:29:36 +08:00
|
|
|
if (name[0] == '<')
|
|
|
|
continue;
|
2009-05-08 23:40:13 +08:00
|
|
|
|
2023-02-06 05:55:37 +08:00
|
|
|
accels = gimp_action_get_display_accels (action);
|
2009-05-08 23:40:13 +08:00
|
|
|
|
2023-02-06 05:55:37 +08:00
|
|
|
if (accels && accels[0])
|
2009-05-08 23:40:13 +08:00
|
|
|
{
|
2023-02-06 05:55:37 +08:00
|
|
|
const gchar *label_tmp;
|
|
|
|
gchar *label;
|
2009-05-08 23:40:13 +08:00
|
|
|
|
2023-02-06 05:55:37 +08:00
|
|
|
label_tmp = gimp_action_get_label (action);
|
|
|
|
label = gimp_strip_uline (label_tmp);
|
2009-05-08 23:40:13 +08:00
|
|
|
|
2023-02-06 05:55:37 +08:00
|
|
|
strings = g_list_prepend (strings,
|
|
|
|
g_strdup_printf ("%-20s %s",
|
|
|
|
accels[0], label));
|
2009-05-08 23:40:13 +08:00
|
|
|
|
2023-02-06 05:55:37 +08:00
|
|
|
g_free (label);
|
|
|
|
|
|
|
|
for (gint i = 1; accels[i] != NULL; i++)
|
|
|
|
strings = g_list_prepend (strings, g_strdup (accels[i]));
|
2009-05-08 23:40:13 +08:00
|
|
|
}
|
2023-02-06 05:55:37 +08:00
|
|
|
|
|
|
|
g_strfreev (accels);
|
2009-05-08 23:40:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (actions);
|
|
|
|
}
|
2009-05-16 20:42:17 +08:00
|
|
|
|
|
|
|
/* Sort and prints the strings */
|
|
|
|
{
|
|
|
|
GList *string_it = NULL;
|
|
|
|
|
|
|
|
strings = g_list_sort (strings, (GCompareFunc) strcmp);
|
|
|
|
|
|
|
|
for (string_it = strings; string_it; string_it = g_list_next (string_it))
|
|
|
|
{
|
2009-05-30 02:49:40 +08:00
|
|
|
g_print ("%s\n", (gchar *) string_it->data);
|
2009-05-16 20:42:17 +08:00
|
|
|
g_free (string_it->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (strings);
|
|
|
|
}
|
2009-05-08 23:40:13 +08:00
|
|
|
}
|
|
|
|
|
2006-09-06 05:36:20 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
debug_dump_attached_data_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2006-09-06 05:36:20 +08:00
|
|
|
{
|
|
|
|
Gimp *gimp = action_data_get_gimp (data);
|
|
|
|
GimpContext *user_context = gimp_get_user_context (gimp);
|
|
|
|
|
|
|
|
debug_print_qdata (GIMP_OBJECT (gimp));
|
|
|
|
debug_print_qdata (GIMP_OBJECT (user_context));
|
|
|
|
}
|
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2014-06-03 03:32:00 +08:00
|
|
|
static gboolean
|
|
|
|
debug_benchmark_projection (GimpDisplay *display)
|
|
|
|
{
|
2018-01-10 17:29:37 +08:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
2014-06-03 03:32:00 +08:00
|
|
|
|
2018-01-10 17:29:37 +08:00
|
|
|
if (image)
|
|
|
|
{
|
|
|
|
GimpProjection *projection = gimp_image_get_projection (image);
|
|
|
|
|
app: add "direct" parameter to gimp_projection_flush_now()
Add a boolean "direct" parameter to gimp_projection_flush_now(),
which specifies if the projection buffer should only be invalidated
(FALSE), or rendered directly (TRUE).
Pass TRUE when flushing the projection during painting, so that the
affected regions are rendered in a single step, instead of tile-by-
tile. We previously only invalidated the projection buffer, but
since we synchronously flush the display right after that, the
invalidated regions would still get rendered, albeit less
efficiently.
Likewise, pass TRUE when benchmarking the projection through the
debug action, and avoid flushing the display, to more accurately
measure the render time.
2018-12-02 22:44:52 +08:00
|
|
|
gimp_projection_stop_rendering (projection);
|
|
|
|
|
2018-01-10 17:29:37 +08:00
|
|
|
GIMP_TIMER_START ();
|
2014-06-03 03:32:00 +08:00
|
|
|
|
2019-09-04 19:37:38 +08:00
|
|
|
gimp_image_invalidate_all (image);
|
app: add "direct" parameter to gimp_projection_flush_now()
Add a boolean "direct" parameter to gimp_projection_flush_now(),
which specifies if the projection buffer should only be invalidated
(FALSE), or rendered directly (TRUE).
Pass TRUE when flushing the projection during painting, so that the
affected regions are rendered in a single step, instead of tile-by-
tile. We previously only invalidated the projection buffer, but
since we synchronously flush the display right after that, the
invalidated regions would still get rendered, albeit less
efficiently.
Likewise, pass TRUE when benchmarking the projection through the
debug action, and avoid flushing the display, to more accurately
measure the render time.
2018-12-02 22:44:52 +08:00
|
|
|
gimp_projection_flush_now (projection, TRUE);
|
2014-06-03 03:32:00 +08:00
|
|
|
|
2018-01-10 17:29:37 +08:00
|
|
|
GIMP_TIMER_END ("Validation of the entire projection");
|
2014-06-03 03:32:00 +08:00
|
|
|
|
2018-01-10 17:29:37 +08:00
|
|
|
g_object_unref (display);
|
|
|
|
}
|
2014-06-03 03:32:00 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-02-24 04:43:30 +08:00
|
|
|
static gboolean
|
|
|
|
debug_show_image_graph (GimpImage *source_image)
|
|
|
|
{
|
2015-06-20 05:49:41 +08:00
|
|
|
GeglNode *image_graph;
|
|
|
|
GeglNode *output_node;
|
|
|
|
GimpImage *new_image;
|
|
|
|
GeglNode *introspect;
|
|
|
|
GeglNode *sink;
|
2020-12-06 01:55:59 +08:00
|
|
|
GeglBuffer *buffer = NULL;
|
2015-06-20 05:49:41 +08:00
|
|
|
|
|
|
|
image_graph = gimp_projectable_get_graph (GIMP_PROJECTABLE (source_image));
|
|
|
|
|
|
|
|
output_node = gegl_node_get_output_proxy (image_graph, "output");
|
|
|
|
|
2009-02-24 04:43:30 +08:00
|
|
|
introspect = gegl_node_new_child (NULL,
|
|
|
|
"operation", "gegl:introspect",
|
2009-04-12 18:23:02 +08:00
|
|
|
"node", output_node,
|
2009-02-24 04:43:30 +08:00
|
|
|
NULL);
|
|
|
|
sink = gegl_node_new_child (NULL,
|
|
|
|
"operation", "gegl:buffer-sink",
|
|
|
|
"buffer", &buffer,
|
|
|
|
NULL);
|
2015-06-20 05:49:41 +08:00
|
|
|
|
2009-02-24 04:43:30 +08:00
|
|
|
gegl_node_link_many (introspect, sink, NULL);
|
|
|
|
gegl_node_process (sink);
|
|
|
|
|
2020-12-06 01:55:59 +08:00
|
|
|
if (buffer)
|
|
|
|
{
|
|
|
|
gchar *new_name;
|
|
|
|
|
|
|
|
/* This should not happen but "gegl:introspect" is a bit fickle as
|
|
|
|
* it uses an external binary `dot`. Prevent useless crashes.
|
|
|
|
* I don't output a warning when buffer is NULL because anyway
|
|
|
|
* GEGL will output one itself.
|
|
|
|
*/
|
|
|
|
new_name = g_strdup_printf ("%s GEGL graph",
|
|
|
|
gimp_image_get_display_name (source_image));
|
|
|
|
|
|
|
|
new_image = gimp_create_image_from_buffer (source_image->gimp,
|
|
|
|
buffer, new_name);
|
|
|
|
gimp_image_set_file (new_image, g_file_new_for_uri (new_name));
|
|
|
|
|
|
|
|
g_free (new_name);
|
|
|
|
g_object_unref (buffer);
|
|
|
|
}
|
2015-06-20 05:49:41 +08:00
|
|
|
|
2009-02-24 04:43:30 +08:00
|
|
|
g_object_unref (sink);
|
|
|
|
g_object_unref (introspect);
|
2015-06-20 05:49:41 +08:00
|
|
|
|
2009-02-24 04:43:30 +08:00
|
|
|
g_object_unref (source_image);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-09-06 05:36:20 +08:00
|
|
|
static void
|
|
|
|
debug_print_qdata (GimpObject *object)
|
|
|
|
{
|
|
|
|
g_print ("\nData attached to '%s':\n\n", gimp_object_get_name (object));
|
|
|
|
g_datalist_foreach (&G_OBJECT (object)->qdata,
|
|
|
|
debug_print_qdata_foreach,
|
|
|
|
NULL);
|
|
|
|
g_print ("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
debug_print_qdata_foreach (GQuark key_id,
|
|
|
|
gpointer data,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
g_print ("%s: %p\n", g_quark_to_string (key_id), data);
|
|
|
|
}
|