Source/WebCore: If you set a tiled cross-faded-image or a tiled gradient as
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jan 2014 16:36:50 +0000 (16:36 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jan 2014 16:36:50 +0000 (16:36 +0000)
a background layer, -webkit-background-blend-mode doesn't work.
The problem consists in the blendMode parameter not being set
for these specific drawing paths.

https://bugs.webkit.org/show_bug.cgi?id=126888
Patch by Mihai Tica <mitica@adobe.com> on 2014-01-21
Reviewed by Dirk Schulze.

Test: css3/compositing/background-blend-mode-tiled-layers.html

* platform/graphics/CrossfadeGeneratedImage.cpp:
(WebCore::CrossfadeGeneratedImage::drawPattern): Add the blendMode parameter and pass it to ImageBuffer::drawPattern.
* platform/graphics/GradientImage.cpp:
(WebCore::GradientImage::drawPattern): Add the blendMode parameter and pass it to ImageBuffer::drawPattern.
* platform/graphics/ImageBuffer.h: Add a BlendMode parameter to the drawPattern method.
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::drawPattern): Add the default BlendMode parameter to the method declaration.
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::drawPattern): Add and use the blendMode parameter for all the code paths.
* platform/graphics/wince/ImageBufferWinCE.cpp:
(WebCore::BufferedImage::drawPattern): Add the default BlendMode parameter to the method declaration.

LayoutTests: If you set a tiled cross-faded-image or a tiled gradient as
a background layer, -webkit-background-blend-mode doesn't work.
https://bugs.webkit.org/show_bug.cgi?id=126888

Patch by Mihai Tica <mitica@adobe.com> on 2014-01-21
Reviewed by Dirk Schulze.

* css3/compositing/background-blend-mode-tiled-layers-expected.html: Added.
* css3/compositing/background-blend-mode-tiled-layers.html: Added.
* platform/efl/TestExpectations: Skip test for efl, blendModes are not implemented.
* platform/mac/TestExpectations: Mark added test as ImageOnlyFailure due to slight differences between the actual result and the blending formula.

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/compositing/background-blend-mode-tiled-layers-expected.html [new file with mode: 0644]
LayoutTests/css3/compositing/background-blend-mode-tiled-layers.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp
Source/WebCore/platform/graphics/GradientImage.cpp
Source/WebCore/platform/graphics/ImageBuffer.h
Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp

index 1360029..bdbb686 100644 (file)
@@ -1,3 +1,16 @@
+2014-01-21  Mihai Tica  <mitica@adobe.com>
+
+        If you set a tiled cross-faded-image or a tiled gradient as
+        a background layer, -webkit-background-blend-mode doesn't work.
+        https://bugs.webkit.org/show_bug.cgi?id=126888
+
+        Reviewed by Dirk Schulze.
+
+        * css3/compositing/background-blend-mode-tiled-layers-expected.html: Added.
+        * css3/compositing/background-blend-mode-tiled-layers.html: Added.
+        * platform/efl/TestExpectations: Skip test for efl, blendModes are not implemented.
+        * platform/mac/TestExpectations: Mark added test as ImageOnlyFailure due to slight differences between the actual result and the blending formula.
+
 2014-01-21  Peter Molnar  <pmolnar.u-szeged@partner.samsung.com>
 
         Fix SVG animations which set rx or ry attributes
