Bug 42214

Summary: chromium/skia: Fix canvas.toDataURL in the presence of transparency
Product: WebKit Reporter: Nico Weber <thakis>
Component: New BugsAssignee: Nico Weber <thakis>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, agl, brettw, commit-queue, eric, jamesr, ojan, pkasting, senorblanco, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Nico Weber 2010-07-13 17:02:08 PDT
chromium/skia: Fix canvas.toDataURL in the presence of transparency
Comment 1 Nico Weber 2010-07-13 17:09:21 PDT
Created attachment 61436 [details]
Patch
Comment 2 Nico Weber 2010-07-13 17:53:43 PDT
The patch still needs a test case (despite claim in the changelog), but the code change is complete. Comments?
Comment 3 Nico Weber 2010-07-13 17:54:25 PDT
Oh, this is http://crbug.com/26456 , and I need to credit deanm in the changelog as well.
Comment 4 Nico Weber 2010-07-13 18:15:23 PDT
Created attachment 61446 [details]
Patch
Comment 5 Nico Weber 2010-07-13 18:18:36 PDT
Now with tests and attribution.
Comment 6 Adam Langley 2010-07-15 08:52:32 PDT
LGTM
Comment 7 Ojan Vafai 2010-07-15 11:11:02 PDT
Comment on attachment 61446 [details]
Patch

Code changes look fine. Just a few test comments.

> diff --git a/LayoutTests/fast/canvas/toDataURL-alpha.html b/LayoutTests/fast/canvas/toDataURL-alpha.html
> +      var d = document;
> +      var c = d.getElementById("c").getContext("2d");
> +      c.fillStyle = "rgba(200, 255, 200, 0.7)";
> +      c.fillRect(0, 0, c.canvas.width, c.canvas.height);
> +      d.getElementById("d").style.backgroundImage = ["url(", c.canvas.toDataURL("image/png"), ")"].join("");

Short variable names are generally frowned upon in WebKit code. I know this is just a test, but it makes this hard to read. Can you s/c/context and either not alias document or s/d/doc?

> diff --git a/LayoutTests/platform/mac-leopard/fast/canvas/toDataURL-alpha-expected.checksum b/LayoutTests/platform/mac-leopard/fast/canvas/toDataURL-alpha-expected.checksum
> diff --git a/LayoutTests/platform/mac-leopard/fast/canvas/toDataURL-alpha-expected.png b/LayoutTests/platform/mac-leopard/fast/canvas/toDataURL-alpha-expected.png

These should be in platform/mac or next to the test. Snow Leopard, for example, won't know to find the expected results in this directory.
Comment 8 Nico Weber 2010-07-15 11:17:12 PDT
Created attachment 61690 [details]
Patch
Comment 9 Nico Weber 2010-07-15 11:18:15 PDT
> Short variable names are generally frowned upon in WebKit code. I know this is just a test, but it makes this hard to read. Can you s/c/context and either not alias document or s/d/doc?

Don.

> > diff --git a/LayoutTests/platform/mac-leopard/fast/canvas/toDataURL-alpha-expected.png b/LayoutTests/platform/mac-leopard/fast/canvas/toDataURL-alpha-expected.png
> 
> These should be in platform/mac or next to the test. Snow Leopard, for example, won't know to find the expected results in this directory.

