LayoutTests/ChangeLog

 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 canvas/philip/tests/toDataURL.jpeg.alpha.html only fails on chromium-mac
 9 now, tracked by bug http://webkit.org/b/40147.
 10
 11 * platform/chromium/test_expectations.txt: win & linux pass.
 12
1132010-12-19 Dan Bernstein <mitz@apple.com>
214
315 Reviewed by Cameron Zwarich.

LayoutTests/platform/chromium/test_expectations.txt

@@BUGWK45991 : canvas/philip/tests/2d.pattern.image.broken.html = TEXT
23032303BUGWK45991 : canvas/philip/tests/2d.text.draw.baseline.ideographic.html = TEXT
23042304BUGWK48579 : canvas/philip/tests/type.prototype.html = TEXT
23052305BUGWK50797 : canvas/philip/tests/2d.fillStyle.parse.invalid.rgba-6.html = TEXT
2306 BUGWK40147 : canvas/philip/tests/toDataURL.jpeg.alpha.html = TEXT
 2306BUGWK40147 MAC : canvas/philip/tests/toDataURL.jpeg.alpha.html = TEXT
23072307BUGCR61824 : canvas/philip/tests/2d.pattern.image.string.html = TEXT
23082308
23092309// Update canvas/philip in WK r71481

WebCore/ChangeLog

 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
1272010-12-19 Dan Bernstein <mitz@apple.com>
228
329 Reviewed by Cameron Zwarich.

WebCore/platform/image-encoders/skia/JPEGImageEncoder.cpp

@@static void handleError(j_common_ptr common)
7979 longjmp(*jumpBufferPtr, -1);
8080}
8181
82 // FIXME: is alpha unpremultiplication correct, or should the alpha channel
83 // be ignored? See bug http://webkit.org/b/40147.
84 void preMultipliedBGRAtoRGB(const SkPMColor* input, unsigned int pixels, unsigned char* output)
 82static void preMultipliedBGRAtoRGB(const SkPMColor* input, unsigned int pixels, unsigned char* output)
8583{
86  static const SkUnPreMultiply::Scale* scale = SkUnPreMultiply::GetScaleTable();
87 
8884 for (; pixels-- > 0; ++input) {
89  const unsigned alpha = SkGetPackedA32(*input);
90  if ((alpha != 0) && (alpha != 255)) {
91  *output++ = SkUnPreMultiply::ApplyScale(scale[alpha], SkGetPackedR32(*input));
92  *output++ = SkUnPreMultiply::ApplyScale(scale[alpha], SkGetPackedG32(*input));
93  *output++ = SkUnPreMultiply::ApplyScale(scale[alpha], SkGetPackedB32(*input));
94  } else {
95  *output++ = SkGetPackedR32(*input);
96  *output++ = SkGetPackedG32(*input);
97  *output++ = SkGetPackedB32(*input);
98  }
 85 *output++ = SkGetPackedR32(*input);
 86 *output++ = SkGetPackedG32(*input);
 87 *output++ = SkGetPackedB32(*input);
9988 }
10089}
10190