Commit Graph

5310 Commits

Author SHA1 Message Date
Ell eeae5b48ca app: avoid pushing undo for nested gimp_group_layer_{suspend,resume}_mask()
... in order not to overshoot the undo-stack estimated memory-
usage.  See comment in the code.
2018-04-22 04:05:36 -04:00
Ell 577e17032a app: fix undo when moving a group-layer child outside the group
In gimp_image_reorder_item(), call gimp_item_start/end_move()
before/after reordering the item (and use an undo group, so that
the resulting undo actions are grouped together with the reordering
undo action,) so that if the item is a child of a group layer, and
reordering moves it out of the group in a way that causes the
group's mask to be resized, the mask will be properly restored when
undoing the operation.
2018-04-22 04:05:35 -04:00
Ell 66bc050df8 app: indentation fix to last commit 2018-04-19 05:17:47 -04:00
Ell 87e6653c9a app: improve drawable flipping speed
In gimp_drawable_transform_buffer_flip(), perform flipping tile-by-
tile, instead of row-by-row/column-by-column.
2018-04-19 05:13:42 -04:00
Michael Natterer 428110f63f app: remove non-cut/copy/paste functions from gimp-edit.[ch]
Move them to the new files gimpdrawable-edit.[ch] and
gimpimage-fade.[ch].
2018-04-18 23:48:33 +02:00
Michael Natterer 9dbf919d46 app: speed up gradient rendering a lot
by using a cache of colors that is calculated once, instead of
calling gimp_gradient_get_color_at() for each rendered pixel.
2018-04-18 01:18:09 +02:00
Michael Natterer 2da25576c3 app: fix duplication of GeglParamSpecSeed, we missed its limits before
(which are probably never used, but still)
2018-04-17 00:12:01 +02:00
Ell 02808e8072 Merge branch 'fix-gradient-history'
This fixes the history of app/core/gimpdrawable-gradient.h, and
app/tools/gimpgradienttool{.c,-editor.{c,h}}.
2018-04-15 03:30:52 -04:00
Michael Natterer 721ce91d75 Bug 795230 - Rename Blend tool and provide PDB compatibility
Redo the part of commits 4f2e078ccb
and 5f6dfc7617, reverted by commit
e30a32d56e.
2018-04-15 03:30:07 -04:00
Michael Natterer 9fd44d5e44 Bug 795230 - Rename Blend tool and provide PDB compatibility
Rename gimpdrawable-blend.h to gimpdrawable-gradient.h.  Note that
this commit only renames the file; the actual changes are done in
the next commit, so that git doesn't consider this a new file.
2018-04-15 03:30:05 -04:00
Ell e30a32d56e Bug 795230 - Rename Blend tool and provide PDB compatibility
Partially revert commits 4f2e078ccb
and b0beb0197a, since the changes
they introduced to some of the renamed files were big enough for
git to consider them entirely new files, hence we lost their
history.  The next few commits fix this.

This commit also partially or entirely undoes followup commits
5f6dfc7617,
c3f98cccbd,
6b0f5136e0,
and 3736bfd189, which will be
restored by the next few commits as well.
2018-04-15 03:28:41 -04:00
Michael Natterer 0c066f311e app: drop alpha from all fishes in gimpgradient.c
Alpha is calculated separately, ne need to run it through babl.
Also some formatting cleanup.
2018-04-14 21:09:01 +02:00
Øyvind Kolås 6d6da684f1 app: add handling of CIE Lab blend space to gradient
Using CIE Lab yields gradients that more closely resemble the perceptual
gradients but without the gamma based blending problems of linear-RGB / CIE
XYZ.
2018-04-14 18:12:30 +02:00
Jehan 063a83c1ec app: migrate configuration files for s/Blend/Gradient/ tool renaming.
This includes migrating properly any custom shortcut (menurc), as well
as a few strings in tool-presets/, and finally "gimp-blend-tool" in
contextrc and devicerc.
File toolrc also has some occurrences, but we are already skipping it
anyway, same as whatever is under tool-options/.
Hopefully I missed nothing.
2018-04-14 04:01:32 +02:00
Michael Natterer 5f6dfc7617 app: add GimpGradientBlendColorSpace parameter to gimp_drawable_gradient() 2018-04-14 01:34:50 +02:00
Michael Natterer b0beb0197a Bug 795230 - Rename Blend tool and provide PDB compatibility
Rename the tool and its options, and the gradient sub-struct of paint
options.
2018-04-14 00:52:20 +02:00
Michael Natterer 4f2e078ccb Bug 795230 - Rename Blend tool and provide PDB compatibility
Rename gimpdrawable-blend.[ch] to gimpdrawable-gradient.[ch]
2018-04-13 23:43:27 +02:00
Michael Natterer b55c116755 Bug 795230 - Rename Blend tool and provide PDB compatibility
Rename GimpOperationBlend to GimpOperationGradient.
2018-04-13 23:36:16 +02:00
Michael Natterer 99ea6f91e2 app: fix the build after the GimpGradientBlendColorSpace commit
Somehow, gimppalette-import.c was not rebuilt on my system,
leaving one gimp_gradient_get_color_at() unchanged.
2018-04-13 23:12:21 +02:00
Michael Natterer ebb9d83d63 Bug 795230 - Rename Blend tool and provide PDB compatibility
Step 1: rename the icon to GIMP_ICON_TOOL_GRADIENT (gimp-tool-gradient)
2018-04-13 23:07:08 +02:00
Michael Natterer bf49b47620 Bug 795207 - Add color space to blend(gradient) tool options
First WIP commit, adds:

