Commit Graph

5774 Commits

Author SHA1 Message Date
3a34f80d45 Issue #4068: default pixel density should be 72.0 for loaded images.
New images should obviously still default to the template pixel density
(defaulting to 300.0 PPI when no specific template is selected).

Loaded images though should use a more conservative default of 72 PPI,
first because this is what other software defaults to when no density is
set (so we should keep consistent when possible), and this is also what
the Exif standard (I checked both last version 2.32, and older 2.3)
recommends when no resolution is set.

Technically we differentiate a loaded from a newly created image by
whether or not an imported_file has been set. Of course, any explicitly
set resolution will always override whatever default.

(cherry picked from commit fef9b1d2a3)
2019-10-12 17:12:15 +02:00
Ell
ada1a3cf69 app: clip floating selection to layers with no alpha channel
Alawys clip a floating selection to its base layer, if the layer
has no alpha channel.  This avoids arbitrarily filling the extended
regions of the layer with, or compositing the floating selection
against, black color.

This is a temporary solution.  Ideally, we'd automatically add an
alpha channel to the layer as necessary.

(cherry picked from commit 7a8c79e7e75812d683430be163950b68a3d3498a)
2019-10-03 22:20:46 +03:00
Ell
3bb181cb03 app: update drawable bounding box when detaching floating selection
(cherry picked from commit 783b475b7b)
2019-10-03 21:31:28 +03:00
Ell
97c549198e app: avoid dropping cached data when committing filters
In gimp_gegl_apply_cached_operation(), add a boolean
connect_src_buffer parameter, which determines whether to connect
the source buffer to the operation-node's input, or to use its
existing input.  In gimp_drawable_merge_filter(), pass FALSE for
connect_src_buffer, so that the existing filter-node input is used.
This produces an equivalent result, however, it avoids invalidating
the filter node, and dropping cached data as a result.  In
operations that cache larger areas than the ROI, this avoids
reprocessing already-cached data when processing the rest of the
operation.

Additionally, in gimp_gegl_apply_cached_operation(), use an empty
input for the operation if src_buffer is NULL and
connect_src_buffer is TRUE; previously, we'd use the operation-
node's existing input when src_buffer was NULL.  Furthermore, crop
the operation-node's input to the destination rect when crop_input
is TRUE, even if connect_src_buffer is FALSE.

(cherry picked from commit 11629fde66)
2019-10-03 20:12:23 +03:00
Ell
eb0cf2d3f5 app: update drawable bounding box when floating-selection bounding box changes
When the bounding box of a floating selection changes, update the
bounding box of the associated drawable, since floating selections
are no longer clipped to the drawable's bounds in general.

(cherry picked from commit ec6bbd1937)
2019-10-02 21:35:23 +03:00
Ell
72eeee39db Issue #2837 - Floating selection is clipped to base layer
When attaching a floating selection to a layer, don't clip the
floating selection to the layer's boundary, and instead resize the
layer to include the entire floating selection when it's anchored.
As per the last commit, this can be prevented by locking the
layer's position.

(cherry picked from commit 64b979c2f3)
2019-10-02 18:22:28 +03:00
Ell
58e486ad93 app: don't resize layer when applying filter if its position/size are locked
When applying a filter to a layer whose position and size are
locked, avoid resizing the layer to the result size in ADJUST mode.
We do this by always returning GIMP_TRANSFORM_RESIZE_CLIP in
gimp_item_get_clip() when the position is locked, and properly
updating the drawable-filter's clip mode, and the filter-tool's UI,
when the position lock changes.

(cherry picked from commit 6ed6cd78d8)
2019-10-02 18:22:27 +03:00
Ell
dd1525cf75 app: add missing change to last commit
(cherry picked from commit 24731851e4)
2019-09-28 11:36:30 +03:00
Ell
a93d410916 app: avoid updating image bounding box multiple times when reordering layer
Add internal gimp_image_{freeze,thaw}_bounding_box() functions, and
use them in gimp_image_reorder_item() to avoid updating the
bounding box multiple times while moving a layer across group
boundary, to prevent flickering.

