Commit Graph

21636 Commits

Author SHA1 Message Date
Ell dac9bfe334 app: add "direct" parameter to gimp_projection_flush_now()
Add a boolean "direct" parameter to gimp_projection_flush_now(),
which specifies if the projection buffer should only be invalidated
(FALSE), or rendered directly (TRUE).

Pass TRUE when flushing the projection during painting, so that the
affected regions are rendered in a single step, instead of tile-by-
tile.  We previously only invalidated the projection buffer, but
since we synchronously flush the display right after that, the
invalidated regions would still get rendered, albeit less
efficiently.

Likewise, pass TRUE when benchmarking the projection through the
debug action, and avoid flushing the display, to more accurately
measure the render time.
2018-12-02 10:14:58 -05:00
Ell 06923d0f65 app: fix iterated-over area in gimp_gegl_clear()
Iterate over the per-thread area, not the full region.
2018-12-02 03:48:32 -05:00
Ell 42b82419b1 app: another fix to drawable direct-fill criterion
Don't use a direct-buffer fill when filling using a pattern with
alpha, even when the mode is subtractive.
2018-12-02 03:43:25 -05:00
Ell 660f53d300 app: fix drawable direct-fill criterion
Don't use a direct-buffer fill if the mode is subtractive, and the
composite region includes the source.  Currently, this never
actually happens.
2018-12-02 03:33:56 -05:00
Ell dd8268c0a2 app: optimize simple whole-drawable fill/clear
In gimp_drawable_edit_fill(), when filling/clearing the whole
drawable, without any special compositing (i.e., when there's no
selection, the opacity is 100%, and the layer mode is trivial),
fill/clear the drawable's buffer directly, without using an
applicator.  This makes such operations much faster, especially in
big images.
2018-12-02 03:10:31 -05:00
Ell 45fc4cb4f9 app: add gimp_fill_options_fill_buffer()
... which is similar to gimp_fill_options_create_buffer(), however,
it fills an existing buffer, instead of creating a new buffer.

Implement gimp_fill_options_create_buffer() in terms of the new
function.
2018-12-02 03:10:30 -05:00
Ell 8adec5fb3a app: add gimp_layer_mode_is_trivial()
Add a TRIVIAL layer-mode flag, and corresponding
gimp_layer_mode_is_trivial() function, which indicates if the blend
function of a given layer mode is trivial, i.e., either never
modifies the source pixels (for non-subtractive modes), or always
clears the destination pixels (for subtractive modes).
2018-12-02 03:10:30 -05:00
Ell 2e3eab7fbd app: add gimp_gegl_clear()
... which clears the alpha component of a given buffer region,
i.e., it makes the region transparent, while preserving color
information.  This corresponds to the "edit-clear" action.
2018-12-02 03:10:29 -05:00
Ell 861f356b63 app: in GimpPaintCore, align copied undo rect to tile grid
In gimp_paint_core_finish(), when copying the relevant region of
the cached undo buffer into a new buffer, align the region to the
buffer's tile grid, so that all copied tiles are COWed.  This
avoids lag when finishing a stroke.
2018-12-02 03:10:29 -05:00
Ell bb9dd049fb app: align drawable undo rectangle to tile grid
When creating a drawable undo from the drawable's buffer, align the
copied rectangle to the buffer's tile grid, so that all the copied
tiles are COWed, saving memory and gaining speed.