- enum GimpGradientBlendColorSpace { RGB_PERCEPTUAL, RGB_LINEAR }
- linear blending mode for gradient segments
- tool options GUI for the blend and paint tools which use gradients
2018-04-13 22:33:16 +02:00
Michael Natterer 421c9fc51a Bug 795050 - ‘strncpy’ output truncated before terminating nul
Use memcpy() because we really dont' want to copy the terminating nul,
but we don't want a warning either.
2018-04-11 11:31:02 +02:00
Jehan 1993d8a4a7 Bug 768872 - Tiling Symmetry doesn't wrap vertical coordinates over...
... edges for MyPaint brush.

Adding the concept of "stateful" symmetry when a tool needs to make sure
of corresponding stroke numbers and orders while painting (i.e. stroke N
at time T+1 is the continuation of stroke N at time T). This is the case
for the MyPaint brushes and the ink tool.
2018-04-11 02:09:21 +02:00
Michael Natterer 3f95dc52d3 Bug 791519 - Unexpected selection from channel
Make sure a channel -> selection -> channel roundtrip never does any
gamma conversion.

In gimp_channel_duplicate(), make sure a created channel has the
right format, and the right data. Fixes selection -> channel.

When switching off quick mask, call gimp_item_to_selection() instead
if gimp_selection_load(), the latter was implementing a shortcut which
is now wrong.

Remove gimp_selection_load() which is now unused.

Unrelated: also remove gimp_selection_save(), it was an obvious
3-liner used only twice.
2018-04-10 02:00:23 +02:00
Michael Natterer bba8f69594 Revert "Bug 791512 - make the selection boundary detection the same as 2.8"
This commit was fixing only a symptom of our channel/selection
problem, making it appear things were fine.

This reverts commit 27512d802b.
2018-04-10 00:26:01 +02:00
Ell f5cb1fed85 Bug 795081 - Crash when using a brush combined with a dynamics
In GimpPaintTool, brush outline generation took place during
gimp_paint_tool_draw() even while painting.  This function is run
concurrently with the paint thread.  When using dynamics, this
introduced a race conidition between updating the brush mask in the
paint thread, and updating the brush boundary in the main thread.

Move brush outline generation during painting to
gimppainttool-paint.c, and perform it in the display-update
timeout, while the main thread and the paint thread are
synchronized.
2018-04-09 14:27:48 -04:00
luz.paz 7fdb963e01 Bug 794996 - Misc. typo fixes in comments in app/
Found via `codespell -q 3 --skip="./po*"`
2018-04-08 21:25:56 +02:00
Michael Natterer bb4ac7c829 Bug 791519 - Unexpected selection from channel
Storing selections and layer masks as linear grayscale, but channels
as whatever-the-layers-are caused severe problems in images with
gamma-corrected layers: when combining channels with the selection,
they would go thorugh a gamma conversion before being combined, giving
unexpected results.

This commit changes all channels to always be linear, except in 8-bit
images, where they continue to be "Y' u8", for compatibility with old
XCF files, and because linear 8-bit can't really be used in
compositing (channels can be visible too).

To fix channel -> selection combinations also for these images, add a
small hack to gimp_gegl_mask_combine_buffer() which makes sure the
to-be-combined channel's pixels are always read as-is, without any
gamma conversion. After changing channels to linear, this makes no
difference except in the 8-bit images where we need this hack.
2018-04-08 19:26:48 +02:00
Ell ce9ca03ed4 app: add gimp_drawable_{start,end,flush}_paint()
gimp_drawable_start/end_paint() are used to enter/exit paint mode
for a given drawable.  While the drawable is in paint mode,
gimp_drawable_get_buffer() returns a copy of the real drawable's
buffer, referred to as the paint buffer, so that modifications to
the returned buffer don't immediately affect the projection, and
calls to gimp_drawable_update() queue the updated region, instead
of emitting an "update" signal.

