Commit Graph

106 Commits

Author SHA1 Message Date
Ell 94554fcc0c app: resize group-layer mask after moving the group
We avoid resizing the mask as a result of changes in the group's
bounding box while the group is being moved (i.e., translated,
rotated, etc.), so that GimpLayer transforms the original mask,
rather than a cropped mask.  We still need to crop the mask after
we're finished moving the group, however.  This commit takes care
of that.
2018-02-07 09:54:08 -05:00
Ell e7a2624a85 app: fix undo when resizing a group layer with a mask
Override GimpItem::resize(), instead of GimpLayer::resize(), when
resizing a group layer, so that GimpLayer doesn't try to resize the
mask.  Instead, the let the usual mask resizing logic in
GimpGroupLayer handle that.

Also, make sure that the mask is properly restored upon undo when
group resizing is suspended outside of any mask-suspension block,
which can happen when resizing the group.
2018-02-05 15:15:21 -05:00
Ell 36dec4e6b0 Bug 51112 - Support layer masks on layer groups
Add layer-mask support for group layers.  Group-layer masks work
similarly to ordinary-layer masks, with the following
considerations:

The group's mask size is the same as group's size (i.e., the
bounding box of its children) at all times.  When the group's size
changes, the mask is cropped to the new size -- areas of the mask
that fall outside of the new bounds are discarded and their data is
lost (sans undo), and newly added areas are filled with black (and
hence are transparent by default).

The new gimp_group_layer_{suspend,resume}_mask() functions can be
used to modify this behavior.  Between the outermost pair of
suspend/resume calls, the old mask data is remembered, and is used
to fill the newly added areas while cropping the mask when the
group is resized.  We override GimpItem::{start,end}_move() for
GimpLayer, to call these functions (suspend() in start_move(), and
resume() in end_move()) for each of the layer's ancestors.

As a result, while moving a layer, or a set of layers, atomically,
such as while dragging with the move tool, or moving linked layers,
the ancestors' mask data is not lost, and is only discarded at the
end of the operation.

This commit also takes care of properly handling undo for group-
layer mask crops, properly invalidating the image when the group
layer's mask is shown, and enabling the mask actions for group
layers (obviously :).
2018-02-05 12:08:54 -05:00
Michael Natterer 6d075aa10a app: some cleanup in the first of the two assert removals below 2018-01-23 19:50:07 +01:00
Jehan f87bc3fe09 app: we should not have any g_assert*() code if possible.
Replace all g_assert_not_reached() in app/core/ by g_return_if_reached()
or g_return_val_if_reached(). GIMP may handle a lot of creative work,
sometimes unsaved for hours. We should not just crash on purpose.
g_assert*() could theoretically be turned off on a glib build, but this
is nearly never done, and is not a solution either (actually it is
probably even worse because the broken code would just continue on a
forbidden path). It is much better to return with a warning on such
forbidden code paths, allowing someone to report a bug without
experiencing a crash and data loss.

For now, I only took care of g_assert_not_reached() inside app/core.
More g_assert*() code should be replaced.
Note: assert are acceptable in plug-ins though, but not in the main
executable, unless absolutely necessary (something happening so bad that
crash is better than continuing).
2018-01-22 12:46:37 +01:00
Ell fa9a023c27 app: strength-reduce pass-through groups to normal groups
Override GimpLayer::get_effective_mode() in GimpGroupLayer, to
perform strength-reduction of pass-through groups to normal groups
under certain conditions (see gimp_group_layer_get_effective_mode()
for the logic.)

The main motivation for this is the fact that Photoshop uses pass-
through mode as the default mode for groups, resulting in many PSDs
using pass-through groups generously and unnecessarily.  Since
pass-through groups are more expensive that normal groups, reducing
them to normal groups when possible can make a big difference.

Note that, while the results of the strength-reduced composition
are theoretically equivalent, there may be small differences in
practice due to numerical errors, especially when using low
precision.  This is unlikely to be an issue, but, just in case,
allow disabling this optimization using the
GIMP_NO_PASS_THROUGH_STRENGTH_REDUCTION environment variable.
2017-12-06 14:51:47 -05:00
Ell f5d1686a21 app: add GimpFilter::active property; move ::visible to GimpItem
Add an "active" property to GimpFilter, which replaces its
"visible" property.  The new property assumes the lower-level role
"visible" had -- controlling whether the filter has any effect as
part of its parent filter-stack.

