Commit Graph

5912 Commits

Author SHA1 Message Date
b49c062fa4 New upstream version 2.10.34 2023-03-01 18:41:57 -05:00
de25be9210 app: fix a crash when converting to higher precision.
gimp_display_shell_render() writes to a GeglBuffer backed by allocated memory
(shell->profile_data). Unfortunately while converting prevision in
gimp_image_convert_precision(), we change the "precision" property (hence the
source format) first, hence end up trying to write data in a too small buffer.
This crash was hard to find as it was not showing up on my machine (though it
did produce rendering artifacts!), unless I built both GIMP and babl with
`b_sanitize=address`.

Note that an alternate fix was to make sure that the profile_data buffer is big
enough (by calling gimp_display_shell_profile_update() before rendering), but
anyway the image is in an inconsistent state while conversion is in progress:
whereas the `src_format` is the new one, the `src_profile` is still the old one
(and cannot be changed before we finish converting).

Moreover the render happen regularly on progress signals, once after each
converted drawable. So each of these rendering step happens in an inconsistent
state, with the wrong profile set, some of the drawables converted and others
not yet.
We could still render properly if each drawable's buffer used space-aware format
(thus allowing different drawables to use different profiles/spaces), but it
feels over-engineering the problem. It might be much better to ignore rendering
steps while converting the image precision. Moreover it would obviously make a
faster conversion.

See discussions in #9136 for this crash, which didn't have dedicated report
AFAIK.
2023-02-19 18:30:18 +01:00
aacd3d4640 Issue #8666: Color profile conversion is broken.
A bug in babl would run the color conversion twice when the input and output
buffer is the same and a LUT is available for the color transform. This is a
workaround in GIMP code (especially because we still don't require the latest
babl version), though a real bug fix will soon happen too in babl itself as
well.
2023-02-12 12:52:29 +01:00
30c23df646 New upstream version 2.10.32 2022-08-01 09:14:18 -04:00
6ab90ecbbd app: fix #8230 crash in gimp_layer_invalidate_boundary when channel is NULL
gimp_channel_is_empty returns FALSE if channel is NULL. This causes
gimp_layer_invalidate_boundary to crash if the mask channel is NULL.

With a NULL channel gimp_channel_is_empty should return TRUE, just like
the similar gimp_image_is_empty does, because returning FALSE here
suggests we have a non empty channel.

(cherry picked from commit 22af0bcfe6)
2022-06-05 18:54:20 -04:00
d9c9ef7902 app: fix #6961 Scaled image bug
With large image sizes a 32-bit int is not enough for the intermediate
computations, which byte per pixel, width and height are.

So, just like the function below it does: gimp_gegl_pyramid_get_memsize,
we will cast these to gint64.

Thanks to Massimo Valentini for finding the cause.

(cherry picked from commit ba841a98da)
2022-05-28 12:17:30 -04:00
52519f1290 New upstream version 2.10.30 2021-12-27 21:32:02 -05:00
b2396ec9d8 app: fix #383 Large PBM files exported from GIMP are blank
Fix as suggested by Massimo with formatting adjustments by me.
The use of gulong and glong is not cross platform safe: on Windows it is
32-bit and on most other platforms 64-bit.

Let's use guint64 and gint64 instead.

(cherry picked from commit d2c5591088)
2021-11-14 18:27:39 -05:00
1ff0cc1f5c New upstream version 2.10.28 2021-09-19 12:12:14 -04:00
970059b644 New upstream version 2.10.26 2021-09-09 19:33:41 -04:00
16fe52582d app: Correctly place merged down layer...
when the image is in indexed color mode, and bottom layer doesn't
have an alpha channel.

Resolves: #4945
2021-09-02 12:20:09 +06:00
0fccc87cb6 app: improve error message loading pattern that is too large
As noted in issue #6032 the error message when trying to open a pattern
file with dimension larger than supported could be a little clearer.

We do this by adding the maximum allowed dimensions to the error message.

(cherry picked from commit 317b5d9cff)
2021-08-09 18:28:16 -04:00
d9e82494b4 app: disallow saving of patterns larger than max allowed dimensions
For GIMP patterns we have maximum allowed dimensions which we check when
loading a pattern. However, we did not check this when saving a pattern.
See issue #6032.

This commit adds a check when saving a pattern and adds a descriptive
error to make clear why saving fails.

(cherry picked from commit f130fe1917)
2021-08-09 18:27:59 -04:00
5ad7ef10c3 Issue #6610: crashes on free select for images of certain dimensions.
g_alloca() is unadvised. Even though it might be more efficient in some
specific cases, it is pretty subject to stack overflow when a lot of
memory is requested.