gimp_drawable_flush_paint() can be called while the drawable is in
paint mode, in order to copy the updated region of the paint buffer
back to the drawable's real buffer, and to emit "update" signals
for the queued region.

We use these functions in the next commit, to move painting to a
separate thread in the paint tools.
2018-04-08 09:42:47 -04:00
Ell 6ebc3f1b09 Makefiles: don't use -xobjective-c when linking files on Mac
Last commit caused -xobjective-c to be passed during linking on
Mac, causing object files to be treated as source files.  Add a
-xnone flag to AM_LDFLAGS, canceling the effect of -xobjective-c.

Additinally, add a -xobjective-c++ flag to AM_CXXFLAGS, so that we
can use Objective-C in C++ files on Mac, if we ever need to.
2018-04-08 04:03:55 -04:00
Ell 06950be7f0 Makefiles: don't use -xobjective-c when compiling C++ files on Mac
On Mac, pass -xobjective-c to the compiler through AM_CFLAGS, not
AM_CPPFLAGS, so that it's only used for C sources, and not C++
sources.  In the latter case, it clashes with the -std=... flag,
spewing an error.  Thanks, Partha :)
2018-04-07 16:57:52 -04:00
Massimo Valentini 81e1e3967d app: silence gcc warning
gimp-templates.c:143:15: warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation]
               strncpy (dpi, "ppi", 3);
               ^~~~~~~~~~~~~~~~~~~~~~~
2018-04-07 14:45:45 +02:00
Jehan 0009794d9d app: migrate tool-presets with s/GimpImageMapOptions/GimpFilterOptions/.
As requested!
2018-04-05 11:46:49 +02:00
Ell c8d4c079a2 app: parallelize gimpbrush-transform.cc
Use gimp_parallel_distribute_foo() to parallelize the brush
transform functions.
2018-04-04 17:49:46 -04:00
Ell 565f1f2aa4 app: switch gimpbrush-transform.c to C++
The next commit is going to parallelize gimpbrush-transform using
the gimp_parallel_distribute_foo() functions.  To spare us a lot of
boilerplate code, we're going to use C++ lambdas as callback
arguments to these functions.

This commit does the initial conversion of gimpbrush-transform.c to
C++, renaming it to gimpbrush-transform.cc.  We do this in a
separate commit, so that the changes are small enough for git to
register this as a renamed file, rather than a new file, so that we
don't lose the file's history.
2018-04-04 17:49:46 -04:00
Ell 86b89cf62a app: add gimp-parallel
Add gimp-parallel.[cc,h], which provides a set of parallel
algorithms.

These currently include:

  - gimp_parallel_distribute():  Calls a callback function in
    parallel on multiple threads, passing it the current thread
    index, and the total number of threads.  Allows specifying the
    maximal number of threads used.

  - gimp_parallel_distribute_range():  Splits a range of integers
    between multiple threads, passing the sub-range to a callback
    function.  Allows specifying the minimal sub-range size.

  - gimp_parallel_distribute_area():  Splits a rectangular area
    between multiple threads, passing the sub-area to a callback
    function.  Allows specifying the minimal sub-area.

The callback function is passed using an appropriately-typed
function pointer, and a user-data pointer.  Additionally, when used
in a C++ file, each of the above functions has an overloaded
template version, taking the callback through a generic parameter,
without a user-data pointer, which allows using function objects.
2018-04-04 17:49:46 -04:00
Michael Natterer 65a697ff67 app: switch the first two args of gimp_channel_new_from_buffer() 2018-04-03 21:57:43 +02:00
Jehan d779c13891 app: do not edit symmetry variables but properties.
If variables are edited directly, in some cases, the GUI and the
symmetries may end up out-of-sync. The variable can only be edited
through property setting.
2018-04-02 18:49:23 +02:00
Jehan 3c1516ea50 app: mirror positions 0.0 are accepted.
This value is actually used as a special value when removing a guide to
get rid of a symmetry, in particular it is set in the guides' callback
gimp_mirror_guide_removed_cb() for "removed" signal.
If not setting to 0, when adding back a symmetry, it starts with weird
low or high values near to border (whereas when set to 0, it is reset to
default position afterwards).
2018-04-02 17:44:01 +02:00
Jehan c9df2a6879 app: do not raise a warning when failing to deserialize symmetry...
... parasite.
Not sure if that should be considered a bug. On one hand, it should
because that's core code. On the other hand, symmetry saving currently
uses parasites, which is a feature which can also be used by people
randomly. So "theoretically", there could be any data in a parasite and
we should not assume specific format.
Anyway still keep the error message but just print to standard error
output instead. Also print a bit more details (parasite name and
contents) as it would help for debugging when such a case were to occur.
2018-04-01 18:20:26 +02:00
Jehan e0029d31b4 Bug 792520 - Image symmetries should be saved: version the properties.
Care for future changes of symmetries, by adding a version property. For
now, all symmetries are at version 0, and no real check is done. If any
symmetry bumps its settings in the future, it will have to override also
update_version() to change settings properly if necessary, according to
any new behavior.
2018-04-01 17:51:07 +02:00
Ell 49285463e6 app: align projection update area to coarse grid
When adding a rectangle to a projection's update area, align the
rectangle to a coarse grid, to reduce the complexity of the overall
area.  We currently align the rectangle to a 32x32 grid, which
seems to be a good tradeoff between the overhead of processing a
complex area, and the overhead of processing a large area.
2018-03-31 08:19:18 -04:00
Ell 53c145c0be app: add --show-debug-menu command-line option
The debug menu is currently not included in stable versions.

