Commit Graph

691 Commits

Author SHA1 Message Date
Jehan a03e52ea08 app: add "cairo-ARGB32" to "R'G'B'A u8" in gimp_babl_init_fishes().
This fish is used for text layers, so if we let it to be
lazy-initialized, the first time one writes text in a text layer, it
generates a few seconds delay, which is really not great.
2018-08-01 16:45:16 +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
Ell 432a884715 app: flush async-operations queue when setting async thread count to 0
In gimp-parallel, always flush the async-operations queue (by
executing all remaining operations on the caller thread) when
setting the async-pool thread count to 0 (as happens when setting
GEGL_THREADS=1, per the previous commit,) and not only when
shutting GIMP down.  Otherwise, pending asynchronous operations
can "get lost" when setting GEGL_THREADS to 1.

Additionally, in gimp_gegl_init(), initialize gimp-parallel before
before connecting to GimpGeglConfig's "notify::num-processors"
signal, so that the number of async threads is set *before*
GEGL_THREADS, in order to avoid setting GEGL_THREADS to 1 while
async operations are still executing.

Also, allow setting the number of gimp-parallel-distribute threads
while a gimp-parallel-distribute function is running (which can
happen if gimp-parallel-distribute is used in an async operation,
as is the case for histogram calculation), by waiting for the
parallel-distribute function to finish before setting the number of
threads.
2018-07-15 05:07:20 -04:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Ell a0a62656d2 Issue #1792 - Xcf file crashing gimp-console-2.10 ...
... (valgrind reports Invalid read)

Add gimp_babl_is_valid(), which takes a GimpImageBaseType and a
GimpPrecision, and determines whether the image-type/precision
combination is valid.  Use this function to validate that loaded
XCFs use a valid type/precision combination, before trying to
create the image.  Otherwise, we get a CRITICAL, and eventually a
segfault, when the combination is invalid.

Use the same function to validate the arguments of
gimp_image_new().
2018-07-06 13:06:46 -04:00
Michael Natterer 3089a20167 app: remove all calls to gdk_window_process_updated()
- remove gimp_widget_flush_expose()
- remove the "now" argument to gimp_display_shell_flush() and make it
  only update widget states
- rename gimp_display_flush_whenever() to gimp_display_flush_update_region()
  and call gimp_display_shell_flush() separately in the only case we
  passed FALSE to flush_whenever()
- remove th flush_now interval logic from GimpDisplay, as soon as we
  have exposed the canvas, we are in the loop for the next frame clock
  tick anyway, so delaying a useless and removed process_updates serves
  no purpose
- in gimptool-progress.c, create the invisible grab widget also for
  non-cencelable cases, so we can always safely run the main loop
  manually to make the progress updates visible
- in gimp-gegl-apply-operation.c, always run the main loop manually
  to make the progress updates visible
- in gimpstatusbar.c, leave some FIXME comments as reminder that
  we might need the same logic as in gimptool-progress.c
2018-07-01 16:40:27 +02:00
Ell 8a881ca61a app: properly handle NULL rectangle arguments in gimp-gegl-loops
... and gimppaintcore-loops

When a rectangle argument is NULL, use the extents of the
corresponding buffer, instead of raising a CRITICAL, to match the
old behavior.
2018-06-21 08:11:16 -04:00
Michael Natterer 1b7d63cce9 Use g_set_object() in a lot of places, and splrinkle some g_clear_object() 2018-06-01 12:59:52 +02:00
Ell 08ff2ac8c8 app: use gimp_gegl_buffer_copy() all over the place
Replace all uses of gegl_buffer_copy() in app/ with
gimp_gegl_buffer_copy(), added in the previous commit.
2018-05-25 08:12:27 -04:00
Ell fded25b38c app: add gimp_gegl_buffer_copy()
... which is a drop-in replacement for gegl_buffer_copy(),
parallelizing the copy operation when the source and destination
formats are different, requiring a conversion.
2018-05-25 08:12:27 -04:00
Ell d272368251 app: add gimp_gegl_average_color()
... which takes a GeglBuffer and calculates the average color over
a given area.
2018-05-18 15:07:32 -04:00
Ell 2e68088c35 app: use gimp:normal instead of gegl:over in gimp_gegl_apply_cached_operation()
When the operation doesn't have an input pad, composite it over the
input using gimp:normal, instead of gegl:over, for consistency with
the rest of our compositing code (although the result should be the
same).
2018-05-07 14:38:53 -04:00
Michael Natterer d87259ccf9 app: fix gimp_gegl_apply_operation() for source OPs
Blend them on top of the source buffer using gegl:over like
GimpDrawableFilter does interactively. Fixes "Repeat Last" and
probably some other stuff for source OPs.
2018-05-07 14:26:26 +02: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 8994246be2 Bug 791519 - Unexpected selection from channel
One additional fix for the gimp-channel-combine-masks procedure,
it needs both the combined *and* combined-to buffer in
gimp_gegl_mask_combine_buffer() to be treated specially.
2018-04-08 20:26:32 +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 87a10aaf9e Bug 795048 - Image->mode->Grayscale results in a black or transparent image
In gimp_gegl_convert_color_profile(), when src/dest_rect is NULL,
use the extents of src/dest_buffer, instead of passing a NULL area
to gimp_parallel_distribute_area(), which results in a CRITICAL.

