Commit Graph

492 Commits

Author SHA1 Message Date
Jehan 6f127f9db4 app: disable multi-threading on "gimp:shapeburst" operation.
This operation is currently broken on multi-thread. So disable
multi-threading, at least temporarily (if not forever since apparently
we can get similar output with "gegl:distance-transform", but much
faster and nicer). See bug 781621.
2018-03-13 18:24:08 +01:00
Ell 8d3b287273 app: improve gimp_layer_mode_get_format()
When the layer mode is composite-space agnostic, return a fast
format based on the preferred format's model, not the exact format.
2018-02-12 13:49:03 -05:00
Jehan ec14e1006e app: add a g_return_val_if_fail() to avoid a crash.
It seems gegl_buffer_sample() crashes with the first parameter being
NULL so let's just test its value first. This will output a huge
quantity of CRITICALs in this edge case but that's much better than a
crash. :-)
See also bug 793371 where this bug is being processed.
2018-02-12 19:42:11 +01:00
Jehan 2956cde6cf app: switch to #ifdef GEGL_BUG_645810_SOLVED code.
When checking the Cage Transform operation code, I saw some ifdef meant
to be switched to when bug 645810 is fixed. It also says in a comment:
> /* When Gegl bug #645810 will be solved,
>    this should be a good optimisation */
Checking said bug, it appears it has been fixed since 2012!
I also fixed a bit the parameters in gegl_buffer_sample() call since it
seems the function signature has changed quite a bit.
2018-02-12 19:23:08 +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
Ell 07355803a8 app: use gegl_buffer_signal_connect() in gimp:buffer-source-validate
... instead of g_signal_connect(), to connect to the buffer's
"changed" signal.
2018-02-07 09:54:08 -05:00
Michael Natterer b23f231a1a Bug 792470 - Some filters e.g. "Levels" are not added to "Repeat last" history
The four remaining "classic" color tools (Brightness-Contrast, Curves,
Levels and Threshold) are in fact just special UIs for otherwise
completely normal filter ops.

Add normal filter actions for them and invoke them like all
other filters, which makes them show up in the filter history
automatically.

The only small hack needed is to special case them in
gimp_gegl_procedure_execute_async() so the right tools are created
instead of the default GimpOperationTool. Also, blacklist the
automatically generated tools actions from action search and the
shortcut editor.
2018-01-14 15:42:29 +01:00
Ell d34800c5fc app: reintroduce clamping to vivid-light mode
... removed by commit 0f9da165e0, and
improved by this commit.

Our foo-light modes aren't really prepared to handle out-of-range
input.  Make sure that in-range input doesn't result in out-of-
range output.
2018-01-06 12:56:44 -05:00
Ell 3b52b044f9 app: small cleanup in gimpoperationlayermode-blend.c
Indentation, float literals, etc...
2018-01-06 12:31:51 -05:00
Ell 0f9da165e0 Bug 790566 - Modify the divide blend mode to not max out at 5.0
Add a safe_div() function to gimpoperationlayermode-blend.c, and
use it in the relevant blend funcs, instead of plain division.
This function clamps the quotient to some reasonable range, to
avoid infinities, and maps epsilon/... to 0, to avoid NaN.  The
latter part results in similar qualitative results to the
corresponding legacy modes, when calculating 0/0.
2018-01-06 12:31:51 -05:00
Michael Natterer 54d3beab9c Bug 757444 - Curves and Levels should operate by default on linear RGB...
...and present linear RGB Histograms

This is step one: implement the feature at all (without new defaults
or proper GUI, cough).

Add boolean "linear" properties to GimpOperationPointFilter,
GimpCurvesConfig and GimpLevelsConfig.

In the filter, simply set the input/output formats to linear in
prepare().

In the curves and levels tools, add "Linear" toggles from hell,
like in the histogram dockable, and make sure things work right
wrt changing and resetting the property, switching from levels
to curves, and picking colors.

The result currently changes when switching a non-nop curves/levels
between perceptual and linear, because adjusting the parameters
between the spaces is not implemented yet.
2018-01-05 22:37:18 +01:00
Ell da8bcdcd56 app: in legacy layer modes, clamp after blending, not compositing
In legacy layer modes that may produce out-of-range output given
in-range input, clamp the result after blending and before
compositing, instead of after compositing, to avoid producing
different results than 2.8 in certain cases.
2018-01-04 13:33:57 -05:00
Ell 6759c4e675 app: use float literals in legacy layer modes
... to make the code more consistent with the non-legacy modes.
2018-01-04 13:33:50 -05:00
Michael Natterer dce93c7d7e Bug 762443 - Levels tool Output Level sliders works incorrectly
Add "clamp-input" (which clamps the input values to [0..1])
and "clamp-output" (which clips the final result to [0..1]),
properties, parameters and GUI to:

- GimpLevelsConfig
- GimpOperationLevels
- The levels tool dialog
- The gimp_drawable_levels() PDB API

The old deprecated gimp_levels() PDB API now sets both clamping
options to TRUE which restores the 2.8 behavior.