Include the menu unconditionally, but hide it, and its associated
actions, by default in stable versions.  Allow enabling the menu
using a new --show-debug-menu command-line option, in the same vein
as --show-playground.
2018-03-29 05:26:03 -04:00
Ell 3265797f3e Bug 794753 - do not dither image mask and channels for imported images
By the same logic of commit
44f293bcdb, we shouldn't dither the
alpha channel either.
2018-03-29 03:30:31 -04:00
Ell 9cabee5451 app: call gimp_progress_end() at gimp_image_convert_dither_u8() exit 2018-03-29 03:30:31 -04:00
Thomas Manni 44f293bcdb Bug 794753 - do not dither image mask and channels for imported images
When "Dither images when promoting to floating point" is checked in
Preferences, apply dithering on layers and keep image mask and channels
unaltered.
2018-03-28 17:15:06 +02:00
Michael Natterer 60e01f5593 app: fix error reporting in gimp_tool_preset_deserialize_property()
when setting a custom parse error with g_scanner_error() we *must*
return G_TOKEN_NONE as expected token, or general GimpConfig error
handling will try to overwrite our error with its generic "unexpected
token" message, which triggers a warning.
2018-03-28 01:17:39 +02:00
Ell 5614cd444d app: in gimp_image_convert_precision(), report progress for selection mask 2018-03-27 09:39:52 -04:00
Ell cf658f64b5 Bug 794721 - CRITICAL converting image precision
In gimp_image_convert_precision(), don't overwrite the 'progress'
parameter with the object queue, since we need to call
gimp_progress_end() on it at the end of the process.
2018-03-27 09:39:52 -04:00
Michael Natterer 7c4f7c53ea Bug 794679 - warning on scrolling in the gradient dock
Validate all enum fields in gimp_gradient_load(), and reject
gradients with out-of-range values.
2018-03-26 18:54:43 +02:00
Ell 806d1b0510 app: fix resizing of image-sized layers when resizing canvas
In gimp_image_resize_with_layers(), calculate the set of resized
layers before changing the image size, so that we correctly
identify image-sized layers w.r.t. the old image size.  (Fixes
commit 139a23451ddc588c91610f67daa799afc2f89080.)
2018-03-26 04:38:47 -04:00
Ell 5763b50d45 app: round layer bounds to global pixel grid when scaling image/group
Add gimp_item_scale_by_factors_with_origin(), which is an extension
of gimp_item_scale_by_factors(), taking the input/output points of
origin for the transformation (both of which are (0, 0) in the case
of gimp_item_scale_by_factors()).  Implement
gimp_item_scale_by_factors() in terms of the new function, and Use
the new function when scaling group layers, instead of manually
calculating the children boundaries, so that the behavior is
uniform across whole-image scaling and group-layer scaling.

The new function rounds all four edges of the boundary to the
image-global pixel grid, instead of only rounding the top/left
edges to the global grid, and the bottom/right edges to the item-
local grid.  This preserves layer-adjacency when scaling.
2018-03-25 11:46:42 -04:00
Ell 139a23451d app: use GimpObjectQueue in lots of places
Use GimpObjectQueue, added in the previous commit, in various
instances where we perform an action on a set of objects.  This
improves progress reporting, by using a single progress for the
entire operation, rather than reporting the progress of each object
individually, and by taking the relative cost of each object into
account, instead of assuming a uniform cost for all objects.

In particular, this affects the various whole-image operations
(i.e., transformations and color conversions), operations on linked
items, and operations on layer groups.  This also affects layers
with masks, whose progress is now reported together instead of
individually.

