Commit Graph

454 Commits

Author SHA1 Message Date
Ell 0cf77b0a3b app: #include <string.h> in gimpoperationreplace.c
... for memset().
2019-02-14 11:09:17 -05:00
Ell 27e8f452b3 app: change behavior of REPLACE mode for fully-transparent pixels
When the result of compositing has an alpha value of 0, the
corresponding color value is not mathematically defined.
Currently, all out layer modes opt to preserve the destination's
color value in this case.  However, REPLACE mode is different
enough to warrant a different behavior:

Unlike the other layer modes, when the compositing opacity
approaches 0 or 1, the output color value approaches the
destination or source color values, respectively, regardless of the
output alpha value.  When the opacity doesn't approach 0 or 1, the
output color value generally doesn't approach a limit as the output
alpha value approaches 0, however, when both the destination and
source alpha values are equal, the output color value is always a
simple linear interpolation between the destination and source
color values, according to the opacity.  In other words, this means
that it's reasonable to simply use the above linear interpolation
for the output color value, whenever the output alpha value is 0.

Since filters are commonly combined with the input using REPALCE
mode with full opacity, this has the effect that filters may now
modify the color values of fully-transparent pixels.  This is
generally desirable, IMO, especially for point filters.  Indeed,
painting with REPLACE mode (i.e., with tools that use
gimp_paint_core_replace()) behaved excatly as described above, and
had this property, before we switched gimp_paint_core_replace() to
use the common compositing code; this created a discrepancy between
painting and applying filters, which is now gone.

A side effect of this change is that we can now turn gimp:replace
into a NOP when the opacity is 100% and there's no mask, which
avoids the compositing step when applying filters.  We could
previously only apply this optimization to PASS_THROUGH mode, which
is a subclass of REPLACE mode.

Note that the discussion above concerns the UNION composite mode,
which is the only mode we currently use REPLACE in.  We modify the
rest of the composite modes to match the new behavior:
CLIP_TO_BACKDROP always preserves the color values of the
destionation, CLIP_TO_LAYER always preserves the color values of
the source, and INTERSECTION always produces fully-zeroed pixels.
2019-02-14 11:04:53 -05:00
Jehan f508e24f0c Issue #2848: some sentences have no translation. 2019-01-24 16:14:46 +01:00
Ell 2cd7938f02 app: in gimp:gradient, improve adaptive supersampling
In gimp:gradient, when using adaptive supersampling, render the
gradient tile-by-tile, using an iterator, instead of row-by-row.
This significantly improves performance, while also avoiding the
assumption that gimp_adaptive_supersample_area() works row-by-row.

Additionally, when not using supersampling, use a single GRand
instance, since the separation to distinct seed and per-tile
instances, which was a threading optimization (commit
7f39e41254), is no longer needed.
2019-01-24 04:15:22 -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 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
Ell f508ec8b89 app: mark REPLACE and PASS_THROUGH modes as trivial 2018-12-03 09:54:09 -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 8adec5fb3a app: add gimp_layer_mode_is_trivial()
Add a TRIVIAL layer-mode flag, and corresponding
gimp_layer_mode_is_trivial() function, which indicates if the blend
function of a given layer mode is trivial, i.e., either never
modifies the source pixels (for non-subtractive modes), or always
clears the destination pixels (for subtractive modes).
2018-12-02 03:10:30 -05:00
Ell ce3a6c4fd6 app: use gimp_gegl_rectangle_align_to_tile_grid() in gimp:buffer-source-validate
... instead of custom code.
2018-12-02 03:10:28 -05:00
Ell dbab0b557d app: in Luminance mode, cache RGBA -> Y fish 2018-12-01 05:55:17 -05:00
Ell 70b7316ebc app: in Luminance mode, replace VLAs with gimp-scratch
In the Luminance layer-mode, use the scratch allocator for
allocating temporary buffers, instead of using VLAs.
GimpOperationLayerMode already allocates data on the stack,
calculated as not to overflow the stack on any platform, so having
any of its descendants also allocate big buffers on the stack is
risky.
2018-12-01 05:55:16 -05:00
Øyvind Kolås 4dd3e2197a app: cache fishes per operation instance in layer-modes
There was a global 3x3 array of babl fishes used for converting between
blending and compositing pixel representations, these were all hard-coded to
operate within the sRGB babl-space family. This commit updates a per-instance
array during operation prepare instead, that comes preconfigured with fishes
derived from the correct space. Since the same operation instance might get
different space input during its life time we store and compare the cached
fishes with the current format (which is unique depending on space).