Add a "visible" property to GimpItem, separate from the "active"
property, which assumes the higher-level role "visible" had --
controlling whether the item is considered "visible", as per the
GUI.  By default, the item's "visible" property is bound to the
filter's "active" property, so that changes in visibility directly
affect the filter's "activeness"; this binding can be controlled
using the new gimp_item_bind_visible_to_active() function.

This distinction is currently necessary for floating selections.
Floating selection layers must not be active in their parent stack,
regardless of their visibility, in particular, so that their mode
node doesn't hide the entire backdrop when their composite mode
excludes the backdrop (i.e., when it's dst-atop or src-in).
Instead, their visibility should affect the activeness of the
floating-selection filter of the drawable they're attached to.
This is handled by the next commit.
2017-12-05 16:12:46 -05:00
Ell e042c82d59 app: flush group proj. switching from pass-through to non-pass-through
When switching a group layer from pass-through mode to a non-pass-
through mode, flush the projection synchrnously, to make sure that
the projection's buffer gets properly invalidated at that point,
and can be subsequently used as a source for the rest of the
composition.

Add a boolean 'pass_through' member to GimpGroupLayerPrivate, which
indicates if the group is a pass-through group, and use it instead
of checking the group's mode, so that we can detect that the group
used to be a pass-through group when the mode changes, and to
simplify the rest of the code.
2017-12-02 15:35:08 -05:00
Ell 9f79be44f8 app: flush pass-through groups' projection asynchronously
The source node of pass-through groups doesn't use the projection's
buffer, hence there's no need to invalidate it synchronously, which
is faster.
2017-12-02 10:38:34 -05:00
Ell be97b97a2b app: set group layer projection priority according to depth
Set the priority of group-layer projections according to the group
layer's depth, so that top-level groups have a priority of 1
(compared to a priority of 0 for the image projection), and nested
groups have a priority one greater than their parent (in other
words, shallower groups have higher priority than deeper groups,
all of which have lower priority than the image.)

This makes pass-through groups much faster, in particular.
2017-12-02 10:38:34 -05:00
Ell 35b0f6102e app: update group-layer item offset after updating offset node
When the group's offset changes, update the item's offset *after*
updating the group's offset node, so that the item's offset nodes
and the group's offset node are in sync when the corresponding
"notify" signals are emitted.
2017-11-24 12:34:25 -05:00
Ell 4ded26c4f1 app: update group layer offset before calling gimp_pickable_flush()
In gimp_group_layer_update_size(), when the layer's bounds have
changed, update the group layer's offset before the call to
gimp_pickable_flush() when reallocating the projection.  Otherwise,
if the group layer's graph isn't constructed yet, it will get
constructed during the call to gimp_pickable_flush(), however,
gimp_group_layer_get_graph() will pick up the old coordinates for
the offset node.
2017-11-11 17:51:02 -05:00
Ell d027a059ef app: respond to viewable expanded state changes in container views
Add an "expanded-changed" signal to GimpViewable, which should be
emitted by subclasses when the viewable's expanded state changes.
Emit this signal when the expanded state of group layers changes.
Respond to this signal in GimpContainerView, by calling a new
expand_item() virtual function.  Implement expand_item() in
GimpContainerTreeView, expanding or collapsing the item as
necessary.
2017-10-22 12:30:21 -04:00
Michael Natterer 6dfe04e928 Bug 787848 - Duplicate image crashes if there is an empty layer group
An empty gorup layer has no extent, so we fake its extents to be at
least 1x1 whenever its projection is being recreated, because we can't
have a 0x0 buffer in a drawable. This safeguard was forgotten in
gimp_group_layer_convert_type() which gets called on image duplicate.
2017-09-18 20:31:21 +02: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 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
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 c83f0e88af app: add virtual transform/type-conversion functions to GimpLayer
The GimpLayer implementation of the GimpItem transform functions,
and the GimpDrawable convert_type() function, apply their operation
to both the layer and its mask.  The subclasses of GimpLayer --
GimpGroupLayer and GimpTextLayer -- override some of these
functions, providing their own logic for the layer part, and
duplicating the mask part.

Avoid this duplication by adding a set of virtual transform and
type-conversion functions to GimpLayer.  Have the GimpLayer
implementaion of the corresponding GimpItem and GimpDrawable
functions use these functions to apply the operation to the layer,
while taking care of the mask themselves.  Have GimpLayer's
subclasses override the new virtual functions, instead of the
GimpItem and GimpDrawable ones.

Note that the existing implementation of convert_type() in
GimpTextLayer neglected to convert the mask, hence text layer masks
retained their old format after conversion.  This issue is fixed as
a side effect of this commit.
2017-06-17 13:42:41 -04:00
Ell 07ac78ef8d app: add GimpLayerStack
A subclass of GimpDrawableStack, for layer stacks.  Invalidates the
layers' backdrop as/when necessary, according to the value of their
excludes_backdrop property.

Make gimp_drawable_stack_update() protected, instead of private, so
that we can use it in GimpLayerStack.
2017-05-11 17:44:56 -04:00
Michael Natterer 8928bcd088 Bug 777017 - creating an empty layer group inside an existing...
...layer group cause a bug in the existing layer size

Change gimp_group_layer_get_size() to return FALSE if there are no
children (there is no content).

In gimp_group_layer_update_size(), skip children where get_size()
returns FALSE. Fixes bogus size calculation.
2017-01-15 21:01:03 +01:00
Michael Natterer 87d38194d7 app, pdb: use GeglDitherMethod instead of simply an integer 2016-11-07 20:41:39 +01:00
Michael Natterer 997ae1e28b Bug 764024 - Allow to choose fill color when resizing layers and images
Add a GimpFillType argument to GimpItem::resize() and fill type
widgets to the canvas and layer resize dialogs. Fill the new parts of
the drawable according to fill type in gimp_drawable_resize(). Make
sure places that need the old behavior get GIMP_FILL_TRANSPARENT
passed by hardcoding it in the GimpItem::resize() implemetations of
channel, mask, selection etc.
2016-10-10 00:02:16 +02:00
Michael Natterer ecf4af88b8 app: add "gboolean new_has_alpha" to gimp_drawable_convert_type()
making its external API "complete". Remove the redundant
"new_base_type" and "new_precision" from the internal (vfunc) API (the
Babl format has the same information).
2016-10-04 01:39:15 +02:00
klausstaedtler 2696611d1e icons: Bug 759904
add
gimp-group-layer

patch
gimpgrouplayer.c
2016-06-10 13:50:45 +02:00
Michael Natterer 28e1a379e6 app: remove const qualifiers from all object parameters
They are unreliable because every type checking cast discards them,
they are useless anyway, visual clutter, added inconsistently, and
generally suck. Wanted to do this a long time ago, it was a bad idea
in the first place.
2016-05-19 23:54:14 +02:00
Michael Natterer ef4ab94a12 app: change GimpDrawable::convert_type() to take a target profile
instead of just a boolean "convert_profile". This takes the logic to
figure the right target profile out of gimp_layer_convert_type(), it
can't possibly know everything about how to convert anyway, and having
the logic in the callers conveniently splits it up and distributes its
parts to the places they belong.

This commit should cause no behavor change and is just preparation for
fixing bug 765176.
2016-04-30 18:35:52 +02:00
Michael Natterer ac1c6d7864 app: add progress reporting to gimp_drawable_convert_type()
so it doesn't sit there appearing to do nothing while converting an
image with profile to gamma/linear.
2015-10-21 22:22:30 +02:00
Michael Natterer 76ff1c1584 Revert "app: add ::get_color_profile() to GimpPickable and GimpProjectable"
This reverts commit 5c8ffdf6c5.

It was a bad idea, we have the GimpColorManaged interface for that.
2015-09-03 00:21:09 +02:00
Michael Natterer 5c8ffdf6c5 app: add ::get_color_profile() to GimpPickable and GimpProjectable
which currently all end in a call to gimp_color_managed_get_color_profile()
except for channels and masks. This is currently unused infrastructure but
will be used for things like layer previews, and return NULL if called
on a mask or channel, or if color management is disabled, or whatever.
2015-09-01 22:27:31 +02:00
Michael Natterer 76782e622d app: add "gboolean convert_profile" to GimpDrawable::convert_type()
also add "GType old_type" to GimpItem::convert() so implementations
can do things depending on the type of the original item.

In gimp_layer_convert(), if the original item is also a layer, and
color management is not off (with a FIXME because this is the wrong
check), pass convert_profile = TRUE to gimp_drawable_convert_type().

There is no color profile conversion anywhere behind this, this is
just an API change commit.
2015-08-16 15:56:28 +02:00
Michael Natterer b12ecc7195 app: small fix for the previous patch in gimp_group_layer_update_size() 2015-06-24 19:40:54 +02:00
Michael Natterer 2f8476bd18 app: fix update of group layers when size changes only trigger an offset change
In gimp_group_layer_update_size(), when the new size happens to be the
same as the old size, we need to call gimp_pickable_flush() on the
group projection so it is ready to be used for rendering the image,
just like in gimp_group_layer_stack_update().
2015-06-23 10:27:47 +02:00
Michael Natterer 02c9dacc8f app: s/GimpPrecision/GimpComponentType/ in gimp_projection_estimate_memsize() 2014-06-14 23:20:52 +02:00
Michael Natterer 909c4b4084 app: add a GimpCpmponentType parameter to GimpDrawable::estimate_memsize()
so we can also estimate converting the drawable to other precisions.
2014-06-14 23:12:22 +02:00
Michael Natterer 7647b0d3a0 Bug 730550 - Layers incorrectly positioned on screen
gimp_group_layer_update_size(): update the group layer's offset node
before reallocating the group's projection, or we might render the
group projection's buffer with the old offsets.
2014-05-22 20:48:50 +02:00
Michael Natterer 23037b5230 app: convert all stock IDs kept around by the core by icon names
Particularly GimpViewable's stock_id. Make sure old config files
containing stock IDs are still properly parsed.
2014-05-07 01:01:56 +02:00
Michael Natterer 697572ccc0 app,libgimp*: fix includes to follow our include policy
- don't include <gdk-pixbuf/gdk-pixbuf.h> in headers in app/
- instead, include it in many .c files instead of <glib-object.h>,
  finally acknowledging the fact that app/ depends on gdk-pixbuf almost
  globally
- fix up includes as if libgimpbase depended in GIO, which it soon will
2013-10-15 01:58:39 +02:00
Michael Natterer 0289eb8898 Bug 705397 - Layer groups are not exported properly/fully
In gimpgrouplayer.c always gimp_pickable_flush() after
gimp_projectable_structure_changed() so all queued updates are
actually flushed to the projection buffer's invalid area, and are
constructed upon reading. This would have been neccessary before for
group layers, but worked anyway until we changed
gimp_projection_get_buffer() to construct the buffer on idle time
initially in order to make images appear more responsively after
loading.
2013-08-04 14:52:01 +02:00
Michael Natterer 3b68ae0f3c app, pdb, libgimp: Remove all traces of the supersampling recursion level
from all transform APIs. This is no longer used since we use GEGL to
transform, the value was only passed around and never used.
2013-05-31 01:15:32 +02:00
Michael Natterer aa56bcd284 app: add new class GimpFilterStack factored out of GimpDrawableStack
and make it the parent class of GimpItemStack. Which means we now have
a generic stack of filters independent of any image items.
2013-04-11 12:25:11 +02:00
Michael Natterer d4933b3052 Bug 674160 - Redesign of "Lock panel"
Apply and heavily modify patch from remyDev which adds "lock position"
to GimpItem, similar to "lock content". Lock position disables all
sorts of translation and transform, from the GUI and the PDB.

Cleaned up some aspects of the lock content code as well because a
second instance of similar code always shows what went wrong the first
time.
2012-11-09 11:17:25 +01:00
Michael Natterer 60305c11d5 app: add "const Babl *new_format" to GimpDrawable::convert_type()
but only to the virtual function, not the public API. Implement it in
GimpSelection and GimpLayerMask, and pass the correct mask format down
to the parent class which does the actual conversion.
2012-10-13 22:56:32 +02:00
Michael Natterer 5dbcdef477 app: implement optional dithering when converting to lower bit depth
Add "layer_dither_type" and "mask_dither_type" to
GimpDrawable::convert_type(), pass around the dither type from the
dialog, and implement dithering using gegl:color-reduction.
2012-10-13 21:46:56 +02:00
Michael Natterer 1725c6c865 app: make group layer type conversion depend on less side conditions
gimp_group_layer_convert_type() required the image's precision to be
already set to the new value.
2012-09-28 20:58:40 +02:00
Michael Natterer 101a9b9887 app: make image and projection size estimations precision-aware
GimpProjection estimation was still assuming 8 bit, so was
GimpTemplate. Also, calculate GIMP_PROJECTION_IDLE_PRIORITY
inatead of hardcoding it.
2012-08-24 22:16:02 +02:00
Michael Natterer 759b71b8e9 app: remove GimpProjectable::get_layers() and ::get_channels() 2012-05-20 20:28:27 +02:00
Michael Natterer d294cfb8b2 app: remove the legacy projection construction code 2012-05-19 00:06:03 +02:00
Michael Natterer 1a624d4df4 app: remove many includes of "gegl/gimp-gegl-utils.h" 2012-05-10 23:12:39 +02:00
Michael Natterer 94da46c373 app: add precision argument to gimp_image_get_format()
and use it instead of gimp_babl_format() in some places where indexed
formats can occur. Also fix some places using gimp_babl_format() to
special case indexed formats correctly.
2012-05-07 21:46:47 +02:00