Also reorder some stuff in GimpLevelsConfig and elsewhere so the
levels parameters are always in the same order.
2018-01-02 18:47:20 +01:00
Ell 0ff3bf93f3 app: misc performance improvements to GimpOperationComposeCrop
Override get_invalidated_by_change() with the same logic as
get_required_for_output(), to avoid unnecessary invalidation.

Avoid format conversion when input and aux have the same format.

Add pass-through fast path when the ROI is completely inside/
outside the cropped rectangle.

Use bulk memcpy(), instead of per-pixel test-and-copy, in
process().
2017-12-26 09:19:46 -05:00
Ell 74a47a8ac9 app: implement get_required_for_output() for GimpOperationComposerCrop
This avoids unnecessarily processing regions of the input and/or
aux nodes that will get cropped out.  In particular, this avoids
processing cropped-out regions when using the filter tool in split-
view mode.
2017-12-25 16:09:45 -05:00
Jehan f28cb1c511 app: add/update some comments.
Keep multi-threading disable on the cage transform operation. It is now
fixed but is a lot much slower than when single-threaded, making it
painful to use on bigger images.
So let's reenable later if we can improve this. See bug 787663.
2017-12-06 23:30:54 +01:00
Massimo Valentini f727e885cd Bug 787663 - Cage tool creates artifacts with multi-threading
Stop recursion only when all 3 vertices of the triangle are outside the
roi (left/right or above/below).
2017-12-06 23:26:08 +01:00
Jehan 87aaf576d2 Bug 787663 - Cage tool creates artifacts with multi-threading.
Temporarily disable multi-threading on the cage transform so that it
performs sanely until it is fixed.
2017-12-06 15:07:50 +01:00
Ell 4e4c1cd57e Bug 790810 - Nested layer groups lead to a deadlock with multithreading
Use gimp:buffer-source-validate, introduced in the previous commit,
for the source node of GimpDrawables.  This avoids threading issues
with layer groups, or any other drawables that may use a validating
buffer, by making sure the buffer is validated before any
succeeding operations, and hence the associated graph is processed
on the same thread as the parent composition.

Restore multithreaded processing in GimpOperationLayerMode.
2017-12-04 16:03:15 -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 5a28753924 app: add abbreviations for layer modes
Add abbreviated versions for long layer mode names.  In particular,
replace the "(legacy)" suffixes with "(l)" in the abbreviated
versions.
2017-11-30 04:46:46 -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 2ff52af5a9 Bug 790810 - Nested layer groups lead to a deadlock with multithreading
Temporarily disable multithreading for GimpOperationLayerMode, to
avoid the deadlock.  The environment variable
GIMP_MULTITHREADED_COMPOSITING can be set to reenable it, for the
sake of debugging.
2017-11-26 10:54:41 -05:00
Øyvind Kolås 9c0dac9e6d app: heed deprectation warning of gegl_operation_context_get_source 2017-11-21 20:21:25 +01:00
Ell 6f7d95c21c app: remove legacy color-erase mode from the layer mode combo
It was accidentally made applicable to layers by commit
7d345071c7.  Only the non-legacy
color-erase mode shoule be applicable to layers (since 2.8 didn't
allow it as a layer mode), while the legacy mode is only available
for painting, and in the fade dialog.
2017-10-23 09:53:07 -04:00
Ell 2bf166d2ce app: use fuzzy comparison in various layer-mode blendfuncs
Use fuzzy comparison, instead of exact comparison, in various layer-mode
blendfuncs which may be sensitive to small error.
2017-10-17 08:47:23 -04:00
Ell 0e9747380b app: in GimpOperationBlend, fix left/right-most colors when offset > 0 2017-10-09 13:15:42 -04:00
Ell a789c6e5e2 app: in GimpOperationBlend, swap leftmost and rightmost colors when ...
... rendering a reversed gradient

Finishes up the last commit.
2017-10-09 13:03:50 -04:00
Ell 4e2e60caf4 app: fix leftmost and rightmost gradient colors in GimpOperationBlend
When rendering a gradient with a repeat mode of NONE, don't sample
the gradient at 0.0 and 1.0, for pixels that lie to the left and to
the right of the gradient, respectively.  Instead, use the left
color of the leftmost segment directly, and, likewise, the right
color of the rightmost segment.  This always gives us the right
color for such pixels, even when there are gradient stops, that may
use different colors, at 0.0 and 1.0,
2017-10-09 12:48:56 -04:00
Ell dfeafcb175 app: cache last-sampled gradient segment in GimpOperationBlend
Remember the gradient segment at which the most-recent sample lies,
and pass it to gimp_gradient_get_color_at() as a seed for segement
lookup on the next sample.  This improves the performance
marginally.
2017-10-09 12:48:56 -04:00
Ell 33b05cd367 Bug 786844 - Issue with grain merge layer mode
Use 128/255, rather than 0.5, as the half-intensity value for
legacy layer modes that use it explicitly, to match 2.8 results.
2017-09-28 10:31:39 -04:00
Michael Natterer 723c4d7f87 app: remove GimpColorizeConfig, merge its props into GimpOperationColorize
Colorize doesn't need a config object just because it has a generated
property for the GUI only.
2017-09-05 21:26:59 +02:00
Ell 5effdd03b4 app: add dedicated op for pass through mode, with shortcuts
Pass through mode uses the same compositing logic as REPLACE mode,
however, it's a special case of REPLACE, where the layer is already
composited against the backdrop.  This allows us to take a few
shortcuts that aren't generally applicable to REPLACE mode.

