Commit Graph

5774 Commits

Author SHA1 Message Date
Ell
8f31f8fa3c 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.

(cherry picked from commit 12dde445c4)
2019-02-06 14:30:55 -05:00
Ell
d6bb1efd77 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.

(cherry picked from commit 59ef222c7f)
2019-02-04 16:48:54 -05:00
Ell
bcc44a08b1 app: fix indentation in gimpmaskundo.h
(cherry picked from commit 4db566f0e1)
2019-01-20 10:33:56 -05:00
Ell
8324aeba82 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.

(cherry picked from commit 7cd768f3d8)
2019-01-20 10:07:33 -05:00
Ell
4c22313ce6 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.

(cherry picked from commit ac5e4f4c33)
2019-01-17 15:15:59 -05:00
Ell
858dbf6e18 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.

(cherry picked from commit de4e7b4770)
2019-01-17 14:21:03 -05:00
7700cb3d81 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.

(cherry picked from commit aa04258620)
2019-01-17 15:37:24 +01:00
b35941ec4c Issue #2785: Fill by line art detection produces Segmentation fault...
... with some images.

(cherry picked from commit 036ccc70cf)
2019-01-17 15:37:24 +01:00
Ell
61a6b15a66 app: parallelize gimp_pickable_contiguous_region_by_color()
... by distributing the processed area over multiple threads.

(cherry picked from commit 8571d7812f)
2019-01-17 09:30:51 -05:00
Ell
cfd1d0463f app: convert gimppickable-contiguous-region to C++
(cherry picked from commit 9719dff9c5)
2019-01-17 09:30:50 -05:00
32fdd69324 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).

(cherry picked from commit c71b4916af)
2019-01-15 17:39:17 +01:00
Ell
fe5ee0f7b8 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.

(cherry picked from commit 9833da3431)
2019-01-13 08:23:05 -05:00
4fd8e4841f 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!

(cherry picked from commit 005bc1406b)
2019-01-12 18:03:24 +01:00
Ell
dfc038e650 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.

(cherry picked from commit 42845c9462)
2019-01-12 08:33:24 -05:00
Ell
f21eec319f 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.

(cherry picked from commit 0e5de95760)
2019-01-12 08:20:16 -05:00
Ell
4cbec7608f app: fix gimp_chunk_iterator_set_priority_rect()
(cherry picked from commit 942e1aa939)
2019-01-12 07:32:08 -05:00
Ell
5e00c26295 app: in gimpchunkiterator.c, #include <stdlib.h>
... for qsort().

(cherry picked from commit a61f29e30a)
2019-01-12 06:16:50 -05:00
Ell
b62e3fd3b8 app: use GimpChunkIterator in GimpProjection
Replace the custom chunking logic of GimpProjection with
GimpChunkIterator, added in the previous commit.

(cherry picked from commit 246e782858)
2019-01-12 04:53:11 -05:00
Ell
8c31ed6f02 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.

(cherry picked from commit ba9ce34e10)
2019-01-12 04:53:10 -05:00
e0be9bdef2 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.

(cherry picked from commit 90e9eb3fca)
2019-01-08 13:41:06 +01:00
Ell
0f2f95d97b 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.

(cherry picked from commit 823d4a0d24)
2019-01-06 16:31:11 -05:00
Ell
fbf73bee70 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.

(cherry picked from commit 889e2e26ee)
2019-01-06 07:39:52 -05:00
Ell
8142fe4d1c 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.

(cherry picked from commit d56d663eaa)
2019-01-04 08:17:42 -05:00
a27f7c7724 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

(cherry picked from commit abd7cbfc8d)
2019-01-02 01:53:02 +01:00
d6ca6d510e 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.

(cherry picked from commit 8a4aacb52f)
2019-01-02 00:17:45 +01:00
Ell
e61188e666 app: small fix to gimp_drawable_edit_fill()
(cherry picked from commit 3738ff3ffd)
2018-12-31 05:33:45 -05:00
Ell
5d905d1d65 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.

(cherry picked from commit 6384ff01b6)
2018-12-31 04:40:18 -05:00
Ell
a330a94b94 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.

(cherry picked from commit b846ffed19)
2018-12-30 05:13:30 -05:00
Ell
05f74b6f40 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.

(cherry picked from commit 5c27d14fdf)
2018-12-30 05:13:29 -05:00
Ell
81bef8cd50 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.

(cherry picked from commit 7534ae53d6)
2018-12-30 05:13:29 -05:00
Ell
bb039c8401 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.

(cherry picked from commit b201f73562)
2018-12-29 14:28:51 -05:00
Ell
b4c1c94db0 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.

(cherry picked from commit ab52dc6bca)
2018-12-29 14:28:50 -05:00
Ell
c650c51cbc 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.

(cherry picked from commit cba4bc4781)
2018-12-28 08:31:05 -05:00
Ell
96a16b8db7 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.

(cherry picked from commit 95393722cc)
2018-12-28 03:57:35 -05:00
Ell
8415bc7d94 app: cache result of floating selections
Use an output cache for floating-selection filters, to speed up
anchoring.

(cherry picked from commit 3f45e893bf)
2018-12-28 03:56:54 -05:00
Ell
20d6db79c2 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.

(cherry picked from commit 0560c5a6fe)
2018-12-28 03:56:54 -05:00
Ell
37b0832c2d 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.

(cherry picked from commit 8e57ee2265)
2018-12-28 03:56:53 -05:00
Ell
7c1d5b7a3e app: add GimpDrawable::format-changed signal
... which is emitted when the drawable's format is changed.

(cherry picked from commit 85e454bae8)
2018-12-28 03:56:52 -05:00
Ell
13c6fe5db6 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.

(cherry picked from commit ef9b1f6694)
2018-12-27 17:14:34 -05:00
Ell
23ae869f21 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.

(cherry picked from commit ed7ea51fb7)
2018-12-27 11:45:11 -05:00
e001f344e5 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!).

(cherry picked from commit 503775a5a0)
2018-12-24 13:35:32 +01:00
Ell
d70aeea550 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.

(cherry picked from commit 93f4b18704)
2018-12-20 08:32:23 -05:00
ef12064655 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.

(cherry picked from commit 0a2d066168)
2018-12-19 16:24:23 +01:00
86b9738286 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.

(cherry picked from commit cd924f453a)
2018-12-19 16:23:26 +01:00
a68524d43b 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.

(cherry picked from commit db18c679f3)
2018-12-19 16:14:11 +01:00
b1236403cf 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.

(cherry picked from commit d71efdec20)
2018-12-19 16:05:30 +01:00
1471da20b7 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).

(cherry picked from commit f7a4ce1051)
2018-12-19 16:05:05 +01:00
439a44a613 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.

(cherry picked from commit 744d67939d)
2018-12-19 15:53:46 +01:00
4fe5dc5d42 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).

(cherry picked from commit 6bec0bc82d)
2018-12-19 15:53:05 +01:00
c4988efdb0 app: add possibility to antialias line art colorization.
(cherry picked from commit d2f9549c9f)
2018-12-19 15:51:27 +01:00