Additionally, this commit fixes erroneous group-layer mask cropping
during undo when resizing the image, by properly calling
{start,end}_move() on all the resized layers before starting the
operation, and when scaling the image, by only scaling top-level
layers, and letting group layers scale their children themselves.
2018-03-25 11:46:42 -04:00
Ell 3ee5054eb7 app: add GimpObjectQueue
GimpObjectQueue implements a queue of GimpObjects.  It derives from
GimpSubProgress, and hence can be used as a GimpProgress object.
It keeps track of the total memsize of the objects that were
pushed-to and popped-from the queue, and uses these numbers to set
the corresponding subrange of the progress object when an object is
popped.

This provides an easy way to perform an operation on a set of
objects, correctly reporting progress based on the relative sizes
of the objects, which is assumed to be a good estimate of the
relative cost of processing each object.
2018-03-25 11:46:42 -04:00
Ell 0f532787c9 app: add "progress" property to GimpSubProgress
Make the parent GimpProgress object of a GimpSubProgress instance
settable through a property during construction, so that we can use
it as a base class.
2018-03-25 11:46:42 -04:00
Ell 76a88cc60a app: fix layer-group mask cropping during move operation undo
In gimp_group_layer_{start,end}_move(), push corresponding undo
steps, which perform the opposite operation during undo, and make
sure that mask-cropping is frozen during group-layer move
operations.

This fixed erroneous group-layer mask cropping when undoing/redoing
a group-layer move operation multiple times.
2018-03-25 11:46:42 -04:00
Ell 8f07d76786 app: fix paste-in-place when pasting over a layer group/locked item
When pasting in place over a layer group or a content-locked item,
change the paste type to NEW_LAYER_IN_PLACE, rather than NEW_LAYER,
so that the new layer is still pasted in the right location.

Additionally, avoid showing the "Pasted as new layer because ..."
message when pasting over a layer group or a content-locked item,
when the paste type is NEW_LAYER[_IN_PLACE] to begin with.
2018-03-24 12:50:16 -04:00
Ell e1b1611ec4 app: add crop_input parameter to gimp_gegl_apply_operation()
Add a crop_input parameter to gimp_gegl_apply_[cached_]operation().
When TRUE, the functions crop the op's input to the destination
rect.  This is particularly useful for functions that process the
entire input in one go (by means of get_cached_region()).  See the
next commit.

Pass crop_input = FALSE at all call sites for now, to keep the
current behavior.
2018-03-22 13:46:28 -04:00
Michael Natterer 829d44d900 app: make "color" parameter of gimp_palettes_add_color_history() const 2018-03-21 19:10:55 +01:00
Michael Natterer 28d9e43f53 Bug 792686 - Colormap widget not updated when adding entry
gimp_image_add_colormap_entry(): increment private->n_colors *before*
calling gimp_image_colormap_set_palette_entry() so it actually adds an
entry.
2018-03-20 00:53:57 +01:00
Jehan a1b4f4aef5 Bug 793638 - (gimp-edit-stroke ...) crashes gimp-console-2.9 unless...
... (gimp-context-set-paint-method...) is called.
GimpContext initialized with standard paint info at constructed() time
to ensure there is always a paint_info even if none were set manually.
2018-03-18 15:07:50 +01:00
Jehan e164aee7a9 app, libgimp, pdb: add "distance-metric" property to GimpPDBContext.
This property is currently only used for gimp_edit_blend() to control
how are computed distances. In the future, it could be used for more
functions making use of "gegl:distance-transform" operation, or even for
other algorithms, if relevant.
This new property obviously comes with 2 new PDB calls:
gimp_context_get_distance_metric() & gimp_context_set_distance_metric()
2018-03-18 01:03:40 +01:00
Jehan c3ef34b496 Revert "app: "distance-metric" is now a property of GimpContext."
This reverts commit 2c799d4af9.
Ok. I misunderstood Mitch. This belongs in GimpPDBContext.
2018-03-17 20:05:54 +01:00
Jehan 2c799d4af9 app: "distance-metric" is now a property of GimpContext.
Remove the property from Blend tool and make it use the context one.
2018-03-17 18:18:56 +01:00
Jehan acc0a97eed app: updating the previous commit following enum update in GEGL.
Enums have been renamed to s/GEGL_DISTANCE_FOO/GEGL_DISTANCE_METRIC_FOO/
Make the change in GIMP too.
2018-03-17 16:19:31 +01:00
Jehan 9b11fb2b91 app, libgimp, libgimpbase, pdb: s/GimpDistanceMetric/GeglDistanceMetric/
GeglDistanceMetric has just been added as a public enum in GEGL. Basing
our code on this, and getting rid of the newly added GimpDistanceMetric.
2018-03-17 14:57:31 +01:00
Jehan 87330a7746 app: add "distance-metric" property to the Blend tool options.
It seems old blend tool (from GIMP 2.8) was using manhattan distance,
whereas the new one uses euclidean. I guess there must be use cases for
both. In any case, it is a good idea to simply propose the option since
the property exists in the "gegl:distance-transform" operation.
See also bug 781621.
2018-03-15 13:24:59 +01:00
Ell a7f3a2dd9f app, pdb, libgimp, plug-ins, menus: rename layer composite modes
Our composite modes don't correspond directly to the Porter-Duff
operators after which they're named, and these names aren't too
descriptive anyway.