Add a dedicated op class for pass through mode, derived from the
REPLACE mode op, implementing these shortcuts.
2017-08-31 11:39:38 -04:00
Ell 58fdaae3ad enums: add intermediate generated enum files to .gitignore 2017-08-24 15:35:27 -04:00
Ell f13c177ea7 app: fix babl format names in luminance mode
More refactoring fallout :P
2017-08-20 17:15:32 -04:00
Ell 77f51dd737 app: specify blend function for GIMP_LAYER_MODE_COLOR_ERASE_LEGACY
This is what happens when you edit code with sed :P
2017-08-19 15:37:49 -04: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
Ell 71bbd88e00 app: layer mode code shuffling
Commit 3635cf04ab moved the special
handling of bottom-layer compositing to GimpOperationLayerMode.
This required giving the op more control over the process()
function of its subclasses.  As a temporary workaround, the commit
bypassed the subclasses entirely, using "gimp:layer-mode" for all
modes.  This is the reckoning :)

Add a process() virtual function to GimpOperationLayerMode, which
its subclasses should override instead of
GeglOperationPointComposer3's process() functions.  Reinstate the
subclasses (by returning the correct op in
gimp_layer_mode_get_oepration()), and have them override this
function.

Improve the way gimp_operation_layer_mode_process() dispatches to
the actual process function, to slightly lower its overhead and
fix some thread-safety issues.

Remove the "function" field of the layer-mode info array, and have
gimp_layer_mode_get_function() return the
GimpOperationLayerMode::process() function of the corresponding
op's class (caching the result, to keep it cheap.)  This reduces
redundancy, allows us to make the ops' process() functions private,
and simplifies SSE dispatching (only used by NORMAL mode,
currently.)

Move the blend and composite functions of the non-specialized
layer modes to gimpoperationlayermode-{blend,composite}.[hc],
respectively, to improve code organization.

Move the SSE2 composite functions to a separate file, so that they
can be built as part of libapplayermodes_sse2, allowing
libapplayermodes to be built without SSE2 compiler flags.  This
allows building GIMP with SSE acceleration enabled, while running
the resulting binary on a target with no SSE accelration.

Add a "blend_function" field to the layer-mode info array, and use
it to specify the blend function for the non-specialized modes.
This replaces the separate switch() statement that we used
previously.

Remove the "affected_region" field of the layer-mode info array.
We don't need it anymore, since we can go back to using
GimpOperationLayerMode's virtual get_affected_region() function.

Last but not least, a bunch of code cleanups and consistency
adjustments.
2017-08-17 11:19:37 -04:00
Ell 3635cf04ab app: move bottom-layer special casing to GimpOperationLayerMode
GimpFilter's is_last_node field only reflects the item's position
within the parent stack.  When a layer is contained in a pass-
through group, it can be the last layer of the group, while not
being the last layer in the graph as a whole (paticularly, if
there are visible layers below the group).  In fact, when we have
nested pass-through groups, whether or not a layer is the last
node depends on which group we're considering as the root (since
we exclude the backdrop from the group's projection, resulting in
different graphs for different groups).

Instead of rolling our own graph traversal, just move the relevant
logic to GimpOperationLayerMode, and let GEGL do the work for us.
At processing time, we can tell if we're the last node by checking
if we have any input.

For this to work, GimpOperationLayerMode's process() function needs
to have control over what's going on.  Replace the derived op
classes, which override process(), with a call to the layer mode's
function (as per gimp_layer_mode_get_function()) in
GimpOperationLayerMode's process() function.  (Well, actually, this
commit keeps the ops around, and just hacks around them in
gimp_layer_mode_get_operation(), because laziness :P)

Keep using the layer's is_last_node property to do the invalidation.
2017-08-08 15:39:28 -04:00
Ell 440d8d6855 app: add pass-through layer mode
Only add the enum-value/mode-info for now.  Pass-through mode
appears above normal mode, in the default group, for layer groups
only.
2017-08-08 15:39:26 -04: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
Ell e15a444656 Bug 784799 - select > shrink and border produce horizontal gaps in selection
The grow, shrink, and border ops are written to process the entire
input at once, so chunking breaks them.  Just make them non-threaded
for now.
2017-07-11 16:49:49 -04:00
Michael Natterer 4f7fff8cb8 app: change some gimp-operation-config.[ch] parameters to GObject
They were GimpObject for no reason, also inconsistent with other
places where we deal with config objects.
2017-07-09 19:20:55 +02:00
Michael Natterer 51cc6893ab app: add gimp_operation_config_list_properties()
which is the same as g_object_class_list_properties() but filters
out the properties for which we don't want to create a GUI.

