Commit Graph

523 Commits

Author SHA1 Message Date
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
Michael Natterer 9397aff96f app: add GIMP_LAYER_MODE_LUMA_DARKEN_ONLY and _LUMA_DARKEN_ONLY
which are perceptual versions of the new LUMINANCE_DARKEN_ONLY and
LUMINANCE_LIGHTEN_ONLY modes. Add the new modes to the UI.
2017-01-30 22:07:51 +01:00
Øyvind Kolås e9a6d93197 app: add darken only, lighten only that uses luminance
These variations on darken only and lighten only have the advantage over the
componentvise versions that they always use the full triplet of either original
or new layer - meaning no new colors/hues will be introduced. This is similar
to how these modes operated/operates in picture publisher and photo-paint.
2017-01-29 22:27:28 +01:00
Michael Natterer 5389e8e417 app, libgimp: rename GIMP_LAYER_MODE_NORMAL to NORMAL_LINEAR
and NORMAL_NON_LINEAR to NORMAL, so it's consistent with all other
modes.
2017-01-28 21:38:52 +01:00
Michael Natterer 31241a984e app, libgimp: remove GIMP_LAYER_MODE_DARKEN,LIGHTEN_ONLY_LINEAR
There is no _LINEAR variant, the modes always do the same.
2017-01-25 22:08:06 +01:00
Øyvind Kolås 09af8dbca5 app: slight optimization of sse2 for src_atop 2017-01-25 21:14:14 +01:00
Øyvind Kolås e1c1a5a9a8 app: implement SSE2 acceleration of src_atop 2017-01-25 12:54:20 +01:00
Michael Natterer 0fcf4ca59d app: remove gimpblendcomposite.h from Makefile.am, it's gone 2017-01-24 23:54:56 +01:00
Øyvind Kolås 579676cfe4 app: fix grain_extract behavior
The blending function of grain merge was being used instead of grain extract.
2017-01-24 19:19:19 +01:00
Øyvind Kolås 6a1d49bc6d app: fix legacy divide blend mode
The porting from 8bit per component scaled some 8bit fractions up to huge
floating point numbers, this works for most values but causes trouble for near
transparent pixel values. This commit copies the inner blend loop from the new
divide layer mode, but keeps the old compositing logic.
2017-01-24 18:36:08 +01:00
Ell 9128f3fc87 app: skip color calculation in the blend funcs if either dest or src ...
... is fully transparent, instead of just src.

The blend func results only affect the intersection of dest and src.
Run time is currently dominated by the compositing step for most modes,
so the difference in performance is pretty negligible, but it does make
a difference for the more expensive modes, like the HSV ones.
2017-01-24 11:27:40 -05:00
Øyvind Kolås 59471adfee app: remove default from gimp_layer_mode_get_blend_fun switch
This makes gcc warn when new cases have been added to the layer mode enum,
better than silently failing at runtime.
2017-01-24 02:53:39 +01:00
Øyvind Kolås d836d94114 app: implement non-legacy blend modes in GimpOperationLayerMode
For operations needing to override default behavior sub-classes should still be
used.

This commit also enables pinligh, vividlight and linearlight blend mode modes
2017-01-23 23:47:56 +01:00
Øyvind Kolås 5978def585 app: improve vivid-light formula 2017-01-23 22:40:10 +01:00
Øyvind Kolås 774687dcfe app: improve formulas of softlight and linear light blending modes 2017-01-23 19:03:44 +01:00
Michael Natterer d3b8a0d007 app: s/trc/space/ in the property names too 2017-01-22 17:14:44 +01:00
Øyvind Kolås 2537d3d0e9 app: refer to (color) space instead of trc for blend/composite
Since CIE Lab is one of the supported color spaces for doing the blending -
this enum is not only about transfer functions/curves or gamma. This finishes
already started cleanups.
2017-01-22 16:04:50 +01:00
Michael Natterer b10fc58802 app: add a "layer-mode" property to GimpOperationLayerMode 2017-01-22 14:41:21 +01:00
Øyvind Kolås c9ad09df61 app: add a handful more blending innerloops
Adding linear burn, vivid light, linear light, pinlight and exclusion formulas
as described on
http://www.deepskycolors.com/archivo/2010/04/21/formulas-for-Photoshop-blending-modes.html
2017-01-22 13:41:49 +01:00
Michael Natterer 05f3d38acb app: rename GimpOperationPointLayerMode to GimpOperationLayerMode
and formatting cleanup.
2017-01-21 21:35:52 +01:00
Ell 0c35baecca app: in gimp_composite_blend(), more alloca avoiding 2017-01-21 09:06:08 -05:00
Øyvind Kolås c993adf91e app: remove a trampoline in layer/paint mode dispatch
Fully removes one trampoline level and passing fewer args through the remaining
trampoline.
2017-01-21 14:10:03 +01:00
Ell fb3b99553c app: in gimp_composite_blend(), avoid another alloca when doing in-place output 2017-01-21 07:18:47 -05:00
Ell 4d985d11df app: in gimp_composite_blend(), avoid an alloca when doing in-place output 2017-01-21 06:36:03 -05:00
Ell 5da89f0daf app: in gimp_composite_blend(), avoid overwriting input in some cases (again)
Revert commit f6436eee96, which was wrong,
and redo it the right way.
2017-01-19 16:16:44 -05:00
Øyvind Kolås e9d72ef2a8 app: finish GimpLayerColorSpace rename 2017-01-19 19:22:40 +00:00
Øyvind Kolås 386e18e510 app: rename GimpLayerBlendTRC to GimpLayerColorSpace
It is used both for blending and compositing, the repeated use of the word
BLEND in code made the logic involving both blending and compositing hard to
read.
2017-01-19 19:17:24 +00:00
Ell f6436eee96 app: in gimp_composite_blend(), avoid overwriting input in some cases
Note that in some cases the alloca may be unnecessary, but this keeps
the code clean, and we have to be able to *potentially* do the alloca
anyway, so what the hell.
2017-01-19 13:51:48 -05:00
Michael Natterer a5ee5f28f9 app: cast ops using (gpointer) everywhere instead of 3 different ways 2017-01-19 19:04:49 +01:00
Michael Natterer 268e35a996 app: remove prepare() impls from erase and anti-erase
the calling code makes sure the ops have the right linear formats.
2017-01-19 18:49:22 +01:00
Michael Natterer 349cff8c16 app: remove "gboolean linear" from gimp_get_layer_mode_function()
and get rid of the two process_pixels() functions in the LCH modes,
they always take linear now.
2017-01-19 18:43:31 +01:00
Ell 417d9553b5 app: in gimpblendcomposite.h, small fix in compfun_dst_atop() 2017-01-19 12:03:39 -05:00
Ell 7df1bb4c0e app: in gimp_blend_composite(), fix dst_atop and avoid some conversions
Also s/comp_alpha/layer_alpha/ for consistency.
2017-01-19 11:55:21 -05:00
Michael Natterer d656fbab86 app: coding style cleanup in all layer modes, fiddle with includes a bit 2017-01-19 17:48:45 +01:00
Øyvind Kolås 80c947f04f app: add missing breaks in switches of gimpblendcomposite 2017-01-19 14:25:04 +00:00
Michael Natterer 4e9ce952d9 app: indentation in operations-types.h 2017-01-19 14:47:48 +01:00
Michael Natterer 4683b986f3 app: use the GimpBlendFunc typedef in gimpblendcomposite.h 2017-01-19 14:46:29 +01:00
Øyvind Kolås f645665324 app: unconditionally set alpha in hardlight/softlight/overlay 2017-01-19 14:44:39 +01:00
Michael Natterer bfdea93a9c app: indentation and formatting cleanup in gimpblendcomposite.h
Also remove all includes, they should already be there when this
header gets included.
2017-01-19 14:31:40 +01:00
Øyvind Kolås 72cbda11ae app: composite_blend, fix src_over 2017-01-19 04:57:14 +01:00
Øyvind Kolås 41fff6990e app: make layer modes more configurable
Implement a common utility function gimp_blend_composite that uses utility
functions for implementing layer modes, with separate (possibly SIMD) optimized
loops for blending and compositing, with configured linear TRC, perceptual
gamma TRC or even using CIE Lab as the space.
2017-01-19 01:04:15 +01:00
Michael Natterer 6e72d3eddf app: add blend-trc and composite-mode properties to GimpOperationPointLayerMode
and set them to unused default values.
2017-01-17 15:09:17 +01:00
Michael Natterer 5c4eb75361 app: register the enums in operations-enums.h as GTypes
and rename them to GimpLayerBlendTRC and GimpLayerCompositeMode.
2017-01-17 01:19:06 +01:00
Michael Natterer e267d87963 app: add operations-enums.h with two soon-needed enums 2017-01-16 23:07:50 +01:00
Michael Natterer 69c4644e15 app: rename GimpLayerModeFunction to GimpLayerModeFunc
like all other function typedefs and add GimpBlendFunc typedef which
will be needed soon. Also rename get_layer_mode_function() to
gimp_get_layer_mode_function().
2017-01-16 22:44:01 +01:00
Øyvind Kolås e1b7eb7245 app: divide blend mode, limit high values to 5.0
Possibly counteracting inaccuracies in used babl conversions, but with this the
result match legacy as expected.
2017-01-16 02:36:11 +01:00
Øyvind Kolås 60847cce73 app: remove odd ratio scaling, replace with range check for nan 2017-01-15 01:33:40 +01:00
Øyvind Kolås 315ccc7f82 app: remove clamping in multiply mode 2017-01-15 01:33:40 +01:00
Michael Natterer 50669fe6d4 app, libgimp: rename BEHIND enum values to be consistent with others
Also update gimplayermodefunctions.c which I forgot before.
2017-01-15 00:01:09 +01:00
Øyvind Kolås f01374798e app: remove clamps from addition, subtract and grain blend modes 2017-01-14 21:06:06 +01:00
Øyvind Kolås 39adf3627d app: use hypotf in lhc chroma blend mode 2017-01-14 21:03:29 +01:00
Øyvind Kolås f8c65367f0 app: cache fishes in lch blend modes 2017-01-13 19:21:01 +00:00
Øyvind Kolås 975a0a6943 app: reuse more code 2017-01-13 19:21:01 +00:00
Øyvind Kolås be8c2015a0 app: move factored out compositing to common header 2017-01-13 19:21:01 +00:00
Øyvind Kolås acd20fb55b app: use cached fishes in lch chroma mode 2017-01-13 19:21:00 +00:00
Øyvind Kolås 7959141eb4 app: make compositing of hsv value blend mode consistent 2017-01-13 14:26:36 +01:00
Øyvind Kolås 75173b97d9 app: make compositing of grain extract blend mode consistent 2017-01-13 14:26:05 +01:00
Øyvind Kolås 954030fab6 app: make compositing of dodge blend mode consistent with rest 2017-01-13 14:25:46 +01:00
Øyvind Kolås 13eab78ecc app: improve and simplify alpha handling of LCH blending modes 2017-01-13 14:15:35 +01:00
Øyvind Kolås feb2bb4083 app: lch color modes remove unneeded includes 2017-01-13 13:53:08 +01:00
Øyvind Kolås 0b1f684e8f app: remove unneded variable named tmp 2017-01-13 13:38:12 +01:00
Øyvind Kolås 24b04c0b40 app: use single precision hypotf and constants for performance 2017-01-13 13:17:25 +01:00
Øyvind Kolås dc5b86f0eb app: add TRC variants to get_layer_mode_function() 2017-01-12 15:18:44 +01:00
Øyvind Kolås 36ebe03770 app: remove lingering old files of dead code 2017-01-11 15:18:52 +01:00
Michael Natterer a187329777 app: sort includes in gimp-operations.c 2017-01-11 15:00:37 +01:00
Michael Natterer 77f9659c98 app: move gimplayermodefunctions.[ch] to layer-modes/ 2017-01-11 14:58:43 +01:00
Michael Natterer b959e0b69b app: move GimpOperationPointLayerMode to layer-modes/ 2017-01-11 14:44:10 +01:00
Ell e17f640fba app: eliminate unnecessary condition in GimpOperationReplaceMode
8-bit relic.
2017-01-11 08:21:02 -05:00
Michael Natterer ad134263d2 app: clean up Makefile.am in layer-modes/ and layer-modes-legacy/ 2017-01-11 13:00:27 +01:00
Michael Natterer 8b5553cef6 app: move the remaining 3 layer modes to layer-modes/
Not exactly sure if all are correct, but the file moving is almost
done now.
2017-01-11 12:55:13 +01:00