This should address the problem seen in issue #2592
2018-11-30 01:23:25 +01:00
Ell 83dd94ba6a app: use gimp_tile_handler_validate_validate() in gimp:buffer-source-validate
Use gimp_tile_handler_validate_validate(), added in the commit
before last, in gimp:buffer-source-validate, in order to pre-render
the necessary region of the buffer, instead of performing the
validation implicitly by iterating over the region.  This is both
simpler, and, more importantly, allows us to render the entire
region in a single chunk, instead of tile-by-tile, which can be
considerably more efficient, especially with high thread counts.

This essentially extends the dynamic sizing of rendered projection
chunks to layer groups, which are rendered through
gimp:buffer-source-validate, rather than just the main image
projection.
2018-11-28 13:26:40 -05:00
Øyvind Kolås 34376c7abf app: propagate space in gimp_layer_mode_get_format
We were not propagating the space properly causing compositing and blending to
always happen in default/linear sRGB space.
2018-11-01 01:51:47 +01:00
Øyvind Kolås 55b3438328 app: migrate gimpoperationmaskcomponents to new iterator api 2018-09-11 01:47:31 +02:00
Øyvind Kolås c6d23add65 app: migrate gimpoperationgradient to new iterator api 2018-09-11 01:47:12 +02:00
Øyvind Kolås f03a84d607 app: migrate gimpoperationcagetransform to new iterator api 2018-09-11 01:46:53 +02:00
Øyvind Kolås 822f9f0d2b app: migrate gimpoperationcagecoefcalc to new iterator api 2018-09-11 01:46:34 +02:00
Øyvind Kolås 95358ca1fa app: migrate operationbuffersourcevalidate to new iterator api 2018-09-11 01:46:10 +02: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 49dfc6143d Issue #1662 - GIMP crashes while using cage transform when selection is active
Fixed by implementing Massimo's two findings:

gimp_operation_cage_transform_process(): if aux_buf is NULL, bail out
after initializing out_buf with identity vectors, fixes the crash.

gimp_cage_tool_create_filter(): set the drawable filter's region to
GIMP_FILTER_REGION_DRAWABLE, fixes offset when there is a selection.
2018-08-07 20:09:35 +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
Michael Natterer bab75b7365 Change a bazillion URLs to https://
Including all user-visible link and links called from code, like
the help pages.
2018-07-14 14:19:27 +02:00
Michael Natterer 9ef39b507b app: relax precondition checks in gimp_operation_config_get_type()
Only require the parent type if the requested type is not already
registered.
2018-07-13 13:57:02 +02:00
Michael Natterer b5b48e51c8 app: remove duplicate include in gimpcurvesconfig.c 2018-07-13 01:17:16 +02:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Michael Natterer 926dc070ef app, libgimp*: make user visible color model labels consistent
- "LCh" intead of "LCH"
- "CIE LCh" instead of "CIELCh"
- "HSV Hue" instead of "Hue (HSV)" for all models/components
2018-07-08 16:15:13 +02:00
Øyvind Kolås 8f63397ef7 app: gimp:semi-flatten propagate babl space 2018-07-06 15:27:55 +02:00
Øyvind Kolås 11dd90eb89 app: gimp:threshold-alpha propagate babl space 2018-07-06 15:09:18 +02:00
Øyvind Kolås f3a757ff33 app: gimp:set-alpha propagate space 2018-07-06 15:03:37 +02:00
Øyvind Kolås 045328c889 app: gimp:grow propagate babl space 2018-07-06 14:53:16 +02:00
Øyvind Kolås 4d5a967d6a app: gimp:shrink propagate bable space 2018-07-06 14:51:45 +02:00
Øyvind Kolås df4f9e0d9b app: propagate babl space in pointfilter base class 2018-07-06 14:51:23 +02:00
Øyvind Kolås ae2c30ad0e app: gimp:flood propagate babl space 2018-07-06 14:50:08 +02:00
Øyvind Kolås 38b1502024 app: gimp:desaturate propagate babl space 2018-07-06 14:48:26 +02:00
Øyvind Kolås 0b4d41c2ee app: gimp:compose-crop propagate babl space 2018-07-06 14:48:13 +02:00
Øyvind Kolås 5e8a5cf999 app: gimp:border propagate babl space 2018-07-06 14:47:27 +02:00
Ell 993bbd354e Issue #1682 - Segfault when starting GIMP, due to empty data files
Use gimp_input_data_stream_read_line_always(), instead of
g_input_data_stream_read_line(), in a bunch of places that don't
expect EOF.  If we don't do that, the code assumes the GError
parameter is set by the function and returns an error indication,
causing the caller to segfault when it tries to access
error->message.  Instead, we now process an empty line when EOF is
reached, which is caught by the normal parsing logic.

