Commit Graph

5768 Commits

Author SHA1 Message Date
Ell 8ef1113dee Issue #2372 - Reduced quality of the Parametric brush in 2.10
Promote the precision of generated brushes to 32-bit float, and
modify brush preview generation, and gimpbrushcore-loops, to handle
float brushes.  This avoids posterization in large brushes.

Note that non-generated brushes are still uint8.
2019-02-06 14:30:48 -05:00
Ell 12dde445c4 app: add gimp_temp_buf_{lock,unlock}()
In GimpTempBuf, add gimp_temp_buf_lock() and gimp_temp_buf_unlock()
functions, which lock/unlock the buffer for data access.  Unlike
gimp_temp_buf_get_data(), which returns a direct pointer to the
buffer's data, the new functions take a format parameter and may
return a temporary buffer, allowing the buffer to be accessed using
an arbitrary format.
2019-02-06 14:30:47 -05:00
Ell 59ef222c7f app: in gimp_transform_matrix_generic(), apply matrix even if invalid
In gimp_transform_matrix_generic(), apply the resulting matrix even
if the transformation is invalid, since GimpGenericTransformTool
relies on the matrix to properly update the transform-grid widget.
2019-02-04 15:59:52 -05:00
Michael Natterer 08b4b944dc app: remove GimpDrawableFilter's own color profile conversion hack
it's wrong and harmful after space invasion.
2019-01-28 20:13:12 +01:00
Ell 4db566f0e1 app: fix indentation in gimpmaskundo.h 2019-01-20 10:33:53 -05:00
Ell 7cd768f3d8 app: align mask-undo buffer to tile grid
In GimpMaskUndo, align the copied region to the source buffer's
tile grid, so that all copied tiles are COWed.
2019-01-20 10:06:55 -05:00
Ell ac5e4f4c33 app: improve gimp_channel_clear()
When clearing a channel, do nothing if the channel is already
empty; otherwise, align the cleared rectangle to the channel
buffer's tile grid, so that all affected tiles are dropped, rather
than zeroed.  Furthermore, only update the affected region of the
channel.
2019-01-17 15:15:56 -05:00
Ell de4e7b4770 app: update drawable filter upon alpha-lock change
In GimpDrawableFilter, when operating on a layer, update the filter
when the layer's lock-alpha flag changes.
2019-01-17 14:19:58 -05:00
Ell 8571d7812f app: parallelize gimp_pickable_contiguous_region_by_color()
... by distributing the processed area over multiple threads.
2019-01-17 09:30:45 -05:00
Ell 9719dff9c5 app: convert gimppickable-contiguous-region to C++ 2019-01-17 09:30:45 -05:00
Jehan aa04258620 app: improved fix to commit 036ccc70cf.
After discussion with Sébastien Fourey and David Tschumperlé, it was
decided that a better fix for the edge case raised in #2785 was to add a
keypoint anyway, even if the point and none of its neigbours have a
positive smoothed curvature, yet they have a positive raw curvature. In
such case, we use the local maximum raw curvature instead of the local
maximum smoothed curvature.
2019-01-17 13:21:18 +01:00
Jehan c71b4916af app: add the concept of line art source to Bucket Fill tool.
Additionally to sample merge and active layer, now we can only use the
layer above or below the active layer as line art source.

The line art fill is meant to work on drawing lines. Though sample merge
still is ok in many cases, the more you fill with colors, the more the
line art computation becomes unecessarily complex. Also when you use a
lot of layers with some of them already filled with colors, it makes it
impossible to colorize some line art zones with the tool. Moreover you
just don't want to have to hide every layers out there to colorize one
layer (especially background layers and such as you may want to see the
result with your background).
Thus we want to be able to set the source as a unique layer, while it
not being necessarily the active one (because you want lines and colors
on different layers). In this case, I am assuming that the color and the
line layers are next to each other (most common organization).
2019-01-15 16:06:50 +01:00
Jehan 036ccc70cf Issue #2785: Fill by line art detection produces Segmentation fault...
... with some images.
2019-01-13 17:40:25 +01:00
Ell 9833da3431 app: clear priority rect when finishing projection rendering
In gimp_projection_finish_draw(), clear the chunk iterator's
priority rect before finishing rendering, since it's not needed at
this point, and this is slightly more efficient.
2019-01-13 08:23:01 -05:00
Ell 42845c9462 app: in gimp_projection_chunk_render_start(), properly invalidate preview
In gimp_projection_chunk_render_start(), when the current
projection rendering is complete, but not finalized yet, and no new
rendering is started (since the current update region is empty),
make sure to invalidate the projectable's preview, since it
normally happens when rendering is finalized, which doesn't happen
in this case.
2019-01-12 08:33:16 -05:00
Ell 0e5de95760 app: in gimp_projection_chunk_render_start(), don't leak empty region
In gimp_projection_chunk_render_start(), don't leak the current
update region when it's empty, but not NULL, and properly shut down
the idle source.
2019-01-12 08:20:10 -05:00
Ell 942e1aa939 app: fix gimp_chunk_iterator_set_priority_rect() 2019-01-12 07:31:33 -05:00
Ell a61f29e30a app: in gimpchunkiterator.c, #include <stdlib.h>
... for qsort().
2019-01-12 06:16:48 -05:00
Ell 246e782858 app: use GimpChunkIterator in GimpProjection
Replace the custom chunking logic of GimpProjection with
GimpChunkIterator, added in the previous commit.
2019-01-12 04:50:57 -05:00
Ell ba9ce34e10 app: add GimpChunkIterator
Factor out the region-chunking logic of GimpProjection into a new
GimpChunkIterator type, providing a generic mechanism for iterating
over a cairo region in discrete chunks.  The iterator doesn't
perform any processing itself, but rather dispenses rectangular
chunks, which the user then processes.

Iteration is broken into intervals, the duration of which is
configurable.  Each iteration begins with a call to
gimp_chunk_iterator_next(), after which
gimp_chunk_iterator_get_rect() should be called in succession to
fetch a rectangle to process, until it returns FALSE, which marks
the end of the iteration.  Updates to the UI should take place in
the interval between iterations, but not during an iteration.  The
iterator dynamically adjusts the chunk size according to processing
speed, in order to match the target iteration interval.

The iterator can be given a priority rectangle, which is processed
before the rest of the region.  It can also be given a
representative tile rectangle, defining a regular tile grid;
dispensed chunks are aligned to the tile grid as much as possible.
2019-01-12 04:50:57 -05:00
Jehan 005bc1406b app: add link to Smart Colorization scientific paper.
This is sometimes asked, and myself also need to find it from time to
time. I may as well put the link inside the code comments, where it is
just easy to find!
2019-01-12 00:26:19 +01:00
Jehan 90e9eb3fca app: alt-click to pick a layer will loop through candidate layers.
If you click on a zone filled in several visible layers, you don't
necessarily want the top layer. You may want one below. With this
change, as long as you hold alt, you will loop through all candidate
layers from top to bottom (then looping back top when reaching the
bottom).
In a first alt-click, you will always end up to the top candidate.
2019-01-07 23:08:48 +01:00
Ell 823d4a0d24 app: in bucket-fill tool, avoid calculating line art when not in line-art mode
In the bucket-fill tool, don't pre-calculate the line art when not
using a line-art fill area.  Also, misc. cleanup.
2019-01-06 16:30:41 -05:00
Ell 889e2e26ee app: remove gimp-scratch; replace with gegl-scratch
The scratch allocator has been moved to GEGL (commit
gegl@b99032d799dda3436ffa8c1cc28f8b0d34fb965d).  Remove gimp-
scratch, and replace all its uses with gegl-scratch.
2019-01-06 07:37:19 -05:00
Ell d56d663eaa app: In GimpHistogram, align copied buffer region to tile rect
In gimp_histogram_calculate_async(), align the copied region of the
drawable and mask buffers to the tile grid, so that all copied
tiles are COWed.
2019-01-04 08:16:51 -05:00
Michael Natterer b2cb334b47 app, libgimp: forgot to add /*< pdb-skip >*/ to enum GimpBucketFillMode
so it was still exported to libgimp.
2019-01-02 16:18:28 +01:00
Michael Natterer 07e46abb72 app, libgimp*: move enum GimpBucketFillMode to the core
The libgimp API using it is gone.
2019-01-02 16:07:20 +01:00
Michael Natterer abd7cbfc8d Issue #1788 - Inconsistency between FG color and selected color in...
...palette views despite selected color being in the currently
selected pallette

As suggested by Massimo, changing the color comparison EPSILON in
gimppalette.c from 1e-10 to 1e-6 fixes this, and is really small
enough.

Also, generally clean up color comparison epsilons:

- use a #define, not hardcoded values for all uses of
  gimp_rgb[a]_distance()
- call the #defines RGB_EPSILON and RGBA_EPSILON
- make them all 1e-6 or larger
2019-01-02 01:49:43 +01:00
Michael Natterer 8a4aacb52f Issue #2667 - When copying a text layer, paste should create a new...
...text layer, not an image of the text

In gimp_edit_paste_get_layer(), when pasting as floating selection,
collapse the pasted layer into an ordinary layer only if it's a group
layer. There is nothing that speaks against having a floating text
layer, it works just fine.
2019-01-02 00:14:35 +01:00
Michael Natterer a338220fa6 app: fix the layer formats of indexed images to contain the space
Add gimp_image_colormap_update_formats() which does:

- always update the cached palette formats based on the current space
  of the image
- always set the palette entries on the palette formats

Make sure the function is called whenever the space or the colormap
change.

