[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
krit at webkit.org
krit at webkit.org
Thu Oct 29 20:36:17 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit 42b5c8a63a8f015a75e853aaab537bc535aecf76
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Sep 29 20:29:30 2009 +0000
2009-09-29 Dirk Schulze <krit at webkit.org>
Reviewed by Nikolas Zimmermann.
SVG Filter feComposite implementation is missing
[https://bugs.webkit.org/show_bug.cgi?id=28362]
feComposite implementation for SVG.
Test: svg/filters/feComposite.svg
* platform/graphics/filters/FEComposite.cpp:
(WebCore::arithmetic):
(WebCore::FEComposite::apply):
Tests the feComposite implementation for SVG.
* platform/mac/svg/filters/feComposite-expected.checksum: Added.
* platform/mac/svg/filters/feComposite-expected.png: Added.
* platform/mac/svg/filters/feComposite-expected.txt: Added.
* svg/filters/feComposite.svg: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48896 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 3cead04..979ab22 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2009-09-29 Dirk Schulze <krit at webkit.org>
+
+ Reviewed by Nikolas Zimmermann.
+
+ Tests the feComposite implementation for SVG.
+
+ * platform/mac/svg/filters/feComposite-expected.checksum: Added.
+ * platform/mac/svg/filters/feComposite-expected.png: Added.
+ * platform/mac/svg/filters/feComposite-expected.txt: Added.
+ * svg/filters/feComposite.svg: Added.
+
2009-09-29 Shinichiro Hamaji <hamaji at chromium.org>
Reviewed by David Kilzer.
diff --git a/LayoutTests/platform/mac/svg/filters/feComposite-expected.checksum b/LayoutTests/platform/mac/svg/filters/feComposite-expected.checksum
new file mode 100644
index 0000000..aae9b7a
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/filters/feComposite-expected.checksum
@@ -0,0 +1 @@
+17fffed8f873ee7fee9b0117f95a8e30
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/filters/feComposite-expected.png b/LayoutTests/platform/mac/svg/filters/feComposite-expected.png
new file mode 100644
index 0000000..d2cfcca
Binary files /dev/null and b/LayoutTests/platform/mac/svg/filters/feComposite-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/filters/feComposite-expected.txt b/LayoutTests/platform/mac/svg/filters/feComposite-expected.txt
new file mode 100644
index 0000000..7742240
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/filters/feComposite-expected.txt
@@ -0,0 +1,29 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 400x400
+ RenderSVGRoot {svg} at (10,10) size 182x184
+ RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+ RenderPath {rect} at (10,10) size 50x50 [fill={[type=SOLID] [color=#000000]}] [filter=over] [data="M10.00,10.00 L60.00,10.00 L60.00,60.00 L10.00,60.00 Z"]
+ RenderSVGText {text} at (10,90) size 28x18 contains 1 chunk(s)
+ RenderSVGInlineText {#text} at (0,-14) size 28x18
+ chunk 1 text run 1 at (10.00,90.00) startOffset 0 endOffset 4 width 28.00: "over"
+ RenderPath {rect} at (70,10) size 50x50 [fill={[type=SOLID] [color=#000000]}] [filter=in] [data="M70.00,10.00 L120.00,10.00 L120.00,60.00 L70.00,60.00 Z"]
+ RenderSVGText {text} at (70,90) size 12x18 contains 1 chunk(s)
+ RenderSVGInlineText {#text} at (0,-14) size 12x18
+ chunk 1 text run 1 at (70.00,90.00) startOffset 0 endOffset 2 width 12.00: "in"
+ RenderPath {rect} at (130,10) size 50x50 [fill={[type=SOLID] [color=#000000]}] [filter=out] [data="M130.00,10.00 L180.00,10.00 L180.00,60.00 L130.00,60.00 Z"]
+ RenderSVGText {text} at (130,90) size 20x18 contains 1 chunk(s)
+ RenderSVGInlineText {#text} at (0,-14) size 20x18
+ chunk 1 text run 1 at (130.00,90.00) startOffset 0 endOffset 3 width 20.00: "out"
+ RenderPath {rect} at (10,110) size 50x50 [fill={[type=SOLID] [color=#000000]}] [filter=atop] [data="M10.00,110.00 L60.00,110.00 L60.00,160.00 L10.00,160.00 Z"]
+ RenderSVGText {text} at (10,190) size 27x18 contains 1 chunk(s)
+ RenderSVGInlineText {#text} at (0,-14) size 27x18
+ chunk 1 text run 1 at (10.00,190.00) startOffset 0 endOffset 4 width 27.00: "atop"
+ RenderPath {rect} at (70,110) size 50x50 [fill={[type=SOLID] [color=#000000]}] [filter=xor] [data="M70.00,110.00 L120.00,110.00 L120.00,160.00 L70.00,160.00 Z"]
+ RenderSVGText {text} at (70,190) size 21x18 contains 1 chunk(s)
+ RenderSVGInlineText {#text} at (0,-14) size 21x18
+ chunk 1 text run 1 at (70.00,190.00) startOffset 0 endOffset 3 width 21.00: "xor"
+ RenderPath {rect} at (130,110) size 50x50 [fill={[type=SOLID] [color=#000000]}] [filter=arithmetic] [data="M130.00,110.00 L180.00,110.00 L180.00,160.00 L130.00,160.00 Z"]
+ RenderSVGText {text} at (130,190) size 62x18 contains 1 chunk(s)
+ RenderSVGInlineText {#text} at (0,-14) size 62x18
+ chunk 1 text run 1 at (130.00,190.00) startOffset 0 endOffset 10 width 62.00: "arithmetic"
diff --git a/LayoutTests/svg/filters/feComposite.svg b/LayoutTests/svg/filters/feComposite.svg
new file mode 100644
index 0000000..b053d51
--- /dev/null
+++ b/LayoutTests/svg/filters/feComposite.svg
@@ -0,0 +1,48 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="400" height="400" version="1.1" xmlns="http://www.w3.org/2000/svg">
+<defs>
+<filter id="over" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" x="0%" y="0%" width="100%" height="100%">
+ <feFlood flood-color="#f00" flood-opacity="0.5" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+ <feFlood flood-color="#00f" flood-opacity="0.5" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+ <feComposite in2="res1" in="res2" operator="over"/>
+</filter>
+<filter id="in" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" x="0%" y="0%" width="100%" height="100%">
+ <feFlood flood-color="#f00" flood-opacity="0.5" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+ <feFlood flood-color="#00f" flood-opacity="0.5" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+ <feComposite in2="res1" in="res2" operator="in"/>
+</filter>
+<filter id="out" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" x="0%" y="0%" width="100%" height="100%">
+ <feFlood flood-color="#f00" flood-opacity="0.5" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+ <feFlood flood-color="#00f" flood-opacity="0.5" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+ <feComposite in2="res1" in="res2" operator="out"/>
+</filter>
+<filter id="atop" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" x="0%" y="0%" width="100%" height="100%">
+ <feFlood flood-color="#f00" flood-opacity="0.5" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+ <feFlood flood-color="#00f" flood-opacity="0.5" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+ <feComposite in2="res1" in="res2" operator="atop"/>
+</filter>
+<filter id="xor" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" x="0%" y="0%" width="100%" height="100%">
+ <feFlood flood-color="#f00" flood-opacity="0.5" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+ <feFlood flood-color="#00f" flood-opacity="0.5" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+ <feComposite in2="res1" in="res2" operator="xor"/>
+</filter>
+<filter id="arithmetic" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" x="0%" y="0%" width="100%" height="100%">
+ <feFlood flood-color="#f00" flood-opacity="0.2" result="res1" x="0%" y="0%" width="75%" height="75%"/>
+ <feFlood flood-color="#00f" flood-opacity="0.5" result="res2" x="25%" y="25%" width="75%" height="75%"/>
+ <feComposite in2="res1" in="res2" operator="arithmetic" k1=".5" k2=".5" k3=".5" k4=".5"/>
+</filter>
+</defs>
+<rect x="10" y="10" width="50" height="50" filter="url(#over)"/>
+<text x="10" y="90">over</text>
+<rect x="70" y="10" width="50" height="50" filter="url(#in)"/>
+<text x="70" y="90">in</text>
+<rect x="130" y="10" width="50" height="50" filter="url(#out)"/>
+<text x="130" y="90">out</text>
+<rect x="10" y="110" width="50" height="50" filter="url(#atop)"/>
+<text x="10" y="190">atop</text>
+<rect x="70" y="110" width="50" height="50" filter="url(#xor)"/>
+<text x="70" y="190">xor</text>
+<rect x="130" y="110" width="50" height="50" filter="url(#arithmetic)"/>
+<text x="130" y="190">arithmetic</text>
+</svg>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 925a8d9..a5c1bf4 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2009-09-29 Dirk Schulze <krit at webkit.org>
+
+ Reviewed by Nikolas Zimmermann.
+
+ SVG Filter feComposite implementation is missing
+ [https://bugs.webkit.org/show_bug.cgi?id=28362]
+
+ feComposite implementation for SVG.
+
+ Test: svg/filters/feComposite.svg
+
+ * platform/graphics/filters/FEComposite.cpp:
+ (WebCore::arithmetic):
+ (WebCore::FEComposite::apply):
+
2009-09-29 Dumitru Daniliuc <dumi at chromium.org>
Reviewed by Dimitri Glazkov.
diff --git a/WebCore/platform/graphics/filters/FEComposite.cpp b/WebCore/platform/graphics/filters/FEComposite.cpp
index 0706358..f452a2d 100644
--- a/WebCore/platform/graphics/filters/FEComposite.cpp
+++ b/WebCore/platform/graphics/filters/FEComposite.cpp
@@ -2,6 +2,7 @@
Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann at kde.org>
2004, 2005 Rob Buis <buis at kde.org>
2005 Eric Seidel <eric at webkit.org>
+ 2009 Dirk Schulze <krit at webkit.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -24,7 +25,10 @@
#if ENABLE(FILTERS)
#include "FEComposite.h"
+#include "CanvasPixelArray.h"
#include "Filter.h"
+#include "GraphicsContext.h"
+#include "ImageData.h"
namespace WebCore {
@@ -97,8 +101,74 @@ void FEComposite::setK4(float k4)
m_k4 = k4;
}
-void FEComposite::apply(Filter*)
+inline void arithmetic(const RefPtr<CanvasPixelArray>& srcPixelArrayA, CanvasPixelArray*& srcPixelArrayB,
+ float k1, float k2, float k3, float k4)
{
+ float scaledK1 = k1 / 255.f;
+ float scaledK4 = k4 * 255.f;
+ for (unsigned pixelOffset = 0; pixelOffset < srcPixelArrayA->length(); pixelOffset += 4) {
+ for (unsigned channel = 0; channel < 4; ++channel) {
+ unsigned char i1 = srcPixelArrayA->get(pixelOffset + channel);
+ unsigned char i2 = srcPixelArrayB->get(pixelOffset + channel);
+
+ unsigned char result = scaledK1 * i1 * i2 + k2 * i1 + k3 * i2 + scaledK4;
+ if (channel == 3 && i1 == 0 && i2 == 0)
+ result = 0;
+ srcPixelArrayB->set(pixelOffset + channel, result);
+ }
+ }
+}
+
+void FEComposite::apply(Filter* filter)
+{
+ m_in->apply(filter);
+ m_in2->apply(filter);
+ if (!m_in->resultImage() || !m_in2->resultImage())
+ return;
+
+ GraphicsContext* filterContext = getEffectContext();
+ if (!filterContext)
+ return;
+
+ FloatRect srcRect = FloatRect(0.f, 0.f, -1.f, -1.f);
+ switch (m_type) {
+ case FECOMPOSITE_OPERATOR_OVER:
+ filterContext->drawImage(m_in->resultImage()->image(), calculateDrawingRect(m_in->subRegion()));
+ filterContext->drawImage(m_in2->resultImage()->image(), calculateDrawingRect(m_in2->subRegion()));
+ break;
+ case FECOMPOSITE_OPERATOR_IN:
+ filterContext->save();
+ filterContext->clipToImageBuffer(calculateDrawingRect(m_in2->subRegion()), m_in2->resultImage());
+ filterContext->drawImage(m_in->resultImage()->image(), calculateDrawingRect(m_in->subRegion()));
+ filterContext->restore();
+ break;
+ case FECOMPOSITE_OPERATOR_OUT:
+ filterContext->drawImage(m_in->resultImage()->image(), calculateDrawingRect(m_in->subRegion()));
+ filterContext->drawImage(m_in2->resultImage()->image(), calculateDrawingRect(m_in2->subRegion()), srcRect, CompositeDestinationOut);
+ break;
+ case FECOMPOSITE_OPERATOR_ATOP:
+ filterContext->drawImage(m_in2->resultImage()->image(), calculateDrawingRect(m_in2->subRegion()));
+ filterContext->drawImage(m_in->resultImage()->image(), calculateDrawingRect(m_in->subRegion()), srcRect, CompositeSourceAtop);
+ break;
+ case FECOMPOSITE_OPERATOR_XOR:
+ filterContext->drawImage(m_in2->resultImage()->image(), calculateDrawingRect(m_in2->subRegion()));
+ filterContext->drawImage(m_in->resultImage()->image(), calculateDrawingRect(m_in->subRegion()), srcRect, CompositeXOR);
+ break;
+ case FECOMPOSITE_OPERATOR_ARITHMETIC: {
+ IntRect effectADrawingRect = calculateDrawingIntRect(m_in->subRegion());
+ RefPtr<CanvasPixelArray> srcPixelArrayA(m_in->resultImage()->getPremultipliedImageData(effectADrawingRect)->data());
+
+ IntRect effectBDrawingRect = calculateDrawingIntRect(m_in2->subRegion());
+ RefPtr<ImageData> imageData(m_in2->resultImage()->getPremultipliedImageData(effectBDrawingRect));
+ CanvasPixelArray* srcPixelArrayB(imageData->data());
+
+ arithmetic(srcPixelArrayA, srcPixelArrayB, m_k1, m_k2, m_k3, m_k4);
+ resultImage()->putPremultipliedImageData(imageData.get(), IntRect(IntPoint(), resultImage()->size()), IntPoint());
+ }
+ break;
+ default:
+ break;
+ }
}
void FEComposite::dump()
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list