diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2009-06-15 09:06:43 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-06-15 09:31:31 (GMT) |
commit | c411f16870f112c3407c28c22b617f613a82cff4 (patch) | |
tree | 29a1bcd590c8b31af2aab445bfe8a978dc5bf582 /src/3rdparty/webkit/WebCore/svg/graphics | |
parent | 3d77b56b32a0c53ec0bbfaa07236fedb900ff336 (diff) | |
download | Qt-c411f16870f112c3407c28c22b617f613a82cff4.zip Qt-c411f16870f112c3407c28c22b617f613a82cff4.tar.gz Qt-c411f16870f112c3407c28c22b617f613a82cff4.tar.bz2 |
Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit-4.6-snapshot-15062009 ( 65232bf00dc494ebfd978f998c88f58d18ecce1e )
Diffstat (limited to 'src/3rdparty/webkit/WebCore/svg/graphics')
55 files changed, 753 insertions, 856 deletions
diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp index 45d58ef..2157144 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2006 Eric Seidel (eric@webkit.org) - * Copyright (C) 2008 Apple, Inc. All rights reserved. + * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,8 +35,9 @@ #include "FrameLoader.h" #include "FrameView.h" #include "GraphicsContext.h" +#include "HTMLFormElement.h" +#include "ImageBuffer.h" #include "ImageObserver.h" -#include "NotImplemented.h" #include "Page.h" #include "RenderView.h" #include "ResourceError.h" @@ -46,6 +47,9 @@ #include "SVGSVGElement.h" #include "Settings.h" +// Moving this #include above FrameLoader.h causes the Windows build to fail due to warnings about +// alignment in Timer<FrameLoader>. It seems that the definition of EmptyFrameLoaderClient is what +// causes this (removing that definition fixes the warnings), but it isn't clear why. #include "EmptyClients.h" namespace WebCore { @@ -76,36 +80,33 @@ private: SVGImage::SVGImage(ImageObserver* observer) : Image(observer) - , m_document(0) - , m_chromeClient(0) - , m_page(0) - , m_frame(0) - , m_frameView(0) { } SVGImage::~SVGImage() { - if (m_frame) - m_frame->loader()->frameDetached(); // Break both the loader and view references to the frame + if (m_page) { + m_page->mainFrame()->loader()->frameDetached(); // Break both the loader and view references to the frame + + // Clear explicitly because we want to delete the page before the ChromeClient. + // FIXME: I believe that's already guaranteed by C++ object destruction rules, + // so this may matter only for the assertion below. + m_page.clear(); + } - // Clear these manually so we can safely delete the ChromeClient afterwards - m_frameView.clear(); - m_frame.clear(); - m_page.clear(); - // Verify that page teardown destroyed the Chrome ASSERT(!m_chromeClient->image()); } void SVGImage::setContainerSize(const IntSize& containerSize) { - if (containerSize.width() <= 0 || containerSize.height() <= 0) + if (containerSize.isEmpty()) return; - if (!m_frame || !m_frame->document()) + if (!m_page) return; - SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement(); + Frame* frame = m_page->mainFrame(); + SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement(); if (!rootElement) return; @@ -114,9 +115,10 @@ void SVGImage::setContainerSize(const IntSize& containerSize) bool SVGImage::usesContainerSize() const { - if (!m_frame || !m_frame->document()) + if (!m_page) return false; - SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement(); + Frame* frame = m_page->mainFrame(); + SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement(); if (!rootElement) return false; @@ -125,10 +127,10 @@ bool SVGImage::usesContainerSize() const IntSize SVGImage::size() const { - if (!m_frame || !m_frame->document()) + if (!m_page) return IntSize(); - - SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement(); + Frame* frame = m_page->mainFrame(); + SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement(); if (!rootElement) return IntSize(); @@ -151,9 +153,9 @@ IntSize SVGImage::size() const bool SVGImage::hasRelativeWidth() const { - if (!m_frame || !m_frame->document()) + if (!m_page) return false; - SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement(); + SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_page->mainFrame()->document())->rootElement(); if (!rootElement) return false; @@ -162,9 +164,9 @@ bool SVGImage::hasRelativeWidth() const bool SVGImage::hasRelativeHeight() const { - if (!m_frame || !m_frame->document()) + if (!m_page) return false; - SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement(); + SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_page->mainFrame()->document())->rootElement(); if (!rootElement) return false; @@ -173,22 +175,24 @@ bool SVGImage::hasRelativeHeight() const void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator compositeOp) { - if (!m_frame) + if (!m_page) return; - + + FrameView* view = m_page->mainFrame()->view(); + context->save(); context->setCompositeOperation(compositeOp); context->clip(enclosingIntRect(dstRect)); if (compositeOp != CompositeSourceOver) - context->beginTransparencyLayer(1.0f); + context->beginTransparencyLayer(1); context->translate(dstRect.location().x(), dstRect.location().y()); - context->scale(FloatSize(dstRect.width()/srcRect.width(), dstRect.height()/srcRect.height())); + context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height())); - m_frame->view()->resize(size()); + view->resize(size()); - if (m_frame->view()->needsLayout()) - m_frame->view()->layout(); - m_frame->view()->paint(context, enclosingIntRect(srcRect)); + if (view->needsLayout()) + view->layout(); + view->paint(context, enclosingIntRect(srcRect)); if (compositeOp != CompositeSourceOver) context->endTransparencyLayer(); @@ -205,20 +209,22 @@ NativeImagePtr SVGImage::nativeImageForCurrentFrame() // frame cache, or better yet, not use a cache for tiled drawing at all, instead // having a tiled drawing callback (hopefully non-virtual). if (!m_frameCache) { - m_frameCache.set(ImageBuffer::create(size(), false).release()); + if (!m_page) + return 0; + m_frameCache = ImageBuffer::create(size(), false); if (!m_frameCache) // failed to allocate image return 0; - renderSubtreeToImage(m_frameCache.get(), m_frame->contentRenderer()); + renderSubtreeToImage(m_frameCache.get(), m_page->mainFrame()->contentRenderer()); } return m_frameCache->image()->nativeImageForCurrentFrame(); } bool SVGImage::dataChanged(bool allDataReceived) { - int length = m_data->size(); - if (!length) // if this was an empty image + // Don't do anything if is an empty image. + if (!m_data->size()) return true; - + if (allDataReceived) { static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderClient; static EditorClient* dummyEditorClient = new EmptyEditorClient; @@ -228,28 +234,29 @@ bool SVGImage::dataChanged(bool allDataReceived) m_chromeClient.set(new SVGImageChromeClient(this)); - // FIXME: If this SVG ends up loading itself, we'll leak this Frame (and associated DOM & render trees). - // The Cache code does not know about CachedImages holding Frames and won't know to break the cycle. + // FIXME: If this SVG ends up loading itself, we might leak the world. + // THe comment said that the Cache code does not know about CachedImages + // holding Frames and won't know to break the cycle. But m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient)); m_page->settings()->setJavaScriptEnabled(false); m_page->settings()->setPluginsEnabled(false); - m_frame = Frame::create(m_page.get(), 0, dummyFrameLoaderClient); - m_frameView = new FrameView(m_frame.get()); - m_frameView->deref(); // FIXME: FrameView starts with a refcount of 1 - m_frame->setView(m_frameView.get()); - m_frame->init(); + RefPtr<Frame> frame = Frame::create(m_page.get(), 0, dummyFrameLoaderClient); + frame->setView(FrameView::create(frame.get())); + frame->init(); ResourceRequest fakeRequest(KURL("")); - m_frame->loader()->load(fakeRequest); // Make sure the DocumentLoader is created - m_frame->loader()->cancelContentPolicyCheck(); // cancel any policy checks - m_frame->loader()->commitProvisionalLoad(0); - m_frame->loader()->setResponseMIMEType("image/svg+xml"); - m_frame->loader()->begin(KURL()); // create the empty document - m_frame->loader()->write(m_data->data(), m_data->size()); - m_frame->loader()->end(); - m_frameView->setTransparent(true); // SVG Images are transparent. + FrameLoader* loader = frame->loader(); + loader->load(fakeRequest, false); // Make sure the DocumentLoader is created + loader->cancelContentPolicyCheck(); // cancel any policy checks + loader->commitProvisionalLoad(0); + loader->setResponseMIMEType("image/svg+xml"); + loader->begin(KURL()); // create the empty document + loader->write(m_data->data(), m_data->size()); + loader->end(); + frame->view()->setTransparent(true); // SVG Images are transparent. } - return m_frameView; + + return m_page; } } diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.h b/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.h index 062c0a2..2cea91a 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2006 Eric Seidel (eric@webkit.org) + * Copyright (C) 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,15 +30,10 @@ #if ENABLE(SVG) #include "Image.h" -#include "ImageBuffer.h" -#include "IntSize.h" -#include <wtf/OwnPtr.h> namespace WebCore { - - class SVGDocument; - class Frame; - class FrameView; + + class ImageBuffer; class Page; class SVGImageChromeClient; @@ -72,12 +68,8 @@ namespace WebCore { virtual NativeImagePtr nativeImageForCurrentFrame(); - SVGDocument* m_document; OwnPtr<SVGImageChromeClient> m_chromeClient; OwnPtr<Page> m_page; - RefPtr<Frame> m_frame; - RefPtr<FrameView> m_frameView; - IntSize m_minSize; OwnPtr<ImageBuffer> m_frameCache; }; } diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServer.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServer.cpp index 0240532..0fcd722 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServer.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServer.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> * 2007 Rob Buis <buis@kde.org> + * 2008 Dirk Schulze <krit@webkit.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,6 +37,10 @@ #include "SVGStyledElement.h" #include "SVGURIReference.h" +#if PLATFORM(SKIA) +#include "PlatformContextSkia.h" +#endif + namespace WebCore { SVGPaintServer::SVGPaintServer() @@ -81,7 +86,7 @@ SVGPaintServer* SVGPaintServer::fillPaintServer(const RenderStyle* style, const AtomicString id(SVGURIReference::getTarget(fill->uri())); fillPaintServer = getPaintServerById(item->document(), id); - SVGElement* svgElement = static_cast<SVGElement*>(item->element()); + SVGElement* svgElement = static_cast<SVGElement*>(item->node()); ASSERT(svgElement && svgElement->document() && svgElement->isStyled()); if (item->isRenderPath() && fillPaintServer) @@ -122,7 +127,7 @@ SVGPaintServer* SVGPaintServer::strokePaintServer(const RenderStyle* style, cons AtomicString id(SVGURIReference::getTarget(stroke->uri())); strokePaintServer = getPaintServerById(item->document(), id); - SVGElement* svgElement = static_cast<SVGElement*>(item->element()); + SVGElement* svgElement = static_cast<SVGElement*>(item->node()); ASSERT(svgElement && svgElement->document() && svgElement->isStyled()); if (item->isRenderPath() && strokePaintServer) @@ -158,6 +163,44 @@ void applyStrokeStyleToContext(GraphicsContext* context, RenderStyle* style, con context->setLineDash(dashes, dashOffset); } +void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const +{ + if (!setup(context, path, type)) + return; + + renderPath(context, path, type); + teardown(context, path, type); +} + +void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const +{ + const SVGRenderStyle* style = path ? path->style()->svgStyle() : 0; + + if ((type & ApplyToFillTargetType) && (!style || style->hasFill())) + context->fillPath(); + + if ((type & ApplyToStrokeTargetType) && (!style || style->hasStroke())) + context->strokePath(); +} + +#if PLATFORM(SKIA) +void SVGPaintServer::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const +{ + // FIXME: Move this into the GraphicsContext + // WebKit implicitly expects us to reset the path. + // For example in fillAndStrokePath() of RenderPath.cpp the path is + // added back to the context after filling. This is because internally it + // calls CGContextFillPath() which closes the path. + context->beginPath(); + context->platformContext()->setGradient(0); + context->platformContext()->setPattern(0); +} +#else +void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool) const +{ +} +#endif + DashArray dashArrayFromRenderingStyle(const RenderStyle* style) { DashArray array; diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServer.h b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServer.h index 5722e8b..9174f66 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServer.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServer.h @@ -77,12 +77,6 @@ namespace WebCore { static SVGPaintServerSolid* sharedSolidPaintServer(); protected: -#if PLATFORM(CG) - void strokePath(CGContextRef, const RenderObject*) const; - void fillPath(CGContextRef, const RenderObject*) const; -#endif - - protected: SVGPaintServer(); }; diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerGradient.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerGradient.cpp index ba080ae..9ba224e 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerGradient.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerGradient.cpp @@ -34,22 +34,18 @@ #include "GraphicsContext.h" #include "ImageBuffer.h" #include "RenderObject.h" +#include "RenderView.h" #include "SVGGradientElement.h" #include "SVGPaintServerLinearGradient.h" #include "SVGPaintServerRadialGradient.h" #include "SVGRenderSupport.h" #include "SVGRenderTreeAsText.h" -#if PLATFORM(CG) -#include <wtf/MathExtras.h> -#include <wtf/RetainPtr.h> -#endif - using namespace std; namespace WebCore { -TextStream& operator<<(TextStream& ts, GradientSpreadMethod m) +static TextStream& operator<<(TextStream& ts, GradientSpreadMethod m) { switch (m) { case SpreadMethodPad: @@ -63,7 +59,7 @@ TextStream& operator<<(TextStream& ts, GradientSpreadMethod m) return ts; } -TextStream& operator<<(TextStream& ts, const Vector<SVGGradientStop>& l) +static TextStream& operator<<(TextStream& ts, const Vector<SVGGradientStop>& l) { ts << "["; for (Vector<SVGGradientStop>::const_iterator it = l.begin(); it != l.end(); ++it) { @@ -76,10 +72,8 @@ TextStream& operator<<(TextStream& ts, const Vector<SVGGradientStop>& l) } SVGPaintServerGradient::SVGPaintServerGradient(const SVGGradientElement* owner) - : m_spreadMethod(SpreadMethodPad) - , m_boundingBoxMode(true) + : m_boundingBoxMode(true) , m_ownerElement(owner) - #if PLATFORM(CG) , m_savedContext(0) , m_imageBuffer(0) @@ -102,16 +96,6 @@ void SVGPaintServerGradient::setGradient(PassRefPtr<Gradient> gradient) m_gradient = gradient; } -GradientSpreadMethod SVGPaintServerGradient::spreadMethod() const -{ - return m_spreadMethod; -} - -void SVGPaintServerGradient::setGradientSpreadMethod(const GradientSpreadMethod& method) -{ - m_spreadMethod = method; -} - bool SVGPaintServerGradient::boundingBoxMode() const { return m_boundingBoxMode; @@ -133,8 +117,6 @@ void SVGPaintServerGradient::setGradientTransform(const TransformationMatrix& tr } #if PLATFORM(CG) -// Helper function for text painting in CG -// This Cg specific code should move to GraphicsContext and Font* in a next step. static inline const RenderObject* findTextRootObject(const RenderObject* start) { while (start && !start->isSVGText()) @@ -149,15 +131,15 @@ static inline bool createMaskAndSwapContextForTextGradient( GraphicsContext*& context, GraphicsContext*& savedContext, OwnPtr<ImageBuffer>& imageBuffer, const RenderObject* object) { - FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->relativeBBox(false); + FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->objectBoundingBox(); IntRect maskRect = enclosingIntRect(object->absoluteTransform().mapRect(maskBBox)); IntSize maskSize(maskRect.width(), maskRect.height()); - clampImageBufferSizeToViewport(object->document()->renderer(), maskSize); + clampImageBufferSizeToViewport(object->view()->frameView(), maskSize); - auto_ptr<ImageBuffer> maskImage = ImageBuffer::create(maskSize, false); + OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(maskSize, false); - if (!maskImage.get()) + if (!maskImage) return false; GraphicsContext* maskImageContext = maskImage->context(); @@ -174,18 +156,18 @@ static inline bool createMaskAndSwapContextForTextGradient( return true; } -static inline void clipToTextMask(GraphicsContext* context, +static inline TransformationMatrix clipToTextMask(GraphicsContext* context, OwnPtr<ImageBuffer>& imageBuffer, const RenderObject* object, const SVGPaintServerGradient* gradientServer) { - FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->relativeBBox(false); + FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->objectBoundingBox(); // Fixup transformations to be able to clip to mask TransformationMatrix transform = object->absoluteTransform(); FloatRect textBoundary = transform.mapRect(maskBBox); IntSize maskSize(lroundf(textBoundary.width()), lroundf(textBoundary.height())); - clampImageBufferSizeToViewport(object->document()->renderer(), maskSize); + clampImageBufferSizeToViewport(object->view()->frameView(), maskSize); textBoundary.setSize(textBoundary.size().shrunkTo(maskSize)); // Clip current context to mask image (gradient) @@ -193,11 +175,13 @@ static inline void clipToTextMask(GraphicsContext* context, context->clipToImageBuffer(textBoundary, imageBuffer.get()); context->concatCTM(transform); + TransformationMatrix matrix; if (gradientServer->boundingBoxMode()) { - context->translate(maskBBox.x(), maskBBox.y()); - context->scale(FloatSize(maskBBox.width(), maskBBox.height())); + matrix.translate(maskBBox.x(), maskBBox.y()); + matrix.scaleNonUniform(maskBBox.width(), maskBBox.height()); } - context->concatCTM(gradientServer->gradientTransform()); + matrix.multiply(gradientServer->gradientTransform()); + return matrix; } #endif @@ -234,54 +218,51 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject applyStrokeStyleToContext(context, object->style(), object); } + TransformationMatrix matrix; + // CG platforms will handle the gradient space transform for text in + // teardown, so we don't apply it here. For non-CG platforms, we + // want the text bounding box applied to the gradient space transform now, + // so the gradient shader can use it. +#if PLATFORM(CG) if (boundingBoxMode() && !isPaintingText) { - FloatRect bbox = object->relativeBBox(false); - // Don't use gradientes for 1d objects like horizontal/vertical +#else + if (boundingBoxMode()) { +#endif + FloatRect bbox = object->objectBoundingBox(); + // Don't use gradients for 1d objects like horizontal/vertical // lines or rectangles without width or height. if (bbox.width() == 0 || bbox.height() == 0) { Color color(0, 0, 0); context->setStrokeColor(color); return true; } - context->translate(bbox.x(), bbox.y()); - context->scale(FloatSize(bbox.width(), bbox.height())); - - // With scaling the context, the strokeThickness is scaled too. We have to - // undo this. - float strokeThickness = std::max((context->strokeThickness() / ((bbox.width() + bbox.height()) / 2) - 0.001f), 0.f); - context->setStrokeThickness(strokeThickness); + matrix.translate(bbox.x(), bbox.y()); + matrix.scaleNonUniform(bbox.width(), bbox.height()); } - context->concatCTM(gradientTransform()); - context->setSpreadMethod(spreadMethod()); + matrix.multiply(gradientTransform()); + m_gradient->setGradientSpaceTransform(matrix); return true; } -void SVGPaintServerGradient::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const -{ - const SVGRenderStyle* style = path->style()->svgStyle(); - - if ((type & ApplyToFillTargetType) && style->hasFill()) - context->fillPath(); - - if ((type & ApplyToStrokeTargetType) && style->hasStroke()) - context->strokePath(); -} - void SVGPaintServerGradient::teardown(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType, bool isPaintingText) const { #if PLATFORM(CG) // renderPath() is not used when painting text, so we paint the gradient during teardown() if (isPaintingText && m_savedContext) { + // Restore on-screen drawing context context = m_savedContext; m_savedContext = 0; - clipToTextMask(context, m_imageBuffer, object, this); + TransformationMatrix matrix = clipToTextMask(context, m_imageBuffer, object, this); + m_gradient->setGradientSpaceTransform(matrix); + context->setFillGradient(m_gradient); + + FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->objectBoundingBox(); + + context->fillRect(maskBBox); - // finally fill the text clip with the shading - CGContextDrawShading(context->platformContext(), m_gradient->platformGradient()); - m_imageBuffer.clear(); // we're done with our text mask buffer } #endif @@ -295,8 +276,8 @@ TextStream& SVGPaintServerGradient::externalRepresentation(TextStream& ts) const // abstract, don't stream type ts << "[stops=" << gradientStops() << "]"; - if (spreadMethod() != SpreadMethodPad) - ts << "[method=" << spreadMethod() << "]"; + if (m_gradient->spreadMethod() != SpreadMethodPad) + ts << "[method=" << m_gradient->spreadMethod() << "]"; if (!boundingBoxMode()) ts << " [bounding box mode=" << boundingBoxMode() << "]"; if (!gradientTransform().isIdentity()) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerGradient.h b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerGradient.h index 9f0b714..b24c417 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerGradient.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerGradient.h @@ -52,9 +52,6 @@ namespace WebCore { void setGradient(PassRefPtr<Gradient>); Gradient* gradient() const; - GradientSpreadMethod spreadMethod() const; - void setGradientSpreadMethod(const GradientSpreadMethod&); - // Gradient start and end points are percentages when used in boundingBox mode. // For instance start point with value (0,0) is top-left and end point with // value (100, 100) is bottom-right. BoundingBox mode is enabled by default. @@ -71,7 +68,6 @@ namespace WebCore { virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const; virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const; - virtual void renderPath(GraphicsContext*&, const RenderObject*, SVGPaintTargetType) const; protected: SVGPaintServerGradient(const SVGGradientElement* owner); @@ -79,7 +75,6 @@ namespace WebCore { private: Vector<SVGGradientStop> m_stops; RefPtr<Gradient> m_gradient; - GradientSpreadMethod m_spreadMethod; bool m_boundingBoxMode; TransformationMatrix m_gradientTransform; const SVGGradientElement* m_ownerElement; diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerPattern.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerPattern.cpp index 0eae212..74ea27a 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerPattern.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerPattern.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> + * 2008 Dirk Schulze <krit@webkit.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,9 +29,14 @@ #if ENABLE(SVG) #include "SVGPaintServerPattern.h" +#include "GraphicsContext.h" +#include "Image.h" #include "ImageBuffer.h" +#include "Pattern.h" +#include "RenderObject.h" #include "SVGPatternElement.h" #include "SVGRenderTreeAsText.h" +#include "TransformationMatrix.h" using namespace std; @@ -38,20 +44,13 @@ namespace WebCore { SVGPaintServerPattern::SVGPaintServerPattern(const SVGPatternElement* owner) : m_ownerElement(owner) -#if PLATFORM(CG) - , m_patternSpace(0) , m_pattern(0) -#endif { ASSERT(owner); } SVGPaintServerPattern::~SVGPaintServerPattern() { -#if PLATFORM(CG) - CGPatternRelease(m_pattern); - CGColorSpaceRelease(m_patternSpace); -#endif } FloatRect SVGPaintServerPattern::patternBoundaries() const @@ -69,9 +68,9 @@ ImageBuffer* SVGPaintServerPattern::tile() const return m_tile.get(); } -void SVGPaintServerPattern::setTile(auto_ptr<ImageBuffer> tile) +void SVGPaintServerPattern::setTile(PassOwnPtr<ImageBuffer> tile) { - m_tile.set(tile.release()); + m_tile = tile; } TransformationMatrix SVGPaintServerPattern::patternTransform() const @@ -96,6 +95,89 @@ TextStream& SVGPaintServerPattern::externalRepresentation(TextStream& ts) const return ts; } +bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const +{ + FloatRect targetRect = object->objectBoundingBox(); + + const SVGRenderStyle* style = object->style()->svgStyle(); + bool isFilled = (type & ApplyToFillTargetType) && style->hasFill(); + bool isStroked = (type & ApplyToStrokeTargetType) && style->hasStroke(); + + ASSERT(isFilled && !isStroked || !isFilled && isStroked); + + m_ownerElement->buildPattern(targetRect); + if (!tile()) + return false; + + context->save(); + + ASSERT(!m_pattern); + + IntRect tileRect = tile()->image()->rect(); + if (tileRect.width() > patternBoundaries().width() || tileRect.height() > patternBoundaries().height()) { + // Draw the first cell of the pattern manually to support overflow="visible" on all platforms. + int tileWidth = static_cast<int>(patternBoundaries().width() + 0.5f); + int tileHeight = static_cast<int>(patternBoundaries().height() + 0.5f); + OwnPtr<ImageBuffer> tileImage = ImageBuffer::create(IntSize(tileWidth, tileHeight), false); + + GraphicsContext* tileImageContext = tileImage->context(); + + int numY = static_cast<int>(ceilf(tileRect.height() / tileHeight)) + 1; + int numX = static_cast<int>(ceilf(tileRect.width() / tileWidth)) + 1; + + tileImageContext->save(); + tileImageContext->translate(-patternBoundaries().width() * numX, -patternBoundaries().height() * numY); + for (int i = numY; i > 0; i--) { + tileImageContext->translate(0, patternBoundaries().height()); + for (int j = numX; j > 0; j--) { + tileImageContext->translate(patternBoundaries().width(), 0); + tileImageContext->drawImage(tile()->image(), tileRect, tileRect); + } + tileImageContext->translate(-patternBoundaries().width() * numX, 0); + } + tileImageContext->restore(); + + m_pattern = Pattern::create(tileImage->image(), true, true); + } + else + m_pattern = Pattern::create(tile()->image(), true, true); + + if (isFilled) { + context->setAlpha(style->fillOpacity()); + context->setFillPattern(m_pattern); + context->setFillRule(style->fillRule()); + } + if (isStroked) { + context->setAlpha(style->strokeOpacity()); + context->setStrokePattern(m_pattern); + applyStrokeStyleToContext(context, object->style(), object); + } + + TransformationMatrix matrix; + matrix.translate(patternBoundaries().x(), patternBoundaries().y()); + matrix.multiply(patternTransform()); + m_pattern->setPatternSpaceTransform(matrix); + + if (isPaintingText) { + context->setTextDrawingMode(isFilled ? cTextFill : cTextStroke); +#if PLATFORM(CG) + if (isFilled) + context->applyFillPattern(); + else + context->applyStrokePattern(); +#endif + } + + return true; +} + +void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const +{ + m_pattern = 0; + + context->restore(); +} + } // namespace WebCore #endif diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerPattern.h b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerPattern.h index ee23e5b..253e012 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerPattern.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerPattern.h @@ -30,11 +30,13 @@ #include "TransformationMatrix.h" #include "FloatRect.h" +#include "Pattern.h" #include "SVGPaintServer.h" #include <memory> #include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> namespace WebCore { @@ -55,7 +57,7 @@ namespace WebCore { FloatRect patternBoundaries() const; ImageBuffer* tile() const; - void setTile(std::auto_ptr<ImageBuffer>); + void setTile(PassOwnPtr<ImageBuffer>); TransformationMatrix patternTransform() const; void setPatternTransform(const TransformationMatrix&); @@ -63,9 +65,7 @@ namespace WebCore { virtual TextStream& externalRepresentation(TextStream&) const; virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const; -#if PLATFORM(CG) || PLATFORM(QT) virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const; -#endif private: SVGPaintServerPattern(const SVGPatternElement*); @@ -75,10 +75,7 @@ namespace WebCore { TransformationMatrix m_patternTransform; FloatRect m_patternBoundaries; -#if PLATFORM(CG) - mutable CGColorSpaceRef m_patternSpace; - mutable CGPatternRef m_pattern; -#endif + mutable RefPtr<Pattern> m_pattern; }; } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerSolid.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerSolid.cpp index e862115..b333042 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerSolid.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerSolid.cpp @@ -88,17 +88,6 @@ bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* o return true; } -void SVGPaintServerSolid::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const -{ - const SVGRenderStyle* svgStyle = path ? path->style()->svgStyle() : 0; - - if ((type & ApplyToFillTargetType) && (!svgStyle || svgStyle->hasFill())) - context->fillPath(); - - if ((type & ApplyToStrokeTargetType) && (!svgStyle || svgStyle->hasStroke())) - context->strokePath(); -} - } // namespace WebCore #endif diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerSolid.h b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerSolid.h index 120752c..0166c87 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerSolid.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGPaintServerSolid.h @@ -46,7 +46,6 @@ namespace WebCore { virtual TextStream& externalRepresentation(TextStream&) const; virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const; - virtual void renderPath(GraphicsContext*&, const RenderObject*, SVGPaintTargetType) const; private: SVGPaintServerSolid(); diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceClipper.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceClipper.cpp index 51bda0d..5998afb 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceClipper.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceClipper.cpp @@ -72,7 +72,7 @@ void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& bo if (clipData.bboxUnits) { TransformationMatrix transform; transform.translate(boundingBox.x(), boundingBox.y()); - transform.scale(boundingBox.width(), boundingBox.height()); + transform.scaleNonUniform(boundingBox.width(), boundingBox.height()); clipPath.transform(transform); } context->addPath(clipPath); diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceFilter.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceFilter.cpp index 8fb2dfa..6c1dccb 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceFilter.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceFilter.cpp @@ -2,6 +2,7 @@ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> 2005 Eric Seidel <eric@webkit.org> + 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 @@ -21,64 +22,97 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGResourceFilter.h" +#include "FilterEffect.h" +#include "GraphicsContext.h" +#include "ImageBuffer.h" +#include "PlatformString.h" +#include "SVGFilter.h" +#include "SVGFilterBuilder.h" #include "SVGRenderTreeAsText.h" -#include "SVGFilterEffect.h" +#include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { SVGResourceFilter::SVGResourceFilter() - : m_platformData(createPlatformData()) - , m_filterBBoxMode(false) + : m_filterBBoxMode(false) , m_effectBBoxMode(false) , m_xBBoxMode(false) , m_yBBoxMode(false) + , m_savedContext(0) + , m_sourceGraphicBuffer(0) { + m_filterBuilder.set(new SVGFilterBuilder()); } -void SVGResourceFilter::clearEffects() +void SVGResourceFilter::addFilterEffect(SVGFilterPrimitiveStandardAttributes* effectAttributes, PassRefPtr<FilterEffect> effect) { - m_effects.clear(); + effectAttributes->setStandardAttributes(this, effect.get()); + builder()->add(effectAttributes->result(), effect); } -void SVGResourceFilter::addFilterEffect(SVGFilterEffect* effect) +FloatRect SVGResourceFilter::filterBBoxForItemBBox(const FloatRect& itemBBox) const { - ASSERT(effect); + FloatRect filterBBox = filterRect(); - if (effect) { - ASSERT(effect->filter() == this); - m_effects.append(effect); - } + if (filterBoundingBoxMode()) + filterBBox = FloatRect(itemBBox.x() + filterBBox.x() * itemBBox.width(), + itemBBox.y() + filterBBox.y() * itemBBox.height(), + filterBBox.width() * itemBBox.width(), + filterBBox.height() * itemBBox.height()); + + return filterBBox; } -FloatRect SVGResourceFilter::filterBBoxForItemBBox(const FloatRect& itemBBox) const +void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const FloatRect& itemRect) { - FloatRect filterBBox = filterRect(); + // Draw the content of the current element and it's childs to a imageBuffer to get the SourceGraphic. + // The size of the SourceGraphic must match the size of the element, the filter is aplied to. + IntSize bufferSize = IntSize(itemRect.width(), itemRect.height()); + OwnPtr<ImageBuffer> sourceGraphic(ImageBuffer::create(bufferSize, false)); + + if (!sourceGraphic.get()) + return; + + GraphicsContext* sourceGraphicContext = sourceGraphic->context(); + sourceGraphicContext->translate(-itemRect.x(), -itemRect.y()); + sourceGraphicContext->clearRect(FloatRect(0, 0, itemRect.width(), itemRect.height())); + m_sourceGraphicBuffer.set(sourceGraphic.release()); + m_savedContext = context; + + context = sourceGraphicContext; +} - float xOffset = 0.0f; - float yOffset = 0.0f; +void SVGResourceFilter::applyFilter(GraphicsContext*& context, const FloatRect& itemRect) +{ + if (!m_savedContext) + return; - if (!effectBoundingBoxMode()) { - xOffset = itemBBox.x(); - yOffset = itemBBox.y(); - } + FloatRect filterRect = filterBBoxForItemBBox(itemRect); - if (filterBoundingBoxMode()) { - filterBBox = FloatRect(xOffset + filterBBox.x() * itemBBox.width(), - yOffset + filterBBox.y() * itemBBox.height(), - filterBBox.width() * itemBBox.width(), - filterBBox.height() * itemBBox.height()); - } else { - if (xBoundingBoxMode()) - filterBBox.setX(xOffset + filterBBox.x()); + setFilterBoundingBox(filterRect); + setItemBoundingBox(itemRect); + + context = m_savedContext; + m_savedContext = 0; - if (yBoundingBoxMode()) - filterBBox.setY(yOffset + filterBBox.y()); + FilterEffect* lastEffect = m_filterBuilder->lastEffect(); + + if (lastEffect && !filterRect.isEmpty()) { + RefPtr<Filter> filter = SVGFilter::create(m_itemBBox, m_filterBBox, m_effectBBoxMode, m_filterBBoxMode); + filter->setSourceImage(m_sourceGraphicBuffer->image()); + lastEffect->apply(filter.get()); + + context->clip(filterRect); + + if (lastEffect->resultImage()) + context->drawImage(lastEffect->resultImage()->image(), + lastEffect->subRegion()); } - return filterBBox; + m_sourceGraphicBuffer.clear(); } TextStream& SVGResourceFilter::externalRepresentation(TextStream& ts) const @@ -102,8 +136,6 @@ TextStream& SVGResourceFilter::externalRepresentation(TextStream& ts) const ts << " [bounding box mode=" << filterBoundingBoxMode() << "]"; if (effectBoundingBoxMode()) // default is false ts << " [effect bounding box mode=" << effectBoundingBoxMode() << "]"; - if (m_effects.size() > 0) - ts << " [effects=" << m_effects << "]"; return ts; } diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceFilter.h b/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceFilter.h index 646c732..d081b6b 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceFilter.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceFilter.h @@ -2,6 +2,7 @@ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> 2005 Eric Seidel <eric@webkit.org> + 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 @@ -22,23 +23,25 @@ #ifndef SVGResourceFilter_h #define SVGResourceFilter_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGResource.h" -#include "SVGFilterEffect.h" +#include "Image.h" +#include "ImageBuffer.h" #include "FloatRect.h" +#include "SVGFilterPrimitiveStandardAttributes.h" #include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> +#include <wtf/PassRefPtr.h> namespace WebCore { +class Filter; +class FilterEffect; class GraphicsContext; -class SVGFilterEffect; - -class SVGResourceFilterPlatformData { -public: - virtual ~SVGResourceFilterPlatformData() {} -}; +class SVGFilterBuilder; +class SVGFilterPrimitiveStandardAttributes; class SVGResourceFilter : public SVGResource { public: @@ -61,24 +64,24 @@ public: FloatRect filterRect() const { return m_filterRect; } void setFilterRect(const FloatRect& rect) { m_filterRect = rect; } - FloatRect filterBBoxForItemBBox(const FloatRect& itemBBox) const; + FloatRect filterBoundingBox() { return m_filterBBox; } + void setFilterBoundingBox(const FloatRect& rect) { m_filterBBox = rect; } + + FloatRect itemBoundingBox() { return m_itemBBox; } + void setItemBoundingBox(const FloatRect& rect) { m_itemBBox = rect; } - void clearEffects(); - void addFilterEffect(SVGFilterEffect*); + FloatRect filterBBoxForItemBBox(const FloatRect& itemBBox) const; virtual TextStream& externalRepresentation(TextStream&) const; - // To be implemented in platform specific code. - void prepareFilter(GraphicsContext*&, const FloatRect& bbox); - void applyFilter(GraphicsContext*&, const FloatRect& bbox); - - SVGResourceFilterPlatformData* platformData() { return m_platformData.get(); } - const Vector<SVGFilterEffect*>& effects() { return m_effects; } + void prepareFilter(GraphicsContext*&, const FloatRect&); + void applyFilter(GraphicsContext*&, const FloatRect&); + + void addFilterEffect(SVGFilterPrimitiveStandardAttributes*, PassRefPtr<FilterEffect>); + + SVGFilterBuilder* builder() { return m_filterBuilder.get(); } private: - SVGResourceFilterPlatformData* createPlatformData(); - - OwnPtr<SVGResourceFilterPlatformData> m_platformData; bool m_filterBBoxMode : 1; bool m_effectBBoxMode : 1; @@ -87,7 +90,13 @@ private: bool m_yBBoxMode : 1; FloatRect m_filterRect; - Vector<SVGFilterEffect*> m_effects; + + FloatRect m_filterBBox; + FloatRect m_itemBBox; + + OwnPtr<SVGFilterBuilder> m_filterBuilder; + GraphicsContext* m_savedContext; + OwnPtr<ImageBuffer> m_sourceGraphicBuffer; }; SVGResourceFilter* getFilterById(Document*, const AtomicString&); diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceMarker.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceMarker.cpp index c50f5e3..112e4d6 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceMarker.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceMarker.cpp @@ -82,14 +82,14 @@ void SVGResourceMarker::draw(GraphicsContext* context, const FloatRect& rect, do // the translation performed on the viewport itself. TransformationMatrix viewportTransform; if (m_useStrokeWidth) - viewportTransform.scale(strokeWidth, strokeWidth); + viewportTransform.scaleNonUniform(strokeWidth, strokeWidth); viewportTransform *= m_marker->viewportTransform(); double refX, refY; - viewportTransform.map(m_refX, m_refY, &refX, &refY); + viewportTransform.map(m_refX, m_refY, refX, refY); transform.translate(-refX, -refY); if (m_useStrokeWidth) - transform.scale(strokeWidth, strokeWidth); + transform.scaleNonUniform(strokeWidth, strokeWidth); // FIXME: PaintInfo should be passed into this method instead of being created here // FIXME: bounding box fractions are lost diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceMasker.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceMasker.cpp index 842f04f..3c21350 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceMasker.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGResourceMasker.cpp @@ -28,9 +28,18 @@ #if ENABLE(SVG) #include "SVGResourceMasker.h" +#include "CanvasPixelArray.h" +#include "Image.h" #include "ImageBuffer.h" +#include "ImageData.h" +#include "GraphicsContext.h" +#include "SVGMaskElement.h" +#include "SVGRenderSupport.h" +#include "SVGRenderStyle.h" #include "TextStream.h" +#include <wtf/ByteArray.h> + using namespace std; namespace WebCore { @@ -51,6 +60,44 @@ void SVGResourceMasker::invalidate() m_mask.clear(); } +void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& boundingBox) +{ + if (!m_mask) + m_mask = m_ownerElement->drawMaskerContent(boundingBox, m_maskRect); + + if (!m_mask) + return; + + IntSize imageSize(m_mask->size()); + IntRect intImageRect(0, 0, imageSize.width(), imageSize.height()); + + // Create new ImageBuffer to apply luminance + OwnPtr<ImageBuffer> luminancedImage = ImageBuffer::create(imageSize, false); + if (!luminancedImage) + return; + + PassRefPtr<CanvasPixelArray> srcPixelArray(m_mask->getImageData(intImageRect)->data()); + PassRefPtr<ImageData> destImageData(luminancedImage->getImageData(intImageRect)); + + for (unsigned pixelOffset = 0; pixelOffset < srcPixelArray->length(); pixelOffset++) { + unsigned pixelByteOffset = pixelOffset * 4; + + unsigned char r = 0, g = 0, b = 0, a = 0; + srcPixelArray->get(pixelByteOffset, r); + srcPixelArray->get(pixelByteOffset + 1, g); + srcPixelArray->get(pixelByteOffset + 2, b); + srcPixelArray->get(pixelByteOffset + 3, a); + + double luma = (r * 0.2125 + g * 0.7154 + b * 0.0721) * ((double)a / 255.0); + + destImageData->data()->set(pixelByteOffset + 3, luma); + } + + luminancedImage->putImageData(destImageData.get(), intImageRect, IntPoint(0, 0)); + + context->clipToImageBuffer(m_maskRect, luminancedImage.get()); +} + TextStream& SVGResourceMasker::externalRepresentation(TextStream& ts) const { ts << "[type=MASKER]"; diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGDistantLightSource.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGDistantLightSource.h index 25c2045..07ac16c 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGDistantLightSource.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGDistantLightSource.h @@ -23,7 +23,7 @@ #ifndef SVGDistantLightSource_h #define SVGDistantLightSource_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGLightSource.h" namespace WebCore { @@ -48,6 +48,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGDistantLightSource_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp index 4b82e5a..5197215 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp @@ -21,8 +21,9 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEConvolveMatrix.h" +#include "Filter.h" #include "SVGRenderTreeAsText.h" namespace WebCore { @@ -133,7 +134,7 @@ void FEConvolveMatrix::setPreserveAlpha(bool preserveAlpha) m_preserveAlpha = preserveAlpha; } -void FEConvolveMatrix::apply() +void FEConvolveMatrix::apply(Filter*) { } @@ -174,4 +175,4 @@ TextStream& FEConvolveMatrix::externalRepresentation(TextStream& ts) const }; // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h index c3eea2b..9b3b33f 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h @@ -22,11 +22,11 @@ #ifndef SVGFEConvolveMatrix_h #define SVGFEConvolveMatrix_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "FilterEffect.h" #include "FloatPoint.h" #include "FloatSize.h" - +#include "Filter.h" #include <wtf/Vector.h> namespace WebCore { @@ -68,8 +68,8 @@ namespace WebCore { bool preserveAlpha() const; void setPreserveAlpha(bool); - virtual void apply(); - virtual void dump(); + void apply(Filter*); + void dump(); TextStream& externalRepresentation(TextStream& ts) const; private: @@ -90,6 +90,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGFEConvolveMatrix_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp index 6399c5e..c536478 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp @@ -21,10 +21,11 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGLightSource.h" #include "SVGFEDiffuseLighting.h" #include "SVGRenderTreeAsText.h" +#include "Filter.h" namespace WebCore { @@ -112,7 +113,7 @@ void FEDiffuseLighting::setLightSource(LightSource* lightSource) m_lightSource = lightSource; } -void FEDiffuseLighting::apply() +void FEDiffuseLighting::apply(Filter*) { } @@ -132,4 +133,4 @@ TextStream& FEDiffuseLighting::externalRepresentation(TextStream& ts) const } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h index a817ce2..f4b4dad 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h @@ -22,9 +22,10 @@ #ifndef SVGFEDiffuseLighting_h #define SVGFEDiffuseLighting_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "Color.h" #include "FilterEffect.h" +#include "Filter.h" namespace WebCore { @@ -54,8 +55,8 @@ namespace WebCore { const LightSource* lightSource() const; void setLightSource(LightSource*); - virtual void apply(); - virtual void dump(); + void apply(Filter*); + void dump(); TextStream& externalRepresentation(TextStream& ts) const; private: @@ -73,6 +74,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGFEDiffuseLighting_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp index f7996e3..abb57ee 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp @@ -21,9 +21,10 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEDisplacementMap.h" #include "SVGRenderTreeAsText.h" +#include "Filter.h" namespace WebCore { @@ -74,7 +75,7 @@ void FEDisplacementMap::setScale(float scale) m_scale = scale; } -void FEDisplacementMap::apply() +void FEDisplacementMap::apply(Filter*) { } @@ -113,4 +114,4 @@ TextStream& FEDisplacementMap::externalRepresentation(TextStream& ts) const } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h index 0218d57..1fd6db9 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h @@ -22,9 +22,10 @@ #ifndef SVGFEDisplacementMap_h #define SVGFEDisplacementMap_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "PlatformString.h" #include "FilterEffect.h" +#include "Filter.h" namespace WebCore { @@ -50,8 +51,8 @@ namespace WebCore { float scale() const; void setScale(float scale); - virtual void apply(); - virtual void dump(); + void apply(Filter*); + void dump(); TextStream& externalRepresentation(TextStream& ts) const; private: @@ -67,6 +68,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGFEDisplacementMap_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEFlood.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEFlood.cpp index 3d52f63..9bdb8ca 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEFlood.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEFlood.cpp @@ -21,22 +21,24 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEFlood.h" +#include "Filter.h" #include "SVGRenderTreeAsText.h" namespace WebCore { -FEFlood::FEFlood(const Color& floodColor, const float& floodOpacity) +FEFlood::FEFlood(FilterEffect* in, const Color& floodColor, const float& floodOpacity) : FilterEffect() + , m_in(in) , m_floodColor(floodColor) , m_floodOpacity(floodOpacity) { } -PassRefPtr<FEFlood> FEFlood::create(const Color& floodColor, const float& floodOpacity) +PassRefPtr<FEFlood> FEFlood::create(FilterEffect* in, const Color& floodColor, const float& floodOpacity) { - return adoptRef(new FEFlood(floodColor, floodOpacity)); + return adoptRef(new FEFlood(in, floodColor, floodOpacity)); } Color FEFlood::floodColor() const @@ -59,7 +61,7 @@ void FEFlood::setFloodOpacity(float floodOpacity) m_floodOpacity = floodOpacity; } -void FEFlood::apply() +void FEFlood::apply(Filter*) { } @@ -78,4 +80,4 @@ TextStream& FEFlood::externalRepresentation(TextStream& ts) const } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEFlood.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEFlood.h index 0558774..21985db 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEFlood.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEFlood.h @@ -22,15 +22,16 @@ #ifndef SVGFEFlood_h #define SVGFEFlood_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#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&); + static PassRefPtr<FEFlood> create(FilterEffect*, const Color&, const float&); Color floodColor() const; void setFloodColor(const Color &); @@ -38,19 +39,20 @@ namespace WebCore { float floodOpacity() const; void setFloodOpacity(float); - virtual void apply(); - virtual void dump(); + void apply(Filter*); + void dump(); TextStream& externalRepresentation(TextStream& ts) const; private: - FEFlood(const Color&, const float&); + FEFlood(FilterEffect*, const Color&, const float&); + RefPtr<FilterEffect> m_in; Color m_floodColor; float m_floodOpacity; }; } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGFEFlood_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp index 4e64c58..601c39e 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp @@ -21,9 +21,10 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEGaussianBlur.h" #include "SVGRenderTreeAsText.h" +#include "Filter.h" namespace WebCore { @@ -60,7 +61,7 @@ void FEGaussianBlur::setStdDeviationY(float y) m_y = y; } -void FEGaussianBlur::apply() +void FEGaussianBlur::apply(Filter*) { } @@ -78,4 +79,4 @@ TextStream& FEGaussianBlur::externalRepresentation(TextStream& ts) const } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h index 33ad0c7..a377f89 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h @@ -22,8 +22,9 @@ #ifndef SVGFEGaussianBlur_h #define SVGFEGaussianBlur_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "FilterEffect.h" +#include "Filter.h" namespace WebCore { @@ -37,8 +38,8 @@ namespace WebCore { float stdDeviationY() const; void setStdDeviationY(float); - virtual void apply(); - virtual void dump(); + void apply(Filter*); + void dump(); TextStream& externalRepresentation(TextStream& ts) const; private: @@ -51,6 +52,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGFEGaussianBlur_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEImage.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEImage.cpp index 2bf83be..a01ad3b 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEImage.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEImage.cpp @@ -21,9 +21,10 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEImage.h" #include "SVGRenderTreeAsText.h" +#include "Filter.h" namespace WebCore { @@ -63,7 +64,7 @@ void FEImage::setCachedImage(CachedImage* image) m_cachedImage->addClient(this); } -void FEImage::apply() +void FEImage::apply(Filter*) { } @@ -81,4 +82,4 @@ TextStream& FEImage::externalRepresentation(TextStream& ts) const } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEImage.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEImage.h index fcf413f..3fdc26a 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEImage.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEImage.h @@ -22,11 +22,12 @@ #ifndef SVGFEImage_h #define SVGFEImage_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "CachedImage.h" #include "CachedResourceClient.h" #include "CachedResourceHandle.h" #include "FilterEffect.h" +#include "Filter.h" namespace WebCore { @@ -41,8 +42,8 @@ namespace WebCore { CachedImage* cachedImage() const; void setCachedImage(CachedImage*); - virtual void apply(); - virtual void dump(); + void apply(Filter*); + void dump(); TextStream& externalRepresentation(TextStream& ts) const; private: @@ -53,6 +54,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGFEImage_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMerge.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMerge.cpp index 8ce15a7..7f12c4c 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMerge.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMerge.cpp @@ -21,9 +21,10 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEMerge.h" #include "SVGRenderTreeAsText.h" +#include "Filter.h" namespace WebCore { @@ -48,7 +49,7 @@ void FEMerge::setMergeInputs(const Vector<FilterEffect*>& mergeInputs) m_mergeInputs = mergeInputs; } -void FEMerge::apply() +void FEMerge::apply(Filter*) { } @@ -75,4 +76,4 @@ TextStream& FEMerge::externalRepresentation(TextStream& ts) const } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMerge.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMerge.h index 6415c9f..e41e554 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMerge.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMerge.h @@ -22,9 +22,9 @@ #ifndef SVGFEMerge_h #define SVGFEMerge_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "FilterEffect.h" - +#include "Filter.h" #include <wtf/Vector.h> namespace WebCore { @@ -36,8 +36,8 @@ namespace WebCore { const Vector<FilterEffect*>& mergeInputs() const; void setMergeInputs(const Vector<FilterEffect*>& mergeInputs); - virtual void apply(); - virtual void dump(); + void apply(Filter*); + void dump(); TextStream& externalRepresentation(TextStream& ts) const; private: @@ -48,6 +48,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGFEMerge_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMorphology.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMorphology.cpp index 7838a8c..3767734 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMorphology.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMorphology.cpp @@ -21,9 +21,10 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEMorphology.h" #include "SVGRenderTreeAsText.h" +#include "Filter.h" namespace WebCore { @@ -71,7 +72,7 @@ void FEMorphology::setRadiusY(float radiusY) m_radiusY = radiusY; } -void FEMorphology::apply() +void FEMorphology::apply(Filter*) { } @@ -104,4 +105,4 @@ TextStream& FEMorphology::externalRepresentation(TextStream& ts) const } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMorphology.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMorphology.h index 98ab633..1db8bc4 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMorphology.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEMorphology.h @@ -22,8 +22,9 @@ #ifndef SVGFEMorphology_h #define SVGFEMorphology_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "FilterEffect.h" +#include "Filter.h" namespace WebCore { @@ -45,8 +46,8 @@ namespace WebCore { float radiusY() const; void setRadiusY(float); - virtual void apply(); - virtual void dump(); + void apply(Filter*); + void dump(); TextStream& externalRepresentation(TextStream& ts) const; private: @@ -60,6 +61,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGFEMorphology_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEOffset.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEOffset.cpp index c2a0fc9..63775fb 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEOffset.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEOffset.cpp @@ -21,9 +21,10 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEOffset.h" #include "SVGRenderTreeAsText.h" +#include "Filter.h" namespace WebCore { @@ -60,7 +61,7 @@ void FEOffset::setDy(float dy) m_dy = dy; } -void FEOffset::apply() +void FEOffset::apply(Filter*) { } @@ -78,4 +79,4 @@ TextStream& FEOffset::externalRepresentation(TextStream& ts) const } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEOffset.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEOffset.h index 86128da..93bdde9 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEOffset.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEOffset.h @@ -22,8 +22,9 @@ #ifndef SVGFEOffset_h #define SVGFEOffset_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "FilterEffect.h" +#include "Filter.h" namespace WebCore { @@ -37,8 +38,8 @@ namespace WebCore { float dy() const; void setDy(float); - virtual void apply(); - virtual void dump(); + void apply(Filter*); + void dump(); TextStream& externalRepresentation(TextStream& ts) const; private: @@ -51,6 +52,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGFEOffset_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp index e3446ed..eb0c280 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp @@ -21,9 +21,10 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFESpecularLighting.h" #include "SVGRenderTreeAsText.h" +#include "Filter.h" namespace WebCore { @@ -124,7 +125,7 @@ void FESpecularLighting::setLightSource(LightSource* lightSource) m_lightSource = lightSource; } -void FESpecularLighting::apply() +void FESpecularLighting::apply(Filter*) { } @@ -144,4 +145,4 @@ TextStream& FESpecularLighting::externalRepresentation(TextStream& ts) const } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFESpecularLighting.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFESpecularLighting.h index e1c1930..4efff93 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFESpecularLighting.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFESpecularLighting.h @@ -22,10 +22,11 @@ #ifndef SVGFESpecularLighting_h #define SVGFESpecularLighting_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "Color.h" -#include "SVGLightSource.h" #include "FilterEffect.h" +#include "SVGLightSource.h" +#include "Filter.h" namespace WebCore { @@ -56,8 +57,8 @@ namespace WebCore { const LightSource* lightSource() const; void setLightSource(LightSource*); - virtual void apply(); - virtual void dump(); + void apply(Filter*); + void dump(); TextStream& externalRepresentation(TextStream& ts) const; private: @@ -76,6 +77,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGFESpecularLighting_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETile.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETile.cpp index 773a5cd..fecd105 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETile.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETile.cpp @@ -19,9 +19,10 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFETile.h" #include "SVGRenderTreeAsText.h" +#include "Filter.h" namespace WebCore { @@ -36,7 +37,7 @@ PassRefPtr<FETile> FETile::create(FilterEffect* in) return adoptRef(new FETile(in)); } -void FETile::apply() +void FETile::apply(Filter*) { } @@ -53,5 +54,5 @@ TextStream& FETile::externalRepresentation(TextStream& ts) const } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETile.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETile.h index 986f6fd..f1e8d1a 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETile.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETile.h @@ -22,8 +22,9 @@ #ifndef SVGFETile_h #define SVGFETile_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "FilterEffect.h" +#include "Filter.h" namespace WebCore { @@ -31,8 +32,8 @@ namespace WebCore { public: static PassRefPtr<FETile> create(FilterEffect*); - virtual void apply(); - virtual void dump(); + void apply(Filter*); + void dump(); TextStream& externalRepresentation(TextStream& ts) const; private: @@ -43,6 +44,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGFETile_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETurbulence.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETurbulence.cpp index 9731c49..542c576 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETurbulence.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETurbulence.cpp @@ -21,9 +21,10 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFETurbulence.h" #include "SVGRenderTreeAsText.h" +#include "Filter.h" namespace WebCore { @@ -105,7 +106,7 @@ void FETurbulence::setStitchTiles(bool stitch) m_stitchTiles = stitch; } -void FETurbulence::apply() +void FETurbulence::apply(Filter*) { } @@ -142,4 +143,4 @@ TextStream& FETurbulence::externalRepresentation(TextStream& ts) const } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETurbulence.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETurbulence.h index 6977460..e7f40f6 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETurbulence.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFETurbulence.h @@ -22,8 +22,9 @@ #ifndef SVGFETurbulence_h #define SVGFETurbulence_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "FilterEffect.h" +#include "Filter.h" namespace WebCore { @@ -56,8 +57,8 @@ namespace WebCore { bool stitchTiles() const; void setStitchTiles(bool); - virtual void apply(); - virtual void dump(); + void apply(Filter*); + void dump(); TextStream& externalRepresentation(TextStream& ts) const; private: @@ -74,6 +75,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGFETurbulence_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilter.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilter.cpp new file mode 100644 index 0000000..71c00eb --- /dev/null +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilter.cpp @@ -0,0 +1,47 @@ +/* + * 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 + * aint 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 "SVGFilter.h" + +namespace WebCore { + +SVGFilter::SVGFilter(const FloatRect& itemBox, const FloatRect& filterRect, bool effectBBoxMode, bool filterBBoxMode) + : Filter() + , m_itemBox(itemBox) + , m_filterRect(filterRect) + , m_effectBBoxMode(effectBBoxMode) + , m_filterBBoxMode(filterBBoxMode) +{ +} + +void SVGFilter::calculateEffectSubRegion(FilterEffect*) +{ +} + +PassRefPtr<SVGFilter> SVGFilter::create(const FloatRect& itemBox, const FloatRect& filterRect, bool effectBBoxMode, bool filterBBoxMode) +{ + return adoptRef(new SVGFilter(itemBox, filterRect, effectBBoxMode, filterBBoxMode)); +} + +} // namespace WebCore + +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilter.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilter.h new file mode 100644 index 0000000..95b3414 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilter.h @@ -0,0 +1,53 @@ +/* + * 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 + * aint 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 SVGFilter_h +#define SVGFilter_h + +#if ENABLE(SVG) && ENABLE(FILTERS) +#include "Filter.h" +#include "FilterEffect.h" +#include "FloatRect.h" + +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + + class SVGFilter : public Filter { + public: + static PassRefPtr<SVGFilter> create(const FloatRect&, const FloatRect&, bool, bool); + + void calculateEffectSubRegion(FilterEffect*); + + private: + SVGFilter(const FloatRect& itemBox, const FloatRect& filterRect, bool itemBBoxMode, bool filterBBoxMode); + + FloatRect m_itemBox; + FloatRect m_filterRect; + bool m_effectBBoxMode; + bool m_filterBBoxMode; + }; + +} // namespace WebCore + +#endif // ENABLE(SVG) && ENABLE(FILTERS) + +#endif // SVGFilter_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp new file mode 100644 index 0000000..67668d6 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp @@ -0,0 +1,79 @@ + +/* + * 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 + * aint 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 "SVGFilterBuilder.h" + +#include "FilterEffect.h" +#include "PlatformString.h" +#include "SourceAlpha.h" +#include "SourceGraphic.h" + +#include <wtf/HashMap.h> +#include <wtf/PassRefPtr.h> + +namespace WebCore { + +SVGFilterBuilder::SVGFilterBuilder() +{ + m_builtinEffects.add(SourceGraphic::effectName(), SourceGraphic::create()); + m_builtinEffects.add(SourceAlpha::effectName(), SourceAlpha::create()); +} + +void SVGFilterBuilder::add(const AtomicString& id, RefPtr<FilterEffect> effect) +{ + if (id.isEmpty()) { + m_lastEffect = effect.get(); + return; + } + + if (m_builtinEffects.contains(id)) + return; + + m_lastEffect = effect.get(); + m_namedEffects.set(id, m_lastEffect); +} + +FilterEffect* SVGFilterBuilder::getEffectById(const AtomicString& id) const +{ + if (id.isEmpty()) { + if (m_lastEffect) + return m_lastEffect.get(); + + return m_builtinEffects.get(SourceGraphic::effectName()).get(); + } + + if (m_builtinEffects.contains(id)) + return m_builtinEffects.get(id).get(); + + return m_namedEffects.get(id).get(); +} + +void SVGFilterBuilder::clearEffects() +{ + m_lastEffect = 0; + m_namedEffects.clear(); +} + +} // namespace WebCore + +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilterBuilder.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilterBuilder.h new file mode 100644 index 0000000..55844c9 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilterBuilder.h @@ -0,0 +1,56 @@ +/* + Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> + + 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 SVGFilterBuilder_h +#define SVGFilterBuilder_h + +#include "config.h" + +#if ENABLE(SVG) && ENABLE(FILTERS) +#include "AtomicStringHash.h" +#include "FilterEffect.h" +#include "PlatformString.h" + +#include <wtf/HashMap.h> +#include <wtf/PassRefPtr.h> + +namespace WebCore { + + class SVGFilterBuilder : public RefCounted<SVGFilterBuilder> { + public: + SVGFilterBuilder(); + + void add(const AtomicString& id, RefPtr<FilterEffect> effect); + + FilterEffect* getEffectById(const AtomicString& id) const; + FilterEffect* lastEffect() const { return m_lastEffect.get(); } + + void clearEffects(); + + private: + HashMap<AtomicString, RefPtr<FilterEffect> > m_builtinEffects; + HashMap<AtomicString, RefPtr<FilterEffect> > m_namedEffects; + + RefPtr<FilterEffect> m_lastEffect; + }; + +} //namespace WebCore + +#endif // ENABLE(SVG) && ENABLE(FILTERS) +#endif diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilterEffect.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilterEffect.cpp deleted file mode 100644 index f8e246f..0000000 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilterEffect.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005 Rob Buis <buis@kde.org> - 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 - aint 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(SVG_FILTERS) -#include "SVGFilterEffect.h" - -#include "SVGRenderTreeAsText.h" -#include "SVGResourceFilter.h" - -namespace WebCore { - -SVGFilterEffect::SVGFilterEffect(SVGResourceFilter* filter) - : m_filter(filter) - , m_xBBoxMode(false) - , m_yBBoxMode(false) - , m_widthBBoxMode(false) - , m_heightBBoxMode(false) -{ -} - -FloatRect SVGFilterEffect::primitiveBBoxForFilterBBox(const FloatRect& filterBBox, const FloatRect& itemBBox) const -{ - FloatRect subRegionBBox = subRegion(); - FloatRect useBBox = filterBBox; - - ASSERT(m_filter); - if (!m_filter) - return FloatRect(); - - if (m_filter->effectBoundingBoxMode()) { - if (!m_filter->filterBoundingBoxMode()) - useBBox = itemBBox; - - subRegionBBox = FloatRect(useBBox.x() + subRegionBBox.x() * useBBox.width(), - useBBox.y() + subRegionBBox.y() * useBBox.height(), - subRegionBBox.width() * useBBox.width(), - subRegionBBox.height() * useBBox.height()); - } else { - if (xBoundingBoxMode()) - subRegionBBox.setX(useBBox.x() + subRegionBBox.x() * useBBox.width()); - - if (yBoundingBoxMode()) - subRegionBBox.setY(useBBox.y() + subRegionBBox.y() * useBBox.height()); - - if (widthBoundingBoxMode()) - subRegionBBox.setWidth(subRegionBBox.width() * useBBox.width()); - - if (heightBoundingBoxMode()) - subRegionBBox.setHeight(subRegionBBox.height() * useBBox.height()); - } - - return subRegionBBox; -} - -FloatRect SVGFilterEffect::subRegion() const -{ - return m_subRegion; -} - -void SVGFilterEffect::setSubRegion(const FloatRect& subRegion) -{ - m_subRegion = subRegion; -} - -String SVGFilterEffect::in() const -{ - return m_in; -} - -void SVGFilterEffect::setIn(const String& in) -{ - m_in = in; -} - -String SVGFilterEffect::result() const -{ - return m_result; -} - -void SVGFilterEffect::setResult(const String& result) -{ - m_result = result; -} - -SVGResourceFilter* SVGFilterEffect::filter() const -{ - return m_filter; -} - -void SVGFilterEffect::setFilter(SVGResourceFilter* filter) -{ - m_filter = filter; -} - -TextStream& SVGFilterEffect::externalRepresentation(TextStream& ts) const -{ - if (!in().isEmpty()) - ts << "[in=\"" << in() << "\"]"; - if (!result().isEmpty()) - ts << " [result=\"" << result() << "\"]"; - if (!subRegion().isEmpty()) - ts << " [subregion=\"" << subRegion() << "\"]"; - return ts; -} - -TextStream& operator<<(TextStream& ts, const SVGFilterEffect& e) -{ - return e.externalRepresentation(ts); -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilterEffect.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilterEffect.h deleted file mode 100644 index d497f8b..0000000 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFilterEffect.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005 Rob Buis <buis@kde.org> - 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 - aint 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 SVGFilterEffect_h -#define SVGFilterEffect_h - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) -#include "FloatRect.h" -#include "PlatformString.h" - -#if PLATFORM(CI) -#ifdef __OBJC__ -@class CIFilter; -#else -class CIFilter; -#endif -#endif - -namespace WebCore { - -class SVGResourceFilter; -class TextStream; - -class SVGFilterEffect : public RefCounted<SVGFilterEffect> { -public: - SVGFilterEffect(SVGResourceFilter*); - virtual ~SVGFilterEffect() { } - - bool xBoundingBoxMode() const { return m_xBBoxMode; } - void setXBoundingBoxMode(bool bboxMode) { m_xBBoxMode = bboxMode; } - - bool yBoundingBoxMode() const { return m_yBBoxMode; } - void setYBoundingBoxMode(bool bboxMode) { m_yBBoxMode = bboxMode; } - - bool widthBoundingBoxMode() const { return m_widthBBoxMode; } - void setWidthBoundingBoxMode(bool bboxMode) { m_widthBBoxMode = bboxMode; } - - bool heightBoundingBoxMode() const { return m_heightBBoxMode; } - void setHeightBoundingBoxMode(bool bboxMode) { m_heightBBoxMode = bboxMode; } - - FloatRect primitiveBBoxForFilterBBox(const FloatRect& filterBBox, const FloatRect& itemBBox) const; - - FloatRect subRegion() const; - void setSubRegion(const FloatRect&); - - String in() const; - void setIn(const String&); - - String result() const; - void setResult(const String&); - - SVGResourceFilter* filter() const; - void setFilter(SVGResourceFilter*); - - virtual TextStream& externalRepresentation(TextStream&) const; - -#if PLATFORM(CI) - virtual CIFilter* getCIFilter(const FloatRect& bbox) const; -#endif - -private: - SVGResourceFilter* m_filter; - - bool m_xBBoxMode : 1; - bool m_yBBoxMode : 1; - bool m_widthBBoxMode : 1; - bool m_heightBBoxMode : 1; - - FloatRect m_subRegion; - - String m_in; - String m_result; -}; - -TextStream& operator<<(TextStream&, const SVGFilterEffect&); - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) - -#endif // SVGFilterEffect_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGLightSource.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGLightSource.cpp index 77611ca..9176b4c 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGLightSource.cpp +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGLightSource.cpp @@ -21,7 +21,7 @@ #include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGPointLightSource.h" #include "SVGRenderTreeAsText.h" #include "SVGSpotLightSource.h" @@ -62,4 +62,4 @@ TextStream& DistantLightSource::externalRepresentation(TextStream& ts) const } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGLightSource.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGLightSource.h index 779e147..22b43c8 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGLightSource.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGLightSource.h @@ -23,7 +23,7 @@ #ifndef SVGLightSource_h #define SVGLightSource_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include <wtf/RefCounted.h> namespace WebCore { @@ -53,6 +53,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGLightSource_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGPointLightSource.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGPointLightSource.h index 099a165..772e278 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGPointLightSource.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGPointLightSource.h @@ -23,7 +23,7 @@ #ifndef SVGPointLightSource_h #define SVGPointLightSource_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "FloatPoint3D.h" #include "SVGLightSource.h" @@ -46,6 +46,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGPointLightSource_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGSpotLightSource.h b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGSpotLightSource.h index a4aa1fb..9a787fb 100644 --- a/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGSpotLightSource.h +++ b/src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGSpotLightSource.h @@ -23,7 +23,7 @@ #ifndef SVGSpotLightSource_h #define SVGSpotLightSource_h -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) +#if ENABLE(SVG) && ENABLE(FILTERS) #include "FloatPoint3D.h" #include "SVGLightSource.h" @@ -57,6 +57,6 @@ namespace WebCore { } // namespace WebCore -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif // SVGSpotLightSource_h diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/qt/RenderPathQt.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/qt/RenderPathQt.cpp deleted file mode 100644 index 6bc2682..0000000 --- a/src/3rdparty/webkit/WebCore/svg/graphics/qt/RenderPathQt.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org> - 2004, 2005, 2006 Rob Buis <buis@kde.org> - 2005 Eric Seidel <eric.seidel@kdemail.net> - - This file is part of the KDE project - - 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 - aint 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" -#include "RenderPath.h" -#include "SVGRenderStyle.h" -#include "SVGPaintServer.h" - -#include <QDebug> -#include <QPainterPathStroker> - -namespace WebCore { - -bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const -{ - if (path().isEmpty()) - return false; - - if (requiresStroke && !SVGPaintServer::strokePaintServer(style(), this)) - return false; - - return false; -} - -} - -// vim:ts=4:noet diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp deleted file mode 100644 index 8ae5a1a..0000000 --- a/src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> - Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de> - - 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 - aint 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) -#include "SVGPaintServerPattern.h" - -#include "TransformationMatrix.h" -#include "GraphicsContext.h" -#include "ImageBuffer.h" -#include "Pattern.h" -#include "RenderObject.h" -#include "SVGPatternElement.h" - -#include <QPainter> -#include <QPainterPath> - -namespace WebCore { - -bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const -{ - Q_ASSERT(context); - Q_ASSERT(object); - - FloatRect targetRect = object->relativeBBox(false); - m_ownerElement->buildPattern(targetRect); - - if (!tile()) - return false; - - QPainter* painter = context->platformContext(); - QPainterPath* path = context->currentPath(); - - RenderStyle* style = object->style(); - const SVGRenderStyle* svgStyle = object->style()->svgStyle(); - - RefPtr<Pattern> pattern = Pattern::create(tile()->image(), true, true); - - context->save(); - painter->setPen(Qt::NoPen); - painter->setBrush(Qt::NoBrush); - - TransformationMatrix affine; - affine.translate(patternBoundaries().x(), patternBoundaries().y()); - affine.multiply(patternTransform()); - - QBrush brush(pattern->createPlatformPattern(affine)); - if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) { - painter->setBrush(brush); - context->setFillRule(svgStyle->fillRule()); - } - - if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) { - QPen pen; - pen.setBrush(brush); - painter->setPen(pen); - applyStrokeStyleToContext(context, style, object); - } - - return true; -} - -void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const -{ - context->restore(); -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp deleted file mode 100644 index 801201b..0000000 --- a/src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> - Copyright (C) 2008 Holger Hans Peter Freyther - - This file is part of the KDE project - - 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 - aint 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) -#include "SVGPaintServer.h" - -#include "GraphicsContext.h" -#include "SVGRenderStyle.h" -#include "RenderObject.h" - -#include <QPainter> -#include <QVector> - -namespace WebCore { - -void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const -{ - if (!setup(context, path, type)) - return; - - renderPath(context, path, type); - teardown(context, path, type); -} - -void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const -{ - // no-op -} - -void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const -{ - RenderStyle* renderStyle = path ? path->style(): 0; - - QPainter* painter(context ? context->platformContext() : 0); - Q_ASSERT(painter); - - QPainterPath* painterPath(context ? context->currentPath() : 0); - Q_ASSERT(painterPath); - - if ((type & ApplyToFillTargetType) && (!renderStyle || renderStyle->svgStyle()->hasFill())) - painter->fillPath(*painterPath, painter->brush()); - - if ((type & ApplyToStrokeTargetType) && (!renderStyle || renderStyle->svgStyle()->hasStroke())) - painter->strokePath(*painterPath, painter->pen()); -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp deleted file mode 100644 index cbf90cd..0000000 --- a/src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> - - This file is part of the KDE project - - 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 - aint 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(SVG_FILTERS) -#include "SVGResourceFilter.h" -#include "NotImplemented.h" - -namespace WebCore { - -SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData() -{ - notImplemented(); - return 0; -} - -void SVGResourceFilter::prepareFilter(GraphicsContext*&, const FloatRect&) -{ - notImplemented(); -} - -void SVGResourceFilter::applyFilter(GraphicsContext*&, const FloatRect&) -{ - notImplemented(); -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGResourceMaskerQt.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGResourceMaskerQt.cpp deleted file mode 100644 index 2b89bac..0000000 --- a/src/3rdparty/webkit/WebCore/svg/graphics/qt/SVGResourceMaskerQt.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> - - This file is part of the KDE project - - 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 - aint 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) -#include "SVGResourceMasker.h" - -namespace WebCore { - -void SVGResourceMasker::applyMask(GraphicsContext*, const FloatRect&) -{ - // FIXME: implement me :-) -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet |