Commit Graph

1112 Commits

Author SHA1 Message Date
Michael Natterer b0beb0197a Bug 795230 - Rename Blend tool and provide PDB compatibility
Rename the tool and its options, and the gradient sub-struct of paint
options.
2018-04-14 00:52:20 +02:00
Michael Natterer bf49b47620 Bug 795207 - Add color space to blend(gradient) tool options
First WIP commit, adds:

- enum GimpGradientBlendColorSpace { RGB_PERCEPTUAL, RGB_LINEAR }
- linear blending mode for gradient segments
- tool options GUI for the blend and paint tools which use gradients
2018-04-13 22:33:16 +02:00
Ell ff34965faf Bug 795177 - seg fault with clone tool
Don't flush the source pickable in gimp_source_core_motion(), as
this introduces a race condition between the paint thread and the
display-update timeout, when the source pickable is the image
containing the target drawable.

Flushing the source pickable shouldn't be currently necessary, and
either way, should happen during initialization.
2018-04-13 10:03:20 -04:00
Jehan 1993d8a4a7 Bug 768872 - Tiling Symmetry doesn't wrap vertical coordinates over...
... edges for MyPaint brush.

Adding the concept of "stateful" symmetry when a tool needs to make sure
of corresponding stroke numbers and orders while painting (i.e. stroke N
at time T+1 is the continuation of stroke N at time T). This is the case
for the MyPaint brushes and the ink tool.
2018-04-11 02:09:21 +02:00
luz.paz 7fdb963e01 Bug 794996 - Misc. typo fixes in comments in app/
Found via `codespell -q 3 --skip="./po*"`
2018-04-08 21:25:56 +02:00
Jehan 87b9611628 app: fix build error "‘memset’ was not declared in this scope". 2018-04-05 23:57:34 +02:00
Ell 4336e2e52a app: parallelize gimpbrushcore-loops.cc
Use gimp_parallel_distribute_foo() to parallelize the brush core
loops.
2018-04-05 17:41:29 -04:00
Ell 6e314b5090 app: move brush-core loops to a separate file
Move gimp_brush_core_{subsample,pressurize,solidify}_mask() to a
separate gimpbrushcore-loops.cc file, so that they can be C++-ified
independently from the rest of the code.  The next commit
parallelizes them.
2018-04-05 17:41:29 -04:00
Ell f7ea9abc73 app: add include guards to gimppatincore-loops.h 2018-04-05 17:41:29 -04:00
Ell 082a6404c9 app: fix iterator area in canvas_buffer_to_paint_buf_alpha()
The entire ROI was processed in all threads, instead of only the
thread-specific area, causing artifacts.
2018-04-05 02:19:52 -04:00
Ell 3df757ffd7 app: parallelize gimppaintcore-loops.cc
Ditto.
2018-04-04 17:49:47 -04:00
Ell e8a14deecf app: switch gimppaintcore-loops.c to C++
Ditto.
2018-04-04 17:49:46 -04:00
shark0r e55c94eff0 Bug 794854 - Brush color is not added to color history in smudge tool
Add the color in gimp_smudge_paint(INIT) like GimpPaintbrush does.

Achieve this by calling gimp_palettes_add_color_history() directly,
not by inheriting GimpPaintbrush because GimpPaintbrush and GimpSmudge seem to share few common features.
2018-04-01 12:57:27 +02:00
Jehan 04a798d786 app: do not copy needlessly paint_mask GimpTempBuf.
We are not doing any write operation on this mask data so copying all
the data just to read it and unreffing it in the end is only a cost on
performance.
See also bug 694917.
2018-03-31 16:54:53 +02:00
Massimo Valentini f561231e1f app: various speedups to gimp_brush_core_color_area_with_pixmap()
In gimp_brush_core_color_area_with_pixmap(), use the native area
format when painting the brush, instead of always going through
"RGBA float", and create the pixmap -> area fish only once, instead
of once per scanrow.

In gimp_brush_core_paint_line_pixmap_mask(), avoid modulus
calculation at each pixel.

See bug #694917.
2018-03-25 15:22:47 -04:00
Ell 1be002254d Bug 793392 - Issue when painting with some layer modes ...
... on perceptual gamma image

When constructing the paint core's paint buffer, in GimpBrushCore
and GimpInk, use the drawable's format as the preferred format in
the call to gimp_layer_mode_get_format(), instead of NULL.

Subsequently, use the paint buffer's format, instead of the source
buffer's format, as the preferred iterator format in
do_layer_blend(), since the iterator format must match the paint
buffer format.
2018-02-12 13:49:03 -05:00
Michael Natterer 6f324b867a Bug 783755 - Smudge should blend the smudged colors using linear RGB
This reverts commit 94c6bb4603, because
unlike what the bug title suggests, Smudge apparently *should* use
perceptual RGB, so now everything works as before.
2018-02-12 17:27:05 +01:00
Michael Natterer 539927ebfa app: replace all g_assert() by the newly added gimp_assert()
which is just a #define to g_assert for now, but can now easily be
turned into something that does some nicer debugging using our new
stack trace infrastructure. This commit also reverts all constructed()
functions to use assert again.
2018-02-11 22:23:10 +01:00
shark0r 32280a170b app: Add "No erasing effect" parameter to MyPaint brush
Last and unrelated patch of bug #785001.
2018-01-03 02:23:53 +01:00
Piotr Drąg 4df282a6fb app: fix a typo (realtive) 2017-12-23 00:13:18 +01:00
Ell eded91e118 Bug 753412 - New Canvas rotation feature rotates brush.
Replace the "lock brush size to zoom" paint option with a "lock
brush to view" option, which links the entire brush transform to
the view transform, so that the brush remains invariant in display
space under scaling, rotation, and reflection.
2017-12-22 17:52:29 -05:00
Ell a0b73420ec app: add support for brush reflection
Add support for reflecting brushes as part of their transformation.
The reflection is performed as the last step of the transformation,
across the vertical axis.

