cross-fade() rendering doesn't match expectation
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 May 2016 22:40:57 +0000 (22:40 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 May 2016 22:40:57 +0000 (22:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157665
rdar://problem/17917708

Reviewed by Dean Jackson.

Source/WebCore:

Cross-fading two opaque images would result in a non-opaque result in between the endpoints,
probably because r157045 caused both images to be drawn with srcOver, since drawImage()
clobbers the composite operation in the context.

Fix by passing the composite operation to the drawImage() calls for the non-transparency layer
code path.

Converted css3/images/cross-fade-blending.html into a ref test to test this.

* platform/graphics/CrossfadeGeneratedImage.cpp:
(WebCore::drawCrossfadeSubimage):

LayoutTests:

Make css3/images/cross-fade-blending.html a ref test.

* css3/images/cross-fade-blending-expected.html: Added.
* css3/images/cross-fade-blending-expected.png: Removed.
* css3/images/cross-fade-blending-expected.txt: Removed.
* css3/images/cross-fade-blending.html:
* platform/mac/css3/images/cross-fade-blending-expected.png: Removed.

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

LayoutTests/ChangeLog
LayoutTests/css3/images/cross-fade-blending-expected.html [new file with mode: 0644]
LayoutTests/css3/images/cross-fade-blending-expected.png [deleted file]
LayoutTests/css3/images/cross-fade-blending-expected.txt [deleted file]
LayoutTests/css3/images/cross-fade-blending.html
LayoutTests/css3/images/resources/green-10-2.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/images/cross-fade-blending-expected.png [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp

index f6aafb7..32d206e 100644 (file)
@@ -1,5 +1,21 @@
 2016-05-13  Simon Fraser  <simon.fraser@apple.com>
 
+        cross-fade() rendering doesn't match expectation
+        https://bugs.webkit.org/show_bug.cgi?id=157665
+        rdar://problem/17917708
+
+        Reviewed by Dean Jackson.
+
+        Make css3/images/cross-fade-blending.html a ref test.
+
+        * css3/images/cross-fade-blending-expected.html: Added.
+        * css3/images/cross-fade-blending-expected.png: Removed.
+        * css3/images/cross-fade-blending-expected.txt: Removed.
+        * css3/images/cross-fade-blending.html:
+        * platform/mac/css3/images/cross-fade-blending-expected.png: Removed.
+
+2016-05-13  Simon Fraser  <simon.fraser@apple.com>
+
         Unprefix -webkit-cross-fade()
         https://bugs.webkit.org/show_bug.cgi?id=157632
 
diff --git a/LayoutTests/css3/images/cross-fade-blending-expected.html b/LayoutTests/css3/images/cross-fade-blending-expected.html
new file mode 100644 (file)
index 0000000..fd4d4d6
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+<style>
+div
+{
+    width: 200px;
+    height: 100px;
+}
+
+.image
+{
+    background-image: url(resources/green-10.png);
+}
+</style>
+<div class="image"></div>
+<div class="image"></div>
+<div class="image"></div>
+</html>
diff --git a/LayoutTests/css3/images/cross-fade-blending-expected.png b/LayoutTests/css3/images/cross-fade-blending-expected.png
deleted file mode 100644 (file)
index a0fc108..0000000
Binary files a/LayoutTests/css3/images/cross-fade-blending-expected.png and /dev/null differ
diff --git a/LayoutTests/css3/images/cross-fade-blending-expected.txt b/LayoutTests/css3/images/cross-fade-blending-expected.txt
deleted file mode 100644 (file)
index daa418a..0000000
+++ /dev/null
@@ -1,8 +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 {DIV} at (0,0) size 200x100
-      RenderBlock {DIV} at (0,100) size 200x100 [bgcolor=#000000]
-        RenderBlock {DIV} at (0,0) size 200x100
index 0f279c0..b6183c3 100644 (file)
@@ -2,16 +2,22 @@
 <style>
 div
 {
-       width: 200px;
-       height: 100px;
+    width: 200px;
+    height: 100px;
 }
 
-div.crossfade
+.crossfade1
 {
-       background-image: -webkit-cross-fade(url(resources/green-10.png), url(resources/green-10.png), 50%);
+    background-image: cross-fade(url(resources/green-10.png), url(resources/green-10.png), 50%);
+}
+
+.crossfade2
+{
+    background-image: cross-fade(url(resources/green-10.png), url(resources/green-10-2.png), 50%);
 }
 </style>
-<!--The first cross-fade should appear as a 100% green square, 200x200px.-->
-<div class="crossfade"></div>
-<div style="background-color: black"><div class="crossfade"></div></div>
+<!-- All rectangles should look the same-->
+<div class="crossfade1"></div>
+<div class="crossfade2"></div>
+<div style="background-color: black"><div class="crossfade2"></div></div>
 </html>
diff --git a/LayoutTests/css3/images/resources/green-10-2.png b/LayoutTests/css3/images/resources/green-10-2.png
new file mode 100644 (file)
index 0000000..8c39b0d
Binary files /dev/null and b/LayoutTests/css3/images/resources/green-10-2.png differ
diff --git a/LayoutTests/platform/mac/css3/images/cross-fade-blending-expected.png b/LayoutTests/platform/mac/css3/images/cross-fade-blending-expected.png
deleted file mode 100644 (file)
index f749155..0000000
Binary files a/LayoutTests/platform/mac/css3/images/cross-fade-blending-expected.png and /dev/null differ
index 79e596d..2c86d2e 100644 (file)
@@ -1,5 +1,25 @@
 2016-05-13  Simon Fraser  <simon.fraser@apple.com>
 
+        cross-fade() rendering doesn't match expectation
+        https://bugs.webkit.org/show_bug.cgi?id=157665
+        rdar://problem/17917708
+
+        Reviewed by Dean Jackson.
+
+        Cross-fading two opaque images would result in a non-opaque result in between the endpoints,
+        probably because r157045 caused both images to be drawn with srcOver, since drawImage()
+        clobbers the composite operation in the context.
+
+        Fix by passing the composite operation to the drawImage() calls for the non-transparency layer
+        code path.
+
+        Converted css3/images/cross-fade-blending.html into a ref test to test this.
+
+        * platform/graphics/CrossfadeGeneratedImage.cpp:
+        (WebCore::drawCrossfadeSubimage):
+
+2016-05-13  Simon Fraser  <simon.fraser@apple.com>
+
         Unprefix -webkit-cross-fade()
         https://bugs.webkit.org/show_bug.cgi?id=157632
 
index 57e3f1a..a6ad51b 100644 (file)
@@ -50,17 +50,20 @@ static void drawCrossfadeSubimage(GraphicsContext& context, Image& image, Compos
     bool useTransparencyLayer = image.isSVGImage();
 
     GraphicsContextStateSaver stateSaver(context);
+    
+    CompositeOperator drawImageOperation = operation;
 
-    context.setCompositeOperation(operation);
-
-    if (useTransparencyLayer)
+    if (useTransparencyLayer) {
+        context.setCompositeOperation(operation);
         context.beginTransparencyLayer(opacity);
-    else
+        drawImageOperation = CompositeSourceOver;
+    } else
         context.setAlpha(opacity);
 
     if (targetSize != imageSize)
         context.scale(FloatSize(targetSize.width() / imageSize.width(), targetSize.height() / imageSize.height()));
-    context.drawImage(image, IntPoint());
+
+    context.drawImage(image, IntPoint(), ImagePaintingOptions(drawImageOperation));
 
     if (useTransparencyLayer)
         context.endTransparencyLayer();