diff options
Diffstat (limited to 'WebCore/svg')
51 files changed, 133 insertions, 3445 deletions
diff --git a/WebCore/svg/SVGFEBlendElement.cpp b/WebCore/svg/SVGFEBlendElement.cpp index c4d816b..6c5952f 100644 --- a/WebCore/svg/SVGFEBlendElement.cpp +++ b/WebCore/svg/SVGFEBlendElement.cpp @@ -60,6 +60,16 @@ void SVGFEBlendElement::parseMappedAttribute(Attribute* attr) SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); } +void SVGFEBlendElement::svgAttributeChanged(const QualifiedName& attrName) +{ + SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); + + if (attrName == SVGNames::modeAttr + || attrName == SVGNames::inAttr + || attrName == SVGNames::in2Attr) + invalidate(); +} + void SVGFEBlendElement::synchronizeProperty(const QualifiedName& attrName) { SVGFilterPrimitiveStandardAttributes::synchronizeProperty(attrName); diff --git a/WebCore/svg/SVGFEBlendElement.h b/WebCore/svg/SVGFEBlendElement.h index 41c8307..c8c5deb 100644 --- a/WebCore/svg/SVGFEBlendElement.h +++ b/WebCore/svg/SVGFEBlendElement.h @@ -34,6 +34,7 @@ private: SVGFEBlendElement(const QualifiedName&, Document*); virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); diff --git a/WebCore/svg/SVGFEConvolveMatrixElement.h b/WebCore/svg/SVGFEConvolveMatrixElement.h index e70b768..b1fe7e2 100644 --- a/WebCore/svg/SVGFEConvolveMatrixElement.h +++ b/WebCore/svg/SVGFEConvolveMatrixElement.h @@ -21,7 +21,7 @@ #define SVGFEConvolveMatrixElement_h #if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEConvolveMatrix.h" +#include "FEConvolveMatrix.h" #include "SVGFilterPrimitiveStandardAttributes.h" #include "SVGNumberList.h" diff --git a/WebCore/svg/SVGFEDiffuseLightingElement.cpp b/WebCore/svg/SVGFEDiffuseLightingElement.cpp index 4bc1bdb..d2e15f8 100644 --- a/WebCore/svg/SVGFEDiffuseLightingElement.cpp +++ b/WebCore/svg/SVGFEDiffuseLightingElement.cpp @@ -23,8 +23,8 @@ #include "SVGFEDiffuseLightingElement.h" #include "Attr.h" +#include "FEDiffuseLighting.h" #include "SVGColor.h" -#include "SVGFEDiffuseLighting.h" #include "SVGFELightElement.h" #include "SVGNames.h" #include "SVGParserUtilities.h" diff --git a/WebCore/svg/SVGFEDisplacementMapElement.h b/WebCore/svg/SVGFEDisplacementMapElement.h index 239c2c7..21fd83f 100644 --- a/WebCore/svg/SVGFEDisplacementMapElement.h +++ b/WebCore/svg/SVGFEDisplacementMapElement.h @@ -21,7 +21,7 @@ #define SVGFEDisplacementMapElement_h #if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEDisplacementMap.h" +#include "FEDisplacementMap.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { diff --git a/WebCore/svg/SVGFEDistantLightElement.cpp b/WebCore/svg/SVGFEDistantLightElement.cpp index 59394d8..43a2868 100644 --- a/WebCore/svg/SVGFEDistantLightElement.cpp +++ b/WebCore/svg/SVGFEDistantLightElement.cpp @@ -21,7 +21,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEDistantLightElement.h" -#include "SVGDistantLightSource.h" + +#include "DistantLightSource.h" namespace WebCore { diff --git a/WebCore/svg/SVGFEFloodElement.h b/WebCore/svg/SVGFEFloodElement.h index 2f7d94d..10a418f 100644 --- a/WebCore/svg/SVGFEFloodElement.h +++ b/WebCore/svg/SVGFEFloodElement.h @@ -22,7 +22,7 @@ #define SVGFEFloodElement_h #if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEFlood.h" +#include "FEFlood.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { diff --git a/WebCore/svg/SVGFELightElement.h b/WebCore/svg/SVGFELightElement.h index b86204d..d594475 100644 --- a/WebCore/svg/SVGFELightElement.h +++ b/WebCore/svg/SVGFELightElement.h @@ -23,8 +23,8 @@ #define SVGFELightElement_h #if ENABLE(SVG) && ENABLE(FILTERS) +#include "LightSource.h" #include "SVGElement.h" -#include "SVGLightSource.h" #include "SVGNames.h" namespace WebCore { diff --git a/WebCore/svg/SVGFEMergeElement.h b/WebCore/svg/SVGFEMergeElement.h index c07be4c..da94ac7 100644 --- a/WebCore/svg/SVGFEMergeElement.h +++ b/WebCore/svg/SVGFEMergeElement.h @@ -22,7 +22,7 @@ #define SVGFEMergeElement_h #if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEMerge.h" +#include "FEMerge.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { diff --git a/WebCore/svg/SVGFEMorphologyElement.cpp b/WebCore/svg/SVGFEMorphologyElement.cpp index b45c6f9..bfd0c0f 100644 --- a/WebCore/svg/SVGFEMorphologyElement.cpp +++ b/WebCore/svg/SVGFEMorphologyElement.cpp @@ -42,9 +42,11 @@ PassRefPtr<SVGFEMorphologyElement> SVGFEMorphologyElement::create(const Qualifie return adoptRef(new SVGFEMorphologyElement(tagName, document)); } -void SVGFEMorphologyElement::setRadius(float, float) +void SVGFEMorphologyElement::setRadius(float x, float y) { - // FIXME: Needs an implementation. + setRadiusXBaseValue(x); + setRadiusYBaseValue(y); + invalidate(); } void SVGFEMorphologyElement::parseMappedAttribute(Attribute* attr) @@ -67,6 +69,16 @@ void SVGFEMorphologyElement::parseMappedAttribute(Attribute* attr) SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); } +void SVGFEMorphologyElement::svgAttributeChanged(const QualifiedName& attrName) +{ + SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); + + if (attrName == SVGNames::inAttr + || attrName == SVGNames::operatorAttr + || attrName == SVGNames::radiusAttr) + invalidate(); +} + void SVGFEMorphologyElement::synchronizeProperty(const QualifiedName& attrName) { SVGFilterPrimitiveStandardAttributes::synchronizeProperty(attrName); diff --git a/WebCore/svg/SVGFEMorphologyElement.h b/WebCore/svg/SVGFEMorphologyElement.h index 9bf26ee..6bbc20c 100644 --- a/WebCore/svg/SVGFEMorphologyElement.h +++ b/WebCore/svg/SVGFEMorphologyElement.h @@ -21,7 +21,7 @@ #define SVGFEMorphologyElement_h #if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEMorphology.h" +#include "FEMorphology.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { @@ -39,6 +39,7 @@ private: SVGFEMorphologyElement(const QualifiedName&, Document*); virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*); diff --git a/WebCore/svg/SVGFEOffsetElement.h b/WebCore/svg/SVGFEOffsetElement.h index e522ce2..2d522a2 100644 --- a/WebCore/svg/SVGFEOffsetElement.h +++ b/WebCore/svg/SVGFEOffsetElement.h @@ -22,8 +22,8 @@ #define SVGFEOffsetElement_h #if ENABLE(SVG) && ENABLE(FILTERS) +#include "FEOffset.h" #include "SVGFilterPrimitiveStandardAttributes.h" -#include "SVGFEOffset.h" namespace WebCore { diff --git a/WebCore/svg/SVGFEPointLightElement.cpp b/WebCore/svg/SVGFEPointLightElement.cpp index 4436ab9..666b744 100644 --- a/WebCore/svg/SVGFEPointLightElement.cpp +++ b/WebCore/svg/SVGFEPointLightElement.cpp @@ -21,7 +21,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEPointLightElement.h" -#include "SVGPointLightSource.h" + +#include "PointLightSource.h" namespace WebCore { diff --git a/WebCore/svg/SVGFESpecularLightingElement.h b/WebCore/svg/SVGFESpecularLightingElement.h index 1fed36f..378bc49 100644 --- a/WebCore/svg/SVGFESpecularLightingElement.h +++ b/WebCore/svg/SVGFESpecularLightingElement.h @@ -23,7 +23,7 @@ #define SVGFESpecularLightingElement_h #if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFESpecularLighting.h" +#include "FESpecularLighting.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { diff --git a/WebCore/svg/SVGFESpotLightElement.cpp b/WebCore/svg/SVGFESpotLightElement.cpp index 04731f0..528cb5c 100644 --- a/WebCore/svg/SVGFESpotLightElement.cpp +++ b/WebCore/svg/SVGFESpotLightElement.cpp @@ -21,7 +21,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFESpotLightElement.h" -#include "SVGSpotLightSource.h" + +#include "SpotLightSource.h" namespace WebCore { diff --git a/WebCore/svg/SVGFETileElement.h b/WebCore/svg/SVGFETileElement.h index 03dc08d..b943c55 100644 --- a/WebCore/svg/SVGFETileElement.h +++ b/WebCore/svg/SVGFETileElement.h @@ -22,8 +22,8 @@ #define SVGFETileElement_h #if ENABLE(SVG) && ENABLE(FILTERS) +#include "FETile.h" #include "SVGFilterPrimitiveStandardAttributes.h" -#include "SVGFETile.h" namespace WebCore { diff --git a/WebCore/svg/SVGFETurbulenceElement.h b/WebCore/svg/SVGFETurbulenceElement.h index 887aacf..20e9ed6 100644 --- a/WebCore/svg/SVGFETurbulenceElement.h +++ b/WebCore/svg/SVGFETurbulenceElement.h @@ -22,7 +22,7 @@ #define SVGFETurbulenceElement_h #if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFETurbulence.h" +#include "FETurbulence.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { diff --git a/WebCore/svg/SVGLength.cpp b/WebCore/svg/SVGLength.cpp index bdd5b27..a8cfb4e 100644 --- a/WebCore/svg/SVGLength.cpp +++ b/WebCore/svg/SVGLength.cpp @@ -86,28 +86,41 @@ static inline String lengthTypeToString(SVGLengthType type) return String(); } -inline SVGLengthType stringToLengthType(const String& string) +inline SVGLengthType stringToLengthType(const UChar*& ptr, const UChar* end) { - if (string.endsWith("%")) - return LengthTypePercentage; - else if (string.endsWith("em")) + if (ptr == end) + return LengthTypeNumber; + + const UChar firstChar = *ptr; + ++ptr; + + if (firstChar == '%') { + if (ptr == end) + return LengthTypePercentage; + return LengthTypeUnknown; + } + + const UChar secondChar = *ptr; + + if (++ptr != end) + return LengthTypeUnknown; + + if (firstChar == 'e' && secondChar == 'm') return LengthTypeEMS; - else if (string.endsWith("ex")) + if (firstChar == 'e' && secondChar == 'x') return LengthTypeEXS; - else if (string.endsWith("px")) + if (firstChar == 'p' && secondChar == 'x') return LengthTypePX; - else if (string.endsWith("cm")) + if (firstChar == 'c' && secondChar == 'm') return LengthTypeCM; - else if (string.endsWith("mm")) + if (firstChar == 'm' && secondChar == 'm') return LengthTypeMM; - else if (string.endsWith("in")) + if (firstChar == 'i' && secondChar == 'n') return LengthTypeIN; - else if (string.endsWith("pt")) + if (firstChar == 'p' && secondChar == 't') return LengthTypePT; - else if (string.endsWith("pc")) + if (firstChar == 'p' && secondChar == 'c') return LengthTypePC; - else if (!string.isEmpty()) - return LengthTypeNumber; return LengthTypeUnknown; } @@ -260,8 +273,8 @@ bool SVGLength::setValueAsString(const String& s) if (!parseNumber(ptr, end, convertedNumber, false)) return false; - SVGLengthType type = stringToLengthType(s); - if (ptr != end && type == LengthTypeNumber) + SVGLengthType type = stringToLengthType(ptr, end); + if (type == LengthTypeUnknown) return false; m_unit = storeUnit(extractMode(m_unit), type); diff --git a/WebCore/svg/SVGParserUtilities.cpp b/WebCore/svg/SVGParserUtilities.cpp index b8b6d85..c37d207 100644 --- a/WebCore/svg/SVGParserUtilities.cpp +++ b/WebCore/svg/SVGParserUtilities.cpp @@ -113,7 +113,10 @@ template <typename FloatType> static bool genericParseNumber(const UChar*& ptr, } number = integer + decimal; - number *= sign * static_cast<FloatType>(pow(10.0, expsign * exponent)); + number *= sign; + + if (exponent) + number *= static_cast<FloatType>(pow(10.0, expsign * exponent)); if (start == ptr) return false; diff --git a/WebCore/svg/SVGSVGElement.cpp b/WebCore/svg/SVGSVGElement.cpp index a461ec4..7de880c 100644 --- a/WebCore/svg/SVGSVGElement.cpp +++ b/WebCore/svg/SVGSVGElement.cpp @@ -299,7 +299,7 @@ void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName) // FIXME: Ugly, ugly hack to around that parseMappedAttribute is not called // when svg.width.baseValue = 100 is evaluated. - // Thus the CSS length value for width is not updated, and width() calcWidth() + // Thus the CSS length value for width is not updated, and width() computeLogicalWidth() // calculations on RenderSVGRoot will be wrong. // https://bugs.webkit.org/show_bug.cgi?id=25387 bool updateRelativeLengths = false; diff --git a/WebCore/svg/graphics/filters/SVGDistantLightSource.h b/WebCore/svg/graphics/filters/SVGDistantLightSource.h deleted file mode 100644 index 93c5f2a..0000000 --- a/WebCore/svg/graphics/filters/SVGDistantLightSource.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGDistantLightSource_h -#define SVGDistantLightSource_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGLightSource.h" - -namespace WebCore { - -class DistantLightSource : public LightSource { -public: - static PassRefPtr<DistantLightSource> create(float azimuth, float elevation) - { - return adoptRef(new DistantLightSource(azimuth, elevation)); - } - - float azimuth() const { return m_azimuth; } - float elevation() const { return m_elevation; } - - virtual void initPaintingData(PaintingData&); - virtual void updatePaintingData(PaintingData&, int x, int y, float z); - - virtual TextStream& externalRepresentation(TextStream&) const; - -private: - DistantLightSource(float azimuth, float elevation) - : LightSource(LS_DISTANT) - , m_azimuth(azimuth) - , m_elevation(elevation) - { - } - - float m_azimuth; - float m_elevation; -}; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGDistantLightSource_h diff --git a/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp deleted file mode 100644 index 2dbc7ab..0000000 --- a/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp +++ /dev/null @@ -1,472 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> - * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEConvolveMatrix.h" - -#include "CanvasPixelArray.h" -#include "Filter.h" -#include "ImageData.h" -#include "SVGRenderTreeAsText.h" - -namespace WebCore { - -FEConvolveMatrix::FEConvolveMatrix(const IntSize& kernelSize, - float divisor, float bias, const IntPoint& targetOffset, EdgeModeType edgeMode, - const FloatPoint& kernelUnitLength, bool preserveAlpha, const Vector<float>& kernelMatrix) - : FilterEffect() - , m_kernelSize(kernelSize) - , m_divisor(divisor) - , m_bias(bias) - , m_targetOffset(targetOffset) - , m_edgeMode(edgeMode) - , m_kernelUnitLength(kernelUnitLength) - , m_preserveAlpha(preserveAlpha) - , m_kernelMatrix(kernelMatrix) -{ -} - -PassRefPtr<FEConvolveMatrix> FEConvolveMatrix::create(const IntSize& kernelSize, - float divisor, float bias, const IntPoint& targetOffset, EdgeModeType edgeMode, - const FloatPoint& kernelUnitLength, bool preserveAlpha, const Vector<float>& kernelMatrix) -{ - return adoptRef(new FEConvolveMatrix(kernelSize, divisor, bias, targetOffset, edgeMode, kernelUnitLength, - preserveAlpha, kernelMatrix)); -} - - -IntSize FEConvolveMatrix::kernelSize() const -{ - return m_kernelSize; -} - -void FEConvolveMatrix::setKernelSize(IntSize kernelSize) -{ - m_kernelSize = kernelSize; -} - -const Vector<float>& FEConvolveMatrix::kernel() const -{ - return m_kernelMatrix; -} - -void FEConvolveMatrix::setKernel(const Vector<float>& kernel) -{ - m_kernelMatrix = kernel; -} - -float FEConvolveMatrix::divisor() const -{ - return m_divisor; -} - -void FEConvolveMatrix::setDivisor(float divisor) -{ - m_divisor = divisor; -} - -float FEConvolveMatrix::bias() const -{ - return m_bias; -} - -void FEConvolveMatrix::setBias(float bias) -{ - m_bias = bias; -} - -IntPoint FEConvolveMatrix::targetOffset() const -{ - return m_targetOffset; -} - -void FEConvolveMatrix::setTargetOffset(IntPoint targetOffset) -{ - m_targetOffset = targetOffset; -} - -EdgeModeType FEConvolveMatrix::edgeMode() const -{ - return m_edgeMode; -} - -void FEConvolveMatrix::setEdgeMode(EdgeModeType edgeMode) -{ - m_edgeMode = edgeMode; -} - -FloatPoint FEConvolveMatrix::kernelUnitLength() const -{ - return m_kernelUnitLength; -} - -void FEConvolveMatrix::setKernelUnitLength(FloatPoint kernelUnitLength) -{ - m_kernelUnitLength = kernelUnitLength; -} - -bool FEConvolveMatrix::preserveAlpha() const -{ - return m_preserveAlpha; -} - -void FEConvolveMatrix::setPreserveAlpha(bool preserveAlpha) -{ - m_preserveAlpha = preserveAlpha; -} - -/* - ----------------------------------- - ConvolveMatrix implementation - ----------------------------------- - - The image rectangle is split in the following way: - - +---------------------+ - | A | - +---------------------+ - | | | | - | B | C | D | - | | | | - +---------------------+ - | E | - +---------------------+ - - Where region C contains those pixels, whose values - can be calculated without crossing the edge of the rectangle. - - Example: - Image size: width: 10, height: 10 - - Order (kernel matrix size): width: 3, height 4 - Target: x:1, y:3 - - The following figure shows the target inside the kernel matrix: - - ... - ... - ... - .X. - - The regions in this case are the following: - Note: (x1, y1) top-left and (x2, y2) is the bottom-right corner - Note: row x2 and column y2 is not part of the region - only those (x, y) pixels, where x1 <= x < x2 and y1 <= y < y2 - - Region A: x1: 0, y1: 0, x2: 10, y2: 3 - Region B: x1: 0, y1: 3, x2: 1, y2: 10 - Region C: x1: 1, y1: 3, x2: 9, y2: 10 - Region D: x1: 9, y1: 3, x2: 10, y2: 10 - Region E: x1: 0, y1: 10, x2: 10, y2: 10 (empty region) - - Since region C (often) contains most of the pixels, we implemented - a fast algoritm to calculate these values, called fastSetInteriorPixels. - For other regions, fastSetOuterPixels is used, which calls getPixelValue, - to handle pixels outside of the image. In a rare situations, when - kernel matrix is bigger than the image, all pixels are calculated by this - function. - - Although these two functions have lot in common, I decided not to make - common a template for them, since there are key differences as well, - and would make it really hard to understand. -*/ - -static ALWAYS_INLINE unsigned char clampRGBAValue(float channel, unsigned char max = 255) -{ - if (channel <= 0) - return 0; - if (channel >= max) - return max; - return channel; -} - -template<bool preserveAlphaValues> -ALWAYS_INLINE void setDestinationPixels(CanvasPixelArray* image, int& pixel, float* totals, float divisor, float bias, CanvasPixelArray* src) -{ - unsigned char maxAlpha = preserveAlphaValues ? 255 : clampRGBAValue(totals[3] / divisor + bias); - for (int i = 0; i < 3; ++i) - image->set(pixel++, clampRGBAValue(totals[i] / divisor + bias, maxAlpha)); - - if (preserveAlphaValues) { - image->set(pixel, src->get(pixel)); - ++pixel; - } else - image->set(pixel++, maxAlpha); -} - -// Only for region C -template<bool preserveAlphaValues> -ALWAYS_INLINE void FEConvolveMatrix::fastSetInteriorPixels(PaintingData& paintingData, int clipRight, int clipBottom) -{ - // edge mode does not affect these pixels - int pixel = (m_targetOffset.y() * paintingData.width + m_targetOffset.x()) * 4; - int startKernelPixel = 0; - int kernelIncrease = clipRight * 4; - int xIncrease = (m_kernelSize.width() - 1) * 4; - // Contains the sum of rgb(a) components - float totals[3 + (preserveAlphaValues ? 0 : 1)]; - - // m_divisor cannot be 0, SVGFEConvolveMatrixElement ensures this - ASSERT(m_divisor); - - for (int y = clipBottom + 1; y > 0; --y) { - for (int x = clipRight + 1; x > 0; --x) { - int kernelValue = m_kernelMatrix.size() - 1; - int kernelPixel = startKernelPixel; - int width = m_kernelSize.width(); - - totals[0] = 0; - totals[1] = 0; - totals[2] = 0; - if (!preserveAlphaValues) - totals[3] = 0; - - while (kernelValue >= 0) { - totals[0] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->get(kernelPixel++)); - totals[1] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->get(kernelPixel++)); - totals[2] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->get(kernelPixel++)); - if (!preserveAlphaValues) - totals[3] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->get(kernelPixel)); - ++kernelPixel; - --kernelValue; - if (!--width) { - kernelPixel += kernelIncrease; - width = m_kernelSize.width(); - } - } - - setDestinationPixels<preserveAlphaValues>(paintingData.dstPixelArray, pixel, totals, m_divisor, paintingData.bias, paintingData.srcPixelArray); - startKernelPixel += 4; - } - pixel += xIncrease; - startKernelPixel += xIncrease; - } -} - -ALWAYS_INLINE int FEConvolveMatrix::getPixelValue(PaintingData& paintingData, int x, int y) -{ - if (x >= 0 && x < paintingData.width && x >= 0 && y < paintingData.height) - return (y * paintingData.width + x) << 2; - - switch (m_edgeMode) { - default: // EDGEMODE_NONE - return -1; - case EDGEMODE_DUPLICATE: - if (x < 0) - x = 0; - else if (x >= paintingData.width) - x = paintingData.width - 1; - if (y < 0) - y = 0; - else if (y >= paintingData.height) - y = paintingData.height - 1; - return (y * paintingData.width + x) << 2; - case EDGEMODE_WRAP: - while (x < 0) - x += paintingData.width; - x %= paintingData.width; - while (y < 0) - y += paintingData.height; - y %= paintingData.height; - return (y * paintingData.width + x) << 2; - } -} - -// For other regions than C -template<bool preserveAlphaValues> -void FEConvolveMatrix::fastSetOuterPixels(PaintingData& paintingData, int x1, int y1, int x2, int y2) -{ - int pixel = (y1 * paintingData.width + x1) * 4; - int height = y2 - y1; - int width = x2 - x1; - int beginKernelPixelX = x1 - m_targetOffset.x(); - int startKernelPixelX = beginKernelPixelX; - int startKernelPixelY = y1 - m_targetOffset.y(); - int xIncrease = (paintingData.width - width) * 4; - // Contains the sum of rgb(a) components - float totals[3 + (preserveAlphaValues ? 0 : 1)]; - - // m_divisor cannot be 0, SVGFEConvolveMatrixElement ensures this - ASSERT(m_divisor); - - for (int y = height; y > 0; --y) { - for (int x = width; x > 0; --x) { - int kernelValue = m_kernelMatrix.size() - 1; - int kernelPixelX = startKernelPixelX; - int kernelPixelY = startKernelPixelY; - int width = m_kernelSize.width(); - - totals[0] = 0; - totals[1] = 0; - totals[2] = 0; - if (!preserveAlphaValues) - totals[3] = 0; - - while (kernelValue >= 0) { - int pixelIndex = getPixelValue(paintingData, kernelPixelX, kernelPixelY); - if (pixelIndex >= 0) { - totals[0] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->get(pixelIndex)); - totals[1] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->get(pixelIndex + 1)); - totals[2] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->get(pixelIndex + 2)); - } - if (!preserveAlphaValues && pixelIndex >= 0) - totals[3] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->get(pixelIndex + 3)); - ++kernelPixelX; - --kernelValue; - if (!--width) { - kernelPixelX = startKernelPixelX; - ++kernelPixelY; - width = m_kernelSize.width(); - } - } - - setDestinationPixels<preserveAlphaValues>(paintingData.dstPixelArray, pixel, totals, m_divisor, paintingData.bias, paintingData.srcPixelArray); - ++startKernelPixelX; - } - pixel += xIncrease; - startKernelPixelX = beginKernelPixelX; - ++startKernelPixelY; - } -} - -ALWAYS_INLINE void FEConvolveMatrix::setInteriorPixels(PaintingData& paintingData, int clipRight, int clipBottom) -{ - // Must be implemented here, since it refers another ALWAYS_INLINE - // function, which defined in this C++ source file as well - if (m_preserveAlpha) - fastSetInteriorPixels<true>(paintingData, clipRight, clipBottom); - else - fastSetInteriorPixels<false>(paintingData, clipRight, clipBottom); -} - -ALWAYS_INLINE void FEConvolveMatrix::setOuterPixels(PaintingData& paintingData, int x1, int y1, int x2, int y2) -{ - // Although this function can be moved to the header, it is implemented here - // because setInteriorPixels is also implemented here - if (m_preserveAlpha) - fastSetOuterPixels<true>(paintingData, x1, y1, x2, y2); - else - fastSetOuterPixels<false>(paintingData, x1, y1, x2, y2); -} - -void FEConvolveMatrix::apply(Filter* filter) -{ - FilterEffect* in = inputEffect(0); - in->apply(filter); - if (!in->resultImage()) - return; - - if (!getEffectContext()) - return; - - IntRect imageRect(IntPoint(), resultImage()->size()); - IntRect effectDrawingRect = calculateDrawingIntRect(in->filterPrimitiveSubregion()); - - RefPtr<CanvasPixelArray> srcPixelArray; - if (m_preserveAlpha) - srcPixelArray = in->resultImage()->getUnmultipliedImageData(effectDrawingRect)->data(); - else - srcPixelArray = in->resultImage()->getPremultipliedImageData(effectDrawingRect)->data(); - - RefPtr<ImageData> imageData = ImageData::create(imageRect.width(), imageRect.height()); - - PaintingData paintingData; - paintingData.srcPixelArray = srcPixelArray.get(); - paintingData.dstPixelArray = imageData->data(); - paintingData.width = imageRect.width(); - paintingData.height = imageRect.height(); - paintingData.bias = m_bias * 255; - - // Drawing fully covered pixels - int clipRight = imageRect.width() - m_kernelSize.width(); - int clipBottom = imageRect.height() - m_kernelSize.height(); - - if (clipRight >= 0 && clipBottom >= 0) { - setInteriorPixels(paintingData, clipRight, clipBottom); - - clipRight += m_targetOffset.x() + 1; - clipBottom += m_targetOffset.y() + 1; - if (m_targetOffset.y() > 0) - setOuterPixels(paintingData, 0, 0, imageRect.width(), m_targetOffset.y()); - if (clipBottom < imageRect.height()) - setOuterPixels(paintingData, 0, clipBottom, imageRect.width(), imageRect.height()); - if (m_targetOffset.x() > 0) - setOuterPixels(paintingData, 0, m_targetOffset.y(), m_targetOffset.x(), clipBottom); - if (clipRight < imageRect.width()) - setOuterPixels(paintingData, clipRight, m_targetOffset.y(), imageRect.width(), clipBottom); - } else { - // Rare situation, not optimizied for speed - setOuterPixels(paintingData, 0, 0, imageRect.width(), imageRect.height()); - } - - if (m_preserveAlpha) - resultImage()->putUnmultipliedImageData(imageData.get(), imageRect, IntPoint()); - else - resultImage()->putPremultipliedImageData(imageData.get(), imageRect, IntPoint()); -} - -void FEConvolveMatrix::dump() -{ -} - -static TextStream& operator<<(TextStream& ts, const EdgeModeType& type) -{ - switch (type) { - case EDGEMODE_UNKNOWN: - ts << "UNKNOWN"; - break; - case EDGEMODE_DUPLICATE: - ts << "DUPLICATE"; - break; - case EDGEMODE_WRAP: - ts << "WRAP"; - break; - case EDGEMODE_NONE: - ts << "NONE"; - break; - } - return ts; -} - -TextStream& FEConvolveMatrix::externalRepresentation(TextStream& ts, int indent) const -{ - writeIndent(ts, indent); - ts << "[feConvolveMatrix"; - FilterEffect::externalRepresentation(ts); - ts << " order=\"" << m_kernelSize << "\" " - << "kernelMatrix=\"" << m_kernelMatrix << "\" " - << "divisor=\"" << m_divisor << "\" " - << "bias=\"" << m_bias << "\" " - << "target=\"" << m_targetOffset << "\" " - << "edgeMode=\"" << m_edgeMode << "\" " - << "kernelUnitLength=\"" << m_kernelUnitLength << "\" " - << "preserveAlpha=\"" << m_preserveAlpha << "\"]\n"; - inputEffect(0)->externalRepresentation(ts, indent + 1); - return ts; -} - -}; // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h deleted file mode 100644 index 736933c..0000000 --- a/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGFEConvolveMatrix_h -#define SVGFEConvolveMatrix_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "FilterEffect.h" -#include "FloatPoint.h" -#include "FloatSize.h" -#include "Filter.h" -#include <wtf/AlwaysInline.h> -#include <wtf/Vector.h> - -namespace WebCore { - -enum EdgeModeType { - EDGEMODE_UNKNOWN = 0, - EDGEMODE_DUPLICATE = 1, - EDGEMODE_WRAP = 2, - EDGEMODE_NONE = 3 -}; - -class CanvasPixelArray; - -class FEConvolveMatrix : public FilterEffect { -public: - static PassRefPtr<FEConvolveMatrix> create(const IntSize&, - float, float, const IntPoint&, EdgeModeType, const FloatPoint&, - bool, const Vector<float>&); - - IntSize kernelSize() const; - void setKernelSize(IntSize); - - const Vector<float>& kernel() const; - void setKernel(const Vector<float>&); - - float divisor() const; - void setDivisor(float); - - float bias() const; - void setBias(float); - - IntPoint targetOffset() const; - void setTargetOffset(IntPoint); - - EdgeModeType edgeMode() const; - void setEdgeMode(EdgeModeType); - - FloatPoint kernelUnitLength() const; - void setKernelUnitLength(FloatPoint); - - bool preserveAlpha() const; - void setPreserveAlpha(bool); - - void apply(Filter*); - void dump(); - TextStream& externalRepresentation(TextStream&, int indent) const; - -private: - FEConvolveMatrix(const IntSize&, float, float, - const IntPoint&, EdgeModeType, const FloatPoint&, bool, const Vector<float>&); - - struct PaintingData { - CanvasPixelArray* srcPixelArray; - CanvasPixelArray* dstPixelArray; - int width; - int height; - float bias; - }; - - template<bool preserveAlphaValues> - ALWAYS_INLINE void fastSetInteriorPixels(PaintingData&, int clipRight, int clipBottom); - - ALWAYS_INLINE int getPixelValue(PaintingData&, int x, int y); - - template<bool preserveAlphaValues> - void fastSetOuterPixels(PaintingData&, int x1, int y1, int x2, int y2); - - // Wrapper functions - ALWAYS_INLINE void setInteriorPixels(PaintingData& paintingData, int clipRight, int clipBottom); - ALWAYS_INLINE void setOuterPixels(PaintingData& paintingData, int x1, int y1, int x2, int y2); - - IntSize m_kernelSize; - float m_divisor; - float m_bias; - IntPoint m_targetOffset; - EdgeModeType m_edgeMode; - FloatPoint m_kernelUnitLength; - bool m_preserveAlpha; - Vector<float> m_kernelMatrix; -}; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGFEConvolveMatrix_h diff --git a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp deleted file mode 100644 index b439c46..0000000 --- a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEDiffuseLighting.h" - -#include "SVGLightSource.h" -#include "SVGRenderTreeAsText.h" - -namespace WebCore { - -FEDiffuseLighting::FEDiffuseLighting(const Color& lightingColor, float surfaceScale, - float diffuseConstant, float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) - : FELighting(DiffuseLighting, lightingColor, surfaceScale, diffuseConstant, 0, 0, kernelUnitLengthX, kernelUnitLengthY, lightSource) -{ -} - -PassRefPtr<FEDiffuseLighting> FEDiffuseLighting::create(const Color& lightingColor, - float surfaceScale, float diffuseConstant, float kernelUnitLengthX, - float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) -{ - return adoptRef(new FEDiffuseLighting(lightingColor, surfaceScale, diffuseConstant, kernelUnitLengthX, kernelUnitLengthY, lightSource)); -} - -FEDiffuseLighting::~FEDiffuseLighting() -{ -} - -Color FEDiffuseLighting::lightingColor() const -{ - return m_lightingColor; -} - -void FEDiffuseLighting::setLightingColor(const Color& lightingColor) -{ - m_lightingColor = lightingColor; -} - -float FEDiffuseLighting::surfaceScale() const -{ - return m_surfaceScale; -} - -void FEDiffuseLighting::setSurfaceScale(float surfaceScale) -{ - m_surfaceScale = surfaceScale; -} - -float FEDiffuseLighting::diffuseConstant() const -{ - return m_diffuseConstant; -} - -void FEDiffuseLighting::setDiffuseConstant(float diffuseConstant) -{ - m_diffuseConstant = diffuseConstant; -} - -float FEDiffuseLighting::kernelUnitLengthX() const -{ - return m_kernelUnitLengthX; -} - -void FEDiffuseLighting::setKernelUnitLengthX(float kernelUnitLengthX) -{ - m_kernelUnitLengthX = kernelUnitLengthX; -} - -float FEDiffuseLighting::kernelUnitLengthY() const -{ - return m_kernelUnitLengthY; -} - -void FEDiffuseLighting::setKernelUnitLengthY(float kernelUnitLengthY) -{ - m_kernelUnitLengthY = kernelUnitLengthY; -} - -const LightSource* FEDiffuseLighting::lightSource() const -{ - return m_lightSource.get(); -} - -void FEDiffuseLighting::setLightSource(PassRefPtr<LightSource> lightSource) -{ - m_lightSource = lightSource; -} - -void FEDiffuseLighting::dump() -{ -} - -TextStream& FEDiffuseLighting::externalRepresentation(TextStream& ts, int indent) const -{ - writeIndent(ts, indent); - ts << "[feDiffuseLighting"; - FilterEffect::externalRepresentation(ts); - ts << " surfaceScale=\"" << m_surfaceScale << "\" " - << "diffuseConstant=\"" << m_diffuseConstant << "\" " - << "kernelUnitLength=\"" << m_kernelUnitLengthX << ", " << m_kernelUnitLengthY << "\"]\n"; - inputEffect(0)->externalRepresentation(ts, indent + 1); - return ts; -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h deleted file mode 100644 index 0cdeae3..0000000 --- a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGFEDiffuseLighting_h -#define SVGFEDiffuseLighting_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFELighting.h" - -namespace WebCore { - -class LightSource; - -class FEDiffuseLighting : public FELighting { -public: - static PassRefPtr<FEDiffuseLighting> create(const Color&, float, float, - float, float, PassRefPtr<LightSource>); - virtual ~FEDiffuseLighting(); - - Color lightingColor() const; - void setLightingColor(const Color&); - - float surfaceScale() const; - void setSurfaceScale(float); - - float diffuseConstant() const; - void setDiffuseConstant(float); - - float kernelUnitLengthX() const; - void setKernelUnitLengthX(float); - - float kernelUnitLengthY() const; - void setKernelUnitLengthY(float); - - const LightSource* lightSource() const; - void setLightSource(PassRefPtr<LightSource>); - - void dump(); - TextStream& externalRepresentation(TextStream&, int indent) const; - -private: - FEDiffuseLighting(const Color&, float, float, - float, float, PassRefPtr<LightSource>); -}; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGFEDiffuseLighting_h diff --git a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp deleted file mode 100644 index 9d9857e..0000000 --- a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEDisplacementMap.h" - -#include "CanvasPixelArray.h" -#include "Filter.h" -#include "GraphicsContext.h" -#include "ImageData.h" -#include "SVGRenderTreeAsText.h" - -namespace WebCore { - -FEDisplacementMap::FEDisplacementMap(ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float scale) - : FilterEffect() - , m_xChannelSelector(xChannelSelector) - , m_yChannelSelector(yChannelSelector) - , m_scale(scale) -{ -} - -PassRefPtr<FEDisplacementMap> FEDisplacementMap::create(ChannelSelectorType xChannelSelector, - ChannelSelectorType yChannelSelector, float scale) -{ - return adoptRef(new FEDisplacementMap(xChannelSelector, yChannelSelector, scale)); -} - -ChannelSelectorType FEDisplacementMap::xChannelSelector() const -{ - return m_xChannelSelector; -} - -void FEDisplacementMap::setXChannelSelector(const ChannelSelectorType xChannelSelector) -{ - m_xChannelSelector = xChannelSelector; -} - -ChannelSelectorType FEDisplacementMap::yChannelSelector() const -{ - return m_yChannelSelector; -} - -void FEDisplacementMap::setYChannelSelector(const ChannelSelectorType yChannelSelector) -{ - m_yChannelSelector = yChannelSelector; -} - -float FEDisplacementMap::scale() const -{ - return m_scale; -} - -void FEDisplacementMap::setScale(float scale) -{ - m_scale = scale; -} - -void FEDisplacementMap::apply(Filter* filter) -{ - FilterEffect* in = inputEffect(0); - FilterEffect* in2 = inputEffect(1); - in->apply(filter); - in2->apply(filter); - if (!in->resultImage() || !in2->resultImage()) - return; - - if (m_xChannelSelector == CHANNEL_UNKNOWN || m_yChannelSelector == CHANNEL_UNKNOWN) - return; - - if (!getEffectContext()) - return; - - IntRect effectADrawingRect = calculateDrawingIntRect(in->repaintRectInLocalCoordinates()); - RefPtr<CanvasPixelArray> srcPixelArrayA(in->resultImage()->getPremultipliedImageData(effectADrawingRect)->data()); - - IntRect effectBDrawingRect = calculateDrawingIntRect(in2->repaintRectInLocalCoordinates()); - RefPtr<CanvasPixelArray> srcPixelArrayB(in2->resultImage()->getUnmultipliedImageData(effectBDrawingRect)->data()); - - IntRect imageRect(IntPoint(), resultImage()->size()); - RefPtr<ImageData> imageData = ImageData::create(imageRect.width(), imageRect.height()); - - ASSERT(srcPixelArrayA->length() == srcPixelArrayB->length()); - - float scaleX = m_scale / 255.f * filter->filterResolution().width(); - float scaleY = m_scale / 255.f * filter->filterResolution().height(); - float scaleAdjustmentX = (0.5f - 0.5f * m_scale) * filter->filterResolution().width(); - float scaleAdjustmentY = (0.5f - 0.5f * m_scale) * filter->filterResolution().height(); - int stride = imageRect.width() * 4; - for (int y = 0; y < imageRect.height(); ++y) { - int line = y * stride; - for (int x = 0; x < imageRect.width(); ++x) { - int dstIndex = line + x * 4; - int srcX = x + static_cast<int>(scaleX * srcPixelArrayB->get(dstIndex + m_xChannelSelector - 1) + scaleAdjustmentX); - int srcY = y + static_cast<int>(scaleY * srcPixelArrayB->get(dstIndex + m_yChannelSelector - 1) + scaleAdjustmentY); - for (unsigned channel = 0; channel < 4; ++channel) { - if (srcX < 0 || srcX >= imageRect.width() || srcY < 0 || srcY >= imageRect.height()) - imageData->data()->set(dstIndex + channel, static_cast<unsigned char>(0)); - else { - unsigned char pixelValue = srcPixelArrayA->get(srcY * stride + srcX * 4 + channel); - imageData->data()->set(dstIndex + channel, pixelValue); - } - } - - } - } - resultImage()->putPremultipliedImageData(imageData.get(), imageRect, IntPoint()); -} - -void FEDisplacementMap::dump() -{ -} - -static TextStream& operator<<(TextStream& ts, const ChannelSelectorType& type) -{ - switch (type) { - case CHANNEL_UNKNOWN: - ts << "UNKNOWN"; - break; - case CHANNEL_R: - ts << "RED"; - break; - case CHANNEL_G: - ts << "GREEN"; - break; - case CHANNEL_B: - ts << "BLUE"; - break; - case CHANNEL_A: - ts << "ALPHA"; - break; - } - return ts; -} - -TextStream& FEDisplacementMap::externalRepresentation(TextStream& ts, int indent) const -{ - writeIndent(ts, indent); - ts << "[feDisplacementMap"; - FilterEffect::externalRepresentation(ts); - ts << " scale=\"" << m_scale << "\" " - << "xChannelSelector=\"" << m_xChannelSelector << "\" " - << "yChannelSelector=\"" << m_yChannelSelector << "\"]\n"; - inputEffect(0)->externalRepresentation(ts, indent + 1); - inputEffect(1)->externalRepresentation(ts, indent + 1); - return ts; -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h deleted file mode 100644 index 9e17da4..0000000 --- a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGFEDisplacementMap_h -#define SVGFEDisplacementMap_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "PlatformString.h" -#include "FilterEffect.h" -#include "Filter.h" - -namespace WebCore { - - enum ChannelSelectorType { - CHANNEL_UNKNOWN = 0, - CHANNEL_R = 1, - CHANNEL_G = 2, - CHANNEL_B = 3, - CHANNEL_A = 4 - }; - - class FEDisplacementMap : public FilterEffect { - public: - static PassRefPtr<FEDisplacementMap> create(ChannelSelectorType, ChannelSelectorType, float); - - ChannelSelectorType xChannelSelector() const; - void setXChannelSelector(const ChannelSelectorType); - - ChannelSelectorType yChannelSelector() const; - void setYChannelSelector(const ChannelSelectorType); - - float scale() const; - void setScale(float scale); - - void apply(Filter*); - void dump(); - TextStream& externalRepresentation(TextStream&, int indent) const; - - private: - FEDisplacementMap(ChannelSelectorType, ChannelSelectorType, float); - - ChannelSelectorType m_xChannelSelector; - ChannelSelectorType m_yChannelSelector; - float m_scale; - }; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGFEDisplacementMap_h diff --git a/WebCore/svg/graphics/filters/SVGFEFlood.cpp b/WebCore/svg/graphics/filters/SVGFEFlood.cpp deleted file mode 100644 index a2b2cd2..0000000 --- a/WebCore/svg/graphics/filters/SVGFEFlood.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEFlood.h" - -#include "Filter.h" -#include "GraphicsContext.h" -#include "SVGRenderTreeAsText.h" - -namespace WebCore { - -FEFlood::FEFlood(const Color& floodColor, const float& floodOpacity) - : FilterEffect() - , m_floodColor(floodColor) - , m_floodOpacity(floodOpacity) -{ -} - -PassRefPtr<FEFlood> FEFlood::create(const Color& floodColor, const float& floodOpacity) -{ - return adoptRef(new FEFlood(floodColor, floodOpacity)); -} - -Color FEFlood::floodColor() const -{ - return m_floodColor; -} - -void FEFlood::setFloodColor(const Color& color) -{ - m_floodColor = color; -} - -float FEFlood::floodOpacity() const -{ - return m_floodOpacity; -} - -void FEFlood::setFloodOpacity(float floodOpacity) -{ - m_floodOpacity = floodOpacity; -} - -void FEFlood::apply(Filter*) -{ - GraphicsContext* filterContext = getEffectContext(); - if (!filterContext) - return; - - Color color = colorWithOverrideAlpha(floodColor().rgb(), floodOpacity()); - filterContext->fillRect(FloatRect(FloatPoint(), repaintRectInLocalCoordinates().size()), color, DeviceColorSpace); -} - -void FEFlood::dump() -{ -} - -TextStream& FEFlood::externalRepresentation(TextStream& ts, int indent) const -{ - writeIndent(ts, indent); - ts << "[feFlood"; - FilterEffect::externalRepresentation(ts); - ts << " flood-color=\"" << floodColor() << "\" " - << "flood-opacity=\"" << floodOpacity() << "\"]\n"; - return ts; -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGFEFlood.h b/WebCore/svg/graphics/filters/SVGFEFlood.h deleted file mode 100644 index 8ae251d..0000000 --- a/WebCore/svg/graphics/filters/SVGFEFlood.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGFEFlood_h -#define SVGFEFlood_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "Color.h" -#include "Filter.h" -#include "FilterEffect.h" - -namespace WebCore { - - class FEFlood : public FilterEffect { - public: - static PassRefPtr<FEFlood> create(const Color&, const float&); - - Color floodColor() const; - void setFloodColor(const Color &); - - float floodOpacity() const; - void setFloodOpacity(float); - - void apply(Filter*); - void dump(); - TextStream& externalRepresentation(TextStream&, int indent) const; - - private: - FEFlood(const Color&, const float&); - - Color m_floodColor; - float m_floodOpacity; - }; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGFEFlood_h diff --git a/WebCore/svg/graphics/filters/SVGFEImage.cpp b/WebCore/svg/graphics/filters/SVGFEImage.cpp index a3ac882..c94547b 100644 --- a/WebCore/svg/graphics/filters/SVGFEImage.cpp +++ b/WebCore/svg/graphics/filters/SVGFEImage.cpp @@ -29,18 +29,17 @@ #include "Filter.h" #include "GraphicsContext.h" #include "SVGPreserveAspectRatio.h" -#include "SVGRenderTreeAsText.h" namespace WebCore { -FEImage::FEImage(RefPtr<Image> image, SVGPreserveAspectRatio preserveAspectRatio) +FEImage::FEImage(RefPtr<Image> image, const SVGPreserveAspectRatio& preserveAspectRatio) : FilterEffect() , m_image(image) , m_preserveAspectRatio(preserveAspectRatio) { } -PassRefPtr<FEImage> FEImage::create(RefPtr<Image> image, SVGPreserveAspectRatio preserveAspectRatio) +PassRefPtr<FEImage> FEImage::create(RefPtr<Image> image, const SVGPreserveAspectRatio& preserveAspectRatio) { return adoptRef(new FEImage(image, preserveAspectRatio)); } @@ -50,7 +49,7 @@ void FEImage::apply(Filter*) if (!m_image.get()) return; - GraphicsContext* filterContext = getEffectContext(); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; diff --git a/WebCore/svg/graphics/filters/SVGFEImage.h b/WebCore/svg/graphics/filters/SVGFEImage.h index 97a9cda..fe2d8c4 100644 --- a/WebCore/svg/graphics/filters/SVGFEImage.h +++ b/WebCore/svg/graphics/filters/SVGFEImage.h @@ -29,20 +29,21 @@ namespace WebCore { - class FEImage : public FilterEffect { - public: - static PassRefPtr<FEImage> create(RefPtr<Image>, SVGPreserveAspectRatio); - - void apply(Filter*); - void dump(); - TextStream& externalRepresentation(TextStream&, int indent) const; - - private: - FEImage(RefPtr<Image>, SVGPreserveAspectRatio); - - RefPtr<Image> m_image; - SVGPreserveAspectRatio m_preserveAspectRatio; - }; +class FEImage : public FilterEffect { +public: + static PassRefPtr<FEImage> create(RefPtr<Image>, const SVGPreserveAspectRatio&); + + virtual void apply(Filter*); + virtual void dump(); + + virtual TextStream& externalRepresentation(TextStream&, int indention) const; + +private: + FEImage(RefPtr<Image>, const SVGPreserveAspectRatio&); + + RefPtr<Image> m_image; + SVGPreserveAspectRatio m_preserveAspectRatio; +}; } // namespace WebCore diff --git a/WebCore/svg/graphics/filters/SVGFELighting.cpp b/WebCore/svg/graphics/filters/SVGFELighting.cpp deleted file mode 100644 index dc82840..0000000 --- a/WebCore/svg/graphics/filters/SVGFELighting.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright (C) 2010 University of Szeged - * Copyright (C) 2010 Zoltan Herczeg - * - * 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 UNIVERSITY OF SZEGED ``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 UNIVERSITY OF SZEGED OR - * 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(SVG) && ENABLE(FILTERS) -#include "SVGFELighting.h" - -#include "CanvasPixelArray.h" -#include "ImageData.h" -#include "SVGLightSource.h" - -namespace WebCore { - -FELighting::FELighting(LightingType lightingType, const Color& lightingColor, float surfaceScale, - float diffuseConstant, float specularConstant, float specularExponent, - float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) - : FilterEffect() - , m_lightingType(lightingType) - , m_lightSource(lightSource) - , m_lightingColor(lightingColor) - , m_surfaceScale(surfaceScale) - , m_diffuseConstant(diffuseConstant) - , m_specularConstant(specularConstant) - , m_specularExponent(specularExponent) - , m_kernelUnitLengthX(kernelUnitLengthX) - , m_kernelUnitLengthY(kernelUnitLengthY) -{ -} - -const static int cPixelSize = 4; -const static int cAlphaChannelOffset = 3; -const static unsigned char cOpaqueAlpha = static_cast<unsigned char>(0xff); - -ALWAYS_INLINE int FELighting::LightingData::upLeftPixelValue() -{ - return static_cast<int>(pixels->get(offset - widthMultipliedByPixelSize - cPixelSize + cAlphaChannelOffset)); -} - -ALWAYS_INLINE int FELighting::LightingData::upPixelValue() -{ - return static_cast<int>(pixels->get(offset - widthMultipliedByPixelSize + cAlphaChannelOffset)); -} - -ALWAYS_INLINE int FELighting::LightingData::upRightPixelValue() -{ - return static_cast<int>(pixels->get(offset - widthMultipliedByPixelSize + cPixelSize + cAlphaChannelOffset)); -} - -ALWAYS_INLINE int FELighting::LightingData::leftPixelValue() -{ - return static_cast<int>(pixels->get(offset - cPixelSize + cAlphaChannelOffset)); -} - -ALWAYS_INLINE int FELighting::LightingData::centerPixelValue() -{ - return static_cast<int>(pixels->get(offset + cAlphaChannelOffset)); -} - -ALWAYS_INLINE int FELighting::LightingData::rightPixelValue() -{ - return static_cast<int>(pixels->get(offset + cPixelSize + cAlphaChannelOffset)); -} - -ALWAYS_INLINE int FELighting::LightingData::downLeftPixelValue() -{ - return static_cast<int>(pixels->get(offset + widthMultipliedByPixelSize - cPixelSize + cAlphaChannelOffset)); -} - -ALWAYS_INLINE int FELighting::LightingData::downPixelValue() -{ - return static_cast<int>(pixels->get(offset + widthMultipliedByPixelSize + cAlphaChannelOffset)); -} - -ALWAYS_INLINE int FELighting::LightingData::downRightPixelValue() -{ - return static_cast<int>(pixels->get(offset + widthMultipliedByPixelSize + cPixelSize + cAlphaChannelOffset)); -} - -ALWAYS_INLINE void FELighting::setPixel(LightingData& data, LightSource::PaintingData& paintingData, - int lightX, int lightY, float factorX, int normalX, float factorY, int normalY) -{ - m_lightSource->updatePaintingData(paintingData, lightX, lightY, static_cast<float>(data.pixels->get(data.offset + 3)) * data.surfaceScale); - - data.normalVector.setX(factorX * static_cast<float>(normalX) * data.surfaceScale); - data.normalVector.setY(factorY * static_cast<float>(normalY) * data.surfaceScale); - data.normalVector.setZ(1.0f); - data.normalVector.normalize(); - - if (m_lightingType == FELighting::DiffuseLighting) - data.lightStrength = m_diffuseConstant * (data.normalVector * paintingData.lightVector); - else { - FloatPoint3D halfwayVector = paintingData.lightVector; - halfwayVector.setZ(halfwayVector.z() + 1.0f); - halfwayVector.normalize(); - if (m_specularExponent == 1.0f) - data.lightStrength = m_specularConstant * (data.normalVector * halfwayVector); - else - data.lightStrength = m_specularConstant * powf(data.normalVector * halfwayVector, m_specularExponent); - } - - if (data.lightStrength > 1.0f) - data.lightStrength = 1.0f; - if (data.lightStrength < 0.0f) - data.lightStrength = 0.0f; - - data.pixels->set(data.offset, static_cast<unsigned char>(data.lightStrength * paintingData.colorVector.x())); - data.pixels->set(data.offset + 1, static_cast<unsigned char>(data.lightStrength * paintingData.colorVector.y())); - data.pixels->set(data.offset + 2, static_cast<unsigned char>(data.lightStrength * paintingData.colorVector.z())); -} - -bool FELighting::drawLighting(CanvasPixelArray* pixels, int width, int height) -{ - LightSource::PaintingData paintingData; - LightingData data; - - if (!m_lightSource) - return false; - - // FIXME: do something if width or height (or both) is 1 pixel. - // The W3 spec does not define this case. Now the filter just returns. - if (width <= 2 || height <= 2) - return false; - - data.pixels = pixels; - data.surfaceScale = m_surfaceScale / 255.0f; - data.widthMultipliedByPixelSize = width * cPixelSize; - data.widthDecreasedByOne = width - 1; - data.heightDecreasedByOne = height - 1; - paintingData.colorVector = FloatPoint3D(m_lightingColor.red(), m_lightingColor.green(), m_lightingColor.blue()); - m_lightSource->initPaintingData(paintingData); - - // Top/Left corner - data.offset = 0; - setPixel(data, paintingData, 0, 0, - -2.0f / 3.0f, -2 * data.centerPixelValue() + 2 * data.rightPixelValue() - data.downPixelValue() + data.downRightPixelValue(), - -2.0f / 3.0f, -2 * data.centerPixelValue() - data.rightPixelValue() + 2 * data.downPixelValue() + data.downRightPixelValue()); - - // Top/Right pixel - data.offset = data.widthMultipliedByPixelSize - cPixelSize; - setPixel(data, paintingData, data.widthDecreasedByOne, 0, - -2.0f / 3.0f, -2 * data.leftPixelValue() + 2 * data.centerPixelValue() - data.downLeftPixelValue() + data.downPixelValue(), - -2.0f / 3.0f, -data.leftPixelValue() - 2 * data.centerPixelValue() + data.downLeftPixelValue() + 2 * data.downPixelValue()); - - // Bottom/Left pixel - data.offset = data.heightDecreasedByOne * data.widthMultipliedByPixelSize; - setPixel(data, paintingData, 0, data.heightDecreasedByOne, - -2.0f / 3.0f, -data.upPixelValue() + data.upRightPixelValue() - 2 * data.centerPixelValue() + 2 * data.rightPixelValue(), - -2.0f / 3.0f, -2 * data.upPixelValue() - data.upRightPixelValue() + 2 * data.centerPixelValue() + data.rightPixelValue()); - - // Bottom/Right pixel - data.offset = height * data.widthMultipliedByPixelSize - cPixelSize; - setPixel(data, paintingData, data.widthDecreasedByOne, data.heightDecreasedByOne, - -2.0f / 3.0f, -data.upLeftPixelValue() + data.upPixelValue() - 2 * data.leftPixelValue() + 2 * data.centerPixelValue(), - -2.0f / 3.0f, -data.upLeftPixelValue() - 2 * data.upPixelValue() + data.leftPixelValue() + 2 * data.centerPixelValue()); - - if (width >= 3) { - // Top line - data.offset = cPixelSize; - for (int x = 1; x < data.widthDecreasedByOne; ++x, data.offset += cPixelSize) { - setPixel(data, paintingData, x, 0, - -1.0f / 3.0f, -2 * data.leftPixelValue() + 2 * data.rightPixelValue() - data.downLeftPixelValue() + data.downRightPixelValue(), - -1.0f / 2.0f, -data.leftPixelValue() - 2 * data.centerPixelValue() - data.rightPixelValue() + data.downLeftPixelValue() + 2 * data.downPixelValue() + data.downRightPixelValue()); - } - // Bottom line - data.offset = data.heightDecreasedByOne * data.widthMultipliedByPixelSize + cPixelSize; - for (int x = 1; x < data.widthDecreasedByOne; ++x, data.offset += cPixelSize) { - setPixel(data, paintingData, x, data.heightDecreasedByOne, - -1.0f / 3.0f, -data.upLeftPixelValue() + data.upRightPixelValue() - 2 * data.leftPixelValue() + 2 * data.rightPixelValue(), - -1.0f / 2.0f, -data.upLeftPixelValue() - 2 * data.upPixelValue() - data.upRightPixelValue() + data.leftPixelValue() + 2 * data.centerPixelValue() + data.rightPixelValue()); - } - } - - if (height >= 3) { - // Left line - data.offset = data.widthMultipliedByPixelSize; - for (int y = 1; y < data.heightDecreasedByOne; ++y, data.offset += data.widthMultipliedByPixelSize) { - setPixel(data, paintingData, 0, y, - -1.0f / 2.0f, -data.upPixelValue() + data.upRightPixelValue() - 2 * data.centerPixelValue() + 2 * data.rightPixelValue() - data.downPixelValue() + data.downRightPixelValue(), - -1.0f / 3.0f, -2 * data.upPixelValue() - data.upRightPixelValue() + 2 * data.downPixelValue() + data.downRightPixelValue()); - } - // Right line - data.offset = data.widthMultipliedByPixelSize + data.widthMultipliedByPixelSize - cPixelSize; - for (int y = 1; y < data.heightDecreasedByOne; ++y, data.offset += data.widthMultipliedByPixelSize) { - setPixel(data, paintingData, data.widthDecreasedByOne, y, - -1.0f / 2.0f, -data.upLeftPixelValue() + data.upPixelValue() -2 * data.leftPixelValue() + 2 * data.centerPixelValue() - data.downLeftPixelValue() + data.downPixelValue(), - -1.0f / 3.0f, -data.upLeftPixelValue() - 2 * data.upPixelValue() + data.downLeftPixelValue() + 2 * data.downPixelValue()); - } - } - - if (width >= 3 && height >= 3) { - // Interior pixels - for (int y = 1; y < data.heightDecreasedByOne; ++y) { - data.offset = y * data.widthMultipliedByPixelSize + cPixelSize; - for (int x = 1; x < data.widthDecreasedByOne; ++x, data.offset += cPixelSize) { - setPixel(data, paintingData, x, y, - -1.0f / 4.0f, -data.upLeftPixelValue() + data.upRightPixelValue() - 2 * data.leftPixelValue() + 2 * data.rightPixelValue() - data.downLeftPixelValue() + data.downRightPixelValue(), - -1.0f / 4.0f, -data.upLeftPixelValue() - 2 * data.upPixelValue() - data.upRightPixelValue() + data.downLeftPixelValue() + 2 * data.downPixelValue() + data.downRightPixelValue()); - } - } - } - - int totalSize = data.widthMultipliedByPixelSize * height; - if (m_lightingType == DiffuseLighting) { - for (int i = 3; i < totalSize; i += 4) - data.pixels->set(i, cOpaqueAlpha); - } else { - for (int i = 0; i < totalSize; i += 4) { - unsigned char a1 = data.pixels->get(i); - unsigned char a2 = data.pixels->get(i + 1); - unsigned char a3 = data.pixels->get(i + 2); - // alpha set to set to max(a1, a2, a3) - data.pixels->set(i + 3, a1 >= a2 ? (a1 >= a3 ? a1 : a3) : (a2 >= a3 ? a2 : a3)); - } - } - - return true; -} - -void FELighting::apply(Filter* filter) -{ - FilterEffect* in = inputEffect(0); - in->apply(filter); - if (!in->resultImage()) - return; - - if (!getEffectContext()) - return; - - setIsAlphaImage(false); - - IntRect effectDrawingRect = calculateDrawingIntRect(in->repaintRectInLocalCoordinates()); - RefPtr<ImageData> srcImageData(in->resultImage()->getUnmultipliedImageData(effectDrawingRect)); - CanvasPixelArray* srcPixelArray(srcImageData->data()); - - // FIXME: support kernelUnitLengths other than (1,1). The issue here is that the W3 - // standard has no test case for them, and other browsers (like Firefox) has strange - // output for various kernelUnitLengths, and I am not sure they are reliable. - // Anyway, feConvolveMatrix should also use the implementation - - if (drawLighting(srcPixelArray, effectDrawingRect.width(), effectDrawingRect.height())) - resultImage()->putUnmultipliedImageData(srcImageData.get(), IntRect(IntPoint(), resultImage()->size()), IntPoint()); -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGFELighting.h b/WebCore/svg/graphics/filters/SVGFELighting.h deleted file mode 100644 index 55802ca..0000000 --- a/WebCore/svg/graphics/filters/SVGFELighting.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2010 University of Szeged - * Copyright (C) 2010 Zoltan Herczeg - * - * 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 UNIVERSITY OF SZEGED ``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 UNIVERSITY OF SZEGED OR - * 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. - */ - -#ifndef SVGFELighting_h -#define SVGFELighting_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "Color.h" -#include "Filter.h" -#include "FilterEffect.h" -#include "SVGLightSource.h" -#include <wtf/AlwaysInline.h> - -// Common base class for FEDiffuseLighting and FESpecularLighting - -namespace WebCore { - -class CanvasPixelArray; - -class FELighting : public FilterEffect { -public: - void apply(Filter*); - -protected: - enum LightingType { - DiffuseLighting, - SpecularLighting - }; - - struct LightingData { - FloatPoint3D normalVector; - CanvasPixelArray* pixels; - float lightStrength; - float surfaceScale; - int offset; - int widthMultipliedByPixelSize; - int widthDecreasedByOne; - int heightDecreasedByOne; - - ALWAYS_INLINE int upLeftPixelValue(); - ALWAYS_INLINE int upPixelValue(); - ALWAYS_INLINE int upRightPixelValue(); - ALWAYS_INLINE int leftPixelValue(); - ALWAYS_INLINE int centerPixelValue(); - ALWAYS_INLINE int rightPixelValue(); - ALWAYS_INLINE int downLeftPixelValue(); - ALWAYS_INLINE int downPixelValue(); - ALWAYS_INLINE int downRightPixelValue(); - }; - - FELighting(LightingType, const Color&, float, float, float, float, float, float, PassRefPtr<LightSource>); - - bool drawLighting(CanvasPixelArray*, int, int); - ALWAYS_INLINE void setPixel(LightingData&, LightSource::PaintingData&, - int lightX, int lightY, float factorX, int normalX, float factorY, int normalY); - - LightingType m_lightingType; - RefPtr<LightSource> m_lightSource; - - Color m_lightingColor; - float m_surfaceScale; - float m_diffuseConstant; - float m_specularConstant; - float m_specularExponent; - float m_kernelUnitLengthX; - float m_kernelUnitLengthY; -}; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGFELighting_h diff --git a/WebCore/svg/graphics/filters/SVGFEMerge.cpp b/WebCore/svg/graphics/filters/SVGFEMerge.cpp deleted file mode 100644 index e92ce4c..0000000 --- a/WebCore/svg/graphics/filters/SVGFEMerge.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEMerge.h" - -#include "Filter.h" -#include "GraphicsContext.h" -#include "SVGRenderTreeAsText.h" - -namespace WebCore { - -FEMerge::FEMerge() - : FilterEffect() -{ -} - -PassRefPtr<FEMerge> FEMerge::create() -{ - return adoptRef(new FEMerge); -} - -void FEMerge::apply(Filter* filter) -{ - unsigned size = numberOfEffectInputs(); - ASSERT(size > 0); - for (unsigned i = 0; i < size; ++i) { - FilterEffect* in = inputEffect(i); - in->apply(filter); - if (!in->resultImage()) - return; - } - - GraphicsContext* filterContext = getEffectContext(); - if (!filterContext) - return; - - for (unsigned i = 0; i < size; ++i) { - FilterEffect* in = inputEffect(i); - filterContext->drawImageBuffer(in->resultImage(), DeviceColorSpace, calculateDrawingRect(in->repaintRectInLocalCoordinates())); - } -} - -void FEMerge::dump() -{ -} - -TextStream& FEMerge::externalRepresentation(TextStream& ts, int indent) const -{ - writeIndent(ts, indent); - ts << "[feMerge"; - FilterEffect::externalRepresentation(ts); - unsigned size = numberOfEffectInputs(); - ASSERT(size > 0); - ts << " mergeNodes=\"" << size << "\"]\n"; - for (unsigned i = 0; i < size; ++i) - inputEffect(i)->externalRepresentation(ts, indent + 1); - return ts; -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGFEMerge.h b/WebCore/svg/graphics/filters/SVGFEMerge.h deleted file mode 100644 index 439d789..0000000 --- a/WebCore/svg/graphics/filters/SVGFEMerge.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGFEMerge_h -#define SVGFEMerge_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "FilterEffect.h" -#include "Filter.h" -#include <wtf/Vector.h> - -namespace WebCore { - - class FEMerge : public FilterEffect { - public: - static PassRefPtr<FEMerge> create(); - - void apply(Filter*); - void dump(); - TextStream& externalRepresentation(TextStream&, int indent) const; - - private: - FEMerge(); - }; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGFEMerge_h diff --git a/WebCore/svg/graphics/filters/SVGFEMorphology.cpp b/WebCore/svg/graphics/filters/SVGFEMorphology.cpp deleted file mode 100644 index 6645259..0000000 --- a/WebCore/svg/graphics/filters/SVGFEMorphology.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEMorphology.h" - -#include "CanvasPixelArray.h" -#include "Filter.h" -#include "ImageData.h" -#include "SVGRenderTreeAsText.h" - -#include <wtf/Vector.h> - -using std::min; -using std::max; - -namespace WebCore { - -FEMorphology::FEMorphology(MorphologyOperatorType type, float radiusX, float radiusY) - : FilterEffect() - , m_type(type) - , m_radiusX(radiusX) - , m_radiusY(radiusY) -{ -} - -PassRefPtr<FEMorphology> FEMorphology::create(MorphologyOperatorType type, float radiusX, float radiusY) -{ - return adoptRef(new FEMorphology(type, radiusX, radiusY)); -} - -MorphologyOperatorType FEMorphology::morphologyOperator() const -{ - return m_type; -} - -void FEMorphology::setMorphologyOperator(MorphologyOperatorType type) -{ - m_type = type; -} - -float FEMorphology::radiusX() const -{ - return m_radiusX; -} - -void FEMorphology::setRadiusX(float radiusX) -{ - m_radiusX = radiusX; -} - -float FEMorphology::radiusY() const -{ - return m_radiusY; -} - -void FEMorphology::setRadiusY(float radiusY) -{ - m_radiusY = radiusY; -} - -void FEMorphology::apply(Filter* filter) -{ - FilterEffect* in = inputEffect(0); - in->apply(filter); - if (!in->resultImage()) - return; - - if (!getEffectContext()) - return; - - setIsAlphaImage(in->isAlphaImage()); - - int radiusX = static_cast<int>(m_radiusX * filter->filterResolution().width()); - int radiusY = static_cast<int>(m_radiusY * filter->filterResolution().height()); - if (radiusX <= 0 || radiusY <= 0) - return; - - IntRect imageRect(IntPoint(), resultImage()->size()); - IntRect effectDrawingRect = calculateDrawingIntRect(in->repaintRectInLocalCoordinates()); - RefPtr<CanvasPixelArray> srcPixelArray(in->resultImage()->getPremultipliedImageData(effectDrawingRect)->data()); - RefPtr<ImageData> imageData = ImageData::create(imageRect.width(), imageRect.height()); - - int effectWidth = effectDrawingRect.width() * 4; - - // Limit the radius size to effect dimensions - radiusX = min(effectDrawingRect.width() - 1, radiusX); - radiusY = min(effectDrawingRect.height() - 1, radiusY); - - Vector<unsigned char> extrema; - for (int y = 0; y < effectDrawingRect.height(); ++y) { - int startY = max(0, y - radiusY); - int endY = min(effectDrawingRect.height() - 1, y + radiusY); - for (unsigned channel = 0; channel < 4; ++channel) { - // Fill the kernel - extrema.clear(); - for (int j = 0; j <= radiusX; ++j) { - unsigned char columnExtrema = srcPixelArray->get(startY * effectWidth + 4 * j + channel); - for (int i = startY; i <= endY; ++i) { - unsigned char pixel = srcPixelArray->get(i * effectWidth + 4 * j + channel); - if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && pixel <= columnExtrema) || - (m_type == FEMORPHOLOGY_OPERATOR_DILATE && pixel >= columnExtrema)) - columnExtrema = pixel; - } - extrema.append(columnExtrema); - } - - // Kernel is filled, get extrema of next column - for (int x = 0; x < effectDrawingRect.width(); ++x) { - unsigned endX = min(x + radiusX, effectDrawingRect.width() - 1); - unsigned char columnExtrema = srcPixelArray->get(startY * effectWidth + endX * 4 + channel); - for (int i = startY; i <= endY; ++i) { - unsigned char pixel = srcPixelArray->get(i * effectWidth + endX * 4 + channel); - if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && pixel <= columnExtrema) || - (m_type == FEMORPHOLOGY_OPERATOR_DILATE && pixel >= columnExtrema)) - columnExtrema = pixel; - } - if (x - radiusX >= 0) - extrema.remove(0); - if (x + radiusX <= effectDrawingRect.width()) - extrema.append(columnExtrema); - unsigned char entireExtrema = extrema[0]; - for (unsigned kernelIndex = 0; kernelIndex < extrema.size(); ++kernelIndex) { - if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && extrema[kernelIndex] <= entireExtrema) || - (m_type == FEMORPHOLOGY_OPERATOR_DILATE && extrema[kernelIndex] >= entireExtrema)) - entireExtrema = extrema[kernelIndex]; - } - imageData->data()->set(y * effectWidth + 4 * x + channel, entireExtrema); - } - } - } - resultImage()->putPremultipliedImageData(imageData.get(), imageRect, IntPoint()); -} - -void FEMorphology::dump() -{ -} - -static TextStream& operator<<(TextStream& ts, const MorphologyOperatorType& type) -{ - switch (type) { - case FEMORPHOLOGY_OPERATOR_UNKNOWN: - ts << "UNKNOWN"; - break; - case FEMORPHOLOGY_OPERATOR_ERODE: - ts << "ERODE"; - break; - case FEMORPHOLOGY_OPERATOR_DILATE: - ts << "DILATE"; - break; - } - return ts; -} - -TextStream& FEMorphology::externalRepresentation(TextStream& ts, int indent) const -{ - writeIndent(ts, indent); - ts << "[feMorphology"; - FilterEffect::externalRepresentation(ts); - ts << " operator=\"" << morphologyOperator() << "\" " - << "radius=\"" << radiusX() << ", " << radiusY() << "\"]\n"; - inputEffect(0)->externalRepresentation(ts, indent + 1); - return ts; -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGFEMorphology.h b/WebCore/svg/graphics/filters/SVGFEMorphology.h deleted file mode 100644 index 9743d2b..0000000 --- a/WebCore/svg/graphics/filters/SVGFEMorphology.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGFEMorphology_h -#define SVGFEMorphology_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "FilterEffect.h" -#include "Filter.h" - -namespace WebCore { - - enum MorphologyOperatorType { - FEMORPHOLOGY_OPERATOR_UNKNOWN = 0, - FEMORPHOLOGY_OPERATOR_ERODE = 1, - FEMORPHOLOGY_OPERATOR_DILATE = 2 - }; - - class FEMorphology : public FilterEffect { - public: - static PassRefPtr<FEMorphology> create(MorphologyOperatorType, float radiusX, float radiusY); - MorphologyOperatorType morphologyOperator() const; - void setMorphologyOperator(MorphologyOperatorType); - - float radiusX() const; - void setRadiusX(float); - - float radiusY() const; - void setRadiusY(float); - - void apply(Filter*); - void dump(); - TextStream& externalRepresentation(TextStream&, int indent) const; - - private: - FEMorphology(MorphologyOperatorType, float radiusX, float radiusY); - - MorphologyOperatorType m_type; - float m_radiusX; - float m_radiusY; - }; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGFEMorphology_h diff --git a/WebCore/svg/graphics/filters/SVGFEOffset.cpp b/WebCore/svg/graphics/filters/SVGFEOffset.cpp deleted file mode 100644 index 685bd7b..0000000 --- a/WebCore/svg/graphics/filters/SVGFEOffset.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEOffset.h" - -#include "Filter.h" -#include "GraphicsContext.h" -#include "SVGRenderTreeAsText.h" - -namespace WebCore { - -FEOffset::FEOffset(float dx, float dy) - : FilterEffect() - , m_dx(dx) - , m_dy(dy) -{ -} - -PassRefPtr<FEOffset> FEOffset::create(float dx, float dy) -{ - return adoptRef(new FEOffset(dx, dy)); -} - -float FEOffset::dx() const -{ - return m_dx; -} - -void FEOffset::setDx(float dx) -{ - m_dx = dx; -} - -float FEOffset::dy() const -{ - return m_dy; -} - -void FEOffset::setDy(float dy) -{ - m_dy = dy; -} - -void FEOffset::apply(Filter* filter) -{ - FilterEffect* in = inputEffect(0); - in->apply(filter); - if (!in->resultImage()) - return; - - GraphicsContext* filterContext = getEffectContext(); - if (!filterContext) - return; - - setIsAlphaImage(in->isAlphaImage()); - - FloatRect sourceImageRect = filter->sourceImageRect(); - sourceImageRect.scale(filter->filterResolution().width(), filter->filterResolution().height()); - - if (filter->effectBoundingBoxMode()) { - m_dx *= sourceImageRect.width(); - m_dy *= sourceImageRect.height(); - } - m_dx *= filter->filterResolution().width(); - m_dy *= filter->filterResolution().height(); - - FloatRect dstRect = FloatRect(m_dx + in->repaintRectInLocalCoordinates().x() - repaintRectInLocalCoordinates().x(), - m_dy + in->repaintRectInLocalCoordinates().y() - repaintRectInLocalCoordinates().y(), - in->repaintRectInLocalCoordinates().width(), - in->repaintRectInLocalCoordinates().height()); - - filterContext->drawImageBuffer(in->resultImage(), DeviceColorSpace, dstRect); -} - -void FEOffset::dump() -{ -} - -TextStream& FEOffset::externalRepresentation(TextStream& ts, int indent) const -{ - writeIndent(ts, indent); - ts << "[feOffset"; - FilterEffect::externalRepresentation(ts); - ts << " dx=\"" << dx() << "\" dy=\"" << dy() << "\"]\n"; - inputEffect(0)->externalRepresentation(ts, indent + 1); - return ts; -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGFEOffset.h b/WebCore/svg/graphics/filters/SVGFEOffset.h deleted file mode 100644 index 34ed97b..0000000 --- a/WebCore/svg/graphics/filters/SVGFEOffset.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGFEOffset_h -#define SVGFEOffset_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "FilterEffect.h" -#include "Filter.h" - -namespace WebCore { - - class FEOffset : public FilterEffect { - public: - static PassRefPtr<FEOffset> create(float, float); - - float dx() const; - void setDx(float); - - float dy() const; - void setDy(float); - - void apply(Filter*); - void dump(); - TextStream& externalRepresentation(TextStream&, int indent) const; - - private: - FEOffset(float, float); - - float m_dx; - float m_dy; - }; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGFEOffset_h diff --git a/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp b/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp deleted file mode 100644 index 33f7b6c..0000000 --- a/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFESpecularLighting.h" - -#include "SVGLightSource.h" -#include "SVGRenderTreeAsText.h" - -namespace WebCore { - -FESpecularLighting::FESpecularLighting(const Color& lightingColor, float surfaceScale, - float specularConstant, float specularExponent, float kernelUnitLengthX, - float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) - : FELighting(SpecularLighting, lightingColor, surfaceScale, 0, specularConstant, specularExponent, kernelUnitLengthX, kernelUnitLengthY, lightSource) -{ -} - -PassRefPtr<FESpecularLighting> FESpecularLighting::create(const Color& lightingColor, - float surfaceScale, float specularConstant, float specularExponent, - float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) -{ - return adoptRef(new FESpecularLighting(lightingColor, surfaceScale, specularConstant, specularExponent, - kernelUnitLengthX, kernelUnitLengthY, lightSource)); -} - -FESpecularLighting::~FESpecularLighting() -{ -} - -Color FESpecularLighting::lightingColor() const -{ - return m_lightingColor; -} - -void FESpecularLighting::setLightingColor(const Color& lightingColor) -{ - m_lightingColor = lightingColor; -} - -float FESpecularLighting::surfaceScale() const -{ - return m_surfaceScale; -} - -void FESpecularLighting::setSurfaceScale(float surfaceScale) -{ - m_surfaceScale = surfaceScale; -} - -float FESpecularLighting::specularConstant() const -{ - return m_specularConstant; -} - -void FESpecularLighting::setSpecularConstant(float specularConstant) -{ - m_specularConstant = specularConstant; -} - -float FESpecularLighting::specularExponent() const -{ - return m_specularExponent; -} - -void FESpecularLighting::setSpecularExponent(float specularExponent) -{ - m_specularExponent = specularExponent; -} - -float FESpecularLighting::kernelUnitLengthX() const -{ - return m_kernelUnitLengthX; -} - -void FESpecularLighting::setKernelUnitLengthX(float kernelUnitLengthX) -{ - m_kernelUnitLengthX = kernelUnitLengthX; -} - -float FESpecularLighting::kernelUnitLengthY() const -{ - return m_kernelUnitLengthY; -} - -void FESpecularLighting::setKernelUnitLengthY(float kernelUnitLengthY) -{ - m_kernelUnitLengthY = kernelUnitLengthY; -} - -const LightSource* FESpecularLighting::lightSource() const -{ - return m_lightSource.get(); -} - -void FESpecularLighting::setLightSource(PassRefPtr<LightSource> lightSource) -{ - m_lightSource = lightSource; -} - -void FESpecularLighting::dump() -{ -} - -TextStream& FESpecularLighting::externalRepresentation(TextStream& ts, int indent) const -{ - writeIndent(ts, indent); - ts << "[feSpecularLighting"; - FilterEffect::externalRepresentation(ts); - ts << " surfaceScale=\"" << m_surfaceScale << "\" " - << "specualConstant=\"" << m_specularConstant << "\" " - << "specularExponent=\"" << m_specularExponent << "\"]\n"; - inputEffect(0)->externalRepresentation(ts, indent + 1); - return ts; -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGFESpecularLighting.h b/WebCore/svg/graphics/filters/SVGFESpecularLighting.h deleted file mode 100644 index 6067a76..0000000 --- a/WebCore/svg/graphics/filters/SVGFESpecularLighting.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGFESpecularLighting_h -#define SVGFESpecularLighting_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFELighting.h" - -namespace WebCore { - -class FESpecularLighting : public FELighting { -public: - static PassRefPtr<FESpecularLighting> create(const Color&, float, float, - float, float, float, PassRefPtr<LightSource>); - virtual ~FESpecularLighting(); - - Color lightingColor() const; - void setLightingColor(const Color&); - - float surfaceScale() const; - void setSurfaceScale(float); - - float specularConstant() const; - void setSpecularConstant(float); - - float specularExponent() const; - void setSpecularExponent(float); - - float kernelUnitLengthX() const; - void setKernelUnitLengthX(float); - - float kernelUnitLengthY() const; - void setKernelUnitLengthY(float); - - const LightSource* lightSource() const; - void setLightSource(PassRefPtr<LightSource>); - - void dump(); - TextStream& externalRepresentation(TextStream&, int indent) const; - -private: - FESpecularLighting(const Color&, float, float, float, float, float, PassRefPtr<LightSource>); -}; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGFESpecularLighting_h diff --git a/WebCore/svg/graphics/filters/SVGFETile.cpp b/WebCore/svg/graphics/filters/SVGFETile.cpp deleted file mode 100644 index 80eb9b3..0000000 --- a/WebCore/svg/graphics/filters/SVGFETile.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> - * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFETile.h" - -#include "AffineTransform.h" -#include "Filter.h" -#include "GraphicsContext.h" -#include "Pattern.h" -#include "SVGRenderTreeAsText.h" - -namespace WebCore { - -FETile::FETile() - : FilterEffect() -{ -} - -PassRefPtr<FETile> FETile::create() -{ - return adoptRef(new FETile); -} - -FloatRect FETile::determineFilterPrimitiveSubregion(Filter* filter) -{ - inputEffect(0)->determineFilterPrimitiveSubregion(filter); - - filter->determineFilterPrimitiveSubregion(this, filter->filterRegion()); - return filterPrimitiveSubregion(); -} - -void FETile::apply(Filter* filter) -{ - FilterEffect* in = inputEffect(0); - in->apply(filter); - if (!in->resultImage()) - return; - - GraphicsContext* filterContext = getEffectContext(); - if (!filterContext) - return; - - setIsAlphaImage(in->isAlphaImage()); - - IntRect tileRect = enclosingIntRect(in->repaintRectInLocalCoordinates()); - - // Source input needs more attention. It has the size of the filterRegion but gives the - // size of the cutted sourceImage back. This is part of the specification and optimization. - if (in->isSourceInput()) { - FloatRect filterRegion = filter->filterRegion(); - filterRegion.scale(filter->filterResolution().width(), filter->filterResolution().height()); - tileRect = enclosingIntRect(filterRegion); - } - - OwnPtr<ImageBuffer> tileImage = ImageBuffer::create(tileRect.size()); - GraphicsContext* tileImageContext = tileImage->context(); - tileImageContext->drawImageBuffer(in->resultImage(), DeviceColorSpace, IntPoint()); - RefPtr<Pattern> pattern = Pattern::create(tileImage->copyImage(), true, true); - - AffineTransform matrix; - matrix.translate(in->repaintRectInLocalCoordinates().x() - repaintRectInLocalCoordinates().x(), - in->repaintRectInLocalCoordinates().y() - repaintRectInLocalCoordinates().y()); - pattern.get()->setPatternSpaceTransform(matrix); - - filterContext->setFillPattern(pattern); - filterContext->fillRect(FloatRect(FloatPoint(), repaintRectInLocalCoordinates().size())); -} - -void FETile::dump() -{ -} - -TextStream& FETile::externalRepresentation(TextStream& ts, int indent) const -{ - writeIndent(ts, indent); - ts << "[feTile"; - FilterEffect::externalRepresentation(ts); - ts << "]\n"; - inputEffect(0)->externalRepresentation(ts, indent + 1); - - return ts; -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - diff --git a/WebCore/svg/graphics/filters/SVGFETile.h b/WebCore/svg/graphics/filters/SVGFETile.h deleted file mode 100644 index 128c9cb..0000000 --- a/WebCore/svg/graphics/filters/SVGFETile.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGFETile_h -#define SVGFETile_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "FilterEffect.h" -#include "Filter.h" - -namespace WebCore { - - class FETile : public FilterEffect { - public: - static PassRefPtr<FETile> create(); - - void apply(Filter*); - void dump(); - TextStream& externalRepresentation(TextStream&, int indent) const; - - virtual FloatRect determineFilterPrimitiveSubregion(Filter*); - - private: - FETile(); - }; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGFETile_h diff --git a/WebCore/svg/graphics/filters/SVGFETurbulence.cpp b/WebCore/svg/graphics/filters/SVGFETurbulence.cpp deleted file mode 100644 index 399f7fc..0000000 --- a/WebCore/svg/graphics/filters/SVGFETurbulence.cpp +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> - * Copyright (C) 2010 Renata Hodovan <reni@inf.u-szeged.hu> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFETurbulence.h" - -#include "CanvasPixelArray.h" -#include "Filter.h" -#include "ImageData.h" -#include "SVGRenderTreeAsText.h" - -#include <wtf/MathExtras.h> - -namespace WebCore { - -/* - Produces results in the range [1, 2**31 - 2]. Algorithm is: - r = (a * r) mod m where a = randAmplitude = 16807 and - m = randMaximum = 2**31 - 1 = 2147483647, r = seed. - See [Park & Miller], CACM vol. 31 no. 10 p. 1195, Oct. 1988 - To test: the algorithm should produce the result 1043618065 - as the 10,000th generated number if the original seed is 1. -*/ -static const int s_perlinNoise = 4096; -static const long s_randMaximum = 2147483647; // 2**31 - 1 -static const int s_randAmplitude = 16807; // 7**5; primitive root of m -static const int s_randQ = 127773; // m / a -static const int s_randR = 2836; // m % a - -FETurbulence::FETurbulence(TurbulanceType type, float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, bool stitchTiles) - : FilterEffect() - , m_type(type) - , m_baseFrequencyX(baseFrequencyX) - , m_baseFrequencyY(baseFrequencyY) - , m_numOctaves(numOctaves) - , m_seed(seed) - , m_stitchTiles(stitchTiles) -{ -} - -PassRefPtr<FETurbulence> FETurbulence::create(TurbulanceType type, float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, bool stitchTiles) -{ - return adoptRef(new FETurbulence(type, baseFrequencyX, baseFrequencyY, numOctaves, seed, stitchTiles)); -} - -TurbulanceType FETurbulence::type() const -{ - return m_type; -} - -void FETurbulence::setType(TurbulanceType type) -{ - m_type = type; -} - -float FETurbulence::baseFrequencyY() const -{ - return m_baseFrequencyY; -} - -void FETurbulence::setBaseFrequencyY(float baseFrequencyY) -{ - m_baseFrequencyY = baseFrequencyY; -} - -float FETurbulence::baseFrequencyX() const -{ - return m_baseFrequencyX; -} - -void FETurbulence::setBaseFrequencyX(float baseFrequencyX) -{ - m_baseFrequencyX = baseFrequencyX; -} - -float FETurbulence::seed() const -{ - return m_seed; -} - -void FETurbulence::setSeed(float seed) -{ - m_seed = seed; -} - -int FETurbulence::numOctaves() const -{ - return m_numOctaves; -} - -void FETurbulence::setNumOctaves(bool numOctaves) -{ - m_numOctaves = numOctaves; -} - -bool FETurbulence::stitchTiles() const -{ - return m_stitchTiles; -} - -void FETurbulence::setStitchTiles(bool stitch) -{ - m_stitchTiles = stitch; -} - -// The turbulence calculation code is an adapted version of what appears in the SVG 1.1 specification: -// http://www.w3.org/TR/SVG11/filters.html#feTurbulence - -FETurbulence::PaintingData::PaintingData(long paintingSeed, const IntSize& paintingSize) - : seed(paintingSeed) - , width(0) - , height(0) - , wrapX(0) - , wrapY(0) - , channel(0) - , filterSize(paintingSize) -{ -} - -// Compute pseudo random number. -inline long FETurbulence::PaintingData::random() -{ - long result = s_randAmplitude * (seed % s_randQ) - s_randR * (seed / s_randQ); - if (result <= 0) - result += s_randMaximum; - seed = result; - return result; -} - -inline float smoothCurve(float t) -{ - return t * t * (3 - 2 * t); -} - -inline float linearInterpolation(float t, float a, float b) -{ - return a + t * (b - a); -} - -inline void FETurbulence::initPaint(PaintingData& paintingData) -{ - float normalizationFactor; - - // The seed value clamp to the range [1, s_randMaximum - 1]. - if (paintingData.seed <= 0) - paintingData.seed = -(paintingData.seed % (s_randMaximum - 1)) + 1; - if (paintingData.seed > s_randMaximum - 1) - paintingData.seed = s_randMaximum - 1; - - float* gradient; - for (int channel = 0; channel < 4; ++channel) { - for (int i = 0; i < s_blockSize; ++i) { - paintingData.latticeSelector[i] = i; - gradient = paintingData.gradient[channel][i]; - gradient[0] = static_cast<float>((paintingData.random() % (2 * s_blockSize)) - s_blockSize) / s_blockSize; - gradient[1] = static_cast<float>((paintingData.random() % (2 * s_blockSize)) - s_blockSize) / s_blockSize; - normalizationFactor = sqrtf(gradient[0] * gradient[0] + gradient[1] * gradient[1]); - gradient[0] /= normalizationFactor; - gradient[1] /= normalizationFactor; - } - } - for (int i = s_blockSize - 1; i > 0; --i) { - int k = paintingData.latticeSelector[i]; - int j = paintingData.random() % s_blockSize; - ASSERT(j >= 0); - ASSERT(j < 2 * s_blockSize + 2); - paintingData.latticeSelector[i] = paintingData.latticeSelector[j]; - paintingData.latticeSelector[j] = k; - } - for (int i = 0; i < s_blockSize + 2; ++i) { - paintingData.latticeSelector[s_blockSize + i] = paintingData.latticeSelector[i]; - for (int channel = 0; channel < 4; ++channel) { - paintingData.gradient[channel][s_blockSize + i][0] = paintingData.gradient[channel][i][0]; - paintingData.gradient[channel][s_blockSize + i][1] = paintingData.gradient[channel][i][1]; - } - } -} - -inline void checkNoise(int& noiseValue, int limitValue, int newValue) -{ - if (noiseValue >= limitValue) - noiseValue -= newValue; - if (noiseValue >= limitValue - 1) - noiseValue -= newValue - 1; -} - -float FETurbulence::noise2D(PaintingData& paintingData, const FloatPoint& noiseVector) -{ - struct Noise { - int noisePositionIntegerValue; - float noisePositionFractionValue; - - Noise(float component) - { - float position = component + s_perlinNoise; - noisePositionIntegerValue = static_cast<int>(position); - noisePositionFractionValue = position - noisePositionIntegerValue; - } - }; - - Noise noiseX(noiseVector.x()); - Noise noiseY(noiseVector.y()); - float* q; - float sx, sy, a, b, u, v; - - // If stitching, adjust lattice points accordingly. - if (m_stitchTiles) { - checkNoise(noiseX.noisePositionIntegerValue, paintingData.wrapX, paintingData.width); - checkNoise(noiseY.noisePositionIntegerValue, paintingData.wrapY, paintingData.height); - } - - noiseX.noisePositionIntegerValue &= s_blockMask; - noiseY.noisePositionIntegerValue &= s_blockMask; - int latticeIndex = paintingData.latticeSelector[noiseX.noisePositionIntegerValue]; - int nextLatticeIndex = paintingData.latticeSelector[(noiseX.noisePositionIntegerValue + 1) & s_blockMask]; - - sx = smoothCurve(noiseX.noisePositionFractionValue); - sy = smoothCurve(noiseY.noisePositionFractionValue); - - // This is taken 1:1 from SVG spec: http://www.w3.org/TR/SVG11/filters.html#feTurbulenceElement. - int temp = paintingData.latticeSelector[latticeIndex + noiseY.noisePositionIntegerValue]; - q = paintingData.gradient[paintingData.channel][temp]; - u = noiseX.noisePositionFractionValue * q[0] + noiseY.noisePositionFractionValue * q[1]; - temp = paintingData.latticeSelector[nextLatticeIndex + noiseY.noisePositionIntegerValue]; - q = paintingData.gradient[paintingData.channel][temp]; - v = (noiseX.noisePositionFractionValue - 1) * q[0] + noiseY.noisePositionFractionValue * q[1]; - a = linearInterpolation(sx, u, v); - temp = paintingData.latticeSelector[latticeIndex + noiseY.noisePositionIntegerValue + 1]; - q = paintingData.gradient[paintingData.channel][temp]; - u = noiseX.noisePositionFractionValue * q[0] + (noiseY.noisePositionFractionValue - 1) * q[1]; - temp = paintingData.latticeSelector[nextLatticeIndex + noiseY.noisePositionIntegerValue + 1]; - q = paintingData.gradient[paintingData.channel][temp]; - v = (noiseX.noisePositionFractionValue - 1) * q[0] + (noiseY.noisePositionFractionValue - 1) * q[1]; - b = linearInterpolation(sx, u, v); - return linearInterpolation(sy, a, b); -} - -unsigned char FETurbulence::calculateTurbulenceValueForPoint(PaintingData& paintingData, const FloatPoint& point) -{ - float tileWidth = paintingData.filterSize.width(); - ASSERT(tileWidth > 0); - float tileHeight = paintingData.filterSize.height(); - ASSERT(tileHeight > 0); - // Adjust the base frequencies if necessary for stitching. - if (m_stitchTiles) { - // When stitching tiled turbulence, the frequencies must be adjusted - // so that the tile borders will be continuous. - if (m_baseFrequencyX) { - float lowFrequency = floorf(tileWidth * m_baseFrequencyX) / tileWidth; - float highFrequency = ceilf(tileWidth * m_baseFrequencyX) / tileWidth; - // BaseFrequency should be non-negative according to the standard. - if (m_baseFrequencyX / lowFrequency < highFrequency / m_baseFrequencyX) - m_baseFrequencyX = lowFrequency; - else - m_baseFrequencyX = highFrequency; - } - if (m_baseFrequencyY) { - float lowFrequency = floorf(tileHeight * m_baseFrequencyY) / tileHeight; - float highFrequency = ceilf(tileHeight * m_baseFrequencyY) / tileHeight; - if (m_baseFrequencyY / lowFrequency < highFrequency / m_baseFrequencyY) - m_baseFrequencyY = lowFrequency; - else - m_baseFrequencyY = highFrequency; - } - // Set up TurbulenceInitial stitch values. - paintingData.width = roundf(tileWidth * m_baseFrequencyX); - paintingData.wrapX = s_perlinNoise + paintingData.width; - paintingData.height = roundf(tileHeight * m_baseFrequencyY); - paintingData.wrapY = s_perlinNoise + paintingData.height; - } - float turbulenceFunctionResult = 0; - FloatPoint noiseVector(point.x() * m_baseFrequencyX, point.y() * m_baseFrequencyY); - float ratio = 1; - for (int octave = 0; octave < m_numOctaves; ++octave) { - if (m_type == FETURBULENCE_TYPE_FRACTALNOISE) - turbulenceFunctionResult += noise2D(paintingData, noiseVector) / ratio; - else - turbulenceFunctionResult += fabsf(noise2D(paintingData, noiseVector)) / ratio; - noiseVector.setX(noiseVector.x() * 2); - noiseVector.setY(noiseVector.y() * 2); - ratio *= 2; - if (m_stitchTiles) { - // Update stitch values. Subtracting s_perlinNoiseoise before the multiplication and - // adding it afterward simplifies to subtracting it once. - paintingData.width *= 2; - paintingData.wrapX = 2 * paintingData.wrapX - s_perlinNoise; - paintingData.height *= 2; - paintingData.wrapY = 2 * paintingData.wrapY - s_perlinNoise; - } - } - - // The value of turbulenceFunctionResult comes from ((turbulenceFunctionResult * 255) + 255) / 2 by fractalNoise - // and (turbulenceFunctionResult * 255) by turbulence. - if (m_type == FETURBULENCE_TYPE_FRACTALNOISE) - turbulenceFunctionResult = turbulenceFunctionResult * 0.5f + 0.5f; - // Clamp result - turbulenceFunctionResult = std::max(std::min(turbulenceFunctionResult, 1.f), 0.f); - return static_cast<unsigned char>(turbulenceFunctionResult * 255); -} - -void FETurbulence::apply(Filter* filter) -{ - if (!getEffectContext()) - return; - - IntRect imageRect(IntPoint(), resultImage()->size()); - if (!imageRect.size().width() || !imageRect.size().height()) - return; - - RefPtr<ImageData> imageData = ImageData::create(imageRect.width(), imageRect.height()); - PaintingData paintingData(m_seed, imageRect.size()); - initPaint(paintingData); - - FloatRect filterRegion = filter->filterRegion(); - FloatPoint point; - point.setY(filterRegion.y()); - int indexOfPixelChannel = 0; - for (int y = 0; y < imageRect.height(); ++y) { - point.setY(point.y() + 1); - point.setX(filterRegion.x()); - for (int x = 0; x < imageRect.width(); ++x) { - point.setX(point.x() + 1); - for (paintingData.channel = 0; paintingData.channel < 4; ++paintingData.channel, ++indexOfPixelChannel) - imageData->data()->set(indexOfPixelChannel, calculateTurbulenceValueForPoint(paintingData, point)); - } - } - resultImage()->putUnmultipliedImageData(imageData.get(), imageRect, IntPoint()); -} - -void FETurbulence::dump() -{ -} - -static TextStream& operator<<(TextStream& ts, const TurbulanceType& type) -{ - switch (type) { - case FETURBULENCE_TYPE_UNKNOWN: - ts << "UNKNOWN"; - break; - case FETURBULENCE_TYPE_TURBULENCE: - ts << "TURBULANCE"; - break; - case FETURBULENCE_TYPE_FRACTALNOISE: - ts << "NOISE"; - break; - } - return ts; -} - -TextStream& FETurbulence::externalRepresentation(TextStream& ts, int indent) const -{ - writeIndent(ts, indent); - ts << "[feTurbulence"; - FilterEffect::externalRepresentation(ts); - ts << " type=\"" << type() << "\" " - << "baseFrequency=\"" << baseFrequencyX() << ", " << baseFrequencyY() << "\" " - << "seed=\"" << seed() << "\" " - << "numOctaves=\"" << numOctaves() << "\" " - << "stitchTiles=\"" << stitchTiles() << "\"]\n"; - return ts; -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGFETurbulence.h b/WebCore/svg/graphics/filters/SVGFETurbulence.h deleted file mode 100644 index d27b7f6..0000000 --- a/WebCore/svg/graphics/filters/SVGFETurbulence.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> - * Copyright (C) 2010 Renata Hodovan <reni@inf.u-szeged.hu> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGFETurbulence_h -#define SVGFETurbulence_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "FilterEffect.h" -#include "Filter.h" - -namespace WebCore { - -enum TurbulanceType { - FETURBULENCE_TYPE_UNKNOWN = 0, - FETURBULENCE_TYPE_FRACTALNOISE = 1, - FETURBULENCE_TYPE_TURBULENCE = 2 -}; - -class FETurbulence : public FilterEffect { -public: - static PassRefPtr<FETurbulence> create(TurbulanceType, float, float, int, float, bool); - - TurbulanceType type() const; - void setType(TurbulanceType); - - float baseFrequencyY() const; - void setBaseFrequencyY(float); - - float baseFrequencyX() const; - void setBaseFrequencyX(float); - - float seed() const; - void setSeed(float); - - int numOctaves() const; - void setNumOctaves(bool); - - bool stitchTiles() const; - void setStitchTiles(bool); - - void apply(Filter*); - void dump(); - TextStream& externalRepresentation(TextStream&, int indent) const; - -private: - static const int s_blockSize = 256; - static const int s_blockMask = s_blockSize - 1; - - struct PaintingData { - long seed; - int latticeSelector[2 * s_blockSize + 2]; - float gradient[4][2 * s_blockSize + 2][2]; - int width; // How much to subtract to wrap for stitching. - int height; - int wrapX; // Minimum value to wrap. - int wrapY; - int channel; - IntSize filterSize; - - PaintingData(long paintingSeed, const IntSize& paintingSize); - inline long random(); - }; - - FETurbulence(TurbulanceType, float, float, int, float, bool); - - inline void initPaint(PaintingData&); - float noise2D(PaintingData&, const FloatPoint&); - unsigned char calculateTurbulenceValueForPoint(PaintingData&, const FloatPoint&); - - TurbulanceType m_type; - float m_baseFrequencyX; - float m_baseFrequencyY; - int m_numOctaves; - float m_seed; - bool m_stitchTiles; -}; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGFETurbulence_h diff --git a/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp b/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp index 5a6d0b9..091379e 100644 --- a/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp +++ b/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp @@ -27,15 +27,16 @@ #include "SourceAlpha.h" #include "SourceGraphic.h" -#include <wtf/HashMap.h> #include <wtf/PassRefPtr.h> namespace WebCore { SVGFilterBuilder::SVGFilterBuilder() + : m_lastEffect(0) { m_builtinEffects.add(SourceGraphic::effectName(), SourceGraphic::create()); m_builtinEffects.add(SourceAlpha::effectName(), SourceAlpha::create()); + addBuiltinEffects(); } void SVGFilterBuilder::add(const AtomicString& id, RefPtr<FilterEffect> effect) @@ -67,10 +68,26 @@ FilterEffect* SVGFilterBuilder::getEffectById(const AtomicString& id) const return m_namedEffects.get(id).get(); } +void SVGFilterBuilder::appendEffectToEffectReferences(RefPtr<FilterEffect> effectReference) +{ + // The effect must be a newly created filter effect. + ASSERT(!m_effectReferences.contains(effectReference)); + m_effectReferences.add(effectReference, FilterEffectSet()); + + FilterEffect* effect = effectReference.get(); + unsigned numberOfInputEffects = effect->inputEffects().size(); + + // It is not possible to add the same value to a set twice. + for (unsigned i = 0; i < numberOfInputEffects; ++i) + getEffectReferences(effect->inputEffect(i)).add(effect); +} + void SVGFilterBuilder::clearEffects() { m_lastEffect = 0; m_namedEffects.clear(); + m_effectReferences.clear(); + addBuiltinEffects(); } } // namespace WebCore diff --git a/WebCore/svg/graphics/filters/SVGFilterBuilder.h b/WebCore/svg/graphics/filters/SVGFilterBuilder.h index 4ef6ffe..320088d 100644 --- a/WebCore/svg/graphics/filters/SVGFilterBuilder.h +++ b/WebCore/svg/graphics/filters/SVGFilterBuilder.h @@ -27,6 +27,7 @@ #include "PlatformString.h" #include <wtf/HashMap.h> +#include <wtf/HashSet.h> #include <wtf/PassRefPtr.h> #include <wtf/text/AtomicStringHash.h> @@ -34,6 +35,8 @@ namespace WebCore { class SVGFilterBuilder : public RefCounted<SVGFilterBuilder> { public: + typedef HashSet<FilterEffect*> FilterEffectSet; + static PassRefPtr<SVGFilterBuilder> create() { return adoptRef(new SVGFilterBuilder); } void add(const AtomicString& id, RefPtr<FilterEffect> effect); @@ -41,15 +44,32 @@ namespace WebCore { FilterEffect* getEffectById(const AtomicString& id) const; FilterEffect* lastEffect() const { return m_lastEffect.get(); } - const HashMap<AtomicString, RefPtr<FilterEffect> >& namedEffects() { return m_namedEffects; } + void appendEffectToEffectReferences(RefPtr<FilterEffect>); + + inline FilterEffectSet& getEffectReferences(FilterEffect* effect) + { + // Only allowed for effects belongs to this builder. + ASSERT(m_effectReferences.contains(effect)); + return m_effectReferences.find(effect)->second; + } void clearEffects(); private: SVGFilterBuilder(); + inline void addBuiltinEffects() + { + HashMap<AtomicString, RefPtr<FilterEffect> >::iterator end = m_builtinEffects.end(); + for (HashMap<AtomicString, RefPtr<FilterEffect> >::iterator iterator = m_builtinEffects.begin(); iterator != end; ++iterator) + m_effectReferences.add(iterator->second, FilterEffectSet()); + } + HashMap<AtomicString, RefPtr<FilterEffect> > m_builtinEffects; HashMap<AtomicString, RefPtr<FilterEffect> > m_namedEffects; + // The value is a list, which contains those filter effects, + // which depends on the key filter effect. + HashMap<RefPtr<FilterEffect>, FilterEffectSet> m_effectReferences; RefPtr<FilterEffect> m_lastEffect; }; diff --git a/WebCore/svg/graphics/filters/SVGLightSource.cpp b/WebCore/svg/graphics/filters/SVGLightSource.cpp deleted file mode 100644 index 2981f25..0000000 --- a/WebCore/svg/graphics/filters/SVGLightSource.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGLightSource.h" - -#include "SVGDistantLightSource.h" -#include "SVGPointLightSource.h" -#include "SVGRenderTreeAsText.h" -#include "SVGSpotLightSource.h" -#include <wtf/MathExtras.h> - -namespace WebCore { - -void PointLightSource::initPaintingData(PaintingData&) -{ -} - -void PointLightSource::updatePaintingData(PaintingData& paintingData, int x, int y, float z) -{ - paintingData.lightVector.setX(m_position.x() - x); - paintingData.lightVector.setY(m_position.y() - y); - paintingData.lightVector.setZ(m_position.z() - z); - paintingData.lightVector.normalize(); -} - -// spot-light edge darkening depends on an absolute treshold -// according to the SVG 1.1 SE light regression tests -static const float antiAliasTreshold = 0.016f; - -void SpotLightSource::initPaintingData(PaintingData& paintingData) -{ - paintingData.privateColorVector = paintingData.colorVector; - paintingData.directionVector.setX(m_direction.x() - m_position.x()); - paintingData.directionVector.setY(m_direction.y() - m_position.y()); - paintingData.directionVector.setZ(m_direction.z() - m_position.z()); - paintingData.directionVector.normalize(); - - if (!m_limitingConeAngle) { - paintingData.coneCutOffLimit = 0.0f; - paintingData.coneFullLight = -antiAliasTreshold; - } else { - float limitingConeAngle = m_limitingConeAngle; - if (limitingConeAngle < 0.0f) - limitingConeAngle = -limitingConeAngle; - if (limitingConeAngle > 90.0f) - limitingConeAngle = 90.0f; - paintingData.coneCutOffLimit = cosf(deg2rad(180.0f - limitingConeAngle)); - paintingData.coneFullLight = paintingData.coneCutOffLimit - antiAliasTreshold; - } - - // Optimization for common specularExponent values - if (!m_specularExponent) - paintingData.specularExponent = 0; - else if (m_specularExponent == 1.0f) - paintingData.specularExponent = 1; - else // It is neither 0.0f nor 1.0f - paintingData.specularExponent = 2; -} - -void SpotLightSource::updatePaintingData(PaintingData& paintingData, int x, int y, float z) -{ - paintingData.lightVector.setX(m_position.x() - x); - paintingData.lightVector.setY(m_position.y() - y); - paintingData.lightVector.setZ(m_position.z() - z); - paintingData.lightVector.normalize(); - - float cosineOfAngle = paintingData.lightVector * paintingData.directionVector; - if (cosineOfAngle > paintingData.coneCutOffLimit) { - // No light is produced, scanlines are not updated - paintingData.colorVector.setX(0.0f); - paintingData.colorVector.setY(0.0f); - paintingData.colorVector.setZ(0.0f); - return; - } - - // Set the color of the pixel - float lightStrength; - switch (paintingData.specularExponent) { - case 0: - lightStrength = 1.0f; // -cosineOfAngle ^ 0 == 1 - break; - case 1: - lightStrength = -cosineOfAngle; // -cosineOfAngle ^ 1 == -cosineOfAngle - break; - default: - lightStrength = powf(-cosineOfAngle, m_specularExponent); - break; - } - - if (cosineOfAngle > paintingData.coneFullLight) - lightStrength *= (paintingData.coneCutOffLimit - cosineOfAngle) / (paintingData.coneCutOffLimit - paintingData.coneFullLight); - - if (lightStrength > 1.0f) - lightStrength = 1.0f; - - paintingData.colorVector.setX(paintingData.privateColorVector.x() * lightStrength); - paintingData.colorVector.setY(paintingData.privateColorVector.y() * lightStrength); - paintingData.colorVector.setZ(paintingData.privateColorVector.z() * lightStrength); -} - -void DistantLightSource::initPaintingData(PaintingData& paintingData) -{ - float azimuth = deg2rad(m_azimuth); - float elevation = deg2rad(m_elevation); - paintingData.lightVector.setX(cosf(azimuth) * cosf(elevation)); - paintingData.lightVector.setY(sinf(azimuth) * cosf(elevation)); - paintingData.lightVector.setZ(sinf(elevation)); -} - -void DistantLightSource::updatePaintingData(PaintingData&, int, int, float) -{ -} - -static TextStream& operator<<(TextStream& ts, const FloatPoint3D& p) -{ - ts << "x=" << p.x() << " y=" << p.y() << " z=" << p.z(); - return ts; -} - -TextStream& PointLightSource::externalRepresentation(TextStream& ts) const -{ - ts << "[type=POINT-LIGHT] "; - ts << "[position=\"" << position() << "\"]"; - return ts; -} - -TextStream& SpotLightSource::externalRepresentation(TextStream& ts) const -{ - ts << "[type=SPOT-LIGHT] "; - ts << "[position=\"" << position() << "\"]"; - ts << "[direction=\"" << direction() << "\"]"; - ts << "[specularExponent=\"" << specularExponent() << "\"]"; - ts << "[limitingConeAngle=\"" << limitingConeAngle() << "\"]"; - return ts; -} - -TextStream& DistantLightSource::externalRepresentation(TextStream& ts) const -{ - ts << "[type=DISTANT-LIGHT] "; - ts << "[azimuth=\"" << azimuth() << "\"]"; - ts << "[elevation=\"" << elevation() << "\"]"; - return ts; -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGLightSource.h b/WebCore/svg/graphics/filters/SVGLightSource.h deleted file mode 100644 index 6795107..0000000 --- a/WebCore/svg/graphics/filters/SVGLightSource.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGLightSource_h -#define SVGLightSource_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "FloatPoint3D.h" -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> - -namespace WebCore { - -enum LightType { - LS_DISTANT, - LS_POINT, - LS_SPOT -}; - -class TextStream; - -class LightSource : public RefCounted<LightSource> { -public: - - // Light vectors must be calculated for every pixel during - // painting. It is expensive to pass all these arguments to - // a frequently called function, especially because not all - // light sources require all of them. Instead, we just pass - // a reference to the following structure - struct PaintingData { - // SVGFELighting also use them - FloatPoint3D lightVector; - FloatPoint3D colorVector; - // Private members - FloatPoint3D directionVector; - FloatPoint3D privateColorVector; - float coneCutOffLimit; - float coneFullLight; - int specularExponent; - }; - - LightSource(LightType type) - : m_type(type) - { } - - virtual ~LightSource() { } - - LightType type() const { return m_type; } - virtual TextStream& externalRepresentation(TextStream&) const = 0; - - virtual void initPaintingData(PaintingData&) = 0; - // z is a float number, since it is the alpha value scaled by a user - // specified "surfaceScale" constant, which type is <number> in the SVG standard - virtual void updatePaintingData(PaintingData&, int x, int y, float z) = 0; - -private: - LightType m_type; -}; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGLightSource_h diff --git a/WebCore/svg/graphics/filters/SVGPointLightSource.h b/WebCore/svg/graphics/filters/SVGPointLightSource.h deleted file mode 100644 index cd8f9b2..0000000 --- a/WebCore/svg/graphics/filters/SVGPointLightSource.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGPointLightSource_h -#define SVGPointLightSource_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGLightSource.h" - -namespace WebCore { - -class PointLightSource : public LightSource { -public: - static PassRefPtr<PointLightSource> create(const FloatPoint3D& position) - { - return adoptRef(new PointLightSource(position)); - } - - const FloatPoint3D& position() const { return m_position; } - - virtual void initPaintingData(PaintingData&); - virtual void updatePaintingData(PaintingData&, int x, int y, float z); - - virtual TextStream& externalRepresentation(TextStream&) const; - -private: - PointLightSource(const FloatPoint3D& position) - : LightSource(LS_POINT) - , m_position(position) - { - } - - FloatPoint3D m_position; -}; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGPointLightSource_h diff --git a/WebCore/svg/graphics/filters/SVGSpotLightSource.h b/WebCore/svg/graphics/filters/SVGSpotLightSource.h deleted file mode 100644 index 31c5674..0000000 --- a/WebCore/svg/graphics/filters/SVGSpotLightSource.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> - * Copyright (C) 2005 Eric Seidel <eric@webkit.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SVGSpotLightSource_h -#define SVGSpotLightSource_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGLightSource.h" - -namespace WebCore { - -class SpotLightSource : public LightSource { -public: - static PassRefPtr<SpotLightSource> create(const FloatPoint3D& position, - const FloatPoint3D& direction, float specularExponent, float limitingConeAngle) - { - return adoptRef(new SpotLightSource(position, direction, specularExponent, limitingConeAngle)); - } - - const FloatPoint3D& position() const { return m_position; } - const FloatPoint3D& direction() const { return m_direction; } - - float specularExponent() const { return m_specularExponent; } - float limitingConeAngle() const { return m_limitingConeAngle; } - - virtual void initPaintingData(PaintingData&); - virtual void updatePaintingData(PaintingData&, int x, int y, float z); - - virtual TextStream& externalRepresentation(TextStream&) const; - -private: - SpotLightSource(const FloatPoint3D& position, const FloatPoint3D& direction, - float specularExponent, float limitingConeAngle) - : LightSource(LS_SPOT) - , m_position(position) - , m_direction(direction) - , m_specularExponent(specularExponent) - , m_limitingConeAngle(limitingConeAngle) - { - } - - FloatPoint3D m_position; - FloatPoint3D m_direction; - - float m_specularExponent; - float m_limitingConeAngle; -}; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGSpotLightSource_h |