(cherry picked from commit a6ebbfe317)
2019-09-28 11:14:16 +03:00
Ell
e4c7f869c4 app: update image bounding box when moving layer inside/outside of group
In GimpImage, update the image's bounding box in response to the
layer container's "add" and "remove" signals, instead of during
gimp_image_{add,remove}_layer(), so that the bounding box is
properly updated when moving an existing layer inside/outside of a
layer group, instead of only when adding/removing a new layer.

Even though moving a layer across group boundary doesn't change the
overall image bounding box, it does change the group's bounding
box, affecting the image bounding box.  It's therefore necessary to
update the image bounding box again when the layer is re-added to
the layer stack, so that the bounding box doesn't get stuck in an
intermediate state.

(cherry picked from commit 2a753170b9)
2019-09-28 11:14:16 +03:00
a19f03486e --verbose messages don't need to be translatable. 2019-09-26 23:56:41 +00:00
Ell
7132dd0355 app: handle buffers with arbitrary origin in gimp_layer_new_from_gegl_buffer()
... by translating the layer according to the buffer's origin.

(cherry picked from commit 6ef21ed1f0)
2019-09-19 20:24:49 +03:00
Ell
d3e1f50b13 app, meson.build: fix a bunch of warnings in C++ files
(cherry picked from commit 4fc345183b)
2019-09-12 20:05:45 +03:00
Ell
d8622989e3 app: fix empty mask when duplicating a group layer
In gimp_group_layer_mask_changed(), avoid recalculating the group's
bounding box if it hasn't been calculated yet, since, not only is
this unnecessary in this case, but it causes the group's mask to
be erroneously clipped upon duplication, when set by
gimp_layer_duplicate() while the group is still empty.

(cherry picked from commit 184762cd81)
2019-09-07 10:37:24 +03:00
07f8662dc0 Revert the *enums.c part of the last commit
- it was changing generated files
- no dialog-specific mnemonics on generic enum labels
2019-09-06 09:46:48 +03:00
Ell
09c7714021 app: add "show all" support to the bucket-fill tool in "fill similar colors" mode
In the bucket-fill tool, allow using the tool outside the canvas
bounds with "sample merged" active in "fill similar colors" mode,
when the current display is in "show all" mode.  Additionally,
ignore "sample merged" in "fill whole selection" mode, on which it
has no effect.

(cherry picked from commit 17f8cff6f6)
2019-09-05 18:04:22 +03:00
Ell
897426c4e1 app: in gimp_pickable_contiguous_region_by_seed(), add support for arbitrary buffer extents
(cherry picked from commit 99759a57e8)
2019-09-05 18:04:21 +03:00
35df110a05 Missing mnemonics on several dialogs
paste as brush, paste as pattern, select to new brush, select to new pattern
fill selection outline, fill path, stroke selection, distort, rounded rectangle
indexed color conversion, merge visible layers, new guide, new guide (by percent)
image properties, newsprint, fractal explorer, sample colorize, new layer

metadata editor (just a button), spyroplus (only common buttons)
2019-09-05 12:44:17 +00:00
Ell
5e59e5c002 app: add support for color picking in "show all" mode
Add a show_all parameter to gimp_image_pick_color(), which, when
TRUE, allows picking colors outside the canvas bounds in sample-
merged mode.  Forward the display's "show all" mode through this
parameter where applicable (in particular, in the color-picker tool
and the pointer dockable).
2019-09-04 20:56:24 +03:00
Ell
8b90240928 app: fix gimp_projection_get_pixel_at() for general bounding boxes 2019-09-04 20:56:24 +03:00
Ell
b8377fd341 app: add GimpImageViewable class
Add a new GimpImageViewable class, which acts as a proxy viewable
for an image.  Unlike the image itself, whose preview is always
restricted to the size of the canvas, a GimpImageViewable provides
a show-all property, which controls whether the preview includes
the full image contents.  We're going to use GimpImageViewable as
the source viewable for GimpNavigationView.
2019-09-04 20:56:23 +03:00
Ell
4d2b713a08 app: defer GimpViewable::size-changed signal emission while frozen
In GimpViewable, defer emission of the size-changed signal while
the viewable's preview is frozen, and only emit the signal once
thawed.
2019-09-04 20:56:23 +03:00
Ell
ceb8b398ca app: in GimpImage, ignore "show all" when image used as pickable
In GimpImage, make sure the image's pickable interface keeps
behaving as before (i.e., restricted to the canvas size), even when
the image is in "show all" mode.  In contrast, the image's
projection, when used as a pickable, *is* affected by "show all".
2019-09-04 20:56:23 +03:00
Ell
2e30ec353a app: add gimp_image_invalidate_all()
... which invalidates the entire image.  This replaces all calls to
gimp_image_invalidate() with the full canvas size, since the image
content can now be larger than the canvas.
2019-09-04 20:56:23 +03:00
Ell
94cdbacca7 app: add "show all" mode to GimpImage
Add a "show all" mode to GimpImage, which, when active, causes the
image projection's bounding box to be adjusted dynamically to the
combined bounding box of all layers and the canvas.  This mode is
controlled through the new gimp_image_{inc,dec}_show_all()
functions, which should be called by the display; a corresponding
display toggle will be added in the following commits.

