Fix by Mitz Pettel, reviewed by Darin.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Aug 2006 20:32:45 +0000 (20:32 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Aug 2006 20:32:45 +0000 (20:32 +0000)
        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=3438
          incorrect display of transparent 1x1 PNGs

        Test: fast/replaced/image-solid-color-with-alpha.html

        * platform/mac/ImageMac.mm:
        (WebCore::Image::checkForSolidColor): Changed to divide each color component
        by the alpha component. You need to do that since the bitmap context has
        premultiplied alpha but m_solidColor should be non-premultiplied.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15758 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/replaced/image-solid-color-with-alpha-expected.checksum [new file with mode: 0644]
LayoutTests/fast/replaced/image-solid-color-with-alpha-expected.png [new file with mode: 0644]
LayoutTests/fast/replaced/image-solid-color-with-alpha-expected.txt [new file with mode: 0644]
LayoutTests/fast/replaced/image-solid-color-with-alpha.html [new file with mode: 0644]
LayoutTests/fast/replaced/img-1x1-expected.checksum [deleted file]
LayoutTests/fast/replaced/img-1x1-expected.png [deleted file]
LayoutTests/fast/replaced/img-1x1-expected.txt [deleted file]
LayoutTests/fast/replaced/img-1x1.html [deleted file]
WebCore/ChangeLog
WebCore/platform/mac/ImageMac.mm

index c8c50658ed3a119de52e941c88fbbd59140fd502..27997b83e6db184de84e766e93f55ba7dd909715 100644 (file)
@@ -1,3 +1,19 @@
+2006-08-02  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Darin.
+
+        - pixel test for http://bugzilla.opendarwin.org/show_bug.cgi?id=3438
+          incorrect display of transparent 1x1 PNGs
+
+        * fast/replaced/image-solid-color-with-alpha-expected.checksum: Added.
+        * fast/replaced/image-solid-color-with-alpha-expected.png: Added.
+        * fast/replaced/image-solid-color-with-alpha-expected.txt: Added.
+        * fast/replaced/image-solid-color-with-alpha.html: Added.
+        * fast/replaced/img-1x1-expected.checksum: Removed.
+        * fast/replaced/img-1x1-expected.png: Removed.
+        * fast/replaced/img-1x1-expected.txt: Removed.
+        * fast/replaced/img-1x1.html: Removed.
+
 2006-08-01  Darin Adler  <darin@apple.com>
 
         - updated a test affected by changes to the DumpRenderTree tool
diff --git a/LayoutTests/fast/replaced/image-solid-color-with-alpha-expected.checksum b/LayoutTests/fast/replaced/image-solid-color-with-alpha-expected.checksum
new file mode 100644 (file)
index 0000000..9805ab6
--- /dev/null
@@ -0,0 +1 @@
+31bbbc113d0d41bd5516b09d1973480f
\ No newline at end of file
diff --git a/LayoutTests/fast/replaced/image-solid-color-with-alpha-expected.png b/LayoutTests/fast/replaced/image-solid-color-with-alpha-expected.png
new file mode 100644 (file)
index 0000000..b49e451
Binary files /dev/null and b/LayoutTests/fast/replaced/image-solid-color-with-alpha-expected.png differ
diff --git a/LayoutTests/fast/replaced/image-solid-color-with-alpha-expected.txt b/LayoutTests/fast/replaced/image-solid-color-with-alpha-expected.txt
new file mode 100644 (file)
index 0000000..8ec84f2
--- /dev/null
@@ -0,0 +1,22 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 53x18
+          text run at (0,0) width 53: "Test for "
+        RenderInline {A} at (0,0) size 60x18 [color=#0000EE]
+          RenderText {#text} at (53,0) size 60x18
+            text run at (53,0) width 60: "bug 3438"
+        RenderText {#text} at (113,0) size 202x18
+          text run at (113,0) width 202: ": rendering of 1x1 PNG images."
+      RenderBlock {P} at (0,34) size 784x18
+        RenderText {#text} at (0,0) size 283x18
+          text run at (0,0) width 283: "The two squares should have the same color:"
+      RenderBlock (anonymous) at (0,68) size 784x54
+        RenderImage {IMG} at (0,0) size 50x50
+        RenderText {#text} at (50,36) size 4x18
+          text run at (50,36) width 4: " "
+        RenderImage {IMG} at (54,0) size 50x50
+        RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/fast/replaced/image-solid-color-with-alpha.html b/LayoutTests/fast/replaced/image-solid-color-with-alpha.html
new file mode 100644 (file)
index 0000000..2ddcdb8
--- /dev/null
@@ -0,0 +1,4 @@
+<p>Test for <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=3438">bug 3438</a>: rendering of 1x1 PNG images.</p>
+<p>The two squares should have the same color:</p>
+<img width=50 height=50 src="data:image/png,%89%50%4E%47%0D%0A%1A%0A%00%00%00%0D%49%48%44%52%00%00%00%01%00%00%00%01%08%06%00%00%00%1F%15%C4%89%00%00%00%0D%49%44%41%54%08%D7%63%60%A8%FB%AF%07%00%03%AB%01%AC%78%79%CD%87%00%00%00%00%49%45%4E%44%AE%42%60%82">
+<img width=50 height=50 src="data:image/png,%89%50%4E%47%0D%0A%1A%0A%00%00%00%0D%49%48%44%52%00%00%00%02%00%00%00%02%08%06%00%00%00%72%B6%0D%24%00%00%00%10%49%44%41%54%08%D7%63%60%A8%FB%AF%07%C6%30%06%00%3A%08%06%AD%99%13%F9%18%00%00%00%00%49%45%4E%44%AE%42%60%82">
diff --git a/LayoutTests/fast/replaced/img-1x1-expected.checksum b/LayoutTests/fast/replaced/img-1x1-expected.checksum
deleted file mode 100644 (file)
index 70d94a7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-856eb8e8e0ee4834a3f069e5e710f8b6
\ No newline at end of file
diff --git a/LayoutTests/fast/replaced/img-1x1-expected.png b/LayoutTests/fast/replaced/img-1x1-expected.png
deleted file mode 100644 (file)
index 1659482..0000000
Binary files a/LayoutTests/fast/replaced/img-1x1-expected.png and /dev/null differ
diff --git a/LayoutTests/fast/replaced/img-1x1-expected.txt b/LayoutTests/fast/replaced/img-1x1-expected.txt
deleted file mode 100644 (file)
index 622a7a8..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {P} at (0,0) size 784x18
-        RenderText {#text} at (0,0) size 53x18
-          text run at (0,0) width 53: "Test for "
-        RenderInline {A} at (0,0) size 60x18 [color=#0000EE]
-          RenderText {#text} at (53,0) size 60x18
-            text run at (53,0) width 60: "bug 3438"
-        RenderText {#text} at (113,0) size 202x18
-          text run at (113,0) width 202: ": rendering of 1x1 PNG images."
-      RenderTable {TABLE} at (0,34) size 440x24
-        RenderTableSection {TBODY} at (0,0) size 440x24
-          RenderTableRow {TR} at (0,2) size 440x20
-            RenderTableCell {TD} at (2,2) size 408x20 [r=0 c=0 rs=1 cs=1]
-              RenderText {#text} at (1,1) size 406x18
-                text run at (1,1) width 406: "Should be uniform color (comparing PNG with GIF and JPEG):"
-            RenderTableCell {TD} at (412,6) size 12x12 [r=0 c=1 rs=1 cs=1]
-              RenderImage {IMG} at (1,1) size 10x10
-              RenderText {#text} at (0,0) size 0x0
-            RenderTableCell {TD} at (426,6) size 12x12 [r=0 c=2 rs=1 cs=1]
-              RenderImage {IMG} at (1,1) size 10x10
-              RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/fast/replaced/img-1x1.html b/LayoutTests/fast/replaced/img-1x1.html
deleted file mode 100644 (file)
index 2fd62eb..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<p>Test for <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=3438">bug 3438</a>: rendering of 1x1 PNG images.</p>
-<table>
-  <tr><td>Should be uniform color (comparing PNG with GIF and JPEG):</td>
-   <td style='background-image: url("data:image/png,%89%50%4e%47%0d%0a%1a%0a%00%00%00%0d%49%48%44%52%00%00%00%01%00%00%00%01%08%06%00%00%00%1f%15%c4%89%00%00%00%04%67%41%4d%41%00%00%af%c8%37%05%8a%e9%00%00%00%19%74%45%58%74%53%6f%66%74%77%61%72%65%00%41%64%6f%62%65%20%49%6d%61%67%65%52%65%61%64%79%71%c9%65%3c%00%00%00%0f%49%44%41%54%78%da%62%62%a8%fb%af%07%10%60%00%03%b5%01%ae%2f%07%97%8d%00%00%00%00%49%45%4e%44%ae%42%60%82%00");'>
-     <img width=10 height=10 src="data:image/jpeg,%ff%d8%ff%e0%00%10%4a%46%49%46%00%01%02%00%00%64%00%64%00%00%ff%ec%00%11%44%75%63%6b%79%00%01%00%04%00%00%00%3c%00%00%ff%ee%00%0e%41%64%6f%62%65%00%64%c0%00%00%00%01%ff%db%00%84%00%06%04%04%04%05%04%06%05%05%06%09%06%05%06%09%0b%08%06%06%08%0b%0c%0a%0a%0b%0a%0a%0c%10%0c%0c%0c%0c%0c%0c%10%0c%0e%0f%10%0f%0e%0c%13%13%14%14%13%13%1c%1b%1b%1b%1c%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%01%07%07%07%0d%0c%0d%18%10%10%18%1a%15%11%15%1a%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%1f%ff%c0%00%11%08%00%01%00%01%03%01%11%00%02%11%01%03%11%01%ff%c4%00%4b%00%01%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%08%01%01%01%00%00%00%00%00%00%00%00%00%00%00%00%00%00%04%05%10%01%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%11%01%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%ff%da%00%0c%03%01%00%02%11%03%11%00%3f%00%42%a9%00%ff%d9">
-   </td>
-   <td style='background-image: url("data:image/png,%89%50%4e%47%0d%0a%1a%0a%00%00%00%0d%49%48%44%52%00%00%00%01%00%00%00%01%08%06%00%00%00%1f%15%c4%89%00%00%00%04%67%41%4d%41%00%00%af%c8%37%05%8a%e9%00%00%00%19%74%45%58%74%53%6f%66%74%77%61%72%65%00%41%64%6f%62%65%20%49%6d%61%67%65%52%65%61%64%79%71%c9%65%3c%00%00%00%0f%49%44%41%54%78%da%62%62%a8%fb%af%07%10%60%00%03%b5%01%ae%2f%07%97%8d%00%00%00%00%49%45%4e%44%ae%42%60%82%00");'>
-     <img width=10 height=10 src="data:image/gif,%47%49%46%38%39%61%01%00%01%00%80%00%00%d1%e8%ff%00%00%00%21%f9%04%00%00%00%00%00%2c%00%00%00%00%01%00%01%00%00%02%02%44%01%00%3b%00">
-   </td>
-  </tr>
-</table>
index 6ddb6dc05c8305a1779064c8ca6487b89b715266..442e525ebbd75d17071442c72ede5a0b511f28ad 100644 (file)
@@ -1,3 +1,17 @@
+2006-08-02  Mitz Pettel  <opendarwin.org@mitzpettel.com>
+
+        Reviewed by Darin.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=3438
+          incorrect display of transparent 1x1 PNGs
+
+        Test: fast/replaced/image-solid-color-with-alpha.html
+
+        * platform/mac/ImageMac.mm:
+        (WebCore::Image::checkForSolidColor): Changed to divide each color component
+        by the alpha component. You need to do that since the bitmap context has
+        premultiplied alpha but m_solidColor should be non-premultiplied.
+
 2006-08-02  Adam Roben  <aroben@apple.com>
 
         Reviewed by Brady.
index 9250d82f7243eea828b34f1d0d3c14f12aa3df17..9e651ae8f549132b01e323636ad1b15298d20584 100644 (file)
@@ -118,7 +118,10 @@ void Image::checkForSolidColor()
                 GraphicsContext(bmap).setCompositeOperation(CompositeCopy);
                 CGRect dst = { {0, 0}, {1, 1} };
                 CGContextDrawImage(bmap, dst, image);
-                m_solidColor = Color(int(pixel[0] * 255), int(pixel[1] * 255), int(pixel[2] * 255), int(pixel[3] * 255));
+                if (pixel[3] == 0)
+                    m_solidColor = Color(0, 0, 0, 0);
+                else
+                    m_solidColor = Color(int(pixel[0] / pixel[3] * 255), int(pixel[1] / pixel[3] * 255), int(pixel[2] / pixel[3] * 255), int(pixel[3] * 255));
                 m_isSolidColor = true;
                 CFRelease(bmap);
             }