Let's allocate dynamic memory instead. To avoid doing it too much, let's
just reuse the same pointer especially since region of interest will
usually be the same size when iterating a buffer, except for border
ones (which would usually be smaller, so we can use the same allocated
buffer again). I still make size checks, just in case.

(cherry picked from commit f2fb98cb69)
2021-08-04 19:36:12 +02:00
6c74aa8490 New upstream version 2.10.24 2021-07-18 14:31:43 -04:00
ac7e841e24 Issue #5008: Always true condition (i>=0) inside fill_inverse_cmap_gray.
Removing useless condition, add a g_return_if_fail() assertion for the
only (impossible unless bug) case which we don't expect. Also set
default mindist to G_MAXLONG instead of a magic number (which was ok now
but might become a problem if some day colormap allowed more than 16-bit
per channel colors).
Finally break when we reach a distance of 0 since we won't get lower
anyway, so better stop early.

Thanks to Rafał Mikrut and Øyvind Kolås for code commenting.

(cherry picked from commit d6dac25579)
2021-04-24 15:23:33 +02:00
2e6c233a4c app: fix an assertion when converting grayscale images to indexed.
We cannot just compare the drawable format with the model-type specs of
the color model. We need to include the space now.
In my case, some random screenshot converted to gray then indexed would
assert because the format is "Y' u8-space-gray-sRGB" (or for layers with
alpha: "Y'A u8-space-gray-sRGB"), hence indexed conversion failed and
ended up dark.

(cherry picked from commit c0e605ef96)
2021-04-24 15:23:21 +02:00
22db7695c8 Issue #288: Point snapping to guides does not work outside the canvas.
This commit also makes snap to grid and snap to vectors work off-canvas.
Since we now have off-canvas viewing, it just makes sense that snapping
would work there too.

Note that I disable snap to grid when "Show All" is OFF. I am actually
unsure this is right (as "Show All" is a view action, and we usually
don't change behavior based on view actions; for instance snap to guides
are not disabled if guides are hidden). Yet I noticed we do this in
various other features when off-canvas. We kind of use this view flag as
a switch for features working off-canvas (for instance, color picking
works off-canvas only when "Show All" is ON). So let's keep the same
logics for now at least.

Snap to guide or snap to vectors will always work though, because guides
and vectors are always visible off-canvas (even when "Show All" is OFF).
They always have been (visible, not snappable off-canvas; now they are
both).

(cherry picked from commit 82438728fb)
2021-02-13 13:11:27 +01:00
f2f0b6aae8 app: wait for the software to be fully initialized before processing…
… DBus calls.
In particular, Aryeom would start GIMP and directly double click some
image to be loaded in GIMP in the very short while when splash is
visible. Previous code would wait for the `restored` flag to be TRUE.
This was nearly it as we can actually start loading images as soon as
the 'restore' signal has passed. Yet the flag is set in the main
handler, but we actually also need the <Image> UI manager to exist,
which is created in gui_restore_after_callback() (so also a 'restore'
handler, yet after the main signal handler, i.e. after `restored` is set
to TRUE). Without this, gui_display_create() would fail with a CRITICAL,
hence file_open_with_proc_and_display() as well.

I could have tried to set the `restored` flag later, maybe with some
clever signal handling trick (and handle both the GUI and non-GUI cases,
i.e. I cannot set the flag inside gui_restore_after_callback() as it
would break the non-GUI cases). Instead I go for a simpler logics with a
new `initialized` flag which is only meant to be set once, once
everything has been loaded, i.e. once you can consider GIMP to be fully
running hence ready to process any common runtime command.

(cherry picked from commit a86ed68870)
2020-11-11 13:19:35 +01:00
627ba9c288 New upstream version 2.10.22 2020-10-06 19:17:19 -04:00
c6b46b63b5 New upstream version 2.10.20 2020-08-26 11:05:56 +01:00
Ell
5fc30e59d3 app: in GimpBacktrace Windows backend, return NULL backtrace if not initialized
In the Windows implementation of gimp_backtrace_new(), return NULL
if the backend is not fully initialized.

(cherry picked from commit 95b69dd77b)
2020-07-30 01:06:54 +03:00
a897b48921 app: show playground if any of the experimental feature is enabled.
Basically if you enabled OpenCL or any of the experimental tools, it
will show the Playground in Preferences. Otherwise, say you enabled some
experimental feature months ago (e.g. with the CLI option) and you now
experience crashes or whatnot. And you forgot how to change it, and only
remembered that there was something in Preferences. It would make you
crazy to not find the tab again to disable the option.

