Title: [128223] trunk
Revision
128223
Author
[email protected]
Date
2012-09-11 13:54:05 -0700 (Tue, 11 Sep 2012)

Log Message

Source/WebCore: [skia] Switch FEComponentTransfer filter to use skia's SkColorFilter
https://bugs.webkit.org/show_bug.cgi?id=95238

Reviewed by Dirk Schulze.

Covered by existing tests in svg/, such as svg/custom/feComponentTransfer-Discrete.svg.

* WebCore.gypi:
* platform/graphics/filters/FEComponentTransfer.cpp:
(WebCore::FEComponentTransfer::platformApplySoftware):
Add a check for the skia implementation.
(WebCore::FEComponentTransfer::getValues):
* platform/graphics/filters/FEComponentTransfer.h:
Factor out the retrieval of LUT values into its own function, so we
can call it from the Skia implementation.
* platform/graphics/filters/skia/FEComponentTransferSkia.cpp: Added.
(WebCore::FEComponentTransfer::platformApplySkia):

LayoutTests: [chromium] Mark some tests as needing a rebaseline due to SVG filters change.
https://bugs.webkit.org/show_bug.cgi?id=95238

Reviewed by Dirk Schulze.

* platform/chromium/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (128222 => 128223)


--- trunk/LayoutTests/ChangeLog	2012-09-11 20:36:16 UTC (rev 128222)
+++ trunk/LayoutTests/ChangeLog	2012-09-11 20:54:05 UTC (rev 128223)
@@ -1,3 +1,12 @@
+2012-09-11  Stephen White  <[email protected]>
+
+        [chromium] Mark some tests as needing a rebaseline due to SVG filters change.
+        https://bugs.webkit.org/show_bug.cgi?id=95238
+
+        Reviewed by Dirk Schulze.
+
+        * platform/chromium/TestExpectations:
+
 2012-09-11  Kevin Ellis  <[email protected]>
 
         Crash on a long press gesture when touch adjustment is enabled.

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (128222 => 128223)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2012-09-11 20:36:16 UTC (rev 128222)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2012-09-11 20:54:05 UTC (rev 128223)
@@ -1318,6 +1318,18 @@
 // Times out on debug builds
 BUGWK93589 LINUX SNOWLEOPARD DEBUG : svg/dom/SVGScriptElement/script-change-externalResourcesRequired-while-loading.svg = TIMEOUT PASS TEXT
 
+// Need rebaseline for slight pixel changes
+BUGWK95238 : svg/W3C-SVG-1.1/filters-comptran-01-b.svg = IMAGE
+BUGWK95238 : svg/custom/feComponentTransfer-Discrete.svg = IMAGE
+BUGWK95238 : svg/custom/feComponentTransfer-Gamma.svg = IMAGE
+BUGWK95238 : svg/custom/feComponentTransfer-Linear.svg = IMAGE
+BUGWK95238 : svg/custom/feComponentTransfer-Table.svg = IMAGE
+BUGWK95238 : svg/dynamic-updates/SVGFEComponentTransferElement-dom-tableValues-attr.html = IMAGE
+BUGWK95238 : svg/dynamic-updates/SVGFEComponentTransferElement-svgdom-tableValues-prop.html = IMAGE
+BUGWK95238 : css3/filters/effect-reference-ordering.html = IMAGE
+BUGWK95238 : css3/filters/effect-combined.html = IMAGE
+BUGWK95238 : css3/filters/effect-opacity.html = IMAGE
+
 // -----------------------------------------------------------------
 // End SVG TESTS
 // -----------------------------------------------------------------

Modified: trunk/Source/WebCore/ChangeLog (128222 => 128223)


--- trunk/Source/WebCore/ChangeLog	2012-09-11 20:36:16 UTC (rev 128222)
+++ trunk/Source/WebCore/ChangeLog	2012-09-11 20:54:05 UTC (rev 128223)
@@ -1,3 +1,23 @@
+2012-09-11  Stephen White  <[email protected]>
+
+        [skia] Switch FEComponentTransfer filter to use skia's SkColorFilter
+        https://bugs.webkit.org/show_bug.cgi?id=95238
+
+        Reviewed by Dirk Schulze.
+
+        Covered by existing tests in svg/, such as svg/custom/feComponentTransfer-Discrete.svg.
+
+        * WebCore.gypi:
+        * platform/graphics/filters/FEComponentTransfer.cpp:
+        (WebCore::FEComponentTransfer::platformApplySoftware):
+        Add a check for the skia implementation.
+        (WebCore::FEComponentTransfer::getValues):
+        * platform/graphics/filters/FEComponentTransfer.h:
+        Factor out the retrieval of LUT values into its own function, so we
+        can call it from the Skia implementation.
+        * platform/graphics/filters/skia/FEComponentTransferSkia.cpp: Added.
+        (WebCore::FEComponentTransfer::platformApplySkia):
+
 2012-09-11  Kevin Ellis  <[email protected]>
 
         Crash on a long press gesture when touch adjustment is enabled.

Modified: trunk/Source/WebCore/WebCore.gypi (128222 => 128223)