Add applied_x and applied_y fields to GimpDrawableUndo, specifying
the position at which to apply the applied_buffer, so that we apply
it in the right place, even if the undo rect has changed due to
alignment.
2018-12-02 03:10:28 -05:00
Ell ce3a6c4fd6 app: use gimp_gegl_rectangle_align_to_tile_grid() in gimp:buffer-source-validate
... instead of custom code.
2018-12-02 03:10:28 -05:00
Ell 69e5f783c5 app: add gimp_gegl_rectangle_align_to_tile_grid()
... which expands a GeglRectangle, such that it's aligned to the
tile grid of a given GeglBuffer.
2018-12-02 03:10:26 -05:00
Ell f27b38808f app: a few improvements to gimp-scratch
Simplify code a bit, and add branch-prediction annotations.
2018-12-01 10:04:11 -05:00
Ell 67d595f651 app: sigh, another gimp-scratch link fix, in config/
That's the last one :)
2018-12-01 08:26:16 -05:00
Ell 471fa632cd app: fix gimp-scratch linking in tests/ 2018-12-01 07:24:50 -05:00
Ell ae6bebb981 app: fix gimp-scratch linking 2018-12-01 06:22:48 -05:00
Ell 8c9eb1c743 app: #include <string.h> in gimp-scratch.h
... for memset().
2018-12-01 06:06:27 -05:00
Ell 5d1a79a34f app: fix definition signature of gimp_scratch_get_total() 2018-12-01 05:58:10 -05:00
Ell dbab0b557d app: in Luminance mode, cache RGBA -> Y fish 2018-12-01 05:55:17 -05:00
Ell 70b7316ebc app: in Luminance mode, replace VLAs with gimp-scratch
In the Luminance layer-mode, use the scratch allocator for
allocating temporary buffers, instead of using VLAs.
GimpOperationLayerMode already allocates data on the stack,
calculated as not to overflow the stack on any platform, so having
any of its descendants also allocate big buffers on the stack is
risky.
2018-12-01 05:55:16 -05:00
Ell 698d1af798 app: add scratch-total variable to the dashboard
Add a scratch-total variable to the dashboard's misc group, showing
the total amount of memory used by the scratch allocator.
2018-12-01 05:55:16 -05:00
Ell a8a8655285 app: add gimp-scratch allocator
gimp-scratch is a fast memory allocator (on the order of magnitude
of alloca()), suitable for small (up to a few megabytes), short-
lived (usually, bound to the current stack-frame) allocations.
Unlike alloca(), gimp-scratch doesn't use the stack, and is
therefore safer, and will also serve bigger requests, by falling-
back to malloc().

