Skip to content

Commit

Permalink
Start using GeglRectangle instead of individual x, y, width, height, …
Browse files Browse the repository at this point in the history
…where possible
  • Loading branch information
lmanul committed Aug 24, 2024
1 parent df02fbc commit 7bcbae0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdlib.h>
#include <math.h>

#include <gegl.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "plugin-intl.h"
Expand Down Expand Up @@ -77,6 +78,8 @@ gint32 render(gint32 image_ID,
height_i = vals->height_i;
width_p = image_vals->width_p;
height_p = image_vals->height_p;
GeglRectangle rect_image = { 0, 0, width_i, height_i };
GeglRectangle rect_patch = { 0, 0, width_p, height_p };
channels = gimp_drawable_bpp (drawable->drawable_id);

if (width_i == width_p && height_i == height_p) {
Expand Down Expand Up @@ -141,8 +144,8 @@ gint32 render(gint32 image_ID,
new_drawable = gimp_drawable_get(new_layer_id);

// Initialize in and out regions.
gimp_pixel_rgn_init(&rgn_out, new_drawable, 0, 0, width_i, height_i, TRUE, TRUE);
gimp_pixel_rgn_init(&rgn_in, drawable, 0, 0, width_p, height_p, FALSE, FALSE);
gimp_pixel_rgn_init(&rgn_out, new_drawable, rect_image.x, rect_image.y, rect_image.width, rect_image.height, TRUE, TRUE);
gimp_pixel_rgn_init(&rgn_in, drawable, rect_patch.x, rect_patch.y, rect_patch.width, rect_patch.height, FALSE, FALSE);

// Allocate some memory for everyone.
patch = g_new(guchar, width_p * height_p * channels);
Expand Down Expand Up @@ -210,7 +213,7 @@ gint32 render(gint32 image_ID,
vals->make_tileable);

cut_graph(patch_posn,
width_i, height_i, width_p, height_p,
rect_image.width, rect_image.height, rect_patch.width, rect_patch.height,
channels,
filled,
image,
Expand All @@ -220,7 +223,7 @@ gint32 render(gint32 image_ID,
FALSE);

// Display progress to the user.
count = count_filled_pixels (filled, width_i, height_i);
count = count_filled_pixels (filled, rect_image.width, rect_image.height);
progress = ((float) count) / ((float) count_max);
progress = (progress > 1.0f)? 1.0f : ((progress < 0.0f)? 0.0f : progress);
gimp_progress_update(progress);
Expand All @@ -236,7 +239,7 @@ gint32 render(gint32 image_ID,

gimp_drawable_flush(new_drawable);
gimp_drawable_merge_shadow (new_drawable->drawable_id, TRUE);
gimp_drawable_update(new_drawable->drawable_id, 0, 0, width_i, height_i);
gimp_drawable_update(new_drawable->drawable_id, rect_image.x, rect_image.y, rect_image.width, rect_image.height);
gimp_displays_flush();

g_free(patch);
Expand Down

0 comments on commit 7bcbae0

Please sign in to comment.