Commit Graph

19795 Commits

Author SHA1 Message Date
Michael Natterer 1cbb2f3309 app: add a comment to test-xcf.c about why we use LEGACY layer modes 2017-08-20 15:02:46 +02:00
Michael Natterer 7ce77c47cc app: stop hardcoding NORMAL_LEGACY for new layers/images
Use GimpCoreConfig::default-new-layer-mode instead.
2017-08-20 15:02:46 +02:00
Michael Natterer a256cf3338 app: add GimpCoreConfig::default-new-layer-mode
which for now has no UI and still defaults to NORMAL_LEGACY.
2017-08-20 14:09:35 +02:00
Michael Natterer b89d10a830 app: fix compositing of non-LEGACY layers in "show mask" mode
gimp_layer_update_mode_node(): when showing the mask, set mode to
NORMAL, and make sure that the composite space is PERCEPTUAL for
LEGACY layers, and LINEAR (or whatever is chosen in layer attibutes)
otherwise.
2017-08-20 14:09:35 +02:00
Michael Natterer 730573375d app: use GIMP_LAYER_MODE_NORMAL for most tests in app/tests/ 2017-08-20 14:09:35 +02: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
Michael Natterer 58a68f5e98 app: add a missing case to a switch in GimpToolRectangle
The case's code was there but unreachable. This fix probably makes no
difference, but it was broken.
2017-08-19 20:05:00 +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
Michael Natterer 94c6bb4603 Bug 783755 - Smudge should blend the smudged colors using linear RGB
Looked a bit deeper into heal: while I didn't try to understand what
it's actually doing, this is strange: there is a comment that says
that healing should done in perceptual space, and the code uses
R'G'B'A float (at least it completely did before the last commit).

On the other hand, the code adds and subtracts temporary buffers,
which screams "gamma artifacts" unless done in linear space.

This commit changes everything to use linear float buffers,
and removes the comment. It "looks" right to me now, please test.
2017-08-18 23:54:26 +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 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
Øyvind Kolås 4410ab0db0 bump required GEGL version to 0.3.20 2017-08-15 23:11:12 +02:00
Jehan a3cd156265 app: remove useless double space.
I don't think there is any good reason for the distance/angle to be
separated by 2 spaces from the status message.
2017-08-15 21:12:17 +02:00
Jehan 78244f9cb5 Bug 785816 - show angle in degrees when drawing straight lines.
Paint tools in straight line mode (shift click) will now display the
angle in status bar. Angle 0 is considered as the horizontal line from
left to right, and angle is measured counterclockwise from there, which
is the most common convention.
2017-08-15 20:57:50 +02:00
Øyvind Kolås 90a808e863 bump required babl version to 0.1.30 2017-08-15 20:54:05 +02:00
Michael Natterer b926de5ada Bug 783755 - Smudge should blend the smudged colors using linear RGB
Use GIMP_LAYER_MODE_NORMAL (not NORMAL_LEGACY) when falling back from
gimp_paint_core_replace() to gimp_paint_core_paste() for layers
without alpha. Adapt the format of the used paint buffers accordingly.
2017-08-12 21:35:47 +02:00
Michael Natterer 26a238c5fb app: default the number of threads used to g_get_num_processors()
Let the bug reporting begin.
2017-08-08 23:03:20 +02:00
Ell 67fc418c3c app: adapt gimp_image_merge_layers() to handle pass-through groups ...
... and fix flatten-image along the way.  *And* do some cleanup.

Currently, gimp_image_merge_layers() combines the layers on its own,
one by one.  This is incompatible with pass-through groups, because
the group's buffer is rendered independently of its backdrop, while
we need to take the backdrop into account when mergeing the group.

Instead, render the subgraph of the parent graph, corresponding to
the set of merged layers, directly into the new layer.  Since the
layers we merge are always visible and continuous, all we need is a
minor massage to the parent graph to make it work.  This takes care
of pass-through groups intrinsicly.

This commit also changes the behavior of flatten-image:  Currently,
the flattened layers are rendered directly on top of the opaque
background, which can make previously-hidden areas (due to layers
using composite modes other than src-over, or legacy layer modes)
visible.  This is almost certainly not desirable.