Fix gimp_image_convert_profile_colormap() to convert the colormap
entries between the right spaces.
2019-01-01 19:06:23 +01:00
Michael Natterer 78f5d39e1a app, libgimpcolor: handle palette formats across babl_format_with_space()
Don't just pass the input format's encoding because that loses the
palette. Instead, pass the input format directly so
babl_format_with_space() can do its job of preserving the palette.
2019-01-01 16:34:57 +01:00
Ell 3738ff3ffd app: small fix to gimp_drawable_edit_fill() 2018-12-31 05:33:42 -05:00
Ell 6384ff01b6 app: in gimp_drawable_edit_fill(), make trivial alpha-only fill a NOP
In gimp_drawable_edit_fill(), if the fill only affects the alpha
channel, and if the drawable has no alpha channel, or the alpha
channel is masked out, do nothing, instead of unnecessarily
performing the fill, which has no effect.
2018-12-31 04:40:09 -05:00
Ell b846ffed19 app: in GimpDrawableFilter, only update crop/preview area when updating whole drawable
In GimpDrawableFilter, when updating the entire filter area, only
update the crop/preview area (as set by
gimp_drawable_filter_set_{crop,preview}()), instead of the entire
drawable.
2018-12-30 05:13:01 -05:00
Ell 5c27d14fdf app: add gimp_drawable_filter_set_crop()
Add gimp_drawable_filter_set_crop(), which allows setting an output
crop rectangle for the filter; anything outside the rectangle
doesn't get filtered.  The crop area is combined with the preview
area to determine the filtered area during preview, however, unlike
the preview area, the crop area remains in effect while committing
the filter.

Consequently, when merging a drawable filter, if the filter has a
crop, only process the cropped area.
2018-12-30 05:13:01 -05:00
Ell 7534ae53d6 app: rename gimp_applicator_set_preview() to _set_crop(); add _get_crop()
We're going to use GimpApplicator's output crop for more than just
split previews.  Rename gimp_applicator_set_preview() to
gimp_applicator_set_crop(), and add gimp_applicator_get_crop(),
which returns the output crop rectangle, or NULL if cropping is
disabled.
2018-12-30 05:13:00 -05:00
Ell b201f73562 app: use GimpDrawableFilter in gimp_drawable_apply_operation()
In gimp_drawable_apply_operation(), use a temporary
GimpDrawableFilter to apply the operation, instead of using a
shadow buffer.  This renders and composits the op directly into the
drawable buffer, avoiding an intermediate buffer, requiring less
space and speeding up processing.
2018-12-29 14:28:43 -05:00
Ell ab52dc6bca app: in GimpApplicator, allow enabling cache/preview after construction; remove preview cache
Remove the use_split_preview and use_result_cache parameters of
gimp_applicator_new(), and allow enabling/disabling the cache
(through gimp_applicator_set_cache()) and the preview crop (through
gimp_applicator_set_preview()) after construction.

Move the preview crop node after the result cache, and remove the
separate preview cache node.  This eliminates an extra cache
buffer, reducing the space consumed by filters, and speeds up split
preview, since the cached result now includes the output
compositing.
2018-12-29 14:28:42 -05:00
Ell cba4bc4781 app: in gimp_drawable_merge_filter(), align undo rect to tile grid
In gimp_drawable_merge_filter(), align the region copied to the
undo buffer to the drawable buffer's tile grid, so that the copied
tiles are COWed.
2018-12-28 08:30:59 -05:00
Ell 95393722cc Revert "Bug 796090 - (wrong) true-color preview of GEGL filter ops, ..."
We now perform the conversion of filter output to the drawable
format as part of the individual filter nodes (see the last few
commits), so there's no need for another conversion after the
filter stack.

This reverts commit d6e0ca5054.
2018-12-28 03:56:31 -05:00
Ell 3f45e893bf app: cache result of floating selections
Use an output cache for floating-selection filters, to speed up
anchoring.
2018-12-28 03:55:35 -05:00
Ell 0560c5a6fe app: use drawable format as floating-sel applicator output format
Set the output format of floating-selection applicators to the
target drawable format.  We're going to remove the global
GipDrawable convert-format node, which we use to get correct
previews for indexed drawables, so that each filter now has to do
its own format conversion.
2018-12-28 03:55:34 -05:00
Ell 8e57ee2265 app: in GimpDrawableFilter, use the drawable format as the cache format
In GimpDrawableFilter, set the applicator's output format to the
drawable format, so that the cache uses the drawable format, and so
copying the cached result to the drawble's buffer when comitting
the filter becomes much cheaper, and, in particular, doesn't
require reading tiles out of the swap.  This notably improves
commit speed in large images, at the expense of requiring a few
extra conversions during preview.
2018-12-28 03:55:34 -05:00
Ell 85e454bae8 app: add GimpDrawable::format-changed signal
... which is emitted when the drawable's format is changed.
2018-12-28 03:55:33 -05:00
Ell ef9b1f6694 app: in GimpLineArt, use "invalidate-preview" signal of input viewable
In GimpLineArt, use the "invalidate-preview" signal of the input
viewable, instead of its "painted" or "rendered" signals, for
asynchronously computing the line art.  Subsequently, remove the
aforementioned signals from GimpDrawable and GimpProjection,
respectively.  This simplifies the code, and reduces the number of
signals.
2018-12-27 17:14:28 -05:00
Ell ed7ea51fb7 app: remove "Edit -> Fade..."
This commit completely removes the "Edit -> Fade..." feature,
because...

- The main reason is that "fade" requires us to keep two buffers,
  instead of one, for each fadeable undo step, doubling (or worse,
  since the extra buffer might have higher precision than the
  drawable) the space consumed by these steps.  This has notable
  impact when editing large images.  This overhead is incurred even
  when not actually using "fade", and since it seems to be very
  rarely used, this is too wasteful.

- "Fade" is broken in 2.10: when comitting a filter, we copy the
  cached parts of the result into the apply buffer.  However, the
  result cache sits after the mode node, while the apply buffer
  should contain the result of the filter *before* the mode node,
  which can lead to wrong results in the general case.

- The same behavior can be trivially achieved "manually", by
  duplicating the layer, editing the duplicate, and changing its
  opacity/mode.

- If we really want this feature, now that most filters are GEGL
  ops, it makes more sense to just add opacity/mode options to the
  filter tool, instead of having this be a separate step.
2018-12-27 11:44:25 -05:00
Jehan 503775a5a0 app: rename and merge the spline and segment length properties...
... in GimpBucketFillOptions for the line art algorithm.

Inside GimpLineArt, there are still 2 properties, but we don't show them
anymore in the Bucket Fill tool options. One of the main reason is
probably that it's hard to differentiate their usage. One is to close
with curved lines, the other with straight segments. Yet we don't
actually have any control on one or the other. All one knows is that you
can have "holes" in your drawing of a given size and you want them
close-like for filling. Only reason I can see to have 2 types of closure
is whether you'd want to totally disable one type of closure (then you
set it to 0). But this is a very limited reason for making the options
less understandable overall, IMO.
So for the time being, let's show up only a single option which sets
both properties in GimpLineArt. As patdavid says "it makes sense as a
first pass".

Also rename the option to shorter/simpler "Maximum gap length". Thanks
to patdavid and pippin for helping on figuring out this better label!

Finally I am bumping the default for the gaps to 100px. The original
values were ok for the basic small images used in demos, but not for
real life image where it was always too short (even 100px may still be
too short actually, but much better than the 20 and 60px from before!).
2018-12-24 13:33:58 +01:00
Ell 93f4b18704 app: improve gradient color-sampling speed
Improve the speed of gimp_gradient_get_color_at(), which is used by
gimp:gradient during processing when the gradient cache is too big,
by disabling type checking, and inlining and avoiding some function
calls.
2018-12-20 08:32:17 -05:00
Jehan 0a2d066168 app: allow setting line art spline and segment length to 0.
Practically it means that the algorithm won't close line art anymore
with both settings at 0. This can nevertheless still be a very useful
tool when you have a drawing style with well-closed lines. In such a
case, you will still profit from the color flooding under the line art
part of the algorithm.
Moreover with such well-closed zones from start, you don't get the
over-segmentation anymore and the threaded processing will be faster
obviously.
2018-12-17 15:46:47 +01:00
Jehan cd924f453a app: do not make line art bucket fill a GimpSelectCriterion anymore.
This was my initial choice, but the more I think about it, the less I am
sure this was the right choice. There was some common code (as I was
making a common composite bucket fill once the line art was generated),
but there is also a lot of different code and the functions were filled
of exception when we were doing a line art fill. Also though there is a
bit of color works (the way we decide whether a pixel is part of a
stroke or not, though currently this is basic grayscale threshold), this
is really not the same as other criterions. In particular this was made
obvious on the Select by Color tool where the line art criterion was
completely meaningless and would have had to be opted-out!

This commit split a bit the code. Instead of finding the line art in the
criterion list, I add a third choice to the "Fill whole selection"/"Fill
similar colors" radio. In turn I create a new GimpBucketFillArea type
with the 3 choices, and remove line art value from GimpSelectCriterion.

I am not fully happy yet of this code, as it creates a bit of duplicate
code, and I would appreciate to move some code away from gimpdrawable-*
and gimppickable-* files. This may happen later. I break the work in
pieces to not get too messy.
Also this removes access to the smart colorization from the API, but
that's probably ok as I prefer to not freeze options too early in the
process since API needs to be stable. Probably we should get a concept
of experimental API.
2018-12-12 15:27:48 +01:00
Jehan db18c679f3 app: reorganize the line art code inside a GimpLineArt object.
The code was too much spread out, in core and tool code, and also it was
made too specific to fill. I'll want to reuse this code at least in the
fuzzy select tool. This will avoid code duplication, and also make this
new process more self-contained and simpler to review later (the
algorithm also has a lot of settings and it is much cleaner to have them
as properties rather than passing these as parameters through many
functions).