Use it in gimp_prop_gui_new().
2017-07-09 17:59:29 +02:00
Ell be193acfe0 app: fix parent_class type of GimpOperationScalarMultiplyClass 2017-06-30 16:24:49 -04:00
Jehan 430c31b798 app, plug-ins: clean out trailing whitespaces in source code. 2017-06-17 04:47:53 +02:00
Michael Natterer 4f4d6b27cf app: register the "settings folder" (e.g. GIMPDIR/curves) with the settings type
and remove all settings_folder API and values from GimpFilterTool and
its subclasses.
2017-06-05 22:00:17 +02:00
Michael Natterer 82d23fc6ff app: don't unref the passed file in gimp_operation_config_[de]serialize() 2017-06-05 20:32:07 +02:00
Michael Natterer 109f23af39 app: replace the hue-saturation tool by a generic filter action
Move the GUI to a custom gimppropgui function.
2017-06-05 18:35:05 +02:00
Michael Natterer 85aab2a0f5 app: restore color balance's tooltip 2017-06-05 13:16:59 +02:00
Michael Natterer ecfec4103b app: remove the colorize tool and replace it by a generic filter action 2017-06-04 21:21:43 +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
Michael Natterer 90698524d9 app: change gimp_operation_config_new() to _get_type()
Return only the config object's GType and do the g_object_new() in the
caller (one caller only needs the type, there is no need to create a
dummy object just to get to its type).
2017-05-29 08:04:52 +02:00
Ell 5bcde32caf enums: run gimp-mkenums from the build dir
Commit 1e6acbd4e1 modified the
generated enum recipes to run gimp-mkenums from the source
directory, instead of the build directory, so that only the
basenames of the corresponding header files would appear in
the comment at the top of the generated files.  This was a
mistake -- $(GIMP_MKENUMS) is expecting to be invoked from the
build directory.

Switch back to running gimp-mkenums from the build directory.  To
avoid including the relative path from the build directory to the
source directory in the generated file, add a @basename@ production
variable to gimp-mkenums, which exapnds to the basename of the
input file, and use it instead of @filename@ in the recipes for the
generated enum files.
2017-05-22 20:29:18 -04:00
Ell f9fa0d1b18 enums: don't write generated enum files to src-dir if unchanged
When regenerating an enum file, don't copy it back to the source
directory if it hasn't actually changed.  This allows using a read-
only source directory where the enum header is newer than the
generated file, as long as they're not really out of sync.

OTOH, *do* touch the generated source-dir file even when unchanged,
in order to avoid re-running its recipe on the next build, however,
allow this to silently fail (which is harmless).
2017-05-22 17:58:04 -04:00
Ell a67135658e app: add gimp_layer_mode_get_included_region()
Takes a layer mode and a composite mode, and returns the region
included in the composition.

Use this function in GimpOperationLayerMode, instead of testing
for specific composite modes directly.  Will also be used by
the next commit.

Indentation cleanup in gimp_layer_modes.h
2017-05-11 17:44:55 -04:00
Ell c78cecd76d app: rename GimpLayerModeAffectMask to GimpLayerCompositeRegion
... so that we can use it for other functions that involve
compositing regions (which we do in the next commit).

Rename gimp_operation_layer_mode_get_affect_mask() and
friends to _get_affected_region().
2017-05-11 17:44:55 -04:00
Ell dfce143f8d app: push regenerated operations-enums.c file
Due to last commit.
2017-05-06 18:36:45 -04:00
Ell 13e2153d33 app: swap enum/ui order of dst-atop and src-in
It's a more logical order.  Hopefully, we're going to rename them
soon, so it'll all make more sense.
2017-05-06 18:23:20 -04:00
Ell 1e6acbd4e1 enums: generate enum files in source dir
We check them into git, so this makes it easier to keep them in
sync when using a separate build directory.

Case in point -- this commit also syncs a few enum files that went
out-of-sync with their headers.
2017-05-06 17:26:16 -04:00
Ell 2d22d0b0ff Bug 780907 - GIMP 2.9.5 layer-blending-mode Tear
Commit 9d4084c82f skips conversion and
blending of (some) transparent source and destination pixels.  When
`blend_out == blend_layer`, it banks on the fact that the alpha values
of `blend_out` would be the same as those of `blend_layer`, and hence
the same as those of `layer`; thing is, we only copy those values from
`layer` to `blend_layer` for the pixels that we *don't* skip, so this
assumption is just wrong :P  This leaves us with bogus alpha values in
`blend_out` for the skipped pixels, when the above equality holds.
For composite modes that use the alpha values of `blend_op` (aka `comp`)
even for transparent input pixels (i.e., src-atop and src-in), this may
result in artifacts.

Fix this by simply initializing the alpha values of `blend_out` for
skipped pixels unconditionally.
2017-04-04 16:48:36 -04:00
Michael Natterer 9b500c03d1 app: initialize generated properties with their default values 2017-03-30 23:21:12 +02:00
Michael Natterer 766d1aa954 app: factor out duplicated code in gimp-operation-config.c 2017-03-24 11:52:41 +01:00
Michael Natterer 70d428591f app: try to move the compat filter config to its new place
from gimpdir/tool-options/ to gimpdir/filters/, and only if moving
fails try reading from the old location as fallback. We don't normally
move files around, but this one-liner nicely avoids cluttering
gimpdir.
2017-03-24 11:44:02 +01:00
Michael Natterer ee6c7ec7b7 Bug 780015 - Filter settings are not properly restored after Gimp restart
Filters settings used to be serialized and deserialized only
when a filter tool's GUI was shown, too late for the code that
re-runs/re-shows filters with previous values.

