[gimp] plug-ins: port lightning to libgimp objects
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: port lightning to libgimp objects
- Date: Mon, 2 Sep 2019 17:36:19 +0000 (UTC)
commit 71f767efc0e1a9abceafa498d3e805a6a08d5939
Author: Michael Natterer <mitch gimp org>
Date: Mon Sep 2 19:31:56 2019 +0200
plug-ins: port lightning to libgimp objects
plug-ins/lighting/Makefile.am | 3 +-
plug-ins/lighting/lighting-apply.c | 51 +++++++++++-----------
plug-ins/lighting/lighting-image.c | 52 +++++++++++-----------
plug-ins/lighting/lighting-image.h | 27 +++++++-----
plug-ins/lighting/lighting-main.c | 60 ++++++++++++++-----------
plug-ins/lighting/lighting-preview.c | 4 +-
plug-ins/lighting/lighting-shade.c | 85 ++++++++++++++++++++++--------------
plug-ins/lighting/lighting-ui.c | 46 ++++++++++---------
plug-ins/lighting/lighting-ui.h | 2 +-
9 files changed, 182 insertions(+), 148 deletions(-)
---
diff --git a/plug-ins/lighting/Makefile.am b/plug-ins/lighting/Makefile.am
index e5a512aabf..4990450699 100644
--- a/plug-ins/lighting/Makefile.am
+++ b/plug-ins/lighting/Makefile.am
@@ -48,10 +48,9 @@ lighting_SOURCES = \
images/lighting-icon-images.h
AM_CPPFLAGS = \
- -DGIMP_DEPRECATED_REPLACE_NEW_API \
-I$(top_srcdir) \
$(GTK_CFLAGS) \
- $(GEGL_CFLAGS) \
+ $(GEGL_CFLAGS) \
-I$(includedir)
LDADD = \
diff --git a/plug-ins/lighting/lighting-apply.c b/plug-ins/lighting/lighting-apply.c
index 500ed24fa2..b7735995c4 100644
--- a/plug-ins/lighting/lighting-apply.c
+++ b/plug-ins/lighting/lighting-apply.c
@@ -27,8 +27,8 @@ 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;
gint32 index;
guchar *row = NULL;
guchar obpp;
@@ -37,43 +37,43 @@ compute_image (void)
if (mapvals.create_new_image == TRUE ||
(mapvals.transparent_background == TRUE &&
- ! gimp_drawable_has_alpha (input_drawable_id)))
+ ! gimp_drawable_has_alpha (input_drawable)))
{
/* Create a new image */
/* ================== */
- new_image_id = gimp_image_new (width, height, GIMP_RGB);
+ new_image = gimp_image_new (width, height, GIMP_RGB);
if (mapvals.transparent_background == TRUE)
{
/* Add a layer with an alpha channel */
/* ================================= */
- new_layer_id = gimp_layer_new (new_image_id, "Background",
- width, height,
- GIMP_RGBA_IMAGE,
- 100.0,
- gimp_image_get_default_new_layer_mode (new_image_id));
+ new_layer = gimp_layer_new (new_image, "Background",
+ width, height,
+ GIMP_RGBA_IMAGE,
+ 100.0,
+ gimp_image_get_default_new_layer_mode (new_image));
}
else
{
/* Create a "normal" layer */
/* ======================= */
- new_layer_id = gimp_layer_new (new_image_id, "Background",
- width, height,
- GIMP_RGB_IMAGE,
- 100.0,
- gimp_image_get_default_new_layer_mode (new_image_id));
+ new_layer = gimp_layer_new (new_image, "Background",
+ width, height,
+ GIMP_RGB_IMAGE,
+ 100.0,
+ gimp_image_get_default_new_layer_mode (new_image));
}
- gimp_image_insert_layer (new_image_id, new_layer_id, -1, 0);
- output_drawable_id = new_layer_id;
+ gimp_image_insert_layer (new_image, new_layer, NULL, 0);
+ output_drawable = GIMP_DRAWABLE (new_layer);
}
if (mapvals.bump_mapped == TRUE && mapvals.bumpmap_id != -1)
{
- bumpmap_setup (mapvals.bumpmap_id);
+ bumpmap_setup (GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.bumpmap_id)));
}
precompute_init (width, height);
@@ -84,17 +84,17 @@ compute_image (void)
}
else
{
- envmap_setup (mapvals.envmap_id);
+ envmap_setup (GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.envmap_id)));
ray_func = get_ray_color_ref;
}
- dest_buffer = gimp_drawable_get_shadow_buffer (output_drawable_id);
+ dest_buffer = gimp_drawable_get_shadow_buffer (output_drawable);
- has_alpha = gimp_drawable_has_alpha (output_drawable_id);
+ has_alpha = gimp_drawable_has_alpha (output_drawable);
/* FIXME */
- obpp = has_alpha ? 4 : 3; //gimp_drawable_bpp (output_drawable_id);
+ obpp = has_alpha ? 4 : 3; //gimp_drawable_bpp (output_drawable);
row = g_new (guchar, obpp * width);
@@ -142,13 +142,12 @@ compute_image (void)
g_object_unref (dest_buffer);
- 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!=-1)
+ if (new_image)
{
- gimp_display_new (new_image_id);
+ gimp_display_new (new_image);
gimp_displays_flush ();
}
-
}
diff --git a/plug-ins/lighting/lighting-image.c b/plug-ins/lighting/lighting-image.c
index e74ff98b79..a712b7e2ad 100644
--- a/plug-ins/lighting/lighting-image.c
+++ b/plug-ins/lighting/lighting-image.c
@@ -14,17 +14,17 @@
#include "lighting-ui.h"
-gint32 input_drawable_id;
-gint32 output_drawable_id;
-GeglBuffer *source_buffer;
-GeglBuffer *dest_buffer;
+GimpDrawable *input_drawable;
+GimpDrawable *output_drawable;
+GeglBuffer *source_buffer;
+GeglBuffer *dest_buffer;
-gint32 bump_drawable_id;
-GeglBuffer *bump_buffer;
-const Babl *bump_format;
+GimpDrawable *bump_drawable;
+GeglBuffer *bump_buffer;
+const Babl *bump_format;
-gint32 env_drawable_id;
-GeglBuffer *env_buffer;
+GimpDrawable *env_drawable;
+GeglBuffer *env_buffer;
guchar *preview_rgb_data = NULL;
gint preview_rgb_stride;
@@ -335,8 +335,8 @@ compute_maps (void)
/****************************************/
gint
-image_setup (gint32 drawable_id,
- gint interactive)
+image_setup (GimpDrawable *drawable,
+ gint interactive)
{
gint w, h;
gboolean ret;
@@ -346,10 +346,10 @@ image_setup (gint32 drawable_id,
/* Get some useful info on the input drawable */
/* ========================================== */
- input_drawable_id = drawable_id;
- output_drawable_id = drawable_id;
+ input_drawable = drawable;
+ output_drawable = drawable;
- ret = gimp_drawable_mask_intersect (drawable_id,
+ ret = gimp_drawable_mask_intersect (drawable,
&border_x1, &border_y1, &w, &h);
border_x2 = border_x1 + w;
@@ -358,10 +358,10 @@ image_setup (gint32 drawable_id,
if (! ret)
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;
@@ -381,13 +381,13 @@ image_setup (gint32 drawable_id,
}
void
-bumpmap_setup (gint32 bumpmap_id)
+bumpmap_setup (GimpDrawable *bumpmap)
{
- if (bumpmap_id != -1 && ! bump_buffer)
+ if (bumpmap && ! bump_buffer)
{
- bump_buffer = gimp_drawable_get_buffer (bumpmap_id);
+ bump_buffer = gimp_drawable_get_buffer (bumpmap);
- if (gimp_drawable_is_rgb (bumpmap_id))
+ if (gimp_drawable_is_rgb (bumpmap))
bump_format = babl_format ("R'G'B' u8");
else
bump_format = babl_format ("Y' u8"); /* FIXME */
@@ -395,13 +395,13 @@ bumpmap_setup (gint32 bumpmap_id)
}
void
-envmap_setup (gint32 envmap_id)
+envmap_setup (GimpDrawable *envmap)
{
- if (envmap_id != -1 && ! env_buffer)
+ if (envmap && ! env_buffer)
{
- env_width = gimp_drawable_width (envmap_id);
- env_height = gimp_drawable_height (envmap_id);
+ env_width = gimp_drawable_width (envmap);
+ env_height = gimp_drawable_height (envmap);
- env_buffer = gimp_drawable_get_buffer (envmap_id);
+ env_buffer = gimp_drawable_get_buffer (envmap);
}
}
diff --git a/plug-ins/lighting/lighting-image.h b/plug-ins/lighting/lighting-image.h
index 817c948bc9..06b0e02399 100644
--- a/plug-ins/lighting/lighting-image.h
+++ b/plug-ins/lighting/lighting-image.h
@@ -4,17 +4,18 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
-extern gint32 input_drawable_id;
-extern gint32 output_drawable_id;
-extern GeglBuffer *source_buffer;
-extern GeglBuffer *dest_buffer;
-extern gint32 bump_drawable_id;
-extern GeglBuffer *bump_buffer;
-extern const Babl *bump_format;
+extern GimpDrawable *input_drawable;
+extern GimpDrawable *output_drawable;
+extern GeglBuffer *source_buffer;
+extern GeglBuffer *dest_buffer;
-extern gint32 env_drawable_id;
-extern GeglBuffer *env_buffer;
+extern GimpDrawable *bump_drawable;
+extern GeglBuffer *bump_buffer;
+extern const Babl *bump_format;
+
+extern GimpDrawable *env_drawable;
+extern GeglBuffer *env_buffer;
extern guchar *preview_rgb_data;
extern gint preview_rgb_stride;
@@ -28,6 +29,7 @@ extern gint border_x1, border_y1, border_x2, border_y2;
extern guchar sinemap[256], spheremap[256], logmap[256];
+
guchar peek_map (GeglBuffer *buffer,
const Babl *format,
gint x,
@@ -61,9 +63,10 @@ gdouble get_map_value (GeglBuffer *buffer,
gdouble u,
gdouble v,
gint *inside);
-gint image_setup (gint32 drawable_id,
+gint image_setup (GimpDrawable *drawable,
gint interactive);
-void bumpmap_setup (gint32 bumpmap_id);
-void envmap_setup (gint32 envmap_id);
+void bumpmap_setup (GimpDrawable *bumpmap);
+void envmap_setup (GimpDrawable *envmap);
+
#endif /* __LIGHTING_IMAGE_H__ */
diff --git a/plug-ins/lighting/lighting-main.c b/plug-ins/lighting/lighting-main.c
index f732b3cbc8..96910e114f 100644
--- a/plug-ins/lighting/lighting-main.c
+++ b/plug-ins/lighting/lighting-main.c
@@ -118,40 +118,48 @@ set_default_settings (void)
static void
check_drawables (void)
{
+ GimpDrawable *drawable;
+ GimpDrawable *map;
+
if (mapvals.bump_mapped)
{
- if (mapvals.bumpmap_id != -1 &&
- gimp_item_get_image (mapvals.bumpmap_id) == -1)
+ if (! gimp_item_id_is_drawable (mapvals.bumpmap_id))
{
mapvals.bump_mapped = FALSE;
mapvals.bumpmap_id = -1;
}
-
- if (gimp_drawable_is_indexed (mapvals.bumpmap_id) ||
- (gimp_drawable_width (mapvals.drawable_id) !=
- gimp_drawable_width (mapvals.bumpmap_id)) ||
- (gimp_drawable_height (mapvals.drawable_id) !=
- gimp_drawable_height (mapvals.bumpmap_id)))
+ else
{
- mapvals.bump_mapped = FALSE;
- mapvals.bumpmap_id = -1;
+ drawable = GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.drawable_id));
+ map = GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.bumpmap_id));
+
+ if (gimp_drawable_is_indexed (map) ||
+ (gimp_drawable_width (drawable) != gimp_drawable_width (map)) ||
+ (gimp_drawable_height (drawable) != gimp_drawable_height (map)))
+ {
+ mapvals.bump_mapped = FALSE;
+ mapvals.bumpmap_id = -1;
+ }
}
}
if (mapvals.env_mapped)
{
- if (mapvals.envmap_id != -1 &&
- gimp_item_get_image (mapvals.envmap_id) == -1)
+ if (! gimp_item_id_is_drawable (mapvals.envmap_id))
{
mapvals.env_mapped = FALSE;
mapvals.envmap_id = -1;
}
-
- if (gimp_drawable_is_gray (mapvals.envmap_id) ||
- gimp_drawable_has_alpha (mapvals.envmap_id))
+ else
{
- mapvals.env_mapped = FALSE;
- mapvals.envmap_id = -1;
+ map = GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.envmap_id));
+
+ if (gimp_drawable_is_gray (map) ||
+ gimp_drawable_has_alpha (map))
+ {
+ mapvals.env_mapped = FALSE;
+ mapvals.envmap_id = -1;
+ }
}
}
}
@@ -195,7 +203,7 @@ query (void)
"Version 0.2.0, March 15 1998",
N_("_Lighting Effects..."),
"RGB*",
- GIMP_PLUGIN,
+ GIMP_PDB_PROC_TYPE_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
@@ -212,7 +220,7 @@ run (const gchar *name,
{
static GimpParam values[1];
GimpRunMode run_mode;
- gint32 drawable_id;
+ GimpDrawable *drawable;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
INIT_I18N ();
@@ -237,10 +245,10 @@ run (const gchar *name,
/* Get the specified drawable */
/* ========================== */
- run_mode = param[0].data.d_int32;
- drawable_id = param[2].data.d_drawable;
+ run_mode = param[0].data.d_int32;
+ drawable = GIMP_DRAWABLE (gimp_item_get_by_id (param[2].data.d_drawable));
- mapvals.drawable_id = drawable_id;
+ mapvals.drawable_id = gimp_item_get_id (GIMP_ITEM (drawable));
check_drawables ();
@@ -249,12 +257,12 @@ run (const gchar *name,
/* Make sure that the drawable is RGBA or RGB color */
/* ================================================ */
- if (gimp_drawable_is_rgb (drawable_id))
+ if (gimp_drawable_is_rgb (drawable))
{
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
- if (main_dialog (drawable_id))
+ if (main_dialog (drawable))
{
compute_image ();
@@ -265,7 +273,7 @@ run (const gchar *name,
break;
case GIMP_RUN_WITH_LAST_VALS:
- if (image_setup (drawable_id, FALSE))
+ if (image_setup (drawable, FALSE))
compute_image ();
gimp_displays_flush ();
break;
@@ -300,7 +308,7 @@ run (const gchar *name,
mapvals.transparent_background = (gint) param[23].data.d_int32;
check_drawables ();
- if (image_setup (drawable_id, FALSE))
+ if (image_setup (drawable, FALSE))
compute_image ();
}
default:
diff --git a/plug-ins/lighting/lighting-preview.c b/plug-ins/lighting/lighting-preview.c
index fc2b641172..b86c997685 100644
--- a/plug-ins/lighting/lighting-preview.c
+++ b/plug-ins/lighting/lighting-preview.c
@@ -96,7 +96,7 @@ compute_preview (gint startx, gint starty, gint w, gint h)
if (mapvals.bump_mapped == TRUE && mapvals.bumpmap_id != -1)
{
- bumpmap_setup (mapvals.bumpmap_id);
+ bumpmap_setup (GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.bumpmap_id)));
}
imagey = 0;
@@ -108,7 +108,7 @@ compute_preview (gint startx, gint starty, gint w, gint h)
if (mapvals.env_mapped == TRUE && mapvals.envmap_id != -1)
{
- envmap_setup (mapvals.envmap_id);
+ envmap_setup (GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.envmap_id)));
if (mapvals.previewquality)
ray_func = get_ray_color_ref;
diff --git a/plug-ins/lighting/lighting-shade.c b/plug-ins/lighting/lighting-shade.c
index 70443d9e42..36cb27b8f7 100644
--- a/plug-ins/lighting/lighting-shade.c
+++ b/plug-ins/lighting/lighting-shade.c
@@ -140,7 +140,10 @@ precompute_init (gint w,
if (mapvals.bumpmap_id != -1)
{
- bpp = gimp_drawable_bpp(mapvals.bumpmap_id);
+ GimpDrawable *drawable =
+ GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.bumpmap_id));
+
+ bpp = gimp_drawable_bpp (drawable);
}
bumprow = g_new (guchar, w * bpp);
@@ -183,7 +186,7 @@ interpol_row (gint x1,
if (mapvals.bumpmap_id != -1)
{
- bumpmap_setup (mapvals.bumpmap_id);
+ bumpmap_setup (GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.bumpmap_id)));
bpp = babl_format_get_bytes_per_pixel (bump_format);
}
@@ -221,7 +224,7 @@ interpol_row (gint x1,
guchar mapval;
guchar mapval1, mapval2;
- if (bpp>1)
+ if (bpp > 1)
{
mapval1 = (guchar)((float)((bumprow1[n * bpp] +bumprow1[n * bpp +1] + bumprow1[n * bpp + 2])/3.0
)) ;
mapval2 = (guchar)((float)((bumprow2[n * bpp] +bumprow2[n * bpp +1] + bumprow2[n * bpp + 2])/3.0
)) ;
@@ -313,7 +316,7 @@ precompute_normals (gint x1,
if (mapvals.bumpmap_id != -1)
{
- bumpmap_setup (mapvals.bumpmap_id);
+ bumpmap_setup (GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.bumpmap_id)));
bpp = babl_format_get_bytes_per_pixel (bump_format);
}
@@ -326,15 +329,15 @@ precompute_normals (gint x1,
{
switch (mapvals.bumpmaptype)
{
- case 1:
- map = logmap;
- break;
- case 2:
- map = sinemap;
- break;
- default:
- map = spheremap;
- break;
+ case 1:
+ map = logmap;
+ break;
+ case 2:
+ map = sinemap;
+ break;
+ default:
+ map = spheremap;
+ break;
}
for (n = 0; n < (x2 - x1); n++)
@@ -357,7 +360,7 @@ precompute_normals (gint x1,
{
for (n = 0; n < (x2 - x1); n++)
{
- if (bpp>1)
+ if (bpp > 1)
{
mapval = (guchar)((float)((bumprow[n * bpp + 0] +
bumprow[n * bpp + 1] +
@@ -425,7 +428,7 @@ precompute_normals (gint x1,
}
}
- if (n <pre_w)
+ if (n < pre_w)
{
if (y > 0)
{
@@ -490,7 +493,7 @@ sphere_to_image (GimpVector3 *normal,
*v = alpha / G_PI;
- if (*v==0.0 || *v==1.0)
+ if (*v == 0.0 || *v == 1.0)
{
*u = 0.0;
}
@@ -501,9 +504,9 @@ sphere_to_image (GimpVector3 *normal,
/* Make sure that we map to -1.0..1.0 (take care of rounding errors) */
/* ================================================================= */
- if (fac>1.0)
+ if (fac > 1.0)
fac = 1.0;
- else if (fac<-1.0)
+ else if (fac < -1.0)
fac = -1.0;
*u = acos (fac) / (2.0 * G_PI);
@@ -548,8 +551,8 @@ get_ray_color (GimpVector3 *position)
for (k = 0; k < NUM_LIGHTS; k++)
{
- if (!mapvals.lightsource[k].active
- || mapvals.lightsource[k].type == NO_LIGHT)
+ if (! mapvals.lightsource[k].active ||
+ mapvals.lightsource[k].type == NO_LIGHT)
continue;
else if (mapvals.lightsource[k].type == POINT_LIGHT)
p = &mapvals.lightsource[k].position;
@@ -559,7 +562,8 @@ get_ray_color (GimpVector3 *position)
color_int = mapvals.lightsource[k].color;
gimp_rgb_multiply (&color_int, mapvals.lightsource[k].intensity);
- if (mapvals.bump_mapped == FALSE || mapvals.bumpmap_id == -1)
+ if (mapvals.bump_mapped == FALSE ||
+ mapvals.bumpmap_id == -1)
{
light_color = phong_shade (position,
&mapvals.viewpoint,
@@ -587,6 +591,7 @@ get_ray_color (GimpVector3 *position)
}
gimp_rgb_clamp (&color_sum);
+
return color_sum;
}
@@ -607,10 +612,16 @@ get_ray_color_ref (GimpVector3 *position)
x = RINT (xf);
- if (mapvals.bump_mapped == FALSE || mapvals.bumpmap_id == -1)
- normal = mapvals.planenormal;
+ if (mapvals.bump_mapped == FALSE ||
+ mapvals.bumpmap_id == -1)
+ {
+ normal = mapvals.planenormal;
+ }
else
- normal = vertex_normals[1][(gint) RINT (xf)];
+ {
+ normal = vertex_normals[1][(gint) RINT (xf)];
+ }
+
gimp_vector3_normalize (&normal);
if (mapvals.transparent_background && heights[1][x] == 0)
@@ -627,8 +638,8 @@ get_ray_color_ref (GimpVector3 *position)
{
p = &mapvals.lightsource[k].direction;
- if (!mapvals.lightsource[k].active
- || mapvals.lightsource[k].type == NO_LIGHT)
+ if (! mapvals.lightsource[k].active ||
+ mapvals.lightsource[k].type == NO_LIGHT)
continue;
else if (mapvals.lightsource[k].type == POINT_LIGHT)
p = &mapvals.lightsource[k].position;
@@ -674,6 +685,7 @@ get_ray_color_ref (GimpVector3 *position)
}
gimp_rgb_clamp (&color_sum);
+
return color_sum;
}
@@ -689,7 +701,6 @@ get_ray_color_no_bilinear (GimpVector3 *position)
GimpVector3 normal, *p;
gint k;
-
pos_to_float (position->x, position->y, &xf, &yf);
x = RINT (xf);
@@ -709,8 +720,8 @@ get_ray_color_no_bilinear (GimpVector3 *position)
{
p = &mapvals.lightsource[k].direction;
- if (!mapvals.lightsource[k].active
- || mapvals.lightsource[k].type == NO_LIGHT)
+ if (! mapvals.lightsource[k].active ||
+ mapvals.lightsource[k].type == NO_LIGHT)
continue;
else if (mapvals.lightsource[k].type == POINT_LIGHT)
p = &mapvals.lightsource[k].position;
@@ -718,7 +729,8 @@ get_ray_color_no_bilinear (GimpVector3 *position)
color_int = mapvals.lightsource[k].color;
gimp_rgb_multiply (&color_int, mapvals.lightsource[k].intensity);
- if (mapvals.bump_mapped == FALSE || mapvals.bumpmap_id == -1)
+ if (mapvals.bump_mapped == FALSE ||
+ mapvals.bumpmap_id == -1)
{
light_color = phong_shade (position,
&mapvals.viewpoint,
@@ -746,6 +758,7 @@ get_ray_color_no_bilinear (GimpVector3 *position)
}
gimp_rgb_clamp (&color_sum);
+
return color_sum;
}
@@ -766,10 +779,16 @@ get_ray_color_no_bilinear_ref (GimpVector3 *position)
x = RINT (xf);
- if (mapvals.bump_mapped == FALSE || mapvals.bumpmap_id == -1)
- normal = mapvals.planenormal;
+ if (mapvals.bump_mapped == FALSE ||
+ mapvals.bumpmap_id == -1)
+ {
+ normal = mapvals.planenormal;
+ }
else
- normal = vertex_normals[1][(gint) RINT (xf)];
+ {
+ normal = vertex_normals[1][(gint) RINT (xf)];
+ }
+
gimp_vector3_normalize (&normal);
if (mapvals.transparent_background && heights[1][x] == 0)
diff --git a/plug-ins/lighting/lighting-ui.c b/plug-ins/lighting/lighting-ui.c
index cf90ee0745..7b36957409 100644
--- a/plug-ins/lighting/lighting-ui.c
+++ b/plug-ins/lighting/lighting-ui.c
@@ -65,11 +65,11 @@ static void toggle_update (GtkWidget *widget,
static void distance_update (GtkAdjustment *adj,
gpointer data);
-static gboolean bumpmap_constrain (gint32 image_id,
- gint32 drawable_id,
+static gboolean bumpmap_constrain (GimpImage *image,
+ GimpItem *item,
gpointer data);
-static gboolean envmap_constrain (gint32 image_id,
- gint32 drawable_id,
+static gboolean envmap_constrain (GimpImage *image,
+ GimpItem *item,
gpointer data);
static void envmap_combo_callback (GtkWidget *widget,
gpointer data);
@@ -254,34 +254,40 @@ zoomin_callback (GtkWidget *widget)
/**********************************************/
static gint
-bumpmap_constrain (gint32 image_id,
- gint32 drawable_id,
- gpointer data)
+bumpmap_constrain (GimpImage *image,
+ GimpItem *item,
+ gpointer data)
{
- return ((gimp_drawable_width (drawable_id) ==
- gimp_drawable_width (mapvals.drawable_id)) &&
- (gimp_drawable_height (drawable_id) ==
- gimp_drawable_height (mapvals.drawable_id)));
+ GimpDrawable *dr = GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.drawable_id));
+
+ return ((gimp_drawable_width (GIMP_DRAWABLE (item)) ==
+ gimp_drawable_width (dr)) &&
+ (gimp_drawable_height (GIMP_DRAWABLE (item)) ==
+ gimp_drawable_height (dr)));
}
static gint
-envmap_constrain (gint32 image_id,
- gint32 drawable_id,
- gpointer data)
+envmap_constrain (GimpImage *image,
+ GimpItem *item,
+ gpointer data)
{
- return (!gimp_drawable_is_gray (drawable_id) &&
- !gimp_drawable_has_alpha (drawable_id));
+ return (! gimp_drawable_is_gray (GIMP_DRAWABLE (item)) &&
+ ! gimp_drawable_has_alpha (GIMP_DRAWABLE (item)));
}
static void
envmap_combo_callback (GtkWidget *widget,
gpointer data)
{
+ GimpDrawable *env;
+
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
&mapvals.envmap_id);
- env_width = gimp_drawable_width (mapvals.envmap_id);
- env_height = gimp_drawable_height (mapvals.envmap_id);
+ env = GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.envmap_id));
+
+ env_width = gimp_drawable_width (env);
+ env_height = gimp_drawable_height (env);
}
/***********************/
@@ -1005,7 +1011,7 @@ create_main_notebook (GtkWidget *container)
/********************************/
gboolean
-main_dialog (gint32 drawable_id)
+main_dialog (GimpDrawable *drawable)
{
GtkWidget *main_hbox;
GtkWidget *vbox;
@@ -1129,7 +1135,7 @@ main_dialog (gint32 drawable_id)
g_object_unref (cursor);
}
- if (image_setup (drawable_id, TRUE))
+ if (image_setup (drawable, TRUE))
preview_compute ();
if (gimp_dialog_run (GIMP_DIALOG (appwin)) == GTK_RESPONSE_OK)
diff --git a/plug-ins/lighting/lighting-ui.h b/plug-ins/lighting/lighting-ui.h
index ad0ffba1a7..904aae8b0a 100644
--- a/plug-ins/lighting/lighting-ui.h
+++ b/plug-ins/lighting/lighting-ui.h
@@ -16,6 +16,6 @@ extern GtkWidget *spin_dir_z;
/* Externally visible functions */
/* ============================ */
-gboolean main_dialog (gint32 drawable_id);
+gboolean main_dialog (GimpDrawable *drawable);
#endif /* __LIGHTING_UI_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]