jamesr told me to put them there because text rendering is different on Snow Leopard, which would cause this to turn the 10.6 bot red.
Comment 10 Ojan Vafai 2010-07-15 11:26:14 PDT
(In reply to comment #9)
> > These should be in platform/mac or next to the test. Snow Leopard, for example, won't know to find the expected results in this directory.
> 
> jamesr told me to put them there because text rendering is different on Snow Leopard, which would cause this to turn the 10.6 bot red.

If this were a test where pixel results were different on Snow Leopard, then it would make sense to do this, then grab the pixel results for Snow Leopard off the bot (assuming we had webkit pixel bots anymore) and put them in platform/mac.

But, not all text rendering is different. I think that most of the time Leopard matches Snow Leopard. I'd be surprised to find that this test rendered differently on Snow Leopard than Leopard. Maybe I'm missing something though.
Comment 11 James Robinson 2010-07-15 11:57:51 PDT
Text _always_ renders differently on Leopard vs Snow Leopard due to subpixel AA differences.  Thus pixel results for tests with text on mac are always Leopard or Snow Leopard specific.  In this case, as the test exists now someone running with -p on Snow Leopard would not see any expected results.  If the results were in platform/mac then someone running with -p on Snow Leopard would see small pixel diffs (if they had fuzzy matching enabled) or get a pixel failure (if they didn't have fuzzy matching enabled).

Currently nobody runs pixel tests in an automated fashion except for Chromium and Chromium only runs them on Leopard, so this won't break anyone either way.  However since we know that these results are going to only be valid on Leopard I'd much rather put them in mac-leopard now instead of having to move them manually later.
Comment 12 James Robinson 2010-07-15 11:58:36 PDT
Naturally adding Snow Leopard specific results to platform/mac in addition to the Leopard specific results in platform/mac-leopard is the best option of them all :)
Comment 13 WebKit Commit Bot 2010-07-15 16:47:30 PDT
Comment on attachment 61690 [details]
Patch

Clearing flags on attachment: 61690

Committed r63494: <http://trac.webkit.org/changeset/63494>
Comment 14 WebKit Commit Bot 2010-07-15 16:47:40 PDT
All reviewed patches have been landed.  Closing bug.
Comment 15 WebKit Review Bot 2010-07-15 17:11:00 PDT
http://trac.webkit.org/changeset/63494 might have broken GTK Linux 32-bit Release and Qt Linux Release
The following changes are on the blame list:
http://trac.webkit.org/changeset/63494
http://trac.webkit.org/changeset/63495
Comment 16 Nico Weber 2010-07-15 17:19:01 PDT
gtk/qt guys: That was probably me. Looks like minor, non-important differences. Could that be caused by fonts? How is this usually handled? Do you just add platform-specific expectations?
Comment 17 Ojan Vafai 2010-07-15 17:31:15 PDT
(In reply to comment #16)
> gtk/qt guys: That was probably me. Looks like minor, non-important differences. Could that be caused by fonts? How is this usually handled? Do you just add platform-specific expectations?

The chromium-win/chromium-linux bots are not finding the expected png. Looking at the code, they don't check mac-leopard. They only fallback to mac.
Comment 18 Nico Weber 2010-07-15 17:47:27 PDT
ojan: jamesr told me the usual procedure is to check in an expected failure for chromium (which I think I did, see my change to LayoutTests/platform/chromium/test_expectations.txt), then grab baselines from the bots later and check them in together with a change that removes the expected failure.

This is my first time doing this, so chances are I screwed something up, but that was my plan :-)
Comment 19 Ojan Vafai 2010-07-15 18:00:22 PDT
(In reply to comment #18)
> ojan: jamesr told me the usual procedure is to check in an expected failure for chromium (which I think I did, see my change to LayoutTests/platform/chromium/test_expectations.txt), then grab baselines from the bots later and check them in together with a change that removes the expected failure.

Ah right. That is the right thing to do. The only catch is that the expectations file differentiates between a pixel failure and a missing result. So, instead of IMAGE here, you should have put MISSING...I think. :) This stuff is unfortunately very complicated.
Comment 20 Ojan Vafai 2010-07-15 18:10:54 PDT
I went ahead and marked it as MISSING.
Comment 21 Adam Barth 2010-07-15 21:21:51 PDT
This patch is wrong.

LayoutTests/fast/canvas/toDataURL-alpha-expected.txt

is a render tree dump.  It should be in the platform/mac directory.  In this patch, it's in the place where a text result should be, which is confusing all the tools.

Will fix.
Comment 22 Adam Barth 2010-07-15 21:28:11 PDT
Result moved in http://trac.webkit.org/changeset/63512
Comment 23 Adam Barth 2010-07-15 21:35:00 PDT
Gtk and Qt baselines in http://trac.webkit.org/changeset/63513

The lesson here is the render tree dumps are very platform specific because of font metrics.  Expected render tree dumps go in the platform folder for the appropriate port.  Text expected results are much more likely to be cross-port, so they go in the main LayoutTest tree.

When you land a render tree dump in the cross-port folder, every port thinks that it should work for it, but it doesn't.  If you landed the results in the platform/mac folder, Qt and Gtk would know that the expected results were missing for them and the builders wouldn't get red and unhappy.
Comment 24 Nico Weber 2010-07-15 22:07:33 PDT
Thanks, Adam. Sorry for the nuisance :-/
Comment 25 Adam Barth 2010-07-15 22:16:13 PDT
(In reply to comment #24)
> Thanks, Adam. Sorry for the nuisance :-/

No problem.  Sorry I was distracted in the channel and couldn't answer you questions in real time.
Comment 26 Nico Weber 2010-07-16 17:02:38 PDT
Baselines for win and linux for this patch are at https://bugs.webkit.org/show_bug.cgi?id=42488