diff --git a/LayoutTests/css3/compositing/background-blend-mode-tiled-layers-expected.html b/LayoutTests/css3/compositing/background-blend-mode-tiled-layers-expected.html
new file mode 100644 (file)
index 0000000..687e16a
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+
+<!-- Test background blend mode with several tiled layers. Test passes if you can see 6 lime squares. -->
+
+<style>
+    div {
+        margin: 5px;
+        width: 100px;
+        height: 100px;
+        background: lime;
+        float: left;
+    }
+</style>
+
+<div></div>
+<div></div>
+<div></div>
+<div></div>
+<div></div>
+<div></div>
diff --git a/LayoutTests/css3/compositing/background-blend-mode-tiled-layers.html b/LayoutTests/css3/compositing/background-blend-mode-tiled-layers.html
new file mode 100644 (file)
index 0000000..6e1c171
--- /dev/null
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+
+<!-- Test background blend mode with several tiled layers. Test passes if you can see 6 lime squares. -->
+
+<style>
+    div {
+        margin: 5px;
+        width: 100px;
+        height: 100px;
+        -webkit-background-blend-mode: difference, normal;
+        float: left;
+    }
+
+    .tiledSVG {
+        background: url('data:image/svg+xml;utf8, \
+            <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"> \
+                <rect width="100" height="100" fill="#F00"/> \
+            </svg>'
+            ) 0 0 /50% 50%, #FF0;
+    }
+
+    .tiledGradient {
+        background: linear-gradient(to right, #F00 0%, #F00 100%) 0 0 /50% 50%, #FF0;
+    }
+
+    .tiledCrossfadeImage {
+        background: -webkit-cross-fade(url('data:image/svg+xml;utf8, \
+            <svg xmlns="http://www.w3.org/2000/svg" width="100px" height="100px"> \
+                <rect width="100" height="100" fill="#F00"/> \
+            </svg>'
+            ), url('data:image/svg+xml;utf8, \
+            <svg xmlns="http://www.w3.org/2000/svg" width="100px" height="100px"> \
+                <rect width="100" height="100" fill="#F00"/> \
+            </svg>'
+            ), 100%) 0 0 /50% 50%, #FF0;
+    }
+
+    .accelerated {
+        -webkit-transform: translateZ(0);
+    }
+
+</style>
+
+<script type="text/javascript">
+    if (window.testRunner)
+        window.testRunner.overridePreference("WebKitAcceleratedCompositingEnabled", "1");
+</script>
+
+<div class="tiledSVG"></div>
+<div class="tiledSVG accelerated"></div>
+
+<div class="tiledGradient"></div>
+<div class="tiledGradient accelerated"></div>
+
+<div class="tiledCrossfadeImage"></div>
+<div class="tiledCrossfadeImage accelerated"></div>
index 0f49bc4..1557a6a 100644 (file)
@@ -499,6 +499,7 @@ webkit.org/b/99200 css3/compositing/blend-mode-reflection.html [ Skip ]
 webkit.org/b/99200 css3/compositing/blend-mode-simple.html [ Skip ]
 webkit.org/b/99200 css3/compositing/blend-mode-should-not-have-compositing-layer.html [ Skip ]
 webkit.org/b/118894 css3/compositing/background-blend-mode-data-uri-svg-image.html [ Skip ]
+webkit.org/b/126888 css3/compositing/background-blend-mode-tiled-layers.html [ Skip ]
 
 # No concept of secure text input
 editing/secure-input [ Failure ]
index 00a5a45..309c4fa 100644 (file)
@@ -617,6 +617,8 @@ compositing/overflow/scrolling-without-painting.html
 
 # Blend mode result is slightly different than the applied formula.
 css3/compositing/background-blend-mode-data-uri-svg-image.html [ ImageOnlyFailure Pass ]
+css3/compositing/background-blend-mode-tiled-layers.html [ ImageOnlyFailure Pass ]
+css3/compositing/background-blend-mode-crossfade-image.html [ ImageOnlyFailure Pass ]
 
 # https://bugs.webkit.org/show_bug.cgi?id=110871
 compositing/overlap-blending/reflection-opacity-huge.html
@@ -661,9 +663,6 @@ fast/canvas/canvas-quadratic-same-endpoint.html
 css3/filters/composited-during-transition-layertree.html
 webkit.org/b/95622 css3/filters/composited-during-animation-layertree.html [ Pass Failure ]
 
-# Blending result is slightly different than the formula.
-webkit.org/b/126887 css3/compositing/background-blend-mode-crossfade-image.html [ ImageOnlyFailure Pass ]
-
 # --- Custom Filters ---
 # The following 5 tests are currently skipped on Mac for slight color differences,
 # please see the relevant bug: http://webkit.org/b/107487
index 21c0df1..73dd3f8 100644 (file)
@@ -1,3 +1,27 @@
+2014-01-21  Mihai Tica  <mitica@adobe.com>
+
+        If you set a tiled cross-faded-image or a tiled gradient as
+        a background layer, -webkit-background-blend-mode doesn't work.
+        The problem consists in the blendMode parameter not being set
+        for these specific drawing paths.
+
+        https://bugs.webkit.org/show_bug.cgi?id=126888
+        Reviewed by Dirk Schulze.
+
+        Test: css3/compositing/background-blend-mode-tiled-layers.html
+
+        * platform/graphics/CrossfadeGeneratedImage.cpp:
+        (WebCore::CrossfadeGeneratedImage::drawPattern): Add the blendMode parameter and pass it to ImageBuffer::drawPattern.
+        * platform/graphics/GradientImage.cpp:
+        (WebCore::GradientImage::drawPattern): Add the blendMode parameter and pass it to ImageBuffer::drawPattern.
+        * platform/graphics/ImageBuffer.h: Add a BlendMode parameter to the drawPattern method.
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBuffer::drawPattern): Add the default BlendMode parameter to the method declaration.
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::drawPattern): Add and use the blendMode parameter for all the code paths.
+        * platform/graphics/wince/ImageBufferWinCE.cpp:
+        (WebCore::BufferedImage::drawPattern): Add the default BlendMode parameter to the method declaration.
+
 2014-01-21  Gurpreet Kaur  <k.gurpreet@samsung.com>
 
         The WebCore.vcxproj.filters doesnot apply
