Support "plus-darker" in mix-blend mode
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jan 2015 16:03:53 +0000 (16:03 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jan 2015 16:03:53 +0000 (16:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140646
<rdar://problem/19523370>

Reviewed by Simon Fraser.

Source/WebCore:

Support the "plus-darker" blending mode to CSS.
See: https://lists.w3.org/Archives/Public/public-fx/2015JanMar/0021.html

Test: css3/blending/svg-blend-plus-darker.html

* css/CSSParser.cpp:
(WebCore::isValidKeywordPropertyAndValue): mix-blend-mode can now accept
the new keyword.
* css/CSSPrimitiveValueMappings.h: Add the mappings.
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator BlendMode):
* platform/graphics/GraphicsTypes.cpp: Add the new GraphicsType.
* platform/graphics/GraphicsTypes.h:
* platform/graphics/ca/mac/PlatformCAFiltersMac.mm: Map to the CA compositing filter.
(PlatformCAFilters::setBlendingFiltersOnLayer):
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::setPlatformCompositeOperation): Map to the CG blending flag.

Source/WebKit2:

Output the appropriate blending type when logging.

* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTextStream::operator<<):

LayoutTests:

Add tests and new expected results for plus-darker.

* css3/blending/blend-mode-property-parsing-expected.txt:
* css3/blending/blend-mode-simple-composited.html:
* css3/blending/blend-mode-simple.html:
* css3/blending/script-tests/blend-mode-property-parsing.js:
* css3/blending/svg-blend-plus-darker.html: Added.
* platform/mac/css3/blending/blend-mode-simple-composited-expected.png:
* platform/mac/css3/blending/blend-mode-simple-composited-expected.txt:
* platform/mac/css3/blending/blend-mode-simple-expected.png:
* platform/mac/css3/blending/blend-mode-simple-expected.txt:
* platform/mac/css3/blending/svg-blend-plus-darker-expected.txt: Added.

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

20 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/blending/blend-mode-property-parsing-expected.txt
LayoutTests/css3/blending/blend-mode-simple-composited.html
LayoutTests/css3/blending/blend-mode-simple.html
LayoutTests/css3/blending/script-tests/blend-mode-property-parsing.js
LayoutTests/css3/blending/svg-blend-plus-darker.html [new file with mode: 0644]
LayoutTests/platform/mac/css3/blending/blend-mode-simple-composited-expected.png
LayoutTests/platform/mac/css3/blending/blend-mode-simple-composited-expected.txt
LayoutTests/platform/mac/css3/blending/blend-mode-simple-expected.png
LayoutTests/platform/mac/css3/blending/blend-mode-simple-expected.txt
LayoutTests/platform/mac/css3/blending/svg-blend-plus-darker-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/platform/graphics/GraphicsTypes.cpp
Source/WebCore/platform/graphics/GraphicsTypes.h
Source/WebCore/platform/graphics/ca/mac/PlatformCAFiltersMac.mm
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm

index b7f8aa6..386f567 100644 (file)
@@ -1,3 +1,24 @@
+2015-01-19  Dean Jackson  <dino@apple.com>
+
+        Support "plus-darker" in mix-blend mode
+        https://bugs.webkit.org/show_bug.cgi?id=140646
+        <rdar://problem/19523370>
+
+        Reviewed by Simon Fraser.
+
+        Add tests and new expected results for plus-darker.
+
+        * css3/blending/blend-mode-property-parsing-expected.txt:
+        * css3/blending/blend-mode-simple-composited.html:
+        * css3/blending/blend-mode-simple.html:
+        * css3/blending/script-tests/blend-mode-property-parsing.js:
+        * css3/blending/svg-blend-plus-darker.html: Added.
+        * platform/mac/css3/blending/blend-mode-simple-composited-expected.png:
+        * platform/mac/css3/blending/blend-mode-simple-composited-expected.txt:
+        * platform/mac/css3/blending/blend-mode-simple-expected.png:
+        * platform/mac/css3/blending/blend-mode-simple-expected.txt:
+        * platform/mac/css3/blending/svg-blend-plus-darker-expected.txt: Added.
+
 2015-01-20  Andrzej Badowski  <a.badowski@samsung.com>
 
         [EFL] [GTK] Change/supplement expectations for two accessibility layout tests.
index 6d87c11..abace3e 100644 (file)
@@ -99,6 +99,14 @@ PASS declaration.getPropertyValue('mix-blend-mode') is 'exclusion'
 PASS jsWrapperClass(blendModeRule) is 'CSSPrimitiveValue'
 PASS jsWrapperClass(blendModeRule.__proto__) is 'CSSPrimitiveValuePrototype'
 PASS jsWrapperClass(blendModeRule.constructor) is 'CSSPrimitiveValueConstructor'
+
+Basic reference : plus-darker
+PASS cssRule.type is 1
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('mix-blend-mode') is 'plus-darker'
+PASS jsWrapperClass(blendModeRule) is 'CSSPrimitiveValue'
+PASS jsWrapperClass(blendModeRule.__proto__) is 'CSSPrimitiveValuePrototype'
+PASS jsWrapperClass(blendModeRule.constructor) is 'CSSPrimitiveValueConstructor'
 PASS successfullyParsed is true
 
 TEST COMPLETE
index aac0fea..2ade2a8 100644 (file)
@@ -34,5 +34,6 @@
         <li><img style="mix-blend-mode: soft-light" src="resources/ducky.png"></li>
         <li><img style="mix-blend-mode: difference" src="resources/ducky.png"></li>
         <li><img style="mix-blend-mode: exclusion" src="resources/ducky.png"></li>
+        <li><img style="mix-blend-mode: plus-darker" src="resources/ducky.png"></li>
     </ul>
 </body>
index 0175b91..b29e067 100644 (file)
@@ -38,5 +38,6 @@
         <li><img style="mix-blend-mode: soft-light" src="resources/ducky.png"></li>
         <li><img style="mix-blend-mode: difference" src="resources/ducky.png"></li>
         <li><img style="mix-blend-mode: exclusion" src="resources/ducky.png"></li>
+        <li><img style="mix-blend-mode: plus-darker" src="resources/ducky.png"></li>
     </ul>
 </body>
index 795696c..852f331 100644 (file)
@@ -43,7 +43,7 @@ function testBlendModeRule(description, rule, expectedLength, expectedValue, exp
     shouldBeType("blendModeRule", "CSSPrimitiveValue");
 }
 
-var blendmodes = ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion"];
+var blendmodes = ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "plus-darker"];
 
 for(x in blendmodes)
    testBlendModeRule("Basic reference", blendmodes[x], 1, blendmodes[x]);
diff --git a/LayoutTests/css3/blending/svg-blend-plus-darker.html b/LayoutTests/css3/blending/svg-blend-plus-darker.html
new file mode 100644 (file)
index 0000000..1f6b289
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="400px" height="400px" >
+<defs>
+  <g id="patch">
+    <rect x="0" y="0" width="10" height="40" fill="rgb(255,0,0)"/>
+    <rect x="10" y="0" width="10" height="40" fill="rgb(0,255,0)"/>
+    <rect x="20" y="0" width="10" height="40" fill="rgb(0,0,255)"/>
+    <rect x="30" y="0" width="10" height="40" fill="rgb(127,127,0)"/>
+  </g>
+  <rect x="0" y="0" width="10" height="10" fill="rgb(255,0,0)"/>
+</defs>
+<g transform="scale(4 4)">
+  <use xlink:href="#patch" x="0" y="0" width="40" height="10"></use>
+  <use xlink:href="#patch" x="0" y="0" width="40" height="10" transform="rotate(90 20 20)" style="mix-blend-mode: plus-darker"></use>
+</g>
+</svg>
+</body>
+</html>
index 20d5217..904706c 100644 (file)
Binary files a/LayoutTests/platform/mac/css3/blending/blend-mode-simple-composited-expected.png and b/LayoutTests/platform/mac/css3/blending/blend-mode-simple-composited-expected.png differ
index 84dd94c..290efab 100644 (file)
@@ -16,6 +16,7 @@ layer at (0,0) size 800x436 isolatesBlending
         RenderBlock (floating) {LI} at (605,145) size 130x130
         RenderBlock (floating) {LI} at (45,285) size 130x130
         RenderBlock (floating) {LI} at (185,285) size 130x130
+        RenderBlock (floating) {LI} at (325,285) size 130x130
 layer at (53,21) size 130x130
   RenderImage {IMG} at (0,0) size 130x130
 layer at (193,21) size 130x130 blendMode: overlay
@@ -40,3 +41,5 @@ layer at (53,301) size 130x130 blendMode: difference
   RenderImage {IMG} at (0,0) size 130x130
 layer at (193,301) size 130x130 blendMode: exclusion
   RenderImage {IMG} at (0,0) size 130x130
+layer at (333,301) size 130x130 blendMode: plus-darker
+  RenderImage {IMG} at (0,0) size 130x130
index be17047..8fda7ae 100644 (file)
Binary files a/LayoutTests/platform/mac/css3/blending/blend-mode-simple-expected.png and b/LayoutTests/platform/mac/css3/blending/blend-mode-simple-expected.png differ
index 7f016a9..5e26b3e 100644 (file)
@@ -17,6 +17,7 @@ layer at (0,0) size 800x436 isolatesBlending
         RenderBlock (floating) {LI} at (605,145) size 130x130
         RenderBlock (floating) {LI} at (45,285) size 130x130
         RenderBlock (floating) {LI} at (185,285) size 130x130
+        RenderBlock (floating) {LI} at (325,285) size 130x130
 layer at (193,21) size 130x130 blendMode: overlay
   RenderImage {IMG} at (0,0) size 130x130
 layer at (333,21) size 130x130 blendMode: screen
@@ -39,3 +40,5 @@ layer at (53,301) size 130x130 blendMode: difference
   RenderImage {IMG} at (0,0) size 130x130
 layer at (193,301) size 130x130 blendMode: exclusion
   RenderImage {IMG} at (0,0) size 130x130
+layer at (333,301) size 130x130 blendMode: plus-darker
+  RenderImage {IMG} at (0,0) size 130x130
diff --git a/LayoutTests/platform/mac/css3/blending/svg-blend-plus-darker-expected.txt b/LayoutTests/platform/mac/css3/blending/svg-blend-plus-darker-expected.txt
new file mode 100644 (file)
index 0000000..41e2833
--- /dev/null
@@ -0,0 +1,27 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x420
+  RenderBlock {HTML} at (0,0) size 800x420
+    RenderBody {BODY} at (8,8) size 784x404
+      RenderSVGRoot {svg} at (8,8) size 160x160
+        RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+          RenderSVGContainer {g} at (8,8) size 40x40
+            RenderSVGRect {rect} at (8,8) size 10x40 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=10.00] [height=40.00]
+            RenderSVGRect {rect} at (18,8) size 10x40 [fill={[type=SOLID] [color=#00FF00]}] [x=10.00] [y=0.00] [width=10.00] [height=40.00]
+            RenderSVGRect {rect} at (28,8) size 10x40 [fill={[type=SOLID] [color=#0000FF]}] [x=20.00] [y=0.00] [width=10.00] [height=40.00]
+            RenderSVGRect {rect} at (38,8) size 10x40 [fill={[type=SOLID] [color=#7F7F00]}] [x=30.00] [y=0.00] [width=10.00] [height=40.00]
+          RenderSVGRect {rect} at (8,8) size 10x10 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=10.00] [height=10.00]
+        RenderSVGContainer {g} at (8,8) size 160x160 [transform={m=((4.00,0.00)(0.00,4.00)) t=(0.00,0.00)}]
+          RenderSVGContainer {use} at (8,8) size 160x160
+            RenderSVGContainer {g} at (8,8) size 160x160
+              RenderSVGRect {rect} at (8,8) size 40x160 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=10.00] [height=40.00]
+              RenderSVGRect {rect} at (48,8) size 40x160 [fill={[type=SOLID] [color=#00FF00]}] [x=10.00] [y=0.00] [width=10.00] [height=40.00]
+              RenderSVGRect {rect} at (88,8) size 40x160 [fill={[type=SOLID] [color=#0000FF]}] [x=20.00] [y=0.00] [width=10.00] [height=40.00]
+              RenderSVGRect {rect} at (128,8) size 40x160 [fill={[type=SOLID] [color=#7F7F00]}] [x=30.00] [y=0.00] [width=10.00] [height=40.00]
+          RenderSVGContainer {use} at (8,8) size 160x160 [transform={m=((0.00,1.00)(-1.00,0.00)) t=(40.00,0.00)}]
+            RenderSVGContainer {g} at (8,8) size 160x160
+              RenderSVGRect {rect} at (8,8) size 160x40 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=10.00] [height=40.00]
+              RenderSVGRect {rect} at (8,48) size 160x40 [fill={[type=SOLID] [color=#00FF00]}] [x=10.00] [y=0.00] [width=10.00] [height=40.00]
+              RenderSVGRect {rect} at (8,88) size 160x40 [fill={[type=SOLID] [color=#0000FF]}] [x=20.00] [y=0.00] [width=10.00] [height=40.00]
+              RenderSVGRect {rect} at (8,128) size 160x40 [fill={[type=SOLID] [color=#7F7F00]}] [x=30.00] [y=0.00] [width=10.00] [height=40.00]
+      RenderText {#text} at (0,0) size 0x0
index 28f2078..ecf8924 100644 (file)
@@ -1,3 +1,29 @@
+2015-01-19  Dean Jackson  <dino@apple.com>
+
+        Support "plus-darker" in mix-blend mode
+        https://bugs.webkit.org/show_bug.cgi?id=140646
+        <rdar://problem/19523370>
+
+        Reviewed by Simon Fraser.
+
+        Support the "plus-darker" blending mode to CSS.
+        See: https://lists.w3.org/Archives/Public/public-fx/2015JanMar/0021.html
+
+        Test: css3/blending/svg-blend-plus-darker.html
+
+        * css/CSSParser.cpp:
+        (WebCore::isValidKeywordPropertyAndValue): mix-blend-mode can now accept
+        the new keyword.
+        * css/CSSPrimitiveValueMappings.h: Add the mappings.
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator BlendMode):
+        * platform/graphics/GraphicsTypes.cpp: Add the new GraphicsType.
+        * platform/graphics/GraphicsTypes.h:
+        * platform/graphics/ca/mac/PlatformCAFiltersMac.mm: Map to the CA compositing filter.
+        (PlatformCAFilters::setBlendingFiltersOnLayer):
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::setPlatformCompositeOperation): Map to the CG blending flag.
+
 2015-01-20  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Fix 'register' storage class specifier is deprecated warning
index 0ba3694..9693318 100644 (file)
@@ -815,7 +815,7 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int
         if (parserContext.isCSSCompositingEnabled && (valueID == CSSValueNormal || valueID == CSSValueMultiply || valueID == CSSValueScreen
             || valueID == CSSValueOverlay || valueID == CSSValueDarken || valueID == CSSValueLighten ||  valueID == CSSValueColorDodge
             || valueID == CSSValueColorBurn || valueID == CSSValueHardLight || valueID == CSSValueSoftLight || valueID == CSSValueDifference
-            || valueID == CSSValueExclusion))
+            || valueID == CSSValueExclusion || valueID == CSSValuePlusDarker))
             return true;
         break;
     case CSSPropertyIsolation:
index 1042b33..615d852 100644 (file)
@@ -4103,6 +4103,9 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(BlendMode blendMode)
     case BlendModeLuminosity:
         m_value.valueID = CSSValueLuminosity;
         break;
+    case BlendModePlusDarker:
+        m_value.valueID = CSSValuePlusDarker;
+        break;
     }
 }
 
@@ -4143,6 +4146,8 @@ template<> inline CSSPrimitiveValue::operator BlendMode() const
         return BlendModeColor;
     case CSSValueLuminosity:
         return BlendModeLuminosity;
+    case CSSValuePlusDarker:
+        return BlendModePlusDarker;
     default:
         break;
     }
index 251c9fc..736fb3e 100644 (file)
@@ -65,7 +65,8 @@ static const char* const blendOperatorNames[] = {
     "hue",
     "saturation",
     "color",
-    "luminosity"
+    "luminosity",
+    "plus-darker"
 };
 const int numCompositeOperatorNames = WTF_ARRAY_LENGTH(compositeOperatorNames);
 const int numBlendOperatorNames = WTF_ARRAY_LENGTH(blendOperatorNames);
index f50b9d1..d43f491 100644 (file)
@@ -63,7 +63,8 @@ namespace WebCore {
         BlendModeHue,
         BlendModeSaturation,
         BlendModeColor,
-        BlendModeLuminosity
+        BlendModeLuminosity,
+        BlendModePlusDarker
     };
 
     enum GradientSpreadMethod {
index 5bb3738..9623c06 100644 (file)
@@ -577,6 +577,9 @@ void PlatformCAFilters::setBlendingFiltersOnLayer(PlatformLayer* layer, const Bl
         case BlendModeScreen:
             filter = [CAFilter filterWithType:kCAFilterScreenBlendMode];
             break;
+        case BlendModePlusDarker:
+            filter = [CAFilter filterWithType:kCAFilterPlusD];
+            break;
         default:
             ASSERT_NOT_REACHED();
     }
index 219876c..c479559 100644 (file)
@@ -1534,6 +1534,9 @@ void GraphicsContext::setPlatformCompositeOperation(CompositeOperator mode, Blen
         case BlendModeLuminosity:
             target = kCGBlendModeLuminosity;
             break;
+        case BlendModePlusDarker:
+            target = kCGBlendModePlusDarker;
+            break;
         default:
             break;
         }
index 70b4134..ab5c72c 100644 (file)
@@ -1,3 +1,16 @@
+2015-01-19  Dean Jackson  <dino@apple.com>
+
+        Support "plus-darker" in mix-blend mode
+        https://bugs.webkit.org/show_bug.cgi?id=140646
+        <rdar://problem/19523370>
+
+        Reviewed by Simon Fraser.
+
+        Output the appropriate blending type when logging.
+
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTextStream::operator<<):
+
 2015-01-20  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Update OptionsGTK.cmake and NEWS for 2.7.4 release.
index 84944e5..9d57592 100644 (file)
@@ -835,6 +835,7 @@ RemoteLayerTreeTextStream& RemoteLayerTreeTextStream::operator<<(BlendMode blend
     case BlendModeSaturation: ts << "saturation"; break;
     case BlendModeColor: ts << "color"; break;
     case BlendModeLuminosity: ts << "luminosity"; break;
+    case BlendModePlusDarker: ts << "plus-darker"; break;
     }
     return ts;
 }