Additionally:

  - Use gimp_ascii_strto[id]() when loading gradients, generated
    brushes, and palettes, to improve error checking for invalid
    numeric input.

  - Improve gradient-segment endpoint consistency check.

  - Allow loading palette files with 0 colors.  They can be created
    during the session, so we might as well successfully load them.
2018-06-20 15:13:05 -04:00
Ell 367399e5c0 Issue #1490 - Crash when flattening an XCF file
The default stack size for new threads on MacOS is 512 KiB, making
our 512 KiB limit for stack-allocated buffers in
gimp_operation_layer_mode_real_process() too high.  Lower it to
256 KiB.
2018-05-25 20:34:46 -04:00
Ell ef43fc395c app: in GimpOperationGradient, use sampler for reading the distance buffer
... instead of using gegl_buffer_get() directly.  This is slightly
faster.
2018-05-25 12:20:48 -04:00
Ell b7d95ad503 app: in GimpOperationCageTransform, use sampler object ...
... instead of gegl_buffer_sample()

GEGL commit 26f13cbfe9aaaa8c176162e54fdbb8af6876538e got rid of the
per-buffer cached samplers, making gegl_buffer_sample() much more
expensive, suitable primarily for one-off samples.

Use a sampler object instead.
2018-05-13 19:40:46 -04:00
luz.paz 69b2e84924 Source and trivial typos
Found via `codespell` and `grep`
2018-05-12 23:44:47 +02:00
Ell 2c58598172 app: add gimp_layer_mode_is_alpha_only()
... which determines if a layer mode's blend function only affects
the alpha, maintaining the backdrop's color.  This is currently
true only for ERASE, SPLIT, and ANTI_ERASE modes.
2018-05-07 16:53:29 -04:00
Ell f6a56fac51 app: move exclusion and linear-burn modes to a more logical position
... in the layer-mode menu (this only affects UI.)
2018-04-26 16:08:55 -04:00
Ell 2d19848277 app: don't invalidate gradient cache upon gradient-type changes
In GimpOperationGradient, since we no longer avoid using the
gradient cache for conical gradients, the gradient type doesn't
affect the cache.
2018-04-26 05:34:58 -04:00
luz.paz 4a77ff2d3d Bug 795557 - Misc. typo fixes in source, comments and doxygen (pt3)
Found via `codespell` and grep.
2018-04-25 23:49:06 +02:00
Ell 5970046e25 app: use gradient cache for conical gradients
Add gimp_drawable_gradient_adjust_coords(), which adjusts the
gradient segment coords according to the gradient type, so that, in
cases where the gradient span is unrelated to the segment length,
the gradient cache (in GimpOperationGradient) is big enough not to
produce banding.  Use the new function in gimp_drawable_gradient()
and in the gradient tool, instead of duplicating the logic.

Move the shapreburst coordinate-adjustment logic to the new
function, and add appropriate logic for conical gradients.

Remove the code that avoids using the gradient cache for conical
gradients from GimpOperationGradient.
2018-04-25 14:05:19 -04:00
Ell 38ba45cf31 app: in GimpOperationGradient, move cache generation back to process()
Undo the part of commit fa9a4108c3
that moved cache generation from process() to prepare().  prepare()
is called after each property change, in order to calculate the
op's bounding box for invalidation.  Since we only need the cache
for actual processing, generating it in process() avoids that
overhead.
2018-04-25 14:05:19 -04:00
Ell fa9a4108c3 app: various improvements to GimpOperationGradient
Invalidate the gradient cache while setting relevant properties,
and validate it, reconstructing if necessary, during prepare(),
rather than process(), to avoid the need to use a mutex.

Make sure the cache has at least two elements, corresponding to
the initial and final colors of the gradient, since both colors
might be needed, and to avoid division by zero.

Avoid using a cache if its necessary size is too big, or if the
gradient type is conical, since the necessary cache size for
conical gradients is unrelated to the gradient line length.

Improve index rounding during cache lookup.

Lots of indentation fixes.
2018-04-25 09:48:02 -04:00