Move the entire loading/saving code to gimp-operation-config.c, even
adding/removing the dummy separator item between timestamped automatic
history and manually saved settings. Load the settings automatically
when a settings container is requested, but still trigger saving from
the few places the container is changed in the GUI; could also
automate that later.

This commit also moves all settings of filters that have their own
tools from gimpdir/tool-options/ to gimpdir/filters/. Add compat code
to try the old filename if the new doesn't exist, so files are
migrated automatically.

WIP, but this step already fixes the bug.
2017-03-24 01:29:50 +01:00
Elle Stone 48e4044672 Bug 780065 - Change default way to desaturate to Luminance
which unlike HSL Lightness is actually physically meaningful and
also generally speaking much more useful than HSL Lightness.

Change "Lightness" to "Lightness (HSL)" to make it clear that
the "Lightness" in the Colors/Desaturate/Desaturate menu is not the
same as "Lightness" in LAB/LCH.

For completeness add the option to desaturate to "Value (HSV)".

Add links in app/operations/gimpoperationdesaturate.c
to the Wikipedia article with definitions of L/I/V in HSL/HSI/HSV.
2017-03-17 17:16:03 -04:00
Ell 8055f14e6b app: fix and streamline HSL color layer mode
Fixes an error introduced by commit 45516a0ca9.

Also, make the code more consistent across the different HS[VL] modes.
2017-03-16 15:37:35 -04:00
Ell 03756d0980 app: rename "Color (HSV) (legacy)" mode to "Color (HSL) (legacy)"
The color-space qualification is, in fact, a 2.9 thing, so there's no
historic reason to keep the wrong name for the legacy mode.
2017-03-16 06:23:30 -04:00
Ell da9c4270a6 app: fix version comments in GimpLayerMode enum 2017-03-16 04:54:23 -04:00
Ell ff5eb69254 app: improve performance of HSV hue mode
No need to do full back and forth RGB/HSV conversions.
2017-03-15 21:49:13 -04:00
Ell 661c22c06f app: rename "Color (HSV)" mode to "Color (HSL)"
... since that's the color space it actually works in.

Keep the legacy "Color (HSV)" mode's name as is, wrong as it is,
since, well, that's what it used to be called...
2017-03-15 19:30:01 -04:00
Ell 45516a0ca9 app: improve performance of HSV [sic] color mode
No need to do full back and forth RGB/HSL conversions.
2017-03-15 18:52:35 -04:00
Ell 77211f1098 app: improve performance of HSV saturation mode
No need to do full back and forth RGB/HSV conversions.

Change the behavior such that fully desaturated values remain
desaturated, instead of saturating towards red.
2017-03-15 18:50:11 -04:00
Ell bcb242df64 app: improve performance of HSV value mode
No need to do full back and forth RGB/HSV conversions.
2017-03-15 18:48:43 -04:00
Ell 3fa2c91502 app: remove mono-mix layer mode
This effectively reverts commit c6c0899655.

Removing due to lack of consensus.  We can always re-add it in the
future if we decide we want it.
2017-03-15 14:52:14 -04:00
Ell 9d4084c82f app: in gimp_composite_blend(), reduce conversion of transparent pixels
Pixels whose source or destination alpha is zero are not blended, and
therefore do not need to be converted between the composite and blend
spaces (assuming a conversion is necessary to begin with.)  When there
is a large enough segment of consecutive pixels that don't need
blending, split the conversion/blending process around it, so that
we don't convert too many unblended pixels unnecessarily.

For layers with lots of transparency, this can dramatically reduce
compositing time; for layers with no transparency, the added
overhead is rather negligible.
2017-03-13 18:30:15 -04:00
Ell ed0fda032d app: add split layer mode
Subtracts the source layer from the destination, such that
recompositing the result with the source using merge mode
reproduces the original content.
2017-03-10 18:56:32 -05:00
Ell 23e6984d46 app: add merge layer mode
Merge mode lays the source layer on top of the destination, same as
normal mode, however, it assumes the source and destination are two
parts of an original whole, and are therefore mutually exclusive.

This is useful for blending cut & pasted content without artifacts,
or for replacing erased content in general.
2017-03-10 18:56:32 -05:00
Ell c6c0899655 app: add mono-mix layer mode
Calculates the dot product of the two input colors, and uses that
as the value for all the output color's components.  Basically,
a per-pixel mono mixer.

Useful for custom desaturation, component extraction, and crazier
stuff (bump mapping!)
2017-03-10 16:33:14 -05:00
Ell 7d345071c7 app: make color-erase mode an ordinary layer mode
Include color-erase mode in the menu for layers.
2017-03-10 15:27:03 -05:00
Ell dfb3ddc4d9 app: make erase mode an ordinary layer/paint mode
Include erase mode in the menu for layers and general paint tools.
This makes the eraser tool somewhat unnecessary, but allows for
interesting use cases (e.g., airbrush eraser, etc.)
2017-03-10 15:27:03 -05:00
Ell 91ef42d1d0 app: fix subtractive src-over compositing 2017-03-10 15:26:57 -05:00
Ell 8e68ca855d app: fix NULL mask handling in previous commit 2017-03-08 15:28:26 -05:00
Ell 7704b6100e Bug 779326 - GIMP Crash on Merging/flattening image ...
... possibly due to small win32 stack

