12010-12-19 Noel Gordon <noel.gordon@gmail.com>
2
3 Reviewed by NOBODY (OOPS!).
4
5 [chromium] canvas.toDataURL("image/jpeg") should composite onto black.
6 https://bugs.webkit.org/show_bug.cgi?id=51237
7
8 The Canvas specification requires that the canvas image is composited using
9 the Porter-Duff operator source-over onto a black background; the resultant
10 image should be JPEG encoded and returned as a dataURL. To composite image
11 A and background B, for any Porter-Duff operator, produce pixels I with
12
13 I = c(A)F(A) + c(B)F(B)
14
15 where, F(X) is the fraction [0.0-1.0] contributed to the composite by image
16 X, and c(X) are the premultiplied RGB color components of image X. Note by
17 definition, c(B) = 0 since the background is black, so I = c(A)F(A). Since
18 F(A) = 1 in Porter-Duff operator source-over, the composited pixels satisfy
19 I = c(A). Hence, to conform to the Canvas spec, pass the premultiplied RGB
20 color components of the canvas image to the JPEG encoder.
21
22 Covered by canvas/philip/tests/toDataURL.jpeg.alpha.html
23
24 * platform/image-encoders/skia/JPEGImageEncoder.cpp:
25 (WebCore::preMultipliedBGRAtoRGB): Use Porter-Duff source-over black.
26