After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 766116 - Behind mode is not working correctly
Behind mode is not working correctly
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
git master
Other All
: Normal normal
: 2.10
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2016-05-07 18:22 UTC by jose americo gobbo
Modified: 2016-07-25 20:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
comparison between GIMP Git Master and GIMP 2.8.16 > Behind mode on painttool (111.52 KB, image/x-xcf)
2016-05-07 18:22 UTC, jose americo gobbo
  Details
fix behind mode operation (1.53 KB, patch)
2016-05-10 10:37 UTC, Massimo
none Details | Review
Variations colours with behind mode with opacity 50% (36.77 KB, image/x-xcf)
2016-05-11 03:26 UTC, jose americo gobbo
  Details
fix behind mode operation (1.74 KB, patch)
2016-05-11 17:29 UTC, Massimo
none Details | Review

Description jose americo gobbo 2016-05-07 18:22:03 UTC
Created attachment 327450 [details]
comparison between GIMP Git Master and GIMP 2.8.16 > Behind mode on painttool

My DE is GNOME 3.10
Ubuntu Gnome 14.04.2
GIMP Git Master commit 46096a1
---

The behind mode is modifying the color hue when I use different opacities. Is possible only to paint in the transparent layers. I have made a comparison with GIMP 2.8.16... and is OK. Is possible in GIMP 2.8.16, also, to use the behind mode on the paint-tools in a non transparent layer. The archive show the two cases, with gimp git master and gimp 2.8.16.
Comment 1 Massimo 2016-05-09 17:44:13 UTC
See:

https://git.gnome.org/browse/gimp/tree/app/operations/gimpoperationbehindmode.c#n108

The second 'value' is certainly wrong and I consider
assigning to out[ALPHA], when in[ALPHA] and layer[ALPHA]
are used later, another source of errors because specially 
in the painting code it is possible that 'in' or 'layer' are
the same buffer as 'out'.

Will test in the next days, unless someone fixes it sooner
Comment 2 Massimo 2016-05-10 10:37:52 UTC
Created attachment 327573 [details] [review]
fix behind mode operation

The attached patch should fix this problem.

If there are no objections, I'll push it later
Comment 3 Massimo 2016-05-10 17:48:52 UTC
Review of attachment 327573 [details] [review]:

well that patch is wrong, it seems to fix painting on a 
transparent layer, but not on a opaque. Sorry
Comment 4 Massimo 2016-05-10 18:46:32 UTC
> The behind mode is modifying the color hue when I use different opacities.
> Is possible only to paint in the transparent layers. I have made a
> comparison with GIMP 2.8.16... and is OK. Is possible in GIMP 2.8.16, also,
> to use the behind mode on the paint-tools in a non transparent layer. The
> archive show the two cases, with gimp git master and gimp 2.8.16.

Apparently there is an inconsistency also in gimp-2.8 because
if I add the alpha channel to the background layer, painting
on a white background (opaque but with alpha channel) results in 
white (so no visible effect). Removing the alpha channel instead
results in the pencil color.
Comment 5 jose americo gobbo 2016-05-11 03:24:38 UTC
> Apparently there is an inconsistency also in gimp-2.8 because
> if I add the alpha channel to the background layer, painting
> on a white background (opaque but with alpha channel) results in 
> white (so no visible effect). Removing the alpha channel instead
> results in the pencil color.

Yes, correct! I have this test and is very strange.
---
Around the color variations
I have a short test between GIMP stable (2.8.16) and GIMP 2.9.3 focused on the colour values. We have a great difference between the values of 2.8.16 to 2.9.3. See my .xcf in attachment.
Comment 6 jose americo gobbo 2016-05-11 03:26:14 UTC
Created attachment 327627 [details]
Variations colours with behind mode with opacity 50%
Comment 7 Massimo 2016-05-11 17:29:09 UTC
Created attachment 327653 [details] [review]
fix behind mode operation

This is a patch fixing the issues reported earlier,
written to look as much as possible similar to:

https://git.gnome.org/browse/gimp/tree/app/paint-funcs/paint-funcs.c?h=gimp-2-8#n1211

I think that gimp-2.8 behavior on opaque layers without
alpha channel is a wrong optimization: painting 'behind'
an opaque object is a nop, not equal to normal.
Comment 8 Massimo 2016-05-16 16:21:05 UTC
(In reply to Massimo from comment #7)
> Created attachment 327653 [details] [review] [review]
> fix behind mode operation
> 

I'm going to test again tomorrow this patch and if I don't 
find errors, weird things, I'll push it.

As I said I think that gimp-2.8 behind mode is wrong painting
on opaque layers and it is quite too rarely used and the code
complex to deserve a fix. Anyway I'm not going to fix it.
Comment 9 Massimo 2016-05-17 18:04:07 UTC
I've pushed a slightly modified patch.

commit 3a43478fdadd3fb2285caa3fca94ddc48e6688b6
Author: Massimo Valentini <mvalentini@src.gnome.org>
Date:   Tue May 17 19:56:39 2016 +0200

    Bug 766116: Behind mode is not working correctly

    use same var names as gimp-2-8 to make
    it easier to spot unwanted differences



I'm leaving the bug open because the behavior is not
the same as in gimp-2.8, but it seems to me that it
is a bug in gimp-2.8.
Comment 10 Michael Natterer 2016-07-01 07:29:16 UTC
I think we can safely close this because this change cannot affect
loaded 2.8 XCF files (behind cannot be used as layer mode).

Unless you have something to add?
Comment 11 Massimo 2016-07-01 08:02:51 UTC
(In reply to Michael Natterer from comment #10)
> I think we can safely close this because this change cannot affect
> loaded 2.8 XCF files (behind cannot be used as layer mode).
> 
> Unless you have something to add?

The bug here is that, in gimp-2-8, painting with behind mode
works differently whether an opaque layer has or not the alpha
channel.

I think it is a wrong optimization choice: painting behind a 
layer without alpha channel (so opaque) is a nop and not 
equivalent to normal mode.

But the code in gimp-2-8 is quite complex and I don't think
is worth fixing. You can achieve nop by simply not painting.

I left it open to mean it is a known issue. When gimp-2-8
is no more the stable version it is reasonable to close
this as obsolete or wontfix. Obviously it is possible to
close it now
Comment 12 Michael Natterer 2016-07-25 20:13:35 UTC
Let's just get rid of the bug and let 2.8 rot in stability.