Title: [134467] trunk/Source/WebCore
Revision
134467
Author
[email protected]
Date
2012-11-13 12:39:21 -0800 (Tue, 13 Nov 2012)

Log Message

[Chromium] Fix SkImageFilter DAG path to pass all css3/filters tests
https://bugs.webkit.org/show_bug.cgi?id=101952

Reviewed by James Robinson.

With these changes, all of the css3/filters tests pass when the
if-test in GraphicsLayerChromium::setFilters() is forced true (for
now, it remains true only if there's a reference filter in the chain).

Covered by the css3/filters tests (when the switch is thrown in
GraphicsLayerChromium::setFilters()).

* WebCore.gypi:
* platform/graphics/chromium/GraphicsLayerChromium.cpp:
Drop to software rendering if there's a custom filter in the chain.
This is the same as the WebFilterOperations path is doing.
* platform/graphics/filters/skia/DropShadowImageFilter.cpp: Added.
* platform/graphics/filters/skia/DropShadowImageFilter.h: Added.
New implementation of drop-shadow filter; equivalent to
the path in cc/render_surface_filters.cc.
* platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp:
Fix the sepia and grayscale filters (value was inverted).

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (134466 => 134467)


--- trunk/Source/WebCore/ChangeLog	2012-11-13 20:36:47 UTC (rev 134466)
+++ trunk/Source/WebCore/ChangeLog	2012-11-13 20:39:21 UTC (rev 134467)
@@ -1,3 +1,28 @@
+2012-11-13  Stephen White  <[email protected]>
+
+        [Chromium] Fix SkImageFilter DAG path to pass all css3/filters tests
+        https://bugs.webkit.org/show_bug.cgi?id=101952
+
+        Reviewed by James Robinson.
+
+        With these changes, all of the css3/filters tests pass when the
+        if-test in GraphicsLayerChromium::setFilters() is forced true (for
+        now, it remains true only if there's a reference filter in the chain).
+
+        Covered by the css3/filters tests (when the switch is thrown in
+        GraphicsLayerChromium::setFilters()).
+
+        * WebCore.gypi:
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        Drop to software rendering if there's a custom filter in the chain.
+        This is the same as the WebFilterOperations path is doing.
+        * platform/graphics/filters/skia/DropShadowImageFilter.cpp: Added.
+        * platform/graphics/filters/skia/DropShadowImageFilter.h: Added.
+        New implementation of drop-shadow filter; equivalent to
+        the path in cc/render_surface_filters.cc.
+        * platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp:
+        Fix the sepia and grayscale filters (value was inverted).
+
 2012-11-13  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r134442.

Modified: trunk/Source/WebCore/WebCore.gypi (134466 => 134467)


--- trunk/Source/WebCore/WebCore.gypi	2012-11-13 20:36:47 UTC (rev 134466)
+++ trunk/Source/WebCore/WebCore.gypi	2012-11-13 20:39:21 UTC (rev 134467)
@@ -5032,6 +5032,8 @@
             'platform/graphics/filters/skia/FELightingSkia.cpp',
             'platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp',
             'platform/graphics/filters/skia/SkiaImageFilterBuilder.h',
+            'platform/graphics/filters/skia/DropShadowImageFilter.cpp',
+            'platform/graphics/filters/skia/DropShadowImageFilter.h',
             'platform/graphics/freetype/FontCacheFreeType.cpp',
             'platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp',
             'platform/graphics/freetype/FontPlatformData.h',

Modified: trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp (134466 => 134467)


--- trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp	2012-11-13 20:36:47 UTC (rev 134466)
+++ trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp	2012-11-13 20:39:21 UTC (rev 134467)
@@ -388,6 +388,13 @@
     // switch all filtering over to this path, and remove setFilters() and
     // WebFilterOperations altogether.
     if (filters.hasReferenceFilter()) {
+        if (filters.hasCustomFilter()) {
+            // Make sure the filters are removed from the platform layer, as they are
+            // going to fallback to software mode.
+            m_layer->layer()->setFilter(0);
+            GraphicsLayer::setFilters(FilterOperations());
+            return false;
+        }
         SkiaImageFilterBuilder builder;
         SkAutoTUnref<SkImageFilter> imageFilter(builder.build(filters));
         m_layer->layer()->setFilter(imageFilter);

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


--- trunk/Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.cpp	2012-11-13 20:39:21 UTC (rev 134467)
@@ -0,0 +1,83 @@
+/*
+ * 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"
+
+#include "DropShadowImageFilter.h"
+
+#include "SkBitmap.h"
+#include "SkBlurImageFilter.h"
+#include "SkCanvas.h"
+#include "SkColorMatrixFilter.h"
+#include "SkDevice.h"
+#include "SkFlattenableBuffers.h"
+
+namespace WebCore {
+
+DropShadowImageFilter::DropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigma, SkColor color, SkImageFilter* input)
+    : SkSingleInputImageFilter(input)
+    , m_dx(dx)
+    , m_dy(dy)
+    , m_sigma(sigma)
+    , m_color(color)
+{
+}
+
+DropShadowImageFilter::DropShadowImageFilter(SkFlattenableReadBuffer& buffer) : SkSingleInputImageFilter(buffer)
+{
+    m_dx = buffer.readScalar();
+    m_dy = buffer.readScalar();
+    m_sigma = buffer.readScalar();
+    m_color = buffer.readColor();
+}
+
+void DropShadowImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const
+{
+    buffer.writeScalar(m_dx);
+    buffer.writeScalar(m_dy);
+    buffer.writeScalar(m_sigma);
+    buffer.writeColor(m_color);
+}
+
+bool DropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, const SkMatrix& matrix, SkBitmap* result, SkIPoint* loc)
+{
+    SkBitmap src = "" source, matrix, loc);
+    SkAutoTUnref<SkDevice> device(proxy->createDevice(src.width(), src.height()));
+    SkCanvas canvas(device.get());
+
+    SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(m_sigma, m_sigma));
+    SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(m_color, SkXfermode::kSrcIn_Mode));
+    SkPaint paint;
+    paint.setImageFilter(blurFilter.get());
+    paint.setColorFilter(colorFilter.get());
+    paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
+    canvas.saveLayer(0, &paint);
+    canvas.drawBitmap(src, m_dx, -m_dy);
+    canvas.restore();
+    canvas.drawBitmap(src, 0, 0);
+    *result = device.get()->accessBitmap(false);
+    return true;
+}
+
+};

Added: trunk/Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.h (0 => 134467)


--- trunk/Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.h	2012-11-13 20:39:21 UTC (rev 134467)
@@ -0,0 +1,47 @@
+/*
+ * 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 "SkColor.h"
+#include "SkScalar.h"
+#include "SkSingleInputImageFilter.h"
+
+namespace WebCore {
+
+class DropShadowImageFilter : public SkSingleInputImageFilter {
+public:
+    DropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigma, SkColor, SkImageFilter* input = 0);
+    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DropShadowImageFilter)
+
+protected:
+    explicit DropShadowImageFilter(SkFlattenableReadBuffer&);
+    virtual void flatten(SkFlattenableWriteBuffer&) const OVERRIDE;
+    virtual bool onFilterImage(Proxy*, const SkBitmap& source, const SkMatrix&, SkBitmap* result, SkIPoint* loc) OVERRIDE;
+
+private:
+    SkScalar m_dx, m_dy, m_sigma;
+    SkColor m_color;
+};
+
+};

Modified: trunk/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp (134466 => 134467)


--- trunk/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp	2012-11-13 20:36:47 UTC (rev 134466)
+++ trunk/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp	2012-11-13 20:39:21 UTC (rev 134467)
@@ -26,6 +26,7 @@
 
 #include "SkiaImageFilterBuilder.h"
 
+#include "DropShadowImageFilter.h"
 #include "FilterEffect.h"
 #include "FilterOperations.h"
 #include "SkBlurImageFilter.h"
@@ -193,13 +194,13 @@
         }
         case FilterOperation::GRAYSCALE: {
             float amount = static_cast<const BasicColorMatrixFilterOperation*>(&op)->amount();
-            getGrayscaleMatrix(amount, matrix);
+            getGrayscaleMatrix(1 - amount, matrix);
             filter = createMatrixImageFilter(matrix, filter);
             break;
         }
         case FilterOperation::SEPIA: {
             float amount = static_cast<const BasicColorMatrixFilterOperation*>(&op)->amount();
-            getSepiaMatrix(amount, matrix);
+            getSepiaMatrix(1 - amount, matrix);
             filter = createMatrixImageFilter(matrix, filter);
             break;
         }
@@ -245,8 +246,8 @@
             break;
         }
         case FilterOperation::DROP_SHADOW: {
-//            const DropShadowFilterOperation& dropShadowOp = *static_cast<const DropShadowFilterOperation*>(&op);
-            // FIXME: do offset and blur
+            const DropShadowFilterOperation* drop = static_cast<const DropShadowFilterOperation*>(&op);
+            filter = new DropShadowImageFilter(SkIntToScalar(drop->x()), SkIntToScalar(drop->y()), SkIntToScalar(drop->stdDeviation()), drop->color().rgb(), filter);
             break;
         }
 #if ENABLE(CSS_SHADERS)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to