Rename the composite modes as follows:

  Source Over       =>  Union
  Source Atop       =>  Clip to Backdrop
  Destination Atop  =>  Clip to Layer
  Source In         =>  Intersection

Update relevant code, including UI text, enumerator names, function
names, and action names.
2018-03-14 16:19:09 -04:00
Jehan 5751bb114e Bug 781621 - PDB shapeburst gradient is slower than the blend tool.
PDB function gimp_edit_blend() was based on "gimp:shapeburst" operation
whereas the rest of GIMP (in particular, the Blend tool) used
"gegl:distance-transform" which is much faster.
Setting the operation to "manhattan" metric ensures that it still
renders the same way as in 2.8 while being a lot faster.

There was still a problem regarding as how it renders differently from
the Blend tool, but it turns out that the Blend tool is the one
rendering differently from how it used to in 2.8. We should discuss
adding the "metric" property in the tool options.
2018-03-14 16:07:18 +01:00
Ell b590b59542 app: fix #include order in gimp-spawn.c
... so that GLib is included before the platform-specific headers,
so that we can check for G_OS_WIN32.

Spotted by Partha, as usual :)
2018-03-10 02:22:40 -05:00
Ell e4c79cb2d6 app: use gimp_cairo_rounded_rectangle() in GimpOverlayFrame
... instead of drawing it the hard way.
2018-03-07 09:40:19 -05:00
Ell a6001f1941 app: add gimp_cairo_rounded_rectangle()
... which draws a rectangle with rounded corners.
2018-03-07 06:18:21 -05:00
Ell efa8040780 app: rename gimp_cairo_foo() functions to follow cairo naming scheme
Really pedantic stuff :)  Rename the functions in gimp-cairo.h to
follow the naming scheme employed by cairo, so that they don't feel
out of place.
2018-03-07 06:18:20 -05:00
Ell 52b0e61001 app: in gimp-spawn.c, add missing #include on Windows
... and improve argument validation.
2018-03-07 01:41:21 -05:00
Ell cdb541f81b app: add gimp_spawn_set_cloexec()
... which prevents child processes from inheriting a given pipe,
under *nix and Windows.
2018-03-06 16:31:17 -05:00
Ell 95af939903 app: verify input argumets in gimp_spawn_async() 2018-03-05 02:55:53 -05:00
Ell e1ed39e3a3 app: in gimp-spawn.c, avoid warning when we don't have vfork() 2018-03-05 02:45:47 -05:00
Ell 0f2df18dde app: add gimp_spawn_async()
gimp_spawn_async() is similar to, but more limited than,
g_spawn_sync().  Unlike the latter, gimp_spawn_async() uses
vfork(), instead of fork(), when possible.

On Linux, a process that uses large amounts of memory (as GIMP may)
can hang during a fork() if overcommitting is enabled, and there's
not enough memroy.  Using vfork() avoids that, since it doesn't
duplicate the parent's address space.
2018-03-05 01:55:40 -05:00
Massimo Valentini 87525c8911 BUG 793634: CRITICAL loading psd file with disabled layer mask
Similarly to other layer setter functions, don't push undo
steps if the layer is not yet attached
2018-02-22 00:43:50 +01:00
Michael Natterer d71ed88592 app: add buffering to reading data files
gimp_data_factory_load_data(): use a GBufferedInputStream so we don't
end up reading files byte-by-byte in the worst case.
2018-02-21 22:12:52 +01:00
Ell 91a947bbe5 app: don't allow setting NULL buffer to drawables; modify steal_buffer()
Revert commit 24fcabc1ca, which
allowed passing a NULL buffer to gimp_drawable_set_buffer[_full](),
leaving the drawable without a buffer in a semi-functional state --
this is too risky.

Instead, have gimp_drawable_steal_buffer() assign an empty 1x1
buffer to the stolen-from drawable, rather than leaving it without
a buffer at all.
2018-02-14 10:39:37 -05:00
Ell b50be495cb app: add gimp_drawable_steal_buffer()
... which transfers a buffer from one drawable to another in a safe
manner, leaving the source drawable empty.

