Last Comment Bug 571532 - Remove support for ctx.globalCompositeOperation = 'darker'
: Remove support for ctx.globalCompositeOperation = 'darker'
: dev-doc-complete, html5
Product: Core
Classification: Components
Component: Canvas: 2D (show other bugs)
: Trunk
: All All
-- normal (vote)
: mozilla2.0b2
Assigned To: :Ms2ger (⌚ UTC+1/+2)
: Milan Sreckovic [:milan]
Depends on: 401788
  Show dependency treegraph
Reported: 2010-06-11 10:40 PDT by :Ms2ger (⌚ UTC+1/+2)
Modified: 2014-01-21 16:52 PST (History)
5 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Patch v1 (1.93 KB, patch)
2010-06-11 10:40 PDT, :Ms2ger (⌚ UTC+1/+2)
vladimir: review+
Details | Diff | Splinter Review

Description User image :Ms2ger (⌚ UTC+1/+2) 2010-06-11 10:40:25 PDT
Created attachment 450682 [details] [diff] [review]
Patch v1

It was removed from the specification in 2007. [1] We should get rid of it, especially as we don't even have a correct implementation.

[1] <>
Comment 1 User image Vladimir Vukicevic [:vlad] [:vladv] 2010-06-12 14:25:39 PDT
Comment on attachment 450682 [details] [diff] [review]
Patch v1

I'm a little hesitant to remove it, but it should really be gone.. it's not even consistent amongst gecko running on different platforms.
Comment 2 User image :Ms2ger (⌚ UTC+1/+2) 2010-06-13 00:04:10 PDT
Comment 3 User image :Ms2ger (⌚ UTC+1/+2) 2010-06-13 00:12:54 PDT
Uh, I just realized that the test will throw until bug 401788 lands. New patch coming up.
Comment 4 User image Vladimir Vukicevic [:vlad] [:vladv] 2010-06-13 01:32:20 PDT
let's just land 401788 first -- I'll take a look at it tomorrow.
Comment 5 User image Dão Gottwald [:dao] 2010-07-15 02:37:13 PDT
Comment 7 User image Felix Klein 2012-06-08 02:13:15 PDT

Just wondering, can anybody point me to a discussion as to why the 'darken' operator was removed from the spec?
I read about bugs and differing browser implementation, but it's a bit difficult to find detailed informations.

I'm currently working excessively with canvas and kind of miss this operator.
Comment 8 User image :Ms2ger (⌚ UTC+1/+2) 2012-06-08 02:32:18 PDT
Different implementations, and unlikelihood of the implementations converging. If we can't get browsers to implement a feature the same way, we're off better without the feature.

You're saying you miss this operator, but which implementation of it do you miss?
Comment 9 User image Felix Klein 2012-06-08 02:48:59 PDT
Ok, I start to see the problem.

I was actually thinking about the "multiply" implementation of Photoshop.
But it turns out, that for my usecase a black image with alpha channel works just as well.

So, uhm... nevermind!
Comment 10 User image lutusp 2013-09-18 16:18:24 PDT
There is an operation in 3D anaglyphic graphics that requires "darker" -- *requires* it. There is no substitute. I think it was a big mistake to remove it from the feature set.

Here's the explanation. If I create an anaglyphic image, a red/cyan image of dots against a black background, it only works if overlapping dots, individually red or cyan, are drawn as white. Easily accomplished -- I use the "lighter" composite operator, Like this:

If instead I want a white background, I can draw the exact same image, by using the "darker" composition operator for the overlapping dots. Like this (rendered by Google Chrome):

No problem. But while testing, I discovered that MSIE and Firefox don't support "darker" -- it was dropped without an explanation. The result looks like this in the current Firefox:

You won't fully appreciate the outcome without anaglyphic glasses, but basically it ruins the effect.

I tried a few alternatives. the "xor" operator ought to have solved the problem by inverting the entire image after drawing it, but the available "xor" operator doesn't actually work -- it only operates on the alpha channel.

I have to say something. I have been creating red/cyan anaglyphic images since I owned an Apple II in 1977. This is the first time I have not been able to produce the images the effect requires. Android supports the "darker" composition operator, so my TankCalc app (, which uses anaglyphs, works fine.

But MSIE doesn't support "darker", and Firefox doesn't support it. This is a big step backward.

Please reconsider this decision.
Comment 11 User image Jotaf 2014-01-11 15:08:53 PST
It seems that the correct mode in Firefox for the old behavior is globalCompositeOperation="difference".

Because "difference" is a mathematical operation, there is no ambiguity in the implementation, unlike the subjective term "darker".
Comment 12 User image lutusp 2014-01-21 16:52:01 PST
(In reply to Jotaf from comment #11)
> It seems that the correct mode in Firefox for the old behavior is
> globalCompositeOperation="difference".

False. They aren't remotely the same thing. "Difference" equals XOR. "Darker" is something else entirely, that doesn't correspond to a simple logical operator.

> Because "difference" is a mathematical operation, there is no ambiguity in
> the implementation, unlike the subjective term "darker".

Yes, but "difference" equals XOR, and "darker" doesn't -- they aren't the same thing. "Darker" remains unique, and remains necessary. Firefox can close this bug if they want, but Firefox can also be left behind in browser development.

One can repair this fault by reprocessing the entire frame, at double or triple the processing time, but this only struggles against an unwise omission.

Note You need to log in before you can comment on or make changes to this bug.