index f3ba138..bf44bff 100644 (file)
@@ -96,7 +96,7 @@ void CrossfadeGeneratedImage::draw(GraphicsContext* context, const FloatRect& ds
     drawCrossfade(context);
 }
 
-void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode)
+void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode blendMode)
 {
     std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(size(), 1, ColorSpaceDeviceRGB, context->isAcceleratedContext() ? Accelerated : Unaccelerated);
     if (!imageBuffer)
@@ -107,7 +107,7 @@ void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatR
     drawCrossfade(graphicsContext);
 
     // Tile the image buffer into the context.
-    imageBuffer->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, compositeOp, dstRect);
+    imageBuffer->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, compositeOp, dstRect, blendMode);
 }
 
 }
index ff6aa36..e8c4203 100644 (file)
@@ -45,7 +45,7 @@ void GradientImage::draw(GraphicsContext* destContext, const FloatRect& destRect
 }
 
 void GradientImage::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
-    const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect, BlendMode)
+    const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect, BlendMode blendMode)
 {
     // Allow the generator to provide visually-equivalent tiling parameters for better performance.
     IntSize adjustedSize = size();
@@ -81,7 +81,7 @@ void GradientImage::drawPattern(GraphicsContext* destContext, const FloatRect& s
     destContext->setDrawLuminanceMask(false);
 
     // Tile the image buffer into the context.
-    m_cachedImageBuffer->drawPattern(destContext, adjustedSrcRect, adjustedPatternCTM, phase, styleColorSpace, compositeOp, destRect);
+    m_cachedImageBuffer->drawPattern(destContext, adjustedSrcRect, adjustedPatternCTM, phase, styleColorSpace, compositeOp, destRect, blendMode);
 }
 
 }
index 55311cf..b62e506 100644 (file)
@@ -143,7 +143,7 @@ namespace WebCore {
         void clip(GraphicsContext*, const FloatRect&) const;
 
         void draw(GraphicsContext*, ColorSpace, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1), CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false);
-        void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
+        void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode = BlendModeNormal);
 
         inline void genericConvertToLuminanceMask();
 
index 8c62e7e..00482ad 100644 (file)
@@ -153,7 +153,7 @@ void ImageBuffer::draw(GraphicsContext* destinationContext, ColorSpace styleColo
 }
 
 void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
-                              const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
+    const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode)
 {
     RefPtr<Image> image = copyImage(DontCopyBackingStore);
     image->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
index e9d346b..625af49 100644 (file)
@@ -307,7 +307,7 @@ void ImageBuffer::draw(GraphicsContext* destContext, ColorSpace styleColorSpace,
     destContext->drawNativeImage(image.get(), m_data.m_backingStoreSize, colorSpace, destRect, adjustedSrcRect, 1, op, blendMode);
 }
 
-void ImageBuffer::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
+void ImageBuffer::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode)
 {
     FloatRect adjustedSrcRect = srcRect;
     adjustedSrcRect.scale(m_resolutionScale, m_resolutionScale);
@@ -315,14 +315,14 @@ void ImageBuffer::drawPattern(GraphicsContext* destContext, const FloatRect& src
     if (!m_context->isAcceleratedContext()) {
         if (destContext == m_context || destContext->isAcceleratedContext()) {
             RefPtr<Image> copy = copyImage(CopyBackingStore); // Drawing into our own buffer, need to deep copy.
-            copy->drawPattern(destContext, adjustedSrcRect, patternTransform, phase, styleColorSpace, op, destRect);
+            copy->drawPattern(destContext, adjustedSrcRect, patternTransform, phase, styleColorSpace, op, destRect, blendMode);
         } else {
             RefPtr<Image> imageForRendering = copyImage(DontCopyBackingStore);
-            imageForRendering->drawPattern(destContext, adjustedSrcRect, patternTransform, phase, styleColorSpace, op, destRect);
+            imageForRendering->drawPattern(destContext, adjustedSrcRect, patternTransform, phase, styleColorSpace, op, destRect, blendMode);
         }
     } else {
         RefPtr<Image> copy = copyImage(CopyBackingStore);
-        copy->drawPattern(destContext, adjustedSrcRect, patternTransform, phase, styleColorSpace, op, destRect);
+        copy->drawPattern(destContext, adjustedSrcRect, patternTransform, phase, styleColorSpace, op, destRect, blendMode);
     }
 }
 
index 271d112..2cc23f8 100644 (file)
@@ -56,7 +56,7 @@ void BufferedImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const
 }
 
 void BufferedImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRectIn, const AffineTransform& patternTransform,
-                             const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
+    const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode)
 {
     m_data->m_bitmap->drawPattern(ctxt, tileRectIn, patternTransform, phase, styleColorSpace, op, destRect, size());
 }