There are already two ad-hoc instances where we steal a drawable's
buffer through simple pointer assignment, however, this avoids
performing potentially necessary cleanup and setup.  In particular,
since commit d0ae244fe8 this causes
actual errors.  The next two commits replace those instances with
calls to gimp_drawable_steal_buffer().
2018-02-13 13:29:15 -05:00
Ell 24fcabc1ca app: allow passing a NULL buffer to gimp_drawable_set_buffer[_full]()
... which clears the drawable's buffer, performing any necessary
cleanup, without setting a new buffer.  While the drawable has no
buffer, it can only be used in a very limited way, in particular,
it may be destroyed, and it may be assigned a new buffer.

This is used by the next commit to implement
gimp_drawable_steal_buffer(), which transfers a buffer from one
drawable to another in a safe manner, leaving the source drawable
empty.
2018-02-13 13:29:15 -05:00
Jehan 77ed476113 app: add GIMP_MESSAGE_BUG_WARNING + GIMP_MESSAGE_BUG_CRITICAL severity.
Since a few commits, I don't generate the traces anymore in errors.c but
delay this to gui-message.c and rely on the message severity to decide
whether or not generating traces.
Unfortunately none of the current severities are properly describing
this new type of messages. Even GIMP_MESSAGE_ERROR is used everywhere in
our code NOT for actual programming bug, but often for data errors
(which are not bugs but proper messages and should obviously not prompt
a debug trace).
2018-02-12 18:22:15 +01:00
Michael Natterer 3bea6dce03 app: don't choke when being asked for GIMP_UNIT_PERCENT's factor or digits
Instead, return bogus default values just like libgimp/gimpunitcache.c
does.
2018-02-12 16:37:49 +01:00
Ell ac3392477b app: don't disable undo for unattached items in gimp_item_{start,end}_move()
Setting push_undo to FALSE in these functions is premature -- let
this stuff be handled at the actual point where the undo is
pushed, which might correspond to a different item than the one for
which gimp_item_{start,end}_move() was called.

In particular, when removing a layer from the image,
gimp_item_end_move() is called (with push_undo == TRUE) on the
layer after it's been removed, but we still need the appropriate
undo enrties to be pushed for the affected group layers.
2018-02-12 05:18:26 -05:00
Ell 68e37f28c2 Bug 793373 - Crash when ctrl-alt-clicking, dragging then releasing...
... a selection.

The crash was the result of an unmatched gimp_item_end_move() call,
which is an error.  Add the matching gimp_item_start_move() call
when starting to drag a selection in GimpEditSelectionTool.  Revert
last commit, so that unmatched gimp_layer_end_move() calls are not
silently ignored, and add a check instead.
2018-02-12 05:18:26 -05:00
Jehan d9987ea7f1 Bug 793373 - Crash when ctrl-alt-clicking, dragging then releasing...
... a selection.
The regression appeared with commit 10c125c627.
gimp_layer_end_move() may sometimes run even while a symmetric
gimp_layer_start_move() had not run. For instance this happens when
releasing the mouse button after dragging a ctrl-alt-click created
floating layer.
Therefore let's check that layer->move_stack is not NULL before
dereferencing it.
2018-02-12 08:29:32 +01:00
Jehan 34fe992f44 app: keep track of number of errors and traces in GimpCriticalDialog.
We don't want an infinite number of traces because it takes some time to
get. Until now I was keeping track of traces in app/errors.c, but that
was very sucky because then I was limiting traces per session. Instead
save them as a variable of a GimpCriticalDialog instance. Therefore only
generate the traces for WARNING/CRITICAL at the last second, when
calling the dialog.
When too many traces are displayed, just fallback to just add error
messages only. But then even errors without traces can be time-consuming
(if you have dozens of thousands of errors in a few seconds, as I had
the other day, updating the dialog for all of them would just freeze the
whole application for a long time).
So also keep track of errors as well and as last fallback, just send the
remaining errors to the stderr.
2018-02-12 02:09:15 +01:00
Michael Natterer 539927ebfa app: replace all g_assert() by the newly added gimp_assert()
which is just a #define to g_assert for now, but can now easily be
turned into something that does some nicer debugging using our new
stack trace infrastructure. This commit also reverts all constructed()
functions to use assert again.
2018-02-11 22:23:10 +01:00
Jehan a5bc153343 app: fix a second switch with missing paste types.
Completing previous commit, the next switch was not raising any error,
but I believe the new "in place" variants of paste as floating selection
also have to be processed for mask removal.
2018-02-10 23:57:45 +01:00
Jehan da3baa1cab Bug 793360 - Error when copy-pasting in place a full layer.
In a switch(), not all paste type were listed (the new "In Place"
versions in particular were missing), therefore we were hitting a
g_return_val_if_reached() error.
2018-02-10 23:46:58 +01:00
Ell d0ae244fe8 app: invalidate channel boundary upon buffer "changed" signal
Have GimpChannel connect to the drawable buffer's "changed" signal,
so that we can invalidate the channel's boundary whenever the
buffer contents change.  Currently, the calls to
gimp_drawable_invalidate_boundary() dispersed throughout the code
are not enough.