Note that from the user's perspective, "show all" is a display
mode, rather than an image mode.  The GimpImage "show all" mode is
therefore merely an implementation detail, and shouldn't have any
effect on displays that don't use "show all" mode, or the PDB.
The ability to use the image with or without taking its "show all"
mode into account will be facilitated by the next commits.
2019-09-04 20:56:23 +03:00
Ell
3587c0a7d2 app: notify GimpProjection::buffer when freeing the projection's buffer
... instead of only when subsequently reallocating it, so that
listeners can respond to the buffer being freed.
2019-09-04 20:56:23 +03:00
Ell
66d7dc76aa app: in GimpProjection, avoid invalidating preview on flush while rendering
In GimpProjection, avoid erroneously invalidating the projectable's
preview when flushing the projection and there's nothing to be
flushed, if the chunk renderer is still running, and hence the
projection is not fully rendered yet.
2019-09-04 20:56:23 +03:00
7fc9357452 Issue #3263: fix critical error on bucket fill tool.
Fixes the error:
> Critical error: gimp_line_art_thaw: assertion 'line_art->priv->frozen'

This may happen in cases when we didn't actually freeze the line art at
pointer click, because we were in an invalid case (for instance,
clicking out of selection), hence we must not thaw the line art either
at button release.

(cherry picked from commit 6391b2bcff)
2019-08-27 12:45:21 +02:00
Ell
409853a03b app: update projection-buffer extent when projectable size changes
In GimpProjection, when the projectable's size changes, while its
offset remains the same, simply update the projection buffer's
extent, instead of allocating a new buffer and copying the contents
over.

(cherry picked from commit 1577174739)
2019-08-13 17:44:26 +03:00
Ell
52c66bca5e app: add gimp_image_transform()
Add a new gimp_image_transform() function, which transforms the
entire image, including all layers, channels (including selection
mask), vectors, guides, and sample points, according to a
transformation matrix.  The canvas is resized according to the
clip_result parameter, the same way drawables are resized during
transformation; the layers are resized using ADJUST mode
regardless.

(cherry picked from commit c45f1b4148)
2019-08-11 00:29:33 +03:00
Ell
2558d77d1c app: add gimp_image_flip_full()
... which takes the symmetry axis as a parameter, instead of hard-
coding the axis to the middle of the image, and which additionally
takes the clipping mode as a parameter, controlling whether to clip
or resize the canvas.  Note that the actual canvas size never
changes, but it may be offset when flipped around an off-center
axis, without clipping.

Implement gimp_image_flip() in terms of gimp_image_flip_full().

(cherry picked from commit ae080f06f9)
2019-08-11 00:29:32 +03:00
Ell
20dd07ca45 app: fix sample-point OOB check in gimp_image_resize[_with_layers]()
(cherry picked from commit d13c6ce3e0)
2019-08-11 00:29:32 +03:00
Ell
f221b424c0 app, pdb: use gimp_item_get_clip() everywhere
Remove the special clipping-mode handling for channels throughout
the transform (and drawable-filter) code, and rather use
gimp_item_get_clip(), added in the previous commit, instead.  As
mentioned in the previous commit, we only modify the clipping mode
in top-level code, while having lower-level code use the clipping
mode as-is.  This not only hides the actual clipping-mode logic
from the transform code, but, in particular, allows code performing
transformation internally to use arbitrary clipping modes.