Limit the number of samples processed in one go by gimp_composite_blend()
so that we don't overflow the stack when we alloca() buffers on it.
2017-03-08 15:07:05 -05:00
Ell 44b4d0f6ab app: small fixes in gimpoperationlayermode.c
I built the thing, how the hell did this happen :P
2017-03-08 15:05:36 -05:00
Ell 7b23e0e937 app: add LEGACY flag to NORMAL_LEGACY mode
Not that we use that for anything...
2017-03-08 14:13:51 -05:00
Ell b22c09e7b7 app: implement color-erase mode as a GimpOperationLayerMode blendfun
... and get rid of the dedicated op.  This gives us support for all
the blend/composite options for this mode.

Rename COLOR_ERASE to COLOR_ERASE_LEGACY, with perceptual blending/
compositing and immutable everything, and add a new COLOR_ERASE
mode, defaulting to linear blending/compositing, with mutable
everything.  Modify affected code.
2017-03-08 14:13:51 -05:00
Ell 398a7b023c app: add subtractive compositing functions to GimpOperationLayerMode
These are more general, and more expensive, versions of the non-
subtractive compositing functions.  They are used with modes that
specify the SUBTRACTIVE flag.  This doesn't affect anything yet, but
the next commit ports color-erase mode to a blendfun.
2017-03-08 14:13:51 -05:00
Ell 40c0ea4fe1 app: add GIMP_LAYER_MODE_FLAG_SUBTRACTIVE
Most modes only modify the *color* of overlapping dest/src regions,
however, erase and color-erase may also reduce their *alpha*, i.e.,
eliminate some of the overlapping content.  Flag these modes with
the new SUBTRACTIVE flag, as they require more general compositing
code.  The next commit adds the said code.
2017-03-08 14:13:51 -05:00
Ell a2f3616a13 app: more consistent layer/comp parameter usage in the compositing functions
Also, don't depend on the layer buffer alignment for the SSE src-atop
function, since it's not used.
2017-03-08 14:13:51 -05:00
Øyvind Kolås 361ca1bfb4 app: show overlay mode also in legacy mode menu
The mode group switching combo box is hard to discover, until we use the
default group instead of legacy group as default - it is better to make legacy
resemble the full old set to.
2017-03-08 18:14:40 +01:00
Ell 2ee8a2ed57 app: avoid an alloca in gimp_composite_blend()
Reuse one of the blend-func input buffers for output, when doing
in-place processing and requiring a blend-space conversion.
2017-02-27 14:23:44 -05:00
Michael Natterer f8d55b75bb app: put BLEND_SPACE_IMMUTABLE back for NORMAL 2017-02-26 16:43:59 +01:00
Michael Natterer 3cf423f0cd *: rename NORMAL to NORMAL_LEGACY and NORMAL_LINEAR to NORMAL
and make NORMAL_LEGACY immutable.
2017-02-26 16:26:34 +01:00
Michael Natterer f63906e5e3 app: add src-format and dest-format properties to gimp:profile-transform
Need to provide the pixels in a format that matches the profile,
simply using "RGBA float" here was a brain bug of mine. Two profiles
and two formats are parameters the used GimpProfileTransform needs to
work correctly.
2017-02-24 12:55:15 +01:00
Michael Natterer 89b27867e1 app: add gimp_layer_mode_get_context_array()
which returns an array of modes in the order they would appear in a
GimpLayerModeContext's UI (like tool options or the layers dialog),
without the separators.