--- trunk/Source/WebCore/WebCore.gypi	2012-09-11 20:36:16 UTC (rev 128222)
+++ trunk/Source/WebCore/WebCore.gypi	2012-09-11 20:54:05 UTC (rev 128223)
@@ -4996,6 +4996,7 @@
             'platform/graphics/filters/arm/FELightingNEON.h',
             'platform/graphics/filters/skia/FEBlendSkia.cpp',
             'platform/graphics/filters/skia/FEColorMatrixSkia.cpp',
+            'platform/graphics/filters/skia/FEComponentTransferSkia.cpp',
             'platform/graphics/filters/skia/FEGaussianBlurSkia.cpp',
             'platform/graphics/filters/skia/FEMorphologySkia.cpp',
             'platform/graphics/filters/skia/FELightingSkia.cpp',

Modified: trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp (128222 => 128223)


--- trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp	2012-09-11 20:36:16 UTC (rev 128222)
+++ trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp	2012-09-11 20:54:05 UTC (rev 128223)
@@ -159,17 +159,9 @@
         return;
 
     unsigned char rValues[256], gValues[256], bValues[256], aValues[256];
-    for (unsigned i = 0; i < 256; ++i)
-        rValues[i] = gValues[i] = bValues[i] = aValues[i] = i;
+    getValues(rValues, gValues, bValues, aValues);
     unsigned char* tables[] = { rValues, gValues, bValues, aValues };
-    ComponentTransferFunction transferFunction[] = {m_redFunc, m_greenFunc, m_blueFunc, m_alphaFunc};
-    TransferType callEffect[] = {identity, identity, table, discrete, linear, gamma};
 
-    for (unsigned channel = 0; channel < 4; channel++) {
-        ASSERT(static_cast<size_t>(transferFunction[channel].type) < WTF_ARRAY_LENGTH(callEffect));
-        (*callEffect[transferFunction[channel].type])(tables[channel], transferFunction[channel]);
-    }
-
     IntRect drawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
     in->copyUnmultipliedImage(pixelArray, drawingRect);
 
@@ -182,6 +174,20 @@
     }
 }
 
+void FEComponentTransfer::getValues(unsigned char rValues[256], unsigned char gValues[256], unsigned char bValues[256], unsigned char aValues[256])
+{
+    for (unsigned i = 0; i < 256; ++i)
+        rValues[i] = gValues[i] = bValues[i] = aValues[i] = i;
+    unsigned char* tables[] = { rValues, gValues, bValues, aValues };
+    ComponentTransferFunction transferFunction[] = {m_redFunc, m_greenFunc, m_blueFunc, m_alphaFunc};
+    TransferType callEffect[] = {identity, identity, table, discrete, linear, gamma};
+
+    for (unsigned channel = 0; channel < 4; channel++) {
+        ASSERT(static_cast<size_t>(transferFunction[channel].type) < WTF_ARRAY_LENGTH(callEffect));
+        (*callEffect[transferFunction[channel].type])(tables[channel], transferFunction[channel]);
+    }
+}
+
 void FEComponentTransfer::dump()
 {
 }

Modified: trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.h (128222 => 128223)


--- trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.h	2012-09-11 20:36:16 UTC (rev 128222)
+++ trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.h	2012-09-11 20:54:05 UTC (rev 128223)
@@ -79,6 +79,9 @@
     void setAlphaFunction(const ComponentTransferFunction&);
 
     virtual void platformApplySoftware();
+#if USE(SKIA)
+    virtual bool platformApplySkia();
+#endif
     virtual void dump();
 
     virtual TextStream& externalRepresentation(TextStream&, int indention) const;
@@ -87,6 +90,8 @@
     FEComponentTransfer(Filter*, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc,
                         const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc);
 
+    void getValues(unsigned char rValues[256], unsigned char gValues[256], unsigned char bValues[256], unsigned char aValues[256]);
+
     ComponentTransferFunction m_redFunc;
     ComponentTransferFunction m_greenFunc;
     ComponentTransferFunction m_blueFunc;

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


--- trunk/Source/WebCore/platform/graphics/filters/skia/FEComponentTransferSkia.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/filters/skia/FEComponentTransferSkia.cpp	2012-09-11 20:54:05 UTC (rev 128223)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 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 ENABLE(FILTERS)
+#include "FEComponentTransfer.h"
+
+#include "NativeImageSkia.h"
+#include "SkTableColorFilter.h"
+
+namespace WebCore {
+
+bool FEComponentTransfer::platformApplySkia()
+{
+    FilterEffect* in = inputEffect(0);
+    ImageBuffer* resultImage = createImageBufferResult();
+    if (!resultImage)
+        return false;
+
+    RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
+    SkBitmap bitmap = image->nativeImageForCurrentFrame()->bitmap();
+
+    unsigned char rValues[256], gValues[256], bValues[256], aValues[256];
+    getValues(rValues, gValues, bValues, aValues);
+
+    SkCanvas* canvas = resultImage->context()->platformContext()->canvas();
+    SkPaint paint;
+    paint.setColorFilter(SkTableColorFilter::CreateARGB(aValues, rValues, gValues, bValues))->unref();
+    paint.setXfermodeMode(SkXfermode::kSrc_Mode);
+    canvas->drawBitmap(bitmap, 0, 0, &paint);
+
+    return true;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILTERS)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to