Moreover, invalidate both the boundary and the bounds in
gimp_channel_invalidate_boundary(), since both are necessary when
the buffer changes.
2018-02-10 05:36:40 -05:00
Ell 10c125c627 app: keep ancestor set in gimp_layer_start_move(), for use in end_move()
In gimp_layer_start_move(), keep the set of ancestors for which for
which we suspended mask cropping, so that we can resume mask
cropping for the same groups in gimp_layer_end_move().  This is
necessary, since gimp_image_remove_layer() calls gimp_item
start_move() before removing the layer from the layer tree, and
gimp_item_end_move() after removing the layer from the layer tree,
at which point the layer has no ancestors.
2018-02-10 05:36:40 -05:00
Jehan d5a67cb162 app: make debugging preference finer-grained than a boolean.
Replacing the boolean property "generate-backtrace" by an enum
"debug-policy". This property allows one to choose whether to debug
WARNING, CRITICAL and FATAL (crashes), or CRITICAL and FATAL only, or
only FATAL, or finally nothing.
By default, a stable release will debug CRITICAL and crashes, and
unstable builds will start debugging at WARNINGs.
The reason for the settings is that if you stumble upon a reccurring bug
in your workflow (and this bug is not major enough for data corruption,
and "you can live with it"), you still have to wait for a new release.
At some point, you may want to disable getting a debug dialog, at least
temporarily. Oppositely, even when using a stable build, you may want to
obtain debug info for lesser issues, even WARNINGs, if you wish to help
the GIMP project.
It can be argued though whether the value GIMP_DEBUG_POLICY_NEVER is
really useful. There is nothing to gain from refusing debugging info
when the software crashed anyway. But I could still imagine that someone
is not interested in helping at all. It's sad but not like we are going
to force people to report. Let's just allow disabling the whole
debugging system.
2018-02-08 20:48:16 +01:00
Ell 94554fcc0c app: resize group-layer mask after moving the group
We avoid resizing the mask as a result of changes in the group's
bounding box while the group is being moved (i.e., translated,
rotated, etc.), so that GimpLayer transforms the original mask,
rather than a cropped mask.  We still need to crop the mask after
we're finished moving the group, however.  This commit takes care
of that.
2018-02-07 09:54:08 -05:00
Ell 9befb8594e pdb: fail layer-remove-mask if applying a mask to a group layer
... which is not supported.
2018-02-05 15:15:22 -05:00
Ell e7a2624a85 app: fix undo when resizing a group layer with a mask
Override GimpItem::resize(), instead of GimpLayer::resize(), when
resizing a group layer, so that GimpLayer doesn't try to resize the
mask.  Instead, the let the usual mask resizing logic in
GimpGroupLayer handle that.

Also, make sure that the mask is properly restored upon undo when
group resizing is suspended outside of any mask-suspension block,
which can happen when resizing the group.
2018-02-05 15:15:21 -05:00
Ell 17fb644787 app: add XCF version 13 for images with group-layer masks 2018-02-05 15:15:21 -05:00
Ell 36dec4e6b0 Bug 51112 - Support layer masks on layer groups
Add layer-mask support for group layers.  Group-layer masks work
similarly to ordinary-layer masks, with the following
considerations:

The group's mask size is the same as group's size (i.e., the
bounding box of its children) at all times.  When the group's size
changes, the mask is cropped to the new size -- areas of the mask
that fall outside of the new bounds are discarded and their data is
lost (sans undo), and newly added areas are filled with black (and
hence are transparent by default).

The new gimp_group_layer_{suspend,resume}_mask() functions can be
used to modify this behavior.  Between the outermost pair of
suspend/resume calls, the old mask data is remembered, and is used
to fill the newly added areas while cropping the mask when the
group is resized.  We override GimpItem::{start,end}_move() for
GimpLayer, to call these functions (suspend() in start_move(), and
resume() in end_move()) for each of the layer's ancestors.

As a result, while moving a layer, or a set of layers, atomically,
such as while dragging with the move tool, or moving linked layers,
the ancestors' mask data is not lost, and is only discarded at the
end of the operation.

This commit also takes care of properly handling undo for group-
layer mask crops, properly invalidating the image when the group
layer's mask is shown, and enabling the mask actions for group
layers (obviously :).
2018-02-05 12:08:54 -05:00