Additionally, only report progress on the main thread.
2018-04-07 12:05:59 -04:00
Ell f7c2ce9b13 app: fix smudge tool artifacts
Commit cb239e60f6 introduced
artifacts when using the smudge tool with multithreads.  Fix this
(caused by a wrong offset passed to an iterator) plus indentation
fixes.
2018-04-05 19:17:45 -04:00
Ell cb239e60f6 app: parallelize gimp-gegl-loops.cc
Ditto.
2018-04-04 17:49:47 -04:00
Ell 828b99b5b3 app: switch gimp-gegl-loops.c to C++
Ditto.
2018-04-04 17:49:47 -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 cad72b1432 app: remove unused variable in gimp_tile_handler_validate_command() 2018-04-02 23:23:54 +02:00
Ell 4acdc7392a app: use gegl_tile_handler_damage_rect() in TileHandlerValidate
Use the recently-added gegl_tile_handler_damage_rect() function
during GimpTileHandlerValidate invalidation, instead of manually
voiding the tile pyramid.  This function avoids voiding mipmapped
tiles entirely when only a subarea of the tile needs to be redrawn.

See GEGL commit 3210f4ffc3c569a2acd9483811cb141070112bc6.
2018-04-02 16:47:45 -04:00
Ell 289ecebd69 Bug 793734 - White alpha border after upscaling
In gimp_gegl_apply_scale(), use a CLAMP abyss policy for the scale
op, to avoid leaking transparency into the image when scaling
drawables.

Note that this (intentionally) only affects whole-image/layer
scaling, and not scaling done using any of the transform tools.
2018-03-22 17:04:13 -04:00
Ell ab4b7ab33a app: crop input to output rect in channel ops
In gimp_gegl_apply_{border,grow,shrink,flood}(), which are used
by the corresponding channel functions, pass crop_input = TRUE to
gimp_gegl_apply_operation(), to clip the input to the output rect.

These operations process the entire input in one go, regardless of
the requested output region; however, the channel functions
calculate the output region according to the known channel bounds,
hence clipping the input to these bounds doesn't affect discard any
information, while avoiding unnecessary work.  In particular, this
makes the corresponding operations on small selections in big images
much faster.
2018-03-22 13:46:28 -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 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
Ell 5f58a7a260 app: pass near-plane z-coordinate to gegl:transform
... so that GEGL performs the same clipping we do.
2018-01-28 16:37:34 -05:00
Ell 3c0787e4c3 app: use gimp_transform_polygon() in gimp_transform_resize_boundary()
... so that the transformed boundary is properly clipped.

Adjust the boundary-size algorithms to operate on arbitrary
polygons.

Avoid using gimp_matrix3_will_explode() in
gimp_drawable_transform_buffer_affine() and falling back to
cropping the result, and avoid setting the "clip-to-input" property
of gegl:transform.  Neither of those in needed anymore.

This effectively reverts the app/ part of commit
768d06614f.  The next commit revets
the libgimpmath/ part.
2018-01-28 16:37:34 -05:00
Ell 73d7a81a4d app: restore operation src node in gimp_gegl_apply_[cached_]operation()
When merging a drawable filter, we call
gimp_gegl_apply_cached_operation() on a node that's part of the
drawable's filter stack graph.  The function rewires the node's
input, and doesn't restore its original input connection before
returning, leaving the graph in an inconsistent state.  Currently,
this doesn't matter, since we remove the filter right after that,
but the next commit expects the filter stack graph to remain
consistent.

Remember the original source node of "operation" in
gimp_gegl_apply_cached_operation(), and restore it upon exit, to
fix that.
2017-12-05 16:12:07 -05:00
Ell dec2375a26 app: add gimp:buffer-source-validate operation
gimp:buffer-source-validate is a drop-in replacement for
gegl:buffer-source, however, if the attached buffer has a
validating tile-handler, it makes sure the required region is
validated during process().  This avoids a situation in which
validation happens in different worker threads at the same time
during the processing of a succeeding operation; since validation
is protected by the buffer's tile-storage mutex, this can result in
either a deadlock (currently), or an effective fallback to single-
threaded processing.
2017-12-04 16:02:41 -05:00
Ell f7d6805ebb */Makefile.am: add abbreviations to generated enum files
Update the dprod production of generated enum files to include
abbreviated value descriptions, as per the previous commits.

Add a comment for translators above the abbreviated descriptions,
specifying the full description they abbreviate.
2017-11-30 03:10:14 -05:00
Ell eeddd13209 Revert "app: make GimpTileHandlerValidate thread safe"
This reverts commit 4bd118ec8a.