Also, this commit fixes a bunch of PDB bugs all over the place :)
2019-08-09 22:24:03 +03:00
Ell
3a7972e5fb app: add gimp_item_get_clip()
Add a new GimpItem::get_clip() virtual function, and a
corresponding gimp_item_get_clip() function, which return the
actual clipping mode to be used when transforming (or applying a
filter to) a given item, given the original clipping mode.  This
applies only to whole-item transformations (i.e., when not creating
a floating selection), and should be used by the top-level code
applying the transformation, rather than by the actual
transformation code, so that the item can be transformed using a
different clipping mode internally.

Provide a default implementation that simply returns the input
clipping mode, and override for GimpChannel (to always return CLIP)
and for GimpVecotrs (to always return ADJUST).

(cherry picked from commit d5cdcc6c02)
2019-08-09 22:23:57 +03:00
Ell
a0d43cd927 app: fix layer-mask offset when applying filter to layer without clipping
(cherry picked from commit f9fb3e6fad)
2019-08-09 22:23:57 +03:00
Ell
037bc8575e app: limit color-history palette size
Limit the color-history palette size (currently, to 256 colors), to
avoid slowdowns, especially during loading.

(cherry picked from commit 07b7d63a7d)
2019-08-07 19:20:59 +03:00
Ell
8d15563f4c Issue #3718 - Large colorrc file causes lag when painting with a new color
In gimp_palette_mru_add(), if the added color doesn't match an
existing color, don't look for two duplicate existing colors (which
has quadratic complexity), since there shouldn't be any under
normal circumstances (as we're not adding duplicates to begin
with).

(cherry picked from commit e60829767e)
2019-08-07 19:20:58 +03:00
Ell
97d666ff41 app: add gimp_drawable_filter_set_clip()
In GimpDrawableFilter, add a new gimp_drawable_filter_set_clip()
function, which controls whether the filter clips the result to the
drawable's boundary, or extends it past it.  The latter is only
possible for layers, when the selection mask is empty.

(cherry picked from commit b7f53262fc)
2019-08-02 00:40:27 +03:00
Ell
ed46ba4ded app: add "clip" parameter to gimp_drawable_merge_filter()
Add a new "clip" parameter to gimp_drawable_merge_filter().  When
set to FALSE, the function resizes the drawable to the bounding box
of the filter's output, instead of clipping the output to the
drawable's boundary.

