Title: [195745] trunk
Revision
195745
Author
[email protected]
Date
2016-01-28 09:33:46 -0800 (Thu, 28 Jan 2016)

Log Message

[SVG] Add support for 'lighter' operator in feComposite
https://bugs.webkit.org/show_bug.cgi?id=141376

Patch by Nikos Andronikos <[email protected]> on 2016-01-28
Reviewed by Darin Adler.

Source/WebCore:

Added new cases where needed to support the lighter (aka 'plus')
Porter Duff operator in SVG Filter Effects.
https://www.w3.org/TR/filter-effects/#valdef-operator-lighter
Note that in the specification, no constant was added to the IDL for
the lighter operator.

Test: svg/filters/feCompositeOpaque.html
      svg/dom/script-tests/SVGAnimatedEnumeration-SVGFECompositeElement.js

* platform/graphics/filters/FEComposite.cpp:
(WebCore::FEComposite::platformApplySoftware):
  Add case to support lighter.
(WebCore::operator<<):
  Add case to support lighter for text stream operations.
* platform/graphics/filters/FEComposite.h:
  Add case for lighter to CompositeOperationType enum.
* svg/SVGFECompositeElement.h:
(WebCore::SVGIDLEnumLimits<CompositeOperationType>::highestExposedEnumValue):
  Higest exposed value is arithmetic - do not expose lighter.
(WebCore::SVGPropertyTraits<CompositeOperationType>::highestEnumValue):
  Highest possible value is now lighter.
(WebCore::SVGPropertyTraits<CompositeOperationType>::toString):
  Add case to support lighter.
(WebCore::SVGPropertyTraits<CompositeOperationType>::fromString):
  Add case to support lighter.

LayoutTests:

Add case to support lighter to DOM manipulation test for feComposite.
Add a new reftest that tests lighter case and supercedes older
pixel test for other modes.

* svg/dom/script-tests/SVGAnimatedEnumeration-SVGFECompositeElement.js:
  Test DOM read/write of SVGFEComposite operator property with new
  lighter mode.
* svg/dom/SVGAnimatedEnumeration-SVGFECompositeElement-expected.txt:
* svg/filters/feCompositeOpaque.html: Added.
  A reftest that supersedes svg/filters/feComposite.svg
  That test used opacity 0.5 which resulted in differing colors
  across platforms. This makes it very hard to maintain the references
  but it's probably still useful as a regression test.
  This new test uses solid colors which result in consistency across
  platforms and allow a reftest to be used.
* svg/filters/feCompositeOpaque-expected.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (195744 => 195745)


--- trunk/LayoutTests/ChangeLog	2016-01-28 17:30:00 UTC (rev 195744)
+++ trunk/LayoutTests/ChangeLog	2016-01-28 17:33:46 UTC (rev 195745)
@@ -1,3 +1,27 @@
+2016-01-28  Nikos Andronikos  <[email protected]>
+
+        [SVG] Add support for 'lighter' operator in feComposite
+        https://bugs.webkit.org/show_bug.cgi?id=141376
+
+        Reviewed by Darin Adler.
+
+        Add case to support lighter to DOM manipulation test for feComposite.
+        Add a new reftest that tests lighter case and supercedes older
+        pixel test for other modes.
+
+        * svg/dom/script-tests/SVGAnimatedEnumeration-SVGFECompositeElement.js:
+          Test DOM read/write of SVGFEComposite operator property with new
+          lighter mode.
+        * svg/dom/SVGAnimatedEnumeration-SVGFECompositeElement-expected.txt:
+        * svg/filters/feCompositeOpaque.html: Added.
+          A reftest that supersedes svg/filters/feComposite.svg
+          That test used opacity 0.5 which resulted in differing colors
+          across platforms. This makes it very hard to maintain the references
+          but it's probably still useful as a regression test.
+          This new test uses solid colors which result in consistency across
+          platforms and allow a reftest to be used.
+        * svg/filters/feCompositeOpaque-expected.html: Added.
+
 2016-01-28  Darin Adler  <[email protected]>
 
         Remove equalIgnoringCase since all callers really wanted equalIgnoringASCIICase

Modified: trunk/LayoutTests/svg/dom/SVGAnimatedEnumeration-SVGFECompositeElement-expected.txt (195744 => 195745)


--- trunk/LayoutTests/svg/dom/SVGAnimatedEnumeration-SVGFECompositeElement-expected.txt	2016-01-28 17:30:00 UTC (rev 195744)
+++ trunk/LayoutTests/svg/dom/SVGAnimatedEnumeration-SVGFECompositeElement-expected.txt	2016-01-28 17:33:46 UTC (rev 195745)
@@ -14,6 +14,11 @@
 PASS feCompositeElement.operator.baseVal is SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_IN
 PASS feCompositeElement.getAttribute('operator') is "in"
 
+Switch to 'over'
+PASS feCompositeElement.operator.baseVal = SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER is SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER
+PASS feCompositeElement.operator.baseVal is SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER
+PASS feCompositeElement.getAttribute('operator') is "over"
+
 Switch to 'out'
 PASS feCompositeElement.operator.baseVal = SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OUT is SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OUT
 PASS feCompositeElement.operator.baseVal is SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OUT
@@ -45,10 +50,9 @@
 PASS feCompositeElement.operator.baseVal is SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_ARITHMETIC
 PASS feCompositeElement.getAttribute('operator') is "arithmetic"
 
-Switch to 'over'
-PASS feCompositeElement.operator.baseVal = SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER is SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER
-PASS feCompositeElement.operator.baseVal is SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER
-PASS feCompositeElement.getAttribute('operator') is "over"
+Switch to 'lighter'
+PASS feCompositeElement.operator.baseVal is SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_UNKNOWN
+PASS feCompositeElement.getAttribute('operator') is "lighter"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/svg/dom/script-tests/SVGAnimatedEnumeration-SVGFECompositeElement.js (195744 => 195745)


--- trunk/LayoutTests/svg/dom/script-tests/SVGAnimatedEnumeration-SVGFECompositeElement.js	2016-01-28 17:30:00 UTC (rev 195744)
+++ trunk/LayoutTests/svg/dom/script-tests/SVGAnimatedEnumeration-SVGFECompositeElement.js	2016-01-28 17:33:46 UTC (rev 195745)
@@ -16,6 +16,12 @@
 shouldBeEqualToString("feCompositeElement.getAttribute('operator')", "in");
 
 debug("");
+debug("Switch to 'over'");
+shouldBe("feCompositeElement.operator.baseVal = SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER", "SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER");
+shouldBe("feCompositeElement.operator.baseVal", "SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER");
+shouldBeEqualToString("feCompositeElement.getAttribute('operator')", "over");
+
+debug("");
 debug("Switch to 'out'");
 shouldBe("feCompositeElement.operator.baseVal = SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OUT", "SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OUT");
 shouldBe("feCompositeElement.operator.baseVal", "SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OUT");
@@ -39,6 +45,11 @@
 shouldBe("feCompositeElement.operator.baseVal", "SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_ARITHMETIC");
 shouldBeEqualToString("feCompositeElement.getAttribute('operator')", "arithmetic");
 
+// Compositing modes added to SVG 2 do not expose their enumeration values through
+// the IDL the way older modes did. Therefore, lighter cannot be selected by
+// setting operator.baseVal and SVG_FECOMPOSITE_OPERATOR_UNKNOWN is returned
+// for all new modes.
+
 debug("");
 debug("Try setting invalid values");
 shouldThrow("feCompositeElement.operator.baseVal = 7");
@@ -54,9 +65,9 @@
 shouldBeEqualToString("feCompositeElement.getAttribute('operator')", "arithmetic");
 
 debug("");
-debug("Switch to 'over'");
-shouldBe("feCompositeElement.operator.baseVal = SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER", "SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER");
-shouldBe("feCompositeElement.operator.baseVal", "SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER");
-shouldBeEqualToString("feCompositeElement.getAttribute('operator')", "over");
+debug("Switch to 'lighter'");
+feCompositeElement.setAttribute('operator', 'lighter');
+shouldBe("feCompositeElement.operator.baseVal", "SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_UNKNOWN");
+shouldBeEqualToString("feCompositeElement.getAttribute('operator')", "lighter");
 
 successfullyParsed = true;

Added: trunk/LayoutTests/svg/filters/feCompositeOpaque-expected.html (0 => 195745)


--- trunk/LayoutTests/svg/filters/feCompositeOpaque-expected.html	                        (rev 0)
+++ trunk/LayoutTests/svg/filters/feCompositeOpaque-expected.html	2016-01-28 17:33:46 UTC (rev 195745)
@@ -0,0 +1,45 @@
+<!-- feComposite reference image -->
+<style>
+* { margin: 0; padding: 0; }
+svg { width: 700px;}
+</style>
+
+<body>
+<svg viewBox="0 0 700 100">
+
+<path d="M 0,0 h75 v75 h-75 z" fill="#f00" />
+<path d="M 25,25 h75 v75 h-75 z" fill="#00f" />
+
+<g transform="translate(100,0)">
+<path d="M 25,25 h50 v50 h-50 z" fill="#00f" />
+</g>
+
+<g transform="translate(200,0)">
+<path d="M 0,0 h75 v75 h-75 z" fill="#f00" />
+<path d="M 25,25 h50 v50 h-50 z" fill="#00f" />
+</g>
+
+<g transform="translate(300,0)">
+<path d="M 75,25 h25 v75 h-75 v-25 h50 z" fill="#00f" />
+</g>
+
+<g transform="translate(400,0)">
+<path d="M 0,0 h75 v25 h-50 v50 h-25 z" fill="#f00" />
+<path d="M 75,25 h25 v75 h-75 v-25 h50 z" fill="#00f" />
+</g>
+
+<g transform="translate(500,0)">
+<path d="M 0,0 h75 v75 h-75 z" fill="#ff8080" />
+<path d="M 25,25 h75 v75 h-75 z" fill="#8080ff" />
+<path d="M 25,25 h50 v50 h-50 z" fill="#b0b" />
+</g>
+
+<g transform="translate(600,0)">
+<path d="M 0,0 h75 v75 h-75 z" fill="#f00" />
+<path d="M 25,25 h75 v75 h-75 z" fill="#00f" />
+<path d="M 25,25 h50 v50 h-50 z" fill="#f0f" />
+</g>
+
+</svg>
+
+

Added: trunk/LayoutTests/svg/filters/feCompositeOpaque.html (0 => 195745)


--- trunk/LayoutTests/svg/filters/feCompositeOpaque.html	                        (rev 0)
+++ trunk/LayoutTests/svg/filters/feCompositeOpaque.html	2016-01-28 17:33:46 UTC (rev 195745)
@@ -0,0 +1,57 @@
+<!-- 
+  Tests each feComposite operator.
+  Only uses full opacity so that results are consistent across platforms.
+-->
+<style>
+* { margin: 0; padding: 0; }
+svg {width: 700px;}
+</style>
+
+<body>
+<svg viewBox="0 0 700 100">
+<defs>
+    <filter id="composite1" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
+        <feFlood flood-color="#f00" flood-opacity="1" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+        <feFlood flood-color="#00f" flood-opacity="1" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+        <feComposite id="fecomposite1" operator="over" in2="res1" in="res2"/>
+    </filter>
+    <filter id="composite2" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
+        <feFlood flood-color="#f00" flood-opacity="1" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+        <feFlood flood-color="#00f" flood-opacity="1" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+        <feComposite id="fecomposite2" operator="in" in2="res1" in="res2"/>
+    </filter>
+    <filter id="composite3" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
+        <feFlood flood-color="#f00" flood-opacity="1" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+        <feFlood flood-color="#00f" flood-opacity="1" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+        <feComposite id="fecomposite3" operator="atop" in2="res1" in="res2"/>
+    </filter>
+    <filter id="composite4" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
+        <feFlood flood-color="#f00" flood-opacity="1" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+        <feFlood flood-color="#00f" flood-opacity="1" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+        <feComposite id="fecomposite4" operator="out" in2="res1" in="res2"/>
+    </filter>
+    <filter id="composite5" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
+        <feFlood flood-color="#f00" flood-opacity="1" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+        <feFlood flood-color="#00f" flood-opacity="1" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+        <feComposite id="fecomposite5" operator="xor" in2="res1" in="res2"/>
+    </filter>
+    <filter id="composite6" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
+        <feFlood flood-color="#f00" flood-opacity="1" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+        <feFlood flood-color="#00f" flood-opacity="1" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+        <feComposite id="fecomposite6" operator="arithmetic" in2="res1" in="res2" k1="1" k2="0.5" k3="0.5" k4="0"/>
+    </filter>
+    <filter id="composite7" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
+        <feFlood flood-color="#f00" flood-opacity="1" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+        <feFlood flood-color="#00f" flood-opacity="1" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+        <feComposite id="fecomposite7" operator="lighter" in2="res1" in="res2"/>
+    </filter>
+</defs>
+<rect x="0" y="0" width="100" height="100" filter="url(#composite1)"/>
+<rect x="100" y="0" width="100" height="100" filter="url(#composite2)"/>
+<rect x="200" y="0" width="100" height="100" filter="url(#composite3)"/>
+<rect x="300" y="0" width="100" height="100" filter="url(#composite4)"/>
+<rect x="400" y="0" width="100" height="100" filter="url(#composite5)"/>
+<rect x="500" y="0" width="100" height="100" filter="url(#composite6)"/>
+<rect x="600" y="0" width="100" height="100" filter="url(#composite7)"/>
+</svg>
+

Modified: trunk/Source/WebCore/ChangeLog (195744 => 195745)


--- trunk/Source/WebCore/ChangeLog	2016-01-28 17:30:00 UTC (rev 195744)
+++ trunk/Source/WebCore/ChangeLog	2016-01-28 17:33:46 UTC (rev 195745)
@@ -1,3 +1,36 @@
+2016-01-28  Nikos Andronikos  <[email protected]>
+
+        [SVG] Add support for 'lighter' operator in feComposite
+        https://bugs.webkit.org/show_bug.cgi?id=141376
+
+        Reviewed by Darin Adler.
+
+        Added new cases where needed to support the lighter (aka 'plus')
+        Porter Duff operator in SVG Filter Effects.
+        https://www.w3.org/TR/filter-effects/#valdef-operator-lighter
+        Note that in the specification, no constant was added to the IDL for
+        the lighter operator. 
+
+        Test: svg/filters/feCompositeOpaque.html
+              svg/dom/script-tests/SVGAnimatedEnumeration-SVGFECompositeElement.js
+
+        * platform/graphics/filters/FEComposite.cpp:
+        (WebCore::FEComposite::platformApplySoftware):
+          Add case to support lighter.
+        (WebCore::operator<<):
+          Add case to support lighter for text stream operations.
+        * platform/graphics/filters/FEComposite.h:
+          Add case for lighter to CompositeOperationType enum.
+        * svg/SVGFECompositeElement.h:
+        (WebCore::SVGIDLEnumLimits<CompositeOperationType>::highestExposedEnumValue):
+          Higest exposed value is arithmetic - do not expose lighter.
+        (WebCore::SVGPropertyTraits<CompositeOperationType>::highestEnumValue):
+          Highest possible value is now lighter.
+        (WebCore::SVGPropertyTraits<CompositeOperationType>::toString):
+          Add case to support lighter.
+        (WebCore::SVGPropertyTraits<CompositeOperationType>::fromString):
+          Add case to support lighter.
+
 2016-01-28  Darin Adler  <[email protected]>
 
         Remove equalIgnoringCase since all callers really wanted equalIgnoringASCIICase

Modified: trunk/Source/WebCore/platform/graphics/filters/FEComposite.cpp (195744 => 195745)


--- trunk/Source/WebCore/platform/graphics/filters/FEComposite.cpp	2016-01-28 17:30:00 UTC (rev 195744)
+++ trunk/Source/WebCore/platform/graphics/filters/FEComposite.cpp	2016-01-28 17:33:46 UTC (rev 195745)
@@ -310,6 +310,10 @@
         filterContext.drawImageBuffer(*imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()));
         filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositeXOR);
         break;
+    case FECOMPOSITE_OPERATOR_LIGHTER:
+        filterContext.drawImageBuffer(*imageBuffer2, drawingRegionOfInputImage(in2->absolutePaintRect()));
+        filterContext.drawImageBuffer(*imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositePlusLighter);
+        break;
     default:
         break;
     }
@@ -343,6 +347,9 @@
     case FECOMPOSITE_OPERATOR_ARITHMETIC:
         ts << "ARITHMETIC";
         break;
+    case FECOMPOSITE_OPERATOR_LIGHTER:
+        ts << "LIGHTER";
+        break;
     }
     return ts;
 }

Modified: trunk/Source/WebCore/platform/graphics/filters/FEComposite.h (195744 => 195745)


--- trunk/Source/WebCore/platform/graphics/filters/FEComposite.h	2016-01-28 17:30:00 UTC (rev 195744)
+++ trunk/Source/WebCore/platform/graphics/filters/FEComposite.h	2016-01-28 17:33:46 UTC (rev 195745)
@@ -36,7 +36,8 @@
     FECOMPOSITE_OPERATOR_OUT        = 3,
     FECOMPOSITE_OPERATOR_ATOP       = 4,
     FECOMPOSITE_OPERATOR_XOR        = 5,
-    FECOMPOSITE_OPERATOR_ARITHMETIC = 6
+    FECOMPOSITE_OPERATOR_ARITHMETIC = 6,
+    FECOMPOSITE_OPERATOR_LIGHTER    = 7
 };
 
 class FEComposite : public FilterEffect {

Modified: trunk/Source/WebCore/svg/SVGFECompositeElement.h (195744 => 195745)


--- trunk/Source/WebCore/svg/SVGFECompositeElement.h	2016-01-28 17:30:00 UTC (rev 195744)
+++ trunk/Source/WebCore/svg/SVGFECompositeElement.h	2016-01-28 17:33:46 UTC (rev 195745)
@@ -29,8 +29,11 @@
 namespace WebCore {
 
 template<>
+inline unsigned SVGIDLEnumLimits<CompositeOperationType>::highestExposedEnumValue() { return FECOMPOSITE_OPERATOR_ARITHMETIC; }
+
+template<>
 struct SVGPropertyTraits<CompositeOperationType> {
-    static unsigned highestEnumValue() { return FECOMPOSITE_OPERATOR_ARITHMETIC; }
+    static unsigned highestEnumValue() { return FECOMPOSITE_OPERATOR_LIGHTER; }
 
     static String toString(CompositeOperationType type)
     {
@@ -49,6 +52,8 @@
             return "xor";
         case FECOMPOSITE_OPERATOR_ARITHMETIC:
             return "arithmetic";
+        case FECOMPOSITE_OPERATOR_LIGHTER:
+            return "lighter";
         }
 
         ASSERT_NOT_REACHED();
@@ -69,6 +74,8 @@
             return FECOMPOSITE_OPERATOR_XOR;
         if (value == "arithmetic")
             return FECOMPOSITE_OPERATOR_ARITHMETIC;
+        if (value == "lighter")
+            return FECOMPOSITE_OPERATOR_LIGHTER;
         return FECOMPOSITE_OPERATOR_UNKNOWN;
     }
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to