Instead, construct the graph such that the flattened layers are
combined with the background only after being merged with one
another.
2017-08-08 15:39:28 -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 1ca1e15dd0 app: implement {begin,end}_render() for GimpGroupLayer
Use them to connect/disconnect the stack graph when the group is
in pass-through mode.
2017-08-08 15:39:28 -04:00
Ell 1c68617302 app: use {begin,end}_render() and GimpTileHandlerProjectable ...
... in GimpProjection and gimp_display_shell_render() (the latter
is not really necessary, but whatever.)
2017-08-08 15:39:27 -04:00
Ell 426bc371cd app: add GimpTileHandlerProjectable
GimpTileHandlerProjectable is similar to GimpTileHandlerValidate,
except that it calls {begin,end}_render() on its associated
projectable before validating.
2017-08-08 15:39:27 -04:00
Ell f0aec02dff app: add gimp_projectable_{begin,end}_render()
In pass-through mode, the group layer-stack's input is connected to
the backdrop.  However, when rendering the group's projection, we
want to render the stack independently of the backdrop.
Unfortunately, we can't use the stack's graph as a subgraph of two
different graphs.

To work around that, the next few commits add a mechanism for a
projectable to be notified before and after its graph is being
rendered.  We use this mechanism to disconnect the stack's graph
from the backdrop before rendering the projection, and reconnect
it afterwards.  Yep, it's ugly, but it's better than having to
maintain n copies of (each node of) the graph (each nesting level
requires an extra copy.)

This commit adds {begin,end}_render() functions to GimpProjectable.
These functions should be called right before/after rendering the
projectable's graph.
2017-08-08 15:39:27 -04:00
Ell dc1d61ff91 app: handle excludes_backdrop in GimpGroupLayer
When any of the children of a pass-through group excludes its
backdrop, the group itself should exclude the backdrop too.  Override
get_excludes_backdrop() to follow this logic, and call
update_excludes_backdrop() when this condition might change.

Note that we always composite pass-through groups using src-over mode,
so to actually hide the backdrop, we need to disconnect it from the
group's mode node's input pad (and reconnect it, when the backdrop is
no longer hidden).
2017-08-08 15:39:27 -04:00
Ell 10371ec22f app: implement pass-through mode in GimpGroupLayer
Override GimpDrawable::get_source_node() for GimpGroupLayer.  Use
a node that contains both the drawable's buffer-source node, and the
layer stack's graph node.  Choose which one of these to connect to
the source node's output based on the group's layer mode: the stack
graph for pass-through mode, and the buffer-source node for all the
rest.

When in pass-through mode, connect the source node's input (which
receives the backdrop) to the stack graph's input.  Keep maintaining
the projection in pass-through mode.  ATM, the projection uses the
same graph as the source node, so it's rendered against the group's
backdrop -- we don't want that.  The next few commits fix it.

Update the group's drawable directly upon filter stack update in
pass-though mode, because the group's graph doesn't go through the
projection.

TODO: if any of the group's children (or a child of a nested pass-
through group, etc.) uses dst-atop/src-in, this needs special
attention.
2017-08-08 15:39:27 -04:00
Ell ac3190215b app: connect layer backdrop to source node's input
Make sure the input of the layer's filter node is connected to its
source node (when it has an input pad), so that, once we implement
pass-though mode, the group's source node can see the backdrop.
2017-08-08 15:39:27 -04:00
Ell 785a0834a2 app: add GimpDrawable::get_source_node() vfunc
For pass-through groups, we want to use the group's layer-stack
graph directly in its filter node, in place of the drawable's
buffer-source node.  Add a get_source_node() vfunc to GimpDrawable,
which defaults to returning the buffer-source node, and use it in
gimp_drawable_get_source_node() instead of using the buffer-source
node directly.  We'll later override this function for
GimpGroupLayer.
2017-08-08 15:39:26 -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
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 c41e8eca86 Bug 785535 - Histogram not updating in real when filters are active
Add "gboolean with_filters" to gimp_drawable_calculate_histogram(),
which is passed as FALSE in almost all places, except the histogram
dockable where we want to see both the drawable's unmodified histogram
*and* the histogram after filters are applied.
2017-08-05 17:15:31 +02: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 bf6c3cb4ba app: add gimp_drawable_has_filters()
which returns TRUE if the drawable has any visible filter.
2017-08-05 15:37:56 +02:00
Ell 2d11d29157 app: improve GimpToolLine slider motion clamping/constraint
During constrained motion, round the slider value before clamping
it, so that the slider limits are always enforced.  Additionally,
snap the slider to 1/12-ths of the line length, rather than
1/24-ths.