(cherry picked from commit 89a9cf7e49)
2019-08-02 00:40:27 +03:00
Ell
8c7d13541d app: calculate bounding box of group layers
In GimpGroupLayer, when recalculating the group's size as a result
of a change to one of the child layers (now including in response
to a child layer's GimpDrawable::bounding-box-changed signal),
calculate the group's bounding box (the bounding box of all its
child layers' bounding boxes) alongside its logical bounds.  Like
in GimpLayer, use the logical bounds as the bounding box if the
group has a mask.

This bounding box is passed to the group's projection, via
GimpGroupLayer's GimpProjectable::get_bounding_box()
implementation, resulting in a buffer whose extent is the same as
the bounding box.

(cherry picked from commit ad1f3d20fb)
2019-08-02 00:40:25 +03:00
Ell
1359c1cb47 app: add support for projectables with an arbitrary bounding box
In GimpProjectable, replace gimp_projectable_get_size(), which only
returned a width and a height, with
gimp_projectable_get_bounding_box(), which returns a full
rectangle.  This allows projectables to have an arbitrary bounding
box, not limited to a (0, 0) top-left corner.

Adapt GimpProjection, creating a buffer with corresponding extent
to the projectable's bounding box.

Adapt GimpImage and GimpGroupLayer.

(cherry picked from commit 8ff43942d6)
2019-08-02 00:40:24 +03:00
Ell
ea27923868 app: implement GimpDrawable::get_bounding_box() for GimpLayer
Implement GimpDrawable::get_bounding_box() for GimpLayer, by
returning the bounding box of its source node.  If the layer has a
mask, we simply return its logical boundary, since the layer can't
extend past the mask.

(cherry picked from commit 7a05d15f7e)
2019-08-02 00:40:24 +03:00
Ell
917f46f184 app: maintain drawable bounding box separately from its logical boundary
Maintain the bounding box of drawables (i.e., the bounds of their
actual rendered content) separately from their logical boundary (as
shown in the UI).

The bounding box is calculated through the new
GimpDrawable::get_bounding_box() virtual function, which has a
corresponding gimp_drawable_get_bounding_box() function; the
default implementation simply returns the drawable's logical
boundary.  The bounding box is specified in drawable coordinates,
i.e., it's not affected by the drawable's offset.

The bounding box is recalculated through
gimp_drawable_update_bounding_box(), which should be called
whenever a change may affect the bounding box (for example, when
setting a new buffer, as done implicitly by GimpDrawable's
::set_buffer() implementation, or when a drawable filter's
properties change, as will be done by GimpDrawableFilter in a
following commit).  When the bounding box changes, the affected
regions of the drawable are updated, and the
GimpDrawable::bounding-box-changed signal is emitted.

When gimp_drawable_update() is called with negative width/height
values, the entire drawable's bounding box is updated, rather than
only its logical boundary.

Likewise, GimpDrawableStack and GimpLayerStack are adapted to use
the bounding box, instead of the logical bounds, when updating the
drawable's area.

(cherry picked from commit 153cb33eec)
2019-08-02 00:40:23 +03:00
Ell
c217876a47 app: in GimpDrawable::set_buffer(), take bounds rect instead of offset only
In GimpDrawable::set_buffer(), and the corresponding
gimp_drawable_set_buffer_full() function, take a bounds rectangle,
which specifies both the drawable's new offset and its new size,
instead of only taking the new offset.  In
gimp_drawable_real_set_buffer(), set the item size according to the
rect dimensions, instead of the buffer dimensions.  The rect's
width/height may be 0, in which case the buffer's dimensions are
used.

Adapt the rest of the code.

We do this in preparation for maintaining the drawable's bounding
box separately from its logical bounds, allowing the drawable
content to extend beyond its bounds.

(cherry picked from commit 3afdd7c5c2)
2019-08-02 00:40:17 +03:00
Ell
2bdbc2f16d app: fix #include in gimpdrawable.c
Local foo leak.

(cherry picked from commit 2331b88d7d)
2019-07-30 21:37:02 +03:00
Ell
29aede6722 app: guarantee fully-COWed copies in more cases in paint code
(cherry picked from commit fb679f9efa)
2019-07-30 20:32:56 +03:00
Ell
ca98ff3c27 app: use gimp_gegl_buffer_dup() everywhere
... instead of gegl_buffer_dup().

(cherry picked from commit 2d80d4d138)
2019-07-30 20:32:56 +03:00
Ell
b72aad57f2 app: remove gimp_gegl_rectangle_align_to_tile_grid()
... and replace it with gegl_rectangle_align_to_buffer().

(cherry picked from commit ab94251ae9)
2019-07-30 20:32:54 +03:00
c9ded16963 Use g_ascii_dtostr() instead of g_ascii_formatd()
The latter is broken and doesn't guarantee a decimal point with the
current bug. Also, g_ascii_dtostr() doesn't need the format parameter
and produces nicer output.

(cherry picked from commit c0fb66254e)
2019-07-30 16:00:06 +02:00
Ell
07bf8c025c app: reduce time complexity of layer-group translation
When translating a layer group, avoid separately updating the
original area of the child layers before translating them (as per
the fix to issue #3484), as this results in quadratic time
complexity w.r.t. to the maximal subgroup nesting level.  Instead,
simply defer the updating of the group's offset until *after*
translating the child layers, so that their original area isn't
clipped by the parent, while their new area is still properly
updated even if the parent's size changes (see comment in code).

(cherry picked from commit ebb3ec4925)
2019-07-23 10:55:57 +03:00