summaryrefslogtreecommitdiffstats
path: root/WebCore/svg/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/svg/graphics')
-rw-r--r--WebCore/svg/graphics/SVGImage.cpp64
-rw-r--r--WebCore/svg/graphics/SVGImage.h11
-rw-r--r--WebCore/svg/graphics/SVGImageEmptyClients.h418
-rw-r--r--WebCore/svg/graphics/SVGPaintServer.cpp21
-rw-r--r--WebCore/svg/graphics/SVGPaintServer.h18
-rw-r--r--WebCore/svg/graphics/SVGPaintServerGradient.cpp16
-rw-r--r--WebCore/svg/graphics/SVGPaintServerGradient.h28
-rw-r--r--WebCore/svg/graphics/SVGPaintServerLinearGradient.h4
-rw-r--r--WebCore/svg/graphics/SVGPaintServerPattern.h13
-rw-r--r--WebCore/svg/graphics/SVGPaintServerRadialGradient.h4
-rw-r--r--WebCore/svg/graphics/SVGPaintServerSolid.h6
-rw-r--r--WebCore/svg/graphics/SVGResource.h4
-rw-r--r--WebCore/svg/graphics/SVGResourceClipper.cpp1
-rw-r--r--WebCore/svg/graphics/SVGResourceClipper.h3
-rw-r--r--WebCore/svg/graphics/SVGResourceFilter.cpp1
-rw-r--r--WebCore/svg/graphics/SVGResourceMarker.h3
-rw-r--r--WebCore/svg/graphics/SVGResourceMasker.h5
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp89
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp50
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp31
-rw-r--r--WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp26
-rw-r--r--WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp6
-rw-r--r--WebCore/svg/graphics/cg/CgSupport.cpp22
-rw-r--r--WebCore/svg/graphics/cg/CgSupport.h4
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp15
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp6
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp27
-rw-r--r--WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp23
-rw-r--r--WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm10
-rw-r--r--WebCore/svg/graphics/filters/SVGDistantLightSource.h31
-rw-r--r--WebCore/svg/graphics/filters/SVGFEBlend.cpp88
-rw-r--r--WebCore/svg/graphics/filters/SVGFEBlend.h64
-rw-r--r--WebCore/svg/graphics/filters/SVGFEColorMatrix.cpp84
-rw-r--r--WebCore/svg/graphics/filters/SVGFEColorMatrix.h64
-rw-r--r--WebCore/svg/graphics/filters/SVGFEComponentTransfer.cpp142
-rw-r--r--WebCore/svg/graphics/filters/SVGFEComponentTransfer.h110
-rw-r--r--WebCore/svg/graphics/filters/SVGFEComposite.cpp112
-rw-r--r--WebCore/svg/graphics/filters/SVGFEComposite.h81
-rw-r--r--WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp102
-rw-r--r--WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h109
-rw-r--r--WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp73
-rw-r--r--WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h65
-rw-r--r--WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp66
-rw-r--r--WebCore/svg/graphics/filters/SVGFEDisplacementMap.h75
-rw-r--r--WebCore/svg/graphics/filters/SVGFEFlood.cpp35
-rw-r--r--WebCore/svg/graphics/filters/SVGFEFlood.h32
-rw-r--r--WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp36
-rw-r--r--WebCore/svg/graphics/filters/SVGFEGaussianBlur.h33
-rw-r--r--WebCore/svg/graphics/filters/SVGFEImage.cpp46
-rw-r--r--WebCore/svg/graphics/filters/SVGFEImage.h45
-rw-r--r--WebCore/svg/graphics/filters/SVGFEMerge.cpp29
-rw-r--r--WebCore/svg/graphics/filters/SVGFEMerge.h30
-rw-r--r--WebCore/svg/graphics/filters/SVGFEMorphology.cpp58
-rw-r--r--WebCore/svg/graphics/filters/SVGFEMorphology.h58
-rw-r--r--WebCore/svg/graphics/filters/SVGFEOffset.cpp39
-rw-r--r--WebCore/svg/graphics/filters/SVGFEOffset.h33
-rw-r--r--WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp81
-rw-r--r--WebCore/svg/graphics/filters/SVGFESpecularLighting.h67
-rw-r--r--WebCore/svg/graphics/filters/SVGFETile.cpp (renamed from WebCore/svg/graphics/filters/cg/SVGFETileCg.mm)34
-rw-r--r--WebCore/svg/graphics/filters/SVGFETile.h26
-rw-r--r--WebCore/svg/graphics/filters/SVGFETurbulence.cpp71
-rw-r--r--WebCore/svg/graphics/filters/SVGFETurbulence.h66
-rw-r--r--WebCore/svg/graphics/filters/SVGFilterEffect.cpp1
-rw-r--r--WebCore/svg/graphics/filters/SVGFilterEffect.h2
-rw-r--r--WebCore/svg/graphics/filters/SVGLightSource.cpp6
-rw-r--r--WebCore/svg/graphics/filters/SVGLightSource.h39
-rw-r--r--WebCore/svg/graphics/filters/SVGPointLightSource.h25
-rw-r--r--WebCore/svg/graphics/filters/SVGSpotLightSource.h43
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEBlendCg.mm77
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEColorMatrixCg.mm111
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEComponentTransferCg.mm167
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFECompositeCg.mm85
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEDiffuseLightingCg.mm74
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEDisplacementMapCg.mm58
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEFloodCg.mm54
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEGaussianBlurCg.mm49
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h6
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm20
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEImageCg.mm80
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEMergeCg.mm57
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFEOffsetCg.mm44
-rw-r--r--WebCore/svg/graphics/filters/cg/SVGFESpecularLightingCg.mm69
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp18
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp69
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerQt.cpp40
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp21
-rw-r--r--WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp8
87 files changed, 1222 insertions, 3015 deletions
diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp
index c8d5cb1..4427277 100644
--- a/WebCore/svg/graphics/SVGImage.cpp
+++ b/WebCore/svg/graphics/SVGImage.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Eric Seidel (eric@webkit.org)
+ * Copyright (C) 2008 Apple, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,10 +26,10 @@
#include "config.h"
#if ENABLE(SVG)
+#include "SVGImage.h"
#include "CachedPage.h"
#include "DocumentLoader.h"
-#include "EditCommand.h"
#include "FloatRect.h"
#include "Frame.h"
#include "FrameLoader.h"
@@ -37,15 +38,15 @@
#include "ImageObserver.h"
#include "NotImplemented.h"
#include "Page.h"
+#include "RenderView.h"
#include "ResourceError.h"
#include "SVGDocument.h"
-#include "SVGImage.h"
#include "SVGLength.h"
#include "SVGRenderSupport.h"
#include "SVGSVGElement.h"
#include "Settings.h"
-#include "SVGImageEmptyClients.h"
+#include "EmptyClients.h"
namespace WebCore {
@@ -69,6 +70,8 @@ void SVGImage::setContainerSize(const IntSize& containerSize)
if (containerSize.width() <= 0 || containerSize.height() <= 0)
return;
+ if (!m_frame || !m_frame->document())
+ return;
SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
if (!rootElement)
return;
@@ -78,6 +81,8 @@ void SVGImage::setContainerSize(const IntSize& containerSize)
bool SVGImage::usesContainerSize() const
{
+ if (!m_frame || !m_frame->document())
+ return false;
SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
if (!rootElement)
return false;
@@ -101,18 +106,20 @@ IntSize SVGImage::size() const
if (width.unitType() == LengthTypePercentage)
svgSize.setWidth(rootElement->relativeWidthValue());
else
- svgSize.setWidth(static_cast<int>(width.value()));
+ svgSize.setWidth(static_cast<int>(width.value(rootElement)));
if (height.unitType() == LengthTypePercentage)
svgSize.setHeight(rootElement->relativeHeightValue());
else
- svgSize.setHeight(static_cast<int>(height.value()));
+ svgSize.setHeight(static_cast<int>(height.value(rootElement)));
return svgSize;
}
bool SVGImage::hasRelativeWidth() const
{
+ if (!m_frame || !m_frame->document())
+ return false;
SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
if (!rootElement)
return false;
@@ -122,6 +129,8 @@ bool SVGImage::hasRelativeWidth() const
bool SVGImage::hasRelativeHeight() const
{
+ if (!m_frame || !m_frame->document())
+ return false;
SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
if (!rootElement)
return false;
@@ -135,10 +144,20 @@ void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
return;
context->save();
+ context->setCompositeOperation(compositeOp);
context->clip(enclosingIntRect(dstRect));
+ if (compositeOp != CompositeSourceOver)
+ context->beginTransparencyLayer(1.0f);
context->translate(dstRect.location().x(), dstRect.location().y());
context->scale(FloatSize(dstRect.width()/srcRect.width(), dstRect.height()/srcRect.height()));
- m_frame->paint(context, enclosingIntRect(srcRect));
+
+ if (m_frame->view()->needsLayout())
+ m_frame->view()->layout();
+ m_frame->view()->paint(context, enclosingIntRect(srcRect));
+
+ if (compositeOp != CompositeSourceOver)
+ context->endTransparencyLayer();
+
context->restore();
if (imageObserver())
@@ -154,18 +173,9 @@ NativeImagePtr SVGImage::nativeImageForCurrentFrame()
m_frameCache.set(ImageBuffer::create(size(), false).release());
if (!m_frameCache) // failed to allocate image
return 0;
- renderSubtreeToImage(m_frameCache.get(), m_frame->renderer());
+ renderSubtreeToImage(m_frameCache.get(), m_frame->contentRenderer());
}
-#if PLATFORM(CG)
- return m_frameCache->cgImage();
-#elif PLATFORM(QT)
- return m_frameCache->pixmap();
-#elif PLATFORM(CAIRO)
- return m_frameCache->surface();
-#else
- notImplemented();
- return 0;
-#endif
+ return m_frameCache->image()->nativeImageForCurrentFrame();
}
bool SVGImage::dataChanged(bool allDataReceived)
@@ -175,31 +185,33 @@ bool SVGImage::dataChanged(bool allDataReceived)
return true;
if (allDataReceived) {
- static ChromeClient* dummyChromeClient = new SVGEmptyChromeClient;
- static FrameLoaderClient* dummyFrameLoaderClient = new SVGEmptyFrameLoaderClient;
- static EditorClient* dummyEditorClient = new SVGEmptyEditorClient;
- static ContextMenuClient* dummyContextMenuClient = new SVGEmptyContextMenuClient;
- static DragClient* dummyDragClient = new SVGEmptyDragClient;
- static InspectorClient* dummyInspectorClient = new SVGEmptyInspectorClient;
+ static ChromeClient* dummyChromeClient = new EmptyChromeClient;
+ static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderClient;
+ static EditorClient* dummyEditorClient = new EmptyEditorClient;
+ static ContextMenuClient* dummyContextMenuClient = new EmptyContextMenuClient;
+ static DragClient* dummyDragClient = new EmptyDragClient;
+ static InspectorClient* dummyInspectorClient = new EmptyInspectorClient;
// 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.
m_page.set(new Page(dummyChromeClient, dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient));
m_page->settings()->setJavaScriptEnabled(false);
+ m_page->settings()->setPluginsEnabled(false);
- m_frame = new Frame(m_page.get(), 0, dummyFrameLoaderClient);
- m_frame->init();
+ 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();
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("placeholder.svg"); // create the empty document
+ 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.
}
return m_frameView;
}
diff --git a/WebCore/svg/graphics/SVGImage.h b/WebCore/svg/graphics/SVGImage.h
index 3e67a7c..994cf91 100644
--- a/WebCore/svg/graphics/SVGImage.h
+++ b/WebCore/svg/graphics/SVGImage.h
@@ -42,7 +42,10 @@ namespace WebCore {
class SVGImage : public Image {
public:
- SVGImage(ImageObserver*);
+ static PassRefPtr<SVGImage> create(ImageObserver* observer)
+ {
+ return adoptRef(new SVGImage(observer));
+ }
~SVGImage();
virtual void setContainerSize(const IntSize&);
@@ -54,9 +57,15 @@ namespace WebCore {
virtual bool dataChanged(bool allDataReceived);
+ // FIXME: SVGImages are underreporting decoded sizes and will be unable
+ // to prune because these functions are not implemented yet.
+ virtual void destroyDecodedData(bool incremental = false, bool preserveNearbyFrames = false) { }
+ virtual unsigned decodedSize() const { return 0; }
+
virtual NativeImagePtr frameAtIndex(size_t) { return 0; }
private:
+ SVGImage(ImageObserver*);
virtual void draw(GraphicsContext*, const FloatRect& fromRect, const FloatRect& toRect, CompositeOperator);
virtual NativeImagePtr nativeImageForCurrentFrame();
diff --git a/WebCore/svg/graphics/SVGImageEmptyClients.h b/WebCore/svg/graphics/SVGImageEmptyClients.h
deleted file mode 100644
index efaaa47..0000000
--- a/WebCore/svg/graphics/SVGImageEmptyClients.h
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * Copyright (C) 2006 Eric Seidel (eric@webkit.org)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SVGImageEmptyClients_h
-#define SVGImageEmptyClients_h
-
-#if ENABLE(SVG)
-
-#include "ChromeClient.h"
-#include "ContextMenuClient.h"
-#include "DragClient.h"
-#include "EditorClient.h"
-#include "FocusDirection.h"
-#include "FrameLoaderClient.h"
-#include "InspectorClient.h"
-#include "SharedBuffer.h"
-
-/*
- This file holds empty Client stubs for use by SVGImage.
- SVGImage needs to create a dummy Page->Frame->FrameView tree for use in parsing an SVGDocument.
- This tree depends heavily on Clients (usually provided by WebKit classes).
-
- SVGImage has no way to access the current Page (nor should it, since Images are not tied to a page).
- See http://bugs.webkit.org/show_bug.cgi?id=5971 for more discussion on this issue.
-
- Ideally, whenever you change a Client class, you should add a stub here.
- Brittle, yes. Unfortunate, yes. Hopefully temporary.
-*/
-
-namespace WebCore {
-
-class SVGEmptyChromeClient : public ChromeClient {
-public:
- virtual ~SVGEmptyChromeClient() { }
- virtual void chromeDestroyed() { }
-
- virtual void setWindowRect(const FloatRect&) { }
- virtual FloatRect windowRect() { return FloatRect(); }
-
- virtual FloatRect pageRect() { return FloatRect(); }
-
- virtual float scaleFactor() { return 1.f; }
-
- virtual void focus() { }
- virtual void unfocus() { }
-
- virtual bool canTakeFocus(FocusDirection) { return false; }
- virtual void takeFocus(FocusDirection) { }
-
- virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&) { return 0; }
- virtual void show() { }
-
- virtual bool canRunModal() { return false; }
- virtual void runModal() { }
-
- virtual void setToolbarsVisible(bool) { }
- virtual bool toolbarsVisible() { return false; }
-
- virtual void setStatusbarVisible(bool) { }
- virtual bool statusbarVisible() { return false; }
-
- virtual void setScrollbarsVisible(bool) { }
- virtual bool scrollbarsVisible() { return false; }
-
- virtual void setMenubarVisible(bool) { }
- virtual bool menubarVisible() { return false; }
-
- virtual void setResizable(bool) { }
-
- virtual void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID) { }
-
- virtual bool canRunBeforeUnloadConfirmPanel() { return false; }
- virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame) { return true; }
-
- virtual void closeWindowSoon() { }
-
- virtual void runJavaScriptAlert(Frame*, const String&) { }
- virtual bool runJavaScriptConfirm(Frame*, const String&) { return false; }
- virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result) { return false; }
- virtual bool shouldInterruptJavaScript() { return false; }
-
- virtual void setStatusbarText(const String&) { }
-
- virtual bool tabsToLinks() const { return false; }
-
- virtual IntRect windowResizerRect() const { return IntRect(); }
- virtual void addToDirtyRegion(const IntRect&) { }
- virtual void scrollBackingStore(int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect) { }
- virtual void updateBackingStore() { }
-
- virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) { }
-
- virtual void setToolTip(const String&) { }
-
- virtual void print(Frame*) { }
-
- virtual void exceededDatabaseQuota(Frame*, const String&) { }
-};
-
-class SVGEmptyFrameLoaderClient : public FrameLoaderClient {
-public:
- virtual ~SVGEmptyFrameLoaderClient() { }
- virtual void frameLoaderDestroyed() { }
-
- virtual bool hasWebView() const { return true; } // mainly for assertions
- virtual bool hasFrameView() const { return true; } // ditto
-
- virtual void makeRepresentation(DocumentLoader*) { }
- virtual void forceLayout() { }
- virtual void forceLayoutForNonHTML() { }
-
- virtual void updateHistoryForCommit() { }
-
- virtual void updateHistoryForBackForwardNavigation() { }
- virtual void updateHistoryForReload() { }
- virtual void updateHistoryForStandardLoad() { }
- virtual void updateHistoryForInternalLoad() { }
-
- virtual void updateHistoryAfterClientRedirect() { }
-
- virtual void setCopiesOnScroll() { }
-
- virtual void detachedFromParent2() { }
- virtual void detachedFromParent3() { }
- virtual void detachedFromParent4() { }
-
- virtual void download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&) { }
-
- virtual void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&) { }
- virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse) { }
- virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) { }
- virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) { }
- virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&) { }
- virtual void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived) { }
- virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) { }
- virtual void dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&) { }
- virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length) { return false; }
-
- virtual void dispatchDidHandleOnloadEvents() { }
- virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() { }
- virtual void dispatchDidCancelClientRedirect() { }
- virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate) { }
- virtual void dispatchDidChangeLocationWithinPage() { }
- virtual void dispatchWillClose() { }
- virtual void dispatchDidReceiveIcon() { }
- virtual void dispatchDidStartProvisionalLoad() { }
- virtual void dispatchDidReceiveTitle(const String& title) { }
- virtual void dispatchDidCommitLoad() { }
- virtual void dispatchDidFailProvisionalLoad(const ResourceError&) { }
- virtual void dispatchDidFailLoad(const ResourceError&) { }
- virtual void dispatchDidFinishDocumentLoad() { }
- virtual void dispatchDidFinishLoad() { }
- virtual void dispatchDidFirstLayout() { }
-
- virtual Frame* dispatchCreatePage() { return 0; }
- virtual void dispatchShow() { }
-
- virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction, const String& MIMEType, const ResourceRequest&) { }
- virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, const String& frameName) { }
- virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&) { }
- virtual void cancelPolicyCheck() { }
-
- virtual void dispatchUnableToImplementPolicy(const ResourceError&) { }
-
- virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>) { }
-
- virtual void dispatchDidLoadMainResource(DocumentLoader*) { }
- virtual void revertToProvisionalState(DocumentLoader*) { }
- virtual void setMainDocumentError(DocumentLoader*, const ResourceError&) { }
- virtual void clearUnarchivingState(DocumentLoader*) { }
-
- virtual void willChangeEstimatedProgress() { }
- virtual void didChangeEstimatedProgress() { }
- virtual void postProgressStartedNotification() { }
- virtual void postProgressEstimateChangedNotification() { }
- virtual void postProgressFinishedNotification() { }
-
- virtual void setMainFrameDocumentReady(bool) { }
-
- virtual void startDownload(const ResourceRequest&) { }
-
- virtual void willChangeTitle(DocumentLoader*) { }
- virtual void didChangeTitle(DocumentLoader*) { }
-
- virtual void committedLoad(DocumentLoader*, const char*, int) { }
- virtual void finishedLoading(DocumentLoader*) { }
- virtual void finalSetupForReplace(DocumentLoader*) { }
-
- virtual ResourceError cancelledError(const ResourceRequest&) { return ResourceError(); }
- virtual ResourceError blockedError(const ResourceRequest&) { return ResourceError(); }
- virtual ResourceError cannotShowURLError(const ResourceRequest&) { return ResourceError(); }
- virtual ResourceError interruptForPolicyChangeError(const ResourceRequest&) { return ResourceError(); }
-
- virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&) { return ResourceError(); }
- virtual ResourceError fileDoesNotExistError(const ResourceResponse&) { return ResourceError(); }
-
- virtual bool shouldFallBack(const ResourceError&) { return false; }
-
- virtual void setDefersLoading(bool) { }
-
- virtual bool willUseArchive(ResourceLoader*, const ResourceRequest&, const KURL& originalURL) const { return false; }
- virtual bool isArchiveLoadPending(ResourceLoader*) const { return false; }
- virtual void cancelPendingArchiveLoad(ResourceLoader*) { }
- virtual void clearArchivedResources() { }
-
- virtual bool canHandleRequest(const ResourceRequest&) const { return false; }
- virtual bool canShowMIMEType(const String& MIMEType) const { return false; }
- virtual bool representationExistsForURLScheme(const String& URLScheme) const { return false; }
- virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const { return ""; }
-
- virtual void frameLoadCompleted() { }
- virtual void restoreViewState() { }
- virtual void provisionalLoadStarted() { }
- virtual bool shouldTreatURLAsSameAsCurrent(const KURL&) const { return false; }
- virtual void addHistoryItemForFragmentScroll() { }
- virtual void didFinishLoad() { }
- virtual void prepareForDataSourceReplacement() { }
-
- virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData) { return new DocumentLoader(request, substituteData); }
- virtual void setTitle(const String& title, const KURL&) { }
-
- virtual String userAgent(const KURL&) { return ""; }
-
- virtual void savePlatformDataToCachedPage(CachedPage*) { }
- virtual void transitionToCommittedFromCachedPage(CachedPage*) { }
- virtual void transitionToCommittedForNewPage() { }
-
- virtual void updateGlobalHistoryForStandardLoad(const KURL&) { }
- virtual void updateGlobalHistoryForReload(const KURL&) { }
- virtual bool shouldGoToHistoryItem(HistoryItem*) const { return false; }
- virtual void saveViewStateToItem(HistoryItem*) { }
- virtual bool canCachePage() const { return false; }
-
- virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
- const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) { return 0; }
- virtual Widget* createPlugin(const IntSize&,Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) { return 0; }
- virtual Widget* createJavaAppletWidget(const IntSize&, Element*, const KURL&, const Vector<String>&, const Vector<String>&) { return 0; }
-
- virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType) { return ObjectContentType(); }
- virtual String overrideMediaType() const { return String(); }
-
- virtual void redirectDataToPlugin(Widget*) {}
- virtual void windowObjectCleared() {}
- virtual void didPerformFirstNavigation() const {}
-
- virtual void registerForIconNotification(bool listen) {}
-
-#if PLATFORM(MAC)
- virtual NSCachedURLResponse* willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse* response) const { return response; }
-#endif
-
-};
-
-class SVGEmptyEditorClient : public EditorClient {
-public:
- virtual ~SVGEmptyEditorClient() { }
- virtual void pageDestroyed() { }
-
- virtual bool shouldDeleteRange(Range*) { return false; }
- virtual bool shouldShowDeleteInterface(HTMLElement*) { return false; }
- virtual bool smartInsertDeleteEnabled() { return false; }
- virtual bool isContinuousSpellCheckingEnabled() { return false; }
- virtual void toggleContinuousSpellChecking() { }
- virtual bool isGrammarCheckingEnabled() { return false; }
- virtual void toggleGrammarChecking() { }
- virtual int spellCheckerDocumentTag() { return -1; }
-
- virtual bool selectWordBeforeMenuEvent() { return false; }
- virtual bool isEditable() { return false; }
-
- virtual bool shouldBeginEditing(Range*) { return false; }
- virtual bool shouldEndEditing(Range*) { return false; }
- virtual bool shouldInsertNode(Node*, Range*, EditorInsertAction) { return false; }
- // virtual bool shouldInsertNode(Node*, Range* replacingRange, WebViewInsertAction) { return false; }
- virtual bool shouldInsertText(String, Range*, EditorInsertAction) { return false; }
- virtual bool shouldChangeSelectedRange(Range* fromRange, Range* toRange, EAffinity, bool stillSelecting) { return false; }
-
- virtual bool shouldApplyStyle(CSSStyleDeclaration*, Range*) { return false; }
- virtual bool shouldMoveRangeAfterDelete(Range*, Range*) { return false; }
- // virtual bool shouldChangeTypingStyle(CSSStyleDeclaration* fromStyle, CSSStyleDeclaration* toStyle) { return false; }
- // virtual bool doCommandBySelector(SEL selector) { return false; }
- //
- virtual void didBeginEditing() { }
- virtual void respondToChangedContents() { }
- virtual void respondToChangedSelection() { }
- virtual void didEndEditing() { }
- virtual void didWriteSelectionToPasteboard() { }
- virtual void didSetSelectionTypesForPasteboard() { }
- // virtual void webViewDidChangeTypingStyle:(NSNotification *)notification { }
- // virtual void webViewDidChangeSelection:(NSNotification *)notification { }
- // virtual NSUndoManager* undoManagerForWebView:(WebView *)webView { return 0; }
-
- virtual void registerCommandForUndo(PassRefPtr<EditCommand>) { }
- virtual void registerCommandForRedo(PassRefPtr<EditCommand>) { }
- virtual void clearUndoRedoOperations() { }
-
- virtual bool canUndo() const { return false; }
- virtual bool canRedo() const { return false; }
-
- virtual void undo() { }
- virtual void redo() { }
-
- virtual void handleKeyboardEvent(KeyboardEvent*) { }
- virtual void handleInputMethodKeydown(KeyboardEvent*) { }
-
- virtual void textFieldDidBeginEditing(Element*) { }
- virtual void textFieldDidEndEditing(Element*) { }
- virtual void textDidChangeInTextField(Element*) { }
- virtual bool doTextFieldCommandFromEvent(Element*, KeyboardEvent*) { return false; }
- virtual void textWillBeDeletedInTextField(Element*) { }
- virtual void textDidChangeInTextArea(Element*) { }
-
-#if PLATFORM(MAC)
- virtual void markedTextAbandoned(Frame*) { }
-
- // FIXME: This should become SelectionController::toWebArchive()
- virtual NSData* dataForArchivedSelection(Frame*) { return 0; }
-
- virtual NSString* userVisibleString(NSURL*) { return 0; }
-#ifdef BUILDING_ON_TIGER
- virtual NSArray* pasteboardTypesForSelection(Frame*) { return 0; }
-#endif
-#endif
- virtual void ignoreWordInSpellDocument(const String&) { }
- virtual void learnWord(const String&) { }
- virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength) { }
- virtual void checkGrammarOfString(const UChar*, int length, Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) { }
- virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&) { }
- virtual void updateSpellingUIWithMisspelledWord(const String&) { }
- virtual void showSpellingUI(bool show) { }
- virtual bool spellingUIIsShowing() { return false; }
- virtual void getGuessesForWord(const String&, Vector<String>& guesses) { }
- virtual void setInputMethodState(bool enabled) { }
-
-
-};
-
-class SVGEmptyContextMenuClient : public ContextMenuClient {
-public:
- virtual ~SVGEmptyContextMenuClient() { }
- virtual void contextMenuDestroyed() { }
-
- virtual PlatformMenuDescription getCustomMenuFromDefaultItems(ContextMenu*) { return 0; }
- virtual void contextMenuItemSelected(ContextMenuItem*, const ContextMenu*) { }
-
- virtual void downloadURL(const KURL& url) { }
- virtual void copyImageToClipboard(const HitTestResult&) { }
- virtual void searchWithGoogle(const Frame*) { }
- virtual void lookUpInDictionary(Frame*) { }
- virtual void speak(const String&) { }
- virtual void stopSpeaking() { }
-
-#if PLATFORM(MAC)
- virtual void searchWithSpotlight() { }
-#endif
-};
-
-class SVGEmptyDragClient : public DragClient {
-public:
- virtual ~SVGEmptyDragClient() {}
- virtual void willPerformDragDestinationAction(DragDestinationAction, DragData*) { }
- virtual void willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*) { }
- virtual DragDestinationAction actionMaskForDrag(DragData*) { return DragDestinationActionNone; }
- virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint&) { return DragSourceActionNone; }
- virtual void startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool) { }
- virtual DragImageRef createDragImageForLink(KURL&, const String& label, Frame*) { return 0; }
- virtual void dragControllerDestroyed() { }
-};
-
-class SVGEmptyInspectorClient : public InspectorClient {
-public:
- virtual ~SVGEmptyInspectorClient() {}
-
- virtual void inspectorDestroyed() {};
-
- virtual Page* createPage() { return 0; };
-
- virtual String localizedStringsURL() { return String(); };
-
- virtual void showWindow() {};
- virtual void closeWindow() {};
-
- virtual void attachWindow() {};
- virtual void detachWindow() {};
-
- virtual void highlight(Node*) {};
- virtual void hideHighlight() {};
- virtual void inspectedURLChanged(const String& newURL) {};
-};
-
-}
-
-#endif // ENABLE(SVG)
-
-#endif // SVGImageEmptyClients_h
-
diff --git a/WebCore/svg/graphics/SVGPaintServer.cpp b/WebCore/svg/graphics/SVGPaintServer.cpp
index 32c0d3c..0240532 100644
--- a/WebCore/svg/graphics/SVGPaintServer.cpp
+++ b/WebCore/svg/graphics/SVGPaintServer.cpp
@@ -29,6 +29,7 @@
#if ENABLE(SVG)
#include "SVGPaintServer.h"
+#include "GraphicsContext.h"
#include "RenderObject.h"
#include "RenderStyle.h"
#include "SVGPaintServerSolid.h"
@@ -61,9 +62,8 @@ SVGPaintServer* getPaintServerById(Document* document, const AtomicString& id)
SVGPaintServerSolid* SVGPaintServer::sharedSolidPaintServer()
{
- static SVGPaintServerSolid* _sharedSolidPaintServer = 0;
- if (!_sharedSolidPaintServer)
- _sharedSolidPaintServer = new SVGPaintServerSolid();
+ static SVGPaintServerSolid* _sharedSolidPaintServer = SVGPaintServerSolid::create().releaseRef();
+
return _sharedSolidPaintServer;
}
@@ -145,6 +145,19 @@ SVGPaintServer* SVGPaintServer::strokePaintServer(const RenderStyle* style, cons
return strokePaintServer;
}
+void applyStrokeStyleToContext(GraphicsContext* context, RenderStyle* style, const RenderObject* object)
+{
+ context->setStrokeThickness(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0f));
+ context->setLineCap(style->svgStyle()->capStyle());
+ context->setLineJoin(style->svgStyle()->joinStyle());
+ if (style->svgStyle()->joinStyle() == MiterJoin)
+ context->setMiterLimit(style->svgStyle()->strokeMiterLimit());
+
+ const DashArray& dashes = dashArrayFromRenderingStyle(object->style());
+ float dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0f);
+ context->setLineDash(dashes, dashOffset);
+}
+
DashArray dashArrayFromRenderingStyle(const RenderStyle* style)
{
DashArray array;
@@ -154,7 +167,7 @@ DashArray dashArrayFromRenderingStyle(const RenderStyle* style)
CSSPrimitiveValue* dash = 0;
unsigned long len = dashes->length();
for (unsigned long i = 0; i < len; i++) {
- dash = static_cast<CSSPrimitiveValue*>(dashes->item(i));
+ dash = static_cast<CSSPrimitiveValue*>(dashes->itemWithoutBoundsCheck(i));
if (!dash)
continue;
diff --git a/WebCore/svg/graphics/SVGPaintServer.h b/WebCore/svg/graphics/SVGPaintServer.h
index e66a103..0d37e9f 100644
--- a/WebCore/svg/graphics/SVGPaintServer.h
+++ b/WebCore/svg/graphics/SVGPaintServer.h
@@ -28,22 +28,13 @@
#if ENABLE(SVG)
+#include "DashArray.h"
#include "SVGResource.h"
#if PLATFORM(CG)
#include <ApplicationServices/ApplicationServices.h>
#endif
-#if PLATFORM(QT)
-class QPen;
-#endif
-
-#if PLATFORM(CG)
- typedef Vector<CGFloat> DashArray;
-#else
- typedef Vector<float> DashArray;
-#endif
-
namespace WebCore {
enum SVGPaintServerType {
@@ -67,7 +58,6 @@ namespace WebCore {
class SVGPaintServer : public SVGResource {
public:
- SVGPaintServer();
virtual ~SVGPaintServer();
virtual SVGResourceType resourceType() const { return PaintServerResourceType; }
@@ -94,15 +84,15 @@ namespace WebCore {
void clipToFillPath(CGContextRef, const RenderObject*) const;
#endif
-#if PLATFORM(QT)
- void setPenProperties(const RenderObject*, const RenderStyle*, QPen&) const;
-#endif
+ protected:
+ SVGPaintServer();
};
TextStream& operator<<(TextStream&, const SVGPaintServer&);
SVGPaintServer* getPaintServerById(Document*, const AtomicString&);
+ void applyStrokeStyleToContext(GraphicsContext*, RenderStyle*, const RenderObject*);
DashArray dashArrayFromRenderingStyle(const RenderStyle* style);
} // namespace WebCore
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.cpp b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
index 6a701b8..58dd6bf 100644
--- a/WebCore/svg/graphics/SVGPaintServerGradient.cpp
+++ b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
@@ -33,14 +33,14 @@
namespace WebCore {
-TextStream& operator<<(TextStream& ts, SVGGradientSpreadMethod m)
+TextStream& operator<<(TextStream& ts, GradientSpreadMethod m)
{
switch (m) {
- case SPREADMETHOD_PAD:
+ case SpreadMethodPad:
ts << "PAD"; break;
- case SPREADMETHOD_REPEAT:
+ case SpreadMethodRepeat:
ts << "REPEAT"; break;
- case SPREADMETHOD_REFLECT:
+ case SpreadMethodReflect:
ts << "REFLECT"; break;
}
@@ -60,7 +60,7 @@ TextStream& operator<<(TextStream& ts, const Vector<SVGGradientStop>& l)
}
SVGPaintServerGradient::SVGPaintServerGradient(const SVGGradientElement* owner)
- : m_spreadMethod(SPREADMETHOD_PAD)
+ : m_spreadMethod(SpreadMethodPad)
, m_boundingBoxMode(true)
, m_ownerElement(owner)
@@ -91,12 +91,12 @@ void SVGPaintServerGradient::setGradientStops(const Vector<SVGGradientStop>& sto
m_stops = stops;
}
-SVGGradientSpreadMethod SVGPaintServerGradient::spreadMethod() const
+GradientSpreadMethod SVGPaintServerGradient::spreadMethod() const
{
return m_spreadMethod;
}
-void SVGPaintServerGradient::setGradientSpreadMethod(const SVGGradientSpreadMethod& method)
+void SVGPaintServerGradient::setGradientSpreadMethod(const GradientSpreadMethod& method)
{
m_spreadMethod = method;
}
@@ -128,7 +128,7 @@ TextStream& SVGPaintServerGradient::externalRepresentation(TextStream& ts) const
// abstract, don't stream type
ts << "[stops=" << gradientStops() << "]";
- if (spreadMethod() != SPREADMETHOD_PAD)
+ if (spreadMethod() != SpreadMethodPad)
ts << "[method=" << spreadMethod() << "]";
if (!boundingBoxMode())
ts << " [bounding box mode=" << boundingBoxMode() << "]";
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.h b/WebCore/svg/graphics/SVGPaintServerGradient.h
index afab7ab..99dac8e 100644
--- a/WebCore/svg/graphics/SVGPaintServerGradient.h
+++ b/WebCore/svg/graphics/SVGPaintServerGradient.h
@@ -30,13 +30,17 @@
#include "AffineTransform.h"
#include "Color.h"
+#include "GraphicsContext.h"
#include "SVGPaintServer.h"
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#if PLATFORM(QT)
+#include <qglobal.h>
+QT_BEGIN_NAMESPACE
class QGradient;
+QT_END_NAMESPACE
#endif
namespace WebCore {
@@ -44,30 +48,21 @@ namespace WebCore {
class ImageBuffer;
class SVGGradientElement;
- // FIXME: Remove the spread method enum in SVGGradientElement
- enum SVGGradientSpreadMethod {
- SPREADMETHOD_PAD = 1,
- SPREADMETHOD_REFLECT = 2,
- SPREADMETHOD_REPEAT = 3
- };
-
#if PLATFORM(CG)
typedef std::pair<CGFloat, Color> SVGGradientStop;
#else
typedef std::pair<float, Color> SVGGradientStop;
#endif
-
class SVGPaintServerGradient : public SVGPaintServer {
public:
- SVGPaintServerGradient(const SVGGradientElement*);
virtual ~SVGPaintServerGradient();
const Vector<SVGGradientStop>& gradientStops() const;
void setGradientStops(const Vector<SVGGradientStop>&);
- SVGGradientSpreadMethod spreadMethod() const;
- void setGradientSpreadMethod(const SVGGradientSpreadMethod&);
+ 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
@@ -99,9 +94,12 @@ namespace WebCore {
virtual QGradient setupGradient(GraphicsContext*&, const RenderObject*) const = 0;
#endif
+ protected:
+ SVGPaintServerGradient(const SVGGradientElement* owner);
+
private:
Vector<SVGGradientStop> m_stops;
- SVGGradientSpreadMethod m_spreadMethod;
+ GradientSpreadMethod m_spreadMethod;
bool m_boundingBoxMode;
AffineTransform m_gradientTransform;
const SVGGradientElement* m_ownerElement;
@@ -115,7 +113,13 @@ namespace WebCore {
} QuartzGradientStop;
struct SharedStopCache : public RefCounted<SharedStopCache> {
+ public:
+ static PassRefPtr<SharedStopCache> create() { return adoptRef(new SharedStopCache); }
+
Vector<QuartzGradientStop> m_stops;
+
+ private:
+ SharedStopCache() { }
};
RefPtr<SharedStopCache> m_stopsCache;
diff --git a/WebCore/svg/graphics/SVGPaintServerLinearGradient.h b/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
index e198830..4b7da32 100644
--- a/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
+++ b/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
@@ -35,7 +35,7 @@ namespace WebCore {
class SVGPaintServerLinearGradient : public SVGPaintServerGradient {
public:
- SVGPaintServerLinearGradient(const SVGGradientElement* owner);
+ static PassRefPtr<SVGPaintServerLinearGradient> create(const SVGGradientElement* owner) { return adoptRef(new SVGPaintServerLinearGradient(owner)); }
virtual ~SVGPaintServerLinearGradient();
virtual SVGPaintServerType type() const { return LinearGradientPaintServer; }
@@ -53,6 +53,8 @@ namespace WebCore {
#endif
private:
+ SVGPaintServerLinearGradient(const SVGGradientElement* owner);
+
FloatPoint m_start;
FloatPoint m_end;
};
diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.h b/WebCore/svg/graphics/SVGPaintServerPattern.h
index 5e7f6ce..65b28e9 100644
--- a/WebCore/svg/graphics/SVGPaintServerPattern.h
+++ b/WebCore/svg/graphics/SVGPaintServerPattern.h
@@ -44,7 +44,8 @@ namespace WebCore {
class SVGPaintServerPattern : public SVGPaintServer {
public:
- SVGPaintServerPattern(const SVGPatternElement*);
+ static PassRefPtr<SVGPaintServerPattern> create(const SVGPatternElement* owner) { return adoptRef(new SVGPaintServerPattern(owner)); }
+
virtual ~SVGPaintServerPattern();
virtual SVGPaintServerType type() const { return PatternPaintServer; }
@@ -61,16 +62,14 @@ namespace WebCore {
virtual TextStream& externalRepresentation(TextStream&) const;
-#if PLATFORM(CG)
- virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
- virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
-#endif
-
-#if PLATFORM(QT) || PLATFORM(CAIRO)
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*);
+
OwnPtr<ImageBuffer> m_tile;
const SVGPatternElement* m_ownerElement;
AffineTransform m_patternTransform;
diff --git a/WebCore/svg/graphics/SVGPaintServerRadialGradient.h b/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
index 1f19e3d..265f76b 100644
--- a/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
+++ b/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
@@ -35,7 +35,7 @@ namespace WebCore {
class SVGPaintServerRadialGradient : public SVGPaintServerGradient {
public:
- SVGPaintServerRadialGradient(const SVGGradientElement* owner);
+ static PassRefPtr<SVGPaintServerRadialGradient> create(const SVGGradientElement* owner) { return adoptRef(new SVGPaintServerRadialGradient(owner)); }
virtual ~SVGPaintServerRadialGradient();
virtual SVGPaintServerType type() const { return RadialGradientPaintServer; }
@@ -56,6 +56,8 @@ namespace WebCore {
#endif
private:
+ SVGPaintServerRadialGradient(const SVGGradientElement* owner);
+
float m_radius;
FloatPoint m_center;
FloatPoint m_focal;
diff --git a/WebCore/svg/graphics/SVGPaintServerSolid.h b/WebCore/svg/graphics/SVGPaintServerSolid.h
index f05a4e6..0166c87 100644
--- a/WebCore/svg/graphics/SVGPaintServerSolid.h
+++ b/WebCore/svg/graphics/SVGPaintServerSolid.h
@@ -35,7 +35,7 @@ namespace WebCore {
class SVGPaintServerSolid : public SVGPaintServer {
public:
- SVGPaintServerSolid();
+ static PassRefPtr<SVGPaintServerSolid> create() { return adoptRef(new SVGPaintServerSolid); }
virtual ~SVGPaintServerSolid();
virtual SVGPaintServerType type() const { return SolidPaintServer; }
@@ -45,11 +45,11 @@ namespace WebCore {
virtual TextStream& externalRepresentation(TextStream&) const;
-#if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(CAIRO)
virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
-#endif
private:
+ SVGPaintServerSolid();
+
Color m_color;
};
diff --git a/WebCore/svg/graphics/SVGResource.h b/WebCore/svg/graphics/SVGResource.h
index 5272468..7ee98f6 100644
--- a/WebCore/svg/graphics/SVGResource.h
+++ b/WebCore/svg/graphics/SVGResource.h
@@ -66,7 +66,6 @@ namespace WebCore {
class SVGResource : public RefCounted<SVGResource> {
public:
- SVGResource();
virtual ~SVGResource();
virtual void invalidate();
@@ -85,6 +84,9 @@ namespace WebCore {
static void invalidateClients(HashSet<SVGStyledElement*>);
static void removeClient(SVGStyledElement*);
+ protected:
+ SVGResource();
+
private:
HashSet<SVGStyledElement*> m_clients;
};
diff --git a/WebCore/svg/graphics/SVGResourceClipper.cpp b/WebCore/svg/graphics/SVGResourceClipper.cpp
index 3e52322..f03f5c2 100644
--- a/WebCore/svg/graphics/SVGResourceClipper.cpp
+++ b/WebCore/svg/graphics/SVGResourceClipper.cpp
@@ -29,7 +29,6 @@
#include "SVGResourceClipper.h"
#include "SVGRenderTreeAsText.h"
-#include "TextStream.h"
namespace WebCore {
diff --git a/WebCore/svg/graphics/SVGResourceClipper.h b/WebCore/svg/graphics/SVGResourceClipper.h
index d5c1ab7..98c295f 100644
--- a/WebCore/svg/graphics/SVGResourceClipper.h
+++ b/WebCore/svg/graphics/SVGResourceClipper.h
@@ -63,7 +63,7 @@ namespace WebCore {
class SVGResourceClipper : public SVGResource {
public:
- SVGResourceClipper();
+ static PassRefPtr<SVGResourceClipper> create() { return adoptRef(new SVGResourceClipper); }
virtual ~SVGResourceClipper();
void resetClipData();
@@ -77,6 +77,7 @@ namespace WebCore {
// To be implemented by the specific rendering devices
void applyClip(GraphicsContext*, const FloatRect& boundingBox) const;
private:
+ SVGResourceClipper();
ClipDataList m_clipData;
};
diff --git a/WebCore/svg/graphics/SVGResourceFilter.cpp b/WebCore/svg/graphics/SVGResourceFilter.cpp
index dceda8b..8fb2dfa 100644
--- a/WebCore/svg/graphics/SVGResourceFilter.cpp
+++ b/WebCore/svg/graphics/SVGResourceFilter.cpp
@@ -26,7 +26,6 @@
#include "SVGRenderTreeAsText.h"
#include "SVGFilterEffect.h"
-#include "TextStream.h"
namespace WebCore {
diff --git a/WebCore/svg/graphics/SVGResourceMarker.h b/WebCore/svg/graphics/SVGResourceMarker.h
index a78573b..bb4039c 100644
--- a/WebCore/svg/graphics/SVGResourceMarker.h
+++ b/WebCore/svg/graphics/SVGResourceMarker.h
@@ -38,7 +38,7 @@ namespace WebCore {
class SVGResourceMarker : public SVGResource {
public:
- SVGResourceMarker();
+ static PassRefPtr<SVGResourceMarker> create() { return adoptRef(new SVGResourceMarker); }
virtual ~SVGResourceMarker();
void setMarker(RenderSVGViewportContainer*);
@@ -61,6 +61,7 @@ namespace WebCore {
virtual TextStream& externalRepresentation(TextStream&) const;
private:
+ SVGResourceMarker();
double m_refX, m_refY;
FloatRect m_cachedBounds;
float m_angle;
diff --git a/WebCore/svg/graphics/SVGResourceMasker.h b/WebCore/svg/graphics/SVGResourceMasker.h
index d530571..f945f56 100644
--- a/WebCore/svg/graphics/SVGResourceMasker.h
+++ b/WebCore/svg/graphics/SVGResourceMasker.h
@@ -34,6 +34,7 @@
#include <memory>
#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
namespace WebCore {
@@ -43,7 +44,7 @@ namespace WebCore {
class SVGResourceMasker : public SVGResource {
public:
- SVGResourceMasker(const SVGMaskElement*);
+ static PassRefPtr<SVGResourceMasker> create(const SVGMaskElement* ownerElement) { return adoptRef(new SVGResourceMasker(ownerElement)); }
virtual ~SVGResourceMasker();
virtual void invalidate();
@@ -55,6 +56,8 @@ namespace WebCore {
void applyMask(GraphicsContext*, const FloatRect& boundingBox);
private:
+ SVGResourceMasker(const SVGMaskElement*);
+
const SVGMaskElement* m_ownerElement;
OwnPtr<ImageBuffer> m_mask;
diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp
index 7b22f4f..e237962 100644
--- a/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp
+++ b/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ * 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
@@ -43,31 +44,69 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject
cairo_matrix_init_identity (&matrix);
const cairo_matrix_t gradient_matrix = gradientTransform();
- // TODO: revise this code, it is known not to work in many cases
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+ RenderStyle* style = object->style();
+
if (this->type() == LinearGradientPaintServer) {
const SVGPaintServerLinearGradient* linear = static_cast<const SVGPaintServerLinearGradient*>(this);
if (boundingBoxMode()) {
- // TODO: use RenderPathCairo's strokeBBox?
- double x1, y1, x2, y2;
- cairo_fill_extents(cr, &x1, &y1, &x2, &y2);
- cairo_matrix_translate(&matrix, x1, y1);
- cairo_matrix_scale(&matrix, x2 - x1, y2 - y1);
- cairo_matrix_multiply(&matrix, &matrix, &gradient_matrix);
- cairo_matrix_invert(&matrix);
+ FloatRect bbox = object->relativeBBox(false);
+ if (bbox.width() == 0 || bbox.height() == 0) {
+ applyStrokeStyleToContext(context, style, object);
+ cairo_set_source_rgb(cr, 0, 0, 0);
+ return true;
+ }
+ cairo_matrix_translate(&matrix, bbox.x(), bbox.y());
+ cairo_matrix_scale(&matrix, bbox.width(), bbox.height());
}
- double x0, x1, y0, y1;
- x0 = linear->gradientStart().x();
- y0 = linear->gradientStart().y();
- x1 = linear->gradientEnd().x();
- y1 = linear->gradientEnd().y();
+ double x0 = linear->gradientStart().x();
+ double y0 = linear->gradientStart().y();
+ double x1 = linear->gradientEnd().x();
+ double y1 = linear->gradientEnd().y();
+
pattern = cairo_pattern_create_linear(x0, y0, x1, y1);
} else if (this->type() == RadialGradientPaintServer) {
- // const SVGPaintServerRadialGradient* radial = static_cast<const SVGPaintServerRadialGradient*>(this);
- // TODO: pattern = cairo_pattern_create_radial();
- return false;
+ const SVGPaintServerRadialGradient* radial = static_cast<const SVGPaintServerRadialGradient*>(this);
+
+ if (boundingBoxMode()) {
+ FloatRect bbox = object->relativeBBox(false);
+ if (bbox.width() == 0 || bbox.height() == 0) {
+ applyStrokeStyleToContext(context, style, object);
+ cairo_set_source_rgb(cr, 0, 0, 0);
+ return true;
+ }
+ cairo_matrix_translate(&matrix, bbox.x(), bbox.y());
+ cairo_matrix_scale(&matrix, bbox.width(), bbox.height());
+ }
+
+ double cx = radial->gradientCenter().x();
+ double cy = radial->gradientCenter().y();
+ double radius = radial->gradientRadius();
+ double fx = radial->gradientFocal().x();
+ double fy = radial->gradientFocal().y();
+
+ fx -= cx;
+ fy -= cy;
+
+ double fradius = 0.0;
+
+ if (sqrt(fx * fx + fy * fy) >= radius) {
+ double angle = atan2(fy, fx);
+ if ((fx + cx) < cx)
+ fx = cos(angle) * radius + 0.002;
+ else
+ fx = cos(angle) * radius - 0.002;
+ if ((fy + cy) < cy)
+ fy = sin(angle) * radius + 0.002;
+ else
+ fy = sin(angle) * radius - 0.002;
+ }
+
+ pattern = cairo_pattern_create_radial(fx + cx, fy + cy, fradius, cx, cy, radius);
+
} else {
return false;
}
@@ -75,13 +114,13 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject
cairo_pattern_set_filter(pattern, CAIRO_FILTER_BILINEAR);
switch (spreadMethod()) {
- case SPREADMETHOD_PAD:
+ case SpreadMethodPad:
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD);
break;
- case SPREADMETHOD_REFLECT:
+ case SpreadMethodReflect:
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REFLECT);
break;
- case SPREADMETHOD_REPEAT:
+ case SpreadMethodRepeat:
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
break;
default:
@@ -89,6 +128,8 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject
break;
}
+ cairo_matrix_multiply(&matrix, &matrix, &gradient_matrix);
+ cairo_matrix_invert(&matrix);
cairo_pattern_set_matrix(pattern, &matrix);
const Vector<SVGGradientStop>& stops = gradientStops();
@@ -96,10 +137,18 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject
for (unsigned i = 0; i < stops.size(); ++i) {
float offset = stops[i].first;
Color color = stops[i].second;
+ if (i > 0 && offset < stops[i - 1].first)
+ offset = stops[i - 1].first;
- cairo_pattern_add_color_stop_rgba(pattern, offset, color.red(), color.green(), color.blue(), color.alpha());
+ cairo_pattern_add_color_stop_rgba(pattern, offset, color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, color.alpha() / 255.0);
}
+ if ((type & ApplyToFillTargetType) && svgStyle->hasFill())
+ context->setFillRule(svgStyle->fillRule());
+
+ if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke())
+ applyStrokeStyleToContext(context, style, object);
+
cairo_set_source(cr, pattern);
cairo_pattern_destroy(pattern);
diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp
index 6381277..86530bc 100644
--- a/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp
+++ b/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ * 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
@@ -20,14 +21,59 @@
#include "config.h"
#if ENABLE(SVG)
-#include "NotImplemented.h"
#include "SVGPaintServerPattern.h"
+#include "GraphicsContext.h"
+#include "Image.h"
+#include "ImageBuffer.h"
+#include "RenderObject.h"
+#include "SVGPatternElement.h"
+
+#include <wtf/OwnArrayPtr.h>
+
namespace WebCore {
bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
{
- notImplemented();
+ FloatRect targetRect = object->relativeBBox(false);
+
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+ RenderStyle* style = object->style();
+
+ float strokeWidth = SVGRenderStyle::cssPrimitiveToLength(object, svgStyle->strokeWidth(), 1.0f);
+
+ if (targetRect.width() == 0)
+ targetRect = FloatRect(targetRect.x(), targetRect.y(), strokeWidth, targetRect.height());
+ if (targetRect.height() == 0)
+ targetRect = FloatRect(targetRect.x(), targetRect.y(), targetRect.width(), strokeWidth);
+
+ m_ownerElement->buildPattern(targetRect);
+
+ cairo_surface_t* image = tile()->image()->nativeImageForCurrentFrame();
+ if (!image)
+ return false;
+
+ cairo_t* cr = context->platformContext();
+
+ cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image);
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
+
+ cairo_pattern_set_filter(pattern, CAIRO_FILTER_BEST);
+ cairo_matrix_t pattern_matrix = patternTransform();
+ cairo_matrix_t matrix = {1, 0, 0, 1, patternBoundaries().x(), patternBoundaries().y()};
+ cairo_matrix_multiply(&matrix, &matrix, &pattern_matrix);
+ cairo_matrix_invert(&matrix);
+ cairo_pattern_set_matrix(pattern, &matrix);
+
+ if ((type & ApplyToFillTargetType) && svgStyle->hasFill())
+ context->setFillRule(svgStyle->fillRule());
+
+ if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke())
+ applyStrokeStyleToContext(context, style, object);
+
+ cairo_set_source(cr, pattern);
+ cairo_pattern_destroy(pattern);
+
return true;
}
diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp
index 6acc9b2..49e6f55 100644
--- a/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp
+++ b/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp
@@ -31,35 +31,22 @@ namespace WebCore {
bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
{
// TODO: share this code with other PaintServers
-
cairo_t* cr = context->platformContext();
- const SVGRenderStyle* style = object->style()->svgStyle();
+
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+ RenderStyle* style = object->style();
float red, green, blue, alpha;
color().getRGBA(red, green, blue, alpha);
- if ((type & ApplyToFillTargetType) && style->hasFill()) {
- alpha = style->fillOpacity();
-
- cairo_set_fill_rule(cr, style->fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
+ if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) {
+ alpha = svgStyle->fillOpacity();
+ context->setFillRule(svgStyle->fillRule());
}
- if ((type & ApplyToStrokeTargetType) && style->hasStroke()) {
- alpha = style->strokeOpacity();
-
- cairo_set_line_width(cr, SVGRenderStyle::cssPrimitiveToLength(object, style->strokeWidth(), 1.0));
- context->setLineCap(style->capStyle());
- context->setLineJoin(style->joinStyle());
- if (style->joinStyle() == MiterJoin)
- context->setMiterLimit(style->strokeMiterLimit());
-
- const DashArray& dashes = dashArrayFromRenderingStyle(object->style());
- double* dsh = new double[dashes.size()];
- for (unsigned i = 0 ; i < dashes.size() ; i++)
- dsh[i] = dashes[i];
- double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->strokeDashOffset(), 0.0);
- cairo_set_dash(cr, dsh, dashes.size(), dashOffset);
- delete[] dsh;
+ if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
+ alpha = svgStyle->strokeOpacity();
+ applyStrokeStyleToContext(context, style, object);
}
cairo_set_source_rgba(cr, red, green, blue, alpha);
diff --git a/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp b/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp
index 5900fcd..6aec0ae 100644
--- a/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp
+++ b/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ * 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
@@ -22,6 +23,7 @@
#if ENABLE(SVG)
#include "SVGResourceClipper.h"
#include "AffineTransform.h"
+#include "CairoPath.h"
#include "GraphicsContext.h"
#include <cairo.h>
@@ -30,33 +32,35 @@ namespace WebCore {
void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
{
- Vector<ClipData> data = m_clipData.clipData();
- unsigned int count = data.size();
- if (!count)
+ cairo_t* cr = context->platformContext();
+ if (m_clipData.clipData().size() < 1)
return;
- cairo_t* cr = context->platformContext();
cairo_reset_clip(cr);
+ context->beginPath();
+
+ for (unsigned int x = 0; x < m_clipData.clipData().size(); x++) {
+ ClipData data = m_clipData.clipData()[x];
- for (unsigned int x = 0; x < count; x++) {
- Path path = data[x].path;
+ Path path = data.path;
if (path.isEmpty())
continue;
path.closeSubpath();
- if (data[x].bboxUnits) {
+ if (data.bboxUnits) {
// Make use of the clipping units
AffineTransform transform;
transform.translate(boundingBox.x(), boundingBox.y());
transform.scale(boundingBox.width(), boundingBox.height());
path.transform(transform);
}
+ cairo_path_t* clipPath = cairo_copy_path(path.platformPath()->m_cr);
+ cairo_append_path(cr, clipPath);
- cairo_set_fill_rule(cr, data[x].windRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
-
- // TODO: review this code, clipping may not be having the desired effect
- context->clip(path);
+ cairo_set_fill_rule(cr, data.windRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
}
+
+ cairo_clip(cr);
}
} // namespace WebCore
diff --git a/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp b/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp
index 78ea76b..1f690b5 100644
--- a/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp
+++ b/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp
@@ -21,6 +21,7 @@
#if ENABLE(SVG)
#include "SVGResourceMasker.h"
+#include "Image.h"
#include "ImageBuffer.h"
#include "GraphicsContext.h"
@@ -30,8 +31,11 @@ namespace WebCore {
void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& boundingBox)
{
+ if (!m_mask)
+ return;
+
cairo_t* cr = context->platformContext();
- cairo_surface_t* surface = m_mask->surface();
+ cairo_surface_t* surface = m_mask->image()->nativeImageForCurrentFrame();
if (!surface)
return;
cairo_pattern_t* mask = cairo_pattern_create_for_surface(surface);
diff --git a/WebCore/svg/graphics/cg/CgSupport.cpp b/WebCore/svg/graphics/cg/CgSupport.cpp
index 9d4eec7..f9bfb4c 100644
--- a/WebCore/svg/graphics/cg/CgSupport.cpp
+++ b/WebCore/svg/graphics/cg/CgSupport.cpp
@@ -41,26 +41,6 @@
namespace WebCore {
-CGAffineTransform CGAffineTransformMakeMapBetweenRects(CGRect source, CGRect dest)
-{
- CGAffineTransform transform = CGAffineTransformMakeTranslation(dest.origin.x - source.origin.x, dest.origin.y - source.origin.y);
- transform = CGAffineTransformScale(transform, dest.size.width/source.size.width, dest.size.height/source.size.height);
- return transform;
-}
-
-void applyStrokeStyleToContext(GraphicsContext* context, RenderStyle* style, const RenderObject* object)
-{
- context->setStrokeThickness(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0f));
- context->setLineCap(style->svgStyle()->capStyle());
- context->setLineJoin(style->svgStyle()->joinStyle());
- context->setMiterLimit(style->svgStyle()->strokeMiterLimit());
-
- const DashArray& dashes = dashArrayFromRenderingStyle(style);
- double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0f);
-
- CGContextSetLineDash(context->platformContext(), narrowPrecisionToCGFloat(dashOffset), dashes.data(), dashes.size());
-}
-
CGContextRef scratchContext()
{
static CGContextRef scratch = 0;
@@ -85,7 +65,7 @@ FloatRect strokeBoundingBox(const Path& path, RenderStyle* style, const RenderOb
// to make an alternative call...
// FIXME: since this is mainly used to decide what to repaint,
- // perhaps it would be sufficien to just outset the fill bbox by
+ // perhaps it would be sufficient to just outset the fill bbox by
// the stroke width - that should be way cheaper and simpler than
// what we do here.
diff --git a/WebCore/svg/graphics/cg/CgSupport.h b/WebCore/svg/graphics/cg/CgSupport.h
index 454e5b9..de6e4b3 100644
--- a/WebCore/svg/graphics/cg/CgSupport.h
+++ b/WebCore/svg/graphics/cg/CgSupport.h
@@ -41,10 +41,6 @@ class RenderStyle;
class RenderObject;
class GraphicsContext;
-CGAffineTransform CGAffineTransformMakeMapBetweenRects(CGRect source, CGRect dest);
-
-void applyStrokeStyleToContext(GraphicsContext*, RenderStyle*, const RenderObject*);
-
CGContextRef scratchContext();
FloatRect strokeBoundingBox(const Path& path, RenderStyle*, const RenderObject*);
diff --git a/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp b/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp
index d1ab090..bfa5017 100644
--- a/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp
+++ b/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp
@@ -24,7 +24,6 @@
#if ENABLE(SVG)
#include "SVGPaintServerGradient.h"
-#include "CgSupport.h"
#include "FloatConversion.h"
#include "GraphicsContext.h"
#include "ImageBuffer.h"
@@ -138,7 +137,7 @@ static CGShadingRef CGShadingRefForRadialGradient(const SVGPaintServerRadialGrad
void SVGPaintServerGradient::updateQuartzGradientStopsCache(const Vector<SVGGradientStop>& stops)
{
- m_stopsCache = new SharedStopCache;
+ m_stopsCache = SharedStopCache::create();
Vector<QuartzGradientStop>& stopsCache = m_stopsCache->m_stops;
stopsCache.resize(stops.size());
CGFloat previousOffset = 0.0f;
@@ -208,7 +207,7 @@ void SVGPaintServerGradient::teardown(GraphicsContext*& context, const RenderObj
// Clip current context to mask image (gradient)
m_savedContext->concatCTM(transform.inverse());
- CGContextClipToMask(m_savedContext->platformContext(), CGRect(textBoundary), m_imageBuffer->cgImage());
+ m_savedContext->clipToImageBuffer(textBoundary, m_imageBuffer);
m_savedContext->concatCTM(transform);
handleBoundingBoxModeAndGradientTransformation(m_savedContext, maskBBox);
@@ -254,20 +253,16 @@ void SVGPaintServerGradient::renderPath(GraphicsContext*& context, const RenderO
void SVGPaintServerGradient::handleBoundingBoxModeAndGradientTransformation(GraphicsContext* context, const FloatRect& targetRect) const
{
- CGContextRef contextRef = context->platformContext();
-
if (boundingBoxMode()) {
// Choose default gradient bounding box
- CGRect gradientBBox = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
+ FloatRect gradientBBox(0.0f, 0.0f, 1.0f, 1.0f);
// Generate a transform to map between both bounding boxes
- CGAffineTransform gradientIntoObjectBBox = CGAffineTransformMakeMapBetweenRects(gradientBBox, CGRect(targetRect));
- CGContextConcatCTM(contextRef, gradientIntoObjectBBox);
+ context->concatCTM(makeMapBetweenRects(gradientBBox, targetRect));
}
// Apply the gradient's own transform
- CGAffineTransform transform = gradientTransform();
- CGContextConcatCTM(contextRef, transform);
+ context->concatCTM(gradientTransform());
}
bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
diff --git a/WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp b/WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp
index e12ff77..416d5fe 100644
--- a/WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp
+++ b/WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp
@@ -35,7 +35,11 @@ namespace WebCore {
static void patternCallback(void* info, CGContextRef context)
{
ImageBuffer* patternImage = reinterpret_cast<ImageBuffer*>(info);
- CGContextDrawImage(context, CGRect(FloatRect(FloatPoint(), patternImage->size())), patternImage->cgImage());
+ CGContextSaveGState(context);
+ CGContextTranslateCTM(context, 0, patternImage->size().height());
+ CGContextScaleCTM(context, 1.0f, -1.0f);
+ CGContextDrawImage(context, CGRect(FloatRect(FloatPoint(), patternImage->size())), patternImage->image()->getCGImageRef());
+ CGContextRestoreGState(context);
}
bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
diff --git a/WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp b/WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp
index 706f39c..bd2a56f 100644
--- a/WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp
+++ b/WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp
@@ -24,42 +24,41 @@
#if ENABLE(SVG)
#include "SVGPaintServerSolid.h"
+#include "Color.h"
+#include "CgSupport.h"
#include "GraphicsContext.h"
#include "RenderObject.h"
-#include "CgSupport.h"
namespace WebCore {
bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
{
- CGContextRef contextRef = context->platformContext();
- RenderStyle* style = object ? object->style() : 0;
+ // FIXME: This function does not use any CG-specific calls, however it's not yet
+ // cross platform, because CG handles fill rule different from other graphics
+ // platforms. CG makes you use two separate fill calls, other platforms set
+ // the fill rule state on the context and then call a generic "fillPath"
- static CGColorSpaceRef deviceRGBColorSpace = CGColorSpaceCreateDeviceRGB(); // This should be shared from GraphicsContext, or some other central location
+ RenderStyle* style = object ? object->style() : 0;
if ((type & ApplyToFillTargetType) && (!style || style->svgStyle()->hasFill())) {
- CGFloat colorComponents[4];
- color().getRGBA(colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]);
+ RGBA32 rgba = color().rgb();
ASSERT(!color().hasAlpha());
if (style)
- colorComponents[3] = style->svgStyle()->fillOpacity(); // SVG/CSS colors are not specified w/o alpha
+ rgba = colorWithOverrideAlpha(rgba, style->svgStyle()->fillOpacity());
- CGContextSetFillColorSpace(contextRef, deviceRGBColorSpace);
- CGContextSetFillColor(contextRef, colorComponents);
+ context->setFillColor(rgba);
if (isPaintingText)
context->setTextDrawingMode(cTextFill);
}
if ((type & ApplyToStrokeTargetType) && (!style || style->svgStyle()->hasStroke())) {
- CGFloat colorComponents[4];
- color().getRGBA(colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]);
+ RGBA32 rgba = color().rgb();
ASSERT(!color().hasAlpha());
if (style)
- colorComponents[3] = style->svgStyle()->strokeOpacity(); // SVG/CSS colors are not specified w/o alpha
+ rgba = colorWithOverrideAlpha(rgba, style->svgStyle()->strokeOpacity());
- CGContextSetStrokeColorSpace(contextRef, deviceRGBColorSpace);
- CGContextSetStrokeColor(contextRef, colorComponents);
+ context->setStrokeColor(rgba);
if (style)
applyStrokeStyleToContext(context, style, object);
diff --git a/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp b/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp
index 071afe2..b04a0dc 100644
--- a/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp
+++ b/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp
@@ -30,14 +30,15 @@
#if ENABLE(SVG)
#include "SVGResourceClipper.h"
+#include "AffineTransform.h"
#include "GraphicsContext.h"
-#include "CgSupport.h"
+
+#include <ApplicationServices/ApplicationServices.h>
namespace WebCore {
void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
{
- CGContextRef cgContext = context->platformContext();
if (m_clipData.clipData().size() < 1)
return;
@@ -46,24 +47,22 @@ void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& bo
context->beginPath();
- CGAffineTransform bboxTransform = CGAffineTransformMakeMapBetweenRects(CGRectMake(0,0,1,1), CGRect(boundingBox));
+ AffineTransform bboxTransform = makeMapBetweenRects(FloatRect(0.0f, 0.0f, 1.0f, 1.0f), boundingBox);
for (unsigned x = 0; x < m_clipData.clipData().size(); x++) {
ClipData data = m_clipData.clipData()[x];
if (data.windRule != clipRule)
heterogenousClipRules = true;
- CGPathRef clipPath = data.path.platformPath();
-
- if (data.bboxUnits) {
- CGMutablePathRef transformedPath = CGPathCreateMutable();
- CGPathAddPath(transformedPath, &bboxTransform, clipPath);
- CGContextAddPath(cgContext, transformedPath);
- CGPathRelease(transformedPath);
- } else
- CGContextAddPath(cgContext, clipPath);
+ Path clipPath = data.path;
+
+ if (data.bboxUnits)
+ clipPath.transform(bboxTransform);
+
+ context->addPath(clipPath);
}
+ CGContextRef cgContext = context->platformContext();
if (m_clipData.clipData().size()) {
// FIXME!
// We don't currently allow for heterogenous clip rules.
diff --git a/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm
index 00e62e7..f867f9c 100644
--- a/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm
+++ b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm
@@ -96,9 +96,10 @@ void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& bou
{
if (!m_mask)
m_mask.set(m_ownerElement->drawMaskerContent(boundingBox, m_maskRect).release());
+
if (!m_mask)
return;
-
+
IntSize maskSize(static_cast<int>(m_maskRect.width()), static_cast<int>(m_maskRect.height()));
clampImageBufferSizeToViewport(m_ownerElement->document()->renderer(), maskSize);
@@ -106,19 +107,20 @@ void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& bou
auto_ptr<ImageBuffer> grayScaleImage(ImageBuffer::create(maskSize, true));
if (!grayScaleImage.get())
return;
-
+
BEGIN_BLOCK_OBJC_EXCEPTIONS
CGContextRef grayScaleContext = grayScaleImage->context()->platformContext();
CIContext* ciGrayscaleContext = [CIContext contextWithCGContext:grayScaleContext options:nil];
// Transform colorized mask to gray scale
- CIImage* colorMask = [CIImage imageWithCGImage:m_mask->cgImage()];
+ CIImage* colorMask = [CIImage imageWithCGImage:m_mask->image()->getCGImageRef()];
if (!colorMask)
return;
+
CIImage* grayScaleMask = transformImageIntoGrayscaleMask(colorMask);
[ciGrayscaleContext drawImage:grayScaleMask atPoint:CGPointZero fromRect:CGRectMake(0, 0, maskSize.width(), maskSize.height())];
- CGContextClipToMask(context->platformContext(), m_maskRect, grayScaleImage->cgImage());
+ CGContextClipToMask(context->platformContext(), m_maskRect, grayScaleImage->image()->getCGImageRef());
END_BLOCK_OBJC_EXCEPTIONS
}
diff --git a/WebCore/svg/graphics/filters/SVGDistantLightSource.h b/WebCore/svg/graphics/filters/SVGDistantLightSource.h
index c4ff9b7..25c2045 100644
--- a/WebCore/svg/graphics/filters/SVGDistantLightSource.h
+++ b/WebCore/svg/graphics/filters/SVGDistantLightSource.h
@@ -1,5 +1,6 @@
/*
- Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
+ 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
2004, 2005 Rob Buis <buis@kde.org>
2005 Eric Seidel <eric@webkit.org>
@@ -27,23 +28,23 @@
namespace WebCore {
-class SVGDistantLightSource : public SVGLightSource {
-public:
- SVGDistantLightSource(float azimuth, float elevation)
- : SVGLightSource(LS_DISTANT)
- , m_azimuth(azimuth)
- , m_elevation(elevation)
- { }
+ class DistantLightSource : public LightSource {
+ public:
+ DistantLightSource(float azimuth, float elevation)
+ : LightSource(LS_DISTANT)
+ , m_azimuth(azimuth)
+ , m_elevation(elevation)
+ { }
- float azimuth() const { return m_azimuth; }
- float elevation() const { return m_elevation; }
+ float azimuth() const { return m_azimuth; }
+ float elevation() const { return m_elevation; }
- virtual TextStream& externalRepresentation(TextStream&) const;
+ virtual TextStream& externalRepresentation(TextStream&) const;
-private:
- float m_azimuth;
- float m_elevation;
-};
+ private:
+ float m_azimuth;
+ float m_elevation;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFEBlend.cpp b/WebCore/svg/graphics/filters/SVGFEBlend.cpp
deleted file mode 100644
index bb083e3..0000000
--- a/WebCore/svg/graphics/filters/SVGFEBlend.cpp
+++ /dev/null
@@ -1,88 +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 "SVGFEBlend.h"
-#include "TextStream.h"
-
-namespace WebCore {
-
-SVGFEBlend::SVGFEBlend(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_mode(SVG_FEBLEND_MODE_UNKNOWN)
-{
-}
-
-String SVGFEBlend::in2() const
-{
- return m_in2;
-}
-
-void SVGFEBlend::setIn2(const String& in2)
-{
- m_in2 = in2;
-}
-
-SVGBlendModeType SVGFEBlend::blendMode() const
-{
- return m_mode;
-}
-
-void SVGFEBlend::setBlendMode(SVGBlendModeType mode)
-{
- m_mode = mode;
-}
-
-static TextStream& operator<<(TextStream& ts, SVGBlendModeType t)
-{
- switch (t)
- {
- case SVG_FEBLEND_MODE_UNKNOWN:
- ts << "UNKNOWN"; break;
- case SVG_FEBLEND_MODE_NORMAL:
- ts << "NORMAL"; break;
- case SVG_FEBLEND_MODE_MULTIPLY:
- ts << "MULTIPLY"; break;
- case SVG_FEBLEND_MODE_SCREEN:
- ts << "SCREEN"; break;
- case SVG_FEBLEND_MODE_DARKEN:
- ts << "DARKEN"; break;
- case SVG_FEBLEND_MODE_LIGHTEN:
- ts << "LIGHTEN"; break;
- }
- return ts;
-}
-
-TextStream& SVGFEBlend::externalRepresentation(TextStream& ts) const
-{
- ts << "[type=BLEND] ";
- SVGFilterEffect::externalRepresentation(ts);
- if (!m_in2.isEmpty())
- ts << " [in2=\"" << m_in2 << "\"]";
- ts << " [blend mode=" << m_mode << "]";
- return ts;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEBlend.h b/WebCore/svg/graphics/filters/SVGFEBlend.h
deleted file mode 100644
index f8063f7..0000000
--- a/WebCore/svg/graphics/filters/SVGFEBlend.h
+++ /dev/null
@@ -1,64 +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 SVGFEBlend_h
-#define SVGFEBlend_h
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
-
-namespace WebCore {
-
-enum SVGBlendModeType {
- SVG_FEBLEND_MODE_UNKNOWN = 0,
- SVG_FEBLEND_MODE_NORMAL = 1,
- SVG_FEBLEND_MODE_MULTIPLY = 2,
- SVG_FEBLEND_MODE_SCREEN = 3,
- SVG_FEBLEND_MODE_DARKEN = 4,
- SVG_FEBLEND_MODE_LIGHTEN = 5
-};
-
-class SVGFEBlend : public SVGFilterEffect {
-public:
- SVGFEBlend(SVGResourceFilter*);
-
- String in2() const;
- void setIn2(const String&);
-
- SVGBlendModeType blendMode() const;
- void setBlendMode(SVGBlendModeType);
-
- virtual TextStream& externalRepresentation(TextStream&) const;
-
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
-
-private:
- SVGBlendModeType m_mode;
- String m_in2;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
-
-#endif // SVGFEBlend_h
diff --git a/WebCore/svg/graphics/filters/SVGFEColorMatrix.cpp b/WebCore/svg/graphics/filters/SVGFEColorMatrix.cpp
deleted file mode 100644
index 8eb2572..0000000
--- a/WebCore/svg/graphics/filters/SVGFEColorMatrix.cpp
+++ /dev/null
@@ -1,84 +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 "SVGFEColorMatrix.h"
-
-namespace WebCore {
-
-SVGFEColorMatrix::SVGFEColorMatrix(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_type(SVG_FECOLORMATRIX_TYPE_UNKNOWN)
-{
-}
-
-SVGColorMatrixType SVGFEColorMatrix::type() const
-{
- return m_type;
-}
-
-void SVGFEColorMatrix::setType(SVGColorMatrixType type)
-{
- m_type = type;
-}
-
-const Vector<float>& SVGFEColorMatrix::values() const
-{
- return m_values;
-}
-
-void SVGFEColorMatrix::setValues(const Vector<float> &values)
-{
- m_values = values;
-}
-
-static TextStream& operator<<(TextStream& ts, SVGColorMatrixType t)
-{
- switch (t)
- {
- case SVG_FECOLORMATRIX_TYPE_UNKNOWN:
- ts << "UNKNOWN"; break;
- case SVG_FECOLORMATRIX_TYPE_MATRIX:
- ts << "CMT_MATRIX"; break;
- case SVG_FECOLORMATRIX_TYPE_SATURATE:
- ts << "CMT_SATURATE"; break;
- case SVG_FECOLORMATRIX_TYPE_HUEROTATE:
- ts << "HUE-ROTATE"; break;
- case SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
- ts << "LUMINANCE-TO-ALPHA"; break;
- }
- return ts;
-}
-
-TextStream& SVGFEColorMatrix::externalRepresentation(TextStream& ts) const
-{
- ts << "[type=COLOR-MATRIX] ";
- SVGFilterEffect::externalRepresentation(ts);
- ts << " [color matrix type=" << type() << "]"
- << " [values=" << values() << "]";
- return ts;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEColorMatrix.h b/WebCore/svg/graphics/filters/SVGFEColorMatrix.h
deleted file mode 100644
index 0d4eb23..0000000
--- a/WebCore/svg/graphics/filters/SVGFEColorMatrix.h
+++ /dev/null
@@ -1,64 +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 SVGFEColorMatrix_h
-#define SVGFEColorMatrix_h
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
-#include "SVGRenderTreeAsText.h"
-
-namespace WebCore {
-
-enum SVGColorMatrixType {
- SVG_FECOLORMATRIX_TYPE_UNKNOWN = 0,
- SVG_FECOLORMATRIX_TYPE_MATRIX = 1,
- SVG_FECOLORMATRIX_TYPE_SATURATE = 2,
- SVG_FECOLORMATRIX_TYPE_HUEROTATE = 3,
- SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA = 4
-};
-
-class SVGFEColorMatrix : public SVGFilterEffect {
-public:
- SVGFEColorMatrix(SVGResourceFilter*);
-
- SVGColorMatrixType type() const;
- void setType(SVGColorMatrixType);
-
- const Vector<float>& values() const;
- void setValues(const Vector<float>&);
-
- virtual TextStream& externalRepresentation(TextStream&) const;
-
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
-
-private:
- SVGColorMatrixType m_type;
- Vector<float> m_values;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
-
-#endif // SVGFEColorMatrix_h
diff --git a/WebCore/svg/graphics/filters/SVGFEComponentTransfer.cpp b/WebCore/svg/graphics/filters/SVGFEComponentTransfer.cpp
deleted file mode 100644
index 55a1730..0000000
--- a/WebCore/svg/graphics/filters/SVGFEComponentTransfer.cpp
+++ /dev/null
@@ -1,142 +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 "SVGFEComponentTransfer.h"
-#include "TextStream.h"
-
-namespace WebCore {
-
-SVGFEComponentTransfer::SVGFEComponentTransfer(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
-{
-}
-
-SVGComponentTransferFunction SVGFEComponentTransfer::redFunction() const
-{
- return m_redFunc;
-}
-
-void SVGFEComponentTransfer::setRedFunction(const SVGComponentTransferFunction& func)
-{
- m_redFunc = func;
-}
-
-SVGComponentTransferFunction SVGFEComponentTransfer::greenFunction() const
-{
- return m_greenFunc;
-}
-
-void SVGFEComponentTransfer::setGreenFunction(const SVGComponentTransferFunction& func)
-{
- m_greenFunc = func;
-}
-
-SVGComponentTransferFunction SVGFEComponentTransfer::blueFunction() const
-{
- return m_blueFunc;
-}
-
-void SVGFEComponentTransfer::setBlueFunction(const SVGComponentTransferFunction& func)
-{
- m_blueFunc = func;
-}
-
-SVGComponentTransferFunction SVGFEComponentTransfer::alphaFunction() const
-{
- return m_alphaFunc;
-}
-
-void SVGFEComponentTransfer::setAlphaFunction(const SVGComponentTransferFunction& func)
-{
- m_alphaFunc = func;
-}
-
-static TextStream& operator<<(TextStream& ts, SVGComponentTransferType t)
-{
- switch (t)
- {
- case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
- ts << "UNKNOWN"; break;
- case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY:
- ts << "IDENTITY"; break;
- case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
- ts << "TABLE"; break;
- case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
- ts << "DISCRETE"; break;
- case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
- ts << "LINEAR"; break;
- case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
- ts << "GAMMA"; break;
- }
- return ts;
-}
-
-static TextStream& operator<<(TextStream& ts, const SVGComponentTransferFunction &func)
-{
- ts << "[type=" << func.type << "]";
- switch (func.type) {
- case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
- case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY:
- break;
- case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
- case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
- {
- ts << " [table values=";
- Vector<float>::const_iterator itr=func.tableValues.begin();
- if (itr != func.tableValues.end()) {
- ts << *itr++;
- for (; itr!=func.tableValues.end(); itr++) {
- ts << " " << *itr;
- }
- }
- ts << "]";
- break;
- }
- case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
- ts << " [slope=" << func.slope << "]"
- << " [intercept=" << func.intercept << "]";
- break;
- case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
- ts << " [amplitude=" << func.amplitude << "]"
- << " [exponent=" << func.exponent << "]"
- << " [offset=" << func.offset << "]";
- break;
- }
- return ts;
-}
-
-TextStream& SVGFEComponentTransfer::externalRepresentation(TextStream& ts) const
-{
- ts << "[type=COMPONENT-TRANSFER] ";
- SVGFilterEffect::externalRepresentation(ts);
- ts << " [red func=" << redFunction() << "]"
- << " [green func=" << greenFunction() << "]"
- << " [blue func=" << blueFunction() << "]"
- << " [alpha func=" << alphaFunction() << "]";
- return ts;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEComponentTransfer.h b/WebCore/svg/graphics/filters/SVGFEComponentTransfer.h
deleted file mode 100644
index 32d5e14..0000000
--- a/WebCore/svg/graphics/filters/SVGFEComponentTransfer.h
+++ /dev/null
@@ -1,110 +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 SVGFEComponentTransfer_h
-#define SVGFEComponentTransfer_h
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include <wtf/Vector.h>
-
-#include "SVGFilterEffect.h"
-#include "SVGFEDisplacementMap.h"
-
-#if PLATFORM(CI)
-#ifdef __OBJC__
-@class CIImage;
-@class CIFilter;
-#else
-class CIImage;
-class CIFilter;
-#endif
-#endif
-
-namespace WebCore {
-
-enum SVGComponentTransferType {
- SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN = 0,
- SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY = 1,
- SVG_FECOMPONENTTRANSFER_TYPE_TABLE = 2,
- SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE = 3,
- SVG_FECOMPONENTTRANSFER_TYPE_LINEAR = 4,
- SVG_FECOMPONENTTRANSFER_TYPE_GAMMA = 5
-};
-
-struct SVGComponentTransferFunction {
- SVGComponentTransferFunction()
- : type(SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN)
- , slope(0.0f)
- , intercept(0.0f)
- , amplitude(0.0f)
- , exponent(0.0f)
- , offset(0.0f)
- {
- }
-
- SVGComponentTransferType type;
-
- float slope;
- float intercept;
- float amplitude;
- float exponent;
- float offset;
-
- Vector<float> tableValues;
-};
-
-class SVGFEComponentTransfer : public SVGFilterEffect {
-public:
- SVGFEComponentTransfer(SVGResourceFilter*);
-
- SVGComponentTransferFunction redFunction() const;
- void setRedFunction(const SVGComponentTransferFunction&);
-
- SVGComponentTransferFunction greenFunction() const;
- void setGreenFunction(const SVGComponentTransferFunction&);
-
- SVGComponentTransferFunction blueFunction() const;
- void setBlueFunction(const SVGComponentTransferFunction&);
-
- SVGComponentTransferFunction alphaFunction() const;
- void setAlphaFunction(const SVGComponentTransferFunction&);
-
- virtual TextStream& externalRepresentation(TextStream&) const;
-
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-
-private:
- CIFilter* getFunctionFilter(SVGChannelSelectorType, CIImage* inputImage) const;
-#endif
-
-private:
- SVGComponentTransferFunction m_redFunc;
- SVGComponentTransferFunction m_greenFunc;
- SVGComponentTransferFunction m_blueFunc;
- SVGComponentTransferFunction m_alphaFunc;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
-
-#endif // SVGFEComponentTransfer_h
diff --git a/WebCore/svg/graphics/filters/SVGFEComposite.cpp b/WebCore/svg/graphics/filters/SVGFEComposite.cpp
deleted file mode 100644
index 4e0dfb5..0000000
--- a/WebCore/svg/graphics/filters/SVGFEComposite.cpp
+++ /dev/null
@@ -1,112 +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 "SVGFEComposite.h"
-#include "TextStream.h"
-
-namespace WebCore {
-
-SVGFEComposite::SVGFEComposite(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_operation(SVG_FECOMPOSITE_OPERATOR_UNKNOWN)
- , m_k1(0.0f)
- , m_k2(0.0f)
- , m_k3(0.0f)
- , m_k4(0.0f)
-{
-}
-
-String SVGFEComposite::in2() const
-{
- return m_in2;
-}
-
-void SVGFEComposite::setIn2(const String& in2)
-{
- m_in2 = in2;
-}
-
-SVGCompositeOperationType SVGFEComposite::operation() const
-{
- return m_operation;
-}
-
-void SVGFEComposite::setOperation(SVGCompositeOperationType oper)
-{
- m_operation = oper;
-}
-
-float SVGFEComposite::k1() const
-{
- return m_k1;
-}
-
-void SVGFEComposite::setK1(float k1)
-{
- m_k1 = k1;
-}
-
-float SVGFEComposite::k2() const
-{
- return m_k2;
-}
-
-void SVGFEComposite::setK2(float k2)
-{
- m_k2 = k2;
-}
-
-float SVGFEComposite::k3() const
-{
- return m_k3;
-}
-
-void SVGFEComposite::setK3(float k3)
-{
- m_k3 = k3;
-}
-
-float SVGFEComposite::k4() const
-{
- return m_k4;
-}
-
-void SVGFEComposite::setK4(float k4)
-{
- m_k4 = k4;
-}
-
-TextStream& SVGFEComposite::externalRepresentation(TextStream& ts) const
-{
- ts << "[type=COMPOSITE] ";
- SVGFilterEffect::externalRepresentation(ts);
- if (!in2().isEmpty())
- ts << " [in2=\"" << in2() << "\"]";
- ts << " [k1=" << k1() << " k2=" << k2() << " k3=" << k3() << " k4=" << k4() << "]";
- return ts;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/SVGFEComposite.h b/WebCore/svg/graphics/filters/SVGFEComposite.h
deleted file mode 100644
index 7a18047..0000000
--- a/WebCore/svg/graphics/filters/SVGFEComposite.h
+++ /dev/null
@@ -1,81 +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 SVGFEComposite_h
-#define SVGFEComposite_h
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
-
-namespace WebCore {
-
-enum SVGCompositeOperationType {
- SVG_FECOMPOSITE_OPERATOR_UNKNOWN = 0,
- SVG_FECOMPOSITE_OPERATOR_OVER = 1,
- SVG_FECOMPOSITE_OPERATOR_IN = 2,
- SVG_FECOMPOSITE_OPERATOR_OUT = 3,
- SVG_FECOMPOSITE_OPERATOR_ATOP = 4,
- SVG_FECOMPOSITE_OPERATOR_XOR = 5,
- SVG_FECOMPOSITE_OPERATOR_ARITHMETIC = 6
-};
-
-class SVGFEComposite : public SVGFilterEffect {
-public:
- SVGFEComposite(SVGResourceFilter*);
-
- String in2() const;
- void setIn2(const String&);
-
- SVGCompositeOperationType operation() const;
- void setOperation(SVGCompositeOperationType);
-
- float k1() const;
- void setK1(float);
-
- float k2() const;
- void setK2(float);
-
- float k3() const;
- void setK3(float);
-
- float k4() const;
- void setK4(float);
-
- virtual TextStream& externalRepresentation(TextStream&) const;
-
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
-
-private:
- SVGCompositeOperationType m_operation;
- float m_k1;
- float m_k2;
- float m_k3;
- float m_k4;
- String m_in2;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
-
-#endif // SVGFEComposite_h
diff --git a/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp
index af2b693..4b82e5a 100644
--- a/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp
+++ b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.cpp
@@ -22,131 +22,153 @@
#include "config.h"
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGRenderTreeAsText.h"
#include "SVGFEConvolveMatrix.h"
+#include "SVGRenderTreeAsText.h"
namespace WebCore {
-SVGFEConvolveMatrix::SVGFEConvolveMatrix(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_kernelSize()
- , m_divisor(0.0f)
- , m_bias(0.0f)
- , m_targetOffset()
- , m_edgeMode(SVG_EDGEMODE_UNKNOWN)
- , m_kernelUnitLength()
- , m_preserveAlpha(false)
+FEConvolveMatrix::FEConvolveMatrix(FilterEffect* in, FilterEffect* in2, const FloatSize& kernelSize,
+ const float& divisor, const float& bias, const FloatSize& targetOffset, EdgeModeType edgeMode,
+ const FloatPoint& kernelUnitLength, bool preserveAlpha, const Vector<float>& kernelMatrix)
+ : FilterEffect()
+ , m_in(in)
+ , m_in2(in2)
+ , m_kernelSize(kernelSize)
+ , m_divisor(divisor)
+ , m_bias(bias)
+ , m_targetOffset(targetOffset)
+ , m_edgeMode(edgeMode)
+ , m_kernelUnitLength(kernelUnitLength)
+ , m_preserveAlpha(preserveAlpha)
+ , m_kernelMatrix(kernelMatrix)
+{
+}
+
+PassRefPtr<FEConvolveMatrix> FEConvolveMatrix::create(FilterEffect* in, FilterEffect* in2, const FloatSize& kernelSize,
+ const float& divisor, const float& bias, const FloatSize& targetOffset, EdgeModeType edgeMode,
+ const FloatPoint& kernelUnitLength, bool preserveAlpha, const Vector<float>& kernelMatrix)
{
+ return adoptRef(new FEConvolveMatrix(in, in2, kernelSize, divisor, bias, targetOffset, edgeMode, kernelUnitLength,
+ preserveAlpha, kernelMatrix));
}
-FloatSize SVGFEConvolveMatrix::kernelSize() const
+
+FloatSize FEConvolveMatrix::kernelSize() const
{
return m_kernelSize;
}
-void SVGFEConvolveMatrix::setKernelSize(FloatSize kernelSize)
+void FEConvolveMatrix::setKernelSize(FloatSize kernelSize)
{
m_kernelSize = kernelSize;
}
-const Vector<float>& SVGFEConvolveMatrix::kernel() const
+const Vector<float>& FEConvolveMatrix::kernel() const
{
return m_kernelMatrix;
}
-void SVGFEConvolveMatrix::setKernel(const Vector<float>& kernel)
+void FEConvolveMatrix::setKernel(const Vector<float>& kernel)
{
m_kernelMatrix = kernel;
}
-float SVGFEConvolveMatrix::divisor() const
+float FEConvolveMatrix::divisor() const
{
return m_divisor;
}
-void SVGFEConvolveMatrix::setDivisor(float divisor)
+void FEConvolveMatrix::setDivisor(float divisor)
{
m_divisor = divisor;
}
-float SVGFEConvolveMatrix::bias() const
+float FEConvolveMatrix::bias() const
{
return m_bias;
}
-void SVGFEConvolveMatrix::setBias(float bias)
+void FEConvolveMatrix::setBias(float bias)
{
m_bias = bias;
}
-FloatSize SVGFEConvolveMatrix::targetOffset() const
+FloatSize FEConvolveMatrix::targetOffset() const
{
return m_targetOffset;
}
-void SVGFEConvolveMatrix::setTargetOffset(FloatSize targetOffset)
+void FEConvolveMatrix::setTargetOffset(FloatSize targetOffset)
{
m_targetOffset = targetOffset;
}
-SVGEdgeModeType SVGFEConvolveMatrix::edgeMode() const
+EdgeModeType FEConvolveMatrix::edgeMode() const
{
return m_edgeMode;
}
-void SVGFEConvolveMatrix::setEdgeMode(SVGEdgeModeType edgeMode)
+void FEConvolveMatrix::setEdgeMode(EdgeModeType edgeMode)
{
m_edgeMode = edgeMode;
}
-FloatPoint SVGFEConvolveMatrix::kernelUnitLength() const
+FloatPoint FEConvolveMatrix::kernelUnitLength() const
{
return m_kernelUnitLength;
}
-void SVGFEConvolveMatrix::setKernelUnitLength(FloatPoint kernelUnitLength)
+void FEConvolveMatrix::setKernelUnitLength(FloatPoint kernelUnitLength)
{
m_kernelUnitLength = kernelUnitLength;
}
-bool SVGFEConvolveMatrix::preserveAlpha() const
+bool FEConvolveMatrix::preserveAlpha() const
{
return m_preserveAlpha;
}
-void SVGFEConvolveMatrix::setPreserveAlpha(bool preserveAlpha)
+void FEConvolveMatrix::setPreserveAlpha(bool preserveAlpha)
{
m_preserveAlpha = preserveAlpha;
}
-static TextStream& operator<<(TextStream& ts, SVGEdgeModeType t)
+void FEConvolveMatrix::apply()
+{
+}
+
+void FEConvolveMatrix::dump()
+{
+}
+
+static TextStream& operator<<(TextStream& ts, EdgeModeType t)
{
switch (t)
{
- case SVG_EDGEMODE_UNKNOWN:
+ case EDGEMODE_UNKNOWN:
ts << "UNKNOWN";break;
- case SVG_EDGEMODE_DUPLICATE:
+ case EDGEMODE_DUPLICATE:
ts << "DUPLICATE";break;
- case SVG_EDGEMODE_WRAP:
+ case EDGEMODE_WRAP:
ts << "WRAP"; break;
- case SVG_EDGEMODE_NONE:
+ case EDGEMODE_NONE:
ts << "NONE"; break;
}
return ts;
}
-TextStream& SVGFEConvolveMatrix::externalRepresentation(TextStream& ts) const
+TextStream& FEConvolveMatrix::externalRepresentation(TextStream& ts) const
{
ts << "[type=CONVOLVE-MATRIX] ";
- SVGFilterEffect::externalRepresentation(ts);
+ FilterEffect::externalRepresentation(ts);
ts << " [order " << m_kernelSize << "]"
- << " [kernel matrix=" << m_kernelMatrix << "]"
- << " [divisor=" << m_divisor << "]"
- << " [bias=" << m_bias << "]"
- << " [target " << m_targetOffset << "]"
- << " [edge mode=" << m_edgeMode << "]"
- << " [kernel unit length " << m_kernelUnitLength << "]"
- << " [preserve alpha=" << m_preserveAlpha << "]";
+ << " [kernel matrix=" << m_kernelMatrix << "]"
+ << " [divisor=" << m_divisor << "]"
+ << " [bias=" << m_bias << "]"
+ << " [target " << m_targetOffset << "]"
+ << " [edge mode=" << m_edgeMode << "]"
+ << " [kernel unit length " << m_kernelUnitLength << "]"
+ << " [preserve alpha=" << m_preserveAlpha << "]";
return ts;
}
diff --git a/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h
index b9744fa..c3eea2b 100644
--- a/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h
+++ b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h
@@ -23,57 +23,70 @@
#define SVGFEConvolveMatrix_h
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
+#include "FilterEffect.h"
+#include "FloatPoint.h"
+#include "FloatSize.h"
-namespace WebCore {
-
-enum SVGEdgeModeType {
- SVG_EDGEMODE_UNKNOWN = 0,
- SVG_EDGEMODE_DUPLICATE = 1,
- SVG_EDGEMODE_WRAP = 2,
- SVG_EDGEMODE_NONE = 3
-};
-
-class SVGFEConvolveMatrix : public SVGFilterEffect {
-public:
- SVGFEConvolveMatrix(SVGResourceFilter*);
-
- FloatSize kernelSize() const;
- void setKernelSize(FloatSize);
-
- const Vector<float>& kernel() const;
- void setKernel(const Vector<float>&);
-
- float divisor() const;
- void setDivisor(float);
+#include <wtf/Vector.h>
- float bias() const;
- void setBias(float);
-
- FloatSize targetOffset() const;
- void setTargetOffset(FloatSize);
-
- SVGEdgeModeType edgeMode() const;
- void setEdgeMode(SVGEdgeModeType);
-
- FloatPoint kernelUnitLength() const;
- void setKernelUnitLength(FloatPoint);
-
- bool preserveAlpha() const;
- void setPreserveAlpha(bool);
-
- virtual TextStream& externalRepresentation(TextStream&) const;
+namespace WebCore {
-private:
- FloatSize m_kernelSize;
- float m_divisor;
- float m_bias;
- FloatSize m_targetOffset;
- SVGEdgeModeType m_edgeMode;
- FloatPoint m_kernelUnitLength;
- bool m_preserveAlpha;
- Vector<float> m_kernelMatrix; // maybe should be a real matrix?
-};
+ enum EdgeModeType {
+ EDGEMODE_UNKNOWN = 0,
+ EDGEMODE_DUPLICATE = 1,
+ EDGEMODE_WRAP = 2,
+ EDGEMODE_NONE = 3
+ };
+
+ class FEConvolveMatrix : public FilterEffect {
+ public:
+ static PassRefPtr<FEConvolveMatrix> create(FilterEffect*, FilterEffect*, const FloatSize&,
+ const float&, const float&, const FloatSize&, EdgeModeType, const FloatPoint&,
+ bool, const Vector<float>&);
+
+ FloatSize kernelSize() const;
+ void setKernelSize(FloatSize);
+
+ const Vector<float>& kernel() const;
+ void setKernel(const Vector<float>&);
+
+ float divisor() const;
+ void setDivisor(float);
+
+ float bias() const;
+ void setBias(float);
+
+ FloatSize targetOffset() const;
+ void setTargetOffset(FloatSize);
+
+ EdgeModeType edgeMode() const;
+ void setEdgeMode(EdgeModeType);
+
+ FloatPoint kernelUnitLength() const;
+ void setKernelUnitLength(FloatPoint);
+
+ bool preserveAlpha() const;
+ void setPreserveAlpha(bool);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEConvolveMatrix(FilterEffect*, FilterEffect*, const FloatSize&, const float&, const float&,
+ const FloatSize&, EdgeModeType, const FloatPoint&, bool, const Vector<float>&);
+
+ RefPtr<FilterEffect> m_in;
+ RefPtr<FilterEffect> m_in2;
+ FloatSize m_kernelSize;
+ float m_divisor;
+ float m_bias;
+ FloatSize m_targetOffset;
+ EdgeModeType m_edgeMode;
+ FloatPoint m_kernelUnitLength;
+ bool m_preserveAlpha;
+ Vector<float> m_kernelMatrix;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp
index 2504ca6..6399c5e 100644
--- a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp
+++ b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp
@@ -24,93 +24,106 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "SVGLightSource.h"
#include "SVGFEDiffuseLighting.h"
-#include "TextStream.h"
+#include "SVGRenderTreeAsText.h"
namespace WebCore {
-SVGFEDiffuseLighting::SVGFEDiffuseLighting(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_lightingColor()
- , m_surfaceScale(0.0f)
- , m_diffuseConstant(0.0f)
- , m_kernelUnitLengthX(0.0f)
- , m_kernelUnitLengthY(0.0f)
- , m_lightSource(0)
+FEDiffuseLighting::FEDiffuseLighting(FilterEffect* in , const Color& lightingColor, const float& surfaceScale,
+ const float& diffuseConstant, const float& kernelUnitLengthX, const float& kernelUnitLengthY, LightSource* lightSource)
+ : FilterEffect()
+ , m_in(in)
+ , m_lightingColor(lightingColor)
+ , m_surfaceScale(surfaceScale)
+ , m_diffuseConstant(diffuseConstant)
+ , m_kernelUnitLengthX(kernelUnitLengthX)
+ , m_kernelUnitLengthY(kernelUnitLengthY)
+ , m_lightSource(lightSource)
{
}
-SVGFEDiffuseLighting::~SVGFEDiffuseLighting()
+PassRefPtr<FEDiffuseLighting> FEDiffuseLighting::create(FilterEffect* in , const Color& lightingColor,
+ const float& surfaceScale, const float& diffuseConstant, const float& kernelUnitLengthX,
+ const float& kernelUnitLengthY, LightSource* lightSource)
{
- delete m_lightSource;
+ return adoptRef(new FEDiffuseLighting(in, lightingColor, surfaceScale, diffuseConstant, kernelUnitLengthX, kernelUnitLengthY, lightSource));
}
-Color SVGFEDiffuseLighting::lightingColor() const
+FEDiffuseLighting::~FEDiffuseLighting()
+{
+}
+
+Color FEDiffuseLighting::lightingColor() const
{
return m_lightingColor;
}
-void SVGFEDiffuseLighting::setLightingColor(const Color& lightingColor)
+void FEDiffuseLighting::setLightingColor(const Color& lightingColor)
{
m_lightingColor = lightingColor;
}
-float SVGFEDiffuseLighting::surfaceScale() const
+float FEDiffuseLighting::surfaceScale() const
{
return m_surfaceScale;
}
-void SVGFEDiffuseLighting::setSurfaceScale(float surfaceScale)
+void FEDiffuseLighting::setSurfaceScale(float surfaceScale)
{
m_surfaceScale = surfaceScale;
}
-float SVGFEDiffuseLighting::diffuseConstant() const
+float FEDiffuseLighting::diffuseConstant() const
{
return m_diffuseConstant;
}
-void SVGFEDiffuseLighting::setDiffuseConstant(float diffuseConstant)
+void FEDiffuseLighting::setDiffuseConstant(float diffuseConstant)
{
m_diffuseConstant = diffuseConstant;
}
-float SVGFEDiffuseLighting::kernelUnitLengthX() const
+float FEDiffuseLighting::kernelUnitLengthX() const
{
return m_kernelUnitLengthX;
}
-void SVGFEDiffuseLighting::setKernelUnitLengthX(float kernelUnitLengthX)
+void FEDiffuseLighting::setKernelUnitLengthX(float kernelUnitLengthX)
{
m_kernelUnitLengthX = kernelUnitLengthX;
}
-float SVGFEDiffuseLighting::kernelUnitLengthY() const
+float FEDiffuseLighting::kernelUnitLengthY() const
{
return m_kernelUnitLengthY;
}
-void SVGFEDiffuseLighting::setKernelUnitLengthY(float kernelUnitLengthY)
+void FEDiffuseLighting::setKernelUnitLengthY(float kernelUnitLengthY)
{
m_kernelUnitLengthY = kernelUnitLengthY;
}
-const SVGLightSource* SVGFEDiffuseLighting::lightSource() const
+const LightSource* FEDiffuseLighting::lightSource() const
{
- return m_lightSource;
+ return m_lightSource.get();
}
-void SVGFEDiffuseLighting::setLightSource(SVGLightSource* lightSource)
+void FEDiffuseLighting::setLightSource(LightSource* lightSource)
{
- if (m_lightSource != lightSource) {
- delete m_lightSource;
- m_lightSource = lightSource;
- }
+ m_lightSource = lightSource;
+}
+
+void FEDiffuseLighting::apply()
+{
+}
+
+void FEDiffuseLighting::dump()
+{
}
-TextStream& SVGFEDiffuseLighting::externalRepresentation(TextStream& ts) const
+TextStream& FEDiffuseLighting::externalRepresentation(TextStream& ts) const
{
ts << "[type=DIFFUSE-LIGHTING] ";
- SVGFilterEffect::externalRepresentation(ts);
+ FilterEffect::externalRepresentation(ts);
ts << " [surface scale=" << m_surfaceScale << "]"
<< " [diffuse constant=" << m_diffuseConstant << "]"
<< " [kernel unit length " << m_kernelUnitLengthX << ", " << m_kernelUnitLengthY << "]";
diff --git a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h
index a2ed775..a817ce2 100644
--- a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h
+++ b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h
@@ -24,49 +24,52 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "Color.h"
-#include "SVGFilterEffect.h"
+#include "FilterEffect.h"
namespace WebCore {
-class SVGLightSource;
+ class LightSource;
-class SVGFEDiffuseLighting : public SVGFilterEffect {
-public:
- SVGFEDiffuseLighting(SVGResourceFilter*);
- virtual ~SVGFEDiffuseLighting();
+ class FEDiffuseLighting : public FilterEffect {
+ public:
+ static PassRefPtr<FEDiffuseLighting> create(FilterEffect*, const Color&, const float&, const float&,
+ const float&, const float&, LightSource*);
+ virtual ~FEDiffuseLighting();
- Color lightingColor() const;
- void setLightingColor(const Color&);
+ Color lightingColor() const;
+ void setLightingColor(const Color&);
- float surfaceScale() const;
- void setSurfaceScale(float);
+ float surfaceScale() const;
+ void setSurfaceScale(float);
- float diffuseConstant() const;
- void setDiffuseConstant(float);
+ float diffuseConstant() const;
+ void setDiffuseConstant(float);
- float kernelUnitLengthX() const;
- void setKernelUnitLengthX(float);
+ float kernelUnitLengthX() const;
+ void setKernelUnitLengthX(float);
- float kernelUnitLengthY() const;
- void setKernelUnitLengthY(float);
+ float kernelUnitLengthY() const;
+ void setKernelUnitLengthY(float);
- const SVGLightSource* lightSource() const;
- void setLightSource(SVGLightSource*);
+ const LightSource* lightSource() const;
+ void setLightSource(LightSource*);
- virtual TextStream& externalRepresentation(TextStream&) const;
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEDiffuseLighting(FilterEffect*, const Color&, const float&, const float&,
+ const float&, const float&, LightSource*);
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
-
-private:
- Color m_lightingColor;
- float m_surfaceScale;
- float m_diffuseConstant;
- float m_kernelUnitLengthX;
- float m_kernelUnitLengthY;
- SVGLightSource* m_lightSource;
-};
+ RefPtr<FilterEffect> m_in;
+ Color m_lightingColor;
+ float m_surfaceScale;
+ float m_diffuseConstant;
+ float m_kernelUnitLengthX;
+ float m_kernelUnitLengthY;
+ RefPtr<LightSource> m_lightSource;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp
index 39b012b..f7996e3 100644
--- a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp
+++ b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp
@@ -22,84 +22,90 @@
#include "config.h"
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGRenderTreeAsText.h"
#include "SVGFEDisplacementMap.h"
+#include "SVGRenderTreeAsText.h"
namespace WebCore {
-SVGFEDisplacementMap::SVGFEDisplacementMap(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_xChannelSelector(SVG_CHANNEL_UNKNOWN)
- , m_yChannelSelector(SVG_CHANNEL_UNKNOWN)
- , m_scale(0)
-{
-}
-
-String SVGFEDisplacementMap::in2() const
+FEDisplacementMap::FEDisplacementMap(FilterEffect* in, FilterEffect* in2, ChannelSelectorType xChannelSelector,
+ ChannelSelectorType yChannelSelector, const float& scale)
+ : FilterEffect()
+ , m_in(in)
+ , m_in2(in2)
+ , m_xChannelSelector(xChannelSelector)
+ , m_yChannelSelector(yChannelSelector)
+ , m_scale(scale)
{
- return m_in2;
}
-void SVGFEDisplacementMap::setIn2(const String &in2)
+PassRefPtr<FEDisplacementMap> FEDisplacementMap::create(FilterEffect* in, FilterEffect* in2,
+ ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, const float& scale)
{
- m_in2 = in2;
+ return adoptRef(new FEDisplacementMap(in, in2, xChannelSelector, yChannelSelector, scale));
}
-SVGChannelSelectorType SVGFEDisplacementMap::xChannelSelector() const
+ChannelSelectorType FEDisplacementMap::xChannelSelector() const
{
return m_xChannelSelector;
}
-void SVGFEDisplacementMap::setXChannelSelector(const SVGChannelSelectorType xChannelSelector)
+void FEDisplacementMap::setXChannelSelector(const ChannelSelectorType xChannelSelector)
{
m_xChannelSelector = xChannelSelector;
}
-SVGChannelSelectorType SVGFEDisplacementMap::yChannelSelector() const
+ChannelSelectorType FEDisplacementMap::yChannelSelector() const
{
return m_yChannelSelector;
}
-void SVGFEDisplacementMap::setYChannelSelector(const SVGChannelSelectorType yChannelSelector)
+void FEDisplacementMap::setYChannelSelector(const ChannelSelectorType yChannelSelector)
{
m_yChannelSelector = yChannelSelector;
}
-float SVGFEDisplacementMap::scale() const
+float FEDisplacementMap::scale() const
{
return m_scale;
}
-void SVGFEDisplacementMap::setScale(float scale)
+void FEDisplacementMap::setScale(float scale)
{
m_scale = scale;
}
-static TextStream& operator<<(TextStream& ts, SVGChannelSelectorType t)
+void FEDisplacementMap::apply()
+{
+}
+
+void FEDisplacementMap::dump()
+{
+}
+
+static TextStream& operator<<(TextStream& ts, ChannelSelectorType t)
{
switch (t)
{
- case SVG_CHANNEL_UNKNOWN:
+ case CHANNEL_UNKNOWN:
ts << "UNKNOWN"; break;
- case SVG_CHANNEL_R:
+ case CHANNEL_R:
ts << "RED"; break;
- case SVG_CHANNEL_G:
+ case CHANNEL_G:
ts << "GREEN"; break;
- case SVG_CHANNEL_B:
+ case CHANNEL_B:
ts << "BLUE"; break;
- case SVG_CHANNEL_A:
+ case CHANNEL_A:
ts << "ALPHA"; break;
}
return ts;
}
-TextStream& SVGFEDisplacementMap::externalRepresentation(TextStream& ts) const
+TextStream& FEDisplacementMap::externalRepresentation(TextStream& ts) const
{
ts << "[type=DISPLACEMENT-MAP] ";
- SVGFilterEffect::externalRepresentation(ts);
- if (!in2().isEmpty())
- ts << " [in2=" << in2() << "]";
- ts << " [scale=" << m_scale << "]"
+ FilterEffect::externalRepresentation(ts);
+ ts << " [in2=" << m_in2.get() << "]"
+ << " [scale=" << m_scale << "]"
<< " [x channel selector=" << m_xChannelSelector << "]"
<< " [y channel selector=" << m_yChannelSelector << "]";
return ts;
diff --git a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h
index bc45728..0218d57 100644
--- a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h
+++ b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h
@@ -23,46 +23,47 @@
#define SVGFEDisplacementMap_h
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
+#include "PlatformString.h"
+#include "FilterEffect.h"
namespace WebCore {
-enum SVGChannelSelectorType {
- SVG_CHANNEL_UNKNOWN = 0,
- SVG_CHANNEL_R = 1,
- SVG_CHANNEL_G = 2,
- SVG_CHANNEL_B = 3,
- SVG_CHANNEL_A = 4
-};
-
-class SVGFEDisplacementMap : public SVGFilterEffect {
-public:
- SVGFEDisplacementMap(SVGResourceFilter*);
-
- String in2() const;
- void setIn2(const String&);
-
- SVGChannelSelectorType xChannelSelector() const;
- void setXChannelSelector(const SVGChannelSelectorType);
-
- SVGChannelSelectorType yChannelSelector() const;
- void setYChannelSelector(const SVGChannelSelectorType);
-
- float scale() const;
- void setScale(float scale);
-
- virtual TextStream& externalRepresentation(TextStream&) const;
-
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
-
-private:
- SVGChannelSelectorType m_xChannelSelector;
- SVGChannelSelectorType m_yChannelSelector;
- float m_scale;
- String m_in2;
-};
+ enum ChannelSelectorType {
+ CHANNEL_UNKNOWN = 0,
+ CHANNEL_R = 1,
+ CHANNEL_G = 2,
+ CHANNEL_B = 3,
+ CHANNEL_A = 4
+ };
+
+ class FEDisplacementMap : public FilterEffect {
+ public:
+ static PassRefPtr<FEDisplacementMap> create(FilterEffect*, FilterEffect*, ChannelSelectorType,
+ ChannelSelectorType, const float&);
+
+ ChannelSelectorType xChannelSelector() const;
+ void setXChannelSelector(const ChannelSelectorType);
+
+ ChannelSelectorType yChannelSelector() const;
+ void setYChannelSelector(const ChannelSelectorType);
+
+ float scale() const;
+ void setScale(float scale);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEDisplacementMap(FilterEffect*, FilterEffect*, ChannelSelectorType,
+ ChannelSelectorType, const float&);
+
+ RefPtr<FilterEffect> m_in;
+ RefPtr<FilterEffect> m_in2;
+ ChannelSelectorType m_xChannelSelector;
+ ChannelSelectorType m_yChannelSelector;
+ float m_scale;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFEFlood.cpp b/WebCore/svg/graphics/filters/SVGFEFlood.cpp
index 2baeb2e..3d52f63 100644
--- a/WebCore/svg/graphics/filters/SVGFEFlood.cpp
+++ b/WebCore/svg/graphics/filters/SVGFEFlood.cpp
@@ -22,42 +22,55 @@
#include "config.h"
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGRenderTreeAsText.h"
#include "SVGFEFlood.h"
+#include "SVGRenderTreeAsText.h"
namespace WebCore {
-SVGFEFlood::SVGFEFlood(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_floodColor()
- , m_floodOpacity(0.0f)
+FEFlood::FEFlood(const Color& floodColor, const float& floodOpacity)
+ : FilterEffect()
+ , m_floodColor(floodColor)
+ , m_floodOpacity(floodOpacity)
+{
+}
+
+PassRefPtr<FEFlood> FEFlood::create(const Color& floodColor, const float& floodOpacity)
{
+ return adoptRef(new FEFlood(floodColor, floodOpacity));
}
-Color SVGFEFlood::floodColor() const
+Color FEFlood::floodColor() const
{
return m_floodColor;
}
-void SVGFEFlood::setFloodColor(const Color& color)
+void FEFlood::setFloodColor(const Color& color)
{
m_floodColor = color;
}
-float SVGFEFlood::floodOpacity() const
+float FEFlood::floodOpacity() const
{
return m_floodOpacity;
}
-void SVGFEFlood::setFloodOpacity(float floodOpacity)
+void FEFlood::setFloodOpacity(float floodOpacity)
{
m_floodOpacity = floodOpacity;
}
-TextStream& SVGFEFlood::externalRepresentation(TextStream& ts) const
+void FEFlood::apply()
+{
+}
+
+void FEFlood::dump()
+{
+}
+
+TextStream& FEFlood::externalRepresentation(TextStream& ts) const
{
ts << "[type=FLOOD] ";
- SVGFilterEffect::externalRepresentation(ts);
+ FilterEffect::externalRepresentation(ts);
ts << " [color=" << floodColor() << "]"
<< " [opacity=" << floodOpacity() << "]";
return ts;
diff --git a/WebCore/svg/graphics/filters/SVGFEFlood.h b/WebCore/svg/graphics/filters/SVGFEFlood.h
index 4cadf9a..0558774 100644
--- a/WebCore/svg/graphics/filters/SVGFEFlood.h
+++ b/WebCore/svg/graphics/filters/SVGFEFlood.h
@@ -24,30 +24,30 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "Color.h"
-#include "SVGFilterEffect.h"
+#include "FilterEffect.h"
namespace WebCore {
-class SVGFEFlood : public SVGFilterEffect {
-public:
- SVGFEFlood(SVGResourceFilter*);
+ class FEFlood : public FilterEffect {
+ public:
+ static PassRefPtr<FEFlood> create(const Color&, const float&);
- Color floodColor() const;
- void setFloodColor(const Color &);
+ Color floodColor() const;
+ void setFloodColor(const Color &);
- float floodOpacity() const;
- void setFloodOpacity(float);
+ float floodOpacity() const;
+ void setFloodOpacity(float);
- virtual TextStream& externalRepresentation(TextStream&) const;
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
+ private:
+ FEFlood(const Color&, const float&);
-private:
- Color m_floodColor;
- float m_floodOpacity;
-};
+ Color m_floodColor;
+ float m_floodOpacity;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp
index aef9aad..4e64c58 100644
--- a/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp
+++ b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp
@@ -23,41 +23,55 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "SVGFEGaussianBlur.h"
-#include "TextStream.h"
+#include "SVGRenderTreeAsText.h"
namespace WebCore {
-SVGFEGaussianBlur::SVGFEGaussianBlur(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_x(0.0f)
- , m_y(0.0f)
+FEGaussianBlur::FEGaussianBlur(FilterEffect* in, const float& x, const float& y)
+ : FilterEffect()
+ , m_in(in)
+ , m_x(x)
+ , m_y(y)
{
}
-float SVGFEGaussianBlur::stdDeviationX() const
+PassRefPtr<FEGaussianBlur> FEGaussianBlur::create(FilterEffect* in, const float& x, const float& y)
+{
+ return adoptRef(new FEGaussianBlur(in, x, y));
+}
+
+float FEGaussianBlur::stdDeviationX() const
{
return m_x;
}
-void SVGFEGaussianBlur::setStdDeviationX(float x)
+void FEGaussianBlur::setStdDeviationX(float x)
{
m_x = x;
}
-float SVGFEGaussianBlur::stdDeviationY() const
+float FEGaussianBlur::stdDeviationY() const
{
return m_y;
}
-void SVGFEGaussianBlur::setStdDeviationY(float y)
+void FEGaussianBlur::setStdDeviationY(float y)
{
m_y = y;
}
-TextStream& SVGFEGaussianBlur::externalRepresentation(TextStream& ts) const
+void FEGaussianBlur::apply()
+{
+}
+
+void FEGaussianBlur::dump()
+{
+}
+
+TextStream& FEGaussianBlur::externalRepresentation(TextStream& ts) const
{
ts << "[type=GAUSSIAN-BLUR] ";
- SVGFilterEffect::externalRepresentation(ts);
+ FilterEffect::externalRepresentation(ts);
ts << " [std dev. x=" << stdDeviationX() << " y=" << stdDeviationY() << "]";
return ts;
}
diff --git a/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h
index 28cb9e0..33ad0c7 100644
--- a/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h
+++ b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h
@@ -23,30 +23,31 @@
#define SVGFEGaussianBlur_h
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
+#include "FilterEffect.h"
namespace WebCore {
-class SVGFEGaussianBlur : public SVGFilterEffect {
-public:
- SVGFEGaussianBlur(SVGResourceFilter*);
+ class FEGaussianBlur : public FilterEffect {
+ public:
+ static PassRefPtr<FEGaussianBlur> create(FilterEffect*, const float&, const float&);
- float stdDeviationX() const;
- void setStdDeviationX(float);
+ float stdDeviationX() const;
+ void setStdDeviationX(float);
- float stdDeviationY() const;
- void setStdDeviationY(float);
+ float stdDeviationY() const;
+ void setStdDeviationY(float);
- virtual TextStream& externalRepresentation(TextStream&) const;
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
+ private:
+ FEGaussianBlur(FilterEffect*, const float&, const float&);
-private:
- float m_x;
- float m_y;
-};
+ RefPtr<FilterEffect> m_in;
+ float m_x;
+ float m_y;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFEImage.cpp b/WebCore/svg/graphics/filters/SVGFEImage.cpp
index 0c9eaee..2bf83be 100644
--- a/WebCore/svg/graphics/filters/SVGFEImage.cpp
+++ b/WebCore/svg/graphics/filters/SVGFEImage.cpp
@@ -23,56 +23,60 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "SVGFEImage.h"
-
-#include "SVGResourceFilter.h"
-#include "TextStream.h"
+#include "SVGRenderTreeAsText.h"
namespace WebCore {
-SVGFEImage::SVGFEImage(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_cachedImage(0)
+FEImage::FEImage(CachedImage* cachedImage)
+ : FilterEffect()
+ , m_cachedImage(cachedImage)
+{
+}
+
+PassRefPtr<FEImage> FEImage::create(CachedImage* cachedImage)
{
+ return adoptRef(new FEImage(cachedImage));
}
-SVGFEImage::~SVGFEImage()
+FEImage::~FEImage()
{
if (m_cachedImage)
- m_cachedImage->deref(this);
+ m_cachedImage->removeClient(this);
}
-CachedImage* SVGFEImage::cachedImage() const
+CachedImage* FEImage::cachedImage() const
{
- return m_cachedImage;
+ return m_cachedImage.get();
}
-void SVGFEImage::setCachedImage(CachedImage* image)
+void FEImage::setCachedImage(CachedImage* image)
{
if (m_cachedImage == image)
return;
if (m_cachedImage)
- m_cachedImage->deref(this);
+ m_cachedImage->removeClient(this);
m_cachedImage = image;
if (m_cachedImage)
- m_cachedImage->ref(this);
+ m_cachedImage->addClient(this);
}
-TextStream& SVGFEImage::externalRepresentation(TextStream& ts) const
+void FEImage::apply()
{
- ts << "[type=IMAGE] ";
- SVGFilterEffect::externalRepresentation(ts);
- // FIXME: should this dump also object returned by SVGFEImage::image() ?
- return ts;
+}
+void FEImage::dump()
+{
}
-void SVGFEImage::imageChanged(CachedImage*)
+TextStream& FEImage::externalRepresentation(TextStream& ts) const
{
- if (SVGResourceFilter* filterResource = filter())
- filterResource->invalidate();
+ ts << "[type=IMAGE] ";
+ FilterEffect::externalRepresentation(ts);
+ // FIXME: should this dump also object returned by SVGFEImage::image() ?
+ return ts;
}
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFEImage.h b/WebCore/svg/graphics/filters/SVGFEImage.h
index 8245d10..fcf413f 100644
--- a/WebCore/svg/graphics/filters/SVGFEImage.h
+++ b/WebCore/svg/graphics/filters/SVGFEImage.h
@@ -25,32 +25,31 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "CachedImage.h"
#include "CachedResourceClient.h"
-#include "SVGFilterEffect.h"
+#include "CachedResourceHandle.h"
+#include "FilterEffect.h"
namespace WebCore {
-class SVGFEImage : public SVGFilterEffect
- , public CachedResourceClient {
-public:
- SVGFEImage(SVGResourceFilter*);
- virtual ~SVGFEImage();
-
- // FIXME: We need to support <svg> (RenderObject*) as well as image data.
-
- CachedImage* cachedImage() const;
- void setCachedImage(CachedImage*);
-
- virtual TextStream& externalRepresentation(TextStream&) const;
-
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
-
- virtual void imageChanged(CachedImage*);
-
-private:
- CachedImage* m_cachedImage;
-};
+ class FEImage : public FilterEffect
+ , public CachedResourceClient {
+ public:
+ static PassRefPtr<FEImage> create(CachedImage*);
+ virtual ~FEImage();
+
+ // FIXME: We need to support <svg> (RenderObject*) as well as image data.
+
+ CachedImage* cachedImage() const;
+ void setCachedImage(CachedImage*);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEImage(CachedImage*);
+
+ CachedResourceHandle<CachedImage> m_cachedImage;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFEMerge.cpp b/WebCore/svg/graphics/filters/SVGFEMerge.cpp
index f4cf2db..8ce15a7 100644
--- a/WebCore/svg/graphics/filters/SVGFEMerge.cpp
+++ b/WebCore/svg/graphics/filters/SVGFEMerge.cpp
@@ -23,24 +23,43 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "SVGFEMerge.h"
-#include "TextStream.h"
+#include "SVGRenderTreeAsText.h"
namespace WebCore {
-const Vector<String>& SVGFEMerge::mergeInputs() const
+FEMerge::FEMerge(const Vector<FilterEffect*>& mergeInputs)
+ : FilterEffect()
+ , m_mergeInputs(mergeInputs)
+{
+}
+
+PassRefPtr<FEMerge> FEMerge::create(const Vector<FilterEffect*>& mergeInputs)
+{
+ return adoptRef(new FEMerge(mergeInputs));
+}
+
+const Vector<FilterEffect*>& FEMerge::mergeInputs() const
{
return m_mergeInputs;
}
-void SVGFEMerge::setMergeInputs(const Vector<String>& mergeInputs)
+void FEMerge::setMergeInputs(const Vector<FilterEffect*>& mergeInputs)
{
m_mergeInputs = mergeInputs;
}
-TextStream& SVGFEMerge::externalRepresentation(TextStream& ts) const
+void FEMerge::apply()
+{
+}
+
+void FEMerge::dump()
+{
+}
+
+TextStream& FEMerge::externalRepresentation(TextStream& ts) const
{
ts << "[type=MERGE] ";
- SVGFilterEffect::externalRepresentation(ts);
+ FilterEffect::externalRepresentation(ts);
ts << "[merge inputs=[";
unsigned x = 0;
unsigned size = m_mergeInputs.size();
diff --git a/WebCore/svg/graphics/filters/SVGFEMerge.h b/WebCore/svg/graphics/filters/SVGFEMerge.h
index 9a0e867..6415c9f 100644
--- a/WebCore/svg/graphics/filters/SVGFEMerge.h
+++ b/WebCore/svg/graphics/filters/SVGFEMerge.h
@@ -23,26 +23,28 @@
#define SVGFEMerge_h
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
+#include "FilterEffect.h"
-namespace WebCore {
+#include <wtf/Vector.h>
-class SVGFEMerge : public SVGFilterEffect {
-public:
- SVGFEMerge(SVGResourceFilter* filter) : SVGFilterEffect(filter) { }
+namespace WebCore {
- const Vector<String>& mergeInputs() const;
- void setMergeInputs(const Vector<String>& mergeInputs);
+ class FEMerge : public FilterEffect {
+ public:
+ static PassRefPtr<FEMerge> create(const Vector<FilterEffect*>&);
- virtual TextStream& externalRepresentation(TextStream&) const;
+ const Vector<FilterEffect*>& mergeInputs() const;
+ void setMergeInputs(const Vector<FilterEffect*>& mergeInputs);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
+ private:
+ FEMerge(const Vector<FilterEffect*>&);
-private:
- Vector<String> m_mergeInputs;
-};
+ Vector<FilterEffect*> m_mergeInputs;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFEMorphology.cpp b/WebCore/svg/graphics/filters/SVGFEMorphology.cpp
index 4eaad67..7838a8c 100644
--- a/WebCore/svg/graphics/filters/SVGFEMorphology.cpp
+++ b/WebCore/svg/graphics/filters/SVGFEMorphology.cpp
@@ -23,68 +23,82 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "SVGFEMorphology.h"
-#include "TextStream.h"
+#include "SVGRenderTreeAsText.h"
namespace WebCore {
-SVGFEMorphology::SVGFEMorphology(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_operator(SVG_MORPHOLOGY_OPERATOR_UNKNOWN)
- , m_radiusX(0.0f)
- , m_radiusY(0.0f)
+FEMorphology::FEMorphology(FilterEffect* in, MorphologyOperatorType type, const float& radiusX, const float& radiusY)
+ : FilterEffect()
+ , m_in(in)
+ , m_type(type)
+ , m_radiusX(radiusX)
+ , m_radiusY(radiusY)
{
}
-SVGMorphologyOperatorType SVGFEMorphology::morphologyOperator() const
+PassRefPtr<FEMorphology> FEMorphology::create(FilterEffect* in, MorphologyOperatorType type, const float& radiusX, const float& radiusY)
{
- return m_operator;
+ return adoptRef(new FEMorphology(in, type, radiusX, radiusY));
}
-void SVGFEMorphology::setMorphologyOperator(SVGMorphologyOperatorType _operator)
+MorphologyOperatorType FEMorphology::morphologyOperator() const
{
- m_operator = _operator;
+ return m_type;
}
-float SVGFEMorphology::radiusX() const
+void FEMorphology::setMorphologyOperator(MorphologyOperatorType type)
+{
+ m_type = type;
+}
+
+float FEMorphology::radiusX() const
{
return m_radiusX;
}
-void SVGFEMorphology::setRadiusX(float radiusX)
+void FEMorphology::setRadiusX(float radiusX)
{
m_radiusX = radiusX;
}
-float SVGFEMorphology::radiusY() const
+float FEMorphology::radiusY() const
{
return m_radiusY;
}
-void SVGFEMorphology::setRadiusY(float radiusY)
+void FEMorphology::setRadiusY(float radiusY)
{
m_radiusY = radiusY;
}
-static TextStream& operator<<(TextStream& ts, SVGMorphologyOperatorType t)
+void FEMorphology::apply()
+{
+}
+
+void FEMorphology::dump()
+{
+}
+
+static TextStream& operator<<(TextStream& ts, MorphologyOperatorType t)
{
switch (t)
{
- case SVG_MORPHOLOGY_OPERATOR_UNKNOWN:
+ case FEMORPHOLOGY_OPERATOR_UNKNOWN:
ts << "UNKNOWN"; break;
- case SVG_MORPHOLOGY_OPERATOR_ERODE:
+ case FEMORPHOLOGY_OPERATOR_ERODE:
ts << "ERODE"; break;
- case SVG_MORPHOLOGY_OPERATOR_DIALATE:
+ case FEMORPHOLOGY_OPERATOR_DIALATE:
ts << "DIALATE"; break;
}
return ts;
}
-TextStream& SVGFEMorphology::externalRepresentation(TextStream& ts) const
+TextStream& FEMorphology::externalRepresentation(TextStream& ts) const
{
- ts << "[type=MORPHOLOGY-OPERATOR] ";
- SVGFilterEffect::externalRepresentation(ts);
+ ts << "[type=MORPHOLOGY] ";
+ FilterEffect::externalRepresentation(ts);
ts << " [operator type=" << morphologyOperator() << "]"
- << " [radius x=" << radiusX() << " y=" << radiusY() << "]";
+ << " [radius x=" << radiusX() << " y=" << radiusY() << "]";
return ts;
}
diff --git a/WebCore/svg/graphics/filters/SVGFEMorphology.h b/WebCore/svg/graphics/filters/SVGFEMorphology.h
index 4ba7131..98ab633 100644
--- a/WebCore/svg/graphics/filters/SVGFEMorphology.h
+++ b/WebCore/svg/graphics/filters/SVGFEMorphology.h
@@ -23,36 +23,40 @@
#define SVGFEMorphology_h
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
+#include "FilterEffect.h"
namespace WebCore {
-enum SVGMorphologyOperatorType {
- SVG_MORPHOLOGY_OPERATOR_UNKNOWN = 0,
- SVG_MORPHOLOGY_OPERATOR_ERODE = 1,
- SVG_MORPHOLOGY_OPERATOR_DIALATE = 2
-};
-
-class SVGFEMorphology : public SVGFilterEffect {
-public:
- SVGFEMorphology(SVGResourceFilter*);
-
- SVGMorphologyOperatorType morphologyOperator() const;
- void setMorphologyOperator(SVGMorphologyOperatorType);
-
- float radiusX() const;
- void setRadiusX(float);
-
- float radiusY() const;
- void setRadiusY(float);
-
- virtual TextStream& externalRepresentation(TextStream&) const;
-
-private:
- SVGMorphologyOperatorType m_operator;
- float m_radiusX;
- float m_radiusY;
-};
+ enum MorphologyOperatorType {
+ FEMORPHOLOGY_OPERATOR_UNKNOWN = 0,
+ FEMORPHOLOGY_OPERATOR_ERODE = 1,
+ FEMORPHOLOGY_OPERATOR_DIALATE = 2
+ };
+
+ class FEMorphology : public FilterEffect {
+ public:
+ PassRefPtr<FEMorphology> create(FilterEffect*, MorphologyOperatorType, const float&, const float&);
+ MorphologyOperatorType morphologyOperator() const;
+ void setMorphologyOperator(MorphologyOperatorType);
+
+ float radiusX() const;
+ void setRadiusX(float);
+
+ float radiusY() const;
+ void setRadiusY(float);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FEMorphology(FilterEffect*, MorphologyOperatorType, const float&, const float&);
+
+ RefPtr<FilterEffect> m_in;
+ MorphologyOperatorType m_type;
+ float m_radiusX;
+ float m_radiusY;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFEOffset.cpp b/WebCore/svg/graphics/filters/SVGFEOffset.cpp
index 024f2cd..c2a0fc9 100644
--- a/WebCore/svg/graphics/filters/SVGFEOffset.cpp
+++ b/WebCore/svg/graphics/filters/SVGFEOffset.cpp
@@ -23,41 +23,56 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "SVGFEOffset.h"
-#include "TextStream.h"
+#include "SVGRenderTreeAsText.h"
namespace WebCore {
-SVGFEOffset::SVGFEOffset(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_dx(0.0f)
- , m_dy(0.0f)
+FEOffset::FEOffset(FilterEffect* in, const float& dx, const float& dy)
+ : FilterEffect()
+ , m_in(in)
+ , m_dx(dx)
+ , m_dy(dy)
{
}
-float SVGFEOffset::dx() const
+PassRefPtr<FEOffset> FEOffset::create(FilterEffect* in, const float& dx, const float& dy)
+{
+ return adoptRef(new FEOffset(in, dx, dy));
+}
+
+float FEOffset::dx() const
{
return m_dx;
}
-void SVGFEOffset::setDx(float dx)
+void FEOffset::setDx(float dx)
{
m_dx = dx;
}
-float SVGFEOffset::dy() const
+float FEOffset::dy() const
{
return m_dy;
}
-void SVGFEOffset::setDy(float dy)
+void FEOffset::setDy(float dy)
{
m_dy = dy;
}
-TextStream& SVGFEOffset::externalRepresentation(TextStream& ts) const
+void FEOffset::apply()
+{
+}
+
+void FEOffset::dump()
+{
+}
+
+TextStream& FEOffset::externalRepresentation(TextStream& ts) const
{
- ts << "[type=OFFSET] "; SVGFilterEffect::externalRepresentation(ts)
- << " [dx=" << dx() << " dy=" << dy() << "]";
+ ts << "[type=OFFSET] ";
+ FilterEffect::externalRepresentation(ts);
+ ts << " [dx=" << dx() << " dy=" << dy() << "]";
return ts;
}
diff --git a/WebCore/svg/graphics/filters/SVGFEOffset.h b/WebCore/svg/graphics/filters/SVGFEOffset.h
index 05b427d..86128da 100644
--- a/WebCore/svg/graphics/filters/SVGFEOffset.h
+++ b/WebCore/svg/graphics/filters/SVGFEOffset.h
@@ -23,30 +23,31 @@
#define SVGFEOffset_h
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
+#include "FilterEffect.h"
namespace WebCore {
-class SVGFEOffset : public SVGFilterEffect {
-public:
- SVGFEOffset(SVGResourceFilter*);
+ class FEOffset : public FilterEffect {
+ public:
+ static PassRefPtr<FEOffset> create(FilterEffect*, const float&, const float&);
- float dx() const;
- void setDx(float);
+ float dx() const;
+ void setDx(float);
- float dy() const;
- void setDy(float);
+ float dy() const;
+ void setDy(float);
- virtual TextStream& externalRepresentation(TextStream&) const;
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
+ private:
+ FEOffset(FilterEffect*, const float&, const float&);
-private:
- float m_dx;
- float m_dy;
-};
+ RefPtr<FilterEffect> m_in;
+ float m_dx;
+ float m_dy;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp b/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp
index ba45dae..e3446ed 100644
--- a/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp
+++ b/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp
@@ -23,104 +23,119 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "SVGFESpecularLighting.h"
-#include "TextStream.h"
+#include "SVGRenderTreeAsText.h"
namespace WebCore {
-SVGFESpecularLighting::SVGFESpecularLighting(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_lightingColor()
- , m_surfaceScale(0.0f)
- , m_specularConstant(0.0f)
- , m_specularExponent(0.0f)
- , m_kernelUnitLengthX(0.0f)
- , m_kernelUnitLengthY(0.0f)
- , m_lightSource(0)
+FESpecularLighting::FESpecularLighting(FilterEffect* in, const Color& lightingColor, const float& surfaceScale,
+ const float& specularConstant, const float& specularExponent, const float& kernelUnitLengthX,
+ const float& kernelUnitLengthY, LightSource* lightSource)
+ : FilterEffect()
+ , m_in(in)
+ , m_lightingColor(lightingColor)
+ , m_surfaceScale(surfaceScale)
+ , m_specularConstant(specularConstant)
+ , m_specularExponent(specularExponent)
+ , m_kernelUnitLengthX(kernelUnitLengthX)
+ , m_kernelUnitLengthY(kernelUnitLengthY)
+ , m_lightSource(lightSource)
{
}
-SVGFESpecularLighting::~SVGFESpecularLighting()
+PassRefPtr<FESpecularLighting> FESpecularLighting::create(FilterEffect* in, const Color& lightingColor,
+ const float& surfaceScale, const float& specularConstant, const float& specularExponent,
+ const float& kernelUnitLengthX, const float& kernelUnitLengthY, LightSource* lightSource)
{
- delete m_lightSource;
+ return adoptRef(new FESpecularLighting(in, lightingColor, surfaceScale, specularConstant, specularExponent,
+ kernelUnitLengthX, kernelUnitLengthY, lightSource));
}
-Color SVGFESpecularLighting::lightingColor() const
+FESpecularLighting::~FESpecularLighting()
+{
+}
+
+Color FESpecularLighting::lightingColor() const
{
return m_lightingColor;
}
-void SVGFESpecularLighting::setLightingColor(const Color& lightingColor)
+void FESpecularLighting::setLightingColor(const Color& lightingColor)
{
m_lightingColor = lightingColor;
}
-float SVGFESpecularLighting::surfaceScale() const
+float FESpecularLighting::surfaceScale() const
{
return m_surfaceScale;
}
-void SVGFESpecularLighting::setSurfaceScale(float surfaceScale)
+void FESpecularLighting::setSurfaceScale(float surfaceScale)
{
m_surfaceScale = surfaceScale;
}
-float SVGFESpecularLighting::specularConstant() const
+float FESpecularLighting::specularConstant() const
{
return m_specularConstant;
}
-void SVGFESpecularLighting::setSpecularConstant(float specularConstant)
+void FESpecularLighting::setSpecularConstant(float specularConstant)
{
m_specularConstant = specularConstant;
}
-float SVGFESpecularLighting::specularExponent() const
+float FESpecularLighting::specularExponent() const
{
return m_specularExponent;
}
-void SVGFESpecularLighting::setSpecularExponent(float specularExponent)
+void FESpecularLighting::setSpecularExponent(float specularExponent)
{
m_specularExponent = specularExponent;
}
-float SVGFESpecularLighting::kernelUnitLengthX() const
+float FESpecularLighting::kernelUnitLengthX() const
{
return m_kernelUnitLengthX;
}
-void SVGFESpecularLighting::setKernelUnitLengthX(float kernelUnitLengthX)
+void FESpecularLighting::setKernelUnitLengthX(float kernelUnitLengthX)
{
m_kernelUnitLengthX = kernelUnitLengthX;
}
-float SVGFESpecularLighting::kernelUnitLengthY() const
+float FESpecularLighting::kernelUnitLengthY() const
{
return m_kernelUnitLengthY;
}
-void SVGFESpecularLighting::setKernelUnitLengthY(float kernelUnitLengthY)
+void FESpecularLighting::setKernelUnitLengthY(float kernelUnitLengthY)
{
m_kernelUnitLengthY = kernelUnitLengthY;
}
-const SVGLightSource* SVGFESpecularLighting::lightSource() const
+const LightSource* FESpecularLighting::lightSource() const
+{
+ return m_lightSource.get();
+}
+
+void FESpecularLighting::setLightSource(LightSource* lightSource)
+{
+ m_lightSource = lightSource;
+}
+
+void FESpecularLighting::apply()
{
- return m_lightSource;
}
-void SVGFESpecularLighting::setLightSource(SVGLightSource* lightSource)
+void FESpecularLighting::dump()
{
- if (m_lightSource != lightSource) {
- delete m_lightSource;
- m_lightSource = lightSource;
- }
}
-TextStream& SVGFESpecularLighting::externalRepresentation(TextStream& ts) const
+TextStream& FESpecularLighting::externalRepresentation(TextStream& ts) const
{
ts << "[type=SPECULAR-LIGHTING] ";
- SVGFilterEffect::externalRepresentation(ts);
+ FilterEffect::externalRepresentation(ts);
ts << " [surface scale=" << m_surfaceScale << "]"
<< " [specual constant=" << m_specularConstant << "]"
<< " [specular exponent=" << m_specularExponent << "]";
diff --git a/WebCore/svg/graphics/filters/SVGFESpecularLighting.h b/WebCore/svg/graphics/filters/SVGFESpecularLighting.h
index 66e1561..e1c1930 100644
--- a/WebCore/svg/graphics/filters/SVGFESpecularLighting.h
+++ b/WebCore/svg/graphics/filters/SVGFESpecularLighting.h
@@ -25,51 +25,54 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "Color.h"
#include "SVGLightSource.h"
-#include "SVGFilterEffect.h"
+#include "FilterEffect.h"
namespace WebCore {
-class SVGFESpecularLighting : public SVGFilterEffect {
-public:
- SVGFESpecularLighting(SVGResourceFilter*);
- virtual ~SVGFESpecularLighting();
+ class FESpecularLighting : public FilterEffect {
+ public:
+ static PassRefPtr<FESpecularLighting> create(FilterEffect*, const Color&, const float&, const float&,
+ const float&, const float&, const float&, LightSource*);
+ virtual ~FESpecularLighting();
- Color lightingColor() const;
- void setLightingColor(const Color&);
+ Color lightingColor() const;
+ void setLightingColor(const Color&);
- float surfaceScale() const;
- void setSurfaceScale(float);
+ float surfaceScale() const;
+ void setSurfaceScale(float);
- float specularConstant() const;
- void setSpecularConstant(float);
+ float specularConstant() const;
+ void setSpecularConstant(float);
- float specularExponent() const;
- void setSpecularExponent(float);
+ float specularExponent() const;
+ void setSpecularExponent(float);
- float kernelUnitLengthX() const;
- void setKernelUnitLengthX(float);
+ float kernelUnitLengthX() const;
+ void setKernelUnitLengthX(float);
- float kernelUnitLengthY() const;
- void setKernelUnitLengthY(float);
+ float kernelUnitLengthY() const;
+ void setKernelUnitLengthY(float);
- const SVGLightSource* lightSource() const;
- void setLightSource(SVGLightSource*);
+ const LightSource* lightSource() const;
+ void setLightSource(LightSource*);
- virtual TextStream& externalRepresentation(TextStream&) const;
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
+ private:
+ FESpecularLighting(FilterEffect*, const Color&, const float&, const float&, const float&,
+ const float&, const float&, LightSource*);
-private:
- Color m_lightingColor;
- float m_surfaceScale;
- float m_specularConstant;
- float m_specularExponent;
- float m_kernelUnitLengthX;
- float m_kernelUnitLengthY;
- SVGLightSource* m_lightSource;
-};
+ RefPtr<FilterEffect> m_in;
+ Color m_lightingColor;
+ float m_surfaceScale;
+ float m_specularConstant;
+ float m_specularExponent;
+ float m_kernelUnitLengthX;
+ float m_kernelUnitLengthY;
+ RefPtr<LightSource> m_lightSource;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/cg/SVGFETileCg.mm b/WebCore/svg/graphics/filters/SVGFETile.cpp
index dea9854..773a5cd 100644
--- a/WebCore/svg/graphics/filters/cg/SVGFETileCg.mm
+++ b/WebCore/svg/graphics/filters/SVGFETile.cpp
@@ -1,7 +1,5 @@
/*
- Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
-
- This file is part of the KDE project
+ 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
@@ -23,19 +21,37 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "SVGFETile.h"
-#include "SVGFEHelpersCg.h"
+#include "SVGRenderTreeAsText.h"
namespace WebCore {
-CIFilter* SVGFETile::getCIFilter(const FloatRect& bbox) const
+FETile::FETile(FilterEffect* in)
+ : FilterEffect()
+ , m_in(in)
+{
+}
+
+PassRefPtr<FETile> FETile::create(FilterEffect* in)
+{
+ return adoptRef(new FETile(in));
+}
+
+void FETile::apply()
{
- SVGResourceFilter* svgFilter = filter();
- FE_QUARTZ_SETUP_INPUT(@"CIAffineTile");
+}
- FE_QUARTZ_MAP_TO_SUBREGION(bbox);
- FE_QUARTZ_OUTPUT_RETURN;
+void FETile::dump()
+{
}
+TextStream& FETile::externalRepresentation(TextStream& ts) const
+{
+ ts << "[type=TILE]";
+ FilterEffect::externalRepresentation(ts);
+ return ts;
}
+} // namespace WebCore
+
#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
+
diff --git a/WebCore/svg/graphics/filters/SVGFETile.h b/WebCore/svg/graphics/filters/SVGFETile.h
index 1c3922f..986f6fd 100644
--- a/WebCore/svg/graphics/filters/SVGFETile.h
+++ b/WebCore/svg/graphics/filters/SVGFETile.h
@@ -23,19 +23,23 @@
#define SVGFETile_h
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
+#include "FilterEffect.h"
namespace WebCore {
-
-class SVGFETile : public SVGFilterEffect
-{
-public:
- SVGFETile(SVGResourceFilter* filter) : SVGFilterEffect(filter) { }
-
-#if PLATFORM(CI)
- virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
-};
+
+ class FETile : public FilterEffect {
+ public:
+ static PassRefPtr<FETile> create(FilterEffect*);
+
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
+
+ private:
+ FETile(FilterEffect*);
+
+ RefPtr<FilterEffect> m_in;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFETurbulence.cpp b/WebCore/svg/graphics/filters/SVGFETurbulence.cpp
index 0f9cbaf..9731c49 100644
--- a/WebCore/svg/graphics/filters/SVGFETurbulence.cpp
+++ b/WebCore/svg/graphics/filters/SVGFETurbulence.cpp
@@ -23,106 +23,121 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "SVGFETurbulence.h"
-#include "TextStream.h"
+#include "SVGRenderTreeAsText.h"
namespace WebCore {
-SVGFETurbulence::SVGFETurbulence(SVGResourceFilter* filter)
- : SVGFilterEffect(filter)
- , m_baseFrequencyX(0.0f)
- , m_baseFrequencyY(0.0f)
- , m_numOctaves(0)
- , m_seed(0)
- , m_stitchTiles(false)
- , m_type(SVG_TURBULENCE_TYPE_UNKNOWN)
+FETurbulence::FETurbulence(TurbulanceType type, const float& baseFrequencyX, const float& baseFrequencyY,
+ const int& numOctaves, const float& seed, bool stitchTiles)
+ : FilterEffect()
+ , m_type(type)
+ , m_baseFrequencyX(baseFrequencyX)
+ , m_baseFrequencyY(baseFrequencyY)
+ , m_numOctaves(numOctaves)
+ , m_seed(seed)
+ , m_stitchTiles(stitchTiles)
{
}
-SVGTurbulanceType SVGFETurbulence::type() const
+PassRefPtr<FETurbulence> FETurbulence::create(TurbulanceType type, const float& baseFrequencyX, const float& baseFrequencyY,
+ const int& numOctaves, const float& seed, bool stitchTiles)
+{
+ return adoptRef(new FETurbulence(type, baseFrequencyX, baseFrequencyY, numOctaves, seed, stitchTiles));
+}
+
+TurbulanceType FETurbulence::type() const
{
return m_type;
}
-void SVGFETurbulence::setType(SVGTurbulanceType type)
+void FETurbulence::setType(TurbulanceType type)
{
m_type = type;
}
-float SVGFETurbulence::baseFrequencyY() const
+float FETurbulence::baseFrequencyY() const
{
return m_baseFrequencyY;
}
-void SVGFETurbulence::setBaseFrequencyY(float baseFrequencyY)
+void FETurbulence::setBaseFrequencyY(float baseFrequencyY)
{
m_baseFrequencyY = baseFrequencyY;
}
-float SVGFETurbulence::baseFrequencyX() const
+float FETurbulence::baseFrequencyX() const
{
return m_baseFrequencyX;
}
-void SVGFETurbulence::setBaseFrequencyX(float baseFrequencyX)
+void FETurbulence::setBaseFrequencyX(float baseFrequencyX)
{
m_baseFrequencyX = baseFrequencyX;
}
-float SVGFETurbulence::seed() const
+float FETurbulence::seed() const
{
return m_seed;
}
-void SVGFETurbulence::setSeed(float seed)
+void FETurbulence::setSeed(float seed)
{
m_seed = seed;
}
-int SVGFETurbulence::numOctaves() const
+int FETurbulence::numOctaves() const
{
return m_numOctaves;
}
-void SVGFETurbulence::setNumOctaves(bool numOctaves)
+void FETurbulence::setNumOctaves(bool numOctaves)
{
m_numOctaves = numOctaves;
}
-bool SVGFETurbulence::stitchTiles() const
+bool FETurbulence::stitchTiles() const
{
return m_stitchTiles;
}
-void SVGFETurbulence::setStitchTiles(bool stitch)
+void FETurbulence::setStitchTiles(bool stitch)
{
m_stitchTiles = stitch;
}
-static TextStream& operator<<(TextStream& ts, SVGTurbulanceType t)
+void FETurbulence::apply()
+{
+}
+
+void FETurbulence::dump()
+{
+}
+
+static TextStream& operator<<(TextStream& ts, TurbulanceType t)
{
switch (t)
{
- case SVG_TURBULENCE_TYPE_UNKNOWN:
+ case FETURBULENCE_TYPE_UNKNOWN:
ts << "UNKNOWN"; break;
- case SVG_TURBULENCE_TYPE_TURBULENCE:
+ case FETURBULENCE_TYPE_TURBULENCE:
ts << "TURBULANCE"; break;
- case SVG_TURBULENCE_TYPE_FRACTALNOISE:
+ case FETURBULENCE_TYPE_FRACTALNOISE:
ts << "NOISE"; break;
}
return ts;
}
-TextStream& SVGFETurbulence::externalRepresentation(TextStream& ts) const
+TextStream& FETurbulence::externalRepresentation(TextStream& ts) const
{
ts << "[type=TURBULENCE] ";
- SVGFilterEffect::externalRepresentation(ts);
+ FilterEffect::externalRepresentation(ts);
ts << " [turbulence type=" << type() << "]"
<< " [base frequency x=" << baseFrequencyX() << " y=" << baseFrequencyY() << "]"
<< " [seed=" << seed() << "]"
<< " [num octaves=" << numOctaves() << "]"
<< " [stitch tiles=" << stitchTiles() << "]";
- return ts;
+ return ts;
}
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFETurbulence.h b/WebCore/svg/graphics/filters/SVGFETurbulence.h
index b871416..6977460 100644
--- a/WebCore/svg/graphics/filters/SVGFETurbulence.h
+++ b/WebCore/svg/graphics/filters/SVGFETurbulence.h
@@ -23,48 +23,54 @@
#define SVGFETurbulence_h
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
+#include "FilterEffect.h"
namespace WebCore {
-enum SVGTurbulanceType {
- SVG_TURBULENCE_TYPE_UNKNOWN = 0,
- SVG_TURBULENCE_TYPE_FRACTALNOISE = 1,
- SVG_TURBULENCE_TYPE_TURBULENCE = 2
-};
+ enum TurbulanceType {
+ FETURBULENCE_TYPE_UNKNOWN = 0,
+ FETURBULENCE_TYPE_FRACTALNOISE = 1,
+ FETURBULENCE_TYPE_TURBULENCE = 2
+ };
-class SVGFETurbulence : public SVGFilterEffect {
-public:
- SVGFETurbulence(SVGResourceFilter*);
+ class FETurbulence : public FilterEffect {
+ public:
+ static PassRefPtr<FETurbulence> create(TurbulanceType, const float&, const float&, const int&, const float&,
+ bool);
- SVGTurbulanceType type() const;
- void setType(SVGTurbulanceType);
+ TurbulanceType type() const;
+ void setType(TurbulanceType);
- float baseFrequencyY() const;
- void setBaseFrequencyY(float);
+ float baseFrequencyY() const;
+ void setBaseFrequencyY(float);
- float baseFrequencyX() const;
- void setBaseFrequencyX(float);
+ float baseFrequencyX() const;
+ void setBaseFrequencyX(float);
- float seed() const;
- void setSeed(float);
+ float seed() const;
+ void setSeed(float);
- int numOctaves() const;
- void setNumOctaves(bool);
+ int numOctaves() const;
+ void setNumOctaves(bool);
- bool stitchTiles() const;
- void setStitchTiles(bool);
+ bool stitchTiles() const;
+ void setStitchTiles(bool);
- virtual TextStream& externalRepresentation(TextStream&) const;
+ virtual void apply();
+ virtual void dump();
+ TextStream& externalRepresentation(TextStream& ts) const;
-private:
- float m_baseFrequencyX;
- float m_baseFrequencyY;
- int m_numOctaves;
- float m_seed;
- bool m_stitchTiles;
- SVGTurbulanceType m_type;
-};
+ private:
+ FETurbulence(TurbulanceType, const float&, const float&, const int&, const float&,
+ bool);
+
+ TurbulanceType m_type;
+ float m_baseFrequencyX;
+ float m_baseFrequencyY;
+ int m_numOctaves;
+ float m_seed;
+ bool m_stitchTiles;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGFilterEffect.cpp b/WebCore/svg/graphics/filters/SVGFilterEffect.cpp
index 9423dc1..f8e246f 100644
--- a/WebCore/svg/graphics/filters/SVGFilterEffect.cpp
+++ b/WebCore/svg/graphics/filters/SVGFilterEffect.cpp
@@ -26,7 +26,6 @@
#include "SVGRenderTreeAsText.h"
#include "SVGResourceFilter.h"
-#include "TextStream.h"
namespace WebCore {
diff --git a/WebCore/svg/graphics/filters/SVGFilterEffect.h b/WebCore/svg/graphics/filters/SVGFilterEffect.h
index f7128fc..d497f8b 100644
--- a/WebCore/svg/graphics/filters/SVGFilterEffect.h
+++ b/WebCore/svg/graphics/filters/SVGFilterEffect.h
@@ -39,7 +39,7 @@ namespace WebCore {
class SVGResourceFilter;
class TextStream;
-class SVGFilterEffect {
+class SVGFilterEffect : public RefCounted<SVGFilterEffect> {
public:
SVGFilterEffect(SVGResourceFilter*);
virtual ~SVGFilterEffect() { }
diff --git a/WebCore/svg/graphics/filters/SVGLightSource.cpp b/WebCore/svg/graphics/filters/SVGLightSource.cpp
index 517ed50..77611ca 100644
--- a/WebCore/svg/graphics/filters/SVGLightSource.cpp
+++ b/WebCore/svg/graphics/filters/SVGLightSource.cpp
@@ -35,14 +35,14 @@ static TextStream& operator<<(TextStream& ts, const FloatPoint3D& p)
return ts;
}
-TextStream& SVGPointLightSource::externalRepresentation(TextStream& ts) const
+TextStream& PointLightSource::externalRepresentation(TextStream& ts) const
{
ts << "[type=POINT-LIGHT] ";
ts << "[position=\"" << position() << "\"]";
return ts;
}
-TextStream& SVGSpotLightSource::externalRepresentation(TextStream& ts) const
+TextStream& SpotLightSource::externalRepresentation(TextStream& ts) const
{
ts << "[type=SPOT-LIGHT] ";
ts << "[position=\"" << position() << "\"]";
@@ -52,7 +52,7 @@ TextStream& SVGSpotLightSource::externalRepresentation(TextStream& ts) const
return ts;
}
-TextStream& SVGDistantLightSource::externalRepresentation(TextStream& ts) const
+TextStream& DistantLightSource::externalRepresentation(TextStream& ts) const
{
ts << "[type=DISTANT-LIGHT] ";
ts << "[azimuth=\"" << azimuth() << "\"]";
diff --git a/WebCore/svg/graphics/filters/SVGLightSource.h b/WebCore/svg/graphics/filters/SVGLightSource.h
index 12cf3d0..779e147 100644
--- a/WebCore/svg/graphics/filters/SVGLightSource.h
+++ b/WebCore/svg/graphics/filters/SVGLightSource.h
@@ -1,5 +1,6 @@
/*
- Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
+ 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
2004, 2005 Rob Buis <buis@kde.org>
2005 Eric Seidel <eric@webkit.org>
@@ -23,32 +24,32 @@
#define SVGLightSource_h
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include <wtf/RefCounted.h>
namespace WebCore {
-enum SVGLightType {
- LS_DISTANT,
- LS_POINT,
- LS_SPOT
-};
+ enum LightType {
+ LS_DISTANT,
+ LS_POINT,
+ LS_SPOT
+ };
-class TextStream;
+ class TextStream;
-class SVGLightSource {
-public:
- SVGLightSource(SVGLightType type)
- : m_type(type)
- { }
+ class LightSource : public RefCounted<LightSource> {
+ public:
+ LightSource(LightType type)
+ : m_type(type)
+ { }
- virtual ~SVGLightSource() { }
+ virtual ~LightSource() { }
- SVGLightType type() const { return m_type; }
- virtual TextStream& externalRepresentation(TextStream&) const = 0;
-
-private:
- SVGLightType m_type;
-};
+ LightType type() const { return m_type; }
+ virtual TextStream& externalRepresentation(TextStream&) const = 0;
+ private:
+ LightType m_type;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGPointLightSource.h b/WebCore/svg/graphics/filters/SVGPointLightSource.h
index 71b8f70..099a165 100644
--- a/WebCore/svg/graphics/filters/SVGPointLightSource.h
+++ b/WebCore/svg/graphics/filters/SVGPointLightSource.h
@@ -1,5 +1,6 @@
/*
- Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
+ 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
2004, 2005 Rob Buis <buis@kde.org>
2005 Eric Seidel <eric@webkit.org>
@@ -28,20 +29,20 @@
namespace WebCore {
-class SVGPointLightSource : public SVGLightSource {
-public:
- SVGPointLightSource(const FloatPoint3D& position)
- : SVGLightSource(LS_POINT)
- , m_position(position)
- { }
+ class PointLightSource : public LightSource {
+ public:
+ PointLightSource(const FloatPoint3D& position)
+ : LightSource(LS_POINT)
+ , m_position(position)
+ { }
- const FloatPoint3D& position() const { return m_position; }
+ const FloatPoint3D& position() const { return m_position; }
- virtual TextStream& externalRepresentation(TextStream&) const;
+ virtual TextStream& externalRepresentation(TextStream&) const;
-private:
- FloatPoint3D m_position;
-};
+ private:
+ FloatPoint3D m_position;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/SVGSpotLightSource.h b/WebCore/svg/graphics/filters/SVGSpotLightSource.h
index 850a5fa..a4aa1fb 100644
--- a/WebCore/svg/graphics/filters/SVGSpotLightSource.h
+++ b/WebCore/svg/graphics/filters/SVGSpotLightSource.h
@@ -1,5 +1,6 @@
/*
- Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
+ 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
2004, 2005 Rob Buis <buis@kde.org>
2005 Eric Seidel <eric@webkit.org>
@@ -28,31 +29,31 @@
namespace WebCore {
-class SVGSpotLightSource : public SVGLightSource {
-public:
- SVGSpotLightSource(const FloatPoint3D& position, const FloatPoint3D& direction, float specularExponent, float limitingConeAngle)
- : SVGLightSource(LS_SPOT)
- , m_position(position)
- , m_direction(direction)
- , m_specularExponent(specularExponent)
- , m_limitingConeAngle(limitingConeAngle)
- { }
+ class SpotLightSource : public LightSource {
+ public:
+ SpotLightSource(const FloatPoint3D& position, const FloatPoint3D& direction, float specularExponent, float limitingConeAngle)
+ : LightSource(LS_SPOT)
+ , m_position(position)
+ , m_direction(direction)
+ , m_specularExponent(specularExponent)
+ , m_limitingConeAngle(limitingConeAngle)
+ { }
- const FloatPoint3D& position() const { return m_position; }
- const FloatPoint3D& direction() const { return m_direction; }
+ const FloatPoint3D& position() const { return m_position; }
+ const FloatPoint3D& direction() const { return m_direction; }
- float specularExponent() const { return m_specularExponent; }
- float limitingConeAngle() const { return m_limitingConeAngle; }
+ float specularExponent() const { return m_specularExponent; }
+ float limitingConeAngle() const { return m_limitingConeAngle; }
- virtual TextStream& externalRepresentation(TextStream&) const;
+ virtual TextStream& externalRepresentation(TextStream&) const;
-private:
- FloatPoint3D m_position;
- FloatPoint3D m_direction;
+ private:
+ FloatPoint3D m_position;
+ FloatPoint3D m_direction;
- float m_specularExponent;
- float m_limitingConeAngle;
-};
+ float m_specularExponent;
+ float m_limitingConeAngle;
+ };
} // namespace WebCore
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEBlendCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEBlendCg.mm
deleted file mode 100644
index 29caaa0..0000000
--- a/WebCore/svg/graphics/filters/cg/SVGFEBlendCg.mm
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <zimmermann@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 "SVGFEBlend.h"
-#include "SVGFEHelpersCg.h"
-
-namespace WebCore {
-
-CIFilter* SVGFEBlend::getCIFilter(const FloatRect& bbox) const
-{
- SVGResourceFilter* svgFilter = filter();
- SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
- CIFilter* filter = nil;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- switch (blendMode()) {
- case SVG_FEBLEND_MODE_UNKNOWN:
- return nil;
- case SVG_FEBLEND_MODE_NORMAL:
- // FIXME: I think this is correct....
- filter = [CIFilter filterWithName:@"CISourceOverCompositing"];
- break;
- case SVG_FEBLEND_MODE_MULTIPLY:
- filter = [CIFilter filterWithName:@"CIMultiplyBlendMode"];
- break;
- case SVG_FEBLEND_MODE_SCREEN:
- filter = [CIFilter filterWithName:@"CIScreenBlendMode"];
- break;
- case SVG_FEBLEND_MODE_DARKEN:
- filter = [CIFilter filterWithName:@"CIDarkenBlendMode"];
- break;
- case SVG_FEBLEND_MODE_LIGHTEN:
- filter = [CIFilter filterWithName:@"CILightenBlendMode"];
- break;
- default:
- LOG_ERROR("Unhandled blend mode: %i", blendMode());
- return nil;
- }
-
- [filter setDefaults];
-
- CIImage* inputImage = filterPlatformData->inputImage(this);
- FE_QUARTZ_CHECK_INPUT(inputImage);
- [filter setValue:inputImage forKey:@"inputImage"];
-
- CIImage* backgroundImage = filterPlatformData->imageForName(in2());
- FE_QUARTZ_CHECK_INPUT(backgroundImage);
- [filter setValue:backgroundImage forKey:@"inputBackgroundImage"];
-
- FE_QUARTZ_MAP_TO_SUBREGION(bbox);
- FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEColorMatrixCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEColorMatrixCg.mm
deleted file mode 100644
index ae6e4aa..0000000
--- a/WebCore/svg/graphics/filters/cg/SVGFEColorMatrixCg.mm
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <zimmermann@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 "SVGFEColorMatrix.h"
-#include "SVGFEHelpersCg.h"
-
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-#define CMValuesCheck(expected, type) \
- if (values().size() != expected) { \
- NSLog(@"Error, incorrect number of values in ColorMatrix for type \"%s\", expected: %i actual: %i, ignoring filter. Values:", type, expected, values().size()); \
- for (unsigned x=0; x < values().size(); x++) fprintf(stderr, " %f", values()[x]); \
- fprintf(stderr, "\n"); \
- return nil; \
- }
-
-CIFilter* SVGFEColorMatrix::getCIFilter(const FloatRect& bbox) const
-{
- SVGResourceFilter* svgFilter = filter();
- SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
- CIFilter* filter = nil;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- switch (type()) {
- case SVG_FECOLORMATRIX_TYPE_UNKNOWN:
- return nil;
- case SVG_FECOLORMATRIX_TYPE_MATRIX:
- {
- CMValuesCheck(20, "matrix");
- filter = [CIFilter filterWithName:@"CIColorMatrix"];
- [filter setDefaults];
- const Vector<float>& v = values();
- [filter setValue:[CIVector vectorWithX:v[0] Y:v[1] Z:v[2] W:v[3]] forKey:@"inputRVector"];
- [filter setValue:[CIVector vectorWithX:v[5] Y:v[6] Z:v[7] W:v[8]] forKey:@"inputGVector"];
- [filter setValue:[CIVector vectorWithX:v[10] Y:v[11] Z:v[12] W:v[13]] forKey:@"inputBVector"];
- [filter setValue:[CIVector vectorWithX:v[15] Y:v[16] Z:v[17] W:v[18]] forKey:@"inputAVector"];
- [filter setValue:[CIVector vectorWithX:v[4] Y:v[9] Z:v[14] W:v[19]] forKey:@"inputBiasVector"];
- break;
- }
- case SVG_FECOLORMATRIX_TYPE_SATURATE:
- {
- CMValuesCheck(1, "saturate");
- filter = [CIFilter filterWithName:@"CIColorControls"];
- [filter setDefaults];
- float saturation = values()[0];
- if ((saturation < 0.0) || (saturation > 3.0))
- NSLog(@"WARNING: Saturation adjustment: %f outside supported range.");
- [filter setValue:[NSNumber numberWithFloat:saturation] forKey:@"inputSaturation"];
- break;
- }
- case SVG_FECOLORMATRIX_TYPE_HUEROTATE:
- {
- CMValuesCheck(1, "hueRotate");
- filter = [CIFilter filterWithName:@"CIHueAdjust"];
- [filter setDefaults];
- float radians = deg2rad(values()[0]);
- [filter setValue:[NSNumber numberWithFloat:radians] forKey:@"inputAngle"];
- break;
- }
- case SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
- {
- CMValuesCheck(0, "luminanceToAlpha");
- // FIXME: I bet there is an easy filter to do this.
- filter = [CIFilter filterWithName:@"CIColorMatrix"];
- [filter setDefaults];
- CGFloat zero[4] = {0, 0, 0, 0};
- CGFloat alpha[4] = {0.2125f, 0.7154f, 0.0721f, 0};
- [filter setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputRVector"];
- [filter setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputGVector"];
- [filter setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBVector"];
- [filter setValue:[CIVector vectorWithValues:alpha count:4] forKey:@"inputAVector"];
- [filter setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBiasVector"];
- break;
- }
- default:
- LOG_ERROR("Unhandled ColorMatrix type: %i", type());
- return nil;
- }
- CIImage *inputImage = filterPlatformData->inputImage(this);
- FE_QUARTZ_CHECK_INPUT(inputImage);
- [filter setValue:inputImage forKey:@"inputImage"];
-
- FE_QUARTZ_MAP_TO_SUBREGION(bbox);
- FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEComponentTransferCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEComponentTransferCg.mm
deleted file mode 100644
index 61515db..0000000
--- a/WebCore/svg/graphics/filters/cg/SVGFEComponentTransferCg.mm
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <zimmermann@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 "SVGFEComponentTransfer.h"
-#include "SVGFEHelpersCg.h"
-
-#import "WKComponentMergeFilter.h"
-#import "WKIdentityTransferFilter.h"
-#import "WKTableTransferFilter.h"
-#import "WKDiscreteTransferFilter.h"
-#import "WKLinearTransferFilter.h"
-#import "WKGammaTransferFilter.h"
-
-namespace WebCore {
-
-static CIImage* genImageFromTable(const Vector<float>& table)
-{
- int length = table.size();
- int nBytes = length * 4 * sizeof(float);
- float* tableStore = (float *) malloc(nBytes);
- NSData* bitmapData = [NSData dataWithBytesNoCopy:tableStore length:nBytes];
- for (Vector<float>::const_iterator it = table.begin(); it != table.end(); it++) {
- const float value = *it;
- *tableStore++ = value;
- *tableStore++ = value;
- *tableStore++ = value;
- *tableStore++ = value;
- }
- return [CIImage imageWithBitmapData:bitmapData bytesPerRow:nBytes size:CGSizeMake(length, 1) format:kCIFormatRGBAf colorSpace:nil];
-}
-
-static void setParametersForComponentFunc(CIFilter* filter, const SVGComponentTransferFunction& func, CIVector* channelSelector)
-{
- switch (func.type) {
- case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
- return;
- case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
- [filter setValue:genImageFromTable(func.tableValues) forKey:@"inputTable"];
- [filter setValue:channelSelector forKey:@"inputSelector"];
- break;
- case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
- [filter setValue:genImageFromTable(func.tableValues) forKey:@"inputTable"];
- [filter setValue:channelSelector forKey:@"inputSelector"];
- break;
- case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
- [filter setValue:[NSNumber numberWithFloat:func.slope] forKey:@"inputSlope"];
- [filter setValue:[NSNumber numberWithFloat:func.intercept] forKey:@"inputIntercept"];
- break;
- case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
- [filter setValue:[NSNumber numberWithFloat:func.amplitude] forKey:@"inputAmplitude"];
- [filter setValue:[NSNumber numberWithFloat:func.exponent] forKey:@"inputExponent"];
- [filter setValue:[NSNumber numberWithFloat:func.offset] forKey:@"inputOffset"];
- break;
- default:
- // identity has no args
- break;
- }
-}
-
-static CIFilter* filterForComponentFunc(const SVGComponentTransferFunction& func)
-{
- CIFilter *filter;
- switch (func.type) {
- case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
- case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY:
- filter = [CIFilter filterWithName:@"WKIdentityTransfer"];
- break;
- case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
- filter = [CIFilter filterWithName:@"WKTableTransferFilter"];
- break;
- case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
- filter = [CIFilter filterWithName:@"WKDiscreteTransferFilter"];
- break;
- case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
- filter = [CIFilter filterWithName:@"WKLinearTransfer"];
- break;
- case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
- filter = [CIFilter filterWithName:@"WKGammaTransfer"];
- break;
- default:
- NSLog(@"WARNING: Unknown function type for feComponentTransfer");
- //and to prevent the entire svg from failing as a result
- filter = [CIFilter filterWithName:@"WKIdentityTransfer"];
- break;
- }
- return filter;
-}
-
-static CIFilter* getFilterForFunc(const SVGComponentTransferFunction& func, CIImage* inputImage, CIVector* channelSelector)
-{
- CIFilter* filter = filterForComponentFunc(func);
- [filter setDefaults];
-
- setParametersForComponentFunc(filter, func, channelSelector);
- [filter setValue:inputImage forKey:@"inputImage"];
- return filter;
-}
-
-CIFilter* SVGFEComponentTransfer::getFunctionFilter(SVGChannelSelectorType channel, CIImage* inputImage) const
-{
- switch (channel) {
- case SVG_CHANNEL_R:
- return [getFilterForFunc(redFunction(), inputImage, getVectorForChannel(channel)) valueForKey:@"outputImage"];
- case SVG_CHANNEL_G:
- return [getFilterForFunc(greenFunction(), inputImage, getVectorForChannel(channel)) valueForKey:@"outputImage"];
- case SVG_CHANNEL_B:
- return [getFilterForFunc(blueFunction(), inputImage, getVectorForChannel(channel)) valueForKey:@"outputImage"];
- case SVG_CHANNEL_A:
- return [getFilterForFunc(alphaFunction(), inputImage, getVectorForChannel(channel)) valueForKey:@"outputImage"];
- default:
- return nil;
- }
-}
-
-CIFilter* SVGFEComponentTransfer::getCIFilter(const FloatRect& bbox) const
-{
- [WKComponentMergeFilter class];
- [WKIdentityTransferFilter class];
- [WKTableTransferFilter class];
- [WKDiscreteTransferFilter class];
- [WKLinearTransferFilter class];
- [WKGammaTransferFilter class];
-
- SVGResourceFilter* svgFilter = filter();
- SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
- CIFilter* filter = nil;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- filter = [CIFilter filterWithName:@"WKComponentMerge"];
- if (!filter)
- return nil;
- [filter setDefaults];
- CIImage* inputImage = filterPlatformData->inputImage(this);
- FE_QUARTZ_CHECK_INPUT(inputImage);
-
- [filter setValue:getFunctionFilter(SVG_CHANNEL_R, inputImage) forKey:@"inputFuncR"];
- [filter setValue:getFunctionFilter(SVG_CHANNEL_G, inputImage) forKey:@"inputFuncG"];
- [filter setValue:getFunctionFilter(SVG_CHANNEL_B, inputImage) forKey:@"inputFuncB"];
- [filter setValue:getFunctionFilter(SVG_CHANNEL_A, inputImage) forKey:@"inputFuncA"];
-
- FE_QUARTZ_MAP_TO_SUBREGION(bbox);
- FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFECompositeCg.mm b/WebCore/svg/graphics/filters/cg/SVGFECompositeCg.mm
deleted file mode 100644
index 624612c..0000000
--- a/WebCore/svg/graphics/filters/cg/SVGFECompositeCg.mm
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <zimmermann@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 "SVGFEComposite.h"
-#include "SVGFEHelpersCg.h"
-
-#import "WKArithmeticFilter.h"
-
-namespace WebCore {
-
-CIFilter* SVGFEComposite::getCIFilter(const FloatRect& bbox) const
-{
- SVGResourceFilter* svgFilter = filter();
- SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
- CIFilter* filter = nil;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- switch (operation()) {
- case SVG_FECOMPOSITE_OPERATOR_UNKNOWN:
- return nil;
- case SVG_FECOMPOSITE_OPERATOR_OVER:
- filter = [CIFilter filterWithName:@"CISourceOverCompositing"];
- break;
- case SVG_FECOMPOSITE_OPERATOR_IN:
- filter = [CIFilter filterWithName:@"CISourceInCompositing"];
- break;
- case SVG_FECOMPOSITE_OPERATOR_OUT:
- filter = [CIFilter filterWithName:@"CISourceOutCompositing"];
- break;
- case SVG_FECOMPOSITE_OPERATOR_ATOP:
- filter = [CIFilter filterWithName:@"CISourceAtopCompositing"];
- break;
- case SVG_FECOMPOSITE_OPERATOR_XOR:
- //FIXME: I'm not sure this is right...
- filter = [CIFilter filterWithName:@"CIExclusionBlendMode"];
- break;
- case SVG_FECOMPOSITE_OPERATOR_ARITHMETIC:
- [WKArithmeticFilter class];
- filter = [CIFilter filterWithName:@"WKArithmeticFilter"];
- break;
- }
-
- [filter setDefaults];
- CIImage* inputImage = filterPlatformData->inputImage(this);
- CIImage* backgroundImage = filterPlatformData->imageForName(in2());
- FE_QUARTZ_CHECK_INPUT(inputImage);
- FE_QUARTZ_CHECK_INPUT(backgroundImage);
- [filter setValue:inputImage forKey:@"inputImage"];
- [filter setValue:backgroundImage forKey:@"inputBackgroundImage"];
- //FIXME: this seems ugly
- if (operation() == SVG_FECOMPOSITE_OPERATOR_ARITHMETIC) {
- [filter setValue:[NSNumber numberWithFloat:k1()] forKey:@"inputK1"];
- [filter setValue:[NSNumber numberWithFloat:k2()] forKey:@"inputK2"];
- [filter setValue:[NSNumber numberWithFloat:k3()] forKey:@"inputK3"];
- [filter setValue:[NSNumber numberWithFloat:k4()] forKey:@"inputK4"];
- }
-
- FE_QUARTZ_MAP_TO_SUBREGION(bbox);
- FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEDiffuseLightingCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEDiffuseLightingCg.mm
deleted file mode 100644
index 981b88b..0000000
--- a/WebCore/svg/graphics/filters/cg/SVGFEDiffuseLightingCg.mm
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <zimmermann@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 "SVGFEDiffuseLighting.h"
-#include "SVGFEHelpersCg.h"
-
-#import "WKDiffuseLightingFilter.h"
-
-namespace WebCore {
-
-CIFilter* SVGFEDiffuseLighting::getCIFilter(const FloatRect& bbox) const
-{
- const SVGLightSource* light = lightSource();
- if (!light)
- return nil;
-
- [WKDiffuseLightingFilter class];
-
- SVGResourceFilter* svgFilter = filter();
- SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
-
- CIFilter* filter;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- filter = [CIFilter filterWithName:@"WKDiffuseLighting"];
- if (!filter)
- return nil;
-
- [filter setDefaults];
- CIImage* inputImage = filterPlatformData->inputImage(this);
- FE_QUARTZ_CHECK_INPUT(inputImage);
- CIFilter* normals = getNormalMap(inputImage, surfaceScale());
- if (!normals)
- return nil;
-
- CIFilter* lightVectors = getLightVectors(normals, light, surfaceScale());
- if (!lightVectors)
- return nil;
-
- [filter setValue:[normals valueForKey:@"outputImage"] forKey:@"inputNormalMap"];
- [filter setValue:[lightVectors valueForKey:@"outputImage"] forKey:@"inputLightVectors"];
- [filter setValue:ciColor(lightingColor()) forKey:@"inputLightingColor"];
- [filter setValue:[NSNumber numberWithFloat:surfaceScale()] forKey:@"inputSurfaceScale"];
- [filter setValue:[NSNumber numberWithFloat:diffuseConstant()] forKey:@"inputDiffuseConstant"];
- [filter setValue:[NSNumber numberWithFloat:kernelUnitLengthX()] forKey:@"inputKernelUnitLengthX"];
- [filter setValue:[NSNumber numberWithFloat:kernelUnitLengthY()] forKey:@"inputKernelUnitLengthY"];
-
- FE_QUARTZ_MAP_TO_SUBREGION(bbox);
- FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEDisplacementMapCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEDisplacementMapCg.mm
deleted file mode 100644
index 9d482e2..0000000
--- a/WebCore/svg/graphics/filters/cg/SVGFEDisplacementMapCg.mm
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <zimmermann@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 "SVGFEDisplacementMap.h"
-#include "SVGFEHelpersCg.h"
-
-#import "WKDisplacementMapFilter.h"
-
-namespace WebCore {
-
-CIFilter* SVGFEDisplacementMap::getCIFilter(const FloatRect& bbox) const
-{
- SVGResourceFilter* svgFilter = filter();
- SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
-
- CIFilter* filter = nil;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- [WKDisplacementMapFilter class];
- filter = [CIFilter filterWithName:@"WKDisplacementMapFilter"];
- [filter setDefaults];
- CIImage* inputImage = filterPlatformData->inputImage(this);
- CIImage* displacementMap = filterPlatformData->imageForName(in2());
- FE_QUARTZ_CHECK_INPUT(inputImage);
- FE_QUARTZ_CHECK_INPUT(displacementMap);
- [filter setValue:inputImage forKey:@"inputImage"];
- [filter setValue:displacementMap forKey:@"inputDisplacementMap"];
- [filter setValue:getVectorForChannel(xChannelSelector()) forKey:@"inputXChannelSelector"];
- [filter setValue:getVectorForChannel(yChannelSelector()) forKey:@"inputYChannelSelector"];
- [filter setValue:[NSNumber numberWithFloat:scale()] forKey:@"inputScale"];
-
- FE_QUARTZ_MAP_TO_SUBREGION(bbox);
- FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEFloodCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEFloodCg.mm
deleted file mode 100644
index db46f5b..0000000
--- a/WebCore/svg/graphics/filters/cg/SVGFEFloodCg.mm
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- Copyright (C) 2006, 2007 Nikolas Zimmermann <zimmermann@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 "SVGFEFlood.h"
-
-#include "AffineTransform.h"
-#include "SVGFEHelpersCg.h"
-#include "CgSupport.h"
-
-namespace WebCore {
-
-CIFilter* SVGFEFlood::getCIFilter(const FloatRect& bbox) const
-{
- SVGResourceFilter* svgFilter = filter();
- SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
- CIFilter* filter;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- filter = [CIFilter filterWithName:@"CIConstantColorGenerator"];
- [filter setDefaults];
- CGColorRef color = cgColor(floodColor());
- CGColorRef withAlpha = CGColorCreateCopyWithAlpha(color, CGColorGetAlpha(color) * floodOpacity());
- CIColor* inputColor = [CIColor colorWithCGColor:withAlpha];
- CGColorRelease(color);
- CGColorRelease(withAlpha);
- [filter setValue:inputColor forKey:@"inputColor"];
-
- FE_QUARTZ_MAP_TO_SUBREGION(bbox);
- FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEGaussianBlurCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEGaussianBlurCg.mm
deleted file mode 100644
index 13140b6..0000000
--- a/WebCore/svg/graphics/filters/cg/SVGFEGaussianBlurCg.mm
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <zimmermann@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 "SVGFEGaussianBlur.h"
-#include "SVGFEHelpersCg.h"
-
-namespace WebCore {
-
-CIFilter* SVGFEGaussianBlur::getCIFilter(const FloatRect& bbox) const
-{
- SVGResourceFilter* svgFilter = filter();
- FE_QUARTZ_SETUP_INPUT(@"CIGaussianPyramid");
-
- float inputRadius = stdDeviationX();
- if (inputRadius != stdDeviationY()) {
- float inputAspectRatio = stdDeviationX()/stdDeviationY();
- // FIXME: inputAspectRatio only support the range .5 to 2.0!
- [filter setValue:[NSNumber numberWithFloat:inputAspectRatio] forKey:@"inputAspectRatio"];
- }
- [filter setValue:[NSNumber numberWithFloat:inputRadius] forKey:@"inputRadius"];
-
- FE_QUARTZ_MAP_TO_SUBREGION(bbox);
- FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h
index 176abb5..f35e028 100644
--- a/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h
+++ b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h
@@ -29,16 +29,16 @@
#include <wtf/MathExtras.h>
class Color;
-class SVGLightSource;
+class LightSource;
namespace WebCore {
-CIVector* getVectorForChannel(SVGChannelSelectorType channel);
+CIVector* getVectorForChannel(ChannelSelectorType channel);
CIColor* ciColor(const Color& c);
// Lighting
CIFilter* getPointLightVectors(CIFilter* normals, CIVector* lightPosition, float surfaceScale);
-CIFilter* getLightVectors(CIFilter* normals, const SVGLightSource* light, float surfaceScale);
+CIFilter* getLightVectors(CIFilter* normals, const LightSource* light, float surfaceScale);
CIFilter* getNormalMap(CIImage* bumpMap, float scale);
};
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm
index 5c7fc31..0f2eb75 100644
--- a/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm
+++ b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm
@@ -39,18 +39,18 @@
namespace WebCore {
-CIVector* getVectorForChannel(SVGChannelSelectorType channel)
+CIVector* getVectorForChannel(ChannelSelectorType channel)
{
switch (channel) {
- case SVG_CHANNEL_UNKNOWN:
+ case CHANNEL_UNKNOWN:
return nil;
- case SVG_CHANNEL_R:
+ case CHANNEL_R:
return [CIVector vectorWithX:1.0f Y:0.0f Z:0.0f W:0.0f];
- case SVG_CHANNEL_G:
+ case CHANNEL_G:
return [CIVector vectorWithX:0.0f Y:1.0f Z:0.0f W:0.0f];
- case SVG_CHANNEL_B:
+ case CHANNEL_B:
return [CIVector vectorWithX:0.0f Y:0.0f Z:1.0f W:0.0f];
- case SVG_CHANNEL_A:
+ case CHANNEL_A:
return [CIVector vectorWithX:0.0f Y:0.0f Z:0.0f W:1.0f];
default:
return [CIVector vectorWithX:0.0f Y:0.0f Z:0.0f W:0.0f];
@@ -82,7 +82,7 @@ CIFilter* getPointLightVectors(CIFilter* normals, CIVector* lightPosition, float
return nil;
}
-CIFilter* getLightVectors(CIFilter* normals, const SVGLightSource* light, float surfaceScale)
+CIFilter* getLightVectors(CIFilter* normals, const LightSource* light, float surfaceScale)
{
[WKDistantLightFilter class];
[WKPointLightFilter class];
@@ -94,7 +94,7 @@ CIFilter* getLightVectors(CIFilter* normals, const SVGLightSource* light, float
switch (light->type()) {
case LS_DISTANT:
{
- const SVGDistantLightSource* dlight = static_cast<const SVGDistantLightSource*>(light);
+ const DistantLightSource* dlight = static_cast<const DistantLightSource*>(light);
filter = [CIFilter filterWithName:@"WKDistantLight"];
if (!filter)
@@ -115,12 +115,12 @@ CIFilter* getLightVectors(CIFilter* normals, const SVGLightSource* light, float
}
case LS_POINT:
{
- const SVGPointLightSource* plight = static_cast<const SVGPointLightSource*>(light);
+ const PointLightSource* plight = static_cast<const PointLightSource*>(light);
return getPointLightVectors(normals, [CIVector vectorWithX:plight->position().x() Y:plight->position().y() Z:plight->position().z()], surfaceScale);
}
case LS_SPOT:
{
- const SVGSpotLightSource* slight = static_cast<const SVGSpotLightSource*>(light);
+ const SpotLightSource* slight = static_cast<const SpotLightSource*>(light);
filter = [CIFilter filterWithName:@"WKSpotLight"];
if (!filter)
return nil;
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEImageCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEImageCg.mm
deleted file mode 100644
index 2f12274..0000000
--- a/WebCore/svg/graphics/filters/cg/SVGFEImageCg.mm
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- Copyright (C) 2006, 2007 Nikolas Zimmermann <zimmermann@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 "SVGFEImage.h"
-
-#include "Image.h"
-#include "SVGFEHelpersCg.h"
-#include "CgSupport.h"
-
-namespace WebCore {
-
-CIFilter* SVGFEImage::getCIFilter(const FloatRect& bbox) const
-{
- if (!cachedImage())
- return nil;
-
- SVGResourceFilter* svgFilter = filter();
- SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
-
- CIFilter* filter;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- CIImage* ciImage = [CIImage imageWithCGImage:cachedImage()->image()->getCGImageRef()];
-
- filter = [CIFilter filterWithName:@"CIAffineTransform"];
- [filter setDefaults];
- [filter setValue:ciImage forKey:@"inputImage"];
-
- FloatRect imageRect = cachedImage()->image()->rect();
-
- // Flip image into right origin
- CGAffineTransform cgTransform = CGAffineTransformMake(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, imageRect.bottom());
- NSAffineTransform* nsTransform = [NSAffineTransform transform];
- [nsTransform setTransformStruct:*((NSAffineTransformStruct *)&cgTransform)];
- [filter setValue:nsTransform forKey:@"inputTransform"];
-
- // Calculate crop rect
- FE_QUARTZ_MAP_TO_SUBREGION_PREPARE(bbox);
-
- // Map between the image rectangle and the crop rect
- if (!cropRect.isEmpty()) {
- CIFilter* scaleImage = [CIFilter filterWithName:@"CIAffineTransform"];
- [scaleImage setDefaults];
- [scaleImage setValue:[filter valueForKey:@"outputImage"] forKey:@"inputImage"];
-
- cgTransform = CGAffineTransformMakeMapBetweenRects(CGRect(imageRect), CGRect(cropRect));
- [nsTransform setTransformStruct:*((NSAffineTransformStruct *)&cgTransform)];
- [scaleImage setValue:nsTransform forKey:@"inputTransform"];
-
- filter = scaleImage;
- }
-
- // Actually apply cropping
- FE_QUARTZ_MAP_TO_SUBREGION_APPLY(cropRect);
- FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEMergeCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEMergeCg.mm
deleted file mode 100644
index 30a981a..0000000
--- a/WebCore/svg/graphics/filters/cg/SVGFEMergeCg.mm
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <zimmermann@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 "SVGFEMerge.h"
-#include "SVGFEHelpersCg.h"
-
-namespace WebCore {
-
-CIFilter* SVGFEMerge::getCIFilter(const FloatRect& bbox) const
-{
- SVGResourceFilter* svgFilter = filter();
- SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
-
- CIFilter* filter = nil;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- const Vector<String>& inputs = mergeInputs();
-
- CIImage* previousOutput = filterPlatformData->inputImage(this);
- for (unsigned x = 0; x < inputs.size(); x++) {
- CIImage* inputImage = filterPlatformData->imageForName(inputs[x]);
- FE_QUARTZ_CHECK_INPUT(inputImage);
- FE_QUARTZ_CHECK_INPUT(previousOutput);
- filter = [CIFilter filterWithName:@"CISourceOverCompositing"];
- [filter setDefaults];
- [filter setValue:inputImage forKey:@"inputImage"];
- [filter setValue:previousOutput forKey:@"inputBackgroundImage"];
- previousOutput = [filter valueForKey:@"outputImage"];
- }
-
- FE_QUARTZ_MAP_TO_SUBREGION(bbox);
- FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEOffsetCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEOffsetCg.mm
deleted file mode 100644
index 46fb045..0000000
--- a/WebCore/svg/graphics/filters/cg/SVGFEOffsetCg.mm
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <zimmermann@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 "SVGFEOffset.h"
-#include "SVGFEHelpersCg.h"
-
-namespace WebCore {
-
-CIFilter* SVGFEOffset::getCIFilter(const FloatRect& bbox) const
-{
- SVGResourceFilter* svgFilter = filter();
- FE_QUARTZ_SETUP_INPUT(@"CIAffineTransform");
- NSAffineTransform* offsetTransform = [NSAffineTransform transform];
- [offsetTransform translateXBy:dx() yBy:dy()];
- [filter setValue:offsetTransform forKey:@"inputTransform"];
-
- FE_QUARTZ_MAP_TO_SUBREGION(bbox);
- FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFESpecularLightingCg.mm b/WebCore/svg/graphics/filters/cg/SVGFESpecularLightingCg.mm
deleted file mode 100644
index e872c6a..0000000
--- a/WebCore/svg/graphics/filters/cg/SVGFESpecularLightingCg.mm
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <zimmermann@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 "SVGFESpecularLighting.h"
-#include "SVGFEHelpersCg.h"
-
-#import "WKSpecularLightingFilter.h"
-
-namespace WebCore {
-
-CIFilter* SVGFESpecularLighting::getCIFilter(const FloatRect& bbox) const
-{
- const SVGLightSource* light = lightSource();
- if (!light)
- return nil;
-
- [WKSpecularLightingFilter class];
-
- SVGResourceFilter* svgFilter = filter();
- SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
- CIFilter* filter;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- filter = [CIFilter filterWithName:@"WKSpecularLighting"];
- [filter setDefaults];
- CIImage* inputImage = filterPlatformData->inputImage(this);
- FE_QUARTZ_CHECK_INPUT(inputImage);
- CIFilter* normals = getNormalMap(inputImage, surfaceScale());
- if (!normals)
- return nil;
- CIFilter* lightVectors = getLightVectors(normals, light, surfaceScale());
- if (!lightVectors)
- return nil;
- [filter setValue:[normals valueForKey:@"outputImage"] forKey:@"inputNormalMap"];
- [filter setValue:[lightVectors valueForKey:@"outputImage"] forKey:@"inputLightVectors"];
- [filter setValue:ciColor(lightingColor()) forKey:@"inputLightingColor"];
- [filter setValue:[NSNumber numberWithFloat:surfaceScale()] forKey:@"inputSurfaceScale"];
- [filter setValue:[NSNumber numberWithFloat:specularConstant()] forKey:@"inputSpecularConstant"];
- [filter setValue:[NSNumber numberWithFloat:specularExponent()] forKey:@"inputSpecularExponent"];
- [filter setValue:[NSNumber numberWithFloat:kernelUnitLengthX()] forKey:@"inputKernelUnitLengthX"];
- [filter setValue:[NSNumber numberWithFloat:kernelUnitLengthY()] forKey:@"inputKernelUnitLengthY"];
-
- FE_QUARTZ_MAP_TO_SUBREGION(bbox);
- FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp
index 7240c49..113f9a7 100644
--- a/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp
+++ b/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp
@@ -62,42 +62,42 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject
QPainterPath* path(context ? context->currentPath() : 0);
Q_ASSERT(path);
- RenderStyle* renderStyle = object->style();
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+ RenderStyle* style = object->style();
QGradient gradient = setupGradient(context, object);
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::NoBrush);
- if (spreadMethod() == SPREADMETHOD_REPEAT)
+ if (spreadMethod() == SpreadMethodRepeat)
gradient.setSpread(QGradient::RepeatSpread);
- else if (spreadMethod() == SPREADMETHOD_REFLECT)
+ else if (spreadMethod() == SpreadMethodReflect)
gradient.setSpread(QGradient::ReflectSpread);
else
gradient.setSpread(QGradient::PadSpread);
double opacity = 1.0;
- if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill()) {
+ if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) {
fillColorArray(gradient, gradientStops(), opacity);
QBrush brush(gradient);
brush.setMatrix(gradientTransform());
painter->setBrush(brush);
- context->setFillRule(renderStyle->svgStyle()->fillRule());
+ context->setFillRule(svgStyle->fillRule());
}
- if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke()) {
+ if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
fillColorArray(gradient, gradientStops(), opacity);
QPen pen;
QBrush brush(gradient);
brush.setMatrix(gradientTransform());
-
- setPenProperties(object, renderStyle, pen);
pen.setBrush(brush);
-
painter->setPen(pen);
+
+ applyStrokeStyleToContext(context, style, object);
}
return true;
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp
index 119e0b0..70ec14c 100644
--- a/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp
+++ b/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp
@@ -1,7 +1,6 @@
/*
Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
-
- This file is part of the KDE project
+ 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
@@ -24,54 +23,66 @@
#if ENABLE(SVG)
#include "SVGPaintServerPattern.h"
+#include "AffineTransform.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
{
- // FIXME: Reactivate old pattern code
+ Q_ASSERT(context);
+ Q_ASSERT(object);
-/*
- QPainter* painter(context ? context->platformContext() : 0);
- Q_ASSERT(painter);
+ FloatRect targetRect = object->relativeBBox(false);
+ m_ownerElement->buildPattern(targetRect);
- QPainterPath* _path = static_cast<QPainterPath*>(qtContext->path());
- Q_ASSERT(_path != 0);
+ if (!tile())
+ return false;
- RenderStyle* renderStyle = object->style();
+ 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);
- QImage* patternimage = new QImage(tile()->bits(), tile()->width(), tile()->height(), QImage::Format_ARGB32_Premultiplied);
- patternimage->setAlphaBuffer(true);
- if (type & APPLY_TO_FILL) {
- //QColor c = color();
- //c.setAlphaF(style->fillPainter()->opacity() * style->opacity() * opacity());
- KRenderingFillPainter fillPainter = KSVGPainterFactory::fillPainter(renderStyle, object);
- QBrush brush(QPixmap::fromImage(*patternimage));
- _path->setFillRule(fillPainter.fillRule() == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
+
+ AffineTransform 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 & APPLY_TO_STROKE) {
- //QColor c = color();
- //c.setAlphaF(style->strokePainter()->opacity() * style->opacity() * opacity());
- KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(renderStyle, object);
+ if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
QPen pen;
- QBrush brush(QPixmap::fromImage(*patternimage));
-
- setPenProperties(strokePainter, pen);
pen.setBrush(brush);
painter->setPen(pen);
+ applyStrokeStyleToContext(context, style, object);
}
- painter->drawPath(*_path);
-
- delete patternimage;
-*/
-
return true;
}
+void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const
+{
+ context->restore();
+}
+
} // namespace WebCore
#endif
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
index db20347..801201b 100644
--- a/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
+++ b/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2008 Holger Hans Peter Freyther
This file is part of the KDE project
@@ -33,39 +34,6 @@
namespace WebCore {
-void SVGPaintServer::setPenProperties(const RenderObject* object, const RenderStyle* style, QPen& pen) const
-{
- pen.setWidthF(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0));
-
- if (style->svgStyle()->capStyle() == ButtCap)
- pen.setCapStyle(Qt::FlatCap);
- else if (style->svgStyle()->capStyle() == RoundCap)
- pen.setCapStyle(Qt::RoundCap);
-
- if (style->svgStyle()->joinStyle() == MiterJoin) {
- pen.setJoinStyle(Qt::MiterJoin);
- pen.setMiterLimit((qreal) style->svgStyle()->strokeMiterLimit());
- } else if(style->svgStyle()->joinStyle() == RoundJoin)
- pen.setJoinStyle(Qt::RoundJoin);
-
- const DashArray& dashes = WebCore::dashArrayFromRenderingStyle(style);
- double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0);
-
- unsigned int dashLength = !dashes.isEmpty() ? dashes.size() : 0;
- if(dashLength) {
- QVector<qreal> pattern;
- unsigned int count = (dashLength % 2) == 0 ? dashLength : dashLength * 2;
-
- for(unsigned int i = 0; i < count; i++)
- pattern.append(dashes[i % dashLength] / (float)pen.widthF());
-
- pen.setDashPattern(pattern);
-
- Q_UNUSED(dashOffset);
- // TODO: dash-offset, does/will qt4 API allow it? (Rob)
- }
-}
-
void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
{
if (!setup(context, path, type))
@@ -82,7 +50,7 @@ void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTa
void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
{
- RenderStyle* renderStyle = path->style();
+ RenderStyle* renderStyle = path ? path->style(): 0;
QPainter* painter(context ? context->platformContext() : 0);
Q_ASSERT(painter);
@@ -90,10 +58,10 @@ void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* p
QPainterPath* painterPath(context ? context->currentPath() : 0);
Q_ASSERT(painterPath);
- if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill())
+ if ((type & ApplyToFillTargetType) && (!renderStyle || renderStyle->svgStyle()->hasFill()))
painter->fillPath(*painterPath, painter->brush());
- if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke())
+ if ((type & ApplyToStrokeTargetType) && (!renderStyle || renderStyle->svgStyle()->hasStroke()))
painter->strokePath(*painterPath, painter->pen());
}
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
index 7b06a03..e088df2 100644
--- a/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
+++ b/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
+ Copyright (C) 2008 Holger Hans Peter Freyther
This file is part of the KDE project
@@ -36,27 +37,33 @@ bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* o
QPainter* painter(context ? context->platformContext() : 0);
Q_ASSERT(painter);
- RenderStyle* renderStyle = object->style();
+ const SVGRenderStyle* svgStyle = object->style()->svgStyle();
+ RenderStyle* style = object ? object->style() : 0;
// TODO? painter->setOpacity(renderStyle->opacity());
QColor c = color();
- if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill()) {
- c.setAlphaF(renderStyle->svgStyle()->fillOpacity());
+ if ((type & ApplyToFillTargetType) && (!style || svgStyle->hasFill())) {
+ if (style)
+ c.setAlphaF(svgStyle->fillOpacity());
QBrush brush(c);
painter->setBrush(brush);
- context->setFillRule(renderStyle->svgStyle()->fillRule());
+
+ if (style)
+ context->setFillRule(svgStyle->fillRule());
/* if(isPaintingText()) ... */
}
- if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke()) {
- c.setAlphaF(renderStyle->svgStyle()->strokeOpacity());
+ if ((type & ApplyToStrokeTargetType) && (!style || svgStyle->hasStroke())) {
+ if (style)
+ c.setAlphaF(svgStyle->strokeOpacity());
QPen pen(c);
- setPenProperties(object, renderStyle, pen);
painter->setPen(pen);
+ if (style)
+ applyStrokeStyleToContext(context, style, object);
/* if(isPaintingText()) ... */
}
diff --git a/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp b/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp
index 557f3dd..cbf90cd 100644
--- a/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp
+++ b/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp
@@ -21,24 +21,26 @@
#include "config.h"
-#if ENABLE(SVG) && ENABLE(SVG_EXPERIMENTAL_FEATURES)
+#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&)
{
- // FIXME: implement me :-)
+ notImplemented();
}
void SVGResourceFilter::applyFilter(GraphicsContext*&, const FloatRect&)
{
- // FIXME: implement me :-)
+ notImplemented();
}
} // namespace WebCore