54
57
item = GIMP_ITEM (drawable);
56
gimage = gimp_item_get_image (item);
59
image = gimp_item_get_image (item);
58
mask = gimp_image_get_mask (gimage);
61
mask = gimp_image_get_mask (image);
60
63
/* don't apply the mask to itself and don't apply an empty mask */
61
64
if (GIMP_DRAWABLE (mask) == drawable || gimp_channel_is_empty (mask))
78
81
/* get the layer offsets */
79
82
gimp_item_offsets (item, &offset_x, &offset_y);
81
/* make sure the image application coordinates are within gimage bounds */
84
/* make sure the image application coordinates are within image bounds */
82
85
x1 = CLAMP (x, 0, gimp_item_width (item));
83
86
y1 = CLAMP (y, 0, gimp_item_height (item));
84
87
x2 = CLAMP (x + src2PR->w, 0, gimp_item_width (item));
99
102
/* If the calling procedure specified an undo step... */
101
gimp_drawable_push_undo (drawable, undo_desc, x1, y1, x2, y2, NULL, FALSE);
105
GimpDrawableUndo *undo;
107
gimp_drawable_push_undo (drawable, undo_desc, x1, y1, x2, y2, NULL, FALSE);
109
undo = GIMP_DRAWABLE_UNDO (gimp_image_undo_get_fadeable (image));
113
PixelRegion tmp_srcPR;
114
PixelRegion tmp_destPR;
116
undo->paint_mode = mode;
117
undo->opacity = opacity;
118
undo->src2_tiles = tile_manager_new (x2 - x1, y2 - y1,
122
pixel_region_resize (&tmp_srcPR,
123
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
125
pixel_region_init (&tmp_destPR, undo->src2_tiles,
127
x2 - x1, y2 - y1, TRUE);
129
copy_region (&tmp_srcPR, &tmp_destPR);
103
133
/* configure the pixel regions
104
134
* If an alternative to using the drawable's data as src1 was provided...
107
137
pixel_region_init (&src1PR, src1_tiles,
108
x1, y1, (x2 - x1), (y2 - y1), FALSE);
138
x1, y1, (x2 - x1), (y2 - y1), FALSE);
110
pixel_region_init (&src1PR, gimp_drawable_data (drawable),
111
x1, y1, (x2 - x1), (y2 - y1), FALSE);
112
pixel_region_init (&destPR, gimp_drawable_data (drawable),
113
x1, y1, (x2 - x1), (y2 - y1), TRUE);
140
pixel_region_init (&src1PR, gimp_drawable_get_tiles (drawable),
141
x1, y1, (x2 - x1), (y2 - y1), FALSE);
142
pixel_region_init (&destPR, gimp_drawable_get_tiles (drawable),
143
x1, y1, (x2 - x1), (y2 - y1), TRUE);
114
144
pixel_region_resize (src2PR,
115
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
116
(x2 - x1), (y2 - y1));
145
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
146
(x2 - x1), (y2 - y1));
127
157
my = y1 + offset_y;
129
159
pixel_region_init (&maskPR,
130
gimp_drawable_data (GIMP_DRAWABLE (mask)),
132
(x2 - x1), (y2 - y1),
160
gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
162
(x2 - x1), (y2 - y1),
135
165
combine_regions (&src1PR, src2PR, &destPR, &maskPR, NULL,
138
168
active_components,
176
206
item = GIMP_ITEM (drawable);
178
gimage = gimp_item_get_image (item);
208
image = gimp_item_get_image (item);
180
mask = gimp_image_get_mask (gimage);
210
mask = gimp_image_get_mask (image);
182
212
/* don't apply the mask to itself and don't apply an empty mask */
183
213
if (GIMP_DRAWABLE (mask) == drawable || gimp_channel_is_empty (mask))
200
230
/* get the layer offsets */
201
231
gimp_item_offsets (item, &offset_x, &offset_y);
203
/* make sure the image application coordinates are within gimage bounds */
233
/* make sure the image application coordinates are within image bounds */
204
234
x1 = CLAMP (x, 0, gimp_item_width (item));
205
235
y1 = CLAMP (y, 0, gimp_item_height (item));
206
236
x2 = CLAMP (x + src2PR->w, 0, gimp_item_width (item));
212
242
* we need to add the layer offset to transform coords
213
243
* into the mask coordinate system
215
x1 = CLAMP (x1, -offset_x, gimp_item_width (GIMP_ITEM (mask))-offset_x);
216
y1 = CLAMP (y1, -offset_y, gimp_item_height(GIMP_ITEM (mask))-offset_y);
217
x2 = CLAMP (x2, -offset_x, gimp_item_width (GIMP_ITEM (mask))-offset_x);
218
y2 = CLAMP (y2, -offset_y, gimp_item_height(GIMP_ITEM (mask))-offset_y);
245
x1 = CLAMP (x1, -offset_x, gimp_item_width (GIMP_ITEM (mask))-offset_x);
246
y1 = CLAMP (y1, -offset_y, gimp_item_height (GIMP_ITEM (mask))-offset_y);
247
x2 = CLAMP (x2, -offset_x, gimp_item_width (GIMP_ITEM (mask))-offset_x);
248
y2 = CLAMP (y2, -offset_y, gimp_item_height (GIMP_ITEM (mask))-offset_y);
221
251
/* If the calling procedure specified an undo step... */
225
255
/* configure the pixel regions
226
256
* If an alternative to using the drawable's data as src1 was provided...
228
pixel_region_init (&src1PR, gimp_drawable_data (drawable),
229
x1, y1, (x2 - x1), (y2 - y1), FALSE);
230
pixel_region_init (&destPR, gimp_drawable_data (drawable),
231
x1, y1, (x2 - x1), (y2 - y1), TRUE);
258
pixel_region_init (&src1PR, gimp_drawable_get_tiles (drawable),
259
x1, y1, (x2 - x1), (y2 - y1), FALSE);
260
pixel_region_init (&destPR, gimp_drawable_get_tiles (drawable),
261
x1, y1, (x2 - x1), (y2 - y1), TRUE);
232
262
pixel_region_resize (src2PR,
233
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
234
(x2 - x1), (y2 - y1));
263
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
264
(x2 - x1), (y2 - y1));
247
277
my = y1 + offset_y;
249
279
pixel_region_init (&mask2PR,
250
gimp_drawable_data (GIMP_DRAWABLE (mask)),
252
(x2 - x1), (y2 - y1),
260
tempPR.rowstride = tempPR.w * tempPR.bytes;
261
tempPR.data = temp_data = g_malloc (tempPR.h * tempPR.rowstride);
280
gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
282
(x2 - x1), (y2 - y1),
285
temp_data = g_malloc ((y2 - y1) * (x2 - x1));
287
pixel_region_init_data (&tempPR, temp_data, 1, x2 - x1,
288
0, 0, x2 - x1, y2 - y1);
263
290
copy_region (&mask2PR, &tempPR);
265
/* apparently, region operations can mutate some PR data. */
270
tempPR.data = temp_data;
292
pixel_region_init_data (&tempPR, temp_data, 1, x2 - x1,
293
0, 0, x2 - x1, y2 - y1);
272
295
apply_mask_to_region (&tempPR, maskPR, OPAQUE_OPACITY);
278
tempPR.data = temp_data;
297
pixel_region_init_data (&tempPR, temp_data, 1, x2 - x1,
298
0, 0, x2 - x1, y2 - y1);
280
300
combine_regions_replace (&src1PR, src2PR, &destPR, &tempPR, NULL,
281
301
opacity * 255.999,