summaryrefslogtreecommitdiffstats
path: root/WebCore/svg/graphics
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
commit635860845790a19bf50bbc51ba8fb66a96dde068 (patch)
treeef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebCore/svg/graphics
parent8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff)
downloadexternal_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebCore/svg/graphics')
-rw-r--r--WebCore/svg/graphics/SVGImage.cpp44
-rw-r--r--WebCore/svg/graphics/SVGImage.h9
-rw-r--r--WebCore/svg/graphics/SVGPaintServer.cpp35
-rw-r--r--WebCore/svg/graphics/SVGPaintServer.h8
-rw-r--r--WebCore/svg/graphics/SVGPaintServerGradient.cpp182
-rw-r--r--WebCore/svg/graphics/SVGPaintServerGradient.h66
-rw-r--r--WebCore/svg/graphics/SVGPaintServerLinearGradient.h4
-rw-r--r--WebCore/svg/graphics/SVGPaintServerPattern.cpp102
-rw-r--r--WebCore/svg/graphics/SVGPaintServerPattern.h16
-rw-r--r--WebCore/svg/graphics/SVGPaintServerRadialGradient.h4
-rw-r--r--WebCore/svg/graphics/SVGPaintServerSolid.cpp32
-rw-r--r--WebCore/svg/graphics/SVGResource.cpp9
-rw-r--r--WebCore/svg/graphics/SVGResourceClipper.cpp39
-rw-r--r--WebCore/svg/graphics/SVGResourceMarker.cpp9
-rw-r--r--WebCore/svg/graphics/cairo/RenderPathCairo.cpp52
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp65
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp160
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp82
-rw-r--r--WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp59
-rw-r--r--WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp68
-rw-r--r--WebCore/svg/graphics/cg/CgSupport.cpp100
-rw-r--r--WebCore/svg/graphics/cg/CgSupport.h50
-rw-r--r--WebCore/svg/graphics/cg/RenderPathCg.cpp79
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerCg.cpp89
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp336
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp130
-rw-r--r--WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp77
-rw-r--r--WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp82
-rw-r--r--WebCore/svg/graphics/cg/SVGResourceFilterCg.mm10
-rw-r--r--WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm1
-rw-r--r--WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m2
-rw-r--r--WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h2
-rw-r--r--WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h2
-rw-r--r--WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm3
-rw-r--r--WebCore/svg/graphics/qt/RenderPathQt.cpp89
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp110
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp65
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp90
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerQt.cpp72
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp98
-rw-r--r--WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp78
-rw-r--r--WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp127
-rw-r--r--WebCore/svg/graphics/skia/SVGResourceFilterSkia.cpp55
-rw-r--r--WebCore/svg/graphics/skia/SVGResourceMaskerSkia.cpp49
44 files changed, 556 insertions, 2285 deletions
diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp
index 4427277..d315dfa 100644
--- a/WebCore/svg/graphics/SVGImage.cpp
+++ b/WebCore/svg/graphics/SVGImage.cpp
@@ -50,9 +50,34 @@
namespace WebCore {
+class SVGImageChromeClient : public EmptyChromeClient {
+public:
+ SVGImageChromeClient(SVGImage* image)
+ : m_image(image)
+ {
+ }
+
+ SVGImage* image() const { return m_image; }
+
+private:
+ virtual void chromeDestroyed()
+ {
+ m_image = 0;
+ }
+
+ virtual void repaint(const IntRect& r, bool, bool, bool)
+ {
+ if (m_image && m_image->imageObserver())
+ m_image->imageObserver()->changedInRect(m_image, r);
+ }
+
+ SVGImage* m_image;
+};
+
SVGImage::SVGImage(ImageObserver* observer)
: Image(observer)
, m_document(0)
+ , m_chromeClient(0)
, m_page(0)
, m_frame(0)
, m_frameView(0)
@@ -63,6 +88,14 @@ SVGImage::~SVGImage()
{
if (m_frame)
m_frame->loader()->frameDetached(); // Break both the loader and view references to the frame
+
+ // Clear these manually so we can safely delete the ChromeClient afterwards
+ m_frameView.clear();
+ m_frame.clear();
+ m_page.clear();
+
+ // Verify that page teardown destroyed the Chrome
+ ASSERT(!m_chromeClient->image());
}
void SVGImage::setContainerSize(const IntSize& containerSize)
@@ -150,7 +183,9 @@ void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
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->view()->resize(size());
+
if (m_frame->view()->needsLayout())
m_frame->view()->layout();
m_frame->view()->paint(context, enclosingIntRect(srcRect));
@@ -185,16 +220,17 @@ bool SVGImage::dataChanged(bool allDataReceived)
return true;
if (allDataReceived) {
- 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;
+ m_chromeClient.set(new SVGImageChromeClient(this));
+
// FIXME: If this SVG ends up loading itself, we'll leak this Frame (and associated DOM & render trees).
// The Cache code does not know about CachedImages holding Frames and won't know to break the cycle.
- m_page.set(new Page(dummyChromeClient, dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient));
+ m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient));
m_page->settings()->setJavaScriptEnabled(false);
m_page->settings()->setPluginsEnabled(false);
@@ -204,7 +240,7 @@ bool SVGImage::dataChanged(bool allDataReceived)
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()->load(fakeRequest, false); // 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");
diff --git a/WebCore/svg/graphics/SVGImage.h b/WebCore/svg/graphics/SVGImage.h
index 994cf91..062c0a2 100644
--- a/WebCore/svg/graphics/SVGImage.h
+++ b/WebCore/svg/graphics/SVGImage.h
@@ -39,6 +39,7 @@ namespace WebCore {
class Frame;
class FrameView;
class Page;
+ class SVGImageChromeClient;
class SVGImage : public Image {
public:
@@ -46,7 +47,9 @@ namespace WebCore {
{
return adoptRef(new SVGImage(observer));
}
- ~SVGImage();
+
+ private:
+ virtual ~SVGImage();
virtual void setContainerSize(const IntSize&);
virtual bool usesContainerSize() const;
@@ -59,18 +62,18 @@ namespace WebCore {
// 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 void destroyDecodedData(bool) { }
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();
SVGDocument* m_document;
+ OwnPtr<SVGImageChromeClient> m_chromeClient;
OwnPtr<Page> m_page;
RefPtr<Frame> m_frame;
RefPtr<FrameView> m_frameView;
diff --git a/WebCore/svg/graphics/SVGPaintServer.cpp b/WebCore/svg/graphics/SVGPaintServer.cpp
index 0240532..4e7a8cf 100644
--- a/WebCore/svg/graphics/SVGPaintServer.cpp
+++ b/WebCore/svg/graphics/SVGPaintServer.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
* 2007 Rob Buis <buis@kde.org>
+ * 2008 Dirk Schulze <krit@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -158,6 +159,40 @@ void applyStrokeStyleToContext(GraphicsContext* context, RenderStyle* style, con
context->setLineDash(dashes, dashOffset);
}
+void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
+{
+ if (!setup(context, path, type))
+ return;
+
+ renderPath(context, path, type);
+ teardown(context, path, type);
+}
+
+void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
+{
+ const SVGRenderStyle* style = path ? path->style()->svgStyle() : 0;
+
+ if ((type & ApplyToFillTargetType) && (!style || style->hasFill()))
+ context->fillPath();
+
+ if ((type & ApplyToStrokeTargetType) && (!style || style->hasStroke()))
+ context->strokePath();
+}
+
+void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool) const
+{
+#if PLATFORM(SKIA)
+ // FIXME: Move this into the GraphicsContext
+ // WebKit implicitly expects us to reset the path.
+ // For example in fillAndStrokePath() of RenderPath.cpp the path is
+ // added back to the context after filling. This is because internally it
+ // calls CGContextFillPath() which closes the path.
+ context->beginPath();
+ context->platformContext()->setGradient(0);
+ context->platformContext()->setPattern(0);
+#endif
+}
+
DashArray dashArrayFromRenderingStyle(const RenderStyle* style)
{
DashArray array;
diff --git a/WebCore/svg/graphics/SVGPaintServer.h b/WebCore/svg/graphics/SVGPaintServer.h
index 0d37e9f..9174f66 100644
--- a/WebCore/svg/graphics/SVGPaintServer.h
+++ b/WebCore/svg/graphics/SVGPaintServer.h
@@ -77,14 +77,6 @@ namespace WebCore {
static SVGPaintServerSolid* sharedSolidPaintServer();
protected:
-#if PLATFORM(CG)
- void strokePath(CGContextRef, const RenderObject*) const;
- void clipToStrokePath(CGContextRef, const RenderObject*) const;
- void fillPath(CGContextRef, const RenderObject*) const;
- void clipToFillPath(CGContextRef, const RenderObject*) const;
-#endif
-
- protected:
SVGPaintServer();
};
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.cpp b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
index 58dd6bf..b06eca1 100644
--- a/WebCore/svg/graphics/SVGPaintServerGradient.cpp
+++ b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
@@ -1,5 +1,7 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * 2008 Eric Seidel <eric@webkit.org>
+ * 2008 Dirk Schulze <krit@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,12 +30,26 @@
#if ENABLE(SVG)
#include "SVGPaintServerGradient.h"
+#include "FloatConversion.h"
+#include "GraphicsContext.h"
+#include "ImageBuffer.h"
+#include "RenderObject.h"
#include "SVGGradientElement.h"
+#include "SVGPaintServerLinearGradient.h"
+#include "SVGPaintServerRadialGradient.h"
+#include "SVGRenderSupport.h"
#include "SVGRenderTreeAsText.h"
+#if PLATFORM(CG)
+#include <wtf/MathExtras.h>
+#include <wtf/RetainPtr.h>
+#endif
+
+using namespace std;
+
namespace WebCore {
-TextStream& operator<<(TextStream& ts, GradientSpreadMethod m)
+static TextStream& operator<<(TextStream& ts, GradientSpreadMethod m)
{
switch (m) {
case SpreadMethodPad:
@@ -47,7 +63,7 @@ TextStream& operator<<(TextStream& ts, GradientSpreadMethod m)
return ts;
}
-TextStream& operator<<(TextStream& ts, const Vector<SVGGradientStop>& l)
+static TextStream& operator<<(TextStream& ts, const Vector<SVGGradientStop>& l)
{
ts << "[";
for (Vector<SVGGradientStop>::const_iterator it = l.begin(); it != l.end(); ++it) {
@@ -65,8 +81,6 @@ SVGPaintServerGradient::SVGPaintServerGradient(const SVGGradientElement* owner)
, m_ownerElement(owner)
#if PLATFORM(CG)
- , m_stopsCache(0)
- , m_shadingCache(0)
, m_savedContext(0)
, m_imageBuffer(0)
#endif
@@ -76,19 +90,16 @@ SVGPaintServerGradient::SVGPaintServerGradient(const SVGGradientElement* owner)
SVGPaintServerGradient::~SVGPaintServerGradient()
{
-#if PLATFORM(CG)
- CGShadingRelease(m_shadingCache);
-#endif
}
-const Vector<SVGGradientStop>& SVGPaintServerGradient::gradientStops() const
+Gradient* SVGPaintServerGradient::gradient() const
{
- return m_stops;
+ return m_gradient.get();
}
-void SVGPaintServerGradient::setGradientStops(const Vector<SVGGradientStop>& stops)
+void SVGPaintServerGradient::setGradient(PassRefPtr<Gradient> gradient)
{
- m_stops = stops;
+ m_gradient = gradient;
}
GradientSpreadMethod SVGPaintServerGradient::spreadMethod() const
@@ -111,16 +122,161 @@ void SVGPaintServerGradient::setBoundingBoxMode(bool mode)
m_boundingBoxMode = mode;
}
-AffineTransform SVGPaintServerGradient::gradientTransform() const
+TransformationMatrix SVGPaintServerGradient::gradientTransform() const
{
return m_gradientTransform;
}
-void SVGPaintServerGradient::setGradientTransform(const AffineTransform& transform)
+void SVGPaintServerGradient::setGradientTransform(const TransformationMatrix& transform)
{
m_gradientTransform = transform;
}
+#if PLATFORM(CG)
+// Helper function for text painting in CG
+// This Cg specific code should move to GraphicsContext and Font* in a next step.
+static inline const RenderObject* findTextRootObject(const RenderObject* start)
+{
+ while (start && !start->isSVGText())
+ start = start->parent();
+ ASSERT(start);
+ ASSERT(start->isSVGText());
+
+ return start;
+}
+
+static inline bool createMaskAndSwapContextForTextGradient(
+ GraphicsContext*& context, GraphicsContext*& savedContext,
+ OwnPtr<ImageBuffer>& imageBuffer, const RenderObject* object)
+{
+ FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->relativeBBox(false);
+ IntRect maskRect = enclosingIntRect(object->absoluteTransform().mapRect(maskBBox));
+
+ IntSize maskSize(maskRect.width(), maskRect.height());
+ clampImageBufferSizeToViewport(object->document()->renderer(), maskSize);
+
+ auto_ptr<ImageBuffer> maskImage = ImageBuffer::create(maskSize, false);
+
+ if (!maskImage.get())
+ return false;
+
+ GraphicsContext* maskImageContext = maskImage->context();
+
+ maskImageContext->save();
+ maskImageContext->translate(-maskRect.x(), -maskRect.y());
+ maskImageContext->concatCTM(object->absoluteTransform());
+
+ imageBuffer.set(maskImage.release());
+ savedContext = context;
+
+ context = maskImageContext;
+
+ return true;
+}
+
+static inline void clipToTextMask(GraphicsContext* context,
+ OwnPtr<ImageBuffer>& imageBuffer, const RenderObject* object,
+ const SVGPaintServerGradient* gradientServer)
+{
+ FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->relativeBBox(false);
+
+ // Fixup transformations to be able to clip to mask
+ TransformationMatrix transform = object->absoluteTransform();
+ FloatRect textBoundary = transform.mapRect(maskBBox);
+
+ IntSize maskSize(lroundf(textBoundary.width()), lroundf(textBoundary.height()));
+ clampImageBufferSizeToViewport(object->document()->renderer(), maskSize);
+ textBoundary.setSize(textBoundary.size().shrunkTo(maskSize));
+
+ // Clip current context to mask image (gradient)
+ context->concatCTM(transform.inverse());
+ context->clipToImageBuffer(textBoundary, imageBuffer.get());
+ context->concatCTM(transform);
+
+ if (gradientServer->boundingBoxMode()) {
+ context->translate(maskBBox.x(), maskBBox.y());
+ context->scale(FloatSize(maskBBox.width(), maskBBox.height()));
+ }
+ context->concatCTM(gradientServer->gradientTransform());
+}
+#endif
+
+bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ m_ownerElement->buildGradient();
+
+ const SVGRenderStyle* style = object->style()->svgStyle();
+ bool isFilled = (type & ApplyToFillTargetType) && style->hasFill();
+ bool isStroked = (type & ApplyToStrokeTargetType) && style->hasStroke();
+
+ ASSERT(isFilled && !isStroked || !isFilled && isStroked);
+
+ context->save();
+
+ if (isPaintingText) {
+#if PLATFORM(CG)
+ if (!createMaskAndSwapContextForTextGradient(context, m_savedContext, m_imageBuffer, object)) {
+ context->restore();
+ return false;
+ }
+#endif
+ context->setTextDrawingMode(isFilled ? cTextFill : cTextStroke);
+ }
+
+ if (isFilled) {
+ context->setAlpha(style->fillOpacity());
+ context->setFillGradient(m_gradient);
+ context->setFillRule(style->fillRule());
+ }
+ if (isStroked) {
+ context->setAlpha(style->strokeOpacity());
+ context->setStrokeGradient(m_gradient);
+ applyStrokeStyleToContext(context, object->style(), object);
+ }
+
+ if (boundingBoxMode() && !isPaintingText) {
+ FloatRect bbox = object->relativeBBox(false);
+ // Don't use gradientes for 1d objects like horizontal/vertical
+ // lines or rectangles without width or height.
+ if (bbox.width() == 0 || bbox.height() == 0) {
+ Color color(0, 0, 0);
+ context->setStrokeColor(color);
+ return true;
+ }
+ context->translate(bbox.x(), bbox.y());
+ context->scale(FloatSize(bbox.width(), bbox.height()));
+
+ // With scaling the context, the strokeThickness is scaled too. We have to
+ // undo this.
+ float strokeThickness = std::max((context->strokeThickness() / ((bbox.width() + bbox.height()) / 2) - 0.001f), 0.f);
+ context->setStrokeThickness(strokeThickness);
+ }
+ context->concatCTM(gradientTransform());
+ context->setSpreadMethod(spreadMethod());
+
+ return true;
+}
+
+void SVGPaintServerGradient::teardown(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType, bool isPaintingText) const
+{
+#if PLATFORM(CG)
+ // renderPath() is not used when painting text, so we paint the gradient during teardown()
+ if (isPaintingText && m_savedContext) {
+ // Restore on-screen drawing context
+ context = m_savedContext;
+ m_savedContext = 0;
+
+ clipToTextMask(context, m_imageBuffer, object, this);
+
+ // finally fill the text clip with the shading
+ CGContextDrawShading(context->platformContext(), m_gradient->platformGradient());
+
+ m_imageBuffer.clear(); // we're done with our text mask buffer
+ }
+#endif
+ context->restore();
+}
+
TextStream& SVGPaintServerGradient::externalRepresentation(TextStream& ts) const
{
// Gradients/patterns aren't setup, until they are used for painting. Work around that fact.
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.h b/WebCore/svg/graphics/SVGPaintServerGradient.h
index 99dac8e..16dab0b 100644
--- a/WebCore/svg/graphics/SVGPaintServerGradient.h
+++ b/WebCore/svg/graphics/SVGPaintServerGradient.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * 2008 Eric Seidel <eric@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,38 +29,28 @@
#if ENABLE(SVG)
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "Color.h"
+#include "Gradient.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 {
class ImageBuffer;
class SVGGradientElement;
-#if PLATFORM(CG)
- typedef std::pair<CGFloat, Color> SVGGradientStop;
-#else
typedef std::pair<float, Color> SVGGradientStop;
-#endif
class SVGPaintServerGradient : public SVGPaintServer {
public:
virtual ~SVGPaintServerGradient();
- const Vector<SVGGradientStop>& gradientStops() const;
- void setGradientStops(const Vector<SVGGradientStop>&);
+ void setGradient(PassRefPtr<Gradient>);
+ Gradient* gradient() const;
GradientSpreadMethod spreadMethod() const;
void setGradientSpreadMethod(const GradientSpreadMethod&);
@@ -70,63 +61,32 @@ namespace WebCore {
bool boundingBoxMode() const;
void setBoundingBoxMode(bool mode = true);
- AffineTransform gradientTransform() const;
- void setGradientTransform(const AffineTransform&);
+ TransformationMatrix gradientTransform() const;
+ void setGradientTransform(const TransformationMatrix&);
+
+ void setGradientStops(const Vector<SVGGradientStop>& stops) { m_stops = stops; }
+ const Vector<SVGGradientStop>& gradientStops() const { return m_stops; }
virtual TextStream& externalRepresentation(TextStream&) const;
virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
-#if PLATFORM(CG)
virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
- virtual void renderPath(GraphicsContext*&, const RenderObject*, SVGPaintTargetType) const;
-
- virtual void invalidate();
-
- // Helpers
- void updateQuartzGradientStopsCache(const Vector<SVGGradientStop>&);
- void updateQuartzGradientCache(const SVGPaintServerGradient*);
- void handleBoundingBoxModeAndGradientTransformation(GraphicsContext*, const FloatRect& targetRect) const;
-#endif
-
-#if PLATFORM(QT)
- protected:
- void fillColorArray(QGradient&, const Vector<SVGGradientStop>&, float opacity) const;
- virtual QGradient setupGradient(GraphicsContext*&, const RenderObject*) const = 0;
-#endif
protected:
SVGPaintServerGradient(const SVGGradientElement* owner);
private:
Vector<SVGGradientStop> m_stops;
+ RefPtr<Gradient> m_gradient;
GradientSpreadMethod m_spreadMethod;
bool m_boundingBoxMode;
- AffineTransform m_gradientTransform;
+ TransformationMatrix m_gradientTransform;
const SVGGradientElement* m_ownerElement;
#if PLATFORM(CG)
public:
- typedef struct {
- CGFloat colorArray[4];
- CGFloat offset;
- CGFloat previousDeltaInverse;
- } 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;
-
- CGShadingRef m_shadingCache;
mutable GraphicsContext* m_savedContext;
- mutable ImageBuffer* m_imageBuffer;
+ mutable OwnPtr<ImageBuffer> m_imageBuffer;
#endif
};
diff --git a/WebCore/svg/graphics/SVGPaintServerLinearGradient.h b/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
index 4b7da32..f0568c7 100644
--- a/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
+++ b/WebCore/svg/graphics/SVGPaintServerLinearGradient.h
@@ -48,10 +48,6 @@ namespace WebCore {
virtual TextStream& externalRepresentation(TextStream&) const;
-#if PLATFORM(QT)
- virtual QGradient setupGradient(GraphicsContext*&, const RenderObject*) const;
-#endif
-
private:
SVGPaintServerLinearGradient(const SVGGradientElement* owner);
diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.cpp b/WebCore/svg/graphics/SVGPaintServerPattern.cpp
index c0e5b07..5926aad 100644
--- a/WebCore/svg/graphics/SVGPaintServerPattern.cpp
+++ b/WebCore/svg/graphics/SVGPaintServerPattern.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * 2008 Dirk Schulze <krit@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,9 +29,14 @@
#if ENABLE(SVG)
#include "SVGPaintServerPattern.h"
+#include "GraphicsContext.h"
+#include "Image.h"
#include "ImageBuffer.h"
+#include "Pattern.h"
+#include "RenderObject.h"
#include "SVGPatternElement.h"
#include "SVGRenderTreeAsText.h"
+#include "TransformationMatrix.h"
using namespace std;
@@ -38,20 +44,13 @@ namespace WebCore {
SVGPaintServerPattern::SVGPaintServerPattern(const SVGPatternElement* owner)
: m_ownerElement(owner)
-#if PLATFORM(CG)
- , m_patternSpace(0)
, m_pattern(0)
-#endif
{
ASSERT(owner);
}
SVGPaintServerPattern::~SVGPaintServerPattern()
{
-#if PLATFORM(CG)
- CGPatternRelease(m_pattern);
- CGColorSpaceRelease(m_patternSpace);
-#endif
}
FloatRect SVGPaintServerPattern::patternBoundaries() const
@@ -74,12 +73,12 @@ void SVGPaintServerPattern::setTile(auto_ptr<ImageBuffer> tile)
m_tile.set(tile.release());
}
-AffineTransform SVGPaintServerPattern::patternTransform() const
+TransformationMatrix SVGPaintServerPattern::patternTransform() const
{
return m_patternTransform;
}
-void SVGPaintServerPattern::setPatternTransform(const AffineTransform& transform)
+void SVGPaintServerPattern::setPatternTransform(const TransformationMatrix& transform)
{
m_patternTransform = transform;
}
@@ -96,6 +95,91 @@ TextStream& SVGPaintServerPattern::externalRepresentation(TextStream& ts) const
return ts;
}
+bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ FloatRect targetRect;
+ if (isPaintingText) {
+ IntRect textBoundary = const_cast<RenderObject*>(object)->absoluteBoundingBoxRect();
+ targetRect = object->absoluteTransform().inverse().mapRect(textBoundary);
+ } else
+ targetRect = object->relativeBBox(false);
+
+ const SVGRenderStyle* style = object->style()->svgStyle();
+ bool isFilled = (type & ApplyToFillTargetType) && style->hasFill();
+ bool isStroked = (type & ApplyToStrokeTargetType) && style->hasStroke();
+
+ ASSERT(isFilled && !isStroked || !isFilled && isStroked);
+
+ m_ownerElement->buildPattern(targetRect);
+ if (!tile())
+ return false;
+
+ context->save();
+ context->translate(patternBoundaries().x(), patternBoundaries().y());
+ context->concatCTM(patternTransform());
+
+ ASSERT(!m_pattern);
+
+ IntRect tileRect = tile()->image()->rect();
+ if (tileRect.width() > patternBoundaries().width() || tileRect.height() > patternBoundaries().height()) {
+ // Draw the first cell of the pattern manually to support overflow="visible" on all platforms.
+ int tileWidth = static_cast<int>(patternBoundaries().width() + 0.5f);
+ int tileHeight = static_cast<int>(patternBoundaries().height() + 0.5f);
+ std::auto_ptr<ImageBuffer> tileImage = ImageBuffer::create(IntSize(tileWidth, tileHeight), false);
+
+ GraphicsContext* tileImageContext = tileImage->context();
+
+ int numY = static_cast<int>(ceilf(tileRect.height() / tileHeight)) + 1;
+ int numX = static_cast<int>(ceilf(tileRect.width() / tileWidth)) + 1;
+
+ tileImageContext->save();
+ tileImageContext->translate(-patternBoundaries().width() * numX, -patternBoundaries().height() * numY);
+ for (int i = numY; i > 0; i--) {
+ tileImageContext->translate(0, patternBoundaries().height());
+ for (int j = numX; j > 0; j--) {
+ tileImageContext->translate(patternBoundaries().width(), 0);
+ tileImageContext->drawImage(tile()->image(), tileRect, tileRect);
+ }
+ tileImageContext->translate(-patternBoundaries().width() * numX, 0);
+ }
+ tileImageContext->restore();
+
+ m_pattern = Pattern::create(tileImage->image(), true, true);
+ }
+ else
+ m_pattern = Pattern::create(tile()->image(), true, true);
+
+ if (isFilled) {
+ context->setAlpha(style->fillOpacity());
+ context->setFillPattern(m_pattern);
+ context->setFillRule(style->fillRule());
+ }
+ if (isStroked) {
+ context->setAlpha(style->strokeOpacity());
+ context->setStrokePattern(m_pattern);
+ applyStrokeStyleToContext(context, object->style(), object);
+ }
+
+ if (isPaintingText) {
+ context->setTextDrawingMode(isFilled ? cTextFill : cTextStroke);
+#if PLATFORM(CG)
+ if (isFilled)
+ context->applyFillPattern();
+ else
+ context->applyStrokePattern();
+#endif
+ }
+
+ return true;
+}
+
+void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const
+{
+ m_pattern = 0;
+
+ context->restore();
+}
+
} // namespace WebCore
#endif
diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.h b/WebCore/svg/graphics/SVGPaintServerPattern.h
index 65b28e9..48acd51 100644
--- a/WebCore/svg/graphics/SVGPaintServerPattern.h
+++ b/WebCore/svg/graphics/SVGPaintServerPattern.h
@@ -28,8 +28,9 @@
#if ENABLE(SVG)
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "FloatRect.h"
+#include "Pattern.h"
#include "SVGPaintServer.h"
#include <memory>
@@ -57,28 +58,23 @@ namespace WebCore {
ImageBuffer* tile() const;
void setTile(std::auto_ptr<ImageBuffer>);
- AffineTransform patternTransform() const;
- void setPatternTransform(const AffineTransform&);
+ TransformationMatrix patternTransform() const;
+ void setPatternTransform(const TransformationMatrix&);
virtual TextStream& externalRepresentation(TextStream&) const;
virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
-#if PLATFORM(CG) || PLATFORM(QT)
virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
-#endif
private:
SVGPaintServerPattern(const SVGPatternElement*);
OwnPtr<ImageBuffer> m_tile;
const SVGPatternElement* m_ownerElement;
- AffineTransform m_patternTransform;
+ TransformationMatrix m_patternTransform;
FloatRect m_patternBoundaries;
-#if PLATFORM(CG)
- mutable CGColorSpaceRef m_patternSpace;
- mutable CGPatternRef m_pattern;
-#endif
+ mutable RefPtr<Pattern> m_pattern;
};
} // namespace WebCore
diff --git a/WebCore/svg/graphics/SVGPaintServerRadialGradient.h b/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
index 265f76b..749ba08 100644
--- a/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
+++ b/WebCore/svg/graphics/SVGPaintServerRadialGradient.h
@@ -51,10 +51,6 @@ namespace WebCore {
virtual TextStream& externalRepresentation(TextStream&) const;
-#if PLATFORM(QT)
- virtual QGradient setupGradient(GraphicsContext*&, const RenderObject*) const;
-#endif
-
private:
SVGPaintServerRadialGradient(const SVGGradientElement* owner);
diff --git a/WebCore/svg/graphics/SVGPaintServerSolid.cpp b/WebCore/svg/graphics/SVGPaintServerSolid.cpp
index cb58a3a..b333042 100644
--- a/WebCore/svg/graphics/SVGPaintServerSolid.cpp
+++ b/WebCore/svg/graphics/SVGPaintServerSolid.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,6 +28,9 @@
#if ENABLE(SVG)
#include "SVGPaintServerSolid.h"
+
+#include "GraphicsContext.h"
+#include "RenderPath.h"
#include "SVGRenderTreeAsText.h"
namespace WebCore {
@@ -56,6 +60,34 @@ TextStream& SVGPaintServerSolid::externalRepresentation(TextStream& ts) const
return ts;
}
+bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+ RenderStyle* style = object ? object->style() : 0;
+ const SVGRenderStyle* svgStyle = style ? style->svgStyle() : 0;
+
+ if ((type & ApplyToFillTargetType) && (!style || svgStyle->hasFill())) {
+ context->setAlpha(style ? svgStyle->fillOpacity() : 1);
+ context->setFillColor(color().rgb());
+ context->setFillRule(style ? svgStyle->fillRule() : RULE_NONZERO);
+
+ if (isPaintingText)
+ context->setTextDrawingMode(cTextFill);
+ }
+
+ if ((type & ApplyToStrokeTargetType) && (!style || svgStyle->hasStroke())) {
+ context->setAlpha(style ? svgStyle->strokeOpacity() : 1);
+ context->setStrokeColor(color().rgb());
+
+ if (style)
+ applyStrokeStyleToContext(context, style, object);
+
+ if (isPaintingText)
+ context->setTextDrawingMode(cTextStroke);
+ }
+
+ return true;
+}
+
} // namespace WebCore
#endif
diff --git a/WebCore/svg/graphics/SVGResource.cpp b/WebCore/svg/graphics/SVGResource.cpp
index 10d6648..82c10ba 100644
--- a/WebCore/svg/graphics/SVGResource.cpp
+++ b/WebCore/svg/graphics/SVGResource.cpp
@@ -31,6 +31,7 @@
#include "RenderPath.h"
#include "SVGElement.h"
#include "SVGStyledElement.h"
+#include <wtf/StdLibExtras.h>
namespace WebCore {
@@ -47,8 +48,10 @@ struct ResourceSet {
SVGResource* resources[_ResourceTypeCount];
};
-static HashMap<SVGStyledElement*, ResourceSet*>& clientMap() {
- static HashMap<SVGStyledElement*, ResourceSet*> map;
+typedef HashMap<SVGStyledElement*, ResourceSet*> ResourceClientMap;
+
+static ResourceClientMap& clientMap() {
+ DEFINE_STATIC_LOCAL(ResourceClientMap, map, ());
return map;
}
@@ -116,7 +119,7 @@ void SVGResource::invalidateClients(HashSet<SVGStyledElement*> clients)
void SVGResource::removeClient(SVGStyledElement* item)
{
- HashMap<SVGStyledElement*, ResourceSet*>::iterator resourcePtr = clientMap().find(item);
+ ResourceClientMap::iterator resourcePtr = clientMap().find(item);
if (resourcePtr == clientMap().end())
return;
diff --git a/WebCore/svg/graphics/SVGResourceClipper.cpp b/WebCore/svg/graphics/SVGResourceClipper.cpp
index f03f5c2..51bda0d 100644
--- a/WebCore/svg/graphics/SVGResourceClipper.cpp
+++ b/WebCore/svg/graphics/SVGResourceClipper.cpp
@@ -28,8 +28,14 @@
#if ENABLE(SVG)
#include "SVGResourceClipper.h"
+#include "TransformationMatrix.h"
+#include "GraphicsContext.h"
#include "SVGRenderTreeAsText.h"
+#if PLATFORM(CG)
+#include <ApplicationServices/ApplicationServices.h>
+#endif
+
namespace WebCore {
SVGResourceClipper::SVGResourceClipper()
@@ -46,6 +52,39 @@ void SVGResourceClipper::resetClipData()
m_clipData.clear();
}
+void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
+{
+ if (m_clipData.clipData().isEmpty())
+ return;
+
+ bool heterogenousClipRules = false;
+ WindRule clipRule = m_clipData.clipData()[0].windRule;
+
+ context->beginPath();
+
+ for (unsigned x = 0; x < m_clipData.clipData().size(); x++) {
+ ClipData clipData = m_clipData.clipData()[x];
+ if (clipData.windRule != clipRule)
+ heterogenousClipRules = true;
+
+ Path clipPath = clipData.path;
+
+ if (clipData.bboxUnits) {
+ TransformationMatrix transform;
+ transform.translate(boundingBox.x(), boundingBox.y());
+ transform.scale(boundingBox.width(), boundingBox.height());
+ clipPath.transform(transform);
+ }
+ context->addPath(clipPath);
+ }
+
+ // FIXME!
+ // We don't currently allow for heterogenous clip rules.
+ // we would have to detect such, draw to a mask, and then clip
+ // to that mask
+ context->clipPath(clipRule);
+}
+
void SVGResourceClipper::addClipData(const Path& path, WindRule rule, bool bboxUnits)
{
m_clipData.addPath(path, rule, bboxUnits);
diff --git a/WebCore/svg/graphics/SVGResourceMarker.cpp b/WebCore/svg/graphics/SVGResourceMarker.cpp
index 3649321..c50f5e3 100644
--- a/WebCore/svg/graphics/SVGResourceMarker.cpp
+++ b/WebCore/svg/graphics/SVGResourceMarker.cpp
@@ -28,10 +28,11 @@
#if ENABLE(SVG)
#include "SVGResourceMarker.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "GraphicsContext.h"
#include "RenderSVGViewportContainer.h"
#include "TextStream.h"
+#include <wtf/StdLibExtras.h>
namespace WebCore {
@@ -65,7 +66,7 @@ void SVGResourceMarker::draw(GraphicsContext* context, const FloatRect& rect, do
if (!m_marker)
return;
- static HashSet<SVGResourceMarker*> currentlyDrawingMarkers;
+ DEFINE_STATIC_LOCAL(HashSet<SVGResourceMarker*>, currentlyDrawingMarkers, ());
// avoid drawing circular marker references
if (currentlyDrawingMarkers.contains(this))
@@ -73,13 +74,13 @@ void SVGResourceMarker::draw(GraphicsContext* context, const FloatRect& rect, do
currentlyDrawingMarkers.add(this);
- AffineTransform transform;
+ TransformationMatrix transform;
transform.translate(x, y);
transform.rotate(m_angle > -1 ? m_angle : angle);
// refX and refY are given in coordinates relative to the viewport established by the marker, yet they affect
// the translation performed on the viewport itself.
- AffineTransform viewportTransform;
+ TransformationMatrix viewportTransform;
if (m_useStrokeWidth)
viewportTransform.scale(strokeWidth, strokeWidth);
viewportTransform *= m_marker->viewportTransform();
diff --git a/WebCore/svg/graphics/cairo/RenderPathCairo.cpp b/WebCore/svg/graphics/cairo/RenderPathCairo.cpp
deleted file mode 100644
index 72379b5..0000000
--- a/WebCore/svg/graphics/cairo/RenderPathCairo.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "RenderPath.h"
-
-#include "CairoPath.h"
-#include "SVGPaintServer.h"
-
-namespace WebCore {
-
-bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const
-{
- if (requiresStroke && !SVGPaintServer::strokePaintServer(style(), this))
- return false;
-
- cairo_t* cr = path().platformPath()->m_cr;
-
- // TODO: set stroke properties
- return cairo_in_stroke(cr, point.x(), point.y());
-}
-
-FloatRect RenderPath::strokeBBox() const
-{
- // TODO: this implementation is naive
-
- cairo_t* cr = path().platformPath()->m_cr;
-
- double x0, x1, y0, y1;
- cairo_stroke_extents(cr, &x0, &y0, &x1, &y1);
- FloatRect bbox = FloatRect(x0, y0, x1 - x0, y1 - y0);
-
- return bbox;
-}
-
-}
diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp
deleted file mode 100644
index 37cab6f..0000000
--- a/WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServer.h"
-
-#include "GraphicsContext.h"
-#include "SVGPaintServer.h"
-#include "RenderPath.h"
-
-#include <cairo.h>
-
-namespace WebCore {
-
-void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
-{
- if (!setup(context, path, type))
- return;
-
- renderPath(context, path, type);
- teardown(context, path, type);
-}
-
-void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const
-{
- // no-op
-}
-
-void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
-{
- cairo_t* cr = context->platformContext();
- const SVGRenderStyle* style = path->style()->svgStyle();
-
- cairo_set_fill_rule(cr, style->fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
-
- if ((type & ApplyToFillTargetType) && style->hasFill())
- cairo_fill_preserve(cr);
-
- if ((type & ApplyToStrokeTargetType) && style->hasStroke())
- cairo_stroke_preserve(cr);
-
- cairo_new_path(cr);
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp
deleted file mode 100644
index e237962..0000000
--- a/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerGradient.h"
-#include "SVGPaintServerLinearGradient.h"
-#include "SVGPaintServerRadialGradient.h"
-
-#include "GraphicsContext.h"
-#include "RenderObject.h"
-#include "RenderPath.h"
-#include "RenderStyle.h"
-#include "SVGGradientElement.h"
-
-namespace WebCore {
-
-bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
-{
- m_ownerElement->buildGradient();
-
- cairo_t* cr = context->platformContext();
- cairo_pattern_t* pattern;
-
- cairo_matrix_t matrix;
- cairo_matrix_init_identity (&matrix);
- const cairo_matrix_t gradient_matrix = gradientTransform();
-
- const SVGRenderStyle* svgStyle = object->style()->svgStyle();
- RenderStyle* style = object->style();
-
- if (this->type() == LinearGradientPaintServer) {
- const SVGPaintServerLinearGradient* linear = static_cast<const SVGPaintServerLinearGradient*>(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 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);
-
- 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;
- }
-
- cairo_pattern_set_filter(pattern, CAIRO_FILTER_BILINEAR);
-
- switch (spreadMethod()) {
- case SpreadMethodPad:
- cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD);
- break;
- case SpreadMethodReflect:
- cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REFLECT);
- break;
- case SpreadMethodRepeat:
- cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
- break;
- default:
- cairo_pattern_set_extend(pattern, CAIRO_EXTEND_NONE);
- break;
- }
-
- cairo_matrix_multiply(&matrix, &matrix, &gradient_matrix);
- cairo_matrix_invert(&matrix);
- cairo_pattern_set_matrix(pattern, &matrix);
-
- const Vector<SVGGradientStop>& stops = gradientStops();
-
- 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() / 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);
-
- return true;
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp
deleted file mode 100644
index 86530bc..0000000
--- a/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#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
-{
- 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;
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp
deleted file mode 100644
index 49e6f55..0000000
--- a/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerSolid.h"
-
-#include "GraphicsContext.h"
-#include "SVGPaintServer.h"
-#include "RenderPath.h"
-
-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* svgStyle = object->style()->svgStyle();
- RenderStyle* style = object->style();
-
- float red, green, blue, alpha;
- color().getRGBA(red, green, blue, alpha);
-
- if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) {
- alpha = svgStyle->fillOpacity();
- context->setFillRule(svgStyle->fillRule());
- }
-
- if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
- alpha = svgStyle->strokeOpacity();
- applyStrokeStyleToContext(context, style, object);
- }
-
- cairo_set_source_rgba(cr, red, green, blue, alpha);
-
- return true;
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp b/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp
deleted file mode 100644
index 6aec0ae..0000000
--- a/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGResourceClipper.h"
-#include "AffineTransform.h"
-#include "CairoPath.h"
-#include "GraphicsContext.h"
-
-#include <cairo.h>
-
-namespace WebCore {
-
-void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
-{
- cairo_t* cr = context->platformContext();
- if (m_clipData.clipData().size() < 1)
- return;
-
- cairo_reset_clip(cr);
- context->beginPath();
-
- for (unsigned int x = 0; x < m_clipData.clipData().size(); x++) {
- ClipData data = m_clipData.clipData()[x];
-
- Path path = data.path;
- if (path.isEmpty())
- continue;
- path.closeSubpath();
-
- 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.windRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
- }
-
- cairo_clip(cr);
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/svg/graphics/cg/CgSupport.cpp b/WebCore/svg/graphics/cg/CgSupport.cpp
deleted file mode 100644
index f9bfb4c..0000000
--- a/WebCore/svg/graphics/cg/CgSupport.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- * 2006 Rob Buis <buis@kde.org>
- * 2008 Nikolas Zimmermann <zimmermann@kde.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.
- */
-
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "CgSupport.h"
-
-#include <ApplicationServices/ApplicationServices.h>
-#include "FloatConversion.h"
-#include "GraphicsContext.h"
-#include "RenderStyle.h"
-#include "SVGPaintServer.h"
-#include "SVGRenderStyle.h"
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-CGContextRef scratchContext()
-{
- static CGContextRef scratch = 0;
- if (!scratch) {
- CFMutableDataRef empty = CFDataCreateMutable(NULL, 0);
- CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData(empty);
- scratch = CGPDFContextCreate(consumer, NULL, NULL);
- CGDataConsumerRelease(consumer);
- CFRelease(empty);
-
- CGFloat black[4] = {0, 0, 0, 1};
- CGContextSetFillColor(scratch, black);
- CGContextSetStrokeColor(scratch, black);
- }
- return scratch;
-}
-
-FloatRect strokeBoundingBox(const Path& path, RenderStyle* style, const RenderObject* object)
- {
- // the bbox might grow if the path is stroked.
- // and CGPathGetBoundingBox doesn't support that, so we'll have
- // to make an alternative call...
-
- // FIXME: since this is mainly used to decide what to repaint,
- // 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.
-
- CGPathRef cgPath = path.platformPath();
-
- CGContextRef context = scratchContext();
- CGContextSaveGState(context);
-
- CGContextBeginPath(context);
- CGContextAddPath(context, cgPath);
-
- GraphicsContext gc(context);
- applyStrokeStyleToContext(&gc, style, object);
-
- CGContextReplacePathWithStrokedPath(context);
- if (CGContextIsPathEmpty(context)) {
- // CGContextReplacePathWithStrokedPath seems to fail to create a path sometimes, this is not well understood.
- // returning here prevents CG from logging to the console from CGContextGetPathBoundingBox
- CGContextRestoreGState(context);
- return FloatRect();
- }
-
- CGRect box = CGContextGetPathBoundingBox(context);
- CGContextRestoreGState(context);
-
- return FloatRect(box);
-}
-
-}
-
-#endif // ENABLE(SVG)
-
diff --git a/WebCore/svg/graphics/cg/CgSupport.h b/WebCore/svg/graphics/cg/CgSupport.h
deleted file mode 100644
index de6e4b3..0000000
--- a/WebCore/svg/graphics/cg/CgSupport.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE 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 CgSupport_h
-#define CgSupport_h
-
-#if ENABLE(SVG)
-
-#include <ApplicationServices/ApplicationServices.h>
-#include "GraphicsTypes.h"
-
-namespace WebCore {
-
-typedef struct CGPath *CGMutablePathRef;
-
-class Path;
-class FloatRect;
-class RenderStyle;
-class RenderObject;
-class GraphicsContext;
-
-CGContextRef scratchContext();
-FloatRect strokeBoundingBox(const Path& path, RenderStyle*, const RenderObject*);
-
-}
-
-#endif // ENABLE(SVG)
-#endif // !CgSupport_h
diff --git a/WebCore/svg/graphics/cg/RenderPathCg.cpp b/WebCore/svg/graphics/cg/RenderPathCg.cpp
deleted file mode 100644
index eb8e482..0000000
--- a/WebCore/svg/graphics/cg/RenderPathCg.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- * (C) 2006 Alexander Kellett <lypanov@kde.org>
- * 2006 Rob Buis <buis@kde.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.
- */
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "RenderPath.h"
-
-#include <ApplicationServices/ApplicationServices.h>
-#include "CgSupport.h"
-#include "GraphicsContext.h"
-#include "SVGPaintServer.h"
-#include "SVGRenderStyle.h"
-#include "SVGStyledElement.h"
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-FloatRect RenderPath::strokeBBox() const
-{
- if (style()->svgStyle()->hasStroke())
- return strokeBoundingBox(path(), style(), this);
-
- return path().boundingRect();
-}
-
-
-bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const
-{
- if (path().isEmpty())
- return false;
-
- if (requiresStroke && !SVGPaintServer::strokePaintServer(style(), this))
- return false;
-
- CGMutablePathRef cgPath = path().platformPath();
-
- CGContextRef context = scratchContext();
- CGContextSaveGState(context);
-
- CGContextBeginPath(context);
- CGContextAddPath(context, cgPath);
-
- GraphicsContext gc(context);
- applyStrokeStyleToContext(&gc, style(), this);
-
- bool hitSuccess = CGContextPathContainsPoint(context, point, kCGPathStroke);
- CGContextRestoreGState(context);
-
- return hitSuccess;
-}
-
-}
-
-#endif // ENABLE(SVG)
diff --git a/WebCore/svg/graphics/cg/SVGPaintServerCg.cpp b/WebCore/svg/graphics/cg/SVGPaintServerCg.cpp
deleted file mode 100644
index 35eb239..0000000
--- a/WebCore/svg/graphics/cg/SVGPaintServerCg.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
-
- This file is part of the KDE project
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServer.h"
-
-#include "GraphicsContext.h"
-#include "RenderObject.h"
-
-namespace WebCore {
-
-void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
-{
- if (!setup(context, path, type))
- return;
-
- renderPath(context, path, type);
- teardown(context, path, type);
-}
-
-void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const
-{
- // no-op
-}
-
-void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
-{
- RenderStyle* style = path ? path->style() : 0;
- CGContextRef contextRef = context->platformContext();
-
- if ((type & ApplyToFillTargetType) && (!style || style->svgStyle()->hasFill()))
- fillPath(contextRef, path);
-
- if ((type & ApplyToStrokeTargetType) && (!style || style->svgStyle()->hasStroke()))
- strokePath(contextRef, path);
-}
-
-void SVGPaintServer::strokePath(CGContextRef context, const RenderObject*) const
-{
- CGContextStrokePath(context);
-}
-
-void SVGPaintServer::clipToStrokePath(CGContextRef context, const RenderObject*) const
-{
- CGContextReplacePathWithStrokedPath(context);
- CGContextClip(context);
-}
-
-void SVGPaintServer::fillPath(CGContextRef context, const RenderObject* path) const
-{
- if (!path || path->style()->svgStyle()->fillRule() == RULE_EVENODD)
- CGContextEOFillPath(context);
- else
- CGContextFillPath(context);
-}
-
-void SVGPaintServer::clipToFillPath(CGContextRef context, const RenderObject* path) const
-{
- if (!path || path->style()->svgStyle()->fillRule() == RULE_EVENODD)
- CGContextEOClip(context);
- else
- CGContextClip(context);
-}
-
-} // namespace WebCore
-
-#endif
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp b/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp
deleted file mode 100644
index bfa5017..0000000
--- a/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- Copyright (C) 2006, 2007, 2008 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)
-#include "SVGPaintServerGradient.h"
-
-#include "FloatConversion.h"
-#include "GraphicsContext.h"
-#include "ImageBuffer.h"
-#include "RenderObject.h"
-#include "SVGGradientElement.h"
-#include "SVGPaintServerLinearGradient.h"
-#include "SVGPaintServerRadialGradient.h"
-#include "SVGRenderSupport.h"
-
-#include <wtf/MathExtras.h>
-
-using namespace std;
-
-namespace WebCore {
-
-static void releaseCachedStops(void* info)
-{
- static_cast<SVGPaintServerGradient::SharedStopCache*>(info)->deref();
-}
-
-static void cgGradientCallback(void* info, const CGFloat* inValues, CGFloat* outColor)
-{
- SVGPaintServerGradient::SharedStopCache* stopsCache = static_cast<SVGPaintServerGradient::SharedStopCache*>(info);
-
- SVGPaintServerGradient::QuartzGradientStop* stops = stopsCache->m_stops.data();
-
- int stopsCount = stopsCache->m_stops.size();
-
- CGFloat inValue = inValues[0];
-
- if (!stopsCount) {
- outColor[0] = 0;
- outColor[1] = 0;
- outColor[2] = 0;
- outColor[3] = 0;
- return;
- } else if (stopsCount == 1) {
- memcpy(outColor, stops[0].colorArray, 4 * sizeof(CGFloat));
- return;
- }
-
- if (!(inValue > stops[0].offset))
- memcpy(outColor, stops[0].colorArray, 4 * sizeof(CGFloat));
- else if (!(inValue < stops[stopsCount - 1].offset))
- memcpy(outColor, stops[stopsCount - 1].colorArray, 4 * sizeof(CGFloat));
- else {
- int nextStopIndex = 0;
- while ((nextStopIndex < stopsCount) && (stops[nextStopIndex].offset < inValue))
- nextStopIndex++;
-
- CGFloat* nextColorArray = stops[nextStopIndex].colorArray;
- CGFloat* previousColorArray = stops[nextStopIndex - 1].colorArray;
- CGFloat diffFromPrevious = inValue - stops[nextStopIndex - 1].offset;
- CGFloat percent = diffFromPrevious * stops[nextStopIndex].previousDeltaInverse;
-
- outColor[0] = ((1.0f - percent) * previousColorArray[0] + percent * nextColorArray[0]);
- outColor[1] = ((1.0f - percent) * previousColorArray[1] + percent * nextColorArray[1]);
- outColor[2] = ((1.0f - percent) * previousColorArray[2] + percent * nextColorArray[2]);
- outColor[3] = ((1.0f - percent) * previousColorArray[3] + percent * nextColorArray[3]);
- }
- // FIXME: have to handle the spreadMethod()s here SPREADMETHOD_REPEAT, etc.
-}
-
-static CGShadingRef CGShadingRefForLinearGradient(const SVGPaintServerLinearGradient* server)
-{
- CGPoint start = CGPoint(server->gradientStart());
- CGPoint end = CGPoint(server->gradientEnd());
-
- CGFunctionCallbacks callbacks = {0, cgGradientCallback, releaseCachedStops};
- CGFloat domainLimits[2] = {0, 1};
- CGFloat rangeLimits[8] = {0, 1, 0, 1, 0, 1, 0, 1};
- server->m_stopsCache->ref();
- CGFunctionRef shadingFunction = CGFunctionCreate(server->m_stopsCache.get(), 1, domainLimits, 4, rangeLimits, &callbacks);
-
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
- CGShadingRef shading = CGShadingCreateAxial(colorSpace, start, end, shadingFunction, true, true);
- CGColorSpaceRelease(colorSpace);
- CGFunctionRelease(shadingFunction);
- return shading;
-}
-
-static CGShadingRef CGShadingRefForRadialGradient(const SVGPaintServerRadialGradient* server)
-{
- CGPoint center = CGPoint(server->gradientCenter());
- CGPoint focus = CGPoint(server->gradientFocal());
- double radius = server->gradientRadius();
-
- double fdx = focus.x - center.x;
- double fdy = focus.y - center.y;
-
- // Spec: If (fx, fy) lies outside the circle defined by (cx, cy) and r, set (fx, fy)
- // to the point of intersection of the line through (fx, fy) and the circle.
- if (sqrt(fdx * fdx + fdy * fdy) > radius) {
- double angle = atan2(focus.y * 100.0, focus.x * 100.0);
- focus.x = narrowPrecisionToCGFloat(cos(angle) * radius);
- focus.y = narrowPrecisionToCGFloat(sin(angle) * radius);
- }
-
- CGFunctionCallbacks callbacks = {0, cgGradientCallback, releaseCachedStops};
- CGFloat domainLimits[2] = {0, 1};
- CGFloat rangeLimits[8] = {0, 1, 0, 1, 0, 1, 0, 1};
- server->m_stopsCache->ref();
- CGFunctionRef shadingFunction = CGFunctionCreate(server->m_stopsCache.get(), 1, domainLimits, 4, rangeLimits, &callbacks);
-
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
- CGShadingRef shading = CGShadingCreateRadial(colorSpace, focus, 0, center, narrowPrecisionToCGFloat(radius), shadingFunction, true, true);
- CGColorSpaceRelease(colorSpace);
- CGFunctionRelease(shadingFunction);
- return shading;
-}
-
-void SVGPaintServerGradient::updateQuartzGradientStopsCache(const Vector<SVGGradientStop>& stops)
-{
- m_stopsCache = SharedStopCache::create();
- Vector<QuartzGradientStop>& stopsCache = m_stopsCache->m_stops;
- stopsCache.resize(stops.size());
- CGFloat previousOffset = 0.0f;
- for (unsigned i = 0; i < stops.size(); ++i) {
- CGFloat currOffset = min(max(stops[i].first, previousOffset), static_cast<CGFloat>(1.0));
- stopsCache[i].offset = currOffset;
- stopsCache[i].previousDeltaInverse = 1.0f / (currOffset - previousOffset);
- previousOffset = currOffset;
- CGFloat* ca = stopsCache[i].colorArray;
- stops[i].second.getRGBA(ca[0], ca[1], ca[2], ca[3]);
- }
-}
-
-void SVGPaintServerGradient::updateQuartzGradientCache(const SVGPaintServerGradient* server)
-{
- // cache our own copy of the stops for faster access.
- // this is legacy code, probably could be reworked.
- if (!m_stopsCache)
- updateQuartzGradientStopsCache(gradientStops());
-
- CGShadingRelease(m_shadingCache);
-
- if (type() == RadialGradientPaintServer) {
- const SVGPaintServerRadialGradient* radial = static_cast<const SVGPaintServerRadialGradient*>(server);
- m_shadingCache = CGShadingRefForRadialGradient(radial);
- } else if (type() == LinearGradientPaintServer) {
- const SVGPaintServerLinearGradient* linear = static_cast<const SVGPaintServerLinearGradient*>(server);
- m_shadingCache = CGShadingRefForLinearGradient(linear);
- }
-}
-
-// Helper function for text painting
-static inline const RenderObject* findTextRootObject(const RenderObject* start)
-{
- while (start && !start->isSVGText())
- start = start->parent();
-
- ASSERT(start);
- ASSERT(start->isSVGText());
-
- return start;
-}
-
-void SVGPaintServerGradient::teardown(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
-{
- CGShadingRef shading = m_shadingCache;
- CGContextRef contextRef = context->platformContext();
- ASSERT(contextRef);
-
- // As renderPath() is not used when painting text, special logic needed here.
- if (isPaintingText) {
- if (m_savedContext) {
- FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->relativeBBox(false);
-
- // Fixup transformations to be able to clip to mask
- AffineTransform transform = object->absoluteTransform();
- FloatRect textBoundary = transform.mapRect(maskBBox);
-
- IntSize maskSize(lroundf(textBoundary.width()), lroundf(textBoundary.height()));
- clampImageBufferSizeToViewport(object->document()->renderer(), maskSize);
-
- if (maskSize.width() < static_cast<int>(textBoundary.width()))
- textBoundary.setWidth(maskSize.width());
-
- if (maskSize.height() < static_cast<int>(textBoundary.height()))
- textBoundary.setHeight(maskSize.height());
-
- // Clip current context to mask image (gradient)
- m_savedContext->concatCTM(transform.inverse());
- m_savedContext->clipToImageBuffer(textBoundary, m_imageBuffer);
- m_savedContext->concatCTM(transform);
-
- handleBoundingBoxModeAndGradientTransformation(m_savedContext, maskBBox);
-
- // Restore on-screen drawing context, after we got the image of the gradient
- delete m_imageBuffer;
-
- context = m_savedContext;
- contextRef = context->platformContext();
-
- m_savedContext = 0;
- m_imageBuffer = 0;
- }
- }
-
- CGContextDrawShading(contextRef, shading);
- context->restore();
-}
-
-void SVGPaintServerGradient::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
-{
- RenderStyle* style = path->style();
- CGContextRef contextRef = context->platformContext();
- ASSERT(contextRef);
-
- bool isFilled = (type & ApplyToFillTargetType) && style->svgStyle()->hasFill();
-
- // Compute destination object bounding box
- FloatRect objectBBox;
- if (boundingBoxMode()) {
- FloatRect bbox = path->relativeBBox(false);
- if (bbox.width() > 0 && bbox.height() > 0)
- objectBBox = bbox;
- }
-
- if (isFilled)
- clipToFillPath(contextRef, path);
- else
- clipToStrokePath(contextRef, path);
-
- handleBoundingBoxModeAndGradientTransformation(context, objectBBox);
-}
-
-void SVGPaintServerGradient::handleBoundingBoxModeAndGradientTransformation(GraphicsContext* context, const FloatRect& targetRect) const
-{
- if (boundingBoxMode()) {
- // Choose default gradient bounding box
- FloatRect gradientBBox(0.0f, 0.0f, 1.0f, 1.0f);
-
- // Generate a transform to map between both bounding boxes
- context->concatCTM(makeMapBetweenRects(gradientBBox, targetRect));
- }
-
- // Apply the gradient's own transform
- context->concatCTM(gradientTransform());
-}
-
-bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
-{
- m_ownerElement->buildGradient();
-
- // We need a hook to call this when the gradient gets updated, before drawn.
- if (!m_shadingCache)
- const_cast<SVGPaintServerGradient*>(this)->updateQuartzGradientCache(this);
-
- CGContextRef contextRef = context->platformContext();
- ASSERT(contextRef);
-
- RenderStyle* style = object->style();
-
- bool isFilled = (type & ApplyToFillTargetType) && style->svgStyle()->hasFill();
- bool isStroked = (type & ApplyToStrokeTargetType) && style->svgStyle()->hasStroke();
-
- ASSERT(isFilled && !isStroked || !isFilled && isStroked);
-
- context->save();
- CGContextSetAlpha(contextRef, isFilled ? style->svgStyle()->fillOpacity() : style->svgStyle()->strokeOpacity());
-
- if (isPaintingText) {
- FloatRect maskBBox = const_cast<RenderObject*>(findTextRootObject(object))->relativeBBox(false);
- IntRect maskRect = enclosingIntRect(object->absoluteTransform().mapRect(maskBBox));
-
- IntSize maskSize(maskRect.width(), maskRect.height());
- clampImageBufferSizeToViewport(object->document()->renderer(), maskSize);
-
- auto_ptr<ImageBuffer> maskImage = ImageBuffer::create(maskSize, false);
-
- if (!maskImage.get()) {
- context->restore();
- return false;
- }
-
- GraphicsContext* maskImageContext = maskImage->context();
- maskImageContext->save();
-
- maskImageContext->setTextDrawingMode(isFilled ? cTextFill : cTextStroke);
- maskImageContext->translate(-maskRect.x(), -maskRect.y());
- maskImageContext->concatCTM(object->absoluteTransform());
-
- m_imageBuffer = maskImage.release();
- m_savedContext = context;
-
- context = maskImageContext;
- contextRef = context->platformContext();
- }
-
- if (isStroked)
- applyStrokeStyleToContext(context, style, object);
-
- return true;
-}
-
-void SVGPaintServerGradient::invalidate()
-{
- SVGPaintServer::invalidate();
-
- // Invalidate caches
- CGShadingRelease(m_shadingCache);
-
- m_stopsCache = 0;
- m_shadingCache = 0;
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp b/WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp
deleted file mode 100644
index 416d5fe..0000000
--- a/WebCore/svg/graphics/cg/SVGPaintServerPatternCg.cpp
+++ /dev/null
@@ -1,130 +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)
-#include "SVGPaintServerPattern.h"
-
-#include "CgSupport.h"
-#include "GraphicsContext.h"
-#include "ImageBuffer.h"
-#include "RenderObject.h"
-#include "SVGPatternElement.h"
-
-namespace WebCore {
-
-static void patternCallback(void* info, CGContextRef context)
-{
- ImageBuffer* patternImage = reinterpret_cast<ImageBuffer*>(info);
- 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
-{
- CGContextRef contextRef = context->platformContext();
-
- // Build pattern tile, passing destination object bounding box
- FloatRect targetRect;
- if (isPaintingText) {
- IntRect textBoundary = const_cast<RenderObject*>(object)->absoluteBoundingBoxRect();
- targetRect = object->absoluteTransform().inverse().mapRect(textBoundary);
- } else
- targetRect = object->relativeBBox(false);
-
- m_ownerElement->buildPattern(targetRect);
-
- if (!tile())
- return false;
-
- context->save();
-
- // Respect local pattern transformation
- context->concatCTM(patternTransform());
-
- // Apply pattern space transformation
- context->translate(patternBoundaries().x(), patternBoundaries().y());
-
- // Crude hack to support overflow="visible".
- // When the patternBoundaries() size is smaller than the actual tile() size, we run into a problem:
- // Our tile contains content which is larger than the pattern cell size. We just draw the pattern
- // "out of" cell boundaries, to draw the overflown content, instead of clipping it away. The uppermost
- // cell doesn't include the overflown content of the cell right above it though -> that's why we're moving
- // down the phase by a very small amount, so we're sure the "cell right above"'s overflown content gets drawn.
- CGContextSetPatternPhase(contextRef, CGSizeMake(0.0f, -0.01f));
-
- RenderStyle* style = object->style();
- CGContextSetAlpha(contextRef, style->opacity());
-
- CGPatternCallbacks callbacks = {0, patternCallback, 0};
-
- ASSERT(!m_pattern);
- m_pattern = CGPatternCreate(tile(),
- CGRect(FloatRect(FloatPoint(), tile()->size())),
- CGContextGetCTM(contextRef),
- patternBoundaries().width(),
- patternBoundaries().height(),
- kCGPatternTilingConstantSpacing,
- true, // has color
- &callbacks);
-
- if (!m_patternSpace)
- m_patternSpace = CGColorSpaceCreatePattern(0);
-
- if ((type & ApplyToFillTargetType) && style->svgStyle()->hasFill()) {
- CGFloat alpha = style->svgStyle()->fillOpacity();
- CGContextSetFillColorSpace(contextRef, m_patternSpace);
- CGContextSetFillPattern(contextRef, m_pattern, &alpha);
-
- if (isPaintingText)
- context->setTextDrawingMode(cTextFill);
- }
-
- if ((type & ApplyToStrokeTargetType) && style->svgStyle()->hasStroke()) {
- CGFloat alpha = style->svgStyle()->strokeOpacity();
- CGContextSetStrokeColorSpace(contextRef, m_patternSpace);
- CGContextSetStrokePattern(contextRef, m_pattern, &alpha);
- applyStrokeStyleToContext(context, style, object);
-
- if (isPaintingText)
- context->setTextDrawingMode(cTextStroke);
- }
-
- return true;
-}
-
-void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const
-{
- CGPatternRelease(m_pattern);
- m_pattern = 0;
-
- context->restore();
-}
-
-} // namespace WebCore
-
-#endif
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp b/WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp
deleted file mode 100644
index bd2a56f..0000000
--- a/WebCore/svg/graphics/cg/SVGPaintServerSolidCg.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
-
- This file is part of the KDE project
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerSolid.h"
-
-#include "Color.h"
-#include "CgSupport.h"
-#include "GraphicsContext.h"
-#include "RenderObject.h"
-
-namespace WebCore {
-
-bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
-{
- // 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"
-
- RenderStyle* style = object ? object->style() : 0;
-
- if ((type & ApplyToFillTargetType) && (!style || style->svgStyle()->hasFill())) {
- RGBA32 rgba = color().rgb();
- ASSERT(!color().hasAlpha());
- if (style)
- rgba = colorWithOverrideAlpha(rgba, style->svgStyle()->fillOpacity());
-
- context->setFillColor(rgba);
-
- if (isPaintingText)
- context->setTextDrawingMode(cTextFill);
- }
-
- if ((type & ApplyToStrokeTargetType) && (!style || style->svgStyle()->hasStroke())) {
- RGBA32 rgba = color().rgb();
- ASSERT(!color().hasAlpha());
- if (style)
- rgba = colorWithOverrideAlpha(rgba, style->svgStyle()->strokeOpacity());
-
- context->setStrokeColor(rgba);
-
- if (style)
- applyStrokeStyleToContext(context, style, object);
-
- if (isPaintingText)
- context->setTextDrawingMode(cTextStroke);
- }
-
- return true;
-}
-
-} // namespace WebCore
-
-#endif
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp b/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp
deleted file mode 100644
index b04a0dc..0000000
--- a/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
- * 2005 Alexander Kellett <lypanov@kde.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.
- */
-
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGResourceClipper.h"
-
-#include "AffineTransform.h"
-#include "GraphicsContext.h"
-
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
-void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
-{
- if (m_clipData.clipData().size() < 1)
- return;
-
- bool heterogenousClipRules = false;
- WindRule clipRule = m_clipData.clipData()[0].windRule;
-
- context->beginPath();
-
- 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;
-
- 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.
- // we would have to detect such, draw to a mask, and then clip
- // to that mask
- if (!CGContextIsPathEmpty(cgContext)) {
- if (clipRule == RULE_EVENODD)
- CGContextEOClip(cgContext);
- else
- CGContextClip(cgContext);
- }
- }
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG)
diff --git a/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm b/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm
index f3dc819..a89ec1d 100644
--- a/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm
+++ b/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm
@@ -29,8 +29,7 @@
#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
#include "SVGResourceFilter.h"
-#include "AffineTransform.h"
-#include "FoundationExtras.h"
+#include "TransformationMatrix.h"
#include "GraphicsContext.h"
#include "SVGResourceFilterPlatformDataMac.h"
@@ -63,7 +62,7 @@ void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const FloatRect
// <http://bugs.webkit.org/show_bug.cgi?id=6947>
// <rdar://problem/4647735>
NSAutoreleasePool* filterContextPool = [[NSAutoreleasePool alloc] init];
- platform->m_filterCIContext = HardRetain([CIContext contextWithCGContext:cgContext options:nil]);
+ platform->m_filterCIContext = [CIContext contextWithCGContext:cgContext options:nil];
[filterContextPool drain];
FloatRect filterRect = filterBBoxForItemBBox(bbox);
@@ -73,7 +72,7 @@ void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const FloatRect
float width = filterRect.width();
float height = filterRect.height();
- platform->m_filterCGLayer = [platform->m_filterCIContext createCGLayerWithSize:CGSizeMake(width, height) info:NULL];
+ platform->m_filterCGLayer = [platform->m_filterCIContext.get() createCGLayerWithSize:CGSizeMake(width, height) info:NULL];
context = new GraphicsContext(CGLayerGetContext(platform->m_filterCGLayer));
context->save();
@@ -126,14 +125,13 @@ void SVGResourceFilter::applyFilter(GraphicsContext*& context, const FloatRect&
FloatPoint destOrigin = filterRect.location();
filterRect.setLocation(FloatPoint(0.0f, 0.0f));
- [platform->m_filterCIContext drawImage:outputImage atPoint:CGPoint(destOrigin) fromRect:filterRect];
+ [platform->m_filterCIContext.get() drawImage:outputImage atPoint:CGPoint(destOrigin) fromRect:filterRect];
}
}
CGLayerRelease(platform->m_filterCGLayer);
platform->m_filterCGLayer = 0;
- HardRelease(platform->m_filterCIContext);
platform->m_filterCIContext = 0;
delete context;
diff --git a/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm
index f867f9c..9793ba0 100644
--- a/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm
+++ b/WebCore/svg/graphics/cg/SVGResourceMaskerCg.mm
@@ -30,7 +30,6 @@
#import "SVGResourceMasker.h"
#import "BlockExceptions.h"
-#import "CgSupport.h"
#import "GraphicsContext.h"
#import "ImageBuffer.h"
#import "SVGMaskElement.h"
diff --git a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m
index ecfed53..6582f9f 100644
--- a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m
+++ b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m
@@ -77,4 +77,4 @@ static CIKernel *linearTransferFilter = nil;
@end
-#endif ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h
index 1b76f2b..cce9e06 100644
--- a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h
+++ b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h
@@ -39,4 +39,4 @@
}
@end
-#endif ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h
index 3236ee5..54f8237 100644
--- a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h
+++ b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h
@@ -53,7 +53,7 @@ namespace WebCore {
NSArray* getCIFilterStack(CIImage* inputImage, const FloatRect& bbox);
- CIContext* m_filterCIContext;
+ RetainPtr<CIContext> m_filterCIContext;
CGLayerRef m_filterCGLayer;
RetainPtr<NSMutableDictionary> m_imagesByName;
SVGResourceFilter* m_filter;
diff --git a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm
index c031bbc..225c649 100644
--- a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm
+++ b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm
@@ -34,8 +34,7 @@ namespace WebCore {
static const char* const SVGPreviousFilterOutputName = "__previousOutput__";
SVGResourceFilterPlatformDataMac::SVGResourceFilterPlatformDataMac(SVGResourceFilter* filter)
- : m_filterCIContext(0)
- , m_filterCGLayer(0)
+ : m_filterCGLayer(0)
, m_imagesByName(AdoptNS, [[NSMutableDictionary alloc] init])
, m_filter(filter)
{
diff --git a/WebCore/svg/graphics/qt/RenderPathQt.cpp b/WebCore/svg/graphics/qt/RenderPathQt.cpp
deleted file mode 100644
index 8bee8b8..0000000
--- a/WebCore/svg/graphics/qt/RenderPathQt.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
- 2004, 2005, 2006 Rob Buis <buis@kde.org>
- 2005 Eric Seidel <eric.seidel@kdemail.net>
-
- This file is part of the KDE project
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "RenderPath.h"
-#include "SVGRenderStyle.h"
-#include "SVGPaintServer.h"
-
-#include <QDebug>
-#include <QPainterPathStroker>
-
-namespace WebCore {
-
-bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const
-{
- if (path().isEmpty())
- return false;
-
- if (requiresStroke && !SVGPaintServer::strokePaintServer(style(), this))
- return false;
-
- return false;
-}
-
-static QPainterPath getPathStroke(const QPainterPath &path, const RenderObject* object, const RenderStyle* style)
-{
- QPainterPathStroker s;
- s.setWidth(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0));
-
- if (style->svgStyle()->capStyle() == ButtCap)
- s.setCapStyle(Qt::FlatCap);
- else if (style->svgStyle()->capStyle() == RoundCap)
- s.setCapStyle(Qt::RoundCap);
-
- if (style->svgStyle()->joinStyle() == MiterJoin) {
- s.setJoinStyle(Qt::MiterJoin);
- s.setMiterLimit((qreal) style->svgStyle()->strokeMiterLimit());
- } else if(style->svgStyle()->joinStyle() == RoundJoin)
- s.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)s.width());
-
- s.setDashPattern(pattern);
-
- Q_UNUSED(dashOffset);
- // TODO: dash-offset, does/will qt4 API allow it? (Rob)
- }
-
- return s.createStroke(path);
-}
-
-FloatRect RenderPath::strokeBBox() const
-{
- QPainterPath outline = getPathStroke(*(path().platformPath()), this, style());
- return outline.boundingRect();
-}
-
-}
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp
deleted file mode 100644
index 113f9a7..0000000
--- a/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
-
- This file is part of the KDE project
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerGradient.h"
-
-#include "GraphicsContext.h"
-#include "RenderObject.h"
-#include "RenderStyle.h"
-#include "SVGGradientElement.h"
-
-#include <QPainter>
-#include <QPainterPath>
-#include <QColor>
-#include <QGradient>
-
-namespace WebCore {
-
-// Helper function used by linear & radial gradient
-void SVGPaintServerGradient::fillColorArray(QGradient& gradient, const Vector<SVGGradientStop>& stops,
- float opacity) const
-{
- for (unsigned i = 0; i < stops.size(); ++i) {
- float offset = stops[i].first;
- Color color = stops[i].second;
-
- QColor c(color.red(), color.green(), color.blue());
- c.setAlpha(int(color.alpha() * opacity));
-
- gradient.setColorAt(offset, c);
- }
-}
-
-bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object,
- SVGPaintTargetType type, bool isPaintingText) const
-{
- m_ownerElement->buildGradient();
-
- QPainter* painter(context ? context->platformContext() : 0);
- Q_ASSERT(painter);
-
- QPainterPath* path(context ? context->currentPath() : 0);
- Q_ASSERT(path);
-
- 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() == SpreadMethodRepeat)
- gradient.setSpread(QGradient::RepeatSpread);
- else if (spreadMethod() == SpreadMethodReflect)
- gradient.setSpread(QGradient::ReflectSpread);
- else
- gradient.setSpread(QGradient::PadSpread);
- double opacity = 1.0;
-
- if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) {
- fillColorArray(gradient, gradientStops(), opacity);
-
- QBrush brush(gradient);
- brush.setMatrix(gradientTransform());
-
- painter->setBrush(brush);
- context->setFillRule(svgStyle->fillRule());
- }
-
- if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
- fillColorArray(gradient, gradientStops(), opacity);
-
- QPen pen;
- QBrush brush(gradient);
- brush.setMatrix(gradientTransform());
- pen.setBrush(brush);
- painter->setPen(pen);
-
- applyStrokeStyleToContext(context, style, object);
- }
-
- return true;
-}
-
-} // namespace WebCore
-
-#endif
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp
deleted file mode 100644
index 69934ab..0000000
--- a/WebCore/svg/graphics/qt/SVGPaintServerLinearGradientQt.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
-
- This file is part of the KDE project
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerLinearGradient.h"
-#include "SVGGradientElement.h"
-
-#include "GraphicsContext.h"
-#include "RenderPath.h"
-
-#include <QLinearGradient>
-#include <QPainter>
-#include <QPainterPath>
-
-namespace WebCore {
-
-QGradient SVGPaintServerLinearGradient::setupGradient(GraphicsContext*& context, const RenderObject* object) const
-{
- QPainterPath* path(context ? context->currentPath() : 0);
- Q_ASSERT(path);
-
- double x1, x2, y1, y2;
- if (boundingBoxMode()) {
- QRectF bbox = path->boundingRect();
- x1 = bbox.x();
- y1 = bbox.y();
- x2 = bbox.x() + bbox.width();
- y2 = bbox.y() + bbox.height();
- } else {
- x1 = gradientStart().x();
- y1 = gradientStart().y();
- x2 = gradientEnd().x();
- y2 = gradientEnd().y();
- }
-
- QLinearGradient gradient(QPointF(x1, y1), QPointF(x2, y2));
-
- return gradient;
-}
-
-} // namespace WebCore
-
-#endif
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp
deleted file mode 100644
index 70ec14c..0000000
--- a/WebCore/svg/graphics/qt/SVGPaintServerPatternQt.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
- Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerPattern.h"
-
-#include "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
-{
- Q_ASSERT(context);
- Q_ASSERT(object);
-
- FloatRect targetRect = object->relativeBBox(false);
- m_ownerElement->buildPattern(targetRect);
-
- if (!tile())
- return false;
-
- QPainter* painter = context->platformContext();
- QPainterPath* path = context->currentPath();
-
- RenderStyle* style = object->style();
- const SVGRenderStyle* svgStyle = object->style()->svgStyle();
-
- RefPtr<Pattern> pattern = Pattern::create(tile()->image(), true, true);
-
- context->save();
- painter->setPen(Qt::NoPen);
- painter->setBrush(Qt::NoBrush);
-
- 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 & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
- QPen pen;
- pen.setBrush(brush);
- painter->setPen(pen);
- applyStrokeStyleToContext(context, style, object);
- }
-
- return true;
-}
-
-void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const
-{
- context->restore();
-}
-
-} // namespace WebCore
-
-#endif
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
deleted file mode 100644
index 801201b..0000000
--- a/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
- Copyright (C) 2008 Holger Hans Peter Freyther
-
- This file is part of the KDE project
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServer.h"
-
-#include "GraphicsContext.h"
-#include "SVGRenderStyle.h"
-#include "RenderObject.h"
-
-#include <QPainter>
-#include <QVector>
-
-namespace WebCore {
-
-void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
-{
- if (!setup(context, path, type))
- return;
-
- renderPath(context, path, type);
- teardown(context, path, type);
-}
-
-void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const
-{
- // no-op
-}
-
-void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
-{
- RenderStyle* renderStyle = path ? path->style(): 0;
-
- QPainter* painter(context ? context->platformContext() : 0);
- Q_ASSERT(painter);
-
- QPainterPath* painterPath(context ? context->currentPath() : 0);
- Q_ASSERT(painterPath);
-
- if ((type & ApplyToFillTargetType) && (!renderStyle || renderStyle->svgStyle()->hasFill()))
- painter->fillPath(*painterPath, painter->brush());
-
- if ((type & ApplyToStrokeTargetType) && (!renderStyle || renderStyle->svgStyle()->hasStroke()))
- painter->strokePath(*painterPath, painter->pen());
-}
-
-} // namespace WebCore
-
-#endif
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp
deleted file mode 100644
index 95d71a3..0000000
--- a/WebCore/svg/graphics/qt/SVGPaintServerRadialGradientQt.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
-
- This file is part of the KDE project
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerRadialGradient.h"
-
-#include "GraphicsContext.h"
-#include "RenderPath.h"
-
-#include <math.h>
-#include <QPainter>
-#include <QPainterPath>
-#include <QRadialGradient>
-
-namespace WebCore {
-
-QGradient SVGPaintServerRadialGradient::setupGradient(GraphicsContext*& context, const RenderObject* object) const
-{
- QPainter* painter(context ? context->platformContext() : 0);
- Q_ASSERT(painter);
-
- QPainterPath* path(context ? context->currentPath() : 0);
- Q_ASSERT(path);
-
- RenderStyle* renderStyle = object->style();
-
- QMatrix mat = painter->matrix();
-
- double cx, fx, cy, fy, r;
- if (boundingBoxMode()) {
- QRectF bbox = path->boundingRect();
- cx = double(bbox.left()) + (double(gradientCenter().x() / 100.0) * double(bbox.width()));
- cy = double(bbox.top()) + (double(gradientCenter().y() / 100.0) * double(bbox.height()));
- fx = double(bbox.left()) + (double(gradientFocal().x() / 100.0) * double(bbox.width())) - cx;
- fy = double(bbox.top()) + (double(gradientFocal().y() / 100.0) * double(bbox.height())) - cy;
- r = double(gradientRadius() / 100.0) * (sqrt(pow(bbox.width(), 2) + pow(bbox.height(), 2)));
-
- float width = bbox.width();
- float height = bbox.height();
-
- int diff = int(width - height); // allow slight tolerance
- if (!(diff > -2 && diff < 2)) {
- // make elliptical or circular depending on bbox aspect ratio
- float ratioX = (width / height);
- float ratioY = (height / width);
- mat.scale((width > height) ? 1 : ratioX, (width > height) ? ratioY : 1);
- }
- } else {
- cx = gradientCenter().x();
- cy = gradientCenter().y();
-
- fx = gradientFocal().x();
- fy = gradientFocal().y();
-
- fx -= cx;
- fy -= cy;
-
- r = gradientRadius();
- }
-
- if (sqrt(fx * fx + fy * fy) > r) {
- // Spec: If (fx, fy) lies outside the circle defined by (cx, cy) and r, set (fx, fy)
- // to the point of intersection of the line through (fx, fy) and the circle.
- double angle = atan2(fy, fx);
- fx = int(cos(angle) * r) - 1;
- fy = int(sin(angle) * r) - 1;
- }
-
- QRadialGradient gradient(QPointF(cx, cy), gradientRadius(), QPointF(fx + cx, fy + cy));
-
- return gradient;
-}
-
-} // namespace WebCore
-
-#endif
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp b/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
deleted file mode 100644
index e088df2..0000000
--- a/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org>
- Copyright (C) 2008 Holger Hans Peter Freyther
-
- This file is part of the KDE project
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGPaintServerSolid.h"
-
-#include "GraphicsContext.h"
-#include "RenderPath.h"
-
-#include <QPainter>
-
-namespace WebCore {
-
-bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
-{
- QPainter* painter(context ? context->platformContext() : 0);
- Q_ASSERT(painter);
-
- const SVGRenderStyle* svgStyle = object->style()->svgStyle();
- RenderStyle* style = object ? object->style() : 0;
- // TODO? painter->setOpacity(renderStyle->opacity());
-
- QColor c = color();
-
- if ((type & ApplyToFillTargetType) && (!style || svgStyle->hasFill())) {
- if (style)
- c.setAlphaF(svgStyle->fillOpacity());
-
- QBrush brush(c);
- painter->setBrush(brush);
-
- if (style)
- context->setFillRule(svgStyle->fillRule());
-
- /* if(isPaintingText()) ... */
- }
-
- if ((type & ApplyToStrokeTargetType) && (!style || svgStyle->hasStroke())) {
- if (style)
- c.setAlphaF(svgStyle->strokeOpacity());
-
- QPen pen(c);
- painter->setPen(pen);
- if (style)
- applyStrokeStyleToContext(context, style, object);
-
- /* if(isPaintingText()) ... */
- }
-
- return true;
-}
-
-} // namespace WebCore
-
-#endif
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp b/WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp
deleted file mode 100644
index 42d3855..0000000
--- a/WebCore/svg/graphics/qt/SVGResourceClipperQt.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
- 2004, 2005, 2006 Rob Buis <buis@kde.org>
- 2005 Apple Computer, Inc.
-
- This file is part of the KDE project
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include "SVGResourceClipper.h"
-
-#include "GraphicsContext.h"
-
-#include <QPainter>
-#include <QPainterPath>
-
-namespace WebCore {
-
-void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
-{
- if (m_clipData.clipData().size() < 1)
- return;
-
- context->beginPath();
-
- QPainterPath newPath;
-
- bool heterogenousClipRules = false;
- WindRule clipRule = m_clipData.clipData()[0].windRule;
-
- unsigned int clipDataCount = m_clipData.clipData().size();
- for (unsigned int x = 0; x < clipDataCount; x++) {
- ClipData clipData = m_clipData.clipData()[x];
- if (clipData.windRule != clipRule)
- heterogenousClipRules = true;
-
- QPainterPath path = *(clipData.path.platformPath());
- if (path.isEmpty())
- continue;
-
- if (!newPath.isEmpty())
- newPath.closeSubpath();
-
- // Respect clipping units...
- QMatrix transform;
-
- if (clipData.bboxUnits) {
- transform.translate(boundingBox.x(), boundingBox.y());
- transform.scale(boundingBox.width(), boundingBox.height());
- }
-
- // TODO: support heterogenous clip rules!
- //clipRule = (clipData.windRule() == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
-
- for (int i = 0; i < path.elementCount(); ++i) {
- const QPainterPath::Element &cur = path.elementAt(i);
-
- switch (cur.type) {
- case QPainterPath::MoveToElement:
- newPath.moveTo(QPointF(cur.x, cur.y) * transform);
- break;
- case QPainterPath::LineToElement:
- newPath.lineTo(QPointF(cur.x, cur.y) * transform);
- break;
- case QPainterPath::CurveToElement:
- {
- const QPainterPath::Element &c1 = path.elementAt(i + 1);
- const QPainterPath::Element &c2 = path.elementAt(i + 2);
-
- Q_ASSERT(c1.type == QPainterPath::CurveToDataElement);
- Q_ASSERT(c2.type == QPainterPath::CurveToDataElement);
-
- newPath.cubicTo(QPointF(cur.x, cur.y) * transform,
- QPointF(c1.x, c1.y) * transform,
- QPointF(c2.x, c2.y) * transform);
-
- i += 2;
- break;
- }
- case QPainterPath::CurveToDataElement:
- Q_ASSERT(false);
- break;
- }
- }
- }
-
- if (m_clipData.clipData().size()) {
- // FIXME!
- // We don't currently allow for heterogenous clip rules.
- // we would have to detect such, draw to a mask, and then clip
- // to that mask
- // if (!CGContextIsPathEmpty(cgContext)) {
- if (clipRule == RULE_EVENODD)
- newPath.setFillRule(Qt::OddEvenFill);
- else
- newPath.setFillRule(Qt::WindingFill);
- // }
- }
-
- QPainter* painter(context ? context->platformContext() : 0);
- Q_ASSERT(painter);
-
- painter->setClipPath(newPath);
-}
-
-} // namespace WebCore
-
-#endif
-
-// vim:ts=4:noet
diff --git a/WebCore/svg/graphics/skia/SVGResourceFilterSkia.cpp b/WebCore/svg/graphics/skia/SVGResourceFilterSkia.cpp
new file mode 100644
index 0000000..b54eb4b
--- /dev/null
+++ b/WebCore/svg/graphics/skia/SVGResourceFilterSkia.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2008, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "NotImplemented.h"
+#include "SVGResourceFilter.h"
+
+namespace WebCore {
+
+SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData()
+{
+ return 0;
+}
+
+void SVGResourceFilter::prepareFilter(GraphicsContext*&, const FloatRect&)
+{
+ notImplemented();
+}
+
+void SVGResourceFilter::applyFilter(GraphicsContext*&, const FloatRect&)
+{
+ notImplemented();
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/skia/SVGResourceMaskerSkia.cpp b/WebCore/svg/graphics/skia/SVGResourceMaskerSkia.cpp
new file mode 100644
index 0000000..06e6833
--- /dev/null
+++ b/WebCore/svg/graphics/skia/SVGResourceMaskerSkia.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2008, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "SVGResourceMasker.h"
+#include "ImageBuffer.h"
+#include "GraphicsContext.h"
+
+#include "NotImplemented.h"
+
+namespace WebCore {
+
+void SVGResourceMasker::applyMask(GraphicsContext*, const FloatRect& boundingBox)
+{
+ notImplemented();
+}
+
+} // namespace WebCore
+
+#endif