Use it in context-commands.c and layers-commands.c instead of static
(and outdated) arrays for the actions that cycle through modes.
2017-02-20 23:51:32 +01:00
Michael Natterer 125727fa15 app: nicer formatting for GIMP_LAYER_MODE_CONTEXT_ALL 2017-02-20 20:35:04 +01:00
Ell 74ec82c3c2 app: whitespace such and such in gimp-layer-modes.c 2017-02-20 14:20:39 -05:00
Øyvind Kolås acc58c421d app: layer-modes: add comments to lighten/darken only
The lack of a blend space is there for a reason, document it.
2017-02-20 20:12:53 +01:00
Øyvind Kolås 4c252a6b55 app: layer-modes, by default use linear blend_space for add/sub/mul/div 2017-02-20 20:02:00 +01:00
Øyvind Kolås 49ccd8dadf app: gimp-layer-modes specify blend space for lighten and darken only 2017-02-20 19:52:03 +01:00
Ell 968397849a app: add luminance mode to the groups array 2017-02-20 13:36:30 -05:00
Michael Natterer 314ad956f8 app, libgimp: commit regenerated files after enum GimpLayerMode change
and reorder the GimpLayerModeInfo array correctly.
2017-02-20 18:21:12 +01:00
Øyvind Kolås c40ac6f252 app: append rather than insert blend mode in layer mode enum 2017-02-20 16:01:47 +01:00
Øyvind Kolås ae03b15522 app: make blendfunction of RGB luminance work again 2017-02-20 13:54:37 +01:00
Elle Stone aaed8a6eb9 app: Bug 753163 - Add blend mode "RGB Luminance"
This adds a blend mode similar to CIE Luminance - but that does not alter
saturation.
2017-02-20 13:54:37 +01:00
Michael Natterer 1dd2c52ed3 app, pdb, libgimp: add PDB API for layer blend space and compositing space 2017-02-20 01:17:07 +01:00
Michael Natterer 63f1ec4101 app, libgimp, plug-ins: remove the _LINEAR layer mode variants
Missing: PDB API to set the various sub-modes we now have for layer modes.
2017-02-19 23:15:59 +01:00
Ell d42f5c4253 app: don't depend on mask alignment for SSE compositing 2017-02-18 20:56:21 -05:00
Ell f2ea995316 app: fix infinite recursion when compositing unaligned buffers 2017-02-18 20:24:51 -05:00
Ell eff87d4fcb app: make blend/composite attributes of color-erase immutable 2017-02-17 18:19:32 -05:00
Ell 60466dce3e app: implement the different composite modes for anti-erase mode 2017-02-17 18:19:32 -05:00
Ell 15f5d5780e app: implement the different composite modes for replace mode 2017-02-17 18:19:32 -05:00
Ell b6d7be4a0f app: implement the different composite modes for behind mode 2017-02-17 18:19:32 -05:00
Ell 7a755d5b52 app: implement the different composite modes for dissolve mode 2017-02-17 18:19:32 -05:00
Ell d1a0c253c2 app: implement the different composite modes for normal mode 2017-02-17 18:19:32 -05:00
Ell 7402127505 app: remove GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA and friends
Instead, add a gimp_layer_mode_get_format() function, which takes
the layer mode, composite space, and blend space, and returns the
I/O format.

Currently, we always use the composite space format as the I/O
format.  This simplifies gimp_composite_blend(), and gives us
composite-space support for the "special" layer mode ops for free.
2017-02-17 18:19:32 -05:00
Ell 50d8455890 app: avoid some GCC warnings due to unhandled switch cases 2017-02-17 18:19:32 -05:00
Ell e30d235ede app: derive the layer-mode menu layout entirely from the info arrays
Replace the 'with-behind' and 'with-replace' properties with a
single 'context' property, and use it to select the included
layer modes, according to their context mask.

Add a dummy GIMP_LAYER_MODE_SEPARATOR value to the GimpLayerMode
enum, and use it to explicitly mark the menu separators in the
layer-mode group arrays; add separators to the layer-mode menu
accordingly.

Update the rest of the code to use 'context' instead of 'with-behind'
and 'with-replace'.  In particular, in the layers and layer options
dialogs, select the right context based on whether or not the
selected layer is a group.
2017-02-17 06:26:32 -05:00
Ell c3d2f57e28 app: add GimpLayerModeContext enum
A bitmask, specifying in which contexts a layer mode is applicable.
Can be a combination of:

  - LAYER: usable as a layer mode for actual layers.
  - GROUP: usable as a layer mode for layer groups.  Currently, all
    modes that specify LAYER also specify GROUP, and vice versa,
    but the planned pass-through mode will be GROUP only.
  - PAINT: can be used as a paint mode.
  - FADE: can be used for fading.

Add a 'context' field to _GimpLayerModeInfo, and provide context
masks to all the modes.

Use the context mask for validation when setting a layer's mode.
The next commit will use the mask when populating the layer mode
menus.
2017-02-17 05:57:13 -05:00
Ell 33f470fb0f app: more layer mode info
Make the layer mode arrays more readable, and fill in more fields,
even for modes that don't use them yet.  Fix a few existing entries.
2017-02-17 05:36:58 -05:00
Michael Natterer a2462907ca app: clean up gimpoperationlayermode.c a bit 2017-02-16 19:00:44 +01:00
Michael Natterer ebd939cb6d app: merge the GimpLayerModeFunc into gimp-layer-modes.c's array
and remove gimplayermodefunctions.[ch].

