- Revision
- 104566
- Author
- [email protected]
- Date
- 2012-01-10 07:01:07 -0800 (Tue, 10 Jan 2012)
Log Message
Source/WebCore: [Skia] Switch FEColorMatrix to use a skia-based implementation when
compiling with USE(SKIA). This change will also switch the software
implementation of FEGaussianBlur to the skia implementation (ie.,
it removes the acceleration check).
https://bugs.webkit.org/show_bug.cgi?id=75582
Reviewed by Dirk Schulze.
Covered by svg/W3C-SVG-1.1/filters-color-01-b.svg and friends (will
need a rebaseline).
* WebCore.gypi:
Add FEColorMatrixSkia.cpp to the build.
* platform/graphics/filters/FEColorMatrix.h:
Add platformApplySkia().
* platform/graphics/filters/FEGaussianBlur.cpp:
(WebCore::FEGaussianBlur::platformApplySoftware):
Remove skia-specific code from FEGaussianBlur::platformApplySoftware().
* platform/graphics/filters/FEGaussianBlur.h:
Make platformApplySkia() virtual, and put it behind #if USE(SKIA).
* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::apply):
Call out to platformApplySkia(), or fall back to
platformApplySoftware().
* platform/graphics/filters/FilterEffect.h:
Add platformApplySkia().
* platform/graphics/filters/skia/FEColorMatrixSkia.cpp: Added.
(WebCore::saturateMatrix):
(WebCore::hueRotateMatrix):
(WebCore::luminanceToAlphaMatrix):
(WebCore::FEColorMatrix::platformApplySkia):
Process color matrix effect, by calling out to generic matrix
version of SkColorMatrixFilter.
* platform/graphics/filters/skia/FEGaussianBlurSkia.cpp:
(WebCore::FEGaussianBlur::platformApplySkia):
Change the signature of FEGaussianBlur::platformApplySkia to be an
override of the new FilterEffect base class version.
LayoutTests: [chomium] Mark svg FEColorMatrix tests as needing new baselines.
https://bugs.webkit.org/show_bug.cgi?id=75582
Reviewed by Dirk Schulze.
* platform/chromium/test_expectations.txt:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (104565 => 104566)
--- trunk/LayoutTests/ChangeLog 2012-01-10 14:18:38 UTC (rev 104565)
+++ trunk/LayoutTests/ChangeLog 2012-01-10 15:01:07 UTC (rev 104566)
@@ -1,3 +1,12 @@
+2012-01-05 Stephen White <[email protected]>
+
+ [chomium] Mark svg FEColorMatrix tests as needing new baselines.
+ https://bugs.webkit.org/show_bug.cgi?id=75582
+
+ Reviewed by Dirk Schulze.
+
+ * platform/chromium/test_expectations.txt:
+
2012-01-10 Csaba Osztrogonác <[email protected]>
Unreviewed gardening.
Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (104565 => 104566)
--- trunk/LayoutTests/platform/chromium/test_expectations.txt 2012-01-10 14:18:38 UTC (rev 104565)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt 2012-01-10 15:01:07 UTC (rev 104566)
@@ -934,6 +934,14 @@
BUGWK62974 : svg/custom/svg-fonts-with-no-element-reference.html = IMAGE+TEXT IMAGE
BUGWK62974 MAC : svg/W3C-SVG-1.1/pservers-grad-08-b.svg = IMAGE
+BUGSENORBLANCO : svg/W3C-SVG-1.1/filters-color-01-b.svg = FAIL
+BUGSENORBLANCO : svg/dynamic-updates/SVGFEColorMatrixElement-dom-in-attr.html = FAIL
+BUGSENORBLANCO : svg/dynamic-updates/SVGFEColorMatrixElement-dom-type-attr.html = FAIL
+BUGSENORBLANCO : svg/dynamic-updates/SVGFEColorMatrixElement-dom-values-attr.html = FAIL
+BUGSENORBLANCO : svg/dynamic-updates/SVGFEColorMatrixElement-svgdom-in-prop.html = FAIL
+BUGSENORBLANCO : svg/filters/feColorMatrix-offset.svg = FAIL
+BUGSENORBLANCO : svg/filters/feColorMatrix-saturate.svg = FAIL
+
// -----------------------------------------------------------------
// End SVG Regressions
// -----------------------------------------------------------------
Modified: trunk/Source/WebCore/ChangeLog (104565 => 104566)
--- trunk/Source/WebCore/ChangeLog 2012-01-10 14:18:38 UTC (rev 104565)
+++ trunk/Source/WebCore/ChangeLog 2012-01-10 15:01:07 UTC (rev 104566)
@@ -1,3 +1,43 @@
+2012-01-06 Stephen White <[email protected]>
+
+ [Skia] Switch FEColorMatrix to use a skia-based implementation when
+ compiling with USE(SKIA). This change will also switch the software
+ implementation of FEGaussianBlur to the skia implementation (ie.,
+ it removes the acceleration check).
+ https://bugs.webkit.org/show_bug.cgi?id=75582
+
+ Reviewed by Dirk Schulze.
+
+ Covered by svg/W3C-SVG-1.1/filters-color-01-b.svg and friends (will
+ need a rebaseline).
+
+ * WebCore.gypi:
+ Add FEColorMatrixSkia.cpp to the build.
+ * platform/graphics/filters/FEColorMatrix.h:
+ Add platformApplySkia().
+ * platform/graphics/filters/FEGaussianBlur.cpp:
+ (WebCore::FEGaussianBlur::platformApplySoftware):
+ Remove skia-specific code from FEGaussianBlur::platformApplySoftware().
+ * platform/graphics/filters/FEGaussianBlur.h:
+ Make platformApplySkia() virtual, and put it behind #if USE(SKIA).
+ * platform/graphics/filters/FilterEffect.cpp:
+ (WebCore::FilterEffect::apply):
+ Call out to platformApplySkia(), or fall back to
+ platformApplySoftware().
+ * platform/graphics/filters/FilterEffect.h:
+ Add platformApplySkia().
+ * platform/graphics/filters/skia/FEColorMatrixSkia.cpp: Added.
+ (WebCore::saturateMatrix):
+ (WebCore::hueRotateMatrix):
+ (WebCore::luminanceToAlphaMatrix):
+ (WebCore::FEColorMatrix::platformApplySkia):
+ Process color matrix effect, by calling out to generic matrix
+ version of SkColorMatrixFilter.
+ * platform/graphics/filters/skia/FEGaussianBlurSkia.cpp:
+ (WebCore::FEGaussianBlur::platformApplySkia):
+ Change the signature of FEGaussianBlur::platformApplySkia to be an
+ override of the new FilterEffect base class version.
+
2012-01-10 Pavel Feldman <[email protected]>
Web Inspector: fix DebuggerPresentationModel::uiSourceCodes - do not iterate
Modified: trunk/Source/WebCore/WebCore.gypi (104565 => 104566)
--- trunk/Source/WebCore/WebCore.gypi 2012-01-10 14:18:38 UTC (rev 104565)
+++ trunk/Source/WebCore/WebCore.gypi 2012-01-10 15:01:07 UTC (rev 104566)
@@ -3742,6 +3742,7 @@
'platform/graphics/filters/arm/FEGaussianBlurNEON.h',
'platform/graphics/filters/arm/FELightingNEON.cpp',
'platform/graphics/filters/arm/FELightingNEON.h',
+ 'platform/graphics/filters/skia/FEColorMatrixSkia.cpp',
'platform/graphics/filters/skia/FEGaussianBlurSkia.cpp',
'platform/graphics/freetype/FontCacheFreeType.cpp',
'platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp',
Modified: trunk/Source/WebCore/platform/graphics/filters/FEColorMatrix.h (104565 => 104566)
--- trunk/Source/WebCore/platform/graphics/filters/FEColorMatrix.h 2012-01-10 14:18:38 UTC (rev 104565)
+++ trunk/Source/WebCore/platform/graphics/filters/FEColorMatrix.h 2012-01-10 15:01:07 UTC (rev 104566)
@@ -49,6 +49,9 @@
bool setValues(const Vector<float>&);
virtual void platformApplySoftware();
+#if USE(SKIA)
+ virtual bool platformApplySkia();
+#endif
virtual void dump();
virtual TextStream& externalRepresentation(TextStream&, int indention) const;
Modified: trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp (104565 => 104566)
--- trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp 2012-01-10 14:18:38 UTC (rev 104565)
+++ trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp 2012-01-10 15:01:07 UTC (rev 104566)
@@ -273,13 +273,6 @@
void FEGaussianBlur::platformApplySoftware()
{
-#if USE(SKIA)
- if (filter()->renderingMode() == Accelerated) {
- platformApplySkia();
- return;
- }
-#endif
-
FilterEffect* in = inputEffect(0);
ByteArray* srcPixelArray = createPremultipliedImageResult();
Modified: trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h (104565 => 104566)
--- trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h 2012-01-10 14:18:38 UTC (rev 104565)
+++ trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h 2012-01-10 15:01:07 UTC (rev 104566)
@@ -74,7 +74,9 @@
inline void platformApplyGeneric(ByteArray* srcPixelArray, ByteArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize);
inline void platformApplyNeon(ByteArray* srcPixelArray, ByteArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize);
- void platformApplySkia();
+#if USE(SKIA)
+ virtual bool platformApplySkia();
+#endif
float m_stdX;
float m_stdY;
Modified: trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp (104565 => 104566)
--- trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp 2012-01-10 14:18:38 UTC (rev 104565)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp 2012-01-10 15:01:07 UTC (rev 104566)
@@ -104,6 +104,10 @@
determineAbsolutePaintRect();
// Add platform specific apply functions here and return earlier.
+#if USE(SKIA)
+ if (platformApplySkia())
+ return;
+#endif
platformApplySoftware();
}
Modified: trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h (104565 => 104566)
--- trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h 2012-01-10 14:18:38 UTC (rev 104565)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h 2012-01-10 15:01:07 UTC (rev 104566)
@@ -87,6 +87,9 @@
void apply();
virtual void platformApplySoftware() = 0;
+#if USE(SKIA)
+ virtual bool platformApplySkia() { return false; }
+#endif
virtual void dump() = 0;
virtual void determineAbsolutePaintRect();
Added: trunk/Source/WebCore/platform/graphics/filters/skia/FEColorMatrixSkia.cpp (0 => 104566)
--- trunk/Source/WebCore/platform/graphics/filters/skia/FEColorMatrixSkia.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/filters/skia/FEColorMatrixSkia.cpp 2012-01-10 15:01:07 UTC (rev 104566)
@@ -0,0 +1,133 @@
+/*
+ * 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) && USE(SKIA)
+#include "FEColorMatrix.h"
+
+#include "NativeImageSkia.h"
+#include "SkColorMatrixFilter.h"
+
+namespace WebCore {
+
+static void saturateMatrix(float s, SkScalar matrix[20])
+{
+ matrix[0] = 0.213f + 0.787f * s;
+ matrix[1] = 0.715f - 0.715f * s;
+ matrix[2] = 0.072f - 0.072f * s;
+ matrix[3] = matrix[4] = 0;
+ matrix[5] = 0.213f - 0.213f * s;
+ matrix[6] = 0.715f + 0.285f * s;
+ matrix[7] = 0.072f - 0.072f * s;
+ matrix[8] = matrix[9] = 0;
+ matrix[10] = 0.213f - 0.213f * s;
+ matrix[11] = 0.715f - 0.715f * s;
+ matrix[12] = 0.072f + 0.928f * s;
+ matrix[13] = matrix[14] = 0;
+ matrix[15] = matrix[16] = matrix[17] = 0;
+ matrix[18] = 1;
+ matrix[19] = 0;
+}
+
+static void hueRotateMatrix(float hue, SkScalar matrix[20])
+{
+ float cosHue = cosf(hue * piFloat / 180);
+ float sinHue = sinf(hue * piFloat / 180);
+ matrix[0] = 0.213f + cosHue * 0.787f - sinHue * 0.213f;
+ matrix[1] = 0.715f - cosHue * 0.715f - sinHue * 0.715f;
+ matrix[2] = 0.072f - cosHue * 0.072f + sinHue * 0.928f;
+ matrix[3] = matrix[4] = 0;
+ matrix[5] = 0.213f - cosHue * 0.213f + sinHue * 0.143f;
+ matrix[6] = 0.715f + cosHue * 0.285f + sinHue * 0.140f;
+ matrix[7] = 0.072f - cosHue * 0.072f - sinHue * 0.283f;
+ matrix[8] = matrix[9] = 0;
+ matrix[10] = 0.213f - cosHue * 0.213f - sinHue * 0.787f;
+ matrix[11] = 0.715f - cosHue * 0.715f + sinHue * 0.715f;
+ matrix[12] = 0.072f + cosHue * 0.928f + sinHue * 0.072f;
+ matrix[13] = matrix[14] = 0;
+ matrix[15] = matrix[16] = matrix[17] = 0;
+ matrix[18] = 1;
+ matrix[19] = 0;
+}
+
+static void luminanceToAlphaMatrix(SkScalar matrix[20])
+{
+ memset(matrix, 0, sizeof(matrix));
+ matrix[15] = 0.2125f;
+ matrix[16] = 0.7154f;
+ matrix[17] = 0.0721f;
+}
+
+bool FEColorMatrix::platformApplySkia()
+{
+ ImageBuffer* resultImage = createImageBufferResult();
+ if (!resultImage)
+ return false;
+
+ FilterEffect* in = inputEffect(0);
+
+ IntRect imageRect(IntPoint(), absolutePaintRect().size());
+
+ SkScalar matrix[20];
+
+ switch (m_type) {
+ case FECOLORMATRIX_TYPE_UNKNOWN:
+ break;
+ case FECOLORMATRIX_TYPE_MATRIX:
+ for (int i = 0; i < 20; ++i)
+ matrix[i] = m_values[i];
+
+ matrix[4] *= SkScalar(255);
+ matrix[9] *= SkScalar(255);
+ matrix[14] *= SkScalar(255);
+ matrix[19] *= SkScalar(255);
+ break;
+ case FECOLORMATRIX_TYPE_SATURATE:
+ saturateMatrix(m_values[0], matrix);
+ break;
+ case FECOLORMATRIX_TYPE_HUEROTATE:
+ hueRotateMatrix(m_values[0], matrix);
+ break;
+ case FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
+ luminanceToAlphaMatrix(matrix);
+ break;
+ }
+
+ RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
+ NativeImageSkia* nativeImage = image->nativeImageForCurrentFrame();
+ if (!nativeImage)
+ return false;
+
+ SkCanvas* canvas = resultImage->context()->platformContext()->canvas();
+ SkPaint paint;
+ paint.setColorFilter(new SkColorMatrixFilter(matrix))->unref();
+ paint.setXfermodeMode(SkXfermode::kSrc_Mode);
+ canvas->drawBitmap(nativeImage->bitmap(), 0, 0, &paint);
+ return true;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILTERS) && USE(SKIA)
Modified: trunk/Source/WebCore/platform/graphics/filters/skia/FEGaussianBlurSkia.cpp (104565 => 104566)
--- trunk/Source/WebCore/platform/graphics/filters/skia/FEGaussianBlurSkia.cpp 2012-01-10 14:18:38 UTC (rev 104565)
+++ trunk/Source/WebCore/platform/graphics/filters/skia/FEGaussianBlurSkia.cpp 2012-01-10 15:01:07 UTC (rev 104566)
@@ -32,11 +32,11 @@
namespace WebCore {
-void FEGaussianBlur::platformApplySkia()
+bool FEGaussianBlur::platformApplySkia()
{
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
- return;
+ return false;
FilterEffect* in = inputEffect(0);
@@ -57,7 +57,7 @@
paint.setColor(0xFFFFFFFF);
dstContext->drawImage(image.get(), ColorSpaceDeviceRGB, drawingRegion.location(), CompositeCopy);
canvas->restore();
- return;
+ return true;
}
};