Open Bug 1072548 Opened 10 years ago Updated 2 years ago

Shadow drawn wrong on Mac with source-in composite operator

Categories

(Core :: Graphics: Canvas2D, defect)

x86
macOS
defect

Tracking

()

People

(Reporter: ian, Unassigned)

References

()

Details

I've no idea what's going on here, but it's not per spec, certainly.

http://goo.gl/LVUZ1r

What Safari does is correct (just a little teal rectangle).

This still happens, and apparently not only on macOs (tried on Windows from a VM).

Here is an other test case: https://jsfiddle.net/gvzpr7La/

Only a red slice should remain, because per specs, the shadow should get composited with the "output bitmap", before the "shape or image" get composited again with the resulting "output bitmap".

So this test case should actually do the same thing as this updated version which doesn't use shadows: https://jsfiddle.net/gvzpr7La/1

This affects some other compositing modes too but not all.
Would be great to have updated WPTs since the current ones for shadows + compositing (using "xor") do pass eveywhere, while Safari also has some other issues.

The problem seems to come from DrawTargetCairo::DrawSurfaceWithShadow where there is a special casing of the current composite mode and a new group is created for the problematic ones.

Not sure where this logic comes from and I'm not sure to completely understand what the grouping implies here.
The specs actually is written in such a way that groups (a.k.a "infinite bitmaps" or "layers") are implied, for any composite mode.

Here is a test where the discrepancy can be seen.
The left canvas is how the current browser renders, and the right one is a rewrite following step by step the rendering of the shadows as defined by the specs (unless I made a mistake).
In Chrome both always produce the same results. Firefox and Safari do differ with the aforementioned list of composite modes, minus "copy" for Firefox only. (*Note that Safari doesn't support filter and thus never has the blur on the right side canvas).

Given that two browsers seem to behave approximately the same there may be an argument for aligning the specs on that behavior but I wasn't able to understand said behavior. So here I am (again).

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.