The refactoring may not be finished; that's at least a first step.
2018-12-07 22:18:06 +01:00
Ell c9c2397b0d app: in GimpProjection, fix reinit. of current row when chunk height changes
In GimpProjection's chunk renderer, when the chunk height changes
in the middle of a row, we need to merge the remainder of the
current render area back into the renderer's update region, and
refetch the remainder of the row as the new render area, so that we
don't miss any unrendered area, or re-render already-rendered area,
due to the change in chunk height.  However, we should previously
fail to verify that the fetched area is, in fact, the remainder of
the current row, which could cause us to render the wrong area,
missing parts of the update region.

Fix this, by breaking up some of the chunk-renderer fucntions into
smaller sub-functions, and using those in order to explicitly set
the new render area to the remainder of the current row when the
chunk height changes.  This also avoids erroneously merging the
unflushed update region of the projection into the renderer's
update region.
2018-12-06 08:50:59 -05:00
Ell 411ddb7e48 Revert "app: save images with fractional grid coordinates as version-10 XCFs"
Actually, image grids are saved as parasites, so even though older
GIMP versions round their coordinates upon loading, they maintain
the fractional coordinates when re-saving the image, hence bumping
the XCF version is not really necessary.

This reverts commit 13119efda33a7aba323dc13e6a56207a15a9f000.
2018-12-05 13:52:38 -05:00
Ell a90322278d app: save images with fractional grid coordinates as version-10 XCFs
Fractional-coordinate support for image grids was added in commit
1572bccc9f, right before the
introduction of XCF version 10.  While images with fractional grid
coordinates can be loaded with earilier versions of GIMP, the grid
coordinates are rounded to the nearest integer.

Bump the minimal XCF version when saving images with fractional
grid coordinates to 10, which should have been the case all along.
2018-12-05 13:33:39 -05:00
Ell 83250eb57c app: don't use direct-buffer fill when some components are masked 2018-12-03 09:54:10 -05:00
Ell 053e5edc93 libgimpcolor, app, modules, plug-ins: remove GEGL_ITERATOR2 define
... it's no longer needed, since GEGL commit
gegl@9dcd2cde63f95a080bf16a58c10e9ffbdd99aace.

Partially reverts commits:

6fca9959c7
cc10af72cc
49c53568d7
8edbc0d491
29f63616d2
3a2014984d
ee48ec6877
4165a315d5
764085278f
b7633c722e
6ab12061b7
754a3c5b18
22b4b647bd
55b3438328
c6d23add65
f03a84d607
822f9f0d2b
95358ca1fa
cdda37f4ee
41e8035635
6761da42b2
fb5d7832a8
97ed7817d8
46e9036578
ea9c5e6a49
24fbdfb591
beb4ecb238
4b77831e03
fcf113a39c
567ffe94ff
2018-12-02 11:15:37 -05:00
Ell dac9bfe334 app: add "direct" parameter to gimp_projection_flush_now()
Add a boolean "direct" parameter to gimp_projection_flush_now(),
which specifies if the projection buffer should only be invalidated
(FALSE), or rendered directly (TRUE).

Pass TRUE when flushing the projection during painting, so that the
affected regions are rendered in a single step, instead of tile-by-
tile.  We previously only invalidated the projection buffer, but
since we synchronously flush the display right after that, the
invalidated regions would still get rendered, albeit less
efficiently.

Likewise, pass TRUE when benchmarking the projection through the
debug action, and avoid flushing the display, to more accurately
measure the render time.
2018-12-02 10:14:58 -05:00
Ell 42b82419b1 app: another fix to drawable direct-fill criterion
Don't use a direct-buffer fill when filling using a pattern with
alpha, even when the mode is subtractive.
2018-12-02 03:43:25 -05:00
Ell 660f53d300 app: fix drawable direct-fill criterion
Don't use a direct-buffer fill if the mode is subtractive, and the
composite region includes the source.  Currently, this never
actually happens.
2018-12-02 03:33:56 -05:00
Ell dd8268c0a2 app: optimize simple whole-drawable fill/clear
In gimp_drawable_edit_fill(), when filling/clearing the whole
drawable, without any special compositing (i.e., when there's no
selection, the opacity is 100%, and the layer mode is trivial),
fill/clear the drawable's buffer directly, without using an
applicator.  This makes such operations much faster, especially in
big images.
2018-12-02 03:10:31 -05:00
Ell 45fc4cb4f9 app: add gimp_fill_options_fill_buffer()
... which is similar to gimp_fill_options_create_buffer(), however,
it fills an existing buffer, instead of creating a new buffer.

Implement gimp_fill_options_create_buffer() in terms of the new
function.
2018-12-02 03:10:30 -05:00
Ell bb9dd049fb app: align drawable undo rectangle to tile grid
When creating a drawable undo from the drawable's buffer, align the
copied rectangle to the buffer's tile grid, so that all the copied
tiles are COWed, saving memory and gaining speed.

Add applied_x and applied_y fields to GimpDrawableUndo, specifying
the position at which to apply the applied_buffer, so that we apply
it in the right place, even if the undo rect has changed due to
alignment.
2018-12-02 03:10:28 -05:00
Ell f27b38808f app: a few improvements to gimp-scratch
Simplify code a bit, and add branch-prediction annotations.
2018-12-01 10:04:11 -05:00
Ell 8c9eb1c743 app: #include <string.h> in gimp-scratch.h
... for memset().
2018-12-01 06:06:27 -05:00
Ell 5d1a79a34f app: fix definition signature of gimp_scratch_get_total() 2018-12-01 05:58:10 -05:00
Ell 698d1af798 app: add scratch-total variable to the dashboard
Add a scratch-total variable to the dashboard's misc group, showing
the total amount of memory used by the scratch allocator.
2018-12-01 05:55:16 -05:00
Ell a8a8655285 app: add gimp-scratch allocator
gimp-scratch is a fast memory allocator (on the order of magnitude
of alloca()), suitable for small (up to a few megabytes), short-
lived (usually, bound to the current stack-frame) allocations.
Unlike alloca(), gimp-scratch doesn't use the stack, and is
therefore safer, and will also serve bigger requests, by falling-
back to malloc().