This is even more important as OpenCL is moving from a normal option to
a playground option. So you might not even have ever seen the Playground
tab in Preferences and would not know how to disable OpenCL after you
enabled it originally in "System Resources" tab.

So now Playground is visible with any of these 3 conditions:
* If you use an unstable version.
* If you run GIMP with --show-playground option.
* If you previously enabled one of the playground options.

(cherry picked from commit d3ef6cfb18)
2020-07-17 22:22:05 +02:00
Ell
e4fbf6c404 Issue #5208 - paint brush is broken when aspect ratio is set to negative
Fix horizontal downscaling of brush mipmap levels with odd width.
We'd previously fail to skip the last pixel of each input row,
which isn't included in the output when the width is odd, causing
subsequent output rows to be shifted to the right.

(cherry picked from commit c4a201eaf4)
2020-06-12 17:30:35 +03:00
Ell
182e9ebac4 app: use absolute offset for filter-tool split-preview guide position
In GimpDrawableFilter and GimpFilterTool, use an absolute offset
for the split-preview guide position, instead of storing it as a
fraction of the drawable's width/height.  The latter could
introduce rounding error, which would result in wrong coordinates
when converted back to an absolute offset.

(cherry picked from commit 214936e8c6)
2020-06-11 20:46:23 +03:00
8bb4b722c8 Compare counter value instead its pointer address
(cherry picked from commit be5d23bf98)
2020-05-31 12:15:43 +02:00
32ed52216c app: some small improvements in line art code.
Mostly I am adding a counter to the insignifiant zone fill, to be double
sure we are not going to fill huge areas (this should not happen already
anyway) and also it is no use to sample the line art buffer in such
case.

(cherry picked from commit 248477a125)
2020-05-31 12:15:19 +02:00
Ell
efb97fa7bd app: implement GimpColorManaged for GimpImageProxy
In GimpImageProxy, implement GimpColorManaged by forwarding the
functions to the underlying GimpImage, and forwarding the signals
in the other direction.  This fixes color-managed view in the
Navigation dockable.

(cherry picked from commit 258c8454d5)
2020-05-22 16:36:42 +03:00
Ell
5771393379 app: zero-out transparent pixels when converting to indexed
When converting an image to indexed mode, zero-out transparent
pixels instead of leaving junk in their indices, which might well
be out of range of the palette.

(cherry picked from commit 09870d4b15)
2020-05-20 21:16:55 +03:00
Ell
3e61ef9ae6 app: fix alignment of generic pixel buffers
Wherever we store arbitrary-format colors in an opaque buffer, use
double for the buffer, instead of char, so that it has a strict-
enough alignment to handle all our used pixel formats.

(cherry picked from commit a90f59d961)
2020-05-20 08:54:31 +03:00
f274b139fc Issue #3533 - Tool preset doesn't restore opacity and paint mode
There is no non-hackish way of fixing this without adding a new
"use-opacity-paint-mode" property to GimpToolPreset and a new toggle
in GimpToolPresetEditor. Restoring opacity and paint mode can now be
controlled explicitly, and defaults to TRUE.

(cherry picked from commit 97b714d428)
2020-05-12 21:14:41 +02:00
a0f03c0e37 app: do not snap white/black when making 2 color palette
For such needs there is a dedicated 1bit black/white palette in the
dialog.

(cherry picked from commit 80664c8e6e)
2020-05-01 17:37:05 +02:00
51955b2115 app: when creating palette only snap to black/white when present
By only doing the snapping to white/black for whitest/blackest palette
entries when the original RGB data contained these colors we permit
choosing near white/black colors in the cases where this might be
a desirable result as the whitest/blackest colors.

(cherry picked from commit d4387987b5)
2020-05-01 02:21:44 +02:00
a3f4bbbac9 app: make generated indexed palettes possibly contain pure black/white
The median-cut algorithm to derive a suitable palette for the image
computes each index to be used as the average of colors in a 3d box
in a color space, making the result value drift away from the extremes.
This makes it nigh impossible to achieve pure white or black, even
when the original image contained these colors, like in scans of
printed documents and technical drawings.

We counteract the drift by snapping the whitest color to white and the
blackest color to black if the resulting colors of median-cut are
already sufficiently close to white or black.