Make sure that sliders can never have negative-zero values, which
can result in a -inf base for spiral.
2017-07-30 14:03:03 -04:00
Jehan 7c171b4df9 app: exclusive visibility in item group only toggles within the group.
Shift-click should actually toggle only within a given group. The new
capability of toggling only a sub-item, brought by commit 970e9ac is
still feasible in 2 steps: first toggling the parent (item group), then
the desired child.
It brings now a third possibility with exclusive toggle among many
children items, without touching other groups and top-level items.
2017-07-30 16:35:37 +02:00
Ell 06a4e1549f app: swap base and balance slider order in spiral
... so that when the base and balance sliders overlap, the base
slider is the one that's picked, since the balance slider is
constrained by the base, but not the other way around.
2017-07-30 07:40:44 -04:00
Ell 8e946ca307 app: don't calculate balance when base == 1 in spiral, to avoid NaN 2017-07-30 07:25:30 -04:00
Michael Natterer 1acaa4444b app: make number-of-threads default value calculation less obfuscated 2017-07-29 00:08:59 +02:00
Ell eef09abf3a app, menus: add gegl:spiral to the menus 2017-07-28 17:48:03 -04:00
Jehan 1ec2bccc8a app, docs: s/in order do/in order to/. 2017-07-28 23:11:48 +02:00
Jehan 1941e5139e app: minor s/placeolder/placeholder/ 2017-07-28 22:57:09 +02:00
Ell 8121769dc9 app: don't propagate NULL error when saving XCFs
xcf_save_foo() can fail without setting the error object, in which
case trying to propagate it emits a CRITICAL.
2017-07-28 16:51:08 -04:00
Ell 6b84293078 app: limit allowable tile data size in XCFs
When loading tiles from an XCF, reject tiles whose on-disk size is
greater than 1.5 times the size of an uncompressed tile -- a limit
that is already present for the last tile in the buffer.  This
should allow for the possibility of negative compression, while
restricting placing a realistic limit.

Currently, no limit is placed on the on-disk tile data size.  When
loading RLE- and zlib-compressed tiles, a buffer large enough to
hold the entire on-disk tile data, up to 2GB, is allocated on the
stack, and the data is read into it.  If the file is smaller than
the reported tile data size, the area of the buffer past the end
of the file is not touched.  This allows a malicious XCF to write
up to 2GB of arbitrary data, at an arbitrary offset, up to 2GB,
below the stack.

Note that a similar issue had existed for earlier versions of GIMP
(see commit d7a9e6079d), however,
since prior to 2.9 the tile data buffer was allocated on the heap,
the potential risk is far smaller.
2017-07-28 16:51:08 -04:00
Michael Natterer 7a10afca39 app: turn magic matching debug output into GIMP_LOG() 2017-07-28 22:35:13 +02:00
Michael Natterer d227a0d71f app: disable gimp_display_shell_profile_update() debug output 2017-07-28 22:34:41 +02:00
Michael Natterer bb93e3401f Bug 785427 - GIMP crashes after applying any GEGL filter
Need to access GimpSettings' "time" property using gint64 variables
now.
2017-07-27 22:20:09 +02:00
Michael Natterer 2a7a53b384 Bug 785240 - Naming the first color in a new palette is hard
Use the proper API to select a newly added palette color, so all
internal states are updated and the entry becomes editable.
2017-07-25 22:50:15 +02:00
Michael Natterer 713995e27d Bug 784261 - Have some nice error message for formats known to work...
...with known plugins

Add new plug-in file-raw-placeholder.c that registers itself for
loading all RAW formats from file-raw/file-formats.h, but does nothing
except returning an error message pointing to darktable and
RawTherapee.

When no real RAW loader is installed, this plug-in is selected
automatically as RAW loader, otherwise the first installed RAW loader
is used. Selecting another in prefs still works as before.
2017-07-24 22:19:53 +02:00
Michael Natterer 287cfb1413 app: some more g_clear_pointer() in gimp_plug_in_manager_finalize() 2017-07-24 22:18:54 +02:00