Commit 1f4a5d40 authored by Michael Natterer's avatar Michael Natterer 😴

plug-ins: port map-objects to libgimp objects

parent fd5740e7
Pipeline #111002 passed with stages
in 15 minutes and 38 seconds
......@@ -48,10 +48,9 @@ map_object_SOURCES = \
../lighting/images/lighting-icon-images.h
AM_CPPFLAGS = \
-DGIMP_DEPRECATED_REPLACE_NEW_API \
-I$(top_srcdir) \
$(GTK_CFLAGS) \
$(GEGL_CFLAGS) \
$(GEGL_CFLAGS) \
-I$(includedir)
LDADD = \
......
......@@ -133,9 +133,9 @@ init_compute (void)
for (i = 0; i < 6; i++)
{
box_drawable_ids[i] = mapvals.boxmap_id[i];
box_drawables[i] = gimp_drawable_get_by_id (mapvals.boxmap_id[i]);
box_buffers[i] = gimp_drawable_get_buffer (box_drawable_ids[i]);
box_buffers[i] = gimp_drawable_get_buffer (box_drawables[i]);
}
break;
......@@ -170,9 +170,9 @@ init_compute (void)
for (i = 0; i < 2; i++)
{
cylinder_drawable_ids[i] = mapvals.cylindermap_id[i];
cylinder_drawables[i] = gimp_drawable_get_by_id (mapvals.cylindermap_id[i]);;
cylinder_buffers[i] = gimp_drawable_get_buffer (cylinder_drawable_ids[i]);
cylinder_buffers[i] = gimp_drawable_get_buffer (cylinder_drawables[i]);
}
break;
}
......@@ -216,27 +216,27 @@ compute_image (void)
GimpRGB color;
glong progress_counter = 0;
GimpVector3 p;
gint32 new_image_id = -1;
gint32 new_layer_id = -1;
GimpImage *new_image = NULL;
GimpLayer *new_layer = NULL;
gboolean insert_layer = FALSE;
init_compute ();
if (mapvals.create_new_image)
{
new_image_id = gimp_image_new (width, height, GIMP_RGB);
new_image = gimp_image_new (width, height, GIMP_RGB);
}
else
{
new_image_id = image_id;
new_image = image;
}
gimp_image_undo_group_start (new_image_id);
gimp_image_undo_group_start (new_image);
if (mapvals.create_new_image ||
mapvals.create_new_layer ||
(mapvals.transparent_background &&
! gimp_drawable_has_alpha (output_drawable_id)))
! gimp_drawable_has_alpha (output_drawable)))
{
gchar *layername[] = {_("Map to plane"),
_("Map to sphere"),
......@@ -244,36 +244,36 @@ compute_image (void)
_("Map to cylinder"),
_("Background")};
new_layer_id = gimp_layer_new (new_image_id,
layername[mapvals.create_new_image ? 4 :
mapvals.maptype],
width, height,
mapvals.transparent_background ?
GIMP_RGBA_IMAGE :
GIMP_RGB_IMAGE,
100.0,
gimp_image_get_default_new_layer_mode (new_image_id));
new_layer = gimp_layer_new (new_image,
layername[mapvals.create_new_image ? 4 :
mapvals.maptype],
width, height,
mapvals.transparent_background ?
GIMP_RGBA_IMAGE :
GIMP_RGB_IMAGE,
100.0,
gimp_image_get_default_new_layer_mode (new_image));
insert_layer = TRUE;
output_drawable_id = new_layer_id;
output_drawable = GIMP_DRAWABLE (new_layer);
}
dest_buffer = gimp_drawable_get_shadow_buffer (output_drawable_id);
dest_buffer = gimp_drawable_get_shadow_buffer (output_drawable);
switch (mapvals.maptype)
{
case MAP_PLANE:
gimp_progress_init (_("Map to plane"));
break;
case MAP_SPHERE:
gimp_progress_init (_("Map to sphere"));
break;
case MAP_BOX:
gimp_progress_init (_("Map to box"));
break;
case MAP_CYLINDER:
gimp_progress_init (_("Map to cylinder"));
break;
case MAP_PLANE:
gimp_progress_init (_("Map to plane"));
break;
case MAP_SPHERE:
gimp_progress_init (_("Map to sphere"));
break;
case MAP_BOX:
gimp_progress_init (_("Map to box"));
break;
case MAP_CYLINDER:
gimp_progress_init (_("Map to cylinder"));
break;
}
if (! mapvals.antialiasing)
......@@ -313,16 +313,16 @@ compute_image (void)
g_object_unref (dest_buffer);
if (insert_layer)
gimp_image_insert_layer (new_image_id, new_layer_id, -1, 0);
gimp_image_insert_layer (new_image, new_layer, NULL, 0);
gimp_drawable_merge_shadow (output_drawable_id, TRUE);
gimp_drawable_update (output_drawable_id, 0, 0, width, height);
gimp_drawable_merge_shadow (output_drawable, TRUE);
gimp_drawable_update (output_drawable, 0, 0, width, height);
if (new_image_id != image_id)
if (new_image != image)
{
gimp_display_new (new_image_id);
gimp_display_new (new_image);
gimp_displays_flush ();
}
gimp_image_undo_group_end (new_image_id);
gimp_image_undo_group_end (new_image);
}
......@@ -23,23 +23,25 @@
#include "map-object-image.h"
gint32 input_drawable_id;
gint32 output_drawable_id;
GeglBuffer *source_buffer;
GeglBuffer *dest_buffer;
GimpImage *image;
gint32 box_drawable_ids[6];
GeglBuffer *box_buffers[6];
GimpDrawable *input_drawable;
GimpDrawable *output_drawable;
GeglBuffer *source_buffer;
GeglBuffer *dest_buffer;
gint32 cylinder_drawable_ids[2];
GeglBuffer *cylinder_buffers[2];
GimpDrawable *box_drawables[6];
GeglBuffer *box_buffers[6];
GimpDrawable *cylinder_drawables[2];
GeglBuffer *cylinder_buffers[2];
guchar *preview_rgb_data = NULL;
gint preview_rgb_stride;
cairo_surface_t *preview_surface = NULL;
glong maxcounter, old_depth, max_depth;
gint width, height, image_id;
gint width, height;
GimpRGB background;
gint border_x, border_y, border_w, border_h;
......@@ -309,20 +311,20 @@ get_cylinder_image_color (gint image,
/****************************************/
gint
image_setup (gint32 drawable_id,
gint interactive)
image_setup (GimpDrawable *drawable,
gint interactive)
{
input_drawable_id = drawable_id;
output_drawable_id = drawable_id;
input_drawable = drawable;
output_drawable = drawable;
if (! gimp_drawable_mask_intersect (drawable_id, &border_x, &border_y,
if (! gimp_drawable_mask_intersect (drawable, &border_x, &border_y,
&border_w, &border_h))
return FALSE;
width = gimp_drawable_width (input_drawable_id);
height = gimp_drawable_height (input_drawable_id);
width = gimp_drawable_width (input_drawable);
height = gimp_drawable_height (input_drawable);
source_buffer = gimp_drawable_get_buffer (input_drawable_id);
source_buffer = gimp_drawable_get_buffer (input_drawable);
maxcounter = (glong) width * (glong) height;
......
......@@ -4,15 +4,17 @@
/* Externally visible variables */
/* ============================ */
extern gint32 input_drawable_id;
extern gint32 output_drawable_id;
extern GimpImage *image;
extern GimpDrawable *input_drawable;
extern GimpDrawable *output_drawable;
extern GeglBuffer *source_buffer;
extern GeglBuffer *dest_buffer;
extern gint32 box_drawable_ids[6];
extern GimpDrawable *box_drawables[6];
extern GeglBuffer *box_buffers[6];
extern gint32 cylinder_drawable_ids[2];
extern GimpDrawable *cylinder_drawables[2];
extern GeglBuffer *cylinder_buffers[2];
extern guchar *preview_rgb_data;
......@@ -20,7 +22,7 @@ extern gint preview_rgb_stride;
extern cairo_surface_t *preview_surface;
extern glong maxcounter, old_depth, max_depth;
extern gint width, height, image_id;
extern gint width, height;
extern GimpRGB background;
extern gint border_x1, border_y1, border_x2, border_y2;
......@@ -28,7 +30,7 @@ extern gint border_x1, border_y1, border_x2, border_y2;
/* Externally visible functions */
/* ============================ */
extern gint image_setup (gint32 drawable_id,
extern gint image_setup (GimpDrawable *drawable,
gint interactive);
extern glong in_xy_to_index (gint x,
gint y);
......
......@@ -101,19 +101,20 @@ set_default_settings (void)
}
static void
check_drawables (gint32 drawable_id)
check_drawables (GimpDrawable *drawable)
{
gint i;
GimpDrawable *map;
gint i;
/* Check that boxmap images are valid */
/* ================================== */
for (i = 0; i < 6; i++)
{
if (mapvals.boxmap_id[i] == -1 ||
!gimp_item_is_valid (mapvals.boxmap_id[i]) ||
gimp_drawable_is_gray (mapvals.boxmap_id[i]))
mapvals.boxmap_id[i] = drawable_id;
map = gimp_drawable_get_by_id (mapvals.boxmap_id[i]);
if (! map || gimp_drawable_is_gray (map))
mapvals.boxmap_id[i] = gimp_item_get_id (GIMP_ITEM (drawable));
}
/* Check that cylindermap images are valid */
......@@ -121,10 +122,10 @@ check_drawables (gint32 drawable_id)
for (i = 0; i < 2; i++)
{
if (mapvals.cylindermap_id[i] == -1 ||
!gimp_item_is_valid (mapvals.cylindermap_id[i]) ||
gimp_drawable_is_gray (mapvals.cylindermap_id[i]))
mapvals.cylindermap_id[i] = drawable_id;
map = gimp_drawable_get_by_id (mapvals.cylindermap_id[i]);
if (! map || gimp_drawable_is_gray (map))
mapvals.cylindermap_id[i] = gimp_item_get_id (GIMP_ITEM (drawable));
}
}
......@@ -192,7 +193,7 @@ query (void)
"Version 1.2.0, July 16 1998",
N_("Map _Object..."),
"RGB*",
GIMP_PLUGIN,
GIMP_PDB_PROC_TYPE_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
......@@ -208,7 +209,7 @@ run (const gchar *name,
{
static GimpParam values[1];
GimpRunMode run_mode;
gint32 drawable_id;
GimpDrawable *drawable;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint i;
......@@ -228,9 +229,9 @@ run (const gchar *name,
/* Get the specified drawable */
/* ========================== */
run_mode = param[0].data.d_int32;
image_id = param[1].data.d_int32;
drawable_id = param[2].data.d_int32;
run_mode = param[0].data.d_int32;
image = gimp_image_get_by_id (param[1].data.d_int32);
drawable = gimp_drawable_get_by_id (param[2].data.d_int32);
switch (run_mode)
{
......@@ -240,8 +241,8 @@ run (const gchar *name,
/* ====================== */
gimp_get_data (PLUG_IN_PROC, &mapvals);
check_drawables (drawable_id);
if (main_dialog (drawable_id))
check_drawables (drawable);
if (main_dialog (drawable))
{
compute_image ();
......@@ -251,8 +252,8 @@ run (const gchar *name,
case GIMP_RUN_WITH_LAST_VALS:
gimp_get_data (PLUG_IN_PROC, &mapvals);
check_drawables (drawable_id);
if (image_setup (drawable_id, FALSE))
check_drawables (drawable);
if (image_setup (drawable, FALSE))
compute_image ();
break;
......@@ -309,8 +310,8 @@ run (const gchar *name,
for (i = 0; i < 2; i++)
mapvals.cylindermap_id[i] = param[47+i].data.d_drawable;
check_drawables (drawable_id);
if (image_setup (drawable_id, FALSE))
check_drawables (drawable);
if (image_setup (drawable, FALSE))
compute_image ();
}
break;
......
......@@ -54,11 +54,11 @@ static void lightmenu_callback (GtkWidget *widget,
static void preview_callback (GtkWidget *widget,
gpointer data);
static gint box_constrain (gint32 image_id,
gint32 drawable_id,
static gint box_constrain (GimpImage *image,
GimpItem *item,
gpointer data);
static gint cylinder_constrain (gint32 image_id,
gint32 drawable_id,
static gint cylinder_constrain (GimpImage *image,
GimpItem *item,
gpointer data);
static GtkWidget * create_options_page (void);
......@@ -268,27 +268,21 @@ zoomed_callback (GimpZoomModel *model)
/**********************************************/
static gint
box_constrain (gint32 image_id,
gint32 drawable_id,
gpointer data)
box_constrain (GimpImage *image,
GimpItem *item,
gpointer data)
{
if (drawable_id == -1)
return TRUE;
return (gimp_drawable_is_rgb (drawable_id) &&
!gimp_drawable_is_indexed (drawable_id));
return (gimp_drawable_is_rgb (GIMP_DRAWABLE (item)) &&
! gimp_drawable_is_indexed (GIMP_DRAWABLE (item)));
}
static gint
cylinder_constrain (gint32 image_id,
gint32 drawable_id,
gpointer data)
cylinder_constrain (GimpImage *image,
GimpItem *item,
gpointer data)
{
if (drawable_id == -1)
return TRUE;
return (gimp_drawable_is_rgb (drawable_id) &&
!gimp_drawable_is_indexed (drawable_id));
return (gimp_drawable_is_rgb (GIMP_DRAWABLE (item)) &&
! gimp_drawable_is_indexed (GIMP_DRAWABLE (item)));
}
/******************************/
......@@ -1295,7 +1289,7 @@ create_main_notebook (GtkWidget *container)
/********************************/
gboolean
main_dialog (gint32 drawable_id)
main_dialog (GimpDrawable *drawable)
{
GtkWidget *main_hbox;
GtkWidget *vbox;
......@@ -1426,7 +1420,7 @@ main_dialog (gint32 drawable_id)
g_object_unref (cursor);
}
image_setup (drawable_id, TRUE);
image_setup (drawable, TRUE);
compute_preview_image ();
......
......@@ -9,6 +9,6 @@ extern GtkWidget *previewarea;
/* Externally visible functions */
/* ============================ */
gboolean main_dialog (gint32 drawable_id);
gboolean main_dialog (GimpDrawable *drawable);
#endif /* __MAPOBJECT_UI_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment