Title: [147470] trunk
Revision
147470
Author
[email protected]
Date
2013-04-02 11:23:30 -0700 (Tue, 02 Apr 2013)

Log Message

[Skia] Enable GPU-accelerated Skia path for FEComposite filter.
https://bugs.webkit.org/show_bug.cgi?id=113797

Reviewed by Adrienne Walker.

Source/WebCore:

Tests: css3/filters/effect-reference-composite-hw.html
       css3/filters/effect-reference-composite.html

* WebCore.gypi:
* platform/graphics/filters/FEComposite.h:
Enable Skia DAG hook for FEComposite.
* platform/graphics/filters/skia/FECompositeSkia.cpp: Added.
(WebCore::FEComposite::createImageFilter):
Implement skia DAG builder for FEComposite, and implement generic
skia version of composite filter.

LayoutTests:

* css3/filters/effect-reference-composite-hw.html: Added.
* css3/filters/effect-reference-composite.html: Added.
* platform/chromium-linux/css3/filters/effect-reference-composite-expected.png: Added.
* platform/chromium-linux/css3/filters/effect-reference-composite-expected.txt: Added.
* platform/chromium-linux/css3/filters/effect-reference-composite-hw-expected.png: Added.
* platform/chromium-linux/css3/filters/effect-reference-composite-hw-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (147469 => 147470)


--- trunk/LayoutTests/ChangeLog	2013-04-02 18:20:14 UTC (rev 147469)
+++ trunk/LayoutTests/ChangeLog	2013-04-02 18:23:30 UTC (rev 147470)
@@ -1,3 +1,17 @@
+2013-04-02  Stephen White  <[email protected]>
+
+        [Skia] Enable GPU-accelerated Skia path for FEComposite filter.
+        https://bugs.webkit.org/show_bug.cgi?id=113797
+
+        Reviewed by Adrienne Walker.
+
+        * css3/filters/effect-reference-composite-hw.html: Added.
+        * css3/filters/effect-reference-composite.html: Added.
+        * platform/chromium-linux/css3/filters/effect-reference-composite-expected.png: Added.
+        * platform/chromium-linux/css3/filters/effect-reference-composite-expected.txt: Added.
+        * platform/chromium-linux/css3/filters/effect-reference-composite-hw-expected.png: Added.
+        * platform/chromium-linux/css3/filters/effect-reference-composite-hw-expected.txt: Added.
+
 2013-04-02  Andrey Kosyakov  <[email protected]>
 
         Web Inspector: [Timeline] warning markers are not propagated to coalesced records

Added: trunk/LayoutTests/css3/filters/effect-reference-composite-hw.html (0 => 147470)


--- trunk/LayoutTests/css3/filters/effect-reference-composite-hw.html	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/effect-reference-composite-hw.html	2013-04-02 18:23:30 UTC (rev 147470)
@@ -0,0 +1,34 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" version="1.1">
+  <defs>
+    <filter id="over">
+      <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 0.7 0" result="matrix"/>
+      <feComposite in2="matrix" operator="over"/>
+    </filter>
+    <filter id="in">
+      <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 0.7 0" result="matrix"/>
+      <feComposite in2="matrix" operator="in"/>
+    </filter>
+    <filter id="out">
+      <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 0.7 0" result="matrix"/>
+      <feComposite in2="matrix" operator="out"/>
+    </filter>
+    <filter id="atop">
+      <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 0.7 0" result="matrix"/>
+      <feComposite in2="matrix" operator="atop"/>
+    </filter>
+    <filter id="xor">
+      <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 0.7 0" result="matrix"/>
+      <feComposite in2="matrix" operator="xor"/>
+    </filter>
+  </defs>
+</svg>
+<style>
+img {
+    margin: 10px;
+}
+</style>
+<img style="-webkit-filter: url(#over); filter: url(#over); -webkit-transform: translateZ(0);" src=""
+<img style="-webkit-filter: url(#in);   filter: url(#in);   -webkit-transform: translateZ(0);"   src=""
+<img style="-webkit-filter: url(#out);  filter: url(#out);  -webkit-transform: translateZ(0);"  src=""
+<img style="-webkit-filter: url(#atop); filter: url(#atop); -webkit-transform: translateZ(0);" src=""
+<img style="-webkit-filter: url(#xor);  filter: url(#xor);  -webkit-transform: translateZ(0);"  src=""

Added: trunk/LayoutTests/css3/filters/effect-reference-composite.html (0 => 147470)


--- trunk/LayoutTests/css3/filters/effect-reference-composite.html	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/effect-reference-composite.html	2013-04-02 18:23:30 UTC (rev 147470)
@@ -0,0 +1,34 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" version="1.1">
+  <defs>
+    <filter id="over">
+      <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 0.7 0" result="matrix"/>
+      <feComposite in2="matrix" operator="over"/>
+    </filter>
+    <filter id="in">
+      <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 0.7 0" result="matrix"/>
+      <feComposite in2="matrix" operator="in"/>
+    </filter>
+    <filter id="out">
+      <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 0.7 0" result="matrix"/>
+      <feComposite in2="matrix" operator="out"/>
+    </filter>
+    <filter id="atop">
+      <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 0.7 0" result="matrix"/>
+      <feComposite in2="matrix" operator="atop"/>
+    </filter>
+    <filter id="xor">
+      <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 0.7 0" result="matrix"/>
+      <feComposite in2="matrix" operator="xor"/>
+    </filter>
+  </defs>
+</svg>
+<style>
+img {
+    margin: 10px;
+}
+</style>
+<img style="-webkit-filter: url(#over); filter: url(#over);" src=""
+<img style="-webkit-filter: url(#in);   filter: url(#in);"   src=""
+<img style="-webkit-filter: url(#out);  filter: url(#out);"  src=""
+<img style="-webkit-filter: url(#atop); filter: url(#atop);" src=""
+<img style="-webkit-filter: url(#xor);  filter: url(#xor);"  src=""

Added: trunk/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-composite-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-composite-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-composite-expected.txt (0 => 147470)


--- trunk/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-composite-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-composite-expected.txt	2013-04-02 18:23:30 UTC (rev 147470)
@@ -0,0 +1,59 @@
+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
+      RenderSVGRoot {svg} at (8,118) size 0x0
+        RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+          RenderSVGResourceFilter {filter} [id="over"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feComposite operation="OVER"]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+          RenderSVGResourceFilter {filter} [id="in"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feComposite operation="IN"]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+          RenderSVGResourceFilter {filter} [id="out"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feComposite operation="OUT"]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+          RenderSVGResourceFilter {filter} [id="atop"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feComposite operation="ATOP"]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+          RenderSVGResourceFilter {filter} [id="xor"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feComposite operation="XOR"]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+      RenderText {#text} at (0,95) size 4x19
+        text run at (0,95) width 4: " "
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (184,95) size 4x19
+        text run at (184,95) width 4: " "
+      RenderText {#text} at (368,95) size 4x19
+        text run at (368,95) width 4: " "
+      RenderText {#text} at (552,95) size 4x19
+        text run at (552,95) width 4: " "
+      RenderText {#text} at (736,95) size 4x19
+        text run at (736,95) width 4: " "
+      RenderText {#text} at (0,0) size 0x0
+layer at (22,18) size 160x90
+  RenderImage {IMG} at (14,10) size 160x90
+layer at (206,18) size 160x90
+  RenderImage {IMG} at (198,10) size 160x90
+layer at (390,18) size 160x90
+  RenderImage {IMG} at (382,10) size 160x90
+layer at (574,18) size 160x90
+  RenderImage {IMG} at (566,10) size 160x90
+layer at (18,133) size 160x90
+  RenderImage {IMG} at (10,125) size 160x90

Added: trunk/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-composite-hw-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-composite-hw-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-composite-hw-expected.txt (0 => 147470)


--- trunk/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-composite-hw-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium-linux/css3/filters/effect-reference-composite-hw-expected.txt	2013-04-02 18:23:30 UTC (rev 147470)
@@ -0,0 +1,59 @@
+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
+      RenderSVGRoot {svg} at (8,118) size 0x0
+        RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+          RenderSVGResourceFilter {filter} [id="over"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feComposite operation="OVER"]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+          RenderSVGResourceFilter {filter} [id="in"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feComposite operation="IN"]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+          RenderSVGResourceFilter {filter} [id="out"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feComposite operation="OUT"]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+          RenderSVGResourceFilter {filter} [id="atop"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feComposite operation="ATOP"]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+          RenderSVGResourceFilter {filter} [id="xor"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
+            [feComposite operation="XOR"]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+              [feColorMatrix type="MATRIX" values="1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.70 0.00"]
+                [SourceGraphic]
+      RenderText {#text} at (0,95) size 4x19
+        text run at (0,95) width 4: " "
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (184,95) size 4x19
+        text run at (184,95) width 4: " "
+      RenderText {#text} at (368,95) size 4x19
+        text run at (368,95) width 4: " "
+      RenderText {#text} at (552,95) size 4x19
+        text run at (552,95) width 4: " "
+      RenderText {#text} at (736,95) size 4x19
+        text run at (736,95) width 4: " "
+      RenderText {#text} at (0,0) size 0x0
+layer at (22,18) size 160x90
+  RenderImage {IMG} at (14,10) size 160x90
+layer at (206,18) size 160x90
+  RenderImage {IMG} at (198,10) size 160x90
+layer at (390,18) size 160x90
+  RenderImage {IMG} at (382,10) size 160x90
+layer at (574,18) size 160x90
+  RenderImage {IMG} at (566,10) size 160x90
+layer at (18,133) size 160x90
+  RenderImage {IMG} at (10,125) size 160x90

Modified: trunk/Source/WebCore/ChangeLog (147469 => 147470)


--- trunk/Source/WebCore/ChangeLog	2013-04-02 18:20:14 UTC (rev 147469)
+++ trunk/Source/WebCore/ChangeLog	2013-04-02 18:23:30 UTC (rev 147470)
@@ -1,3 +1,21 @@
+2013-04-02  Stephen White  <[email protected]>
+
+        [Skia] Enable GPU-accelerated Skia path for FEComposite filter.
+        https://bugs.webkit.org/show_bug.cgi?id=113797
+
+        Reviewed by Adrienne Walker.
+
+        Tests: css3/filters/effect-reference-composite-hw.html
+               css3/filters/effect-reference-composite.html
+
+        * WebCore.gypi:
+        * platform/graphics/filters/FEComposite.h:
+        Enable Skia DAG hook for FEComposite.
+        * platform/graphics/filters/skia/FECompositeSkia.cpp: Added.
+        (WebCore::FEComposite::createImageFilter):
+        Implement skia DAG builder for FEComposite, and implement generic
+        skia version of composite filter.
+
 2013-04-02  Andrey Lushnikov  <[email protected]>
 
         Web Inspector: Avoid using style.display="inline-block"

Modified: trunk/Source/WebCore/WebCore.gypi (147469 => 147470)


--- trunk/Source/WebCore/WebCore.gypi	2013-04-02 18:20:14 UTC (rev 147469)
+++ trunk/Source/WebCore/WebCore.gypi	2013-04-02 18:23:30 UTC (rev 147470)
@@ -4087,6 +4087,7 @@
             'platform/graphics/filters/SpotLightSource.h',
             'platform/graphics/filters/skia/FEBlendSkia.cpp',
             'platform/graphics/filters/skia/FEColorMatrixSkia.cpp',
+            'platform/graphics/filters/skia/FECompositeSkia.cpp',
             'platform/graphics/filters/skia/FEComponentTransferSkia.cpp',
             'platform/graphics/filters/skia/FEConvolveMatrixSkia.cpp',
             'platform/graphics/filters/skia/FEDisplacementMapSkia.cpp',

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


--- trunk/Source/WebCore/platform/graphics/filters/FEComposite.h	2013-04-02 18:20:14 UTC (rev 147469)
+++ trunk/Source/WebCore/platform/graphics/filters/FEComposite.h	2013-04-02 18:23:30 UTC (rev 147470)
@@ -68,6 +68,10 @@
 
     virtual TextStream& externalRepresentation(TextStream&, int indention) const;
 
+#if USE(SKIA)
+    virtual SkImageFilter* createImageFilter(SkiaImageFilterBuilder*);
+#endif
+
 protected:
     virtual bool requiresValidPreMultipliedPixels() OVERRIDE { return m_type != FECOMPOSITE_OPERATOR_ARITHMETIC; }
 

Added: trunk/Source/WebCore/platform/graphics/filters/skia/FECompositeSkia.cpp (0 => 147470)


--- trunk/Source/WebCore/platform/graphics/filters/skia/FECompositeSkia.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/filters/skia/FECompositeSkia.cpp	2013-04-02 18:23:30 UTC (rev 147470)
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#if USE(SKIA)
+#include "FEComposite.h"
+
+#include "SkFlattenableBuffers.h"
+#include "SkMorphologyImageFilter.h"
+#include "SkiaImageFilterBuilder.h"
+
+namespace {
+
+class CompositeImageFilter : public SkImageFilter {
+public:
+    CompositeImageFilter(SkXfermode::Mode mode, SkImageFilter* background, SkImageFilter* foreground) : SkImageFilter(background, foreground), m_mode(mode)
+    {
+    }
+
+    virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm, SkBitmap* dst, SkIPoint* offset)
+    {
+        SkBitmap background, foreground = src;
+        SkImageFilter* backgroundInput = getInput(0);
+        SkImageFilter* foregroundInput = getInput(1);
+        SkIPoint backgroundOffset = SkIPoint::Make(0, 0), foregroundOffset = SkIPoint::Make(0, 0);
+        if (backgroundInput && !backgroundInput->filterImage(proxy, src, ctm, &background, &backgroundOffset))
+            return false;
+
+        if (foregroundInput && !foregroundInput->filterImage(proxy, src, ctm, &foreground, &foregroundOffset))
+            return false;
+
+        dst->setConfig(background.config(), background.width(), background.height());
+        dst->allocPixels();
+        SkCanvas canvas(*dst);
+        SkPaint paint;
+        paint.setXfermodeMode(SkXfermode::kSrc_Mode);
+        canvas.drawBitmap(background, backgroundOffset.fX, backgroundOffset.fY, &paint);
+        paint.setXfermodeMode(m_mode);
+        canvas.drawBitmap(foreground, foregroundOffset.fX, foregroundOffset.fY, &paint);
+        return true;
+    }
+
+    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(CompositeImageFilter)
+
+protected:
+    explicit CompositeImageFilter(SkFlattenableReadBuffer& buffer)
+        : SkImageFilter(buffer)
+    {
+        m_mode = (SkXfermode::Mode) buffer.readInt();
+    }
+
+    virtual void flatten(SkFlattenableWriteBuffer& buffer) const
+    {
+        this->SkImageFilter::flatten(buffer);
+        buffer.writeInt((int) m_mode);
+    }
+
+private:
+    SkXfermode::Mode m_mode;
+};
+
+SkXfermode::Mode toXfermode(WebCore::CompositeOperationType mode)
+{
+    switch (mode) {
+    case WebCore::FECOMPOSITE_OPERATOR_OVER:
+        return SkXfermode::kSrcOver_Mode;
+    case WebCore::FECOMPOSITE_OPERATOR_IN:
+        return SkXfermode::kSrcIn_Mode;
+    case WebCore::FECOMPOSITE_OPERATOR_OUT:
+        return SkXfermode::kDstOut_Mode;
+    case WebCore::FECOMPOSITE_OPERATOR_ATOP:
+        return SkXfermode::kSrcATop_Mode;
+    case WebCore::FECOMPOSITE_OPERATOR_XOR:
+        return SkXfermode::kXor_Mode;
+    default:
+        ASSERT_NOT_REACHED();
+        return SkXfermode::kSrcOver_Mode;
+    }
+}
+
+};
+
+namespace WebCore {
+
+SkImageFilter* FEComposite::createImageFilter(SkiaImageFilterBuilder* builder)
+{
+    SkAutoTUnref<SkImageFilter> foreground(builder->build(inputEffect(0)));
+    SkAutoTUnref<SkImageFilter> background(builder->build(inputEffect(1)));
+    if (m_type == FECOMPOSITE_OPERATOR_ARITHMETIC)
+        return 0; // FIXME: Implement arithmetic op
+    return new CompositeImageFilter(toXfermode(m_type), foreground, background);
+}
+
+};
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to