The option to reflect the brush is not exposed in the UI, or
through the PDB, but is intended to be used for linking the brush
transformation to the view transformation, in the next commit.
2017-12-22 17:52:29 -05:00
Ell 067277340d app: fix brush zoom verification in gimp_brush_core_pre_paint() 2017-12-22 17:52:29 -05:00
Ell 984ed6cefd app: constrain line angles in display space, not image space
Add an offset_angle parameter to gimp_constrain_line(), which
offsets the radial lines by a given angle.

Add gimpdisplayshell-utils.[ch], with two new functions:

  - gimp_display_shell_get_constrained_line_offset_angle():
    Returns the offset angle to be passed to
    gimp_constrain_line(), in order to constrain line angles in
    display space, according to the shell's rotation angle and
    flip mode.

  - gimp_display_shell_constrain_line():  A convenience function
    which calls gimp_constrain_line() with the said offset angle.

Use the new functions in all instances where we constrain line
angles, so that angles are constrained in display space, rather
than image space.

The only exception is GimpEditSelectionTool, which keeps
constraining angles in image space, since it's not entirely obvious
that we want to constrain angles of dragged layers/selections in
display space.
2017-12-22 06:32:24 -05:00
Michael Natterer b05cfc6050 pdb: (try 3) move PDB generation and sources to toplevel/pdb
It never belonged inside "tools". Also rename its "pdb" subdirectory
to "groups". This had to happen before 2.10 so cherry-picking between
branches doesn't become a nightmare in the future.
2017-12-17 14:16:08 -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 58fdaae3ad enums: add intermediate generated enum files to .gitignore 2017-08-24 15:35:27 -04: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 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
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 bcda53ee7b Bug 785001 - Enhanced smudge tool: Smudge with painting
Apply patches from shark0r that alow to mix in both constant and
gradient color while smudging; and clean up the patches.
2017-07-23 14:44:22 +02: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
Michael Natterer f3561549bb app: fix leaks when freeing the list of accum_buffers in gimpsmudge.c 2017-07-15 18:42: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
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 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
Jehan ab56f524e4 app: "Reset to default values" does not properly reset generated...
... brush features.
My previous commit only fixed aspect ratio reset, but I realize that
much more brush options are affected by defaults of generated brushes
(size, hardness, aspect ratio, angle and spacing). Let's reset all these
after the basic property reset.
2017-05-04 04:59:59 +02:00
Jehan 129a0e4bcd app: "Reset to default values" does not properly reset aspect ratio.
Generated brushes can have specific aspect ratio, hence resetting to
fixed property defaults may be wrong. Therefore GimpPaintOptions needs
to redefine the reset() method from GimpConfigInterface.
Note: the specific "Reset aspect ratio to brush's native aspect ratio"
button was alright. But the broader "Reset to default values" was not.
2017-05-04 04:57:42 +02:00
Jehan b0d2d4fb49 app: indentation fix. 2017-04-22 20:53:08 -03:00
Joao S. O. Bueno c2b643d043 app: For clone tool, pattern source, use the pattern center
Spotted by José Americo Gobbo: when using a pattern source
for the clone tool, the top left corner was picked
as starting control point, which made the "fixed" aligment
rather useless. Using the pattern center allows the
better control of a pattern source.
2017-04-20 00:35:20 -03:00
Ell d4bb12d8b8 app: fix painting with force == 0
Should be a nop, but instead does the same thing as force == 0.5.
2017-04-10 09:57:54 -04:00
Ell 6c8ba75021 Bug 779632 - Clone tool jittering
The expression `src_offset_x - coords->x + origin->x` is parsed as
`(src_offset_x - coords->x) + origin->x`; since floating point
arithmetic is not generally associative, even when
`coords->x == origin->x` (in particular, when there is no active
symmetry), it may still yield a different result than plain
`src_offset_x` if there's not enough precision for the intermediary
result (which is usually the case when `{origin,coords}->x` is
noninteger.)  Since `src_offset_x` is an integer, and since the result
of this expression is rounded to an integer, if the error happens to
be in the direction of the rounding, it's magnified to a whole pixel,
which causes visible "jitter".  (Ditto for `src_offset_y` and co.)

Regardless of this issue, we want to individually round `origin->[xy]`
and `coord->[xy]` down before taking their difference, since the
original offset is calculated according to rounded-down coordinates.
This solves the original issue along the way.
2017-04-03 15:38:27 -04:00
Ell 7c7a1b6383 app: integer-ify position/offset members of GimpSourceCore
We don't support subpixel source sampling, so there's no use in
pretending that we do.  Demoting everything to int as soon as
possible helps guarantee that these values are at least rounded
properly and in fewer places.

Make sure we always round coordinates down, and not toward zero.

Keep using floats only in the signatures of the relevant PDB
functions.
2017-04-03 15:32:27 -04: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
Massimo Valentini 3d58a23342 Bug 764619: Color paint dynamic parameter and square artifacts when one or two channel are disabled 2017-02-21 23:47:01 +01: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
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
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