The allocator itself is very simple:  We keep a per-thread stack of
cached memory blocks (allocated using the normal allocator).  When
serving an allocation request, we simply pop the top block off the
stack, and return it. If the block is too small, we replace it with
a big-enough block.  When the block is freed, we push it back to
the top of the stack (note that even though each thread uses a
separate stack, blocks can be migrated between threads, i.e.,
allocated on one thread, and freed on another thread, although this
is not really an intended usage pattern.)  The idea is that the
stacks will ultimately stabalize to contain blocks that can serve
all the encountered allocation patterns, without needing to reisze
any of the blocks; as a consequence, the amount of scratch memory
allocated at any given time should really be kept to a minimum.
2018-12-01 05:55:15 -05:00
Ell 01f9409902 app: in GimpBacktrace Linux backend, don't leak backtrace when dropping threads
Should have been part of commit
a29d040db5.
2018-12-01 04:33:45 -05:00
Ell c749097dcc app: in GimpBacktrace Linux backend, make blacklisted_thread_names const 2018-12-01 03:52:31 -05:00
Ell 6103f0e5d0 app: use gimp_async_add_callback_for_object() in the bucket-fill tool
... for the same reason as commit
7c00cf498a.
2018-11-30 04:14:59 -05:00
Ell 7c00cf498a app: use gimp_async_add_callback_for_object() in various places
Use gimp_async_add_callback_for_object(), added in the previous
commit, instead of gimp_async_add_callback(), in cases where the
destructor of the object owning the async doesn't wait for the
async to finish.  This avoids leaking such ongoing asyncs on
shutdown, during which gimp-parallel either finishes or aborts the
asyncs: if at this point an async has any registered callbacks, an
idle source is added for running the callbacks, extending the
lifetime of the async; however, since we're not getting back into
the main loop, the idle is never run, and the async (and any
associated resources) are never freed.
2018-11-30 04:14:10 -05:00
Ell 49fd2847ac app: add gimp_async_add_callback_for_object()
... which is similar to gimp_async_add_callback(), taking an
additional GObject argument.  The object is kept alive for the
duration of the callback, and the callback is automatically removed
when the object is destroyed (if it hasn't been already called).

This is analogous to g_signal_connect_object(), compared to
g_signal_connect().
2018-11-30 03:30:51 -05:00
Ell a779dd3849 app: unref async when removing last callback if idle is pending
In gimp_async_remove_callback(), if removing the last callback
while the callback idle-source is already pending, cancel the idle
source and unref the async object (the async is reffed when adding
the idle source.)
2018-11-30 03:30:51 -05:00
Øyvind Kolås 4dd3e2197a app: cache fishes per operation instance in layer-modes
There was a global 3x3 array of babl fishes used for converting between
blending and compositing pixel representations, these were all hard-coded to
operate within the sRGB babl-space family. This commit updates a per-instance
array during operation prepare instead, that comes preconfigured with fishes
derived from the correct space. Since the same operation instance might get
different space input during its life time we store and compare the cached
fishes with the current format (which is unique depending on space).

This should address the problem seen in issue #2592
2018-11-30 01:23:25 +01:00
Jehan d71efdec20 app: add the segment and spline max length options for line art.
We can't just hardcode this. On huge images in particular, you'll want
to increase this value.
2018-11-29 17:29:42 +01:00
Jehan f7a4ce1051 app: some code cleaning in gimplineart.
In particular, make simpler code in a few places, taking abyss value
into account (rather than checking the position).
2018-11-29 14:13:50 +01:00
Ell 83dd94ba6a app: use gimp_tile_handler_validate_validate() in gimp:buffer-source-validate
Use gimp_tile_handler_validate_validate(), added in the commit
before last, in gimp:buffer-source-validate, in order to pre-render
the necessary region of the buffer, instead of performing the
validation implicitly by iterating over the region.  This is both
simpler, and, more importantly, allows us to render the entire
region in a single chunk, instead of tile-by-tile, which can be
considerably more efficient, especially with high thread counts.

This essentially extends the dynamic sizing of rendered projection
chunks to layer groups, which are rendered through
gimp:buffer-source-validate, rather than just the main image
projection.
2018-11-28 13:26:40 -05:00
Ell d6f0ca5531 app: use gimp_tile_handler_validate_validate() in GimpProjection
Use gimp_tile_handler_validate_validate(), added in the last
commit, in GimpProjection, in order to render the projection,
instead of separately invalidating the buffer, undoing the
invalidation, and then rendering the graph.  This is more
efficient, and more idiomatic.
2018-11-28 13:26:38 -05:00
Ell 82a60997d4 app: add gimp_tile_handler_validate_validate()
... which validates a given rectangle directly into the buffer,
possibly intersecting it with the dirty region.  This is more
efficient than either invalidating, un-invalidating, and rendering
a given rect, as we're doing in GimpProjection, or validating the
buffer tile-by-tile, as we're doing in gimp:buffer-source-validate.
2018-11-28 13:25:34 -05:00
Ell 0ad41cfe0c app: add GimpTileHandlerValidate::validate_buffer() vfunc
... which is similar to the ::validate() vfunc, however, it should
render the result to the provided GeglBuffer, instead of to a
memory buffer.

Provide a default implementation, which uses
gegl_node_blit_buffer() if the default ::validate() implementation
is used, or, otherwise, calls uses
gegl_buffer_linear_{open,close}(), and passes the returned memory
buffer to ::validate().
2018-11-28 13:25:33 -05:00
Ell 5a623fc54b app: add GimpTileHandlerValidate::{begin,end}_validate() vfuncs
Add begin_validate() and end_validate() virtual functions, and
corresponding free functions, to GimpTileHandlerValidate.  These
functions are called before/after validation happens, and should
perform any necessary steps to prepare for validation.  The default
implementation suspends validation on tile access, so that the
assigned buffer may be accessed without causing validation.

Implement the new functions in GimpTileHandlerProjectable, by
calling gimp_projectable_begin_render() and
gimp_projectable_end_render(), respectively, instead of calling
these functions in the ::validate() implementation (which, in turn,
allows us to use the default ::validate() implementation.)

In GimpProjection, use the new functions in place of
gimp_projectable_{begin,end}_render().
2018-11-28 13:25:33 -05:00
Ell 8a47b68194 app: avoid starting the chunk renderer while finishing drawing a projection
In gimp_projection_finish_draw(), make sure we don't accidentally
re-start the chunk renderer idle source while running the remaining
iterations, in case the chunk height changes, and we need to reinit
the renderer state.
2018-11-28 13:25:32 -05:00
Ell b07f810273 app: avoid flushing bufferless projections
Don't needlessly flush projections whose buffer hasn't been
allocated yet.  This can happen when opening an image, in which
case the image is flushed before its projection has a buffer.
2018-11-28 13:25:32 -05:00
Jehan 5d4281944f app: make GimpBucketFillTool a GimpColorTool.
In particular, it allows to easily color pick. This just makes sense as
the bucket fill is definitely what one could call a "color tool", and
being able to easily change color without having to constantly switch to
color picker tool nor open a color chooser dialog is a must.

The fill type option (FG/BG/Pattern) was already mapped to the common
toggle behavior key (Ctrl on Linux), which is commonly used for
switching to color picker on paint tools. So I decided to remap the fill
type switch to GDK_MOD1_MASK (Alt on Linux) to keep consistent with
other tools (at the price of a change for anyone used to this modifier,
though I doubt it was that much used).
I also made possible to combine the 2 modifiers (so you could pick the
foreground or background color with ctrl and ctrl-alt).
2018-11-27 17:25:05 +01:00
Jehan 744d67939d app: flood isolated pixels in smart colorization fill.
The smart colorization was leaving irritating single pixels in between
colorized regions, after growing and combining. So let's just flood
these. We don't flood bigger regions (and in particular don't use
gimp_gegl_apply_flood()) on purpose, because there may be small yet
actual regions inside regions which we'd want in other colors. 1-pixel
regions is the extreme case where chances that one wanted it filled are
just higher.
2018-11-27 15:12:18 +01:00
Jehan 6bec0bc82d app: radius map actually not useful during smart colorization grow step.
The distance map has all the information we need already. Also we will
actually grow up to the max radius pixel (middle pixel of a stroke).
After discussing with Aryeom, we realized it was better to fill a stroke
fully (for cases of overflowing, I already added the "Maximum growing
size" property anyway).
2018-11-27 14:59:35 +01:00
Jehan 613bf7c5ab app, libgimpconfig: make various usage of g_file_replace() safer.
When an error occurs, we want to prevent overwriting any previous
version of the file by incomplete contents. So run
g_output_stream_close() with a cancelled GCancellable to do so.
See also discussion in #2565.
2018-11-26 15:50:38 +01:00
Jehan 076b53511a app: do no overwite XCF when an error occurred at saving time.
We can cancel a file overwrite at the last second when closing the
stream by setting a cancelled cancellable. Current code was simply not
closing the stream, but this was not enough as overwriting was happening
anyway (probably when finalizing).
This will allow much safe saving process since we would not be
overwriting a previously sane XCF file when an error occurred (either in
our code or a memory error, or whatnot).
See also discussion in #2565.
2018-11-26 14:10:37 +01:00
Jehan d2f9549c9f app: add possibility to antialias line art colorization. 2018-11-26 12:33:45 +01:00
Jehan c32b0ecc92 app: simpler code with gegl_node_blit().
No need to go through an intermediate GeglBuffer when unneeded.
2018-11-26 12:26:54 +01:00
Jehan ec78a7e419 app: gdk_test_simulate_key() Win32 replacement code unneeded on master.
This is still needed on the gimp-2-10 branch since the implementation
appeared on GTK+ 2.24.25. But for GTK+3, it appeared for 3.14.0, which
is below our current minimum requirement on master. So let' clean out
this now useless piece of code.
2018-11-24 11:34:51 +01:00
Oleksii Samorukov 28d376ae3e tests: OSX - activate GIMP window when tests are running
If window is not focused gimp_test_utils_synthesize_key_event would
fail.

(cherry picked from commit 63e86da6f3)
2018-11-23 23:20:20 +01:00
Oleksii Samorukov 7921b24a89 tests: implement gimp_test_utils_synthesize_key_event on OSX/QUARTZ
(cherry picked from commit 9ae19eb8ec)
2018-11-23 23:07:20 +01:00
Ell 0a123a81a3 Issue #2553 - Can't Move Imported or Pasted Path
Initialize the X/Y tilt fields of improted/pasted path control
points to 0, instead of 0.5, which is the normal value for these
fields in paths.  This avoids calculating bogus distances when
trying to pick the path, causing picking to fail.
2018-11-23 08:48:36 -05:00
Alex Samorukov ea2c9eefb3 app: do not activate OSX menu if tests are running to prevent crash
(cherry picked from commit 62c52742cd)
2018-11-23 11:41:16 +01:00