Bug 39177 - Canvas 2d globalCompositeOperation source-in, source-out, destination-in, destination-atop, darker and copy are broken
Summary: Canvas 2d globalCompositeOperation source-in, source-out, destination-in, des...
Status: RESOLVED DUPLICATE of bug 66036
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: https://developer.mozilla.org/samples...
Keywords:
: 34027 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-05-16 07:42 PDT by Stefan Wehrmeyer
Modified: 2011-08-22 23:21 PDT (History)
11 users (show)

See Also:


Attachments
reference rendering with wrong renderings marked red (26.78 KB, image/png)
2010-05-16 07:42 PDT, Stefan Wehrmeyer
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Wehrmeyer 2010-05-16 07:42:51 PDT
Created attachment 56188 [details]
reference rendering with wrong renderings marked red 

What steps will reproduce the problem?
1. Compare the canvas rendering of
https://developer.mozilla.org/samples/canvas-tutorial/6_1_canvas_composite.html 
to the reference images at 
https://developer.mozilla.org/en/Canvas_tutorial/Compositing

What goes wrong?
The following composite operations do not render as they should, but as the following:
"source-in" renders like "source-atop"
"source-out" renders like "xor"
"destination-in" renders like there was no second drawing (no red circle)
"destination-atop" renders like "destination-over"
"darker" doesn't look like the reference (not sure though if the reference gets the darker color right)
"copy" renders like "source-over"

A reference rendering is attached with buggy compositing operations marked red.

This bug is related to
https://bugs.webkit.org/show_bug.cgi?id=34027
but this is a more complete version of the current canvas compositing bugs.

This bug has also been filed downstream at
http://code.google.com/p/chromium/issues/detail?id=37799

Firefox and Opera currently get most composite operations right. This should be fixed as soon as possible, so developers don't have to write custom code for webkit.
Comment 1 Oliver Hunt 2010-07-08 11:34:49 PDT
We believe the spec is wrong in its definition of these behaviours.  The spec behaviour is inconsistent with the original canvas implementation from webkit, and is less powerful.
Comment 2 Oliver Hunt 2010-07-08 11:35:08 PDT
(In reply to comment #1)
> We believe the spec is wrong in its definition of these behaviours.  The spec behaviour is inconsistent with the original canvas implementation from webkit, and is less powerful.

...
And is slower.
Comment 3 Shinichiro Hamaji 2010-08-16 03:25:16 PDT
*** Bug 34027 has been marked as a duplicate of this bug. ***
Comment 4 Charles Pritchard 2010-11-27 11:42:38 PST
(In reply to comment #1)
> We believe the spec is wrong in its definition of these behaviours.

I believe the spec has been updated, and Mozilla has changed their behavior in FF4. Case closed?
Comment 5 Stefan Wehrmeyer 2010-11-27 15:14:31 PST
The behavior of compositing in Webkit is still not compliant to the spec. Firefox and Opera behave the same and as far as I can see compliant to the HTML5 canvas spec.

The "darker" compositing mode is not in the spec, but the description in the bug report still holds. 

I'm the developer of Mapnificent.net and I'm relying on the "destination-in" compositing mode to implement intersections of two areas, see this link (in a Firefox browser) for an example: http://bit.ly/hkqzBN

That doesn't work in Webkit browsers and it is pretty frustrating. I don't know which spec Webkit needs to implement, but I would vote for the HTML5 Canvas spec instead of the original canvas implementation (that might be inconsistent to the current spec). As a developer I want my HTML5 application to work the same across browsers and currently Webkit is the only one stepping out of line.

Please someone confirm this or make a decision.
Comment 6 kangax 2011-04-28 19:32:41 PDT
Oliver, your thoughts on this?
Comment 7 Julien Chaffraix 2011-05-05 11:56:09 PDT
FYI, I posted a patch to correct the source-in and source-out behavior for fillRect as part of bug39027 as FF4, IE9 and Opera all matches the specification and we are the only one standing out.
Comment 8 Jim 2011-08-02 04:32:03 PDT
I'm in the same position as Stefan here. Without destination-in working to specification, my app won't work on Webkit based browsers. The specification still reflects how I believe destination-in should work (show destination only where destination and source overlap) and other browsers implement this correctly.

If the behaviour of the specification is "less powerful" than the webkit implementation, then surely there must at least be a webkit specific way of achieving what is defined in the specification as "destination-in".
Comment 9 Ben Wells 2011-08-22 23:21:44 PDT
All issues reported have been fixed in bug 66036, with the exception of 'darker' which is no longer covered by the canvas spec.

*** This bug has been marked as a duplicate of bug 66036 ***