(cherry picked from commit 9bb3ff42d7)
2020-04-30 21:23:29 +02:00
Ell
cd1f531cde app: when copying GimpCurve, don't overwrite points from samples
In gimp_curve_config_copy(), make sure to copy the curve type
*before* the points, so that, when changing the type from FREE to
SMOOTH, we don't overwrite the copied points with interpolated
samples.

(cherry picked from commit 56693a8393)
2020-04-14 18:03:12 +03:00
a66f88287c app: add missing includes for windows
(cherry picked from commit 46f706a403)
2020-04-13 11:57:38 +02:00
Ell
1a41acecf2 app: apply common operation settings when reapplying a filter
Add a new gimp_drawable_apply_operation_with_config() function,
which takes an operation node together with a config object, and
applies the operation using the config options, including both the
operation-specific options, and the common GimpOperationSettings
options.

Use the function in gimp_gegl_procedure_execute(), so that
reapplying a filter takes the common operation settings used
originally into account.
2020-04-07 19:42:48 +03:00
Ell
6c0326a4fa app: add gimp_gegl_node_has_key()
... which determines if a node's operation-class has a specific
key, and can be used instead of gimp_gegl_node_get_key() when only
existence is important, to avoid compiler warnings.

Update the rest of the code to use the new function.
2020-04-07 19:42:48 +03:00
Ell
2bd0b77ad0 app: use gimp_drawable_supports_alpha() in GimpDrawableFilter
... instead of GIMP_IS_LAYER()
2020-04-07 19:42:48 +03:00
Ell
9906efd28a app: add gimp_drawable_filter_get_{drawable,operation,format}()
... which return the filter's drawable, operation, and output
format, respectively.
2020-04-07 19:42:48 +03:00
Ell
17e14487b8 app: add missing change to gimpdrawablefilter.c 2020-04-02 22:23:00 +03:00
Ell
1da36f32a1 app: add gimp_drawable_filter_set_preview()
... which allows enabling/disabling the filter's preview, without
destroying cached data.

(cherry picked from commit 7ec033d896)
2020-04-02 18:57:12 +03:00
Ell
98e1f6a846 app: rename gimp_drawable_filter_set_preview() to _set_preview_split()
... in preparation for next commit.

Update GimpFilterTool accordingly.

(cherry picked from commit 616530e235)
2020-04-02 18:57:11 +03:00
d5fc3e8009 app: leave locked pixels alone when cropping
Cropping tools will no longer discard layer data that falls out of the
crop region if the layer's pixels are locked

(cherry picked from commit 9a9e2e9a19)
2020-04-01 21:17:58 +02:00
8e7900cbf2 New upstream version 2.10.18 2020-03-29 00:23:03 -04:00
Ell
7685c16a1e Issue #4846 - Symmetry origin is wrong when painting on offset drawable
In gimp_symmetry_{mirror,mandala}_update_strokes(), adjust the
symmetry origin according to the drawable offset, so that it
remains fixed relative to the image regardless of the drawable
position.

(cherry picked from commit 6ed9b2bb7a)
2020-03-26 20:29:44 +02:00
Ell
ad85b13498 Issue #4858 - Duplicated image shows NULL in warning when closing it
In gimp_image_duplicate(), explicitly mark the new image as dirty,
so that its dirty time is set.  This avoids showing a NULL message
in place of the dirty time when closing the image.

(cherry picked from commit 83f935873a)
2020-03-23 22:31:07 +02:00
Ell
fbaf3c4290 app: render layer-group preview in chunks
In gimp_drawable_get_sub_preview_async(), when the drawable buffer
has a validate handler (i.e., when it's a group layer), use a chunk
iterator to validate the buffer in chunks, where each chunk is
validated in a separate invocation of the async function.  This
prevents validation from blocking the main thread for too long when
the buffer is not already fully validated.

(cherry picked from commit 64bf77aed8)
2020-03-14 16:06:13 +02:00
Ell
cd4c81133a app: speed up layer-group preview rendering
In gimp_drawable_get_sub_preview_async(), when the drawable buffer
has a validate handler (i.e., when the drawable is a group layer),
validate the requested area before calling gegl_buffer_get(), so
that the buffer is validated in a single step, instead of tile-by-
tile.

(cherry picked from commit 919ddce773)
2020-03-14 13:55:05 +02:00
Ell
422452b5da app: add "chunked" parameter to gimp_tile_handler_validate_validate()
... which allows validating the area in chunks, instead of in a
single step.

(cherry picked from commit faf6acfb67)
2020-03-14 13:55:04 +02:00