The allocator itself is very simple:  We keep a per-thread stack of
cached memory blocks (allocated using the normal allocator).  When
serving an allocation request, we simply pop the top block off the
stack, and return it. If the block is too small, we replace it with
a big-enough block.  When the block is freed, we push it back to
the top of the stack (note that even though each thread uses a
separate stack, blocks can be migrated between threads, i.e.,
allocated on one thread, and freed on another thread, although this
is not really an intended usage pattern.)  The idea is that the
stacks will ultimately stabalize to contain blocks that can serve
all the encountered allocation patterns, without needing to reisze
any of the blocks; as a consequence, the amount of scratch memory
allocated at any given time should really be kept to a minimum.
2018-12-01 05:55:15 -05:00
Ell 01f9409902 app: in GimpBacktrace Linux backend, don't leak backtrace when dropping threads
Should have been part of commit
a29d040db5.
2018-12-01 04:33:45 -05:00
Ell c749097dcc app: in GimpBacktrace Linux backend, make blacklisted_thread_names const 2018-12-01 03:52:31 -05:00
Ell 49fd2847ac app: add gimp_async_add_callback_for_object()
... which is similar to gimp_async_add_callback(), taking an
additional GObject argument.  The object is kept alive for the
duration of the callback, and the callback is automatically removed
when the object is destroyed (if it hasn't been already called).

This is analogous to g_signal_connect_object(), compared to
g_signal_connect().
2018-11-30 03:30:51 -05:00
Ell a779dd3849 app: unref async when removing last callback if idle is pending
In gimp_async_remove_callback(), if removing the last callback
while the callback idle-source is already pending, cancel the idle
source and unref the async object (the async is reffed when adding
the idle source.)
2018-11-30 03:30:51 -05:00
Jehan d71efdec20 app: add the segment and spline max length options for line art.
We can't just hardcode this. On huge images in particular, you'll want
to increase this value.
2018-11-29 17:29:42 +01:00
Jehan f7a4ce1051 app: some code cleaning in gimplineart.
In particular, make simpler code in a few places, taking abyss value
into account (rather than checking the position).
2018-11-29 14:13:50 +01:00
Ell d6f0ca5531 app: use gimp_tile_handler_validate_validate() in GimpProjection
Use gimp_tile_handler_validate_validate(), added in the last
commit, in GimpProjection, in order to render the projection,
instead of separately invalidating the buffer, undoing the
invalidation, and then rendering the graph.  This is more
efficient, and more idiomatic.
2018-11-28 13:26:38 -05:00
Ell 5a623fc54b app: add GimpTileHandlerValidate::{begin,end}_validate() vfuncs
Add begin_validate() and end_validate() virtual functions, and
corresponding free functions, to GimpTileHandlerValidate.  These
functions are called before/after validation happens, and should
perform any necessary steps to prepare for validation.  The default
implementation suspends validation on tile access, so that the
assigned buffer may be accessed without causing validation.

Implement the new functions in GimpTileHandlerProjectable, by
calling gimp_projectable_begin_render() and
gimp_projectable_end_render(), respectively, instead of calling
these functions in the ::validate() implementation (which, in turn,
allows us to use the default ::validate() implementation.)

In GimpProjection, use the new functions in place of
gimp_projectable_{begin,end}_render().
2018-11-28 13:25:33 -05:00
Ell 8a47b68194 app: avoid starting the chunk renderer while finishing drawing a projection
In gimp_projection_finish_draw(), make sure we don't accidentally
re-start the chunk renderer idle source while running the remaining
iterations, in case the chunk height changes, and we need to reinit
the renderer state.
2018-11-28 13:25:32 -05:00
Ell b07f810273 app: avoid flushing bufferless projections
Don't needlessly flush projections whose buffer hasn't been
allocated yet.  This can happen when opening an image, in which
case the image is flushed before its projection has a buffer.
2018-11-28 13:25:32 -05:00
Jehan 744d67939d app: flood isolated pixels in smart colorization fill.
The smart colorization was leaving irritating single pixels in between
colorized regions, after growing and combining. So let's just flood
these. We don't flood bigger regions (and in particular don't use
gimp_gegl_apply_flood()) on purpose, because there may be small yet
actual regions inside regions which we'd want in other colors. 1-pixel
regions is the extreme case where chances that one wanted it filled are
just higher.
2018-11-27 15:12:18 +01:00
Jehan 6bec0bc82d app: radius map actually not useful during smart colorization grow step.
The distance map has all the information we need already. Also we will
actually grow up to the max radius pixel (middle pixel of a stroke).
After discussing with Aryeom, we realized it was better to fill a stroke
fully (for cases of overflowing, I already added the "Maximum growing
size" property anyway).
2018-11-27 14:59:35 +01:00
Jehan 613bf7c5ab app, libgimpconfig: make various usage of g_file_replace() safer.
When an error occurs, we want to prevent overwriting any previous
version of the file by incomplete contents. So run
g_output_stream_close() with a cancelled GCancellable to do so.
See also discussion in #2565.
2018-11-26 15:50:38 +01:00
Jehan d2f9549c9f app: add possibility to antialias line art colorization. 2018-11-26 12:33:45 +01:00
Jehan c32b0ecc92 app: simpler code with gegl_node_blit().
No need to go through an intermediate GeglBuffer when unneeded.
2018-11-26 12:26:54 +01:00
Jehan eb042e6c87 app: add "line-art-max-grow" property to the bucket fill options.
When flooding the line art, we may overflood it in sample merge (which
would use color in the line art computation). And if having all colors
on the same layer, this would go over other colors (making the wrong
impression that the line art leaked).
This new option is mostly to keep some control over the mask growth.
Usually a few pixels is enough for most styles of drawing (though we
could technically allow for very wide strokes).
2018-11-22 18:13:58 +01:00
Jehan 5a4754f32b app: properly (bucket) fill created splines and segments in line art.
For this, I needed distmap of the closed version of the line art (after
splines and segments are created). This will result in invisible stroke
borders added when flooding in the end. These invisible borders will
have a thickness of 0.0, which means that flooding will stop at once
after these single pixels are filled, which makes it quick, and is
perfect since created splines and segments are 1-pixel thick anyway.
Only downside is having to run "gegl:distance-transform" a second time,
but this still stays fast.
2018-11-22 14:39:43 +01:00
Jehan 3467acf096 app: replace gegl:watershed-transform with custom algorithm.
We don't really need to flow every line art pixel and this new
implementation is simpler (because we don't actually need over-featured
watershedding), and a lot lot faster, making the line art bucket fill
now very reactive.
For this, I am keeping the computed distance map, as well as local
thickness map around to be used when flooding the line art pixels
(basically I try to flood half the stroke thickness).

Note that there are still some issues with this new implementation as it
doesn't properly flood yet created (i.e. invisible) splines and
segments, and in particular the ones between 2 colored sections. I am
going to fix this next.
2018-11-22 14:24:52 +01:00
Jehan 963eef8207 app: priority map now unneeded for gegl:watershed-transform.
This commit is based on GEGL master as I just made the auxiliary buffer
of gegl:watershed-transform optional for basic cases.
It doesn't necessarily makes the whole operation that much faster
according to my tests, but it makes the code simpler as creating this
priority map was quite unnecessary.
2018-11-20 16:00:01 +01:00
Ell b4e12fbbbb app: add gimp_pickable_contiguous_region_prepare_line_art_async() ...
... and use in bucket-fill tool

Add gimp_pickable_contiguous_region_prepare_line_art_async(), which
computes a line-art asynchronously, and use it in the bucket-fill
tool, instead of having the tool create the async op.

This allows the async to keep running even after the pickable dies,
since we only need the pickable's buffer, and not the pickable
itself.  Previously, we reffed the pickable for the duration of the
async, but we could still segfault when unreffing it, if the
pickable was a drawable, and its parent image had already died.

Furthermore, let the async work on a copy of the pickable's buffer,
rather than the pickable's buffer directly.  This avoids some race
conditions when the pickable is the image (i.e., when "sample
merged" is active), since then we're using image projection's
buffer, which is generally unsafe to use in different threads
concurrently.

Also, s/! has_alpha/has_alpha/ when looking for transparent pixels,
and quit early, at least during this stage, if the async in
canceled.
2018-11-19 15:06:38 -05:00
Ell 62baffed98 app: in gimp-parallel, boost priority of waited-upon asyncs
When an async that was created through
gimp_parallel_run_async[_full](), and whose execution is still
pending, is being waited-upon, maximize its priority so that it
gets executed before all other pending asyncs.

Note that we deliberately don't simply execute the async in the
calling thread in this case, to allow timed-waits to fail (which is
especially important for gimp_wait()).
2018-11-19 15:06:38 -05:00
Ell 965da12b35 app: add GimpAsync::waiting signal
... which is emitted when the async is being waited-upon, blocking
execution.
2018-11-19 15:06:38 -05:00
Jehan 79571231c5 app: end point detection uses both the end point rate and clamped value. 2018-11-19 14:44:26 +01:00
Jehan 047265333c app: better handle drawable and image update for line art computation.
The "update" signal on drawable or projection can actually be emitted
many times for a single painting event. Just add new signals ("painted"
on GimpDrawable and "rendered" on GimpProjection) which are emitted once
for a single update (from user point of view), at the end, after actual
rendering is done (i.e. after the various "update" signals).

Also better support the sample merge vs current drawable paths for
bucket fill.
2018-11-19 14:18:18 +01:00
Jehan 3f58a38574 app: remove now useless erosion size option.
Since commit b00037b850, erosion size is not used anymore, as this step
has been removed, and the end point detection now uses local thickness
of strokes instead.
2018-11-19 14:18:18 +01:00
Jehan b00037b850 app: improve end point detection for smart colorization.
Previous algorithm was relying on strokes of small radius to detect
points of interest. In order to work with various sizes of strokes, we
were computing an approximate median stroke thickness, then using this
median value to erode the binary line art.

Unfortunately this was not working that well for very fat strokes, and
also it was potentially opening holes in the line art. These holes were
usually filled back later during the spline and segment creations. Yet
it could not be totally assured, and we had some experience where color
filling would leak out of line art zones without any holes from the
start (which is the opposite of where this new feature is supposed to
go)!

This updated code computes instead some radius estimate for every border
point of strokes, and the detection of end points uses this information
of local thickness. Using local approximation is obviously much more
accurate than a single thickness approximation for the whole drawing,
while not making the processing slower (in particular since we got rid
of the quite expensive erosion step).
This fixes the aforementionned issues (i.e. work better with fat strokes
and do not create invisible holes in closed lines), and also is not
subject to the problem of mistakenly increasing median radius when you
color fill in sample merge mode (i.e. using also the color data in the
input)!
Also it is algorithmically less intensive, which is obviously very good.

This new version of the algorithm is a reimplementation in GIMP of new
code by Sébastien Fourey and David Tschumperlé, as a result of our many
discussions and tests with the previous algorithm.

Note that we had various tests, experiments and propositions to try and
improve these issues. Skeletonization was evoked, but would have been
most likely much slower. Simpler erosion based solely on local radius
was also a possibility but it may have created too much noise (skeleton
barbs), with high curvature, hence may have created too many new
artificial endpoints.
This new version also creates more endpoints though (and does not seem
to lose any previously detected endpoints), which may be a bit annoying
yet acceptable with the new bucket fill stroking interaction. In any
case, on simple examples, it seems to do the job quite well.
2018-11-16 20:39:04 +01:00
Jehan 255f2e1cdf app: fix uninitialized variables. 2018-11-15 14:05:28 +01:00
Ell 05a4437d9a app: more gimp-parallel fixes
Fix indentation in gimp-parallel.{cc,h}.

Remove unused typedefs in gimp-parallel.h.

s/Gimp/Gegl/ in function-type cast in gimphistogram.c.
2018-11-14 11:01:43 -05:00
Ell 115fc174f2 app: indentation fix in gimp-parallel.cc 2018-11-14 10:54:39 -05:00
Ell 2736cee577 app: remove gimp_parallel_distribute(); use gegl_parallel_distribute()
The parallel_distribute() family of functions has been migrated to
GEGL.  Remove the gimp_parallel_distribute() functions from
gimp-parallel, and replace all uses of these functions with the
corresponding gegl_parallel_distrubte() functions.
2018-11-14 10:52:06 -05:00
Jehan 824af12438 app: edit the bucket fill tool options with new line art options.
I have not added all the options for this new tool yet, but this sets
the base. I also added a bit of TODO for several places where we need to
make it settable, in particular the fuzzy select tool, but also simply
PDB calls (this will need to be a PDB context settings.

Maybe also I will want to make some LineArtOptions struct in order not
to have infinite list of parameters to functions. And at some point, it
may also be worth splitting a bit process with other type of
selection/fill (since they barely share any settings anyway).

Finally I take the opportunity to document a little more the parameters
to gimp_lineart_close(), which can still be improved later (I should
have documented these straight away when I re-implemented this all from
G'Mic code, as I am a bit fuzzy on some details now and will need to
re-understand code).
2018-11-14 13:37:42 +01:00
Jehan e1c4050617 app: bucket fill tool with a "paint-style" interaction.
Rather than just having a click interaction, let's allow to "paint" with
the bucket fill. This is very useful for the new "line art" colorization
since it tends to over-segment the drawing. Therefore being able to
stroke through the canvas (rather than click, up, move, click, etc.)
makes the process much simpler. This is also faster since we don't have
to recompute the line art while a filling is in-progress.
Note that this new behavior is not only for the line art mode, but also
any other fill criterion, for which it can also be useful.

Last change of behavior as a side effect: it is possible to cancel the
tool changes the usual GIMP way (for instance by right clicking when
releasing the mouse button).
2018-11-14 13:37:42 +01:00
Jehan f246f40494 app: compute line art in advance.
Right now, this is mostly meaningless as it is still done sequentially.
But I am mostly preparing the field to pre-compute the line art as
background thread.
2018-11-14 13:37:42 +01:00
Jehan 93a49951a0 app: fix line art labellization.
The older labelling based off CImg code was broken (probably because of
me, from my port). Anyway I realized what it was trying to do was too
generic, which is why we had to fix the result later (labeling all
non-stroke pixels as 0, etc.). Instead I just implemented a simpler
labelling and only look for stroke regions. It still over-label a bit
the painting but a lot less, and is much faster.
2018-11-14 13:37:42 +01:00
Jehan c4ff81540d app: better use GeglBufferIterator!
I don't actually need to loop through borders first. This is what the
abyss policy is for, and I can simply check the iterator position to
verify I am within buffer boundaries or not.
This simplifies the code a lot.
2018-11-14 13:37:42 +01:00
Jehan f02993fb9c app: directly update the mask buffer with gegl_node_blit_buffer().
No need to create a temporary buffer for this.
2018-11-14 13:37:42 +01:00
Jehan 410c747509 app: create a simple priority map for line art selection flooding.
We actually don't need to compute distance map. I just make the simplest
priority map, with 1 any line art pixel and 0 any other pixel (in mask
or not), lowest priority being propagated first.
And let the flooding begin!
2018-11-14 13:37:42 +01:00
Jehan e905ea7ba2 app: with recent gegl:watershed-transform, no need for intermediate...
... labels buffer.
We can watershed directly the mask buffer being correctly flagged.
This commit relies on merge request gegl!8 being accepted and merged.
2018-11-14 13:37:42 +01:00
Jehan 0c80f8a718 app: use char array for temporary data (rather than a GEGL buffer).
Also use more GeglBufferIterator on input GEGL buffer.
Using a char array is much less expensive and accelerated the line
erosion a lot!
Moving to GeglBufferIterator is not finished, but I do in steps.
2018-11-14 13:37:42 +01:00
Jehan f975f15ec0 app: use simpler allocated variables.
Allocating double-level arrays is just very inefficient.
2018-11-14 13:37:42 +01:00
Jehan f19181dcf8 app: make visited into single-level allocated array. 2018-11-14 13:37:42 +01:00
Jehan 910d7934f5 app: fix stroke labels in gimp_lineart_estimate_stroke_width().
I must make sure that stroke pixels are labelled 0 and non-stroke other
than 0.
2018-11-14 13:37:42 +01:00
Jehan 1822ea399a app: use more GeglBufferIterator.
In this case, it makes the code a bit more messy, but hopefully more
efficient.
2018-11-14 13:37:42 +01:00
Jehan 041a8f1eec app: use GeglBufferIterator rather than gegl_buffer_sample|set(). 2018-11-14 13:37:42 +01:00
Jehan fcd038eb16 app: babl types returned by choose_format() must be float! 2018-11-14 13:37:42 +01:00
Jehan 8502b4e743 app: implement second step for line art selection/filling.
When filling colors in line arts, you don't want to leave space between
the strokes and the color, which usually happen with any of the current
selection methods.
A "KISS" trick is usually to grow your selection a few pixels before
filling (adding an additional step in colorization process), which
obviously does not handle all cases (depending on drawing style and
stroke size, you may need to grow more or less) as it doesn't take into
account actual stroke geometry.

Instead, I label the selection and the "rest" differently and leave the
pixel strokes unlabelled. Then I let these unlabelled pixels be flooded
by the "gegl:watershed-transform" operation.
Note that this second step is different from the second step from the
GREYC research paper, as they use their own watershed algorithm taking
color spots as sources to color the whole image at once. This is a
different workflow from the one using bucket fill with a single color
source.
2018-11-14 13:37:42 +01:00
Jehan 8ed12b1b98 app, libgimpbase: add GIMP_SELECT_CRITERION_LINE_ART selection type.
This commit implements part of the research paper "A Fast and Efficient
Semi-guided Algorithm for Flat Coloring Line-arts" from the GREYC (the
people from G'Mic). It is meant to select regions from drawn sketchs in
a "smart" way, in particular it tries to close non-perfectly closed
regions, which is a common headache for digital painters and colorists.

The implementation is not finished as it needs some watersheding as well
so that the selected area does not leave "holes" near stroke borders.
The research paper proposes a new watersheding algorithm, but I may not
have to implement it, as it is more focused on automatic colorization
with prepared spots (instead of bucket fill-type interaction).

This will be used in particular with the fuzzy select and bucket fill
tools.

Note that this first version is a bit slow once we get to big images,
but I hope to be able to optimize this.
Also no options from the algorithm are made available in the GUI yet.
2018-11-14 13:37:42 +01:00
Ell 45fc30caa7 Issue #2473 - Transforming a layer doesn't properly transform its mask
In gimp_drawable_transform_buffer_affine(), avoid modifying the
clipping mode when transforming layer masks, since this function is
used (among other things) to transform layer masks together with
their layer, in which case they should use the same clipping mode
as the layer.

This fixes a regression introduced by commit
2ae823ba2b, causing layer masks to be
transformed with a mismatched clipping mode during layer
transforms, leading to discrepencies between the transformed layer
and the transformed mask.

This commit merely reverts the necessary part of above commit,
fixing the regression, though note that this code is really up for
some serious refactoring: the logic for determining which clipping
mode to use when is spread all over the place.
2018-11-11 02:26:29 -05:00
Ell a29d040db5 app: a few improvements to the GimpBacktrace Linux backend
Blacklist the "threaded-ml" thread, which seems to mask the
backtrace signal.

Improve signal-handler synchronozation, to avoid segfaulting when
giving up on waiting for all threads to handle the signal.
Furthermore, when one or more threads fail to handle the signal in
time, return a GimpBacktrace instance with backtraces for all the
other threads, and with empty backtraces for all the non-responding
threads, instead of returning NULL and leaking the allocated
instance.  Don't blacklist threads that failed to handle the signal
in time, and instead shorten the wait period for handling the
signal, and yield execution during waiting to lower the CPU usage.
2018-11-07 14:26:17 -05:00
Ell 56920dcdbf app: don't let image component mask affect channel colors
Connect GimpImage's gimp:mask-components node to the layers node
*before* connecting the channels node, so that the image's
component mask doesn't affect the channel colors, as is the case in
2.8.
2018-11-04 13:23:56 -05:00
Ell c271992aa0 Issue #2405 - Rotation center shifts by half a pixel ...
... the second time you do a 180 degrees rotation

In gimp_transform_resize_adjust(), nudge the transformed layer
boundary by EPSILON toward the center, to avoid enlarging the layer
unnecessarily, as a result of numeric error amplified by rounding,
when the tranformed boundary should land on integer coordinates.
In particular, this avoids enlarging the layer when rotating by 180
degrees.
2018-10-27 00:14:47 -04:00
Michael Natterer ae9d84dd22 Issue #2235 - Color reset/swap keyboard shortcuts not discoverable...
...via hover tooltips

Use the GtkWidget::query_tooltip() signal on GimpFgBgEditor to emit an
own signal "tooltip" that has the hovered widget area as parameter.

Connect to GimpFgBgEditor::tooltip() in gimptoolbox-color-area.c and
set separate tooltips on the widget's areas, including the shortcuts
for "Swap colors" and "Default colors".
2018-10-25 14:45:55 +02:00
Elle Stone 298cc57042 Issue #2345 - Add xyY to color sample readouts
Add xyY color space to the color spaces for sampling colors.

Also add code to xcf-load.c that makes sure the sample point loading
code handles unknown future GimpColorPickMode values (fall back to
PIXEL pick mode).
2018-10-23 17:37:28 +02:00
Michael Natterer 38dcb73bfc Issue #2386 - Pattern fill with selection is shifted in 2.10
Add pattern offset parameters to gimp_fill_options_create_buffer() and
pass the selection's top-left corner so that pattern fills on the same
drawable are aligned.
2018-10-22 16:39:19 +02:00
Ell 72fc01742b app: always use libunwind for symbol names in GimpBacktrace Linux backend
In the GimpBacktrace Linux backend, always use libunwind, when
available, to find symbol names, even if dladdr() or libbacktrace
had already found one.  libunwind provides more descriptive names
in certain cases, and, in particular, full symbol names for C++
lambdas.

Note that, in some cases, this can result in a discrepancy between
the reported symbol name, and the corresponding source location.
2018-10-11 03:35:26 -04:00
Ell 52772cf3ff app: in GimpBacktrace Windows backend, avoid bogus symbol addresses
In the GimpBacktrace Windows backend, avoid reporting meaningless
symbol addresses when failing to retrieve meaningful ones.
Unfortunately, it seems that we never get symbol addresses for
symbols that have debug information, which negatively affects the
log viewer's call graph.  We're going to have to work around this.
2018-10-10 10:00:45 -04:00
Ell 52908f397f app: in GimpBacktrace Windows backend, set main-thread name
When initializing the GimpBacktrace Windows backend, set the name
of the current thread (which is assumed to be the main thread) to
the program's name, to match its name on Linux.  We normally rely
on the SET_THREAD_NAME exception to set thread names on Windows,
which isn't raised for the main thread.
2018-10-10 10:00:45 -04:00
Ell ca6e4eb460 app: improve description comment of GimpAsync 2018-10-10 01:03:42 -04:00
Ell 4969d75785 app: allow progressive execution of parallel async operations
In the gimp_parallel_run_async() family of functions, allow the
async callback to return without completing the async operation, in
which case the callback will be called again, until the operation
is either completed, or canceled, in which case it is aborted
(previously, returning from the callback without completing the
operation would cause it to be aborted.)  It is guaranteed that all
operations of the same priority will get a chance to run, even if
some of them contuinuosly return without completing.

This allows potentially time-consuming operations to yield
execution in favor of other same-priority operations, and, in
particular, of higher-priority operations, to avoid priority
inversion.  Essentially, this allows a simple form of cooperative
multitasking among async operations.
2018-10-09 12:49:38 -04:00
Michael Natterer c399b894a8 app: remove the image's "Enable Color Management" toggle
It was not doing anything right since space invasion. We now treat the
built-in sRGB profile like any other profile and never bypass
conversions based on some weird toggle.

Instead, introduce a "Use sRGB Profile" toggle which, when enabled,
hides whatever profile away so the image actually uses the built-in
sRGB profile.

This is different from discarding and then re-assigning the same
profile only by being faster and more convenient.
2018-10-07 16:16:21 +02:00
Ell 84066ca26a app: use "step" blending function in "FG to BG (Hardedge)" gradient
Use a single segment with a "step" blending function, added in the
previous commit, instead of two separate segments, for the "FG to
BG (Hardedge)" internal gradient.  This makes it simpler to change
its endpoint colors by modifying the gradient, instead of changing
the FG/BG colors.
2018-10-02 21:53:59 -04:00
Ell 68bf99e806 Issue #2303 - Please add Constant type of gradient interpolation ...
... to make multi-color hard-edge gradient fills possible

Add a new "step" gradient-segment blending function, which is 0
before the midpoint, and 1 at, and after, the midpoint.  This
creates a hard-edge transition between the two adjacent color stops
at the midpoint.  Creating such a transition was already possible,
but required duplicating the same color at the opposing ends of two
adjacent stops, which is cumbersome.
2018-10-02 21:53:50 -04:00
Ell e46fdc714e app: in gimp-parallel, cancel ongoing async operations upon exit
When shutting-down gimp-parallel, cancel and/or abort any ongoing
and queued async operations, instead of finishing them (async
operations that already started executing will be canceled, but
execution will be blocked until they're finished.)  This is
especially important since we're shutting down gimp-parallel before
the destruction of data factories.  This commit causes any ongoing
async operations of the factories to be canceled on shutdown,
rather than waiting for them to finish normally.
2018-10-01 05:24:45 -04:00
Ell 6bc0b3b8ad app: add gimp_data_factory_data_cancel()
Add a new GimpData::data_cancel() virtual function, and a
corresponding gimp_data_factory_data_cancel() function.  This
function should cancel any ongoing async operations related to the
factory (i.e., included in its async set), and wait for the
operations to finish.  Provide a default implementation that simply
cancels and waits on the factory's async set.

Use this function to cancel any ongoing operations during factory
destruction, and in gimp_data_factory_data_free().

Override this function in GimpFontFactory, for which we can't
really cancel font loading, and simply cancel and clear the
factory's async set without waiting for loading to finish, making
sure that nothing happens (and, in particular, that the factory
isn't being accessed, since it might be already dead) when loading
does finish.
2018-10-01 05:24:45 -04:00
Ell 50bab438ce app: don't depend on GimpData sort order for identifying internal data
In gimp_data_factory_data_foreach(), don't rely on internal
GimpData objects being sorted first (while this is currently true
for all types of GimpData, they may override the sort order.)
2018-10-01 05:24:45 -04:00
Ell ae3c006293 app: avoid applying buffer to drawable if application region is empty
In gimp_drawable_real_{apply,replace}_buffer(), bail if the
applcation region, after intersection with the drawable and mask
extents, is empty.  This avoids trying to create a GeglBuffer with
negative width/height.
2018-09-29 10:27:20 -04:00
Ell a782acab57 Issue #2287 - Weird things happen with dodge tool ...
... (some sort of corruption)

In gimp_drawable_real_replace_buffer(), adjust the processed buffer
and mask_buffer regions according to the changes made to the
application region, as calculated by intersecting it with the
drawable and mask extents.  This fixes wrong application position
when painting using the heal, dodge/burn, smudge, or convolve
tools, on a drawable whose origin is above/to the left of the
image's origin, and there's a selection active.
2018-09-29 10:27:20 -04:00
Ell ae628a8664 Issue #2222 - Warp Transform doesn't commit changes upon saving ...
... the XCF file

Add a "saving" signal to GimpImage, which is emitted when the image
is about to be saved or exported (but before it's actually saved/
exported).  Connect to this signal in tool-manager, and commit the
current tool in response (unless its GimpToolControl::preserve is
TRUE).
2018-09-29 02:39:23 -04:00
Ell 2ae823ba2b app: add gimp_drawable_transform_get_effective_clip()
Which returns the actual clip mode that will be used by the
drawable for a particular transformation.
2018-09-23 12:58:45 -04:00
Ell 2c52bba071 app: indentation fix in gimpdrawable-transform.[ch] 2018-09-23 12:58:45 -04:00
Ell 7cdd1ebeef app: add source location information to the Linux GimpBacktrace backend
When libbacktrace is available, use it to retrieve source location
information in the Linux GimpBacktrace backend.
2018-09-22 22:39:08 -04:00
Ell a1b08a503d Revert "app: disable parallel asynchronous operations when GEGL_THREADS=1"
This reverts commit 408540659f, which
is no longer necessary after GEGL commit
c8a0b9eff07c8d9122f55f7b7527d51788ae4575.
2018-09-20 08:09:30 -04:00
Ell 3b0040c043 app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()

g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58.  Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.

This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.

Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-18 14:39:56 -04:00
Ell e8c1cd79ba app: in gimpbacktrace-linux, use SA_RESTART for the backtrace signal 2018-09-16 09:00:03 -04:00
Jehan 0fa2ef9118 app: add a reason string for internal zlib compression in GIMP 2.10.
Even though chosen as a parameter to gimp_image_get_xcf_version() and
not a feature within the image itself, we also want to list this reason
in the compatibility list.
2018-09-11 11:26:51 +02:00
Jehan ea67537d85 app: conditionnally free new profile in gimp_image_convert_precision().
Do not free a NULL pointer! This fixes a CRITICAL:
> g_object_unref: assertion 'G_IS_OBJECT (object)' failed
2018-09-11 11:26:51 +02:00
Øyvind Kolås d99cae4ab8 app: gimpscanconvert: migrate to new buffer iterator 2018-09-11 00:19:39 +02:00
Øyvind Kolås c56f543354 app: pickable-contiguous-region migrated to new buffer iterator 2018-09-11 00:19:21 +02:00
Øyvind Kolås 43c107aeab app: palette-import migrated to new buffer iterator 2018-09-11 00:18:57 +02:00
Øyvind Kolås 9f481d3607 app: image-convert-indexed migrated to new buffer iterator 2018-09-11 00:18:36 +02:00
Øyvind Kolås 2c2d8d86fd app: histogram migrated to new buffer iterator 2018-09-11 00:17:24 +02:00
Øyvind Kolås 972f232316 app: gimpdrawable-transform migrated to new buffer iterator 2018-09-11 00:17:09 +02:00
ONO Yoshio 1ff9487d00 Revert "app: make unattached vectors enable to rotate."
This reverts commit 2d415f53bf.
2018-09-06 08:39:51 +09:00
Ell b9f1ab8f53 app: more cleanup in GimpBacktrace
Improve out-of-range check in gimp_backtrace_find_thread_by_id().

Remove unnecessary #include <exchndl.h> in gimpbacktrace-windows.c,
and revert commit 644234e99d (the
DrMingw detection happens at runtime).  The Windows backend can
work without DrMingw, it just can't find all the symbols, and
doesn't provide source-location information.
2018-09-05 14:57:23 -04:00
Jehan 644234e99d app: GimpBacktrace Windows backend only available with Dr. Mingw.
(cherry picked from commit e7dde73f84)
2018-09-05 15:16:32 +02:00
Ell 78adb7c900 app, tools: add "running" thread attribute to GimpBacktrace/performance-log
The "running" attribute (readable through
gimp_backtrace_is_thread_running(), and recorded in the performance
log) specifies if the thread was in a running or suspended state at
the time the backtrace was taken.  It is accurate on Linux, but
only approximated on Windows.

Adapt the performance-log-expand.py tool to maintain this attribute
(and any future thread attributes we might add).
2018-09-03 18:30:10 -04:00
Ell 667efc221d app: add Windows backend to GimpBacktrace
The Windows backend produces full, multithreaded backtraces.  When
DrMingw is available, it also provides full symbol and (where
available) source-location information.  Otherwise, it provides
symbol information for most of our libraries, but not for the GIMP
binary itself.
2018-09-03 15:57:53 -04:00
Ell a6ec857123 app: add source-location information to GimpBacktrace
Add source filename and line number fields to the
GimpBacktraceAddressInfo struct, populated through
gimp_backtrace_get_address_info().  This is not currently supported
by the Linux backend, but is supported by the Windows backend,
which we'll be added in the next commit.
2018-09-03 15:57:53 -04:00
Ell 422f6a55e4 app: more GimpBacktrace tidying
... in preparation for the Windows backend.
2018-09-03 15:57:53 -04:00
ONO Yoshio 2d415f53bf app: make unattached vectors enable to rotate. 2018-09-03 12:19:59 +09:00
Ell c4d89bfe0b app: remove unused #define in gimpbacktrace-linux.c 2018-09-02 14:32:55 -04:00
Ell 7ac87dc01e app: rename gimp_backtrace_get_symbol_info() to ..._get_address_info()
This function returns information about the given address, which
is currently mostly limited to the corresponding symbol
information, but we might want to add address-specific information
in the future, such as a line number.
2018-09-02 13:25:53 -04:00
Ell 77746fd8fc app: in gimpbacktrace-none.c, fix gimp_backtrace_get_frame_address() 2018-09-02 13:25:53 -04:00
Ell 0d3647f854 app: remove stray g_printerr() from gimpbacktrace-linux.c 2018-09-02 09:13:26 -04:00
Ell cb8dd047d0 app: minor cleanup in GimpBacktrace 2018-09-02 09:08:21 -04:00
Ell 80bf686c94 app: add GimpBacktrace
GimpBacktrace provides an interface for creating and traversing
multi-threaded backtraces, as well as querying symbol information.
While we already have some backtrace functionality, it relies on
external tools for the most part, and as such is rather expensive,
and is only meant for producing opaque backtraces.  GimpBacktrace,
on the other hand, is meant to be relatively cheap (we're going to
use it for profiling,) and allow inspection of the backtrace data.
In the future, it might make sense to replace some, or all, of the
other backtrace functions with GimpBacktrace.

GimpBacktrace currently only supports Linux.  By default, it uses
dladdr() to query symbol information, which is somewhat limited (in
particular, it doesn't work for static functions.)  When libunwind
is installed, GimpBacktrace uses it to get more complete symbol
information.  libunwind is currently an optional dependency, but it
might make sense to promote it to a mandatory, or opt-out,
dependency, as it's lightweight and widely available.

On other platforms, the GimpBacktrace interface can still be used,
but it always returns NULL backtraces.
2018-09-02 02:54:43 -04:00
Ell e563845174 Issue #2095 - Filter wavelet-decompose error with layer Group option active
In gimp_image_merge_layers(), explicitly fetch the graph of the top
layer's parent layer (if exists), to make sure that the top layer's
graph has a parent node.  We already fetch the image graph, which
takes care of top-level layers, however, if the top layer is a
child of an invisible layer group, as is the case in the wavelet-
decompose plug-in, this is not generally enough to guarantee that
the group's graph is constructed.
2018-08-25 04:08:59 -04:00
Ell a1706bbd29 app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS).  In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow.  We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.

Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate.  With this commit, we aim to
find a good compromise dynamically, rather than statically.

The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
2018-08-20 11:13:53 -04:00
Ell 105ffc787d app: don't chunk update area when rendering projection synchronously
Add a boolean "chunk" parameter to
gimp_projection_chunk_render_iteration(), which determines whether
the work area should be sub-divided into chunks prior to rendering
(previously, the work area would always be sub-divided.)  Only
pass TRUE when rendering the projection asynchronously, in the
render callback, and pass FALSE when rendering the projection
synchronously, in gimp_projection_finish_draw(), which is called
when flushing the projection through the GimpPickable interface.

Rendering the projection using as big chunks as possible improves
performance, while worsening responsiveness.  Since responsiveness
doesn't matter when rendering synchronously, there's no reason to
render in chunks.
2018-08-20 11:13:05 -04:00
Jehan 8e453330c9 configure: GLIB_COMPILE_RESOURCES is wrong when cross-compiling.
AM_PATH_GLIB_2_0 m4 macro actually computes this value using
$PKG_CONFIG. Yet $PKG_CONFIG variable is the pkg-config tool looking for
target libraries (not host), hence it would return the executable
`glib-compile-resources` built for the target.

Also using the same variable name invalidates our test: our own
AC_PATH_PROG was never run as the variable was already set. And no
environment variable could override this test anymore either. This is
why I rename the test variable to HOST_GLIB_COMPILE_RESOURCES.

(cherry picked from commit d1d9eb17e5)
2018-08-12 22:52:45 +02:00
Ell fc2c640ca2 app: fix group layer drawable update during size change
In gimp_group_layer_update_size(), never suspend drawable updates
(and, in fact, remove the option to suspend drawable updates
entirely,) and instead never update the drawable during the call to
gimp_drawable_set_buffer_full(), and flush the group's projection
*after* setting the drawable's buffer, so that any pending updates
will happen after the group's buffer and size are up-to-date.

This fixes some missed drawable updates.
2018-08-10 03:21:08 -04:00
Ell 2d63bc6e0a app: fix projection update-area offset upon buffer allocation/reisizing
In GimpProjection, change gimp_projection_add_update_area() to take
coordinates in the projection's coordinate system, rather than the
image coordinate system, and move the offset adjustment to the
projectable invalidation handler.

Modify gimp_projection_projectable_structure_changed() to pass
projection-space coordinates to gimp_projection_add_update_area().

gimp_projection_get_buffer() and
gimp_projection_projectable_bounds_changed() already pass
projection-space coordinates to gimp_projection_add_update_area(),
which was wrong before, when the projection had a nontrivial
offset, but is correct now.
2018-08-10 03:21:08 -04:00
Michael Natterer 6938d11716 Issue #1997 - Colors not properly converted to image's color space
Add a Babl space parameter to gimp_gegl_color_new() and all utility
functions using it. Pass NULL if the GimpRGB actually is sRGB, pass
the image's layer space if the color was already converted using
gimp_pickable_srgb_to_image_color() or similar.
2018-08-09 20:04:44 +02:00
Michael Natterer 753523c4d1 Issue #1953 - Crashes during color profile conversion
gimp_image_convert_color_profile(): need to ref the src_profile across
the conversion because gimp_image_set_color_profile() might unref it.
2018-08-09 18:53:13 +02:00
Jehan 549d880847 app: display extension long description in the details widget.
AppStream spec says it can only contain <p>, <ol> and <ul> markups.
Unfortunately these are not pango markups (nor is there any equivalent).
So I just use newlines and spaces until I figure out anything fancier.

That's all still quite ugly, but whatever, I'm still in the start.
2018-08-07 18:22:47 +02:00
Jehan a4e0a8f96e app: extensions can now install themes. 2018-08-07 15:51:54 +02:00
Jehan 7d611e713c app: extensions can now install splashes.
Not the most useful type of extensions per-se, but a lot of people seem
to appreciate creating and installing new splashes. Let's make it easy
to install as extensions.
Note that extension splashes are cumulative. So if you enabled several
splash extensions at once, an image would be chosen in random amongst
all of them.
2018-08-07 15:51:54 +02:00
Jehan b3add5109c app: fix small leak.
Return values of gimp_config_build_*_path() must be properly freed.
2018-08-06 16:51:39 +02:00
Michael Natterer a2fe90aa54 Issue #1980 - Color picker wrong results when picking from non-sRGB...
...image using "Sample Average"

In GimpPickable, create the "RaGaBaA double" format used for averaging
with the space of the source pixels.
2018-08-06 12:39:36 +02:00
Michael Natterer 8226265b12 Issue #1954 - GIMP-2.99 color changes when converting between...
...linear and perceptual precision

Under certain circumstances (e.g. the image has no color profile),
GimpLayer's implementation of GimpDrawable::convert_type() didn't have
enough information to do the right color space conversion.

Intead of messing with stuff like "set profile in between doing a and b",
simply add a "src_profile" parameter to GimpDrawable::convert_type() so
the complete color space conversion information is available without
relying on obscure states that could change in the future.

Make sure all callers pass the right src_profile, particularly in
gimp_image_convert_precision(), which also needed fixing.
2018-08-05 22:28:56 +02:00
Jehan 2912fe7c17 Issue #1974: Memory leak in gimpimage.c.
Ok my previous fix was wrong (at least for the part in the macro). This
is a macro, not a function. So each time we write _reason, the call to
g_strdup_printf() is reevaluated, hence data is allocated.
The right fix is to prepend `tmp` to the list, not `_reason`.
Thanks to Massimo for the debugging, as always!
2018-08-04 12:57:03 +02:00
Jehan 0ab682b0f5 Issue #1974: Memory leak in gimpimage.c.
ADD_REASON macro was leaking the allocated string when version_reason
return value was NULL (i.e. when we didn't care about the version
reasons).

Also we were not properly freeing all the reason strings at the end,
only the list. Use g_list_free_full() instead of g_list_free().
2018-08-04 09:34:05 +02:00
Ell c6b8a4213c app: short-circuit GimpProjection bounds-changed handler if disjoint
In gimp_projection_projectable_bounds_changed(), bail early by
calling gimp_projection_projectable_structure_changed() instead, if
the new bounds don't intersect the old bounds.
2018-08-03 22:04:10 -04:00
Ell bb5e3fd926 app: fix gimp_projection_projectable_bounds_changed()
In gimp_projection_projectable_bounds_changed(), which is called by
GimpProjection in response to a GimpProjectable::bounds-changed
signal, invalidate all regions of the new projection that weren't
copied from the old projection, so that they get rendered upon
flushing, instead of remaining empty.

Additionally, fix preview invalidation -- in particular, don't
directly invalidate the projectable's preview, even if preview
invalidation is already queued and chunk rendering was finished by
the boundary change, and instead always queue a preview
invalidation.
2018-08-03 22:04:10 -04:00
Ell bd726c96bf app: avoid re-rendering group layers upon resizing
Make sure we don't unnecessarily update the group layer's drawable
while flusing the group's projection during resizing, since we want
to either update the entire drawable, or avoid any updates, when
replacing the drawable's buffer.  Note that explicitly supressing
updates in this case should theoretically not be necessary, but the
fact that the call to gimp_projectable_bounds_changed() can result
in reconstructing the projection (see the FIXME comment in that
function) makes it necessary in some cases nonetheless.
2018-08-03 14:09:26 -04:00
Ell 3ff820a00a app: avoid re-rendering group layers upon translation
When translating group layers, there's no need to re-render the
group's projection -- we can simply update the group's offset (and
offset node) directly, and redirect any layer-stack "update"
signals to the group's drawable.  This significantly improves
performance when moving groups.
2018-08-03 13:50:13 -04:00
Ell 1bb3e962f6 app: use gimp_projectable_bounds_changed() when resizing group layers
In GimpGroupLayer, use gimp_projectable_bounds_changed() when
updating the group layer's size, instead of reconstructing the
projection, unless reallocation of the projection has been
requested.  This is more efficient, since it simply copies the
content of the projection's old buffer to the new buffer, rather
than re-rendering the graph.
2018-08-03 13:50:13 -04:00
Ell a4957c7c76 app: stop idle projection rendering when flushing group layers
In gimp_group_layer_flush(), stop any idle rendering, initiated
when a new buffer is allocated, before flushing the group's
pickable.  Otherwise, the idle rendering is finished synchronously,
which unnecessarily introduces a noticeable lag.
2018-08-03 13:50:13 -04:00
Ell 26a8d141f6 app: add "update" parameter to gimp_drawable_set_buffer_full()
... which specifies whether or not to update the drawable in
response to the buffer change.

Pass TRUE for "update" at all existing call sites, to keep the
current behavior.
2018-08-03 13:50:13 -04:00
Ell fbeae36118 app: respond to GimpProjectable::bounds-changed in GimpProjection
In GimpProjection, respond to the projectable's "bounds-changed"
signal, by reallocating the buffer, and copying the corresponding
region of the old buffer (using
gimp_tile_handler_validate_buffer_copy(), added a few commits back,
so that the relevant portion of the validate handler's dirty region
is also copied).  Additionally, shift and clip all outstanding
update regions as necessary (actually, we avoid copying the buffer
when a shift is necessary, and simply reconstruct the projection;
see FIXME comment in the code.)
2018-08-03 13:50:13 -04:00
Ell 460c3d1349 app: add GimpProjectable::bounds-changed signal
... and a corresponding gimp_projectable_bounds_changed() function.

This signal can be emitted by implementers of GimpProjectable,
instead of the GimpProjectable::structure-changed signal, when the
projectable's bounds change, but its content does not -- i.e., the
old content simply gets cropped to the new bounds.
2018-08-03 13:50:13 -04:00
Ell 12530e21b2 app: add gimp_tile_handler_validate_unassign()
... which should be used to properly remove a
GimpTileHandlerValidate from a buffer, instead of using
gegl_buffer_remove_handler() directly.

Use gimp_tile_handler_validate_unassign(), instead of
gegl_buffer_remove_handler(), in gimp_projection_free_buffer().
2018-08-03 13:50:13 -04:00
Ell a826a19359 Issue #1884 - Incorrect font when export to png
In gimp_layer_convert(), avoid converting the drawable type when
the source and destination color profiles are equal, if otherwise
unnecessary.  Otherwise, text layers get unnecessarily re-rendered
during conversion, and, by extension, during image duplication
(which happens when exporting to any format that requires merging
down the image).  This may cause the text layer to appear
differently in the duplicated image, or even use a different font
if the original font doesn't exist.
2018-08-01 05:06:13 -04:00
Ell f38443f3b0 app: copy the is-color-managed status when duplicating an image
When duplicating an image, copy the source image's is-color-managed
status to the duplicated image, instead of having the duplicated
image always be color managed.  In particular, do this before
duplicating the layers, so that we don't convert the duplicated
layers from sRGB to the image's profile when duplicating an image
with a non-sRGB profile but with color management turned off.
2018-08-01 05:06:13 -04:00
luz.paz 949912f5d6 Misc. typos
Found via `codespell  -q 3 -I ../gimp-word-whitelist.txt --skip="*.po"`
2018-07-31 06:58:48 -04:00
Jehan 1e5cf10585 icons, app, libgimpwidgets: use Freedesktop standard icons.
Some icons were still using old gimp-namespaced names.
2018-07-28 12:27:10 +02:00
Ell a5102a7dba */Makefile.am: add *marshal.h files to BUILT_SOURCES
In subdirs containing a generated foomarshal.h header, add the
generated sources to BUILT_SOURCES, so that they're generated
before the rest of the source files are built.  Otherwise, since
there is no rule specifying the dependency between the rest of the
source files and foomarshal.h, and since foomarshal.h is not
checked into git (and hence doesn't exist when doing a clean
build), compilation of the said source files may fail if they're
built before foomarshal.h is generated.
2018-07-24 14:05:08 -04:00
Michael Natterer 248199e997 app: make replacing a drawable's format use almost no undo memory
Add gimp_drawable_set_format() as low-level part of
gimp_layer_fix_format_space(), and add a special undo type for it that
only remembers the format and not the entire drawable buffer, because
all pixels stay the same.
2018-07-24 12:56:36 +02:00
Michael Natterer e09e563a70 Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.

libgimp:

- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
  as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
  NON_LINEAR and PERCPTUAL for each encoding, matching the babl
  encoding variants RGB, R'G'B' and R~G~B~.

- gimp_color_transform_can_gegl_copy() now returns TRUE if both
  profiles can return a babl space, increasing the amount of fast babl
  color conversions significantly.

- TODO: no solution yet for getting libgimp drawable proxy buffers in
  the right format with space.

plug-ins:

- follow the GimpPrecision change.

- TODO: everything else unchanged and partly broken or sub-optimal,
  like setting a new image's color profile too late.

app:

- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
  replacement for all "linear" booleans.

- change gimp-babl functions to take babl spaces and GimpTRCType
  parameters and support all sorts of new perceptual ~ formats.

- a lot of places changed in the early days of goat invasion didn't
  take advantage of gimp-babl utility functions and constructed
  formats manually. They all needed revisiting and many now use much
  simpler code calling gimp-babl API.

- change gimp_babl_format_get_color_profile() to really extract a
  newly allocated color profile from the format, and add
  gimp_babl_get_builtin_color_profile() which does the same as
  gimp_babl_format_get_color_profile() did before. Visited all callers
  to decide whether they are looking for the format's actual profile,
  or for one of the builtin profiles, simplifying code that only needs
  builtin profiles.

- drawables have a new get_space_api(), get_linear() is now get_trc().

- images now have a "layer space" and an API to get it,
  gimp_image_get_layer_format() returns formats in that space.

- an image's layer space is created from the image's color profile,
  change gimpimage-color-profile to deal with that correctly

- change many babl_format() calls to babl_format_with_space() and take
  the space from passed formats or drawables

- add function gimp_layer_fix_format_space() which replaces the
  layer's buffer with one that has the image's layer format, but
  doesn't change pixel values

- use gimp_layer_fix_format_space() to make sure layers loaded from
  XCF and created by plug-ins have the right space when added to the
  image, because it's impossible to always assign the right space upon
  layer creation

- "assign color profile" and "discard color profile" now require use
  of gimp_layer_fix_format_space() too because the profile is now
  embedded in all formats via the space.  Add
  gimp_image_assign_color_profile() which does all that and call it
  instead of a simple gimp_image_set_color_profile(), also from the
  PDB set-color-profile functions, which are essentially "assign" and
  "discard" calls.

- generally, make sure a new image's color profile is set before
  adding layers to it, gimp_image_set_color_profile() is more than
  before considered know-what-you-are-doing API.

- take special precaution in all places that call
  gimp_drawable_convert_type(), we now must pass a new_profile from
  all callers that convert layers within the same image (such as
  image_convert_type, image_convert_precision), because the layer's
  new space can't be determined from the image's layer format during
  the call.

- change all "linear" properties to "trc", in all config objects like
  for levels and curves, in the histogram, in the widgets. This results
  in some GUI that now has three choices instead of two.
  TODO: we might want to reduce that back to two later.

- keep "linear" boolean properties around as compat if needed for file
  pasring, but always convert the parsed parsed boolean to
  GimpTRCType.

- TODO: the image's "enable color management" switch is currently
  broken, will fix that in another commit.
2018-07-21 16:42:57 +02:00
Jehan d68a68c54d app: add "running" property to extension.
And connect to this property in the extension manager to allow dynamic
reload when starting/stopping an extension. It doesn't work yet for
extensions with plug-ins but works with other kinds of data.
2018-07-18 12:08:57 +02:00
Jehan 4d745743e8 app: functions to manage running extensions.
Add gimp_extension_manager_can_run() and rename function:
s/gimp_extension_manager_is_active/gimp_extension_manager_is_running/

A system extension cannot be run if it has been overrided by a
user-installed extension of same ID. Moreover extensions can have GIMP
version requirements as well as have dependency on other extensions
(though these are not implemented yet).
2018-07-17 19:45:51 +02:00
Jehan 02aec4c3d6 app: serialize and deserialize extensionrc from GimpExtensionManager.
We only save the active state of extensions so that we can reload all
extensions same as they were at previous exit. All other data are saved
as per-extension metadata and should not be saved in the rc file.

If an extension is not listed in extensionrc, we run it by default if
this is a system extension (so that new core extensions by the GIMP team
are run when installed after an updated), but not when they are
user-installed extensions.
2018-07-17 19:45:51 +02:00
Ell 4fefab1798 app: fix line-angle constraint when xres != yres
Fix gimp_constrain_line() and friends to properly constrain line
angles when the image's horizontal and vertical resolutions are
different, and dot-for-dot is disabled.
2018-07-15 19:09:06 -04:00