The mutex introduced by the above commit should no longer be
necessary, after GEGL commit
8b034c437b0162b26f85eb80867914977ac3cf57.
2017-11-24 14:10:47 -05:00
Ell 4bd118ec8a app: make GimpTileHandlerValidate thread safe
Use a mutex to protect the call to
gimp_tile_handler_validate_validate() while fetching tiles, since
it's nowhere near thread safe.
2017-11-15 11:51:58 -05:00
Ell 66bb469a78 Bug 786992 - removing alpha produces a black image (sometimes), with OpenCL
When creating a flatten node, which is used when removing alpha
channels and when flattening an image, use a gimp:normal node to
combine the layer with the background color, instead of a gegl:over
node.  gegl:over can apparently result in completely black output
with OpenCL enabled, under certain (not fully pinned-down)
conditions.

As long as the OpenCL version of gegl:over is borked, there is not
much reason to use it over gimp:normal, which is more consistent
(in intension, if not in extension) with the rest of the
compositing pipeline.
2017-10-21 11:44:27 -04:00
Ell 0c305bdb0f app: use the layer's composite space when flattening it
Add a composite_space parameter to gimp_gegl_create_flatten_node()
and gimp_gegl_apply_flatten(), which controld the color space --
linear or perceptual RGB -- used for the operation (instead of
hardcoding it to linear).

When removing a layer's alpha channel, use the layer's composite
space for the flattening.  When flattening an image, use the bottom
layer's composite space.  Keep using linear space when creating a
channel or a mask from a drawable with alpha.
2017-10-21 11:44:27 -04:00
Øyvind Kolås 415f869f20 app: drop workaround for bug #785521
We now hard depend on a fresher release of GEGL that already has this fix in
it.
2017-09-09 23:54:53 +02:00
Michael Natterer 6b1ed42912 app: add a timer to gimp_gegl_convert_color_profile() 2017-09-03 15:17:58 +02:00
Ell 58fdaae3ad enums: add intermediate generated enum files to .gitignore 2017-08-24 15:35:27 -04:00
Michael Natterer 1c740f0d21 app: update .gitignore in app/gegl/ 2017-08-24 20:14:56 +02:00
Michael Natterer 0cfe550639 app, pdb: change a lot of GIMP_LAYER_MODE_NORMAL_LEGACY to just NORMAL
this commit changes just those which make no difference to
functionality: property and object member defaults that get overridden
anyway, return values of g_return_val_if_fail(), some other stuff.
2017-08-19 20:33:47 +02:00
Øyvind Kolås bac042db39 app/gegl: temp hotfix to disable threading in gegl:copy-buffer 2017-08-19 17:12:15 +02:00
Ell 64ade97702 app: move libappgegl's SSE2 bits to a separate library
Split libappgegl into libappgegl-generic and libappgegl-sse2, and
move the SSE2 code (part of the newly added smudge code) to the
latter, so that the rest of the code can be compiled without SSE2
compiler flags.  This allows building GIMP with SSE acceleration
enabled, while running the resulting binary on a target with no
SSE accelration.
2017-08-17 13:04:27 -04:00
Ell 7ecd3f2783 Bug 785890 - libappgegl doesn't use SSE2 compiler flags ...
... causing compilation to fail on 32 bit targets

Use SSE2 compiler flags when building libappgegl, since it's used by
the new smudge tool code.

Avoid using SSE for the smudge tool if SSE acceleration is disabled
at runtime, or if the buffers are not properly aligned.
2017-08-06 14:13:01 -04:00
Michael Natterer 572063765f app: use "const GeglRectangle*" in the GimpTileHandlerValidate API 2017-08-05 15:49:06 +02:00
Michael Natterer 12f920d8bf app: change GimpTileHandlerValidate's API to use GeglRectangle
instead of x, y, width, height.
2017-08-05 15:43:41 +02:00
Michael Natterer bcda53ee7b Bug 785001 - Enhanced smudge tool: Smudge with painting
Apply patches from shark0r that alow to mix in both constant and
gradient color while smudging; and clean up the patches.
2017-07-23 14:44:22 +02:00
Michael Natterer 0cb3e75f79 app: use a lot of g_clear_object() and g_clear_pointer()
More than 2000 lines of code less in app/, instead of

if (instance->member)
  {
    g_object_unref/g_free/g_whatever (instance->member);
    instance->member = NULL;
  }

we now simply use

g_clear_object/pointer (&instance->member);
2017-07-15 18:42:44 +02:00
Michael Natterer 1f5739de57 app: set the number of threads on GeglConfig again, it needs testing
- enable the setting code in gimp-gegl.c again
- but set the default to one thread in GimpGeglConfig, with a CPP warning
- rename "processors" to "threads" in the GUI
- add a warning box about unexpected results when increasing #threads
2017-06-28 19:05:58 +02:00
Ell 3ca48a0b30 enums: don't use comments in generated enum recipes
Works in bash, but apparently not portable.
2017-06-02 11:15:43 -04:00