Make gimp_operation_normal_process() a normal function and redirect to
SSE internally.
2017-02-15 02:25:44 +01:00
Michael Natterer 57360a0ddc Bug 778597 - Eraser paints transparent areas with BG color
Add a "paint_composite_mode" field to GimpLayerModeInfo and set the
mode of the eraser to SRC_ATOP. Defaulting to SRC_OVER for all
painting didn't quite do it for all modes.
2017-02-14 23:04:28 +01:00
Ell df45936743 app: add more IMMUTABLE flags to the layer modes 2017-02-14 16:51:51 -05:00
Michael Natterer cb733efe34 app: add layer mode flags to mark blend and compositing modes immutable
set all legacy modes to completely immutable and the LAB modes'
blend mode to immutable. Change GimpLayer setters and the UI
accordingly. Remove the LAB color spaces from the GUI, they can
only be used with the LAB blend modes anyway and not changed.
2017-02-13 22:12:39 +01:00
Michael Natterer 8634b5cbc3 app: make layer blend color space and compositing color space configurable
...they say it's going to get worse before it gets better...
2017-02-12 23:49:26 +01:00
Ell b3dea58cfd app: fix SRC_ATOP and DST_ATOP too
They can be affected by the same problem described in
commit 4c3a772cd8, although in the
case of SRC_ATOP, the affected pixels are always fully transparent.
2017-02-05 22:32:08 -05:00
Ell 4c3a772cd8 app: fix SRC_OVER composite mode
When the source alpha is zero, we don't calculate the blended color,
so `comp[b]` can be infinite or NaN, in which case the expression
`in[ALPHA] * (comp[b] - layer[b])` is NaN, rather than the expected
value of zero.
2017-02-05 21:39:40 -05:00
Michael Natterer 891f85e805 app: move gimp-gegl-config.[ch] to operations/
and rename it to gimp-operation-config.[ch].
2017-02-05 20:17:31 +01:00
Michael Natterer a3b8d0ceed app: some cleanup and adding const in gimp-layer-modes.c 2017-02-05 16:30:54 +01:00
Michael Natterer daf206c745 app: make struct GimpLayerModeInfo private 2017-02-05 16:06:53 +01:00
Michael Natterer 2950fecf07 app: move layer mode enums and gimp-layer-modes.[ch] to operations/
and to operations/layer-modes/, respectively.

Add gimp_layer_modes_init() which asserts on the correct order of the
GimpLayerModeInfo array, and switch to accessing the array directly in
gimp_layer_mode_info().
2017-02-05 15:59:29 +01:00
Ell 1284715f11 app: fix composite mode of erase mode 2017-02-04 22:29:41 -05:00
Ell 8f4700b839 app: add "hard mix" blend mode
Similar to the Photoshop mode of the same name.  Assigns
either 0 or 1 to each of the channels, depending on whether the
sum of source and destination channel values is less than, or
greater than (or equals to), one, respectively.

This is equivalent to inverting the source, and using it to perform
per-pixel, per-channel threshold against the destination, which is
useful for various effects.
2017-02-04 21:30:56 -05:00
Alexandre Prokoudine 5c873bd93f Reintroduce a cleaner version of the linear light fix 2017-02-05 03:25:14 +03:00
Alexandre Prokoudine 005b16ee06 Revert "Resurrect previous version of the linear light formula and fix it"
This reverts commit 1366592f9f.
2017-02-05 03:22:07 +03:00
Alexandre Prokoudine 1366592f9f Resurrect previous version of the linear light formula and fix it 2017-02-05 01:32:56 +03:00
Alexandre Prokoudine e69924b4eb Fix the linear light layer mode formula
This simpler version provides the rendering that matches
Photoshop's one.
2017-02-05 01:19:53 +03:00
Øyvind Kolås 7a000a0991 app: include composite mode in legacy layer mode info
Otherwise normal mode doesn't work due to optimizations.
2017-02-04 23:19:35 +01:00
Alexandre Prokoudine 0159d0b734 Fix the vivid light formula 2017-02-04 22:59:48 +03:00
Ell 1a2ef41492 app: fix handling of fully desaturated colors in lch chroma mode 2017-02-03 13:55:30 -05:00
Øyvind Kolås eb93475deb app: improve data in layer mode info array 2017-02-03 16:05:21 +01:00
Øyvind Kolås d97be7edd0 app: add repository of layer mode information 2017-02-03 01:53:10 +01:00
Ell 1214d4acf1 app: move all special-case mode processing optimizations to GimpOperationLayerMode
Stuff like passing "input" directly if "aux"'s opacity is 0, etc.
Used to be partly handled by normal mode, even though it applies
to other modes too.

Adjust the logic for the new compositing modes.

Add a GimpLayerModeAffectMask enum, and a corresponding
get_affect_mask() function to GimpOperationLayerMode, which
specifies which of the op's inputs, if any, are affected by the
mode, apart from the overlapping regions.  Most modes affect only
the overlapping regions, but dissolve and replace also affect the
rest of the input.  This information is used for determining if
the optimizations are applicable.
2017-02-02 17:40:05 -05:00
Jehan e957347dd6 app: build layer mode operations with SSE2 flags.
Some of the generic files still contain SSE2 code, in particular
gimpoperationlayermode.c. The reason why it often works without is that
native gcc will usually pre-define SSE macros by default.
To check this: gcc -dM -E - < /dev/null | grep SSE
Yet I had a case on a small netbook where the SSE macros were not
pre-defined even though supported. Consequently the build failed.
2017-02-02 21:41:15 +01:00
Jehan 7447b505f9 app: tab and space cleaning. 2017-02-02 21:41:15 +01:00
Michael Natterer 2a96d598c3 app: add internal and PDB API and UI to control a layer's composite mode
Largely based on a patch by Ell, with the enum type renamed and
various small changes. Adds another axis of configurability to the
existing layer mode madness, and is WIP too.
2017-02-02 00:38:25 +01:00
Ell c6a2a64604 app: add composite mode support to erase mode 2017-01-31 18:16:44 -05:00